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, bool permissive=false) 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.
 
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 DoInitialize () override
 Initialize() implementation.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
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.

Definition at line 39 of file v4traceroute.h.

Constructor & Destructor Documentation

◆ V4TraceRoute()

ns3::V4TraceRoute::V4TraceRoute ( )

Definition at line 87 of file v4traceroute.cc.

References m_osRoute, and m_routeIpv4.

◆ ~V4TraceRoute()

ns3::V4TraceRoute::~V4TraceRoute ( )
override

Definition at line 103 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::Application.

Definition at line 181 of file v4traceroute.cc.

References ns3::Application::DoDispose(), ns3::EventId::IsPending(), 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 195 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 35 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::MakeUintegerChecker(), 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 427 of file v4traceroute.cc.

References 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 108 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 363 of file v4traceroute.cc.

References ns3::Node::ChecksumEnabled(), ns3::Create(), 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 114 of file v4traceroute.cc.

References ns3::Socket::Bind(), ns3::Socket::CreateSocket(), ns3::Ipv4Address::GetAny(), ns3::Application::GetNode(), 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 411 of file v4traceroute.cc.

References HandleWaitReplyTimeout(), ns3::EventId::IsPending(), 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 150 of file v4traceroute.cc.

References ns3::EventId::Cancel(), ns3::Socket::Close(), ns3::EventId::IsPending(), 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 90 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 110 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 116 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 106 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 125 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 129 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 108 of file v4traceroute.h.

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

◆ m_remote

Ipv4Address ns3::V4TraceRoute::m_remote
private

Remote address.

Definition at line 87 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 127 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 122 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 100 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 96 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 98 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 104 of file v4traceroute.h.

Referenced by StartApplication().

◆ m_tos

uint8_t ns3::V4TraceRoute::m_tos
private

The packets Type of Service.

Definition at line 114 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 112 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 102 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 118 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 120 of file v4traceroute.h.

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


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