A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
v4ping.h
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 #ifndef V4PING_H
17 #define V4PING_H
18 
19 #include "ns3/application.h"
20 #include "ns3/traced-callback.h"
21 #include "ns3/nstime.h"
22 #include "ns3/average.h"
23 #include "ns3/simulator.h"
24 #include <map>
25 
26 namespace ns3 {
27 
28 class Socket;
29 
36 class V4Ping : public Application
37 {
38 public:
39  static TypeId GetTypeId (void);
40 
44  V4Ping ();
45  virtual ~V4Ping ();
46 
47 private:
48  void Write32 (uint8_t *buffer, const uint32_t data);
49  void Read32 (const uint8_t *buffer, uint32_t &data);
50 
51  // inherited from Application base class.
52  virtual void StartApplication (void);
53  virtual void StopApplication (void);
54  virtual void DoDispose (void);
55  uint32_t GetApplicationId (void) const;
56  void Receive (Ptr<Socket> socket);
57  void Send ();
58 
67  uint32_t m_size;
68  Ptr<Socket> m_socket;
69  uint16_t m_seq;
70  TracedCallback<Time> m_traceRtt;
72  bool m_verbose;
74  uint32_t m_recv;
82  std::map<uint16_t, Time> m_sent;
83 };
84 
85 } // namespace ns3
86 
87 #endif /* V4PING_H */
virtual void StartApplication(void)
Application specific startup code.
Definition: v4ping.cc:232
keep track of time unit.
Definition: nstime.h:149
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual void DoDispose(void)
Definition: v4ping.cc:80
Time m_started
Start time to report total ping time.
Definition: v4ping.h:76
The base class for all ns3 applications.
Definition: application.h:61
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
Definition: v4ping.h:82
bool m_verbose
produce ping-style output if true
Definition: v4ping.h:72
EventId m_next
Next packet will be sent.
Definition: v4ping.h:80
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:257
an identifier for simulation events.
Definition: event-id.h:46
an application which sends one ICMP ECHO request, waits for a REPLYs and reports the calculated RTT...
Definition: v4ping.h:36
Time m_interval
Wait interval seconds between sending each packet.
Definition: v4ping.h:62
uint32_t m_recv
received packets counter
Definition: v4ping.h:74
Ipv4Address m_remote
Remote address.
Definition: v4ping.h:60
a unique identifier for an interface.
Definition: type-id.h:44
uint32_t m_size
Definition: v4ping.h:67
Average< double > m_avgRtt
Average rtt is ms.
Definition: v4ping.h:78