A Discrete-Event Network Simulator
API
ns3::V4TraceRoute Class Reference

Traceroute application sends one ICMP ECHO request with TTL=1, and after receiving an ICMP TIME EXCEED reply, it increases the TTL and repeat the process to reveal all the intermediate hops to the destination. More...

#include "v4traceroute.h"

+ Inheritance diagram for ns3::V4TraceRoute:
+ Collaboration diagram for ns3::V4TraceRoute:

Public Member Functions

 V4TraceRoute ()
 
virtual ~V4TraceRoute ()
 
void Print (Ptr< OutputStreamWrapper > stream)
 Prints the application traced routes into a given OutputStream. More...
 
- Public Member Functions inherited from ns3::Application
 Application ()
 
virtual ~Application ()
 
Ptr< NodeGetNode () const
 
void SetNode (Ptr< Node > node)
 
void SetStartTime (Time start)
 Specify application start time. More...
 
void SetStopTime (Time stop)
 Specify application stop time. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
virtual TypeId GetInstanceTypeId (void) const =0
 Get the most derived TypeId for this Object. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Application
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Member Functions

virtual void DoDispose (void)
 Destructor implementation. More...
 
uint32_t GetApplicationId (void) const
 Return the application ID in the node. More...
 
void HandleWaitReplyTimeout ()
 Triggers an action if an ICMP TIME EXCEED have not being received in the time defined by StartWaitReplyTimer. More...
 
void Receive (Ptr< Socket > socket)
 Receive an ICMP Echo. More...
 
void Send ()
 Send one (ICMP ECHO) to the destination. More...
 
virtual void StartApplication (void)
 Application specific startup code. More...
 
void StartWaitReplyTimer ()
 Starts a timer after sending an ICMP ECHO. More...
 
virtual void StopApplication (void)
 Application specific shutdown code. More...
 

Private Attributes

Time m_interval
 Wait interval seconds between sending each packet. More...
 
uint16_t m_maxProbes
 The maximum number of probe packets per hop. More...
 
uint32_t m_maxTtl
 The maximium Ttl (Max number of hops to trace) More...
 
EventId m_next
 Next packet will be sent. More...
 
std::ostringstream m_osRoute
 Stream of characters used for printing a single route. More...
 
Ptr< OutputStreamWrapperm_printStream
 Stream of the traceroute used for the output file. More...
 
uint32_t m_probeCount
 The Current probe value. More...
 
Ipv4Address m_remote
 Remote address. More...
 
std::ostringstream m_routeIpv4
 The Ipv4 address of the latest hop found. More...
 
std::map< uint16_t, Timem_sent
 All sent but not answered packets. Map icmp seqno -> when sent. More...
 
uint16_t m_seq
 ICMP ECHO sequence number. More...
 
uint32_t m_size
 Specifies the number of data bytes to be sent. More...
 
Ptr< Socketm_socket
 The socket we send packets from. More...
 
Time m_started
 Start time to report total ping time. More...
 
uint16_t m_ttl
 The current TTL value. More...
 
bool m_verbose
 produce traceroute style output if true More...
 
Time m_waitIcmpReplyTimeout
 The wait time until the response is considered lost. More...
 
EventId m_waitIcmpReplyTimer
 The timer used to wait for the probes ICMP replies. More...
 

Additional Inherited Members

- Public Types inherited from ns3::Application
typedef void(* DelayAddressCallback) (const Time &delay, const Address &from)
 Common callback signature for packet delay and address. More...
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source. More...
 
- Protected Member Functions inherited from ns3::Application
virtual void DoDispose (void)
 Destructor implementation. More...
 
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void DoDispose (void)
 Destructor implementation. More...
 
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 
- Protected Attributes inherited from ns3::Application
Ptr< Nodem_node
 The node that this application is installed on. More...
 
EventId m_startEvent
 The event that will fire at m_startTime to start the application. More...
 
Time m_startTime
 The simulation time that the application will start. More...
 
EventId m_stopEvent
 The event that will fire at m_stopTime to end the application. More...
 
Time m_stopTime
 The simulation time that the application will end. More...
 

Detailed Description

Traceroute application sends one ICMP ECHO request with TTL=1, and after receiving an ICMP TIME EXCEED reply, it increases the TTL and repeat the process to reveal all the intermediate hops to the destination.

Config Paths

ns3::V4TraceRoute is accessible through the following paths with Config::Set and Config::Connect:

  • "/NodeList/[i]/ApplicationList/[i]/$ns3::V4TraceRoute"

Attributes

  • Remote: The address of the machine we want to trace.
  • Verbose: Produce usual output.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: true
    • Flags: constructwriteread
  • Interval: Wait interval between sent packets.
    • Set with class: ns3::TimeValue
    • Underlying type: Time +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread
  • Size: The number of data bytes to be sent, real packet will be 8 (ICMP) + 20 (IP) bytes longer.
    • Set with class: ns3::UintegerValue
    • Underlying type: uint32_t 0:4294967295
    • Initial value: 56
    • Flags: constructwriteread
  • MaxHop: The maximum number of hops to trace.
    • Set with class: ns3::UintegerValue
    • Underlying type: uint32_t 0:4294967295
    • Initial value: 30
    • Flags: constructwriteread
  • ProbeNum: The number of packets send to each hop.
    • Set with class: ns3::UintegerValue
    • Underlying type: uint16_t 0:65535
    • Initial value: 3
    • Flags: constructwriteread
  • Timeout: The waiting time for a route response before a timeout.
    • Set with class: ns3::TimeValue
    • Underlying type: Time +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +5e+09ns
    • Flags: constructwriteread

Attributes defined in parent class ns3::Application

  • StartTime: Time at which the application will start
    • Set with class: ns3::TimeValue
    • Underlying type: Time +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread
  • StopTime: Time at which the application will stop
    • Set with class: ns3::TimeValue
    • Underlying type: Time +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread

No TraceSources are defined for this type.
Size of this type is 984 bytes (on a 64-bit architecture).

Definition at line 50 of file v4traceroute.h.

Constructor & Destructor Documentation

◆ V4TraceRoute()

ns3::V4TraceRoute::V4TraceRoute ( )

Definition at line 88 of file v4traceroute.cc.

References m_osRoute, and m_routeIpv4.

◆ ~V4TraceRoute()

ns3::V4TraceRoute::~V4TraceRoute ( )
virtual

Definition at line 104 of file v4traceroute.cc.

Member Function Documentation

◆ DoDispose()

void ns3::V4TraceRoute::DoDispose ( void  )
privatevirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Reimplemented from ns3::Application.

Definition at line 187 of file v4traceroute.cc.

References ns3::Application::DoDispose(), ns3::EventId::IsRunning(), m_next, m_socket, m_waitIcmpReplyTimer, NS_LOG_FUNCTION, and StopApplication().

+ Here is the call graph for this function:

◆ GetApplicationId()

uint32_t ns3::V4TraceRoute::GetApplicationId ( void  ) const
private

Return the application ID in the node.

Returns
the application id

Definition at line 202 of file v4traceroute.cc.

References ns3::Node::GetApplication(), ns3::Node::GetNApplications(), ns3::Application::GetNode(), NS_ASSERT_MSG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GetTypeId()

TypeId ns3::V4TraceRoute::GetTypeId ( void  )
static

◆ HandleWaitReplyTimeout()

void ns3::V4TraceRoute::HandleWaitReplyTimeout ( void  )
private

Triggers an action if an ICMP TIME EXCEED have not being received in the time defined by StartWaitReplyTimer.

Definition at line 443 of file v4traceroute.cc.

References ns3::OutputStreamWrapper::GetStream(), m_interval, m_maxProbes, m_maxTtl, m_next, m_osRoute, m_printStream, m_probeCount, m_routeIpv4, m_ttl, m_verbose, NS_LOG_UNCOND, ns3::Simulator::Schedule(), and StartWaitReplyTimer().

Referenced by StartWaitReplyTimer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Print()

void ns3::V4TraceRoute::Print ( Ptr< OutputStreamWrapper stream)

Prints the application traced routes into a given OutputStream.

Parameters
streamthe output stream

Definition at line 111 of file v4traceroute.cc.

References m_printStream.

◆ Receive()

◆ Send()

◆ StartApplication()

void ns3::V4TraceRoute::StartApplication ( void  )
privatevirtual

◆ StartWaitReplyTimer()

void ns3::V4TraceRoute::StartWaitReplyTimer ( void  )
private

Starts a timer after sending an ICMP ECHO.

Definition at line 427 of file v4traceroute.cc.

References HandleWaitReplyTimeout(), ns3::EventId::IsRunning(), m_waitIcmpReplyTimeout, m_waitIcmpReplyTimer, ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Simulator::Schedule(), and Send().

Referenced by HandleWaitReplyTimeout(), Receive(), and StartApplication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StopApplication()

void ns3::V4TraceRoute::StopApplication ( void  )
privatevirtual

Application specific shutdown code.

The StopApplication method is called at the stop time specified by Stop This method should be overridden by all or most application subclasses.

Reimplemented from ns3::Application.

Definition at line 156 of file v4traceroute.cc.

References ns3::EventId::Cancel(), ns3::Socket::Close(), ns3::OutputStreamWrapper::GetStream(), ns3::EventId::IsRunning(), m_next, m_printStream, m_socket, m_verbose, m_waitIcmpReplyTimer, NS_LOG_FUNCTION, and NS_LOG_UNCOND.

Referenced by DoDispose(), and Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_interval

Time ns3::V4TraceRoute::m_interval
private

Wait interval seconds between sending each packet.

Definition at line 98 of file v4traceroute.h.

Referenced by GetTypeId(), HandleWaitReplyTimeout(), and Receive().

◆ m_maxProbes

uint16_t ns3::V4TraceRoute::m_maxProbes
private

The maximum number of probe packets per hop.

Definition at line 118 of file v4traceroute.h.

Referenced by GetTypeId(), HandleWaitReplyTimeout(), Receive(), and Send().

◆ m_maxTtl

uint32_t ns3::V4TraceRoute::m_maxTtl
private

The maximium Ttl (Max number of hops to trace)

Definition at line 122 of file v4traceroute.h.

Referenced by GetTypeId(), HandleWaitReplyTimeout(), Receive(), and StartApplication().

◆ m_next

EventId ns3::V4TraceRoute::m_next
private

Next packet will be sent.

Definition at line 114 of file v4traceroute.h.

Referenced by DoDispose(), HandleWaitReplyTimeout(), Receive(), StartApplication(), and StopApplication().

◆ m_osRoute

std::ostringstream ns3::V4TraceRoute::m_osRoute
private

Stream of characters used for printing a single route.

Definition at line 131 of file v4traceroute.h.

Referenced by V4TraceRoute(), HandleWaitReplyTimeout(), and Receive().

◆ m_printStream

Ptr<OutputStreamWrapper> ns3::V4TraceRoute::m_printStream
private

Stream of the traceroute used for the output file.

Definition at line 135 of file v4traceroute.h.

Referenced by HandleWaitReplyTimeout(), Print(), Receive(), StartApplication(), and StopApplication().

◆ m_probeCount

uint32_t ns3::V4TraceRoute::m_probeCount
private

The Current probe value.

Definition at line 116 of file v4traceroute.h.

Referenced by HandleWaitReplyTimeout(), Receive(), and Send().

◆ m_remote

Ipv4Address ns3::V4TraceRoute::m_remote
private

Remote address.

Definition at line 95 of file v4traceroute.h.

Referenced by GetTypeId(), Receive(), Send(), and StartApplication().

◆ m_routeIpv4

std::ostringstream ns3::V4TraceRoute::m_routeIpv4
private

The Ipv4 address of the latest hop found.

Definition at line 133 of file v4traceroute.h.

Referenced by V4TraceRoute(), HandleWaitReplyTimeout(), and Receive().

◆ m_sent

std::map<uint16_t, Time> ns3::V4TraceRoute::m_sent
private

All sent but not answered packets. Map icmp seqno -> when sent.

Definition at line 128 of file v4traceroute.h.

Referenced by Receive(), and Send().

◆ m_seq

uint16_t ns3::V4TraceRoute::m_seq
private

ICMP ECHO sequence number.

Definition at line 108 of file v4traceroute.h.

Referenced by Send().

◆ m_size

uint32_t ns3::V4TraceRoute::m_size
private

Specifies the number of data bytes to be sent.

The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.

Definition at line 104 of file v4traceroute.h.

Referenced by GetTypeId(), Receive(), Send(), and StartApplication().

◆ m_socket

Ptr<Socket> ns3::V4TraceRoute::m_socket
private

The socket we send packets from.

Definition at line 106 of file v4traceroute.h.

Referenced by DoDispose(), Receive(), Send(), StartApplication(), and StopApplication().

◆ m_started

Time ns3::V4TraceRoute::m_started
private

Start time to report total ping time.

Definition at line 112 of file v4traceroute.h.

Referenced by StartApplication().

◆ m_ttl

uint16_t ns3::V4TraceRoute::m_ttl
private

The current TTL value.

Definition at line 120 of file v4traceroute.h.

Referenced by HandleWaitReplyTimeout(), Receive(), and Send().

◆ m_verbose

bool ns3::V4TraceRoute::m_verbose
private

produce traceroute style output if true

Definition at line 110 of file v4traceroute.h.

Referenced by GetTypeId(), HandleWaitReplyTimeout(), Receive(), StartApplication(), and StopApplication().

◆ m_waitIcmpReplyTimeout

Time ns3::V4TraceRoute::m_waitIcmpReplyTimeout
private

The wait time until the response is considered lost.

Definition at line 124 of file v4traceroute.h.

Referenced by GetTypeId(), and StartWaitReplyTimer().

◆ m_waitIcmpReplyTimer

EventId ns3::V4TraceRoute::m_waitIcmpReplyTimer
private

The timer used to wait for the probes ICMP replies.

Definition at line 126 of file v4traceroute.h.

Referenced by DoDispose(), Receive(), StartWaitReplyTimer(), and StopApplication().


The documentation for this class was generated from the following files: