Class for representing queue sizes. More...
#include "queue-size.h"
Public Member Functions | |
QueueSize () | |
QueueSize (QueueSizeUnit unit, uint32_t value) | |
Integer constructor. More... | |
QueueSize (std::string size) | |
String constructor. More... | |
QueueSizeUnit | GetUnit () const |
Get the underlying unit. More... | |
uint32_t | GetValue () const |
Get the underlying value. More... | |
bool | operator!= (const QueueSize &rhs) const |
bool | operator< (const QueueSize &rhs) const |
bool | operator<= (const QueueSize &rhs) const |
bool | operator== (const QueueSize &rhs) const |
bool | operator> (const QueueSize &rhs) const |
bool | operator>= (const QueueSize &rhs) const |
Static Private Member Functions | |
static bool | DoParse (const std::string s, QueueSizeUnit *unit, uint32_t *value) |
Parse a string representing a QueueSize. More... | |
Private Attributes | |
QueueSizeUnit | m_unit |
unit More... | |
uint32_t | m_value |
queue size [bytes or packets] More... | |
Friends | |
std::istream & | operator>> (std::istream &is, QueueSize &size) |
Stream extraction operator. More... | |
Class for representing queue sizes.
Allows for natural and familiar use of queue sizes. Allows construction from strings, natural sum e.g.:
This class also supports the regular comparison operators <
, >
, <=
, >=
, ==
, and !=
Queue size specifiers consist of
Whitespace is allowed but not required between the numeric value and multipler or unit.
Supported multiplier prefixes:
Prefix | Value |
---|---|
"k", "K" | 1000 |
"Ki" | 1024 |
"M" | 1000000 |
"Mi" | 1024 Ki |
Supported unit strings:
Symbol | Meaning |
---|---|
"B" | 8-bit bytes |
"p" | packets |
Examples:
Definition at line 94 of file queue-size.h.
ns3::QueueSize::QueueSize | ( | ) |
Definition at line 113 of file queue-size.cc.
References NS_LOG_FUNCTION.
ns3::QueueSize::QueueSize | ( | QueueSizeUnit | unit, |
uint32_t | value | ||
) |
Integer constructor.
Construct a queue size from a mode and a value.
unit | whether the value is expressed in terms of packets or bytes |
value | the value |
Definition at line 120 of file queue-size.cc.
References NS_LOG_FUNCTION.
ns3::QueueSize::QueueSize | ( | std::string | size | ) |
String constructor.
Construct a queue size from a string. Many different unit strings are supported Supported unit strings: B, p
kB, KB, KiB, kp, Kp, Kip
MB, MiB, Mp, Mip
Examples: "56kB" = 56,000 bytes "128 kB" = 128,000 bytes "8KiB" = 8,192 bytes "1000p" = 1,000 packets
size | string representing the size |
Definition at line 181 of file queue-size.cc.
References DoParse(), m_unit, m_value, NS_ABORT_MSG_IF, NS_LOG_FUNCTION, and NS_UNUSED.
|
staticprivate |
Parse a string representing a QueueSize.
Allowed unit representations include all combinations of
[in] | s | The string representation, including unit |
[in,out] | unit | The location to put the unit. |
[in,out] | value | The location to put the value, in bytes or packets. |
Definition at line 33 of file queue-size.cc.
References ns3::BYTES, sample-rng-plot::n, NS_LOG_FUNCTION, and ns3::PACKETS.
Referenced by ns3::operator>>(), and QueueSize().
QueueSizeUnit ns3::QueueSize::GetUnit | ( | void | ) | const |
Get the underlying unit.
Definition at line 169 of file queue-size.cc.
References m_unit, and NS_LOG_FUNCTION.
Referenced by FifoQueueDiscTestCase::DoRunFifoTest(), ns3::PieQueueDisc::DropEarly(), ns3::QueueBase::GetCurrentSize(), ns3::RedQueueDisc::ModifyP(), operator!=(), ns3::operator+(), operator<(), ns3::operator<<(), operator<=(), operator==(), operator>(), operator>=(), and ns3::QueueDisc::SetMaxSize().
uint32_t ns3::QueueSize::GetValue | ( | void | ) | const |
Get the underlying value.
Definition at line 175 of file queue-size.cc.
References m_value, and NS_LOG_FUNCTION.
Referenced by CheckQueueDiscSize(), CheckQueueSize(), CoDelQueueDiscBasicDrop::Dequeue(), ns3::PieQueueDisc::DoEnqueue(), CoDelQueueDiscBasicEnqueueDequeue::DoRun(), CoDelQueueDiscBasicOverflow::DoRun(), CoDelQueueDiscBasicDrop::DoRun(), FifoQueueDiscTestCase::DoRunFifoTest(), ns3::operator+(), ns3::operator<<(), PieQueueDiscTestCase::RunPieTest(), RedQueueDiscTestCase::RunRedTest(), TbfQueueDiscTestCase::RunTbfTest(), ns3::QueueBase::SetMaxSize(), and ns3::QueueDisc::SetMaxSize().
bool ns3::QueueSize::operator!= | ( | const QueueSize & | rhs | ) | const |
rhs | the queue size to compare to this queue size |
Definition at line 162 of file queue-size.cc.
References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.
bool ns3::QueueSize::operator< | ( | const QueueSize & | rhs | ) | const |
rhs | the queue size to compare to this queue size |
Definition at line 127 of file queue-size.cc.
References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.
bool ns3::QueueSize::operator<= | ( | const QueueSize & | rhs | ) | const |
rhs | the queue size to compare to this queue size |
Definition at line 134 of file queue-size.cc.
References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.
bool ns3::QueueSize::operator== | ( | const QueueSize & | rhs | ) | const |
rhs | the queue size to compare to this queue size |
Definition at line 155 of file queue-size.cc.
References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.
bool ns3::QueueSize::operator> | ( | const QueueSize & | rhs | ) | const |
rhs | the queue size to compare to this queue size |
Definition at line 141 of file queue-size.cc.
References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.
bool ns3::QueueSize::operator>= | ( | const QueueSize & | rhs | ) | const |
rhs | the queue size to compare to this queue size |
Definition at line 148 of file queue-size.cc.
References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.
|
friend |
Stream extraction operator.
is | the stream |
size | the queue size |
Definition at line 196 of file queue-size.cc.
|
private |
unit
Definition at line 199 of file queue-size.h.
Referenced by GetUnit(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and QueueSize().
|
private |
queue size [bytes or packets]
Definition at line 200 of file queue-size.h.
Referenced by GetValue(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and QueueSize().