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 version 2 as
7 # published by the Free Software Foundation;
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.
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/>.
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, \
22 from nepi.resources.ns3.ns3wifiphy import NS3BaseWifiPhy
25 class NS3YansWifiPhy(NS3BaseWifiPhy):
26 _rtype = "ns3::YansWifiPhy"
29 def _register_attributes(cls):
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.",
37 flags = Flags.Reserved | Flags.Construct)
39 cls._register_attribute(attr_energydetectionthreshold)
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",
47 flags = Flags.Reserved | Flags.Construct)
49 cls._register_attribute(attr_ccamode1threshold)
51 attr_txgain = Attribute("TxGain",
52 "Transmission gain (dB).",
57 flags = Flags.Reserved | Flags.Construct)
59 cls._register_attribute(attr_txgain)
61 attr_rxgain = Attribute("RxGain",
62 "Reception gain (dB).",
67 flags = Flags.Reserved | Flags.Construct)
69 cls._register_attribute(attr_rxgain)
71 attr_txpowerlevels = Attribute("TxPowerLevels",
72 "Number of transmission power levels available between TxPowerStart and TxPowerEnd included.",
77 flags = Flags.Reserved | Flags.Construct)
79 cls._register_attribute(attr_txpowerlevels)
81 attr_txpowerend = Attribute("TxPowerEnd",
82 "Maximum available transmission level (dbm).",
87 flags = Flags.Reserved | Flags.Construct)
89 cls._register_attribute(attr_txpowerend)
91 attr_txpowerstart = Attribute("TxPowerStart",
92 "Minimum available transmission level (dbm).",
97 flags = Flags.Reserved | Flags.Construct)
99 cls._register_attribute(attr_txpowerstart)
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",
107 flags = Flags.Reserved | Flags.Construct)
109 cls._register_attribute(attr_rxnoisefigure)
111 attr_channelswitchdelay = Attribute("ChannelSwitchDelay",
112 "Delay between two short frames transmitted on different frequencies.",
114 default = "+250000.0ns",
117 flags = Flags.Reserved | Flags.Construct)
119 cls._register_attribute(attr_channelswitchdelay)
121 attr_channelnumber = Attribute("ChannelNumber",
122 "Channel center frequency = Channel starting frequency + 5 MHz * nch",
123 type = Types.Integer,
127 flags = Flags.Reserved | Flags.Construct)
129 cls._register_attribute(attr_channelnumber)
131 attr_frequency = Attribute("Frequency",
132 "The operating frequency.",
133 type = Types.Integer,
137 flags = Flags.Reserved | Flags.Construct)
139 cls._register_attribute(attr_frequency)
141 attr_transmitters = Attribute("Transmitters",
142 "The number of transmitters.",
143 type = Types.Integer,
147 flags = Flags.Reserved | Flags.Construct)
149 cls._register_attribute(attr_transmitters)
151 attr_recievers = Attribute("Recievers",
152 "The number of recievers.",
153 type = Types.Integer,
157 flags = Flags.Reserved | Flags.Construct)
159 cls._register_attribute(attr_recievers)
161 attr_shortguardenabled = Attribute("ShortGuardEnabled",
162 "Whether or not short guard interval is enabled.",
167 flags = Flags.Reserved | Flags.Construct)
169 cls._register_attribute(attr_shortguardenabled)
171 attr_ldpcenabled = Attribute("LdpcEnabled",
172 "Whether or not LDPC is enabled.",
177 flags = Flags.Reserved | Flags.Construct)
179 cls._register_attribute(attr_ldpcenabled)
181 attr_stbcenabled = Attribute("STBCEnabled",
182 "Whether or not STBC is enabled.",
187 flags = Flags.Reserved | Flags.Construct)
189 cls._register_attribute(attr_stbcenabled)
191 attr_greenfieldenabled = Attribute("GreenfieldEnabled",
192 "Whether or not STBC is enabled.",
197 flags = Flags.Reserved | Flags.Construct)
199 cls._register_attribute(attr_greenfieldenabled)
201 attr_channelbonding = Attribute("ChannelBonding",
202 "Whether 20MHz or 40MHz.",
207 flags = Flags.Reserved | Flags.Construct)
209 cls._register_attribute(attr_channelbonding)
214 def _register_traces(cls):
216 phytxbegin = Trace("PhyTxBegin", "Trace source indicating a packet has begun transmitting over the channel medium")
218 cls._register_trace(phytxbegin)
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.")
222 cls._register_trace(phytxend)
224 phytxdrop = Trace("PhyTxDrop", "Trace source indicating a packet has been dropped by the device during transmission")
226 cls._register_trace(phytxdrop)
228 phyrxbegin = Trace("PhyRxBegin", "Trace source indicating a packet has begun being received from the channel medium by the device")
230 cls._register_trace(phyrxbegin)
232 phyrxend = Trace("PhyRxEnd", "Trace source indicating a packet has been completely received from the channel medium by the device")
234 cls._register_trace(phyrxend)
236 phyrxdrop = Trace("PhyRxDrop", "Trace source indicating a packet has been dropped by the device during reception")
238 cls._register_trace(phyrxdrop)
240 monitorsnifferrx = Trace("MonitorSnifferRx", "Trace source simulating a wifi device in monitor mode sniffing all received frames")
242 cls._register_trace(monitorsnifferrx)
244 monitorsniffertx = Trace("MonitorSnifferTx", "Trace source simulating the capability of a wifi device in monitor mode to sniff all frames being transmitted")
246 cls._register_trace(monitorsniffertx)
250 def __init__(self, ec, guid):
251 super(NS3YansWifiPhy, self).__init__(ec, guid)
252 self._home = "ns3-yans-wifi-phy-%s" % self.guid