A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
v4traceroute.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Ritsumeikan University, Shiga, Japan
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
18 */
19
20#ifndef V4TRACEROUTE_H
21#define V4TRACEROUTE_H
22
23#include "ns3/application.h"
24#include "ns3/average.h"
25#include "ns3/nstime.h"
26#include "ns3/output-stream-wrapper.h"
27#include "ns3/simulator.h"
28#include "ns3/traced-callback.h"
29
30#include <map>
31
32namespace ns3
33{
34
35class Socket;
36
37/**
38 * \ingroup internet-apps
39 * \defgroup v4traceroute V4Traceroute
40 */
41
42/**
43 * \ingroup v4traceroute
44 * \brief Traceroute application sends one ICMP ECHO request with TTL=1,
45 * and after receiving an ICMP TIME EXCEED reply, it increases the
46 * TTL and repeat the process to reveal all the intermediate hops to
47 * the destination.
48 *
49 */
51{
52 public:
53 /**
54 * \brief Get the type ID.
55 * \return the object TypeId
56 */
57 static TypeId GetTypeId();
59 ~V4TraceRoute() override;
60 /**
61 * \brief Prints the application traced routes into a given OutputStream.
62 * \param stream the output stream
63 */
65
66 protected:
67 void DoDispose() override;
68
69 private:
70 void StartApplication() override;
71 void StopApplication() override;
72
73 /**
74 * \brief Return the application ID in the node.
75 * \returns the application id
76 */
78 /**
79 * \brief Receive an ICMP Echo
80 * \param socket the receiving socket
81 *
82 * This function is called by lower layers through a callback.
83 */
84 void Receive(Ptr<Socket> socket);
85
86 /** \brief Send one (ICMP ECHO) to the destination.*/
87 void Send();
88
89 /** \brief Starts a timer after sending an ICMP ECHO.*/
91
92 /** \brief Triggers an action if an ICMP TIME EXCEED have not being received
93 * in the time defined by StartWaitReplyTimer.
94 */
96
97 /// Remote address
99
100 /// Wait interval seconds between sending each packet
102 /**
103 * Specifies the number of data bytes to be sent.
104 * The default is 56, which translates into 64 ICMP data bytes when
105 * combined with the 8 bytes of ICMP header data.
106 */
108 /// The socket we send packets from
110 /// ICMP ECHO sequence number
111 uint16_t m_seq;
112 /// produce traceroute style output if true
114 /// Start time to report total ping time
116 /// Next packet will be sent
118 /// The Current probe value
120 /// The maximum number of probe packets per hop
121 uint16_t m_maxProbes;
122 /// The current TTL value
123 uint16_t m_ttl;
124 /// The packets Type of Service
125 uint8_t m_tos;
126 /// The maximum Ttl (Max number of hops to trace)
128 /// The wait time until the response is considered lost.
130 /// The timer used to wait for the probes ICMP replies
132 /// All sent but not answered packets. Map icmp seqno -> when sent
133 std::map<uint16_t, Time> m_sent;
134
135 /// Stream of characters used for printing a single route
136 std::ostringstream m_osRoute;
137 /// The Ipv4 address of the latest hop found
138 std::ostringstream m_routeIpv4;
139 /// Stream of the traceroute used for the output file
141};
142
143} // namespace ns3
144
145#endif /*V4TRACEROUTE_H*/
The base class for all ns3 applications.
Definition: application.h:62
An identifier for simulation events.
Definition: event-id.h:55
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Traceroute application sends one ICMP ECHO request with TTL=1, and after receiving an ICMP TIME EXCEE...
Definition: v4traceroute.h:51
~V4TraceRoute() override
Ipv4Address m_remote
Remote address.
Definition: v4traceroute.h:98
void HandleWaitReplyTimeout()
Triggers an action if an ICMP TIME EXCEED have not being received in the time defined by StartWaitRep...
void StopApplication() override
Application specific shutdown code.
EventId m_next
Next packet will be sent.
Definition: v4traceroute.h:117
std::ostringstream m_routeIpv4
The Ipv4 address of the latest hop found.
Definition: v4traceroute.h:138
void StartApplication() override
Application specific startup code.
Ptr< OutputStreamWrapper > m_printStream
Stream of the traceroute used for the output file.
Definition: v4traceroute.h:140
uint32_t m_probeCount
The Current probe value.
Definition: v4traceroute.h:119
uint16_t m_seq
ICMP ECHO sequence number.
Definition: v4traceroute.h:111
uint32_t GetApplicationId() const
Return the application ID in the node.
uint16_t m_ttl
The current TTL value.
Definition: v4traceroute.h:123
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
Definition: v4traceroute.h:133
void DoDispose() override
Destructor implementation.
Ptr< Socket > m_socket
The socket we send packets from.
Definition: v4traceroute.h:109
uint32_t m_maxTtl
The maximum Ttl (Max number of hops to trace)
Definition: v4traceroute.h:127
Time m_interval
Wait interval seconds between sending each packet.
Definition: v4traceroute.h:101
void Print(Ptr< OutputStreamWrapper > stream)
Prints the application traced routes into a given OutputStream.
std::ostringstream m_osRoute
Stream of characters used for printing a single route.
Definition: v4traceroute.h:136
Time m_started
Start time to report total ping time.
Definition: v4traceroute.h:115
EventId m_waitIcmpReplyTimer
The timer used to wait for the probes ICMP replies.
Definition: v4traceroute.h:131
uint32_t m_size
Specifies the number of data bytes to be sent.
Definition: v4traceroute.h:107
uint8_t m_tos
The packets Type of Service.
Definition: v4traceroute.h:125
uint16_t m_maxProbes
The maximum number of probe packets per hop.
Definition: v4traceroute.h:121
Time m_waitIcmpReplyTimeout
The wait time until the response is considered lost.
Definition: v4traceroute.h:129
void Receive(Ptr< Socket > socket)
Receive an ICMP Echo.
static TypeId GetTypeId()
Get the type ID.
Definition: v4traceroute.cc:46
void StartWaitReplyTimer()
Starts a timer after sending an ICMP ECHO.
bool m_verbose
produce traceroute style output if true
Definition: v4traceroute.h:113
void Send()
Send one (ICMP ECHO) to the destination.
Every class exported by the ns3 library is enclosed in the ns3 namespace.