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 * Copyright (c) 2016 NITK Surathkal | 3 * Copyright (c) 2016 NITK Surathkal |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 .AddAttribute ("Decrement", | 70 .AddAttribute ("Decrement", |
71 "Pmark decrement Value", | 71 "Pmark decrement Value", |
72 DoubleValue (0.00025), | 72 DoubleValue (0.00025), |
73 MakeDoubleAccessor (&BlueQueueDisc::m_decrement), | 73 MakeDoubleAccessor (&BlueQueueDisc::m_decrement), |
74 MakeDoubleChecker<double> ()) | 74 MakeDoubleChecker<double> ()) |
75 .AddAttribute ("FreezeTime", | 75 .AddAttribute ("FreezeTime", |
76 "Time interval during which Pmark cannot be updated", | 76 "Time interval during which Pmark cannot be updated", |
77 TimeValue (Seconds (0.1)), | 77 TimeValue (Seconds (0.1)), |
78 MakeTimeAccessor (&BlueQueueDisc::m_freezeTime), | 78 MakeTimeAccessor (&BlueQueueDisc::m_freezeTime), |
79 MakeTimeChecker ()) | 79 MakeTimeChecker ()) |
| 80 .AddAttribute ("UseEcn", |
| 81 "True to use ECN (packets are marked instead of being dropped
)", |
| 82 BooleanValue (false), |
| 83 MakeBooleanAccessor (&BlueQueueDisc::m_useEcn), |
| 84 MakeBooleanChecker ()) |
| 85 |
80 ; | 86 ; |
81 | 87 |
82 return tid; | 88 return tid; |
83 } | 89 } |
84 | 90 |
85 BlueQueueDisc::BlueQueueDisc () | 91 BlueQueueDisc::BlueQueueDisc () |
86 : QueueDisc () | 92 : QueueDisc () |
87 { | 93 { |
88 NS_LOG_FUNCTION (this); | 94 NS_LOG_FUNCTION (this); |
89 m_uv = CreateObject<UniformRandomVariable> (); | 95 m_uv = CreateObject<UniformRandomVariable> (); |
(...skipping 12 matching lines...) Expand all Loading... |
102 QueueDisc::DoDispose (); | 108 QueueDisc::DoDispose (); |
103 } | 109 } |
104 | 110 |
105 void | 111 void |
106 BlueQueueDisc::SetMode (QueueDiscMode mode) | 112 BlueQueueDisc::SetMode (QueueDiscMode mode) |
107 { | 113 { |
108 NS_LOG_FUNCTION (this << mode); | 114 NS_LOG_FUNCTION (this << mode); |
109 m_mode = mode; | 115 m_mode = mode; |
110 } | 116 } |
111 | 117 |
112 | |
113 BlueQueueDisc::QueueDiscMode | 118 BlueQueueDisc::QueueDiscMode |
114 BlueQueueDisc::GetMode (void) | 119 BlueQueueDisc::GetMode (void) |
115 { | 120 { |
116 NS_LOG_FUNCTION (this); | 121 NS_LOG_FUNCTION (this); |
117 return m_mode; | 122 return m_mode; |
118 } | 123 } |
119 | 124 |
120 void | 125 void |
121 BlueQueueDisc::SetQueueLimit (uint32_t lim) | 126 BlueQueueDisc::SetQueueLimit (uint32_t lim) |
122 { | 127 { |
(...skipping 10 matching lines...) Expand all Loading... |
133 return GetInternalQueue (0)->GetNBytes (); | 138 return GetInternalQueue (0)->GetNBytes (); |
134 } | 139 } |
135 else if (GetMode () == QUEUE_DISC_MODE_PACKETS) | 140 else if (GetMode () == QUEUE_DISC_MODE_PACKETS) |
136 { | 141 { |
137 return GetInternalQueue (0)->GetNPackets (); | 142 return GetInternalQueue (0)->GetNPackets (); |
138 } | 143 } |
139 else | 144 else |
140 { | 145 { |
141 NS_ABORT_MSG ("Unknown Blue mode."); | 146 NS_ABORT_MSG ("Unknown Blue mode."); |
142 } | 147 } |
143 } | |
144 | |
145 BlueQueueDisc::Stats | |
146 BlueQueueDisc::GetStats () | |
147 { | |
148 NS_LOG_FUNCTION (this); | |
149 return m_stats; | |
150 } | 148 } |
151 | 149 |
152 int64_t | 150 int64_t |
153 BlueQueueDisc::AssignStreams (int64_t stream) | 151 BlueQueueDisc::AssignStreams (int64_t stream) |
154 { | 152 { |
155 NS_LOG_FUNCTION (this << stream); | 153 NS_LOG_FUNCTION (this << stream); |
156 m_uv->SetStream (stream); | 154 m_uv->SetStream (stream); |
157 return 1; | 155 return 1; |
158 } | 156 } |
159 | 157 |
160 bool | 158 bool |
161 BlueQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item) | 159 BlueQueueDisc::DoEnqueue (Ptr<QueueDiscItem> item) |
162 { | 160 { |
163 NS_LOG_FUNCTION (this << item); | 161 NS_LOG_FUNCTION (this << item); |
| 162 |
164 uint32_t nQueued = GetQueueSize (); | 163 uint32_t nQueued = GetQueueSize (); |
165 | 164 |
166 if (m_isIdle) | 165 if (m_isIdle) |
167 { | 166 { |
168 DecrementPmark (); | 167 DecrementPmark (); |
169 m_isIdle = false; | 168 m_isIdle = false; |
170 } | 169 } |
171 | 170 |
172 if ((GetMode () == QUEUE_DISC_MODE_PACKETS && nQueued >= m_queueLimit) | 171 if ((GetMode () == QUEUE_DISC_MODE_PACKETS && nQueued >= m_queueLimit) |
173 || (GetMode () == QUEUE_DISC_MODE_BYTES && nQueued + item->GetSize () > m_
queueLimit)) | 172 || (GetMode () == QUEUE_DISC_MODE_BYTES && nQueued + item->GetSize () > m_
queueLimit)) |
174 { | 173 { |
175 // Drops due to queue limit: reactive | 174 // Drops due to queue limit: reactive |
176 Drop (item); | 175 DropBeforeEnqueue (item, FORCED_DROP); |
177 m_stats.forcedDrop++; | |
178 | |
179 // Increment the Pmark | 176 // Increment the Pmark |
180 IncrementPmark (); | 177 IncrementPmark (); |
181 return false; | 178 return false; |
182 } | 179 } |
183 else if (DropEarly ()) | 180 else if (DropEarly ()) |
184 { | 181 { |
185 // Early probability drop: proactive | 182 if (!m_useEcn || !Mark (item, UNFORCED_MARK)) |
186 Drop (item); | 183 { |
187 m_stats.unforcedDrop++; | 184 NS_LOG_DEBUG ("Proactive Drop"); |
188 // Increment the Pmark | 185 // Early probability drop: proactive |
189 IncrementPmark (); | 186 DropBeforeEnqueue (item, UNFORCED_DROP); |
190 return false; | 187 IncrementPmark (); |
| 188 return false; |
| 189 } |
191 } | 190 } |
192 | 191 |
193 // No drop | 192 // No drop |
194 bool isEnqueued = GetInternalQueue (0)->Enqueue (item); | 193 bool isEnqueued = GetInternalQueue (0)->Enqueue (item); |
195 | 194 |
196 // If Queue::Enqueue fails, QueueDisc::Drop is called by the internal queue | 195 // If Queue::Enqueue fails, QueueDisc::DropBeforeEnqueue is called by the |
197 // because QueueDisc::AddInternalQueue sets the drop callback | 196 // internal queue because QueueDisc::AddInternalQueue sets the trace callback |
198 | 197 |
199 NS_LOG_LOGIC ("\t bytesInQueue " << GetInternalQueue (0)->GetNBytes ()); | 198 NS_LOG_LOGIC ("\t bytesInQueue " << GetInternalQueue (0)->GetNBytes ()); |
200 NS_LOG_LOGIC ("\t packetsInQueue " << GetInternalQueue (0)->GetNPackets ()); | 199 NS_LOG_LOGIC ("\t packetsInQueue " << GetInternalQueue (0)->GetNPackets ()); |
201 | 200 |
202 return isEnqueued; | 201 return isEnqueued; |
203 } | 202 } |
204 | 203 |
205 void | 204 void |
206 BlueQueueDisc::InitializeParams (void) | 205 BlueQueueDisc::InitializeParams (void) |
207 { | 206 { |
208 // Initially queue is empty so variables are initialize to zero except m_dqCou
nt | 207 // Initially queue is empty so variables are initialize to zero except m_dqCou
nt |
209 m_lastUpdateTime = Time (Seconds (0.0)); | 208 m_lastUpdateTime = Time (Seconds (0.0)); |
210 m_idleStartTime = Time (Seconds (0.0)); | 209 m_idleStartTime = Time (Seconds (0.0)); |
211 m_stats.forcedDrop = 0; | |
212 m_stats.unforcedDrop = 0; | |
213 | |
214 m_isIdle = true; | 210 m_isIdle = true; |
215 } | 211 } |
216 | 212 |
217 bool BlueQueueDisc::DropEarly (void) | 213 bool BlueQueueDisc::DropEarly (void) |
218 { | 214 { |
219 NS_LOG_FUNCTION (this); | 215 NS_LOG_FUNCTION (this); |
220 double u = m_uv->GetValue (); | 216 double u = m_uv->GetValue (); |
221 if (u <= m_Pmark) | 217 if (u <= m_Pmark) |
222 { | 218 { |
223 return true; | 219 return true; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 331 } |
336 AddInternalQueue (queue); | 332 AddInternalQueue (queue); |
337 } | 333 } |
338 | 334 |
339 if (GetNInternalQueues () != 1) | 335 if (GetNInternalQueues () != 1) |
340 { | 336 { |
341 NS_LOG_ERROR ("BlueQueueDisc needs 1 internal queue"); | 337 NS_LOG_ERROR ("BlueQueueDisc needs 1 internal queue"); |
342 return false; | 338 return false; |
343 } | 339 } |
344 | 340 |
345 if ((GetInternalQueue (0)->GetMode () == QueueBase::QUEUE_MODE_PACKETS && m_mo
de == QUEUE_DISC_MODE_BYTES) | 341 if ((GetInternalQueue (0)->GetMode () == QueueBase::QUEUE_MODE_PACKETS && m_mo
de == QUEUE_DISC_MODE_BYTES) || |
346 || (GetInternalQueue (0)->GetMode () == QueueBase::QUEUE_MODE_BYTES && m_m
ode == QUEUE_DISC_MODE_PACKETS)) | 342 (GetInternalQueue (0)->GetMode () == QueueBase::QUEUE_MODE_BYTES && m_mode
== QUEUE_DISC_MODE_PACKETS)) |
347 { | 343 { |
348 NS_LOG_ERROR ("The mode of the provided queue does not match the mode set
on the BlueQueueDisc"); | 344 NS_LOG_ERROR ("The mode of the provided queue does not match the mode set
on the BlueQueueDisc"); |
349 return false; | 345 return false; |
350 } | 346 } |
351 | 347 |
352 if ((m_mode == QUEUE_DISC_MODE_PACKETS && GetInternalQueue (0)->GetMaxPackets
() < m_queueLimit) | 348 if ((m_mode == QUEUE_DISC_MODE_PACKETS && GetInternalQueue (0)->GetMaxPackets
() != m_queueLimit) |
353 || (m_mode == QUEUE_DISC_MODE_BYTES && GetInternalQueue (0)->GetMaxBytes
() < m_queueLimit)) | 349 || (m_mode == QUEUE_DISC_MODE_BYTES && GetInternalQueue (0)->GetMaxBytes
() != m_queueLimit)) |
354 { | 350 { |
355 NS_LOG_ERROR ("The size of the internal queue is less than the queue disc
limit"); | 351 NS_LOG_ERROR ("The size of the internal queue differs from the queue disc
limit"); |
356 return false; | 352 return false; |
357 } | 353 } |
358 | 354 |
359 return true; | 355 return true; |
360 } | 356 } |
361 | 357 |
362 } //namespace ns3 | 358 } //namespace ns3 |
LEFT | RIGHT |