|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
28 #include "ns3/icmpv4.h"
29 #include "ns3/icmpv4-l4-protocol.h"
30 #include "ns3/assert.h"
32 #include "ns3/ipv4-address.h"
33 #include "ns3/socket.h"
34 #include "ns3/uinteger.h"
35 #include "ns3/boolean.h"
36 #include "ns3/inet-socket-address.h"
37 #include "ns3/packet.h"
38 #include "ns3/trace-source-accessor.h"
51 .SetGroupName (
"Internet-Apps")
53 .AddAttribute (
"Remote",
54 "The address of the machine we want to trace.",
58 .AddAttribute (
"Verbose",
59 "Produce usual output.",
63 .AddAttribute (
"Interval",
"Wait interval between sent packets.",
67 .AddAttribute (
"Size",
"The number of data bytes to be sent, real packet will be 8 (ICMP) + 20 (IP) bytes longer.",
70 MakeUintegerChecker<uint32_t> ())
71 .AddAttribute (
"MaxHop",
"The maximum number of hops to trace.",
74 MakeUintegerChecker<uint32_t> ())
75 .AddAttribute (
"ProbeNum",
"The number of packets send to each hop.",
78 MakeUintegerChecker<uint16_t> ())
79 .AddAttribute (
"Timeout",
"The waiting time for a route response before a timeout.",
98 m_waitIcmpReplyTimeout (
Seconds (5))
128 <<
m_size <<
" bytes of data.");
135 <<
m_size <<
" bytes of data.\n";
253 recvSeq = (uint16_t)
data[7] << 0;
254 recvSeq |= (uint16_t)
data [6] << 8;
257 std::map<uint16_t, Time>::iterator i =
m_sent.find (recvSeq);
260 Time sendTime = i->second;
311 uint32_t * buf =
new uint32_t [
m_size];
318 Time sendTime = i->second;
382 for (uint32_t i = 0; i <
m_size; ++i)
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time m_interval
Wait interval seconds between sending each packet.
EventId m_waitIcmpReplyTimer
The timer used to wait for the probes ICMP replies.
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
uint32_t m_size
Specifies the number of data bytes to be sent.
uint16_t m_maxProbes
The maximum number of probe packets per hop.
static bool IsMatchingType(const Address &address)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::ostringstream routeIpv4
The Ipv4 address of the latest hop found.
AttributeValue implementation for Boolean.
void SetIdentifier(uint16_t id)
Set the Echo identifier.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Ptr< const AttributeAccessor > MakeIpv4AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint16_t m_ttl
The current TTL value.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
ICMP Time Exceeded header.
void AddHeader(const Header &header)
Add header to this packet.
uint16_t GetPort(void) const
uint16_t GetSequenceNumber(void) const
Get the Echo sequence number.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetSequenceNumber(uint16_t seq)
Set the Echo sequence number.
std::ostringstream osRoute
Stream of characters used for printing a single route.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
Ptr< const AttributeChecker > MakeIpv4AddressChecker(void)
virtual void DoDispose(void)
Destructor implementation.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
EventId m_next
Next packet will be sent.
uint16_t m_seq
ICMP ECHO sequence number.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< OutputStreamWrapper > printStream
Stream of the traceroute used for the output file.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
std::map< uint16_t, Time > m_sent
All sent but not answered packets. Map icmp seqno -> when sent.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
static const uint8_t PROT_NUMBER
ICMP protocol number (0x1)
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
a polymophic address class
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
Ipv4Address GetIpv4(void) const
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
uint32_t GetApplicationId(void) const
Return the application ID in the node.
void Send()
Send one (ICMP ECHO) to the destination.
static bool ChecksumEnabled(void)
void GetData(uint8_t payload[8]) const
Get the ICMP carried data.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
void Print(Ptr< OutputStreamWrapper > stream)
Prints the application traced routes into a given OutputStream.
virtual void StartApplication(void)
Application specific startup code.
uint32_t m_maxTtl
The maximium Ttl (Max number of hops to trace)
Simulation virtual time values and global simulation resolution.
virtual int Close(void)=0
Close a socket.
uint32_t m_probeCount
The Current probe value.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
virtual void StopApplication(void)
Application specific shutdown code.
virtual void DoDispose(void)
Destructor implementation.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Time m_started
Start time to report total ping time.
Traceroute application sends one ICMP ECHO request with TTL=1, and after receiving an ICMP TIME EXCEE...
uint32_t GetDataSize(void) const
Get the Echo data size.
static Ipv4Address GetAny(void)
Ptr< Socket > m_socket
The socket we send packets from.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint32_t GetData(uint8_t payload[]) const
Get the Echo data.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool m_verbose
produce traceroute style output if true
void Receive(Ptr< Socket > socket)
Receive an ICMP Echo.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Time m_waitIcmpReplyTimeout
The wait time until the response is considered lost.
Hold an unsigned integer type.
Ptr< Node > GetNode() const
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Ipv4Address m_remote
Remote address.
void HandleWaitReplyTimeout()
Triggers an action if an ICMP TIME EXCEED have not being received in the time defined by StartWaitRep...
uint16_t GetIdentifier(void) const
Get the Echo identifier.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
The base class for all ns3 applications.
uint32_t GetNApplications(void) const
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
void SetData(Ptr< const Packet > data)
Set the Echo data.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
void StartWaitReplyTimer()
Starts a timer after sending an ICMP ECHO.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
AttributeValue implementation for Ipv4Address.
static TypeId GetTypeId(void)
Get the type ID.