A Discrete-Event Network Simulator
API
packet-loss-counter.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008,2009 INRIA, UDCAST
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@udcast.com>
20  *
21  */
22 
23 #ifndef PACKET_LOSS_COUNTER_H
24 #define PACKET_LOSS_COUNTER_H
25 
26 #include "ns3/application.h"
27 #include "ns3/event-id.h"
28 #include "ns3/ptr.h"
29 #include "ns3/address.h"
30 
31 namespace ns3 {
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 (void) const;
68  uint16_t GetBitMapSize (void) const;
74  void SetBitMapSize (uint16_t size);
75 private:
81  bool GetBit (uint32_t seqNum);
87  void SetBit (uint32_t seqNum, bool val);
88 
89  uint32_t m_lost;
90  uint16_t m_bitMapSize;
91  uint32_t m_lastMaxSeqNum;
92  uint8_t * m_receiveBitMap;
93 };
94 }
95 
96 #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 GetLost(void) const
Get the number of lost packets.
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 m_bitMapSize
Window size.
uint16_t GetBitMapSize(void) const
Return the size of the window used to compute the packet loss.
Every class exported by the ns3 library is enclosed in the ns3 namespace.