9#ifndef LOLLIPOP_COUNTER_H
10#define LOLLIPOP_COUNTER_H
69 "Lollipop counters must be defined on unsigned integer types");
71 uint16_t numberofDigits = std::numeric_limits<T>::digits;
87 uint16_t numberofDigits = std::numeric_limits<T>::digits;
124 uint16_t numberofDigits = std::numeric_limits<T>::digits;
127 numberOfBits >= numberofDigits,
128 "The size of the Sequence Window should be less than the counter size (which is "
153 "Can not compare two Lollipop Counters with different sequence windows");
187 "Can not compare two Lollipop Counters with different sequence windows");
207 "Can not compare two Lollipop Counters with different sequence windows");
211 return std::partial_ordering::equivalent;
223 return std::partial_ordering::unordered;
231 return std::partial_ordering::greater;
233 return std::partial_ordering::less;
257 lhsIsHigher = !lhsIsHigher;
262 return std::partial_ordering::greater;
264 return std::partial_ordering::less;
344 T absDiff = std::min(absDiffDirect, absDiffWrapped);
351 std::numeric_limits<T>::max();
Template class implementing a Lollipop counter as defined in RFC 8505, RFC 6550, and [Perlman83].
friend constexpr std::partial_ordering operator<=>(const LollipopCounter &lhs, const LollipopCounter &rhs)
Spaceship comparison operator.
static constexpr uint8_t m_maxValue
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.
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.
bool IsInit() const
Checks if a counter is in its starting region.
static constexpr uint8_t m_circularRegion
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).
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.