2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2014 INRIA
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.
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.
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/>.
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, \
23 from nepi.resources.ns3.ns3wifiphy import NS3BaseWifiPhy
26 class NS3YansWifiPhy(NS3BaseWifiPhy):
27 _rtype = "ns3::YansWifiPhy"
30 def _register_attributes(cls):
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.",
38 flags = Flags.Reserved | Flags.Construct)
40 cls._register_attribute(attr_energydetectionthreshold)
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",
48 flags = Flags.Reserved | Flags.Construct)
50 cls._register_attribute(attr_ccamode1threshold)
52 attr_txgain = Attribute("TxGain",
53 "Transmission gain (dB).",
58 flags = Flags.Reserved | Flags.Construct)
60 cls._register_attribute(attr_txgain)
62 attr_rxgain = Attribute("RxGain",
63 "Reception gain (dB).",
68 flags = Flags.Reserved | Flags.Construct)
70 cls._register_attribute(attr_rxgain)
72 attr_txpowerlevels = Attribute("TxPowerLevels",
73 "Number of transmission power levels available between TxPowerStart and TxPowerEnd included.",
78 flags = Flags.Reserved | Flags.Construct)
80 cls._register_attribute(attr_txpowerlevels)
82 attr_txpowerend = Attribute("TxPowerEnd",
83 "Maximum available transmission level (dbm).",
88 flags = Flags.Reserved | Flags.Construct)
90 cls._register_attribute(attr_txpowerend)
92 attr_txpowerstart = Attribute("TxPowerStart",
93 "Minimum available transmission level (dbm).",
98 flags = Flags.Reserved | Flags.Construct)
100 cls._register_attribute(attr_txpowerstart)
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",
108 flags = Flags.Reserved | Flags.Construct)
110 cls._register_attribute(attr_rxnoisefigure)
112 attr_channelswitchdelay = Attribute("ChannelSwitchDelay",
113 "Delay between two short frames transmitted on different frequencies.",
115 default = "+250000.0ns",
118 flags = Flags.Reserved | Flags.Construct)
120 cls._register_attribute(attr_channelswitchdelay)
122 attr_channelnumber = Attribute("ChannelNumber",
123 "Channel center frequency = Channel starting frequency + 5 MHz * nch",
124 type = Types.Integer,
128 flags = Flags.Reserved | Flags.Construct)
130 cls._register_attribute(attr_channelnumber)
132 attr_frequency = Attribute("Frequency",
133 "The operating frequency.",
134 type = Types.Integer,
138 flags = Flags.Reserved | Flags.Construct)
140 cls._register_attribute(attr_frequency)
142 attr_transmitters = Attribute("Transmitters",
143 "The number of transmitters.",
144 type = Types.Integer,
148 flags = Flags.Reserved | Flags.Construct)
150 cls._register_attribute(attr_transmitters)
152 attr_recievers = Attribute("Recievers",
153 "The number of recievers.",
154 type = Types.Integer,
158 flags = Flags.Reserved | Flags.Construct)
160 cls._register_attribute(attr_recievers)
162 attr_shortguardenabled = Attribute("ShortGuardEnabled",
163 "Whether or not short guard interval is enabled.",
168 flags = Flags.Reserved | Flags.Construct)
170 cls._register_attribute(attr_shortguardenabled)
172 attr_ldpcenabled = Attribute("LdpcEnabled",
173 "Whether or not LDPC is enabled.",
178 flags = Flags.Reserved | Flags.Construct)
180 cls._register_attribute(attr_ldpcenabled)
182 attr_stbcenabled = Attribute("STBCEnabled",
183 "Whether or not STBC is enabled.",
188 flags = Flags.Reserved | Flags.Construct)
190 cls._register_attribute(attr_stbcenabled)
192 attr_greenfieldenabled = Attribute("GreenfieldEnabled",
193 "Whether or not STBC is enabled.",
198 flags = Flags.Reserved | Flags.Construct)
200 cls._register_attribute(attr_greenfieldenabled)
202 attr_channelbonding = Attribute("ChannelBonding",
203 "Whether 20MHz or 40MHz.",
208 flags = Flags.Reserved | Flags.Construct)
210 cls._register_attribute(attr_channelbonding)
215 def _register_traces(cls):
217 phytxbegin = Trace("PhyTxBegin", "Trace source indicating a packet has begun transmitting over the channel medium")
219 cls._register_trace(phytxbegin)
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.")
223 cls._register_trace(phytxend)
225 phytxdrop = Trace("PhyTxDrop", "Trace source indicating a packet has been dropped by the device during transmission")
227 cls._register_trace(phytxdrop)
229 phyrxbegin = Trace("PhyRxBegin", "Trace source indicating a packet has begun being received from the channel medium by the device")
231 cls._register_trace(phyrxbegin)
233 phyrxend = Trace("PhyRxEnd", "Trace source indicating a packet has been completely received from the channel medium by the device")
235 cls._register_trace(phyrxend)
237 phyrxdrop = Trace("PhyRxDrop", "Trace source indicating a packet has been dropped by the device during reception")
239 cls._register_trace(phyrxdrop)
241 monitorsnifferrx = Trace("MonitorSnifferRx", "Trace source simulating a wifi device in monitor mode sniffing all received frames")
243 cls._register_trace(monitorsnifferrx)
245 monitorsniffertx = Trace("MonitorSnifferTx", "Trace source simulating the capability of a wifi device in monitor mode to sniff all frames being transmitted")
247 cls._register_trace(monitorsniffertx)
251 def __init__(self, ec, guid):
252 super(NS3YansWifiPhy, self).__init__(ec, guid)
253 self._home = "ns3-yans-wifi-phy-%s" % self.guid