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