b7360814555d216b080d699351b4f2e5a4bd0a9d
[nepi.git] / src / nepi / resources / ns3 / classes / mesh_wifi_interface_mac.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.ns3wifimac import NS3BaseWifiMac 
24
25 @clsinit_copy
26 class NS3MeshWifiInterfaceMac(NS3BaseWifiMac):
27     _rtype = "ns3::MeshWifiInterfaceMac"
28
29     @classmethod
30     def _register_attributes(cls):
31         
32         attr_beaconinterval = Attribute("BeaconInterval",
33             "Beacon Interval",
34             type = Types.String,
35             default = "+500000000.0ns",  
36             allowed = None,
37             range = None,    
38             flags = Flags.Reserved | Flags.Construct)
39
40         cls._register_attribute(attr_beaconinterval)
41
42         attr_randomstart = Attribute("RandomStart",
43             "Window when beacon generating starts (uniform random) in seconds",
44             type = Types.String,
45             default = "+500000000.0ns",  
46             allowed = None,
47             range = None,    
48             flags = Flags.Reserved | Flags.Construct)
49
50         cls._register_attribute(attr_randomstart)
51
52         attr_beacongeneration = Attribute("BeaconGeneration",
53             "Enable/Disable Beaconing.",
54             type = Types.Bool,
55             default = "True",  
56             allowed = None,
57             range = None,    
58             flags = Flags.Reserved | Flags.Construct)
59
60         cls._register_attribute(attr_beacongeneration)
61
62         attr_qossupported = Attribute("QosSupported",
63             "This Boolean attribute is set to enable 802.11e/WMM-style QoS support at this STA",
64             type = Types.Bool,
65             default = "False",  
66             allowed = None,
67             range = None,    
68             flags = Flags.Reserved | Flags.Construct)
69
70         cls._register_attribute(attr_qossupported)
71
72         attr_htsupported = Attribute("HtSupported",
73             "This Boolean attribute is set to enable 802.11n support at this STA",
74             type = Types.Bool,
75             default = "False",  
76             allowed = None,
77             range = None,    
78             flags = Flags.Reserved | Flags.Construct)
79
80         cls._register_attribute(attr_htsupported)
81
82         attr_ctstoselfsupported = Attribute("CtsToSelfSupported",
83             "Use CTS to Self when using a rate that is not in the basic set rate",
84             type = Types.Bool,
85             default = "False",  
86             allowed = None,
87             range = None,    
88             flags = Flags.Reserved | Flags.Construct)
89
90         cls._register_attribute(attr_ctstoselfsupported)
91
92         attr_ctstimeout = Attribute("CtsTimeout",
93             "When this timeout expires, the RTS/CTS handshake has failed.",
94             type = Types.String,
95             default = "+75000.0ns",  
96             allowed = None,
97             range = None,    
98             flags = Flags.Reserved | Flags.Construct)
99
100         cls._register_attribute(attr_ctstimeout)
101
102         attr_acktimeout = Attribute("AckTimeout",
103             "When this timeout expires, the DATA/ACK handshake has failed.",
104             type = Types.String,
105             default = "+75000.0ns",  
106             allowed = None,
107             range = None,    
108             flags = Flags.Reserved | Flags.Construct)
109
110         cls._register_attribute(attr_acktimeout)
111
112         attr_basicblockacktimeout = Attribute("BasicBlockAckTimeout",
113             "When this timeout expires, the BASIC_BLOCK_ACK_REQ/BASIC_BLOCK_ACK handshake has failed.",
114             type = Types.String,
115             default = "+281000.0ns",  
116             allowed = None,
117             range = None,    
118             flags = Flags.Reserved | Flags.Construct)
119
120         cls._register_attribute(attr_basicblockacktimeout)
121
122         attr_compressedblockacktimeout = Attribute("CompressedBlockAckTimeout",
123             "When this timeout expires, the COMPRESSED_BLOCK_ACK_REQ/COMPRESSED_BLOCK_ACK handshake has failed.",
124             type = Types.String,
125             default = "+107000.0ns",  
126             allowed = None,
127             range = None,    
128             flags = Flags.Reserved | Flags.Construct)
129
130         cls._register_attribute(attr_compressedblockacktimeout)
131
132         attr_sifs = Attribute("Sifs",
133             "The value of the SIFS constant.",
134             type = Types.String,
135             default = "+16000.0ns",  
136             allowed = None,
137             range = None,    
138             flags = Flags.Reserved | Flags.Construct)
139
140         cls._register_attribute(attr_sifs)
141
142         attr_eifsnodifs = Attribute("EifsNoDifs",
143             "The value of EIFS-DIFS",
144             type = Types.String,
145             default = "+60000.0ns",  
146             allowed = None,
147             range = None,    
148             flags = Flags.Reserved | Flags.Construct)
149
150         cls._register_attribute(attr_eifsnodifs)
151
152         attr_slot = Attribute("Slot",
153             "The duration of a Slot.",
154             type = Types.String,
155             default = "+9000.0ns",  
156             allowed = None,
157             range = None,    
158             flags = Flags.Reserved | Flags.Construct)
159
160         cls._register_attribute(attr_slot)
161
162         attr_pifs = Attribute("Pifs",
163             "The value of the PIFS constant.",
164             type = Types.String,
165             default = "+25000.0ns",  
166             allowed = None,
167             range = None,    
168             flags = Flags.Reserved | Flags.Construct)
169
170         cls._register_attribute(attr_pifs)
171
172         attr_rifs = Attribute("Rifs",
173             "The value of the RIFS constant.",
174             type = Types.String,
175             default = "+2000.0ns",  
176             allowed = None,
177             range = None,    
178             flags = Flags.Reserved | Flags.Construct)
179
180         cls._register_attribute(attr_rifs)
181
182         attr_maxpropagationdelay = Attribute("MaxPropagationDelay",
183             "The maximum propagation delay. Unused for now.",
184             type = Types.String,
185             default = "+3333.0ns",  
186             allowed = None,
187             range = None,    
188             flags = Flags.Reserved | Flags.Construct)
189
190         cls._register_attribute(attr_maxpropagationdelay)
191
192         attr_ssid = Attribute("Ssid",
193             "The ssid we want to belong to.",
194             type = Types.String,
195             default = "default",  
196             allowed = None,
197             range = None,    
198             flags = Flags.Reserved | Flags.Construct)
199
200         cls._register_attribute(attr_ssid)
201
202
203
204     @classmethod
205     def _register_traces(cls):
206         
207         txokheader = Trace("TxOkHeader", "The header of successfully transmitted packet")
208
209         cls._register_trace(txokheader)
210
211         txerrheader = Trace("TxErrHeader", "The header of unsuccessfully transmitted packet")
212
213         cls._register_trace(txerrheader)
214
215         mactx = Trace("MacTx", "A packet has been received from higher layers and is being processed in preparation for queueing for transmission.")
216
217         cls._register_trace(mactx)
218
219         mactxdrop = Trace("MacTxDrop", "A packet has been dropped in the MAC layer before being queued for transmission.")
220
221         cls._register_trace(mactxdrop)
222
223         macpromiscrx = Trace("MacPromiscRx", "A packet has been received by this device, has been passed up from the physical layer and is being forwarded up the local protocol stack.  This is a promiscuous trace,")
224
225         cls._register_trace(macpromiscrx)
226
227         macrx = Trace("MacRx", "A packet has been received by this device, has been passed up from the physical layer and is being forwarded up the local protocol stack.  This is a non-promiscuous trace,")
228
229         cls._register_trace(macrx)
230
231         macrxdrop = Trace("MacRxDrop", "A packet has been dropped in the MAC layer after it has been passed up from the physical layer.")
232
233         cls._register_trace(macrxdrop)
234
235
236
237     def __init__(self, ec, guid):
238         super(NS3MeshWifiInterfaceMac, self).__init__(ec, guid)
239         self._home = "ns3-mesh-wifi-interface-mac-%s" % self.guid