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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
7 */
8
9#ifndef V4TRACEROUTE_H
10#define V4TRACEROUTE_H
11
12#include "ns3/application.h"
13#include "ns3/average.h"
14#include "ns3/nstime.h"
15#include "ns3/output-stream-wrapper.h"
16#include "ns3/simulator.h"
17#include "ns3/traced-callback.h"
18
19#include <map>
20
21namespace ns3
22{
23
24class Socket;
25
26/**
27 * \ingroup internet-apps
28 * \defgroup v4traceroute V4Traceroute
29 */
30
31/**
32 * \ingroup v4traceroute
33 * \brief Traceroute application sends one ICMP ECHO request with TTL=1,
34 * and after receiving an ICMP TIME EXCEED reply, it increases the
35 * TTL and repeat the process to reveal all the intermediate hops to
36 * the destination.
37 *
38 */
40{
41 public:
42 /**
43 * \brief Get the type ID.
44 * \return the object TypeId
45 */
46 static TypeId GetTypeId();
48 ~V4TraceRoute() override;
49 /**
50 * \brief Prints the application traced routes into a given OutputStream.
51 * \param stream the output stream
52 */
54
55 protected:
56 void DoDispose() override;
57
58 private:
59 void StartApplication() override;
60 void StopApplication() override;
61
62 /**
63 * \brief Return the application ID in the node.
64 * \returns the application id
65 */
67 /**
68 * \brief Receive an ICMP Echo
69 * \param socket the receiving socket
70 *
71 * This function is called by lower layers through a callback.
72 */
73 void Receive(Ptr<Socket> socket);
74
75 /** \brief Send one (ICMP ECHO) to the destination.*/
76 void Send();
77
78 /** \brief Starts a timer after sending an ICMP ECHO.*/
80
81 /** \brief Triggers an action if an ICMP TIME EXCEED have not being received
82 * in the time defined by StartWaitReplyTimer.
83 */
85
86 /// Remote address
88
89 /// Wait interval seconds between sending each packet
91 /**
92 * Specifies the number of data bytes to be sent.
93 * The default is 56, which translates into 64 ICMP data bytes when
94 * combined with the 8 bytes of ICMP header data.
95 */
97 /// The socket we send packets from
99 /// ICMP ECHO sequence number
100 uint16_t m_seq;
101 /// produce traceroute style output if true
103 /// Start time to report total ping time
105 /// Next packet will be sent
107 /// The Current probe value
109 /// The maximum number of probe packets per hop
110 uint16_t m_maxProbes;
111 /// The current TTL value
112 uint16_t m_ttl;
113 /// The packets Type of Service
114 uint8_t m_tos;
115 /// The maximum Ttl (Max number of hops to trace)
117 /// The wait time until the response is considered lost.
119 /// The timer used to wait for the probes ICMP replies
121 /// All sent but not answered packets. Map icmp seqno -> when sent
122 std::map<uint16_t, Time> m_sent;
123
124 /// Stream of characters used for printing a single route
125 std::ostringstream m_osRoute;
126 /// The Ipv4 address of the latest hop found
127 std::ostringstream m_routeIpv4;
128 /// Stream of the traceroute used for the output file
130};
131
132} // namespace ns3
133
134#endif /*V4TRACEROUTE_H*/
The base class for all ns3 applications.
Definition application.h:51
An identifier for simulation events.
Definition event-id.h:45
Ipv4 addresses are stored in host order in this class.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Traceroute application sends one ICMP ECHO request with TTL=1, and after receiving an ICMP TIME EXCEE...
~V4TraceRoute() override
Ipv4Address m_remote
Remote address.
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.
std::ostringstream m_routeIpv4
The Ipv4 address of the latest hop found.
void StartApplication() override
Application specific startup code.
Ptr< OutputStreamWrapper > m_printStream
Stream of the traceroute used for the output file.
uint32_t m_probeCount
The Current probe value.
uint16_t m_seq
ICMP ECHO sequence number.
uint32_t GetApplicationId() const
Return the application ID in the node.
uint16_t m_ttl
The current TTL value.
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
void DoDispose() override
Destructor implementation.
Ptr< Socket > m_socket
The socket we send packets from.
uint32_t m_maxTtl
The maximum Ttl (Max number of hops to trace)
Time m_interval
Wait interval seconds between sending each packet.
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.
Time m_started
Start time to report total ping time.
EventId m_waitIcmpReplyTimer
The timer used to wait for the probes ICMP replies.
uint32_t m_size
Specifies the number of data bytes to be sent.
uint8_t m_tos
The packets Type of Service.
uint16_t m_maxProbes
The maximum number of probe packets per hop.
Time m_waitIcmpReplyTimeout
The wait time until the response is considered lost.
void Receive(Ptr< Socket > socket)
Receive an ICMP Echo.
static TypeId GetTypeId()
Get the type ID.
void StartWaitReplyTimer()
Starts a timer after sending an ICMP ECHO.
bool m_verbose
produce traceroute style output if true
void Send()
Send one (ICMP ECHO) to the destination.
Every class exported by the ns3 library is enclosed in the ns3 namespace.