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