Thread to periodically estimate packet error rate based on expected packet rate. More...
#include <packeterrorrateestimator.h>
Public Member Functions | |
uint8_t | packetErrorRate (void) const |
Return the currently estimated packet error rate. More... | |
PacketErrorRateEstimator () | |
Constructor. More... | |
void | packetReceived (void) |
Indicate that a packet has been received. More... | |
void | setExpectedPacketsPerSecond (int16_t packetsPerSecond) |
Set the expected packet reception rate in packets per second. More... | |
virtual | ~PacketErrorRateEstimator () |
Destructor. More... | |
![]() | |
XsThreadId | getThreadId (void) const |
bool | isAlive (void) volatile const noexcept |
bool | isRunning (void) volatile const noexcept |
Returns whether the thread is currently running. More... | |
bool | isTerminating () volatile const noexcept |
Returns whether the thread should (have) terminate(d) More... | |
bool | setPriority (XsThreadPriority pri) |
Sets the priority of the thread. More... | |
virtual void | signalStopThread (void) |
Tells the thread to stop but does not wait for it to end. More... | |
StandardThread () | |
bool | startThread (const char *name=NULL) |
Starts the thread. More... | |
void | stopThread (void) noexcept |
Tells the thread to stop and waits for it to end. More... | |
virtual | ~StandardThread () |
Protected Member Functions | |
virtual void | initFunction (void) |
Initializes the estimation parameters. More... | |
virtual int32_t | innerFunction (void) |
Updates the packet error rate estimate periodically. More... | |
![]() | |
virtual void | exitFunction (void) |
Virtual exit function. More... | |
XsThread | threadHandle () const |
Return the thread handle. More... | |
Private Attributes | |
int32_t | m_expectedPacketsPerSecond |
xsens::Mutex | m_mutex |
uint8_t | m_packetErrorRate |
int64_t | m_previousUpdateTime |
uint16_t | m_receivedPacketCount |
Additional Inherited Members | |
![]() | |
pthread_attr_t | m_attr |
Duplicates m_stop functionality for external dependent classes such as Semaphore. More... | |
bool | m_running |
Indicates that the thread is running. More... | |
volatile std::atomic_bool | m_stop |
Indicates that the thread should stop. Derived classes should check isTerminating() instead of directly polling this value when checking if the thread should stop. However, there are some cases (tests, SignallingThread) where direct access from within the class is desired, which is why the vlaue is protected instead of private. More... | |
volatile std::atomic_bool | m_yieldOnZeroSleep |
When true, a sleep value of 0 returned by innerFunction will trigger a thread yield operation. When false, the next cycle is started immediately. More... | |
Thread to periodically estimate packet error rate based on expected packet rate.
The Packet Error Rate (PER) is estimated based on the ratio of the number of received packets compared to the number of expected packets within a time window. The estimator operates as a thread that periodically updates the PER estimate.
Definition at line 71 of file packeterrorrateestimator.h.
PacketErrorRateEstimator::PacketErrorRateEstimator | ( | ) |
Constructor.
Definition at line 82 of file packeterrorrateestimator.cpp.
|
virtual |
Destructor.
Definition at line 91 of file packeterrorrateestimator.cpp.
|
protectedvirtual |
Initializes the estimation parameters.
Reimplemented from xsens::StandardThread.
Definition at line 125 of file packeterrorrateestimator.cpp.
|
protectedvirtual |
Updates the packet error rate estimate periodically.
Reimplemented from xsens::StandardThread.
Definition at line 132 of file packeterrorrateestimator.cpp.
uint8_t PacketErrorRateEstimator::packetErrorRate | ( | void | ) | const |
Return the currently estimated packet error rate.
Definition at line 118 of file packeterrorrateestimator.cpp.
void PacketErrorRateEstimator::packetReceived | ( | void | ) |
Indicate that a packet has been received.
Should be called for every in order packet received by the device. Reception of out of order packets, e.g. retransmissions, or late packets, should not trigger a call to this function.
Definition at line 109 of file packeterrorrateestimator.cpp.
void PacketErrorRateEstimator::setExpectedPacketsPerSecond | ( | int16_t | packetsPerSecond | ) |
Set the expected packet reception rate in packets per second.
packetsPerSecond | The number of packets expected to be received per second |
Definition at line 98 of file packeterrorrateestimator.cpp.
|
private |
Definition at line 87 of file packeterrorrateestimator.h.
|
mutableprivate |
Definition at line 86 of file packeterrorrateestimator.h.
|
private |
Definition at line 89 of file packeterrorrateestimator.h.
|
private |
Definition at line 90 of file packeterrorrateestimator.h.
|
private |
Definition at line 88 of file packeterrorrateestimator.h.