A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
packet-loss-counter.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008,2009 INRIA, UDCAST
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 *
9 */
10
11#ifndef PACKET_LOSS_COUNTER_H
12#define PACKET_LOSS_COUNTER_H
13
14#include "ns3/address.h"
15#include "ns3/application.h"
16#include "ns3/event-id.h"
17#include "ns3/ptr.h"
18
19namespace ns3
20{
21
22class Socket;
23class Packet;
24
25/**
26 * @ingroup udpclientserver
27 *
28 * @brief A class to count the number of lost packets.
29 *
30 * This class records the packet lost in a client/server transmission
31 * leveraging a sequence number. All the packets outside a given window
32 * (i.e., too old with respect to the last sequence number seen) are considered lost,
33 */
35{
36 public:
37 /**
38 * @brief Constructor
39 * @param bitmapSize The window size. Must be a multiple of 8.
40 */
41 PacketLossCounter(uint8_t bitmapSize);
43 /**
44 * @brief Record a successfully received packet
45 * @param seq the packet sequence number
46 */
47 void NotifyReceived(uint32_t seq);
48 /**
49 * @brief Get the number of lost packets.
50 * @returns the number of lost packets.
51 */
52 uint32_t GetLost() const;
53 /**
54 * @brief Return the size of the window used to compute the packet loss.
55 * @return the window size.
56 */
57 uint16_t GetBitMapSize() const;
58 /**
59 * @brief Set the size of the window used to compute the packet loss.
60 *
61 * @param size The window size. Must be a multiple of 8.
62 */
63 void SetBitMapSize(uint16_t size);
64
65 private:
66 /**
67 * @brief Check if a sequence number in the window has been received.
68 * @param seqNum the sequence number.
69 * @returns false if the packet has not been received.
70 */
71 bool GetBit(uint32_t seqNum);
72 /**
73 * @brief Set a sequence number to a given state.
74 * @param seqNum the sequence number.
75 * @param val false if the packet has not been received.
76 */
77 void SetBit(uint32_t seqNum, bool val);
78
79 uint32_t m_lost; //!< Lost packets counter.
80 uint16_t m_bitMapSize; //!< Window size.
81 uint32_t m_lastMaxSeqNum; //!< Last sequence number seen.
82 uint8_t* m_receiveBitMap; //!< Received packets in the window size.
83};
84} // namespace ns3
85
86#endif /* PACKET_LOSS_COUNTER_H */
A class to count the number of lost packets.
void SetBit(uint32_t seqNum, bool val)
Set a sequence number to a given state.
void NotifyReceived(uint32_t seq)
Record a successfully received packet.
uint32_t m_lastMaxSeqNum
Last sequence number seen.
bool GetBit(uint32_t seqNum)
Check if a sequence number in the window has been received.
PacketLossCounter(uint8_t bitmapSize)
Constructor.
uint32_t m_lost
Lost packets counter.
void SetBitMapSize(uint16_t size)
Set the size of the window used to compute the packet loss.
uint8_t * m_receiveBitMap
Received packets in the window size.
uint16_t GetBitMapSize() const
Return the size of the window used to compute the packet loss.
uint32_t GetLost() const
Get the number of lost packets.
uint16_t m_bitMapSize
Window size.
Every class exported by the ns3 library is enclosed in the ns3 namespace.