13#include "ns3/address-utils.h"
14#include "ns3/assert.h"
15#include "ns3/iana-internet-protocol-numbers.h"
30 .SetGroupName(
"Internet")
232 .SetGroupName(
"Internet")
311 uint8_t buff_target[16];
312 uint16_t checksum = 0;
320 i.
Write(buff_target, 16);
356 .SetGroupName(
"Internet")
474 uint8_t buff_target[16];
475 uint16_t checksum = 0;
500 i.
Write(buff_target, 16);
556 .SetGroupName(
"Internet")
704 uint16_t checksum = 0;
715 flags |= (uint8_t)(1 << 7);
720 flags |= (uint8_t)(1 << 6);
725 flags |= (uint8_t)(1 << 5);
750 uint8_t flags = i.
ReadU8();
755 if (flags & (1 << 7))
760 if (flags & (1 << 6))
765 if (flags & (1 << 5))
783 .SetGroupName(
"Internet")
842 uint16_t checksum = 0;
882 .SetGroupName(
"Internet")
973 uint16_t checksum = 0;
1026 .SetGroupName(
"Internet")
1095 os <<
"( type = " << (
GetType() == 128 ?
"128 (Request)" :
"129 (Reply)")
1111 uint16_t checksum = 0;
1151 static TypeId tid =
TypeId(
"ns3::Icmpv6DestinationUnreachable")
1153 .SetGroupName(
"Internet")
1207 uint16_t checksum = 0;
1220 auto buf =
new uint8_t[size];
1222 iter.
Write(buf, size);
1225 iter = secondaryBuffer.
Begin();
1255 .SetGroupName(
"Internet")
1323 uint16_t checksum = 0;
1336 auto buf =
new uint8_t[size];
1338 iter.
Write(buf, size);
1341 iter = secondaryBuffer.
Begin();
1371 .SetGroupName(
"Internet")
1425 uint16_t checksum = 0;
1438 auto buf =
new uint8_t[size];
1440 iter.
Write(buf, size);
1443 iter = secondaryBuffer.
Begin();
1471 static TypeId tid =
TypeId(
"ns3::Icmpv6ParameterError")
1473 .SetGroupName(
"Internet")
1542 uint16_t checksum = 0;
1555 auto buf =
new uint8_t[size];
1557 iter.
Write(buf, size);
1560 iter = secondaryBuffer.
Begin();
1590 .SetGroupName(
"Internet")
1677 .SetGroupName(
"Internet")
1744 <<
" MTU = " <<
m_mtu <<
")";
1782 static TypeId tid =
TypeId(
"ns3::Icmpv6OptionPrefixInformation")
1784 .SetGroupName(
"Internet")
1934 memset(buf, 0x00,
sizeof(buf));
1974 static TypeId tid =
TypeId(
"ns3::Icmpv6OptionLinkLayerAddress")
1976 .SetGroupName(
"Internet")
2008 uint8_t len = (2 +
m_addr.GetLength()) / 8;
2009 if ((2 +
m_addr.GetLength()) % 8)
2040 <<
" L2 Address = " <<
m_addr <<
")";
2064 for (uint8_t nb = 0; nb < len; nb++)
2094 static TypeId tid =
TypeId(
"ns3::Icmpv6OptionRedirected")
2096 .SetGroupName(
"Internet")
2157 auto buf =
new uint8_t[size];
2170 uint8_t length = i.
ReadU8();
2176 auto buff =
new uint8_t[len2];
a polymophic address class
iterator in a Buffer instance
void WriteU32(uint32_t data)
uint16_t CalculateIpChecksum(uint16_t size)
Calculate the checksum.
void WriteU8(uint8_t data)
void Write(const uint8_t *buffer, uint32_t size)
void WriteU16(uint16_t data)
void Read(uint8_t *buffer, uint32_t size)
void WriteHtonU16(uint16_t data)
void WriteHtonU32(uint32_t data)
void Next()
go forward by one byte
automatically resized byte buffer
void AddAtStart(uint32_t start)
Buffer::Iterator Begin() const
ICMPv6 Error Destination Unreachable header.
uint32_t GetSerializedSize() const override
Get the serialized size.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
~Icmpv6DestinationUnreachable() override
Destructor.
void Print(std::ostream &os) const override
Print information.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Icmpv6DestinationUnreachable()
Constructor.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Ptr< Packet > m_packet
The incorrect Packet.
static TypeId GetTypeId()
Get the UID of this class.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
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.
~Icmpv6Echo() override
Destructor.
uint16_t m_id
ID of the packet (to distinguish response between many ping program).
uint16_t GetId() const
Get the ID of the packet.
void Print(std::ostream &os) const override
Print information.
void SetSeq(uint16_t seq)
Set the sequence number.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint16_t GetSeq() const
Get the sequence number.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
ICMPv6 Neighbor Advertisement header.
bool GetFlagS() const
Get the S flag.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t m_reserved
The reserved value.
~Icmpv6NA() override
Destructor.
TypeId GetInstanceTypeId() const override
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.
uint32_t GetSerializedSize() const override
Get the serialized size.
bool GetFlagO() const
Get the O flag.
void SetFlagO(bool o)
Set the O flag.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void SetReserved(uint32_t reserved)
Set the reserved field.
void Print(std::ostream &os) const override
Print information.
static TypeId GetTypeId()
Get the UID of this class.
Ipv6Address m_target
The IPv6 target address.
uint32_t GetReserved() const
Get the reserved field.
ICMPv6 Neighbor Solicitation header.
uint32_t m_reserved
The reserved value.
uint32_t GetSerializedSize() const override
Get the serialized size.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
uint32_t GetReserved() const
Get the reserved field.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
static TypeId GetTypeId()
Get the UID of this class.
void Print(std::ostream &os) const override
Print information.
Ipv6Address m_target
The IPv6 target address.
void SetReserved(uint32_t reserved)
Set the reserved field.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
Icmpv6NS(Ipv6Address target)
Constructor.
~Icmpv6NS() override
Destructor.
ICMPv6 link-layer address option.
Icmpv6OptionLinkLayerAddress(bool source)
Constructor.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
~Icmpv6OptionLinkLayerAddress() override
Destructor.
Icmpv6OptionLinkLayerAddress()
Constructor.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void Print(std::ostream &os) const override
Print information.
static TypeId GetTypeId()
Get the UID of this class.
uint32_t GetSerializedSize() const override
Get the serialized size.
Address m_addr
The hardware address.
Address GetAddress() const
Get the hardware address.
void SetAddress(Address addr)
Set the hardware address.
~Icmpv6OptionMtu() override
Destructor.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint16_t m_reserved
The reserved value.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
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.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void Print(std::ostream &os) const override
Print information.
void SetMtu(uint32_t mtu)
Set the MTU.
uint32_t m_mtu
The MTU value.
Icmpv6OptionMtu()
Constructor.
uint16_t GetReserved() const
Get the reserved field.
ICMPv6 redirected option.
Icmpv6OptionRedirected()
Constructor.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
~Icmpv6OptionRedirected() override
Destructor.
Ptr< Packet > m_packet
The redirected packet.
void Print(std::ostream &os) const override
Print information.
uint32_t GetSerializedSize() const override
Get the serialized size.
static TypeId GetTypeId()
Get the UID of this class.
void SetPacket(Ptr< Packet > packet)
Set the redirected packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
ICMPv6 Error Parameter Error header.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t m_ptr
The pointer field.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
static TypeId GetTypeId()
Get the UID of this class.
void SetPtr(uint32_t ptr)
Set the pointer field.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
~Icmpv6ParameterError() override
Destructor.
void Print(std::ostream &os) const override
Print information.
Ptr< Packet > m_packet
The incorrect packet.
uint32_t GetPtr() const
Get the pointer field.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Icmpv6ParameterError()
Constructor.
ICMPv6 Router Advertisement header.
void Print(std::ostream &os) const override
Print information.
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
uint32_t GetRetransmissionTime() const
Get the node Retransmission time (Neighbor Discovery).
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.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
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.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t m_RetransmissionTimer
The retransmission timer.
uint32_t GetSerializedSize() const override
Get the serialized size.
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.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
bool GetFlagO() const
Get the O flag.
uint16_t m_LifeTime
The lifetime value.
bool GetFlagM() const
Get the M flag.
uint8_t m_curHopLimit
The max jumps.
uint32_t m_ReachableTime
The reachable time value.
~Icmpv6RA() override
Destructor.
bool GetFlagH() const
Get the H flag.
ICMPv6 Router Solicitation header.
void SetReserved(uint32_t reserved)
Set the reserved field.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
~Icmpv6RS() override
Destructor.
uint32_t GetReserved() const
Get the reserved field.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t m_reserved
The reserved value.
static TypeId GetTypeId()
Get the UID of this class.
void Print(std::ostream &os) const override
Print information.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
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.
uint32_t GetSerializedSize() const override
Get the serialized size.
~Icmpv6Redirection() override
Destructor.
void Print(std::ostream &os) const override
Print information.
Icmpv6Redirection()
Constructor.
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.
void SetTarget(Ipv6Address target)
Set the IPv6 target address.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static TypeId GetTypeId()
Get the UID of this class.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t m_reserved
Reserved value.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
ICMPv6 Error Time Exceeded header.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
~Icmpv6TimeExceeded() override
Destructor.
Icmpv6TimeExceeded()
Constructor.
static TypeId GetTypeId()
Get the UID of this class.
void Print(std::ostream &os) const override
Print information.
Ptr< Packet > m_packet
The incorrect packet.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
ICMPv6 Error Too Big header.
static TypeId GetTypeId()
Get the UID of this class.
void SetMtu(uint32_t mtu)
Set the MTU.
void Print(std::ostream &os) const override
Print information.
Ptr< Packet > m_packet
the incorrect packet.
Icmpv6TooBig()
Constructor.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t GetSerializedSize() const override
Get the serialized size.
~Icmpv6TooBig() override
Destructor.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint32_t m_mtu
The MTU value.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t GetMtu() const
Get the MTU field.
Describes an IPv6 address.
Smart pointer class similar to boost::intrusive_ptr.
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
constexpr uint8_t ICMPV6
ICMP for IPv6 [RFC8200].
Every class exported by the ns3 library is enclosed in the ns3 namespace.