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/average.h"
23#include <map>
24
25namespace ns3 {
26
27class Socket;
28
41class V4Ping : public Application
42{
43public:
48 static TypeId GetTypeId (void);
49
53 V4Ping ();
54 virtual ~V4Ping ();
55
56private:
65 void Write32 (uint8_t *buffer, const uint32_t data);
72 void Read32 (const uint8_t *buffer, uint32_t &data);
73
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 ();
94
107 uint16_t m_seq;
121 std::map<uint16_t, Time> m_sent;
122};
123
124} // namespace ns3
125
126#endif /* V4PING_H */
The base class for all ns3 applications.
Definition: application.h:61
An identifier for simulation events.
Definition: event-id.h:54
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
an application which sends one ICMP ECHO request, waits for a REPLYs and reports the calculated RTT.
Definition: v4ping.h:42
void Read32(const uint8_t *buffer, uint32_t &data)
Writes data from a little-endian formatted buffer to data.
Definition: v4ping.cc:190
Average< double > m_avgRtt
Average rtt is ms.
Definition: v4ping.h:117
bool m_verbose
produce ping-style output if true
Definition: v4ping.h:111
EventId m_next
Next packet will be sent.
Definition: v4ping.h:119
uint32_t m_size
Specifies the number of data bytes to be sent.
Definition: v4ping.h:103
Ptr< Socket > m_socket
The socket we send packets from.
Definition: v4ping.h:105
uint32_t m_recv
received packets counter
Definition: v4ping.h:113
void Send()
Send one Ping (ICMP ECHO) to the destination.
Definition: v4ping.cc:197
Ipv4Address m_remote
Remote address.
Definition: v4ping.h:96
virtual ~V4Ping()
Definition: v4ping.cc:78
uint16_t m_seq
ICMP ECHO sequence number.
Definition: v4ping.h:107
uint32_t GetApplicationId(void) const
Return the application ID in the node.
Definition: v4ping.cc:98
void Write32(uint8_t *buffer, const uint32_t data)
Writes data to buffer in little-endian format.
Definition: v4ping.cc:179
virtual void DoDispose(void)
Destructor implementation.
Definition: v4ping.cc:84
void Receive(Ptr< Socket > socket)
Receive an ICMP Echo.
Definition: v4ping.cc:114
V4Ping()
create a pinger applications
Definition: v4ping.cc:68
TracedCallback< Time > m_traceRtt
TracedCallback for RTT measured by ICMP ECHOs.
Definition: v4ping.h:109
virtual void StartApplication(void)
Application specific startup code.
Definition: v4ping.cc:242
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
Definition: v4ping.h:121
static TypeId GetTypeId(void)
Get the type ID.
Definition: v4ping.cc:36
Time m_interval
Wait interval seconds between sending each packet.
Definition: v4ping.h:98
Time m_started
Start time to report total ping time.
Definition: v4ping.h:115
virtual void StopApplication(void)
Application specific shutdown code.
Definition: v4ping.cc:267
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t data[writeSize]