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 () | |
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< Node > | GetNode () 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< Object > | GetObject () 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< Object > | GetObject (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[[maybe_unused]]) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= ([[maybe_unused]] 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... | |
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< OutputStreamWrapper > | m_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, Time > | m_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< Socket > | m_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 | DoInitialize (void) |
Initialize() implementation. More... | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. 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< Node > | m_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... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
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.
ns3::V4TraceRoute is accessible through the following paths with Config::Set and Config::Connect:
No TraceSources are defined for this type.
Size of this type is 1032 bytes (on a 64-bit architecture).
Definition at line 50 of file v4traceroute.h.
ns3::V4TraceRoute::V4TraceRoute | ( | ) |
Definition at line 88 of file v4traceroute.cc.
References m_osRoute, and m_routeIpv4.
|
virtual |
Definition at line 104 of file v4traceroute.cc.
|
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 177 of file v4traceroute.cc.
References ns3::Application::DoDispose(), ns3::EventId::IsRunning(), m_next, m_socket, m_waitIcmpReplyTimer, NS_LOG_FUNCTION, and StopApplication().
|
private |
Return the application ID in the node.
Definition at line 192 of file v4traceroute.cc.
References ns3::Node::GetApplication(), ns3::Node::GetNApplications(), ns3::Application::GetNode(), NS_ASSERT_MSG, and NS_LOG_FUNCTION.
|
static |
Get the type ID.
Definition at line 47 of file v4traceroute.cc.
References m_interval, m_maxProbes, m_maxTtl, m_remote, m_size, m_verbose, m_waitIcmpReplyTimeout, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeIpv4AddressAccessor(), ns3::MakeIpv4AddressChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeUintegerAccessor(), 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 433 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().
void ns3::V4TraceRoute::Print | ( | Ptr< OutputStreamWrapper > | stream | ) |
Prints the application traced routes into a given OutputStream.
stream | the output stream |
Definition at line 111 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 208 of file v4traceroute.cc.
References ns3::Time::As(), ns3::EventId::Cancel(), ns3::InetSocketAddress::ConvertFrom(), data, ns3::Icmpv4TimeExceeded::GetData(), ns3::Icmpv4Echo::GetDataSize(), ns3::Icmpv4Echo::GetIdentifier(), ns3::InetSocketAddress::GetIpv4(), ns3::InetSocketAddress::GetPort(), ns3::Ipv4Header::GetProtocol(), ns3::Socket::GetRxAvailable(), ns3::Icmpv4Echo::GetSequenceNumber(), ns3::Packet::GetSize(), ns3::OutputStreamWrapper::GetStream(), 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::Packet::RemoveHeader(), ns3::Simulator::Schedule(), ns3::Simulator::ScheduleNow(), StartWaitReplyTimer(), and StopApplication().
Referenced by StartApplication().
|
private |
Send one (ICMP ECHO) to the destination.
Definition at line 367 of file v4traceroute.cc.
References ns3::Packet::AddHeader(), 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().
|
privatevirtual |
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 117 of file v4traceroute.cc.
References ns3::Socket::Bind(), ns3::Socket::CreateSocket(), ns3::Ipv4Address::GetAny(), ns3::Application::GetNode(), ns3::OutputStreamWrapper::GetStream(), ns3::TypeId::LookupByName(), m_maxTtl, m_next, m_printStream, m_remote, m_size, m_socket, m_started, m_verbose, ns3::MakeCallback(), ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_UNCOND, ns3::Icmpv4L4Protocol::PROT_NUMBER, Receive(), ns3::Simulator::ScheduleNow(), ns3::ObjectBase::SetAttribute(), ns3::Socket::SetRecvCallback(), and StartWaitReplyTimer().
|
private |
Starts a timer after sending an ICMP ECHO.
Definition at line 417 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().
|
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::EventId::IsRunning(), m_next, m_socket, m_waitIcmpReplyTimer, and NS_LOG_FUNCTION.
Referenced by DoDispose(), and Receive().
|
private |
Wait interval seconds between sending each packet.
Definition at line 98 of file v4traceroute.h.
Referenced by GetTypeId(), HandleWaitReplyTimeout(), and Receive().
|
private |
The maximum number of probe packets per hop.
Definition at line 118 of file v4traceroute.h.
Referenced by GetTypeId(), HandleWaitReplyTimeout(), Receive(), and Send().
|
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().
|
private |
Next packet will be sent.
Definition at line 114 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 131 of file v4traceroute.h.
Referenced by V4TraceRoute(), HandleWaitReplyTimeout(), and Receive().
|
private |
Stream of the traceroute used for the output file.
Definition at line 135 of file v4traceroute.h.
Referenced by HandleWaitReplyTimeout(), Print(), Receive(), and StartApplication().
|
private |
The Current probe value.
Definition at line 116 of file v4traceroute.h.
Referenced by HandleWaitReplyTimeout(), Receive(), and Send().
|
private |
Remote address.
Definition at line 95 of file v4traceroute.h.
Referenced by GetTypeId(), Receive(), Send(), and StartApplication().
|
private |
The Ipv4 address of the latest hop found.
Definition at line 133 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 128 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 104 of file v4traceroute.h.
Referenced by GetTypeId(), Receive(), Send(), and StartApplication().
The socket we send packets from.
Definition at line 106 of file v4traceroute.h.
Referenced by DoDispose(), Receive(), Send(), StartApplication(), and StopApplication().
|
private |
Start time to report total ping time.
Definition at line 112 of file v4traceroute.h.
Referenced by StartApplication().
|
private |
The current TTL value.
Definition at line 120 of file v4traceroute.h.
Referenced by HandleWaitReplyTimeout(), Receive(), and Send().
|
private |
produce traceroute style output if true
Definition at line 110 of file v4traceroute.h.
Referenced by GetTypeId(), HandleWaitReplyTimeout(), Receive(), and StartApplication().
|
private |
The wait time until the response is considered lost.
Definition at line 124 of file v4traceroute.h.
Referenced by GetTypeId(), and StartWaitReplyTimer().
|
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().