8802aa70e91eecccc749ce795a2106648649b8b0
[nepi.git] / src / nepi / resources / ns3 / classes / ap_wifi_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 NS3ApWifiMac(NS3BaseWifiMac):
27     _rtype = "ns3::ApWifiMac"
28
29     @classmethod
30     def _register_attributes(cls):
31         
32         attr_beaconinterval = Attribute("BeaconInterval",
33             "Delay between two beacons",
34             type = Types.String,
35             default = "+102400000.0ns",  
36             allowed = None,
37             range = None,    
38             flags = Flags.Reserved | Flags.Construct)
39
40         cls._register_attribute(attr_beaconinterval)
41
42         attr_beaconjitter = Attribute("BeaconJitter",
43             "A uniform random variable to cause the initial beacon starting time (after simulation time 0) to be distributed between 0 and the BeaconInterval.",
44             type = Types.String,
45             default = "ns3::UniformRandomVariable",  
46             allowed = None,
47             range = None,    
48             flags = Flags.Reserved | Flags.Construct)
49
50         cls._register_attribute(attr_beaconjitter)
51
52         attr_enablebeaconjitter = Attribute("EnableBeaconJitter",
53             "If beacons are enabled, whether to jitter the initial send event.",
54             type = Types.Bool,
55             default = "False",  
56             allowed = None,
57             range = None,    
58             flags = Flags.Reserved | Flags.Construct)
59
60         cls._register_attribute(attr_enablebeaconjitter)
61
62         attr_beacongeneration = Attribute("BeaconGeneration",
63             "Whether or not beacons are generated.",
64             type = Types.Bool,
65             default = "True",  
66             allowed = None,
67             range = None,    
68             flags = Flags.Reserved | Flags.Construct)
69
70         cls._register_attribute(attr_beacongeneration)
71
72         attr_qossupported = Attribute("QosSupported",
73             "This Boolean attribute is set to enable 802.11e/WMM-style QoS 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_qossupported)
81
82         attr_htsupported = Attribute("HtSupported",
83             "This Boolean attribute is set to enable 802.11n support at this STA",
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_htsupported)
91
92         attr_ctstoselfsupported = Attribute("CtsToSelfSupported",
93             "Use CTS to Self when using a rate that is not in the basic set rate",
94             type = Types.Bool,
95             default = "False",  
96             allowed = None,
97             range = None,    
98             flags = Flags.Reserved | Flags.Construct)
99
100         cls._register_attribute(attr_ctstoselfsupported)
101
102         attr_ctstimeout = Attribute("CtsTimeout",
103             "When this timeout expires, the RTS/CTS 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_ctstimeout)
111
112         attr_acktimeout = Attribute("AckTimeout",
113             "When this timeout expires, the DATA/ACK handshake has failed.",
114             type = Types.String,
115             default = "+75000.0ns",  
116             allowed = None,
117             range = None,    
118             flags = Flags.Reserved | Flags.Construct)
119
120         cls._register_attribute(attr_acktimeout)
121
122         attr_basicblockacktimeout = Attribute("BasicBlockAckTimeout",
123             "When this timeout expires, the BASIC_BLOCK_ACK_REQ/BASIC_BLOCK_ACK handshake has failed.",
124             type = Types.String,
125             default = "+281000.0ns",  
126             allowed = None,
127             range = None,    
128             flags = Flags.Reserved | Flags.Construct)
129
130         cls._register_attribute(attr_basicblockacktimeout)
131
132         attr_compressedblockacktimeout = Attribute("CompressedBlockAckTimeout",
133             "When this timeout expires, the COMPRESSED_BLOCK_ACK_REQ/COMPRESSED_BLOCK_ACK handshake has failed.",
134             type = Types.String,
135             default = "+107000.0ns",  
136             allowed = None,
137             range = None,    
138             flags = Flags.Reserved | Flags.Construct)
139
140         cls._register_attribute(attr_compressedblockacktimeout)
141
142         attr_sifs = Attribute("Sifs",
143             "The value of the SIFS constant.",
144             type = Types.String,
145             default = "+16000.0ns",  
146             allowed = None,
147             range = None,    
148             flags = Flags.Reserved | Flags.Construct)
149
150         cls._register_attribute(attr_sifs)
151
152         attr_eifsnodifs = Attribute("EifsNoDifs",
153             "The value of EIFS-DIFS",
154             type = Types.String,
155             default = "+60000.0ns",  
156             allowed = None,
157             range = None,    
158             flags = Flags.Reserved | Flags.Construct)
159
160         cls._register_attribute(attr_eifsnodifs)
161
162         attr_slot = Attribute("Slot",
163             "The duration of a Slot.",
164             type = Types.String,
165             default = "+9000.0ns",  
166             allowed = None,
167             range = None,    
168             flags = Flags.Reserved | Flags.Construct)
169
170         cls._register_attribute(attr_slot)
171
172         attr_pifs = Attribute("Pifs",
173             "The value of the PIFS constant.",
174             type = Types.String,
175             default = "+25000.0ns",  
176             allowed = None,
177             range = None,    
178             flags = Flags.Reserved | Flags.Construct)
179
180         cls._register_attribute(attr_pifs)
181
182         attr_rifs = Attribute("Rifs",
183             "The value of the RIFS constant.",
184             type = Types.String,
185             default = "+2000.0ns",  
186             allowed = None,
187             range = None,    
188             flags = Flags.Reserved | Flags.Construct)
189
190         cls._register_attribute(attr_rifs)
191
192         attr_maxpropagationdelay = Attribute("MaxPropagationDelay",
193             "The maximum propagation delay. Unused for now.",
194             type = Types.String,
195             default = "+3333.0ns",  
196             allowed = None,
197             range = None,    
198             flags = Flags.Reserved | Flags.Construct)
199
200         cls._register_attribute(attr_maxpropagationdelay)
201
202         attr_ssid = Attribute("Ssid",
203             "The ssid we want to belong to.",
204             type = Types.String,
205             default = "default",  
206             allowed = None,
207             range = None,    
208             flags = Flags.Reserved | Flags.Construct)
209
210         cls._register_attribute(attr_ssid)
211
212
213
214     @classmethod
215     def _register_traces(cls):
216         
217         txokheader = Trace("TxOkHeader", "The header of successfully transmitted packet")
218
219         cls._register_trace(txokheader)
220
221         txerrheader = Trace("TxErrHeader", "The header of unsuccessfully transmitted packet")
222
223         cls._register_trace(txerrheader)
224
225         mactx = Trace("MacTx", "A packet has been received from higher layers and is being processed in preparation for queueing for transmission.")
226
227         cls._register_trace(mactx)
228
229         mactxdrop = Trace("MacTxDrop", "A packet has been dropped in the MAC layer before being queued for transmission.")
230
231         cls._register_trace(mactxdrop)
232
233         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,")
234
235         cls._register_trace(macpromiscrx)
236
237         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,")
238
239         cls._register_trace(macrx)
240
241         macrxdrop = Trace("MacRxDrop", "A packet has been dropped in the MAC layer after it has been passed up from the physical layer.")
242
243         cls._register_trace(macrxdrop)
244
245
246
247     def __init__(self, ec, guid):
248         super(NS3ApWifiMac, self).__init__(ec, guid)
249         self._home = "ns3-ap-wifi-mac-%s" % self.guid