A Discrete-Event Network Simulator
API
v4traceroute.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2019 Ritsumeikan University, Shiga, Japan
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
19  */
20 
21 
22 #ifndef V4TRACEROUTE_H
23 #define V4TRACEROUTE_H
24 
25 #include "ns3/application.h"
26 #include "ns3/traced-callback.h"
27 #include "ns3/nstime.h"
28 #include "ns3/average.h"
29 #include "ns3/simulator.h"
30 #include "ns3/output-stream-wrapper.h"
31 #include <map>
32 
33 namespace ns3 {
34 
35 class Socket;
36 
50 class V4TraceRoute : public Application
51 {
52 public:
57  static TypeId GetTypeId (void);
58  V4TraceRoute ();
59  virtual ~V4TraceRoute ();
63  void Print (Ptr<OutputStreamWrapper> stream);
64 
65 private:
66  virtual void StartApplication (void);
67  virtual void StopApplication (void);
68  virtual void DoDispose (void);
73  uint32_t GetApplicationId (void) const;
80  void Receive (Ptr<Socket> socket);
81 
83  void Send ();
84 
86  void StartWaitReplyTimer ();
87 
91  void HandleWaitReplyTimeout ();
92 
95 
103  uint32_t m_size;
107  uint16_t m_seq;
109  bool m_verbose;
115  uint32_t m_probeCount;
117  uint16_t m_maxProbes;
119  uint16_t m_ttl;
121  uint32_t m_maxTtl;
127  std::map<uint16_t, Time> m_sent;
129  std::ostringstream os;
131  std::ostringstream osRoute;
133  std::ostringstream routeIpv4;
136 
137 
138 };
139 
140 } //ns3 namespace
141 
142 #endif /*V4TRACEROUTE_H*/
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
uint32_t m_maxTtl
The maximium Ttl (Max number of hops to trace)
Definition: v4traceroute.h:121
virtual void StopApplication(void)
Application specific shutdown code.
Time m_started
Start time to report total ping time.
Definition: v4traceroute.h:111
virtual void DoDispose(void)
Destructor implementation.
bool m_verbose
produce traceroute style output if true
Definition: v4traceroute.h:109
Ptr< Socket > m_socket
The socket we send packets from.
Definition: v4traceroute.h:105
void HandleWaitReplyTimeout()
Triggers an action if an ICMP TIME EXCEED have not being received in the time defined by StartWaitRep...
void Receive(Ptr< Socket > socket)
Receive an ICMP Echo.
std::ostringstream os
Stream of characters used for printing the traceroute results.
Definition: v4traceroute.h:129
Ipv4Address m_remote
Remote address.
Definition: v4traceroute.h:94
Time m_waitIcmpReplyTimeout
The wait time until the response is considered lost.
Definition: v4traceroute.h:123
virtual ~V4TraceRoute()
The base class for all ns3 applications.
Definition: application.h:60
static TypeId GetTypeId(void)
Get the type ID.
Definition: v4traceroute.cc:47
void StartWaitReplyTimer()
Starts a timer after sending an ICMP ECHO.
EventId m_waitIcmpReplyTimer
The timer used to wait for the probes ICMP replies.
Definition: v4traceroute.h:125
Time m_interval
Wait interval seconds between sending each packet.
Definition: v4traceroute.h:97
uint16_t m_maxProbes
The maximum number of probe packets per hop.
Definition: v4traceroute.h:117
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostringstream routeIpv4
The Ipv4 address of the latest hop found.
Definition: v4traceroute.h:133
uint32_t m_size
Specifies the number of data bytes to be sent.
Definition: v4traceroute.h:103
uint16_t m_ttl
The current TTL value.
Definition: v4traceroute.h:119
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
std::ostringstream osRoute
Stream of characters used for printing a single route.
Definition: v4traceroute.h:131
An identifier for simulation events.
Definition: event-id.h:53
Ptr< OutputStreamWrapper > printStream
Stream of the traceroute used for the output file.
Definition: v4traceroute.h:135
EventId m_next
Next packet will be sent.
Definition: v4traceroute.h:113
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
Definition: v4traceroute.h:127
uint16_t m_seq
ICMP ECHO sequence number.
Definition: v4traceroute.h:107
uint32_t GetApplicationId(void) const
Return the application ID in the node.
void Send()
Send one (ICMP ECHO) to the destination.
a unique identifier for an interface.
Definition: type-id.h:58
Traceroute application sends one ICMP ECHO request with TTL=1, and after receiving an ICMP TIME EXCEE...
Definition: v4traceroute.h:50
virtual void StartApplication(void)
Application specific startup code.
void Print(Ptr< OutputStreamWrapper > stream)
Prints the application traced routes into a given OutputStream.
uint32_t m_probeCount
The Current probe value.
Definition: v4traceroute.h:115