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.ns3base import NS3Base
26 class NS3dsrDsrRouting(NS3Base):
27 _rtype = "ns3::dsr::DsrRouting"
30 def _register_attributes(cls):
32 attr_maxsendbufflen = Attribute("MaxSendBuffLen",
33 "Maximum number of packets that can be stored in send buffer.",
38 flags = Flags.Reserved | Flags.Construct)
40 cls._register_attribute(attr_maxsendbufflen)
42 attr_maxsendbufftime = Attribute("MaxSendBuffTime",
43 "Maximum time packets can be queued in the send buffer .",
45 default = "+30000000000.0ns",
48 flags = Flags.Reserved | Flags.Construct)
50 cls._register_attribute(attr_maxsendbufftime)
52 attr_maxmaintlen = Attribute("MaxMaintLen",
53 "Maximum number of packets that can be stored in maintenance buffer.",
58 flags = Flags.Reserved | Flags.Construct)
60 cls._register_attribute(attr_maxmaintlen)
62 attr_maxmainttime = Attribute("MaxMaintTime",
63 "Maximum time packets can be queued in maintenance buffer.",
65 default = "+30000000000.0ns",
68 flags = Flags.Reserved | Flags.Construct)
70 cls._register_attribute(attr_maxmainttime)
72 attr_maxcachelen = Attribute("MaxCacheLen",
73 "Maximum number of route entries that can be stored in route cache.",
78 flags = Flags.Reserved | Flags.Construct)
80 cls._register_attribute(attr_maxcachelen)
82 attr_routecachetimeout = Attribute("RouteCacheTimeout",
83 "Maximum time the route cache can be queued in route cache.",
85 default = "+300000000000.0ns",
88 flags = Flags.Reserved | Flags.Construct)
90 cls._register_attribute(attr_routecachetimeout)
92 attr_maxentrieseachdst = Attribute("MaxEntriesEachDst",
93 "Maximum number of route entries for a single destination to respond.",
98 flags = Flags.Reserved | Flags.Construct)
100 cls._register_attribute(attr_maxentrieseachdst)
102 attr_sendbuffinterval = Attribute("SendBuffInterval",
103 "How often to check send buffer for packet with route.",
105 default = "+500000000000.0ns",
108 flags = Flags.Reserved | Flags.Construct)
110 cls._register_attribute(attr_sendbuffinterval)
112 attr_nodetraversaltime = Attribute("NodeTraversalTime",
113 "The time it takes to traverse two neighboring nodes.",
115 default = "+40000000.0ns",
118 flags = Flags.Reserved | Flags.Construct)
120 cls._register_attribute(attr_nodetraversaltime)
122 attr_rreqretries = Attribute("RreqRetries",
123 "Maximum number of retransmissions for request discovery of a route.",
124 type = Types.Integer,
128 flags = Flags.Reserved | Flags.Construct)
130 cls._register_attribute(attr_rreqretries)
132 attr_maintenanceretries = Attribute("MaintenanceRetries",
133 "Maximum number of retransmissions for data packets from maintenance buffer.",
134 type = Types.Integer,
138 flags = Flags.Reserved | Flags.Construct)
140 cls._register_attribute(attr_maintenanceretries)
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,
148 flags = Flags.Reserved | Flags.Construct)
150 cls._register_attribute(attr_requesttablesize)
152 attr_requestidsize = Attribute("RequestIdSize",
153 "Maximum number of request source Ids in the request table.",
154 type = Types.Integer,
158 flags = Flags.Reserved | Flags.Construct)
160 cls._register_attribute(attr_requestidsize)
162 attr_uniquerequestidsize = Attribute("UniqueRequestIdSize",
163 "Maximum number of request Ids in the request table for a single destination.",
164 type = Types.Integer,
168 flags = Flags.Reserved | Flags.Construct)
170 cls._register_attribute(attr_uniquerequestidsize)
172 attr_nonproprequesttimeout = Attribute("NonPropRequestTimeout",
173 "The timeout value for non-propagation request.",
175 default = "+30000000.0ns",
178 flags = Flags.Reserved | Flags.Construct)
180 cls._register_attribute(attr_nonproprequesttimeout)
182 attr_discoveryhoplimit = Attribute("DiscoveryHopLimit",
183 "The max discovery hop limit for route requests.",
184 type = Types.Integer,
188 flags = Flags.Reserved | Flags.Construct)
190 cls._register_attribute(attr_discoveryhoplimit)
192 attr_maxsalvagecount = Attribute("MaxSalvageCount",
193 "The max salvage count for a single data packet.",
194 type = Types.Integer,
198 flags = Flags.Reserved | Flags.Construct)
200 cls._register_attribute(attr_maxsalvagecount)
202 attr_blacklisttimeout = Attribute("BlacklistTimeout",
203 "The time for a neighbor to stay in blacklist.",
205 default = "+3000000000.0ns",
208 flags = Flags.Reserved | Flags.Construct)
210 cls._register_attribute(attr_blacklisttimeout)
212 attr_gratreplyholdoff = Attribute("GratReplyHoldoff",
213 "The time for gratuitous reply entry to expire.",
215 default = "+1000000000.0ns",
218 flags = Flags.Reserved | Flags.Construct)
220 cls._register_attribute(attr_gratreplyholdoff)
222 attr_broadcastjitter = Attribute("BroadcastJitter",
223 "The jitter time to avoid collision for broadcast packets.",
224 type = Types.Integer,
228 flags = Flags.Reserved | Flags.Construct)
230 cls._register_attribute(attr_broadcastjitter)
232 attr_linkacktimeout = Attribute("LinkAckTimeout",
233 "The time a packet in maintenance buffer wait for link acknowledgment.",
235 default = "+100000000.0ns",
238 flags = Flags.Reserved | Flags.Construct)
240 cls._register_attribute(attr_linkacktimeout)
242 attr_trylinkacks = Attribute("TryLinkAcks",
243 "The number of link acknowledgment to use.",
244 type = Types.Integer,
248 flags = Flags.Reserved | Flags.Construct)
250 cls._register_attribute(attr_trylinkacks)
252 attr_passiveacktimeout = Attribute("PassiveAckTimeout",
253 "The time a packet in maintenance buffer wait for passive acknowledgment.",
255 default = "+100000000.0ns",
258 flags = Flags.Reserved | Flags.Construct)
260 cls._register_attribute(attr_passiveacktimeout)
262 attr_trypassiveacks = Attribute("TryPassiveAcks",
263 "The number of passive acknowledgment to use.",
264 type = Types.Integer,
268 flags = Flags.Reserved | Flags.Construct)
270 cls._register_attribute(attr_trypassiveacks)
272 attr_requestperiod = Attribute("RequestPeriod",
273 "The base time interval between route requests.",
275 default = "+500000000.0ns",
278 flags = Flags.Reserved | Flags.Construct)
280 cls._register_attribute(attr_requestperiod)
282 attr_maxrequestperiod = Attribute("MaxRequestPeriod",
283 "The max time interval between route requests.",
285 default = "+10000000000.0ns",
288 flags = Flags.Reserved | Flags.Construct)
290 cls._register_attribute(attr_maxrequestperiod)
292 attr_grareplytablesize = Attribute("GraReplyTableSize",
293 "The gratuitous reply table size.",
294 type = Types.Integer,
298 flags = Flags.Reserved | Flags.Construct)
300 cls._register_attribute(attr_grareplytablesize)
302 attr_cachetype = Attribute("CacheType",
303 "Use Link Cache or use Path Cache",
305 default = "LinkCache",
308 flags = Flags.Reserved | Flags.Construct)
310 cls._register_attribute(attr_cachetype)
312 attr_stabilitydecrfactor = Attribute("StabilityDecrFactor",
313 "The stability decrease factor for link cache",
314 type = Types.Integer,
318 flags = Flags.Reserved | Flags.Construct)
320 cls._register_attribute(attr_stabilitydecrfactor)
322 attr_stabilityincrfactor = Attribute("StabilityIncrFactor",
323 "The stability increase factor for link cache",
324 type = Types.Integer,
328 flags = Flags.Reserved | Flags.Construct)
330 cls._register_attribute(attr_stabilityincrfactor)
332 attr_initstability = Attribute("InitStability",
333 "The initial stability factor for link cache",
335 default = "+25000000000.0ns",
338 flags = Flags.Reserved | Flags.Construct)
340 cls._register_attribute(attr_initstability)
342 attr_minlifetime = Attribute("MinLifeTime",
343 "The minimal life time for link cache",
345 default = "+1000000000.0ns",
348 flags = Flags.Reserved | Flags.Construct)
350 cls._register_attribute(attr_minlifetime)
352 attr_useextends = Attribute("UseExtends",
353 "The extension time for link cache",
355 default = "+120000000000.0ns",
358 flags = Flags.Reserved | Flags.Construct)
360 cls._register_attribute(attr_useextends)
362 attr_enablesubroute = Attribute("EnableSubRoute",
363 "Enables saving of sub route when receiving route error messages, only available when using path route cache",
368 flags = Flags.Reserved | Flags.Construct)
370 cls._register_attribute(attr_enablesubroute)
372 attr_retransincr = Attribute("RetransIncr",
373 "The increase time for retransmission timer when facing network congestion",
375 default = "+20000000.0ns",
378 flags = Flags.Reserved | Flags.Construct)
380 cls._register_attribute(attr_retransincr)
382 attr_maxnetworkqueuesize = Attribute("MaxNetworkQueueSize",
383 "The max number of packet to save in the network queue.",
384 type = Types.Integer,
388 flags = Flags.Reserved | Flags.Construct)
390 cls._register_attribute(attr_maxnetworkqueuesize)
392 attr_maxnetworkqueuedelay = Attribute("MaxNetworkQueueDelay",
393 "The max time for a packet to stay in the network queue.",
395 default = "+30000000000.0ns",
398 flags = Flags.Reserved | Flags.Construct)
400 cls._register_attribute(attr_maxnetworkqueuedelay)
402 attr_numpriorityqueues = Attribute("NumPriorityQueues",
403 "The max number of packet to save in the network queue.",
404 type = Types.Integer,
408 flags = Flags.Reserved | Flags.Construct)
410 cls._register_attribute(attr_numpriorityqueues)
412 attr_linkacknowledgment = Attribute("LinkAcknowledgment",
413 "Enable Link layer acknowledgment mechanism",
418 flags = Flags.Reserved | Flags.Construct)
420 cls._register_attribute(attr_linkacknowledgment)
422 attr_protocolnumber = Attribute("ProtocolNumber",
423 "The Ip protocol number.",
424 type = Types.Integer,
428 flags = Flags.Reserved | Flags.Construct)
430 cls._register_attribute(attr_protocolnumber)
435 def _register_traces(cls):
437 tx = Trace("Tx", "Send DSR packet.")
439 cls._register_trace(tx)
441 drop = Trace("Drop", "Drop DSR packet")
443 cls._register_trace(drop)
447 def __init__(self, ec, guid):
448 super(NS3dsrDsrRouting, self).__init__(ec, guid)
449 self._home = "ns3-dsr-dsr-routing-%s" % self.guid