A Discrete-Event Network Simulator
API
ns3::QueueSize Class Reference

Class for representing queue sizes. More...

#include "queue-size.h"

+ Collaboration diagram for ns3::QueueSize:

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...
 

Detailed Description

Class for representing queue sizes.

Allows for natural and familiar use of queue sizes. Allows construction from strings, natural sum e.g.:

QueueSize x("7kB");
Ptr<Packet> p = Create<Packet> (1000);
QueueSize y = x + p; // 8kB

This class also supports the regular comparison operators <, >, <=, >=, ==, and !=

Queue size specifiers consist of

  • A numeric value,
  • An optional multiplier prefix and
  • A unit.

Whitespace is allowed but not required between the numeric value and multiplier 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:

  • "56kB" = 56,000 bytes
  • "128 kB" = 128,000 bytes
  • "8KiB" = 8,192 bytes
  • "1000p" = 1,000 packets
See also
attribute_QueueSize

Definition at line 95 of file queue-size.h.

Constructor & Destructor Documentation

◆ QueueSize() [1/3]

ns3::QueueSize::QueueSize ( )

Definition at line 113 of file queue-size.cc.

References NS_LOG_FUNCTION.

◆ QueueSize() [2/3]

ns3::QueueSize::QueueSize ( QueueSizeUnit  unit,
uint32_t  value 
)

Integer constructor.

Construct a queue size from a mode and a value.

Parameters
unitwhether the value is expressed in terms of packets or bytes
valuethe value

Definition at line 120 of file queue-size.cc.

References NS_LOG_FUNCTION.

◆ QueueSize() [3/3]

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

Parameters
sizestring representing the size

Definition at line 189 of file queue-size.cc.

References DoParse(), m_unit, m_value, NS_ABORT_MSG_IF, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Member Function Documentation

◆ DoParse()

bool ns3::QueueSize::DoParse ( const std::string  s,
QueueSizeUnit unit,
uint32_t *  value 
)
staticprivate

Parse a string representing a QueueSize.

Allowed unit representations include all combinations of

  • An SI prefix: k, K, M
  • Bytes (8 bits) or packets
Parameters
[in]sThe string representation, including unit
[in,out]unitThe location to put the unit.
[in,out]valueThe location to put the value, in bytes or packets.
Returns
true if parsing was successful.

Definition at line 33 of file queue-size.cc.

References ns3::BYTES, NS_LOG_FUNCTION, and ns3::PACKETS.

Referenced by QueueSize().

+ Here is the caller graph for this function:

◆ GetUnit()

QueueSizeUnit ns3::QueueSize::GetUnit ( ) const

◆ GetValue()

uint32_t ns3::QueueSize::GetValue ( ) const

Get the underlying value.

Returns
The underlying value

Definition at line 183 of file queue-size.cc.

References m_value, and NS_LOG_FUNCTION.

Referenced by CheckQueueDiscSize(), CheckQueueSize(), ns3::PieQueueDisc::DoEnqueue(), ns3::operator+(), ns3::operator-(), ns3::operator<<(), ns3::QueueBase::SetMaxSize(), ns3::QueueDisc::SetMaxSize(), and ns3::QueueBase::WouldOverflow().

+ Here is the caller graph for this function:

◆ operator!=()

bool ns3::QueueSize::operator!= ( const QueueSize rhs) const
Returns
true if this size is not equal to rhs
Parameters
rhsthe queue size to compare to this queue size

Definition at line 168 of file queue-size.cc.

References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.

+ Here is the call graph for this function:

◆ operator<()

bool ns3::QueueSize::operator< ( const QueueSize rhs) const
Returns
true if this size is less than rhs
Parameters
rhsthe 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.

+ Here is the call graph for this function:

◆ operator<=()

bool ns3::QueueSize::operator<= ( const QueueSize rhs) const
Returns
true if this size is less than or equal to rhs
Parameters
rhsthe queue size to compare to this queue size

Definition at line 135 of file queue-size.cc.

References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.

+ Here is the call graph for this function:

◆ operator==()

bool ns3::QueueSize::operator== ( const QueueSize rhs) const
Returns
true if this size is equal to rhs
Parameters
rhsthe queue size to compare to this queue size

Definition at line 160 of file queue-size.cc.

References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.

+ Here is the call graph for this function:

◆ operator>()

bool ns3::QueueSize::operator> ( const QueueSize rhs) const
Returns
true if this size is greater than rhs
Parameters
rhsthe queue size to compare to this queue size

Definition at line 144 of file queue-size.cc.

References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.

+ Here is the call graph for this function:

◆ operator>=()

bool ns3::QueueSize::operator>= ( const QueueSize rhs) const
Returns
true if this size is greater than or equal to rhs
Parameters
rhsthe queue size to compare to this queue size

Definition at line 152 of file queue-size.cc.

References GetUnit(), m_unit, m_value, and NS_ABORT_MSG_IF.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  is,
QueueSize size 
)
friend

Stream extraction operator.

Parameters
isthe stream
sizethe queue size
Returns
a reference to the stream

Definition at line 206 of file queue-size.cc.

Member Data Documentation

◆ m_unit

QueueSizeUnit ns3::QueueSize::m_unit
private

unit

Definition at line 199 of file queue-size.h.

Referenced by QueueSize(), GetUnit(), operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

◆ m_value

uint32_t ns3::QueueSize::m_value
private

queue size [bytes or packets]

Definition at line 200 of file queue-size.h.

Referenced by QueueSize(), GetValue(), operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().


The documentation for this class was generated from the following files: