OLD | NEW |
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) 2012 Andrew McGregor | 3 * Copyright (c) 2012 Andrew McGregor |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 /** | 56 /** |
57 * Returns the current time translated in CoDel time representation | 57 * Returns the current time translated in CoDel time representation |
58 * \return the current time | 58 * \return the current time |
59 */ | 59 */ |
60 static uint32_t CoDelGetTime (void) | 60 static uint32_t CoDelGetTime (void) |
61 { | 61 { |
62 Time time = Simulator::Now (); | 62 Time time = Simulator::Now (); |
63 uint64_t ns = time.GetNanoSeconds (); | 63 uint64_t ns = time.GetNanoSeconds (); |
64 | 64 |
65 return static_cast<uint32_t>(ns >> CODEL_SHIFT); | 65 return static_cast<uint32_t> (ns >> CODEL_SHIFT); |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 NS_OBJECT_ENSURE_REGISTERED (CoDelQueueDisc); | 69 NS_OBJECT_ENSURE_REGISTERED (CoDelQueueDisc); |
70 | 70 |
71 TypeId CoDelQueueDisc::GetTypeId (void) | 71 TypeId CoDelQueueDisc::GetTypeId (void) |
72 { | 72 { |
73 static TypeId tid = TypeId ("ns3::CoDelQueueDisc") | 73 static TypeId tid = TypeId ("ns3::CoDelQueueDisc") |
74 .SetParent<QueueDisc> () | 74 .SetParent<QueueDisc> () |
75 .SetGroupName ("TrafficControl") | 75 .SetGroupName ("TrafficControl") |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 void | 167 void |
168 CoDelQueueDisc::NewtonStep (void) | 168 CoDelQueueDisc::NewtonStep (void) |
169 { | 169 { |
170 NS_LOG_FUNCTION (this); | 170 NS_LOG_FUNCTION (this); |
171 uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT; | 171 uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT; |
172 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32; | 172 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32; |
173 uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2); | 173 uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2); |
174 | 174 |
175 val >>= 2; /* avoid overflow */ | 175 val >>= 2; /* avoid overflow */ |
176 val = (val * invsqrt) >> (32 - 2 + 1); | 176 val = (val * invsqrt) >> (32 - 2 + 1); |
177 m_recInvSqrt = static_cast<uint16_t>(val >> REC_INV_SQRT_SHIFT); | 177 m_recInvSqrt = static_cast<uint16_t> (val >> REC_INV_SQRT_SHIFT); |
178 } | 178 } |
179 | 179 |
180 uint32_t | 180 uint32_t |
181 CoDelQueueDisc::ControlLaw (uint32_t t) | 181 CoDelQueueDisc::ControlLaw (uint32_t t) |
182 { | 182 { |
183 NS_LOG_FUNCTION (this); | 183 NS_LOG_FUNCTION (this); |
184 return t + ReciprocalDivide (Time2CoDel (m_interval), m_recInvSqrt << REC_INV_
SQRT_SHIFT); | 184 return t + ReciprocalDivide (Time2CoDel (m_interval), m_recInvSqrt << REC_INV_
SQRT_SHIFT); |
185 } | 185 } |
186 | 186 |
187 void | 187 void |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 512 |
513 bool | 513 bool |
514 CoDelQueueDisc::CoDelTimeBeforeEq (uint32_t a, uint32_t b) | 514 CoDelQueueDisc::CoDelTimeBeforeEq (uint32_t a, uint32_t b) |
515 { | 515 { |
516 return ((int)(a) - (int)(b) <= 0); | 516 return ((int)(a) - (int)(b) <= 0); |
517 } | 517 } |
518 | 518 |
519 uint32_t | 519 uint32_t |
520 CoDelQueueDisc::Time2CoDel (Time t) | 520 CoDelQueueDisc::Time2CoDel (Time t) |
521 { | 521 { |
522 return static_cast<uint32_t>(t.GetNanoSeconds () >> CODEL_SHIFT); | 522 return static_cast<uint32_t> (t.GetNanoSeconds () >> CODEL_SHIFT); |
523 } | 523 } |
524 | 524 |
525 bool | 525 bool |
526 CoDelQueueDisc::CheckConfig (void) | 526 CoDelQueueDisc::CheckConfig (void) |
527 { | 527 { |
528 NS_LOG_FUNCTION (this); | 528 NS_LOG_FUNCTION (this); |
529 if (GetNQueueDiscClasses () > 0) | 529 if (GetNQueueDiscClasses () > 0) |
530 { | 530 { |
531 NS_LOG_ERROR ("CoDelQueueDisc cannot have classes"); | 531 NS_LOG_ERROR ("CoDelQueueDisc cannot have classes"); |
532 return false; | 532 return false; |
(...skipping 22 matching lines...) Expand all Loading... |
555 } | 555 } |
556 | 556 |
557 void | 557 void |
558 CoDelQueueDisc::InitializeParams (void) | 558 CoDelQueueDisc::InitializeParams (void) |
559 { | 559 { |
560 NS_LOG_FUNCTION (this); | 560 NS_LOG_FUNCTION (this); |
561 } | 561 } |
562 | 562 |
563 } // namespace ns3 | 563 } // namespace ns3 |
564 | 564 |
OLD | NEW |