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"
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< Node > | GetNode () 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< Object > | GetObject () 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< Object > | GetObject (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. | |
SimpleRefCount & | operator= (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< OutputStreamWrapper > | m_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, Time > | m_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< Socket > | m_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< Node > | m_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. | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
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.
ns3::V4TraceRoute::V4TraceRoute | ( | ) |
Definition at line 87 of file v4traceroute.cc.
References m_osRoute, and m_routeIpv4.
|
override |
Definition at line 103 of file v4traceroute.cc.
|
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().
|
private |
Return the application ID in the node.
Definition at line 195 of file v4traceroute.cc.
References ns3::Application::GetNode(), NS_ASSERT_MSG, and NS_LOG_FUNCTION.
|
static |
Get the type ID.
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().
|
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().
void ns3::V4TraceRoute::Print | ( | Ptr< OutputStreamWrapper > | stream | ) |
Prints the application traced routes into a given OutputStream.
stream | the output stream |
Definition at line 108 of file v4traceroute.cc.
References m_printStream.
Receive an ICMP Echo.
socket | the receiving socket |
This function is called by lower layers through a callback.
Definition at line 211 of file v4traceroute.cc.
References ns3::EventId::Cancel(), ns3::InetSocketAddress::ConvertFrom(), data, ns3::Icmpv4TimeExceeded::GetData(), ns3::Icmpv4Echo::GetDataSize(), ns3::Icmpv4Echo::GetIdentifier(), ns3::InetSocketAddress::GetIpv4(), ns3::InetSocketAddress::GetPort(), ns3::Socket::GetRxAvailable(), ns3::Icmpv4Echo::GetSequenceNumber(), ns3::Icmpv4Header::GetType(), ns3::Icmpv4Header::ICMPV4_ECHO_REPLY, ns3::Icmpv4Header::ICMPV4_TIME_EXCEEDED, ns3::InetSocketAddress::IsMatchingType(), m_interval, m_maxProbes, m_maxTtl, m_next, m_osRoute, m_printStream, m_probeCount, m_remote, m_routeIpv4, m_sent, m_size, m_socket, m_ttl, m_verbose, m_waitIcmpReplyTimer, ns3::Time::MS, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_UNCOND, ns3::Icmpv4L4Protocol::PROT_NUMBER, ns3::Socket::RecvFrom(), ns3::Simulator::Schedule(), ns3::Simulator::ScheduleNow(), StartWaitReplyTimer(), and StopApplication().
Referenced by StartApplication().
|
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().
|
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().
|
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().
|
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().
|
private |
Wait interval seconds between sending each packet.
Definition at line 90 of file v4traceroute.h.
Referenced by GetTypeId(), HandleWaitReplyTimeout(), and Receive().
|
private |
The maximum number of probe packets per hop.
Definition at line 110 of file v4traceroute.h.
Referenced by GetTypeId(), HandleWaitReplyTimeout(), Receive(), and Send().
|
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().
|
private |
Next packet will be sent.
Definition at line 106 of file v4traceroute.h.
Referenced by DoDispose(), HandleWaitReplyTimeout(), Receive(), StartApplication(), and StopApplication().
|
private |
Stream of characters used for printing a single route.
Definition at line 125 of file v4traceroute.h.
Referenced by V4TraceRoute(), HandleWaitReplyTimeout(), and Receive().
|
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().
|
private |
The Current probe value.
Definition at line 108 of file v4traceroute.h.
Referenced by HandleWaitReplyTimeout(), Receive(), and Send().
|
private |
Remote address.
Definition at line 87 of file v4traceroute.h.
Referenced by GetTypeId(), Receive(), Send(), and StartApplication().
|
private |
The Ipv4 address of the latest hop found.
Definition at line 127 of file v4traceroute.h.
Referenced by V4TraceRoute(), HandleWaitReplyTimeout(), and Receive().
|
private |
All sent but not answered packets. Map icmp seqno -> when sent.
Definition at line 122 of file v4traceroute.h.
|
private |
|
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().
The socket we send packets from.
Definition at line 98 of file v4traceroute.h.
Referenced by DoDispose(), Receive(), Send(), StartApplication(), and StopApplication().
|
private |
Start time to report total ping time.
Definition at line 104 of file v4traceroute.h.
Referenced by StartApplication().
|
private |
The packets Type of Service.
Definition at line 114 of file v4traceroute.h.
Referenced by GetTypeId(), and StartApplication().
|
private |
The current TTL value.
Definition at line 112 of file v4traceroute.h.
Referenced by HandleWaitReplyTimeout(), Receive(), and Send().
|
private |
produce traceroute style output if true
Definition at line 102 of file v4traceroute.h.
Referenced by GetTypeId(), HandleWaitReplyTimeout(), Receive(), StartApplication(), and StopApplication().
|
private |
The wait time until the response is considered lost.
Definition at line 118 of file v4traceroute.h.
Referenced by GetTypeId(), and StartWaitReplyTimer().
|
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().