A Discrete-Event Network Simulator
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
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  */
17 #ifndef V4PING_H
18 #define V4PING_H
20 #include "ns3/application.h"
21 #include "ns3/traced-callback.h"
22 #include "ns3/average.h"
23 #include <map>
25 namespace ns3 {
27 class Socket;
41 class V4Ping : public Application
42 {
43 public:
48  static TypeId GetTypeId (void);
53  V4Ping ();
54  virtual ~V4Ping ();
56 private:
65  void Write32 (uint8_t *buffer, const uint32_t data);
72  void Read32 (const uint8_t *buffer, uint32_t &data);
74  // inherited from Application base class.
75  virtual void StartApplication (void);
76  virtual void StopApplication (void);
77  virtual void DoDispose (void);
82  uint32_t GetApplicationId (void) const;
89  void Receive (Ptr<Socket> socket);
93  void Send ();
103  uint32_t m_size;
107  uint16_t m_seq;
111  bool m_verbose;
113  uint32_t m_recv;
121  std::map<uint16_t, Time> m_sent;
122 };
124 } // namespace ns3
126 #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:103
Forward calls to a chain of Callback.
TracedCallback< Time > m_traceRtt
TracedCallback for RTT measured by ICMP ECHOs.
Definition: v4ping.h:109
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:115
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:121
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:111
uint16_t m_seq
ICMP ECHO sequence number.
Definition: v4ping.h:107
EventId m_next
Next packet will be sent.
Definition: v4ping.h:119
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
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:41
Time m_interval
Wait interval seconds between sending each packet.
Definition: v4ping.h:98
uint32_t m_recv
received packets counter
Definition: v4ping.h:113
virtual ~V4Ping()
Definition: v4ping.cc:78
Ipv4Address m_remote
Remote address.
Definition: v4ping.h:96
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:103
Average< double > m_avgRtt
Average rtt is ms.
Definition: v4ping.h:117
Ptr< Socket > m_socket
The socket we send packets from.
Definition: v4ping.h:105