A Discrete-Event Network Simulator
API
v4ping.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  */
16 
17 #ifndef V4PING_H
18 #define V4PING_H
19 
20 #include "ns3/application.h"
21 #include "ns3/traced-callback.h"
22 #include "ns3/nstime.h"
23 #include "ns3/average.h"
24 #include "ns3/simulator.h"
25 #include <map>
26 
27 namespace ns3 {
28 
29 class Socket;
30 
43 class V4Ping : public Application
44 {
45 public:
50  static TypeId GetTypeId (void);
51 
55  V4Ping ();
56  virtual ~V4Ping ();
57 
58 private:
67  void Write32 (uint8_t *buffer, const uint32_t data);
74  void Read32 (const uint8_t *buffer, uint32_t &data);
75 
76  // inherited from Application base class.
77  virtual void StartApplication (void);
78  virtual void StopApplication (void);
79  virtual void DoDispose (void);
84  uint32_t GetApplicationId (void) const;
91  void Receive (Ptr<Socket> socket);
95  void Send ();
96 
105  uint32_t m_size;
109  uint16_t m_seq;
113  bool m_verbose;
115  uint32_t m_recv;
123  std::map<uint16_t, Time> m_sent;
124 };
125 
126 } // namespace ns3
127 
128 #endif /* V4PING_H */
uint32_t GetApplicationId(void) const
Return the application ID in the node.
Definition: v4ping.cc:98
virtual void StartApplication(void)
Application specific startup code.
Definition: v4ping.cc:242
void Write32(uint8_t *buffer, const uint32_t data)
Writes data to buffer in little-endian format.
Definition: v4ping.cc:179
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Forward calls to a chain of Callback.
TracedCallback< Time > m_traceRtt
TracedCallback for RTT measured by ICMP ECHOs.
Definition: v4ping.h:111
V4Ping()
create a pinger applications
Definition: v4ping.cc:68
virtual void DoDispose(void)
Destructor implementation.
Definition: v4ping.cc:84
void Read32(const uint8_t *buffer, uint32_t &data)
Writes data from a little-endian formatted buffer to data.
Definition: v4ping.cc:190
Time m_started
Start time to report total ping time.
Definition: v4ping.h:117
static TypeId GetTypeId(void)
Get the type ID.
Definition: v4ping.cc:36
The base class for all ns3 applications.
Definition: application.h:60
void Receive(Ptr< Socket > socket)
Receive an ICMP Echo.
Definition: v4ping.cc:114
uint8_t data[writeSize]
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
Definition: v4ping.h:123
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool m_verbose
produce ping-style output if true
Definition: v4ping.h:113
uint16_t m_seq
ICMP ECHO sequence number.
Definition: v4ping.h:109
EventId m_next
Next packet will be sent.
Definition: v4ping.h:121
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual void StopApplication(void)
Application specific shutdown code.
Definition: v4ping.cc:267
An identifier for simulation events.
Definition: event-id.h:53
void Send()
Send one Ping (ICMP ECHO) to the destination.
Definition: v4ping.cc:197
an application which sends one ICMP ECHO request, waits for a REPLYs and reports the calculated RTT...
Definition: v4ping.h:43
Time m_interval
Wait interval seconds between sending each packet.
Definition: v4ping.h:100
uint32_t m_recv
received packets counter
Definition: v4ping.h:115
virtual ~V4Ping()
Definition: v4ping.cc:78
Ipv4Address m_remote
Remote address.
Definition: v4ping.h:98
a unique identifier for an interface.
Definition: type-id.h:58
uint32_t m_size
Specifies the number of data bytes to be sent.
Definition: v4ping.h:105
Average< double > m_avgRtt
Average rtt is ms.
Definition: v4ping.h:119
Ptr< Socket > m_socket
The socket we send packets from.
Definition: v4ping.h:107