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