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, \
22 ResourceState, reschedule_delay
23 from nepi.resources.ns3.ns3wifiremotestationmanager import NS3BaseWifiRemoteStationManager
26 class NS3CaraWifiManager(NS3BaseWifiRemoteStationManager):
27 _rtype = "ns3::CaraWifiManager"
30 def _register_attributes(cls):
32 attr_probethreshold = Attribute("ProbeThreshold",
33 "The number of consecutive transmissions failure to activate the RTS probe.",
38 flags = Flags.Reserved | Flags.Construct)
40 cls._register_attribute(attr_probethreshold)
42 attr_failurethreshold = Attribute("FailureThreshold",
43 "The number of consecutive transmissions failure to decrease the rate.",
48 flags = Flags.Reserved | Flags.Construct)
50 cls._register_attribute(attr_failurethreshold)
52 attr_successthreshold = Attribute("SuccessThreshold",
53 "The minimum number of sucessfull transmissions to try a new rate.",
58 flags = Flags.Reserved | Flags.Construct)
60 cls._register_attribute(attr_successthreshold)
62 attr_timeout = Attribute("Timeout",
63 "The \'timer\' in the CARA algorithm",
68 flags = Flags.Reserved | Flags.Construct)
70 cls._register_attribute(attr_timeout)
72 attr_islowlatency = Attribute("IsLowLatency",
73 "If true, we attempt to modelize a so-called low-latency device: a device where decisions about tx parameters can be made on a per-packet basis and feedback about the transmission of each packet is obtained before sending the next. Otherwise, we modelize a high-latency device, that is a device where we cannot update our decision about tx parameters after every packet transmission.",
78 flags = Flags.Reserved | Flags.Construct)
80 cls._register_attribute(attr_islowlatency)
82 attr_maxssrc = Attribute("MaxSsrc",
83 "The maximum number of retransmission attempts for an RTS. This value will not have any effect on some rate control algorithms.",
88 flags = Flags.Reserved | Flags.Construct)
90 cls._register_attribute(attr_maxssrc)
92 attr_maxslrc = Attribute("MaxSlrc",
93 "The maximum number of retransmission attempts for a DATA packet. This value will not have any effect on some rate control algorithms.",
98 flags = Flags.Reserved | Flags.Construct)
100 cls._register_attribute(attr_maxslrc)
102 attr_rtsctsthreshold = Attribute("RtsCtsThreshold",
103 "If the size of the data packet + LLC header + MAC header + FCS trailer is bigger than this value, we use an RTS/CTS handshake before sending the data, as per IEEE Std. 802.11-2007, Section 9.2.6. This value will not have any effect on some rate control algorithms.",
104 type = Types.Integer,
108 flags = Flags.Reserved | Flags.Construct)
110 cls._register_attribute(attr_rtsctsthreshold)
112 attr_fragmentationthreshold = Attribute("FragmentationThreshold",
113 "If the size of the data packet + LLC header + MAC header + FCS trailer is biggerthan this value, we fragment it such that the size of the fragments are equal or smaller than this value, as per IEEE Std. 802.11-2007, Section 9.4. This value will not have any effect on some rate control algorithms.",
114 type = Types.Integer,
118 flags = Flags.Reserved | Flags.Construct)
120 cls._register_attribute(attr_fragmentationthreshold)
122 attr_nonunicastmode = Attribute("NonUnicastMode",
123 "Wifi mode used for non-unicast transmissions.",
125 default = "Invalid-WifiMode",
128 flags = Flags.Reserved | Flags.Construct)
130 cls._register_attribute(attr_nonunicastmode)
132 attr_defaulttxpowerlevel = Attribute("DefaultTxPowerLevel",
133 "Default power level to be used for transmissions. This is the power level that is used by all those WifiManagers that do notimplement TX power control.",
134 type = Types.Integer,
138 flags = Flags.Reserved | Flags.Construct)
140 cls._register_attribute(attr_defaulttxpowerlevel)
145 def _register_traces(cls):
147 mactxrtsfailed = Trace("MacTxRtsFailed", "The transmission of a RTS by the MAC layer has failed")
149 cls._register_trace(mactxrtsfailed)
151 mactxdatafailed = Trace("MacTxDataFailed", "The transmission of a data packet by the MAC layer has failed")
153 cls._register_trace(mactxdatafailed)
155 mactxfinalrtsfailed = Trace("MacTxFinalRtsFailed", "The transmission of a RTS has exceeded the maximum number of attempts")
157 cls._register_trace(mactxfinalrtsfailed)
159 mactxfinaldatafailed = Trace("MacTxFinalDataFailed", "The transmission of a data packet has exceeded the maximum number of attempts")
161 cls._register_trace(mactxfinaldatafailed)
165 def __init__(self, ec, guid):
166 super(NS3CaraWifiManager, self).__init__(ec, guid)
167 self._home = "ns3-cara-wifi-manager-%s" % self.guid