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 version 2 as
7 # published by the Free Software Foundation;
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.
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/>.
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, \
22 from nepi.resources.ns3.ns3queue import NS3BaseQueue
25 class NS3RedQueue(NS3BaseQueue):
26 _rtype = "ns3::RedQueue"
29 def _register_attributes(cls):
31 attr_meanpktsize = Attribute("MeanPktSize",
32 "Average of packet size",
37 flags = Flags.Reserved | Flags.Construct)
39 cls._register_attribute(attr_meanpktsize)
41 attr_idlepktsize = Attribute("IdlePktSize",
42 "Average packet size used during idle times. Used when m_cautions = 3",
47 flags = Flags.Reserved | Flags.Construct)
49 cls._register_attribute(attr_idlepktsize)
51 attr_wait = Attribute("Wait",
52 "True for waiting between dropped packets",
57 flags = Flags.Reserved | Flags.Construct)
59 cls._register_attribute(attr_wait)
61 attr_gentle = Attribute("Gentle",
62 "True to increases dropping probability slowly when average queue exceeds maxthresh",
67 flags = Flags.Reserved | Flags.Construct)
69 cls._register_attribute(attr_gentle)
71 attr_minth = Attribute("MinTh",
72 "Minimum average length threshold in packets/bytes",
77 flags = Flags.Reserved | Flags.Construct)
79 cls._register_attribute(attr_minth)
81 attr_maxth = Attribute("MaxTh",
82 "Maximum average length threshold in packets/bytes",
87 flags = Flags.Reserved | Flags.Construct)
89 cls._register_attribute(attr_maxth)
91 attr_queuelimit = Attribute("QueueLimit",
92 "Queue limit in bytes/packets",
97 flags = Flags.Reserved | Flags.Construct)
99 cls._register_attribute(attr_queuelimit)
101 attr_qw = Attribute("QW",
102 "Queue weight related to the exponential weighted moving average (EWMA)",
107 flags = Flags.Reserved | Flags.Construct)
109 cls._register_attribute(attr_qw)
111 attr_linterm = Attribute("LInterm",
112 "The maximum probability of dropping a packet",
117 flags = Flags.Reserved | Flags.Construct)
119 cls._register_attribute(attr_linterm)
121 attr_ns1compat = Attribute("Ns1Compat",
122 "NS-1 compatibility",
127 flags = Flags.Reserved | Flags.Construct)
129 cls._register_attribute(attr_ns1compat)
131 attr_linkbandwidth = Attribute("LinkBandwidth",
132 "The RED link bandwidth",
134 default = "1500000bps",
137 flags = Flags.Reserved | Flags.Construct)
139 cls._register_attribute(attr_linkbandwidth)
141 attr_linkdelay = Attribute("LinkDelay",
142 "The RED link delay",
144 default = "+20000000.0ns",
147 flags = Flags.Reserved | Flags.Construct)
149 cls._register_attribute(attr_linkdelay)
154 def _register_traces(cls):
156 enqueue = Trace("Enqueue", "Enqueue a packet in the queue.")
158 cls._register_trace(enqueue)
160 dequeue = Trace("Dequeue", "Dequeue a packet from the queue.")
162 cls._register_trace(dequeue)
164 drop = Trace("Drop", "Drop a packet stored in the queue.")
166 cls._register_trace(drop)
170 def __init__(self, ec, guid):
171 super(NS3RedQueue, self).__init__(ec, guid)
172 self._home = "ns3-red-queue-%s" % self.guid