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 ();
64  void Print (Ptr<OutputStreamWrapper> stream);
65 
66 private:
67  virtual void StartApplication (void);
68  virtual void StopApplication (void);
69  virtual void DoDispose (void);
74  uint32_t GetApplicationId (void) const;
81  void Receive (Ptr<Socket> socket);
82 
84  void Send ();
85 
87  void StartWaitReplyTimer ();
88 
92  void HandleWaitReplyTimeout ();
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 };
139 
140 } //ns3 namespace
141 
142 #endif /*V4TRACEROUTE_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:103
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
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...
virtual void StopApplication(void)
Application specific shutdown code.
uint32_t GetApplicationId(void) const
Return the application ID in the node.
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
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
static TypeId GetTypeId(void)
Get the type ID.
Definition: v4traceroute.cc:47
uint16_t m_seq
ICMP ECHO sequence number.
Definition: v4traceroute.h:108
virtual void DoDispose(void)
Destructor implementation.
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
Ptr< Socket > m_socket
The socket we send packets from.
Definition: v4traceroute.h:106
uint32_t m_maxTtl
The maximium 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.
virtual ~V4TraceRoute()
std::ostringstream m_osRoute
Stream of characters used for printing a single route.
Definition: v4traceroute.h:131
virtual void StartApplication(void)
Application specific startup code.
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.
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.