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

Static Public Member Functions

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

Protected Member Functions

void DoDispose () override
 Destructor implementation.
 
- Protected Member Functions inherited from ns3::Application
void DoDispose () override
 Destructor implementation.
 
void DoInitialize () override
 Initialize() implementation.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Private Member Functions

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

Private Attributes

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

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.
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source.
 
- Protected Attributes inherited from ns3::Application
Ptr< Nodem_node
 The node that this application is installed on.
 
EventId m_startEvent
 The event that will fire at m_startTime to start the application.
 
Time m_startTime
 The simulation time that the application will start.
 
EventId m_stopEvent
 The event that will fire at m_stopTime to end the application.
 
Time m_stopTime
 The simulation time that the application will end.
 

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

  • 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
  • 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
  • Remote: The address of the machine we want to trace.
  • 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
  • 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
  • Tos: The Type of Service used to send IPv4 packets. All 8 bits of the TOS byte are set (including ECN bits).
    • Set with class: ns3::UintegerValue
    • Underlying type: uint8_t 0:255
    • Initial value: 0
    • Flags: constructwriteread
  • Verbose: Produce usual output.
    • Set with class: ns3::BooleanValue
    • Underlying type: bool
    • Initial value: true
    • 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 1008 bytes (on a 64-bit architecture).

Definition at line 50 of file v4traceroute.h.

Constructor & Destructor Documentation

◆ V4TraceRoute()

ns3::V4TraceRoute::V4TraceRoute ( )

Definition at line 98 of file v4traceroute.cc.

References m_osRoute, and m_routeIpv4.

◆ ~V4TraceRoute()

ns3::V4TraceRoute::~V4TraceRoute ( )
override

Definition at line 114 of file v4traceroute.cc.

Member Function Documentation

◆ DoDispose()

void ns3::V4TraceRoute::DoDispose ( )
overrideprotectedvirtual

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::Object.

Definition at line 192 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 ( ) const
private

Return the application ID in the node.

Returns
the application id

Definition at line 206 of file v4traceroute.cc.

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

+ Here is the call graph for this function:

◆ GetTypeId()

TypeId ns3::V4TraceRoute::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 46 of file v4traceroute.cc.

References m_interval, m_maxProbes, m_maxTtl, m_remote, m_size, m_tos, m_verbose, m_waitIcmpReplyTimeout, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeIpv4AddressAccessor(), ns3::MakeIpv4AddressChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeUintegerAccessor(), ns3::Seconds(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ HandleWaitReplyTimeout()

void ns3::V4TraceRoute::HandleWaitReplyTimeout ( )
private

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

Definition at line 438 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 119 of file v4traceroute.cc.

References m_printStream.

◆ Receive()

void ns3::V4TraceRoute::Receive ( Ptr< Socket socket)
private

◆ Send()

void ns3::V4TraceRoute::Send ( )
private

Send one (ICMP ECHO) to the destination.

Definition at line 374 of file v4traceroute.cc.

References ns3::Node::ChecksumEnabled(), ns3::Icmpv4Header::EnableChecksum(), ns3::Icmpv4Header::ICMPV4_ECHO, m_maxProbes, m_probeCount, m_remote, m_sent, m_seq, m_size, m_socket, m_ttl, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_INFO, ns3::Socket::SendTo(), ns3::Icmpv4Header::SetCode(), ns3::Icmpv4Echo::SetData(), ns3::Icmpv4Echo::SetIdentifier(), ns3::Socket::SetIpTtl(), ns3::Icmpv4Echo::SetSequenceNumber(), and ns3::Icmpv4Header::SetType().

Referenced by StartWaitReplyTimer().

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

◆ StartApplication()

void ns3::V4TraceRoute::StartApplication ( )
overrideprivatevirtual

Application specific startup code.

The StartApplication method is called at the start time specified by Start This method should be overridden by all or most application subclasses.

Reimplemented from ns3::Application.

Definition at line 125 of file v4traceroute.cc.

References ns3::Socket::Bind(), ns3::Socket::CreateSocket(), ns3::Ipv4Address::GetAny(), ns3::Application::GetNode(), ns3::OutputStreamWrapper::GetStream(), ns3::Ipv4Address::IsInitialized(), ns3::TypeId::LookupByName(), m_maxTtl, m_next, m_printStream, m_remote, m_size, m_socket, m_started, m_tos, m_verbose, ns3::MakeCallback(), ns3::Simulator::Now(), NS_ABORT_MSG_IF, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_UNCOND, ns3::Icmpv4L4Protocol::PROT_NUMBER, Receive(), ns3::Simulator::ScheduleNow(), ns3::ObjectBase::SetAttribute(), ns3::Socket::SetIpTos(), ns3::Socket::SetRecvCallback(), and StartWaitReplyTimer().

+ Here is the call graph for this function:

◆ StartWaitReplyTimer()

void ns3::V4TraceRoute::StartWaitReplyTimer ( )
private

Starts a timer after sending an ICMP ECHO.

Definition at line 422 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 ( )
overrideprivatevirtual

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 161 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 101 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 121 of file v4traceroute.h.

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

◆ m_maxTtl

uint32_t ns3::V4TraceRoute::m_maxTtl
private

The maximum Ttl (Max number of hops to trace)

Definition at line 127 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 117 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 136 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 140 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 119 of file v4traceroute.h.

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

◆ m_remote

Ipv4Address ns3::V4TraceRoute::m_remote
private

Remote address.

Definition at line 98 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 138 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 133 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 111 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 107 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 109 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 115 of file v4traceroute.h.

Referenced by StartApplication().

◆ m_tos

uint8_t ns3::V4TraceRoute::m_tos
private

The packets Type of Service.

Definition at line 125 of file v4traceroute.h.

Referenced by GetTypeId(), and StartApplication().

◆ m_ttl

uint16_t ns3::V4TraceRoute::m_ttl
private

The current TTL value.

Definition at line 123 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 113 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 129 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 131 of file v4traceroute.h.

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


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