e6f83ffa4200a630aa52433a01b5089db388d0f1
[nepi.git] / src / nepi / resources / ns3 / classes / dsrdsr_routing.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.ns3base import NS3Base
24
25 @clsinit_copy
26 class NS3dsrDsrRouting(NS3Base):
27     _rtype = "ns3::dsr::DsrRouting"
28
29     @classmethod
30     def _register_attributes(cls):
31         
32         attr_maxsendbufflen = Attribute("MaxSendBuffLen",
33             "Maximum number of packets that can be stored in send buffer.",
34             type = Types.Integer,
35             default = "64",  
36             allowed = None,
37             range = None,    
38             flags = Flags.Reserved | Flags.Construct)
39
40         cls._register_attribute(attr_maxsendbufflen)
41
42         attr_maxsendbufftime = Attribute("MaxSendBuffTime",
43             "Maximum time packets can be queued in the send buffer .",
44             type = Types.String,
45             default = "+30000000000.0ns",  
46             allowed = None,
47             range = None,    
48             flags = Flags.Reserved | Flags.Construct)
49
50         cls._register_attribute(attr_maxsendbufftime)
51
52         attr_maxmaintlen = Attribute("MaxMaintLen",
53             "Maximum number of packets that can be stored in maintenance buffer.",
54             type = Types.Integer,
55             default = "50",  
56             allowed = None,
57             range = None,    
58             flags = Flags.Reserved | Flags.Construct)
59
60         cls._register_attribute(attr_maxmaintlen)
61
62         attr_maxmainttime = Attribute("MaxMaintTime",
63             "Maximum time packets can be queued in maintenance buffer.",
64             type = Types.String,
65             default = "+30000000000.0ns",  
66             allowed = None,
67             range = None,    
68             flags = Flags.Reserved | Flags.Construct)
69
70         cls._register_attribute(attr_maxmainttime)
71
72         attr_maxcachelen = Attribute("MaxCacheLen",
73             "Maximum number of route entries that can be stored in route cache.",
74             type = Types.Integer,
75             default = "64",  
76             allowed = None,
77             range = None,    
78             flags = Flags.Reserved | Flags.Construct)
79
80         cls._register_attribute(attr_maxcachelen)
81
82         attr_routecachetimeout = Attribute("RouteCacheTimeout",
83             "Maximum time the route cache can be queued in route cache.",
84             type = Types.String,
85             default = "+300000000000.0ns",  
86             allowed = None,
87             range = None,    
88             flags = Flags.Reserved | Flags.Construct)
89
90         cls._register_attribute(attr_routecachetimeout)
91
92         attr_maxentrieseachdst = Attribute("MaxEntriesEachDst",
93             "Maximum number of route entries for a single destination to respond.",
94             type = Types.Integer,
95             default = "20",  
96             allowed = None,
97             range = None,    
98             flags = Flags.Reserved | Flags.Construct)
99
100         cls._register_attribute(attr_maxentrieseachdst)
101
102         attr_sendbuffinterval = Attribute("SendBuffInterval",
103             "How often to check send buffer for packet with route.",
104             type = Types.String,
105             default = "+500000000000.0ns",  
106             allowed = None,
107             range = None,    
108             flags = Flags.Reserved | Flags.Construct)
109
110         cls._register_attribute(attr_sendbuffinterval)
111
112         attr_nodetraversaltime = Attribute("NodeTraversalTime",
113             "The time it takes to traverse two neighboring nodes.",
114             type = Types.String,
115             default = "+40000000.0ns",  
116             allowed = None,
117             range = None,    
118             flags = Flags.Reserved | Flags.Construct)
119
120         cls._register_attribute(attr_nodetraversaltime)
121
122         attr_rreqretries = Attribute("RreqRetries",
123             "Maximum number of retransmissions for request discovery of a route.",
124             type = Types.Integer,
125             default = "16",  
126             allowed = None,
127             range = None,    
128             flags = Flags.Reserved | Flags.Construct)
129
130         cls._register_attribute(attr_rreqretries)
131
132         attr_maintenanceretries = Attribute("MaintenanceRetries",
133             "Maximum number of retransmissions for data packets from maintenance buffer.",
134             type = Types.Integer,
135             default = "2",  
136             allowed = None,
137             range = None,    
138             flags = Flags.Reserved | Flags.Construct)
139
140         cls._register_attribute(attr_maintenanceretries)
141
142         attr_requesttablesize = Attribute("RequestTableSize",
143             "Maximum number of request entries in the request table, set this as the number of nodes in the simulation.",
144             type = Types.Integer,
145             default = "64",  
146             allowed = None,
147             range = None,    
148             flags = Flags.Reserved | Flags.Construct)
149
150         cls._register_attribute(attr_requesttablesize)
151
152         attr_requestidsize = Attribute("RequestIdSize",
153             "Maximum number of request source Ids in the request table.",
154             type = Types.Integer,
155             default = "16",  
156             allowed = None,
157             range = None,    
158             flags = Flags.Reserved | Flags.Construct)
159
160         cls._register_attribute(attr_requestidsize)
161
162         attr_uniquerequestidsize = Attribute("UniqueRequestIdSize",
163             "Maximum number of request Ids in the request table for a single destination.",
164             type = Types.Integer,
165             default = "256",  
166             allowed = None,
167             range = None,    
168             flags = Flags.Reserved | Flags.Construct)
169
170         cls._register_attribute(attr_uniquerequestidsize)
171
172         attr_nonproprequesttimeout = Attribute("NonPropRequestTimeout",
173             "The timeout value for non-propagation request.",
174             type = Types.String,
175             default = "+30000000.0ns",  
176             allowed = None,
177             range = None,    
178             flags = Flags.Reserved | Flags.Construct)
179
180         cls._register_attribute(attr_nonproprequesttimeout)
181
182         attr_discoveryhoplimit = Attribute("DiscoveryHopLimit",
183             "The max discovery hop limit for route requests.",
184             type = Types.Integer,
185             default = "255",  
186             allowed = None,
187             range = None,    
188             flags = Flags.Reserved | Flags.Construct)
189
190         cls._register_attribute(attr_discoveryhoplimit)
191
192         attr_maxsalvagecount = Attribute("MaxSalvageCount",
193             "The max salvage count for a single data packet.",
194             type = Types.Integer,
195             default = "15",  
196             allowed = None,
197             range = None,    
198             flags = Flags.Reserved | Flags.Construct)
199
200         cls._register_attribute(attr_maxsalvagecount)
201
202         attr_blacklisttimeout = Attribute("BlacklistTimeout",
203             "The time for a neighbor to stay in blacklist.",
204             type = Types.String,
205             default = "+3000000000.0ns",  
206             allowed = None,
207             range = None,    
208             flags = Flags.Reserved | Flags.Construct)
209
210         cls._register_attribute(attr_blacklisttimeout)
211
212         attr_gratreplyholdoff = Attribute("GratReplyHoldoff",
213             "The time for gratuitous reply entry to expire.",
214             type = Types.String,
215             default = "+1000000000.0ns",  
216             allowed = None,
217             range = None,    
218             flags = Flags.Reserved | Flags.Construct)
219
220         cls._register_attribute(attr_gratreplyholdoff)
221
222         attr_broadcastjitter = Attribute("BroadcastJitter",
223             "The jitter time to avoid collision for broadcast packets.",
224             type = Types.Integer,
225             default = "10",  
226             allowed = None,
227             range = None,    
228             flags = Flags.Reserved | Flags.Construct)
229
230         cls._register_attribute(attr_broadcastjitter)
231
232         attr_linkacktimeout = Attribute("LinkAckTimeout",
233             "The time a packet in maintenance buffer wait for link acknowledgment.",
234             type = Types.String,
235             default = "+100000000.0ns",  
236             allowed = None,
237             range = None,    
238             flags = Flags.Reserved | Flags.Construct)
239
240         cls._register_attribute(attr_linkacktimeout)
241
242         attr_trylinkacks = Attribute("TryLinkAcks",
243             "The number of link acknowledgment to use.",
244             type = Types.Integer,
245             default = "1",  
246             allowed = None,
247             range = None,    
248             flags = Flags.Reserved | Flags.Construct)
249
250         cls._register_attribute(attr_trylinkacks)
251
252         attr_passiveacktimeout = Attribute("PassiveAckTimeout",
253             "The time a packet in maintenance buffer wait for passive acknowledgment.",
254             type = Types.String,
255             default = "+100000000.0ns",  
256             allowed = None,
257             range = None,    
258             flags = Flags.Reserved | Flags.Construct)
259
260         cls._register_attribute(attr_passiveacktimeout)
261
262         attr_trypassiveacks = Attribute("TryPassiveAcks",
263             "The number of passive acknowledgment to use.",
264             type = Types.Integer,
265             default = "1",  
266             allowed = None,
267             range = None,    
268             flags = Flags.Reserved | Flags.Construct)
269
270         cls._register_attribute(attr_trypassiveacks)
271
272         attr_requestperiod = Attribute("RequestPeriod",
273             "The base time interval between route requests.",
274             type = Types.String,
275             default = "+500000000.0ns",  
276             allowed = None,
277             range = None,    
278             flags = Flags.Reserved | Flags.Construct)
279
280         cls._register_attribute(attr_requestperiod)
281
282         attr_maxrequestperiod = Attribute("MaxRequestPeriod",
283             "The max time interval between route requests.",
284             type = Types.String,
285             default = "+10000000000.0ns",  
286             allowed = None,
287             range = None,    
288             flags = Flags.Reserved | Flags.Construct)
289
290         cls._register_attribute(attr_maxrequestperiod)
291
292         attr_grareplytablesize = Attribute("GraReplyTableSize",
293             "The gratuitous reply table size.",
294             type = Types.Integer,
295             default = "64",  
296             allowed = None,
297             range = None,    
298             flags = Flags.Reserved | Flags.Construct)
299
300         cls._register_attribute(attr_grareplytablesize)
301
302         attr_cachetype = Attribute("CacheType",
303             "Use Link Cache or use Path Cache",
304             type = Types.String,
305             default = "LinkCache",  
306             allowed = None,
307             range = None,    
308             flags = Flags.Reserved | Flags.Construct)
309
310         cls._register_attribute(attr_cachetype)
311
312         attr_stabilitydecrfactor = Attribute("StabilityDecrFactor",
313             "The stability decrease factor for link cache",
314             type = Types.Integer,
315             default = "2",  
316             allowed = None,
317             range = None,    
318             flags = Flags.Reserved | Flags.Construct)
319
320         cls._register_attribute(attr_stabilitydecrfactor)
321
322         attr_stabilityincrfactor = Attribute("StabilityIncrFactor",
323             "The stability increase factor for link cache",
324             type = Types.Integer,
325             default = "4",  
326             allowed = None,
327             range = None,    
328             flags = Flags.Reserved | Flags.Construct)
329
330         cls._register_attribute(attr_stabilityincrfactor)
331
332         attr_initstability = Attribute("InitStability",
333             "The initial stability factor for link cache",
334             type = Types.String,
335             default = "+25000000000.0ns",  
336             allowed = None,
337             range = None,    
338             flags = Flags.Reserved | Flags.Construct)
339
340         cls._register_attribute(attr_initstability)
341
342         attr_minlifetime = Attribute("MinLifeTime",
343             "The minimal life time for link cache",
344             type = Types.String,
345             default = "+1000000000.0ns",  
346             allowed = None,
347             range = None,    
348             flags = Flags.Reserved | Flags.Construct)
349
350         cls._register_attribute(attr_minlifetime)
351
352         attr_useextends = Attribute("UseExtends",
353             "The extension time for link cache",
354             type = Types.String,
355             default = "+120000000000.0ns",  
356             allowed = None,
357             range = None,    
358             flags = Flags.Reserved | Flags.Construct)
359
360         cls._register_attribute(attr_useextends)
361
362         attr_enablesubroute = Attribute("EnableSubRoute",
363             "Enables saving of sub route when receiving route error messages, only available when using path route cache",
364             type = Types.Bool,
365             default = "True",  
366             allowed = None,
367             range = None,    
368             flags = Flags.Reserved | Flags.Construct)
369
370         cls._register_attribute(attr_enablesubroute)
371
372         attr_retransincr = Attribute("RetransIncr",
373             "The increase time for retransmission timer when facing network congestion",
374             type = Types.String,
375             default = "+20000000.0ns",  
376             allowed = None,
377             range = None,    
378             flags = Flags.Reserved | Flags.Construct)
379
380         cls._register_attribute(attr_retransincr)
381
382         attr_maxnetworkqueuesize = Attribute("MaxNetworkQueueSize",
383             "The max number of packet to save in the network queue.",
384             type = Types.Integer,
385             default = "400",  
386             allowed = None,
387             range = None,    
388             flags = Flags.Reserved | Flags.Construct)
389
390         cls._register_attribute(attr_maxnetworkqueuesize)
391
392         attr_maxnetworkqueuedelay = Attribute("MaxNetworkQueueDelay",
393             "The max time for a packet to stay in the network queue.",
394             type = Types.String,
395             default = "+30000000000.0ns",  
396             allowed = None,
397             range = None,    
398             flags = Flags.Reserved | Flags.Construct)
399
400         cls._register_attribute(attr_maxnetworkqueuedelay)
401
402         attr_numpriorityqueues = Attribute("NumPriorityQueues",
403             "The max number of packet to save in the network queue.",
404             type = Types.Integer,
405             default = "2",  
406             allowed = None,
407             range = None,    
408             flags = Flags.Reserved | Flags.Construct)
409
410         cls._register_attribute(attr_numpriorityqueues)
411
412         attr_linkacknowledgment = Attribute("LinkAcknowledgment",
413             "Enable Link layer acknowledgment mechanism",
414             type = Types.Bool,
415             default = "False",  
416             allowed = None,
417             range = None,    
418             flags = Flags.Reserved | Flags.Construct)
419
420         cls._register_attribute(attr_linkacknowledgment)
421
422         attr_protocolnumber = Attribute("ProtocolNumber",
423             "The Ip protocol number.",
424             type = Types.Integer,
425             default = "0",  
426             allowed = None,
427             range = None,    
428             flags = Flags.Reserved | Flags.Construct)
429
430         cls._register_attribute(attr_protocolnumber)
431
432
433
434     @classmethod
435     def _register_traces(cls):
436         
437         tx = Trace("Tx", "Send DSR packet.")
438
439         cls._register_trace(tx)
440
441         drop = Trace("Drop", "Drop DSR packet")
442
443         cls._register_trace(drop)
444
445
446
447     def __init__(self, ec, guid):
448         super(NS3dsrDsrRouting, self).__init__(ec, guid)
449         self._home = "ns3-dsr-dsr-routing-%s" % self.guid