22 #include "ns3/nstime.h"
23 #include "ns3/simulator.h"
24 #include "ns3/socket-factory.h"
25 #include "ns3/packet.h"
26 #include "ns3/socket.h"
27 #include "ns3/uinteger.h"
29 #include "ns3/ipv6-address.h"
30 #include "ns3/inet6-socket-address.h"
31 #include "ns3/icmpv6-header.h"
32 #include "ns3/ipv6-raw-socket-factory.h"
33 #include "ns3/ipv6-header.h"
34 #include "ns3/ipv6-extension-header.h"
51 .AddConstructor<Ping6>()
52 .AddAttribute (
"MaxPackets",
53 "The maximum number of packets the application will send",
56 MakeUintegerChecker<uint32_t>())
57 .AddAttribute (
"Interval",
58 "The time to wait between packets",
62 .AddAttribute (
"RemoteIpv6",
63 "The Ipv6Address of the outbound packets",
66 MakeIpv6AddressChecker ())
67 .AddAttribute (
"LocalIpv6",
68 "Local Ipv6Address of the sender",
71 MakeIpv6AddressChecker ())
72 .AddAttribute (
"PacketSize",
73 "Size of packets generated",
76 MakeUintegerChecker<uint32_t>())
198 p = Create<Packet> (
data, 4);
199 p->AddAtEnd (Create<Packet> (
m_size - 4));
222 p->AddHeader (routingHeader);
245 while ((packet = socket->
RecvFrom (from)))
256 packet->
CopyData (&type,
sizeof(type));
263 NS_LOG_INFO (
"Received Echo Reply size = " << std::dec << packet->
GetSize () <<
" bytes from " << address.
GetIpv6 () <<
" id = " << (uint16_t)reply.
GetId () <<
" seq = " << (uint16_t)reply.
GetSeq ());
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
virtual ~Ping6()
Destructor.
uint16_t GetId() const
Get the ID of the packet.
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
keep track of time values and allow control of global simulation resolution
#define NS_LOG_FUNCTION(parameters)
virtual void StopApplication()
Stop the application.
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
Access to the IPv6 forwarding table, interfaces, and configuration.
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
IPv6 address associated with an interface.
void SetRouters(std::vector< Ipv6Address > routers)
Set routers for routing type 0 (loose routing).
uint32_t GetSize(void) const
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Callback< R > MakeNullCallback(void)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Time m_interval
Intervall between packets sent.
void Send()
Send a packet.
a polymophic address class
void SetIfIndex(uint32_t ifIndex)
Set the out interface index.
The base class for all ns3 applications.
hold objects of type ns3::Time
virtual Ipv6InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Get IPv6 address on specified IPv6 interface.
Hold an unsigned integer type.
Ptr< Node > GetNode() const
uint32_t m_sent
Number of packets sent.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
virtual void StartApplication()
Start the application.
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
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...
std::vector< Ipv6Address > m_routers
Routers addresses for routing type 0.
void SetLocal(Ipv6Address ipv6)
Set the local address.
uint16_t GetSeq() const
Get the sequence number.
uint32_t m_size
Size of the packet.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Ptr< Socket > m_socket
Local socket.
Hold objects of type ns3::Ipv6Address.
Doxygen introspection did not find any typical Config paths.
#define NS_ASSERT_MSG(condition, message)
Describes an IPv6 address.
Ipv6InterfaceAddress::Scope_e GetScope() const
Get address scope.
void SetRemote(Ipv6Address ipv6)
Set the remote peer.
an identifier for simulation events.
uint16_t m_seq
Sequence number.
uint32_t m_ifIndex
Out interface (i.e.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
Ipv6Address m_localAddress
Local address.
static bool IsMatchingType(const Address &addr)
If the address match.
void ScheduleTransmit(Time dt)
Schedule sending a packet.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual void DoDispose()
Dispose this object;.
void SetSeq(uint16_t seq)
Set the sequence number.
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.
EventId m_sendEvent
Event ID.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
static TypeId GetTypeId()
Get the type ID.
void SetAttribute(std::string name, const AttributeValue &value)
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Ptr< T > GetObject(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Ipv6Address m_peerAddress
Peer address.
void SetId(uint16_t id)
Set the ID of the packet.
void HandleRead(Ptr< Socket > socket)
Receive method.
static TypeId LookupByName(std::string name)
uint32_t m_count
Number of "Echo request" packets that will be sent.