A Discrete-Event Network Simulator
API
ns3::PacketLossCounter Class Reference

A class to count the number of lost packets. More...

#include "packet-loss-counter.h"

+ Collaboration diagram for ns3::PacketLossCounter:

Public Member Functions

 PacketLossCounter (uint8_t bitmapSize)
 Constructor. More...
 
 ~PacketLossCounter ()
 
uint16_t GetBitMapSize () const
 Return the size of the window used to compute the packet loss. More...
 
uint32_t GetLost () const
 Get the number of lost packets. More...
 
void NotifyReceived (uint32_t seq)
 Record a successfully received packet. More...
 
void SetBitMapSize (uint16_t size)
 Set the size of the window used to compute the packet loss. More...
 

Private Member Functions

bool GetBit (uint32_t seqNum)
 Check if a sequence number in the window has been received. More...
 
void SetBit (uint32_t seqNum, bool val)
 Set a sequence number to a given state. More...
 

Private Attributes

uint16_t m_bitMapSize
 Window size. More...
 
uint32_t m_lastMaxSeqNum
 Last sequence number seen. More...
 
uint32_t m_lost
 Lost packets counter. More...
 
uint8_t * m_receiveBitMap
 Received packets in the window size. More...
 

Detailed Description

A class to count the number of lost packets.

This class records the packet lost in a client/server transmission leveraging a sequence number. All the packets outside a given window (i.e., too old with respect to the last sequence number seen) are considered lost,

Definition at line 45 of file packet-loss-counter.h.

Constructor & Destructor Documentation

◆ PacketLossCounter()

ns3::PacketLossCounter::PacketLossCounter ( uint8_t  bitmapSize)

Constructor.

Parameters
bitmapSizeThe window size. Must be a multiple of 8.

Definition at line 32 of file packet-loss-counter.cc.

References NS_LOG_FUNCTION, and SetBitMapSize().

+ Here is the call graph for this function:

◆ ~PacketLossCounter()

ns3::PacketLossCounter::~PacketLossCounter ( )

Definition at line 42 of file packet-loss-counter.cc.

References m_receiveBitMap, and NS_LOG_FUNCTION.

Member Function Documentation

◆ GetBit()

bool ns3::PacketLossCounter::GetBit ( uint32_t  seqNum)
private

Check if a sequence number in the window has been received.

Parameters
seqNumthe sequence number.
Returns
false if the packet has not been received.

Definition at line 78 of file packet-loss-counter.cc.

References m_bitMapSize, m_receiveBitMap, and NS_LOG_FUNCTION.

Referenced by NotifyReceived().

+ Here is the caller graph for this function:

◆ GetBitMapSize()

uint16_t ns3::PacketLossCounter::GetBitMapSize ( ) const

Return the size of the window used to compute the packet loss.

Returns
the window size.

Definition at line 49 of file packet-loss-counter.cc.

References m_bitMapSize, and NS_LOG_FUNCTION.

Referenced by ns3::UdpServer::GetPacketWindowSize().

+ Here is the caller graph for this function:

◆ GetLost()

uint32_t ns3::PacketLossCounter::GetLost ( ) const

Get the number of lost packets.

Returns
the number of lost packets.

Definition at line 71 of file packet-loss-counter.cc.

References m_lost, and NS_LOG_FUNCTION.

Referenced by PacketLossCounterTestCase::DoRun(), and ns3::UdpServer::GetLost().

+ Here is the caller graph for this function:

◆ NotifyReceived()

void ns3::PacketLossCounter::NotifyReceived ( uint32_t  seq)

Record a successfully received packet.

Parameters
seqthe packet sequence number

Definition at line 111 of file packet-loss-counter.cc.

References GetBit(), m_bitMapSize, m_lastMaxSeqNum, m_lost, NS_LOG_FUNCTION, NS_LOG_INFO, and SetBit().

Referenced by PacketLossCounterTestCase::DoRun(), and ns3::UdpServer::HandleRead().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetBit()

void ns3::PacketLossCounter::SetBit ( uint32_t  seqNum,
bool  val 
)
private

Set a sequence number to a given state.

Parameters
seqNumthe sequence number.
valfalse if the packet has not been received.

Definition at line 85 of file packet-loss-counter.cc.

References m_bitMapSize, m_receiveBitMap, and NS_LOG_FUNCTION.

Referenced by NotifyReceived().

+ Here is the caller graph for this function:

◆ SetBitMapSize()

void ns3::PacketLossCounter::SetBitMapSize ( uint16_t  size)

Set the size of the window used to compute the packet loss.

Parameters
sizeThe window size. Must be a multiple of 8.

Definition at line 56 of file packet-loss-counter.cc.

References m_bitMapSize, m_receiveBitMap, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Referenced by PacketLossCounter(), and ns3::UdpServer::SetPacketWindowSize().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_bitMapSize

uint16_t ns3::PacketLossCounter::m_bitMapSize
private

Window size.

Definition at line 91 of file packet-loss-counter.h.

Referenced by GetBit(), GetBitMapSize(), NotifyReceived(), SetBit(), and SetBitMapSize().

◆ m_lastMaxSeqNum

uint32_t ns3::PacketLossCounter::m_lastMaxSeqNum
private

Last sequence number seen.

Definition at line 92 of file packet-loss-counter.h.

Referenced by NotifyReceived().

◆ m_lost

uint32_t ns3::PacketLossCounter::m_lost
private

Lost packets counter.

Definition at line 90 of file packet-loss-counter.h.

Referenced by GetLost(), and NotifyReceived().

◆ m_receiveBitMap

uint8_t* ns3::PacketLossCounter::m_receiveBitMap
private

Received packets in the window size.

Definition at line 93 of file packet-loss-counter.h.

Referenced by ~PacketLossCounter(), GetBit(), SetBit(), and SetBitMapSize().


The documentation for this class was generated from the following files: