9#ifndef LOLLIPOP_COUNTER_H
10#define LOLLIPOP_COUNTER_H
68 "Lollipop counters must be defined on unsigned integer types");
70 uint16_t numberofDigits = std::numeric_limits<T>::digits;
86 uint16_t numberofDigits = std::numeric_limits<T>::digits;
123 uint16_t numberofDigits = std::numeric_limits<T>::digits;
126 numberOfBits >= numberofDigits,
127 "The size of the Sequence Window should be less than the counter size (which is "
152 "Can not compare two Lollipop Counters with different sequence windows");
186 "Can not compare two Lollipop Counters with different sequence windows");
200 "Can not compare two Lollipop Counters with different sequence windows");
271 if (lhs > rhs || lhs == rhs)
356 T absDiff = std::min(absDiffDirect, absDiffWrapped);
363 std::numeric_limits<T>::max();
Template class implementing a Lollipop counter as defined in RFC 8505 , RFC 6550 ,...
static constexpr T m_maxValue
Maximum value of the counter.
friend LollipopCounter operator++(LollipopCounter &val, int noop)
Postfix increment operator.
T AbsoluteMagnitudeOfDifference(const LollipopCounter &val) const
Compute the Absolute Magnitude Of Difference between two counters.
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.
friend std::ostream & operator<<(std::ostream &os, const LollipopCounter &counter)
Output streamer for LollipopCounter.
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.
static constexpr T m_circularRegion
Circular region of the counter.
LollipopCounter(T val)
Builds a Lollipop counter with a specific initial value.
LollipopCounter & operator=(const LollipopCounter &o)
Assignment.
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.