A Discrete-Event Network Simulator
API
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 
32 namespace ns3
33 {
34 
35 class Socket;
36 
50 class V4TraceRoute : public Application
51 {
52  public:
57  static TypeId GetTypeId();
58  V4TraceRoute();
59  ~V4TraceRoute() override;
64  void Print(Ptr<OutputStreamWrapper> stream);
65 
66  private:
67  void StartApplication() override;
68  void StopApplication() override;
69  void DoDispose() override;
74  uint32_t GetApplicationId() const;
81  void Receive(Ptr<Socket> socket);
82 
84  void Send();
85 
87  void StartWaitReplyTimer();
88 
93 
96 
104  uint32_t m_size;
108  uint16_t m_seq;
110  bool m_verbose;
116  uint32_t m_probeCount;
118  uint16_t m_maxProbes;
120  uint16_t m_ttl;
122  uint32_t m_maxTtl;
128  std::map<uint16_t, Time> m_sent;
129 
131  std::ostringstream m_osRoute;
133  std::ostringstream m_routeIpv4;
136 };
137 
138 } // namespace ns3
139 
140 #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
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:95
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:114
std::ostringstream m_routeIpv4
The Ipv4 address of the latest hop found.
Definition: v4traceroute.h:133
void StartApplication() override
Application specific startup code.
Ptr< OutputStreamWrapper > m_printStream
Stream of the traceroute used for the output file.
Definition: v4traceroute.h:135
uint32_t m_probeCount
The Current probe value.
Definition: v4traceroute.h:116
uint16_t m_seq
ICMP ECHO sequence number.
Definition: v4traceroute.h:108
uint32_t GetApplicationId() const
Return the application ID in the node.
uint16_t m_ttl
The current TTL value.
Definition: v4traceroute.h:120
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
Definition: v4traceroute.h:128
void DoDispose() override
Destructor implementation.
Ptr< Socket > m_socket
The socket we send packets from.
Definition: v4traceroute.h:106
uint32_t m_maxTtl
The maximum Ttl (Max number of hops to trace)
Definition: v4traceroute.h:122
Time m_interval
Wait interval seconds between sending each packet.
Definition: v4traceroute.h:98
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:131
Time m_started
Start time to report total ping time.
Definition: v4traceroute.h:112
EventId m_waitIcmpReplyTimer
The timer used to wait for the probes ICMP replies.
Definition: v4traceroute.h:126
uint32_t m_size
Specifies the number of data bytes to be sent.
Definition: v4traceroute.h:104
uint16_t m_maxProbes
The maximum number of probe packets per hop.
Definition: v4traceroute.h:118
Time m_waitIcmpReplyTimeout
The wait time until the response is considered lost.
Definition: v4traceroute.h:124
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:110
void Send()
Send one (ICMP ECHO) to the destination.
Every class exported by the ns3 library is enclosed in the ns3 namespace.