rename src/nepi/ into just nepi/
[nepi.git] / nepi / resources / ns3 / classes / yans_wifi_phy.py
1 #
2 #    NEPI, a framework to manage network experiments
3 #    Copyright (C) 2014 INRIA
4 #
5 #    This program is free software: you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License version 2 as
7 #    published by the Free Software Foundation;
8 #
9 #    This program is distributed in the hope that it will be useful,
10 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #    GNU General Public License for more details.
13 #
14 #    You should have received a copy of the GNU General Public License
15 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17
18 from nepi.execution.attribute import Attribute, Flags, Types
19 from nepi.execution.trace import Trace, TraceAttr
20 from nepi.execution.resource import ResourceManager, clsinit_copy, \
21         ResourceState
22 from nepi.resources.ns3.ns3wifiphy import NS3BaseWifiPhy 
23
24 @clsinit_copy
25 class NS3YansWifiPhy(NS3BaseWifiPhy):
26     _rtype = "ns3::YansWifiPhy"
27
28     @classmethod
29     def _register_attributes(cls):
30         
31         attr_energydetectionthreshold = Attribute("EnergyDetectionThreshold",
32             "The energy of a received signal should be higher than this threshold (dbm) to allow the PHY layer to detect the signal.",
33             type = Types.Double,
34             default = "-96",  
35             allowed = None,
36             range = None,    
37             flags = Flags.Reserved | Flags.Construct)
38
39         cls._register_attribute(attr_energydetectionthreshold)
40
41         attr_ccamode1threshold = Attribute("CcaMode1Threshold",
42             "The energy of a received signal should be higher than this threshold (dbm) to allow the PHY layer to declare CCA BUSY state",
43             type = Types.Double,
44             default = "-99",  
45             allowed = None,
46             range = None,    
47             flags = Flags.Reserved | Flags.Construct)
48
49         cls._register_attribute(attr_ccamode1threshold)
50
51         attr_txgain = Attribute("TxGain",
52             "Transmission gain (dB).",
53             type = Types.Double,
54             default = "1",  
55             allowed = None,
56             range = None,    
57             flags = Flags.Reserved | Flags.Construct)
58
59         cls._register_attribute(attr_txgain)
60
61         attr_rxgain = Attribute("RxGain",
62             "Reception gain (dB).",
63             type = Types.Double,
64             default = "1",  
65             allowed = None,
66             range = None,    
67             flags = Flags.Reserved | Flags.Construct)
68
69         cls._register_attribute(attr_rxgain)
70
71         attr_txpowerlevels = Attribute("TxPowerLevels",
72             "Number of transmission power levels available between TxPowerStart and TxPowerEnd included.",
73             type = Types.Integer,
74             default = "1",  
75             allowed = None,
76             range = None,    
77             flags = Flags.Reserved | Flags.Construct)
78
79         cls._register_attribute(attr_txpowerlevels)
80
81         attr_txpowerend = Attribute("TxPowerEnd",
82             "Maximum available transmission level (dbm).",
83             type = Types.Double,
84             default = "16.0206",  
85             allowed = None,
86             range = None,    
87             flags = Flags.Reserved | Flags.Construct)
88
89         cls._register_attribute(attr_txpowerend)
90
91         attr_txpowerstart = Attribute("TxPowerStart",
92             "Minimum available transmission level (dbm).",
93             type = Types.Double,
94             default = "16.0206",  
95             allowed = None,
96             range = None,    
97             flags = Flags.Reserved | Flags.Construct)
98
99         cls._register_attribute(attr_txpowerstart)
100
101         attr_rxnoisefigure = Attribute("RxNoiseFigure",
102             "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver. According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is \"the difference in decibels (dB) between the noise output of the actual receiver to the noise output of an  ideal receiver with the same overall gain and bandwidth when the receivers  are connected to sources at the standard noise temperature T0 (usually 290 K)\". For",
103             type = Types.Double,
104             default = "7",  
105             allowed = None,
106             range = None,    
107             flags = Flags.Reserved | Flags.Construct)
108
109         cls._register_attribute(attr_rxnoisefigure)
110
111         attr_channelswitchdelay = Attribute("ChannelSwitchDelay",
112             "Delay between two short frames transmitted on different frequencies.",
113             type = Types.String,
114             default = "+250000.0ns",  
115             allowed = None,
116             range = None,    
117             flags = Flags.Reserved | Flags.Construct)
118
119         cls._register_attribute(attr_channelswitchdelay)
120
121         attr_channelnumber = Attribute("ChannelNumber",
122             "Channel center frequency = Channel starting frequency + 5 MHz * nch",
123             type = Types.Integer,
124             default = "1",  
125             allowed = None,
126             range = None,    
127             flags = Flags.Reserved | Flags.Construct)
128
129         cls._register_attribute(attr_channelnumber)
130
131         attr_frequency = Attribute("Frequency",
132             "The operating frequency.",
133             type = Types.Integer,
134             default = "2407",  
135             allowed = None,
136             range = None,    
137             flags = Flags.Reserved | Flags.Construct)
138
139         cls._register_attribute(attr_frequency)
140
141         attr_transmitters = Attribute("Transmitters",
142             "The number of transmitters.",
143             type = Types.Integer,
144             default = "1",  
145             allowed = None,
146             range = None,    
147             flags = Flags.Reserved | Flags.Construct)
148
149         cls._register_attribute(attr_transmitters)
150
151         attr_recievers = Attribute("Recievers",
152             "The number of recievers.",
153             type = Types.Integer,
154             default = "1",  
155             allowed = None,
156             range = None,    
157             flags = Flags.Reserved | Flags.Construct)
158
159         cls._register_attribute(attr_recievers)
160
161         attr_shortguardenabled = Attribute("ShortGuardEnabled",
162             "Whether or not short guard interval is enabled.",
163             type = Types.Bool,
164             default = "False",  
165             allowed = None,
166             range = None,    
167             flags = Flags.Reserved | Flags.Construct)
168
169         cls._register_attribute(attr_shortguardenabled)
170
171         attr_ldpcenabled = Attribute("LdpcEnabled",
172             "Whether or not LDPC is enabled.",
173             type = Types.Bool,
174             default = "False",  
175             allowed = None,
176             range = None,    
177             flags = Flags.Reserved | Flags.Construct)
178
179         cls._register_attribute(attr_ldpcenabled)
180
181         attr_stbcenabled = Attribute("STBCEnabled",
182             "Whether or not STBC is enabled.",
183             type = Types.Bool,
184             default = "False",  
185             allowed = None,
186             range = None,    
187             flags = Flags.Reserved | Flags.Construct)
188
189         cls._register_attribute(attr_stbcenabled)
190
191         attr_greenfieldenabled = Attribute("GreenfieldEnabled",
192             "Whether or not STBC is enabled.",
193             type = Types.Bool,
194             default = "False",  
195             allowed = None,
196             range = None,    
197             flags = Flags.Reserved | Flags.Construct)
198
199         cls._register_attribute(attr_greenfieldenabled)
200
201         attr_channelbonding = Attribute("ChannelBonding",
202             "Whether 20MHz or 40MHz.",
203             type = Types.Bool,
204             default = "False",  
205             allowed = None,
206             range = None,    
207             flags = Flags.Reserved | Flags.Construct)
208
209         cls._register_attribute(attr_channelbonding)
210
211
212
213     @classmethod
214     def _register_traces(cls):
215         
216         phytxbegin = Trace("PhyTxBegin", "Trace source indicating a packet has begun transmitting over the channel medium")
217
218         cls._register_trace(phytxbegin)
219
220         phytxend = Trace("PhyTxEnd", "Trace source indicating a packet has been completely transmitted over the channel. NOTE: the only official WifiPhy implementation available to this date (YansWifiPhy) never fires this trace source.")
221
222         cls._register_trace(phytxend)
223
224         phytxdrop = Trace("PhyTxDrop", "Trace source indicating a packet has been dropped by the device during transmission")
225
226         cls._register_trace(phytxdrop)
227
228         phyrxbegin = Trace("PhyRxBegin", "Trace source indicating a packet has begun being received from the channel medium by the device")
229
230         cls._register_trace(phyrxbegin)
231
232         phyrxend = Trace("PhyRxEnd", "Trace source indicating a packet has been completely received from the channel medium by the device")
233
234         cls._register_trace(phyrxend)
235
236         phyrxdrop = Trace("PhyRxDrop", "Trace source indicating a packet has been dropped by the device during reception")
237
238         cls._register_trace(phyrxdrop)
239
240         monitorsnifferrx = Trace("MonitorSnifferRx", "Trace source simulating a wifi device in monitor mode sniffing all received frames")
241
242         cls._register_trace(monitorsnifferrx)
243
244         monitorsniffertx = Trace("MonitorSnifferTx", "Trace source simulating the capability of a wifi device in monitor mode to sniff all frames being transmitted")
245
246         cls._register_trace(monitorsniffertx)
247
248
249
250     def __init__(self, ec, guid):
251         super(NS3YansWifiPhy, self).__init__(ec, guid)
252         self._home = "ns3-yans-wifi-phy-%s" % self.guid