23 #include "ns3/assert.h"
24 #include "ns3/address-utils.h"
40 .SetGroupName (
"Internet")
53 : m_calcChecksum (true),
105 os <<
"( type = " << (uint32_t)
m_type <<
" code = " << (uint32_t)
m_code <<
" checksum = " << (uint32_t)
m_checksum <<
")";
152 NS_LOG_FUNCTION (
this << src << dst << length <<
static_cast<uint32_t
> (protocol));
191 .SetGroupName (
"Internet")
250 os <<
"( type = " << (uint32_t)
GetType () <<
" (NS) code = " << (uint32_t)
GetCode () <<
" target = " <<
m_target <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
262 uint8_t buff_target[16];
263 uint16_t checksum = 0;
271 i.
Write (buff_target, 16);
305 .SetGroupName (
"Internet")
397 os <<
"( type = " << (uint32_t)
GetType () <<
" (NA) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
409 uint8_t buff_target[16];
410 uint16_t checksum = 0;
420 reserved |= (uint32_t)(1 << 31);
425 reserved |= (uint32_t)(1<< 30);
430 reserved |= (uint32_t)(1<< 29);
435 i.
Write (buff_target, 16);
489 .SetGroupName (
"Internet")
618 os <<
"( type = " << (uint32_t)
GetType () <<
" (RA) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
630 uint16_t checksum = 0;
641 flags |= (uint8_t)(1<< 7);
646 flags |= (uint8_t)(1<< 6);
651 flags |= (uint8_t)(1<< 5);
675 uint8_t flags = i.
ReadU8 ();
680 if (flags & (1 << 7))
685 if (flags & (1 << 6))
690 if (flags & (1 << 5))
707 .SetGroupName (
"Internet")
747 os <<
"( type = " << (uint32_t)
GetType () <<
" (RS) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
760 uint16_t checksum = 0;
798 .SetGroupName (
"Internet")
878 uint16_t checksum = 0;
929 .SetGroupName (
"Internet")
993 os <<
"( type = " << (
GetType () == 128 ?
"128 (Request)" :
"129 (Reply)") <<
994 " Id = " << (uint32_t)
GetId () <<
995 " SeqNo = " << (uint32_t)
GetSeq () <<
1008 uint16_t checksum = 0;
1046 static TypeId tid =
TypeId (
"ns3::Icmpv6DestinationUnreachable")
1048 .SetGroupName (
"Internet")
1082 os <<
"( type = " << (uint32_t)
GetType () <<
" (Destination Unreachable) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
1096 uint16_t checksum = 0;
1109 uint8_t *buf =
new uint8_t[size];
1111 iter.
Write (buf, size);
1114 iter = secondaryBuffer.
Begin ();
1142 .SetGroupName (
"Internet")
1189 os <<
"( type = " << (uint32_t)
GetType () <<
" (Too Big) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
" mtu = " << (uint32_t)
GetMtu () <<
")";
1203 uint16_t checksum = 0;
1216 uint8_t *buf =
new uint8_t[size];
1218 iter.
Write (buf, size);
1221 iter = secondaryBuffer.
Begin ();
1249 .SetGroupName (
"Internet")
1284 os <<
"( type = " << (uint32_t)
GetType () <<
" (Destination Unreachable) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
1298 uint16_t checksum = 0;
1311 uint8_t *buf =
new uint8_t[size];
1313 iter.
Write (buf, size);
1316 iter = secondaryBuffer.
Begin ();
1342 static TypeId tid =
TypeId (
"ns3::Icmpv6ParameterError")
1344 .SetGroupName (
"Internet")
1391 os <<
"( type = " << (uint32_t)
GetType () <<
" (Destination Unreachable) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
" ptr = " << (uint32_t)
GetPtr () <<
")";
1405 uint16_t checksum = 0;
1418 uint8_t *buf =
new uint8_t[size];
1420 iter.
Write (buf, size);
1423 iter = secondaryBuffer.
Begin ();
1451 .SetGroupName (
"Internet")
1504 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
")";
1530 .SetGroupName (
"Internet")
1591 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
" MTU = " <<
m_mtu <<
")";
1625 static TypeId tid =
TypeId (
"ns3::Icmpv6OptionPrefixInformation")
1627 .SetGroupName (
"Internet")
1654 NS_LOG_FUNCTION (
this << prefix <<
static_cast<uint32_t
> (prefixlen));
1746 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
" prefix " <<
m_prefix <<
")";
1761 memset (buf, 0x00,
sizeof (buf));
1799 static TypeId tid =
TypeId (
"ns3::Icmpv6OptionLinkLayerAddress")
1801 .SetGroupName (
"Internet")
1859 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
" L2 Address = " <<
m_addr <<
")";
1881 for (uint8_t nb = 0; nb<len; nb++)
1908 static TypeId tid =
TypeId (
"ns3::Icmpv6OptionRedirected")
1910 .SetGroupName (
"Internet")
1946 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
")";
1967 uint8_t *buf =
new uint8_t[size];
1969 i.
Write (buf, size);
1979 uint8_t length = i.
ReadU8 ();
1985 uint8_t* buff =
new uint8_t[len2];
1986 i.
Read (buff, len2);
1987 m_packet = Create<Packet> (buff, len2);
double f(double x, void *params)
a polymophic address class
uint8_t GetLength(void) const
Get the length of the underlying address.
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
iterator in a Buffer instance
void Write(uint8_t const *buffer, uint32_t size)
void WriteU32(uint32_t data)
uint16_t ReadNtohU16(void)
uint16_t CalculateIpChecksum(uint16_t size)
Calculate the checksum.
void WriteU8(uint8_t data)
void Next(void)
go forward by one byte
void WriteU16(uint16_t data)
void Read(uint8_t *buffer, uint32_t size)
void WriteHtonU16(uint16_t data)
void WriteHtonU32(uint32_t data)
uint32_t GetSize(void) const
uint32_t ReadNtohU32(void)
automatically resized byte buffer
void AddAtStart(uint32_t start)
Buffer::Iterator Begin(void) const
ICMPv6 Error Destination Unreachable header.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Print(std::ostream &os) const
Print information.
Icmpv6DestinationUnreachable()
Constructor.
Ptr< Packet > m_packet
The incorrect Packet.
static TypeId GetTypeId()
Get the UID of this class.
virtual ~Icmpv6DestinationUnreachable()
Destructor.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the UID of this class.
void SetId(uint16_t id)
Set the ID of the packet.
uint16_t m_seq
Sequence number (to distinguish response).
Icmpv6Echo()
Default constructor.
virtual void Print(std::ostream &os) const
Print information.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint16_t m_id
ID of the packet (to distinguish response between many ping program).
virtual ~Icmpv6Echo()
Destructor.
uint16_t GetId() const
Get the ID of the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void SetSeq(uint16_t seq)
Set the sequence number.
uint16_t GetSeq() const
Get the sequence number.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
ICMPv6 Neighbor Advertisement header.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
bool GetFlagS() const
Get the S flag.
virtual void Print(std::ostream &os) const
Print information.
uint32_t m_reserved
The reserved value.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void SetFlagS(bool s)
Set the S flag.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
void SetFlagR(bool r)
Set the R flag.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
bool GetFlagR() const
Get the R flag.
bool GetFlagO() const
Get the O flag.
void SetFlagO(bool o)
Set the O flag.
void SetReserved(uint32_t reserved)
Set the reserved field.
static TypeId GetTypeId()
Get the UID of this class.
Ipv6Address m_target
The IPv6 target address.
virtual ~Icmpv6NA()
Destructor.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint32_t GetReserved() const
Get the reserved field.
ICMPv6 Neighbor Solicitation header.
uint32_t m_reserved
The reserved value.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
uint32_t GetReserved() const
Get the reserved field.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the UID of this class.
Ipv6Address m_target
The IPv6 target address.
void SetReserved(uint32_t reserved)
Set the reserved field.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual ~Icmpv6NS()
Destructor.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
virtual void Print(std::ostream &os) const
Print information.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
ICMPv6 link-layer address option.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
Icmpv6OptionLinkLayerAddress()
Constructor.
virtual void Print(std::ostream &os) const
Print information.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual TypeId GetInstanceTypeId(void) const
Get the instance type ID.
virtual ~Icmpv6OptionLinkLayerAddress()
Destructor.
static TypeId GetTypeId()
Get the UID of this class.
Address m_addr
The hardware address.
Address GetAddress() const
Get the hardware address.
void SetAddress(Address addr)
Set the hardware address.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint16_t m_reserved
The reserved value.
void SetReserved(uint16_t reserved)
Set the reserved field.
uint32_t GetMtu() const
Get the MTU.
static TypeId GetTypeId()
Get the UID of this class.
void SetMtu(uint32_t mtu)
Set the MTU.
virtual void Print(std::ostream &os) const
Print information.
virtual ~Icmpv6OptionMtu()
Destructor.
uint32_t m_mtu
The MTU value.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Icmpv6OptionMtu()
Constructor.
uint16_t GetReserved() const
Get the reserved field.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
ICMPv6 redirected option.
Icmpv6OptionRedirected()
Constructor.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Ptr< Packet > m_packet
The redirected packet.
virtual ~Icmpv6OptionRedirected()
Destructor.
static TypeId GetTypeId()
Get the UID of this class.
virtual void Print(std::ostream &os) const
Print information.
void SetPacket(Ptr< Packet > packet)
Set the redirected packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
ICMPv6 Error Parameter Error header.
uint32_t m_ptr
The pointer field.
virtual ~Icmpv6ParameterError()
Destructor.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Print(std::ostream &os) const
Print information.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
static TypeId GetTypeId()
Get the UID of this class.
void SetPtr(uint32_t ptr)
Set the pointer field.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Ptr< Packet > m_packet
The incorrect packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
uint32_t GetPtr() const
Get the pointer field.
Icmpv6ParameterError()
Constructor.
ICMPv6 Router Advertisement header.
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
NS_DEPRECATED_3_34 void SetFlags(uint8_t f)
Setflags.
uint32_t GetRetransmissionTime() const
Get the node Retransmission time (Neighbor Discovery).
NS_DEPRECATED_3_34 uint8_t GetFlags() const
Getflags.
void SetFlagH(bool h)
Set the H flag.
void SetRetransmissionTime(uint32_t r)
Set the node Retransmission time (Neighbor Discovery).
void SetCurHopLimit(uint8_t m)
Set the IPv6 maximum number of jumps.
void SetFlagO(bool o)
Set the O flag.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void SetFlagM(bool m)
Set the M flag.
void SetReachableTime(uint32_t r)
Set the node Reachable time (Neighbor Discovery).
static TypeId GetTypeId()
Get the UID of this class.
uint32_t m_RetransmissionTimer
The retransmission timer.
uint16_t GetLifeTime() const
Get the node Life time (Neighbor Discovery).
uint32_t GetReachableTime() const
Get the node Reachable time (Neighbor Discovery).
uint8_t GetCurHopLimit() const
Get the IPv6 maximum number of jumps.
bool GetFlagO() const
Get the O flag.
uint16_t m_LifeTime
The lifetime value.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
bool GetFlagM() const
Get the M flag.
uint8_t m_curHopLimit
The max jumps.
virtual ~Icmpv6RA()
Destructor.
uint32_t m_ReachableTime
The reachable time value.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Print(std::ostream &os) const
Print information.
bool GetFlagH() const
Get the H flag.
ICMPv6 Router Solicitation header.
void SetReserved(uint32_t reserved)
Set the reserved field.
uint32_t GetReserved() const
Get the reserved field.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
uint32_t m_reserved
The reserved value.
static TypeId GetTypeId()
Get the UID of this class.
virtual ~Icmpv6RS()
Destructor.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Print(std::ostream &os) const
Print information.
ICMPv6 Redirection header.
Ipv6Address m_target
IPv6 target address.
Ipv6Address GetTarget() const
Get the IPv6 target address.
Ipv6Address m_destination
IPv6 destination address.
uint32_t GetReserved() const
Get the reserved field.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Icmpv6Redirection()
Constructor.
virtual ~Icmpv6Redirection()
Destructor.
void SetDestination(Ipv6Address destination)
Set the IPv6 destination address.
void SetReserved(uint32_t reserved)
Set the reserved field.
Ipv6Address GetDestination() const
Get the IPv6 destination address.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
void SetTarget(Ipv6Address target)
Set the IPv6 target address.
virtual void Print(std::ostream &os) const
Print information.
static TypeId GetTypeId()
Get the UID of this class.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint32_t m_reserved
Reserved value.
ICMPv6 Error Time Exceeded header.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
Icmpv6TimeExceeded()
Constructor.
static TypeId GetTypeId()
Get the UID of this class.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Print(std::ostream &os) const
Print information.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual ~Icmpv6TimeExceeded()
Destructor.
Ptr< Packet > m_packet
The incorrect packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
ICMPv6 Error Too Big header.
static TypeId GetTypeId()
Get the UID of this class.
void SetMtu(uint32_t mtu)
Set the MTU.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Ptr< Packet > m_packet
the incorrect packet.
Icmpv6TooBig()
Constructor.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual void Print(std::ostream &os) const
Print information.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
virtual ~Icmpv6TooBig()
Destructor.
uint32_t m_mtu
The MTU value.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint32_t GetMtu() const
Get the MTU field.
Describes an IPv6 address.
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the address.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
void Set(char const *address)
Sets an Ipv6Address by parsing the input C-string.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.