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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 *
20 */
21
22#ifndef PACKET_LOSS_COUNTER_H
23#define PACKET_LOSS_COUNTER_H
24
25#include "ns3/address.h"
26#include "ns3/application.h"
27#include "ns3/event-id.h"
28#include "ns3/ptr.h"
29
30namespace ns3
31{
32
33class Socket;
34class Packet;
35
36/**
37 * \ingroup udpclientserver
38 *
39 * \brief A class to count the number of lost packets.
40 *
41 * This class records the packet lost in a client/server transmission
42 * leveraging a sequence number. All the packets outside a given window
43 * (i.e., too old with respect to the last sequence number seen) are considered lost,
44 */
46{
47 public:
48 /**
49 * \brief Constructor
50 * \param bitmapSize The window size. Must be a multiple of 8.
51 */
52 PacketLossCounter(uint8_t bitmapSize);
54 /**
55 * \brief Record a successfully received packet
56 * \param seq the packet sequence number
57 */
58 void NotifyReceived(uint32_t seq);
59 /**
60 * \brief Get the number of lost packets.
61 * \returns the number of lost packets.
62 */
63 uint32_t GetLost() const;
64 /**
65 * \brief Return the size of the window used to compute the packet loss.
66 * \return the window size.
67 */
68 uint16_t GetBitMapSize() const;
69 /**
70 * \brief Set the size of the window used to compute the packet loss.
71 *
72 * \param size The window size. Must be a multiple of 8.
73 */
74 void SetBitMapSize(uint16_t size);
75
76 private:
77 /**
78 * \brief Check if a sequence number in the window has been received.
79 * \param seqNum the sequence number.
80 * \returns false if the packet has not been received.
81 */
82 bool GetBit(uint32_t seqNum);
83 /**
84 * \brief Set a sequence number to a given state.
85 * \param seqNum the sequence number.
86 * \param val false if the packet has not been received.
87 */
88 void SetBit(uint32_t seqNum, bool val);
89
90 uint32_t m_lost; //!< Lost packets counter.
91 uint16_t m_bitMapSize; //!< Window size.
92 uint32_t m_lastMaxSeqNum; //!< Last sequence number seen.
93 uint8_t* m_receiveBitMap; //!< Received packets in the window size.
94};
95} // namespace ns3
96
97#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.
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.