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.ns3queue import NS3BaseQueue
26 class NS3RedQueue(NS3BaseQueue):
27 _rtype = "ns3::RedQueue"
30 def _register_attributes(cls):
32 attr_meanpktsize = Attribute("MeanPktSize",
33 "Average of packet size",
38 flags = Flags.Reserved | Flags.Construct)
40 cls._register_attribute(attr_meanpktsize)
42 attr_idlepktsize = Attribute("IdlePktSize",
43 "Average packet size used during idle times. Used when m_cautions = 3",
48 flags = Flags.Reserved | Flags.Construct)
50 cls._register_attribute(attr_idlepktsize)
52 attr_wait = Attribute("Wait",
53 "True for waiting between dropped packets",
58 flags = Flags.Reserved | Flags.Construct)
60 cls._register_attribute(attr_wait)
62 attr_gentle = Attribute("Gentle",
63 "True to increases dropping probability slowly when average queue exceeds maxthresh",
68 flags = Flags.Reserved | Flags.Construct)
70 cls._register_attribute(attr_gentle)
72 attr_minth = Attribute("MinTh",
73 "Minimum average length threshold in packets/bytes",
78 flags = Flags.Reserved | Flags.Construct)
80 cls._register_attribute(attr_minth)
82 attr_maxth = Attribute("MaxTh",
83 "Maximum average length threshold in packets/bytes",
88 flags = Flags.Reserved | Flags.Construct)
90 cls._register_attribute(attr_maxth)
92 attr_queuelimit = Attribute("QueueLimit",
93 "Queue limit in bytes/packets",
98 flags = Flags.Reserved | Flags.Construct)
100 cls._register_attribute(attr_queuelimit)
102 attr_qw = Attribute("QW",
103 "Queue weight related to the exponential weighted moving average (EWMA)",
108 flags = Flags.Reserved | Flags.Construct)
110 cls._register_attribute(attr_qw)
112 attr_linterm = Attribute("LInterm",
113 "The maximum probability of dropping a packet",
118 flags = Flags.Reserved | Flags.Construct)
120 cls._register_attribute(attr_linterm)
122 attr_ns1compat = Attribute("Ns1Compat",
123 "NS-1 compatibility",
128 flags = Flags.Reserved | Flags.Construct)
130 cls._register_attribute(attr_ns1compat)
132 attr_linkbandwidth = Attribute("LinkBandwidth",
133 "The RED link bandwidth",
135 default = "1500000bps",
138 flags = Flags.Reserved | Flags.Construct)
140 cls._register_attribute(attr_linkbandwidth)
142 attr_linkdelay = Attribute("LinkDelay",
143 "The RED link delay",
145 default = "+20000000.0ns",
148 flags = Flags.Reserved | Flags.Construct)
150 cls._register_attribute(attr_linkdelay)
155 def _register_traces(cls):
157 enqueue = Trace("Enqueue", "Enqueue a packet in the queue.")
159 cls._register_trace(enqueue)
161 dequeue = Trace("Dequeue", "Dequeue a packet from the queue.")
163 cls._register_trace(dequeue)
165 drop = Trace("Drop", "Drop a packet stored in the queue.")
167 cls._register_trace(drop)
171 def __init__(self, ec, guid):
172 super(NS3RedQueue, self).__init__(ec, guid)
173 self._home = "ns3-red-queue-%s" % self.guid