A Discrete-Event Network Simulator
API
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 
30 namespace ns3
31 {
32 
33 class Socket;
34 class Packet;
35 
46 {
47  public:
52  PacketLossCounter(uint8_t bitmapSize);
58  void NotifyReceived(uint32_t seq);
63  uint32_t GetLost() const;
68  uint16_t GetBitMapSize() const;
74  void SetBitMapSize(uint16_t size);
75 
76  private:
82  bool GetBit(uint32_t seqNum);
88  void SetBit(uint32_t seqNum, bool val);
89 
90  uint32_t m_lost;
91  uint16_t m_bitMapSize;
92  uint32_t m_lastMaxSeqNum;
93  uint8_t* m_receiveBitMap;
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.
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.