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) 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 (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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void | 151 void |
152 CoDelQueueDisc::NewtonStep (void) | 152 CoDelQueueDisc::NewtonStep (void) |
153 { | 153 { |
154 NS_LOG_FUNCTION (this); | 154 NS_LOG_FUNCTION (this); |
155 uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT; | 155 uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT; |
156 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32; | 156 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32; |
157 uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2); | 157 uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2); |
158 | 158 |
159 val >>= 2; /* avoid overflow */ | 159 val >>= 2; /* avoid overflow */ |
160 val = (val * invsqrt) >> (32 - 2 + 1); | 160 val = (val * invsqrt) >> (32 - 2 + 1); |
161 m_recInvSqrt = (uint16_t)(val >> REC_INV_SQRT_SHIFT); | 161 m_recInvSqrt = static_cast<uint16_t>(val >> REC_INV_SQRT_SHIFT); |
162 } | 162 } |
163 | 163 |
164 uint32_t | 164 uint32_t |
165 CoDelQueueDisc::ControlLaw (uint32_t t) | 165 CoDelQueueDisc::ControlLaw (uint32_t t) |
166 { | 166 { |
167 NS_LOG_FUNCTION (this); | 167 NS_LOG_FUNCTION (this); |
168 return t + ReciprocalDivide (Time2CoDel (m_interval), m_recInvSqrt << REC_INV_
SQRT_SHIFT); | 168 return t + ReciprocalDivide (Time2CoDel (m_interval), m_recInvSqrt << REC_INV_
SQRT_SHIFT); |
169 } | 169 } |
170 | 170 |
171 void | 171 void |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 bool | 452 bool |
453 CoDelQueueDisc::CoDelTimeBeforeEq (uint32_t a, uint32_t b) | 453 CoDelQueueDisc::CoDelTimeBeforeEq (uint32_t a, uint32_t b) |
454 { | 454 { |
455 return ((int)(a) - (int)(b) <= 0); | 455 return ((int)(a) - (int)(b) <= 0); |
456 } | 456 } |
457 | 457 |
458 uint32_t | 458 uint32_t |
459 CoDelQueueDisc::Time2CoDel (Time t) | 459 CoDelQueueDisc::Time2CoDel (Time t) |
460 { | 460 { |
461 return ((uint32_t)(t.GetNanoSeconds () >> CODEL_SHIFT)); | 461 return static_cast<uint32_t>(t.GetNanoSeconds () >> CODEL_SHIFT); |
462 } | 462 } |
463 | 463 |
464 bool | 464 bool |
465 CoDelQueueDisc::CheckConfig (void) | 465 CoDelQueueDisc::CheckConfig (void) |
466 { | 466 { |
467 NS_LOG_FUNCTION (this); | 467 NS_LOG_FUNCTION (this); |
468 if (GetNQueueDiscClasses () > 0) | 468 if (GetNQueueDiscClasses () > 0) |
469 { | 469 { |
470 NS_LOG_ERROR ("CoDelQueueDisc cannot have classes"); | 470 NS_LOG_ERROR ("CoDelQueueDisc cannot have classes"); |
471 return false; | 471 return false; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 516 } |
517 | 517 |
518 void | 518 void |
519 CoDelQueueDisc::InitializeParams (void) | 519 CoDelQueueDisc::InitializeParams (void) |
520 { | 520 { |
521 NS_LOG_FUNCTION (this); | 521 NS_LOG_FUNCTION (this); |
522 } | 522 } |
523 | 523 |
524 } // namespace ns3 | 524 } // namespace ns3 |
525 | 525 |
LEFT | RIGHT |