22 #ifndef LOLLIPOP_COUNTER_H
23 #define LOLLIPOP_COUNTER_H
26 #include "ns3/abort.h"
74 NS_ABORT_MSG_UNLESS (std::is_unsigned<T>::value,
"Lollipop counters must be defined on unsigned integer types");
76 uint16_t numberofDigits = std::numeric_limits<T>::digits;
92 uint16_t numberofDigits = std::numeric_limits<T>::digits;
129 uint16_t numberofDigits = std::numeric_limits<T>::digits;
131 NS_ABORT_MSG_IF (numberOfBits >= numberofDigits,
"The size of the Sequence Window should be less than the counter size (which is " << +
m_maxValue <<
")");
352 friend std::ostream &
382 T absDiff =
std::min (absDiffDirect, absDiffWrapped);
Template class implementing a Lollipop counter as defined in RFC 8505, RFC 6550, and [Perlman83].
static constexpr T m_maxValue
Maximum value of the counter.
T m_value
Value of the Lollipop Counter.
LollipopCounter()
Builds a Lollipop counter with a default initial value.
friend LollipopCounter operator++(LollipopCounter &val)
Prefix increment operator.
T GetValue() const
Get the counter value.
T m_sequenceWindow
Sequence window used for comparing two counters.
friend bool operator<(const LollipopCounter &lhs, const LollipopCounter &rhs)
Arithmetic operator less-than.
bool IsInit() const
Checks if a counter is in its starting region.
friend std::ostream & operator<<(std::ostream &os, LollipopCounter const &counter)
Output streamer for LollipopCounter.
LollipopCounter & operator=(const LollipopCounter &o)
Assignment.
T AbsoluteMagnitudeOfDifference(LollipopCounter const &val) const
Compute the Absolute Magnitude Of Difference between two counters.
static constexpr T m_circularRegion
Circular region of the counter.
LollipopCounter(T val)
Builds a Lollipop counter with a specific initial value.
friend bool operator==(const LollipopCounter &lhs, const LollipopCounter &rhs)
Arithmetic operator equal-to.
void SetSequenceWindowSize(uint16_t numberOfBits)
Set the Sequence Window Size and resets the counter.
bool IsComparable(const LollipopCounter &val) const
Checks if the counter is comparable with another counter (i.e., not desynchronized).
friend bool operator>(const LollipopCounter &lhs, const LollipopCounter &rhs)
Arithmetic operator greater-than.
void Reset()
Resets the counter to its initial value.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
LollipopCounter< uint8_t > LollipopCounter8
8 bit Lollipop Counter.
LollipopCounter< uint16_t > LollipopCounter16
16 bit Lollipop Counter.
Every class exported by the ns3 library is enclosed in the ns3 namespace.