Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This code was ported from NS-2.34, with licence: | 3 * This code was ported from NS-2.34, with licence: |
4 * | 4 * |
5 * Copyright (c) 1990-1997 Regents of the University of California. | 5 * Copyright (c) 1990-1997 Regents of the University of California. |
6 * All rights reserved. | 6 * All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 * SUCH DAMAGE. | 34 * SUCH DAMAGE. |
35 * | 35 * |
36 * | 36 * |
37 * This port: | 37 * This port: |
38 * | 38 * |
39 * Copyright © 2011 Marcos Talau | 39 * Copyright © 2011 Marcos Talau |
40 * | 40 * |
41 * This program is free software: you can redistribute it and/or modify | 41 * This program is free software: you can redistribute it and/or modify |
42 * it under the terms of the GNU General Public License as published by | 42 * it under the terms of the GNU General Public License as published by |
43 * the Free Software Foundation, either version 3 of the License, or | 43 * the Free Software Foundation, either version 3 of the License, or |
44 * (at your option) any later version. | 44 * (at your option) any later version. |
45 * | 45 * |
46 * This program is distributed in the hope that it will be useful, | 46 * This program is distributed in the hope that it will be useful, |
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 47 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 * Create a RED queue | 92 * Create a RED queue |
93 */ | 93 */ |
94 RedQueue (); | 94 RedQueue (); |
95 | 95 |
96 virtual ~RedQueue (); | 96 virtual ~RedQueue (); |
97 | 97 |
98 typedef struct | 98 typedef struct |
99 { | 99 { |
100 // Early probability drops | 100 // Early probability drops |
101 uint32_t unforcedDrop; | 101 uint32_t unforcedDrop; |
102 // Forced drops, qavg > max threshold | 102 // Forced drops, qavg > max threshold |
103 uint32_t forcedDrop; | 103 uint32_t forcedDrop; |
104 // Drops due to queue limits | 104 // Drops due to queue limits |
105 uint32_t qLimDrop; | 105 uint32_t qLimDrop; |
106 } Stats; | 106 } Stats; |
107 | 107 |
108 // Drop types | 108 // Drop types |
109 enum | 109 enum |
110 { | 110 { |
111 DTYPE_NONE, // Ok, no drop | 111 DTYPE_NONE, // Ok, no drop |
112 DTYPE_FORCED, // A "forced" drop | 112 DTYPE_FORCED, // A "forced" drop |
113 DTYPE_UNFORCED, // An "unforced" (random) drop | 113 DTYPE_UNFORCED, // An "unforced" (random) drop |
114 }; | 114 }; |
115 | 115 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 * \param lim The limit in bytes or packets. | 151 * \param lim The limit in bytes or packets. |
152 */ | 152 */ |
153 void SetQueueLimit(uint32_t lim); | 153 void SetQueueLimit(uint32_t lim); |
154 | 154 |
155 /* | 155 /* |
156 * Set the thresh limits of RED. | 156 * Set the thresh limits of RED. |
157 * | 157 * |
158 * \param min Minimum thresh in bytes or packets. | 158 * \param min Minimum thresh in bytes or packets. |
159 * \param max Maximum thresh in bytes or packets. | 159 * \param max Maximum thresh in bytes or packets. |
160 */ | 160 */ |
161 void SetTh(double min, double max); | 161 void SetTh(double minTh, double maxTh); |
162 | 162 |
163 /* | 163 /* |
164 * Get the RED statistics after running. | 164 * Get the RED statistics after running. |
165 * | 165 * |
166 * \returns The drop statistics. | 166 * \returns The drop statistics. |
167 */ | 167 */ |
168 Stats GetStats(); | 168 Stats GetStats(); |
169 | 169 |
170 private: | 170 private: |
171 virtual bool DoEnqueue (Ptr<Packet> p); | 171 virtual bool DoEnqueue (Ptr<Packet> p); |
172 virtual Ptr<Packet> DoDequeue (void); | 172 virtual Ptr<Packet> DoDequeue (void); |
173 virtual Ptr<const Packet> DoPeek (void) const; | 173 virtual Ptr<const Packet> DoPeek (void) const; |
174 | 174 |
Duy
2011/10/02 00:05:04
We need comments to describe in detail each of the
talau
2011/11/27 16:02:05
Done.
| |
175 // ... | |
175 void InitializeParams (void); | 176 void InitializeParams (void); |
177 // Compute the average queue size | |
176 double Estimator (uint32_t nQueued, uint32_t m, double qAvg, double qW); | 178 double Estimator (uint32_t nQueued, uint32_t m, double qAvg, double qW); |
179 // Check if packet p needs to be dropped due to probability mark | |
177 uint32_t DropEarly (Ptr<Packet> p, uint32_t qSize); | 180 uint32_t DropEarly (Ptr<Packet> p, uint32_t qSize); |
181 // Returns a probability using these function parameters for the DropEarly fun tion | |
178 double CalculatePNew (double qAvg, double maxTh, bool gentle, double vA, | 182 double CalculatePNew (double qAvg, double maxTh, bool gentle, double vA, |
179 double vB, double vC, double vD, double maxP); | 183 double vB, double vC, double vD, double maxP); |
184 // Returns a probability using these function parameters for the DropEarly fun tion | |
180 double ModifyP(double p, uint32_t count, uint32_t countBytes, | 185 double ModifyP(double p, uint32_t count, uint32_t countBytes, |
181 uint32_t meanPktSize, bool wait, uint32_t size); | 186 uint32_t meanPktSize, bool wait, uint32_t size); |
182 | 187 |
183 std::list<Ptr<Packet> > m_packets; | 188 std::list<Ptr<Packet> > m_packets; |
184 | 189 |
185 uint32_t m_bytesInQueue; | 190 uint32_t m_bytesInQueue; |
186 bool m_hasRedStarted; | 191 bool m_hasRedStarted; |
187 Stats m_stats; | 192 Stats m_stats; |
188 | 193 |
189 // ** Variables supplied by user | 194 // ** Variables supplied by user |
190 // Bytes or packets? | 195 // Bytes or packets? |
191 Mode m_mode; | 196 Mode m_mode; |
192 // Avg pkt size | 197 // Avg pkt size |
193 uint32_t m_meanPktSize; | 198 uint32_t m_meanPktSize; |
194 // Avg pkt size used during idle times | 199 // Avg pkt size used during idle times |
195 uint32_t m_idlePktSize; | 200 uint32_t m_idlePktSize; |
196 // True for waiting between dropped packets | 201 // True for waiting between dropped packets |
197 bool m_isWait; | 202 bool m_isWait; |
198 // True to increases dropping prob. slowly when ave queue exceeds maxthresh | 203 // True to increases dropping prob. slowly when ave queue exceeds maxthresh |
199 bool m_isGentle; | 204 bool m_isGentle; |
200 // Min avg length threshold (bytes), should be >= 2*minTh | 205 // Min avg length threshold (bytes) |
Peter Barnes
2011/09/02 17:21:35
Does the "should" clause belong here? or only on
talau
2011/11/18 13:45:43
Done.
| |
201 double m_minTh; | 206 double m_minTh; |
202 // Max avg length threshold (bytes), should be >= 2*minTh | 207 // Max avg length threshold (bytes), should be >= 2*minTh |
203 double m_maxTh; | 208 double m_maxTh; |
204 // Queue limit in bytes / packets | 209 // Queue limit in bytes / packets |
205 uint32_t m_queueLimit; | 210 uint32_t m_queueLimit; |
206 // Queue weight given to cur q size sample | 211 // Queue weight given to cur q size sample |
207 double m_qW; | 212 double m_qW; |
208 // The max probability of dropping a packet | 213 // The max probability of dropping a packet |
209 double m_lInterm; | 214 double m_lInterm; |
210 // Ns-1 compatibility | 215 // Ns-1 compatibility |
211 bool m_isNs1Compat; | 216 bool m_isNs1Compat; |
212 // Link bandwidth | 217 // Link bandwidth |
213 DataRate m_linkBandwidth; | 218 DataRate m_linkBandwidth; |
214 // Link delay | 219 // Link delay |
215 Time m_linkDelay; | 220 Time m_linkDelay; |
216 | 221 |
217 // ** Variables maintained by RED | 222 // ** Variables maintained by RED |
218 // Prob. of packet drop before "count" | 223 // Prob. of packet drop before "count" |
219 double m_vProb1; | 224 double m_vProb1; |
220 // v_prob = v_a * v_ave + v_b | 225 // v_prob = v_a * v_ave + v_b |
221 double m_vA;» » | 226 double m_vA; |
Peter Barnes
2011/09/02 17:21:35
extraneous white space (tabs?) at end of this line
talau
2011/11/18 13:45:43
Done.
| |
222 double m_vB; | 227 double m_vB; |
223 // Used for "gentle" mode | 228 // Used for "gentle" mode |
224 double m_vC;» » | 229 double m_vC; |
225 // Used for "gentle" mode | 230 // Used for "gentle" mode |
226 double m_vD;» » | 231 double m_vD; |
227 // Current max_p | 232 // Current max_p |
228 double m_curMaxP; | 233 double m_curMaxP; |
229 // Prob. of packet drop | 234 // Prob. of packet drop |
230 double m_vProb; | 235 double m_vProb; |
231 // # of bytes since last drop | 236 // # of bytes since last drop |
232 uint32_t m_countBytes; | 237 uint32_t m_countBytes; |
233 // 0 when average queue first exceeds thresh | 238 // 0 when average queue first exceeds thresh |
234 uint32_t m_old; | 239 uint32_t m_old; |
235 // 0/1 idle status | 240 // 0/1 idle status |
236 uint32_t m_idle; | 241 uint32_t m_idle; |
237 // packet time constant in packets/second | 242 // packet time constant in packets/second |
238 double m_ptc; | 243 double m_ptc; |
239 // Average queue length | 244 // Average queue length |
240 double m_qAvg; | 245 double m_qAvg; |
241 // number of packets since last random number generation | 246 // number of packets since last random number generation |
242 uint32_t m_count; | 247 uint32_t m_count; |
243 /* | 248 /* |
244 * 0 for default RED | 249 * 0 for default RED |
245 * 1 for not dropping/marking when the instantaneous queue is much below the, | 250 * 1 experimental (see red-queue.cc) |
Peter Barnes
2011/09/02 17:21:35
red-queue.cc line 235 checks m_cautious = 3, docum
talau
2011/11/18 13:45:43
Done.
| |
246 * average. (NOT IMPLEMENTED YET) | 251 * 2 experimental (see red-queue.cc) |
252 * 3 use Idle packet size in the ptc | |
247 */ | 253 */ |
248 uint32_t m_cautious; | 254 uint32_t m_cautious; |
249 // Start of current idle period | 255 // Start of current idle period |
250 Time m_idleTime; | 256 Time m_idleTime; |
251 }; | 257 }; |
252 | 258 |
253 }; // namespace ns3 | 259 }; // namespace ns3 |
254 | 260 |
255 #endif // RED_QUEUE_H | 261 #endif // RED_QUEUE_H |
LEFT | RIGHT |