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