d68166e7c74dc58c0fb59e2f67abddab49d9ee96
[nepi.git] / src / nepi / resources / ns3 / classes / red_queue.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.ns3queue import NS3BaseQueue 
24
25 @clsinit_copy
26 class NS3RedQueue(NS3BaseQueue):
27     _rtype = "ns3::RedQueue"
28
29     @classmethod
30     def _register_attributes(cls):
31         
32         attr_meanpktsize = Attribute("MeanPktSize",
33             "Average of packet size",
34             type = Types.Integer,
35             default = "500",  
36             allowed = None,
37             range = None,    
38             flags = Flags.Reserved | Flags.Construct)
39
40         cls._register_attribute(attr_meanpktsize)
41
42         attr_idlepktsize = Attribute("IdlePktSize",
43             "Average packet size used during idle times. Used when m_cautions = 3",
44             type = Types.Integer,
45             default = "0",  
46             allowed = None,
47             range = None,    
48             flags = Flags.Reserved | Flags.Construct)
49
50         cls._register_attribute(attr_idlepktsize)
51
52         attr_wait = Attribute("Wait",
53             "True for waiting between dropped packets",
54             type = Types.Bool,
55             default = "True",  
56             allowed = None,
57             range = None,    
58             flags = Flags.Reserved | Flags.Construct)
59
60         cls._register_attribute(attr_wait)
61
62         attr_gentle = Attribute("Gentle",
63             "True to increases dropping probability slowly when average queue exceeds maxthresh",
64             type = Types.Bool,
65             default = "True",  
66             allowed = None,
67             range = None,    
68             flags = Flags.Reserved | Flags.Construct)
69
70         cls._register_attribute(attr_gentle)
71
72         attr_minth = Attribute("MinTh",
73             "Minimum average length threshold in packets/bytes",
74             type = Types.Double,
75             default = "5",  
76             allowed = None,
77             range = None,    
78             flags = Flags.Reserved | Flags.Construct)
79
80         cls._register_attribute(attr_minth)
81
82         attr_maxth = Attribute("MaxTh",
83             "Maximum average length threshold in packets/bytes",
84             type = Types.Double,
85             default = "15",  
86             allowed = None,
87             range = None,    
88             flags = Flags.Reserved | Flags.Construct)
89
90         cls._register_attribute(attr_maxth)
91
92         attr_queuelimit = Attribute("QueueLimit",
93             "Queue limit in bytes/packets",
94             type = Types.Integer,
95             default = "25",  
96             allowed = None,
97             range = None,    
98             flags = Flags.Reserved | Flags.Construct)
99
100         cls._register_attribute(attr_queuelimit)
101
102         attr_qw = Attribute("QW",
103             "Queue weight related to the exponential weighted moving average (EWMA)",
104             type = Types.Double,
105             default = "0.002",  
106             allowed = None,
107             range = None,    
108             flags = Flags.Reserved | Flags.Construct)
109
110         cls._register_attribute(attr_qw)
111
112         attr_linterm = Attribute("LInterm",
113             "The maximum probability of dropping a packet",
114             type = Types.Double,
115             default = "50",  
116             allowed = None,
117             range = None,    
118             flags = Flags.Reserved | Flags.Construct)
119
120         cls._register_attribute(attr_linterm)
121
122         attr_ns1compat = Attribute("Ns1Compat",
123             "NS-1 compatibility",
124             type = Types.Bool,
125             default = "False",  
126             allowed = None,
127             range = None,    
128             flags = Flags.Reserved | Flags.Construct)
129
130         cls._register_attribute(attr_ns1compat)
131
132         attr_linkbandwidth = Attribute("LinkBandwidth",
133             "The RED link bandwidth",
134             type = Types.String,
135             default = "1500000bps",  
136             allowed = None,
137             range = None,    
138             flags = Flags.Reserved | Flags.Construct)
139
140         cls._register_attribute(attr_linkbandwidth)
141
142         attr_linkdelay = Attribute("LinkDelay",
143             "The RED link delay",
144             type = Types.String,
145             default = "+20000000.0ns",  
146             allowed = None,
147             range = None,    
148             flags = Flags.Reserved | Flags.Construct)
149
150         cls._register_attribute(attr_linkdelay)
151
152
153
154     @classmethod
155     def _register_traces(cls):
156         
157         enqueue = Trace("Enqueue", "Enqueue a packet in the queue.")
158
159         cls._register_trace(enqueue)
160
161         dequeue = Trace("Dequeue", "Dequeue a packet from the queue.")
162
163         cls._register_trace(dequeue)
164
165         drop = Trace("Drop", "Drop a packet stored in the queue.")
166
167         cls._register_trace(drop)
168
169
170
171     def __init__(self, ec, guid):
172         super(NS3RedQueue, self).__init__(ec, guid)
173         self._home = "ns3-red-queue-%s" % self.guid