26 lines
796 B
C
26 lines
796 B
C
|
#pragma once
|
||
|
|
||
|
#include <cstdint>
|
||
|
|
||
|
namespace ts::protocol {
|
||
|
class generation_estimator {
|
||
|
public:
|
||
|
generation_estimator();
|
||
|
|
||
|
void reset();
|
||
|
uint16_t visit_packet(uint16_t /* packet id */);
|
||
|
uint16_t generation() const;
|
||
|
|
||
|
void set_last_state(uint16_t last_packet, uint16_t generation) {
|
||
|
this->last_packet_id = last_packet;
|
||
|
this->last_generation = generation;
|
||
|
}
|
||
|
private:
|
||
|
constexpr static uint16_t overflow_window{1024};
|
||
|
constexpr static uint16_t overflow_area_begin{0xFFFF - overflow_window};
|
||
|
constexpr static uint16_t overflow_area_end{overflow_window};
|
||
|
|
||
|
uint16_t last_generation{0};
|
||
|
uint16_t last_packet_id{0};
|
||
|
};
|
||
|
}
|