20 #ifndef LOLLIPOP_COUNTER_H
21 #define LOLLIPOP_COUNTER_H
23 #include "ns3/abort.h"
79 "Lollipop counters must be defined on unsigned integer types");
81 uint16_t numberofDigits = std::numeric_limits<T>::digits;
97 uint16_t numberofDigits = std::numeric_limits<T>::digits;
134 uint16_t numberofDigits = std::numeric_limits<T>::digits;
137 numberOfBits >= numberofDigits,
138 "The size of the Sequence Window should be less than the counter size (which is "
163 "Can not compare two Lollipop Counters with different sequence windows");
197 "Can not compare two Lollipop Counters with different sequence windows");
211 "Can not compare two Lollipop Counters with different sequence windows");
371 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.
friend std::ostream & operator<<(std::ostream &os, const LollipopCounter &counter)
Output streamer for LollipopCounter.
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.
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.
LollipopCounter & operator=(const LollipopCounter &o)
Assignment.
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.