Skip to content

Lollipop counter implementation

Tommaso Pecorella requested to merge tommypec/ns-3-dev:LollipopCounter into master

A lollipop counter is a strange beast- but it's useful in comparing sequence numbers.

If you want to break your brain, see RFC 8505, section 5.2.1. "Comparing TID Values" or RFC 6550, section 7.2. "Sequence Counter Operation" (one is enough, they're identical). Make sure to check also RFC 1982 tho, as it defines the comparisons for "comparable" numbers.

Anyway, to make things simple a Lollipop counter is a counter that has the following properties:

  • Two counters might (or might be not) comparable.
  • Two counters might (or might be not) desynchronized - if they're desynchronized they're also non-comparable.
  • If two counters are comparable, then you can compare them with the usual less than, greater than, and equal to operators.

The class is templatized, so you can have a Lollipop of uint8_t, one of uint16_t, etc. Of course comparison are only between counters having the same underlying type (and also identical sequence window, which is used in comparisons).

Moreover, a counter will (after an initialization phase) always cycle between 0 and std::numeric_limits<T>::max () / 2. Because that's the law.

The lollipop counters are in network/utils purely because both RPL and SixLoWPAN-ND are using them.

Documentation (Doxygen) and test are included.

Merge request reports