A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 */
virtual void StartApplication(void)
Application specific startup code.
Definition: v4ping.cc:235
void Write32(uint8_t *buffer, const uint32_t data)
Writes data to buffer in little-endian format.
Definition: v4ping.cc:172
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
TracedCallback< Time > m_traceRtt
TracedCallback for RTT measured by ICMP ECHOs.
Definition: v4ping.h:111
uint32_t GetApplicationId(void) const
Return the application ID in the node.
Definition: v4ping.cc:91
V4Ping()
create a pinger applications
Definition: v4ping.cc:67
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: v4ping.cc:83
void Read32(const uint8_t *buffer, uint32_t &data)
Writes data from a little-endian formatted buffer to data.
Definition: v4ping.cc:183
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:37
The base class for all ns3 applications.
Definition: application.h:61
void Receive(Ptr< Socket > socket)
Receive an ICMP Echo.
Definition: v4ping.cc:107
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
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:38
virtual void StopApplication(void)
Application specific shutdown code.
Definition: v4ping.cc:260
an identifier for simulation events.
Definition: event-id.h:46
void Send()
Send one Ping (ICMP ECHO) to the destination.
Definition: v4ping.cc:190
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:77
Ipv4Address m_remote
Remote address.
Definition: v4ping.h:98
a unique identifier for an interface.
Definition: type-id.h:49
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