23 #include "ns3/assert.h"
24 #include "ns3/address-utils.h"
41 .AddConstructor<Icmpv6Header> ()
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));
192 .AddConstructor<Icmpv6NS> ()
250 os <<
"( type = " << (uint32_t)
GetType () <<
" (NS) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
262 uint8_t buff_target[16];
263 uint16_t checksum = 0;
271 i.
Write (buff_target, 16);
306 .AddConstructor<Icmpv6NA> ()
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);
490 .AddConstructor<Icmpv6RA> ()
620 os <<
"( type = " << (uint32_t)
GetType () <<
" (RA) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
632 uint16_t checksum = 0;
643 flags |= (uint8_t)(1<< 7);
648 flags |= (uint8_t)(1<< 6);
653 flags |= (uint8_t)(1<< 5);
682 if (m_flags & (1 << 7))
687 if (m_flags & (1 << 6))
692 if (m_flags & (1 << 5))
710 .AddConstructor<Icmpv6RS> ()
749 os <<
"( type = " << (uint32_t)
GetType () <<
" (RS) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
762 uint16_t checksum = 0;
801 .AddConstructor<Icmpv6Redirection> ()
880 uint16_t checksum = 0;
932 .AddConstructor<Icmpv6Echo> ()
995 os <<
"( type = " << (
GetType () == 128 ?
"128 (Request)" :
"129 (Reply)") <<
996 " code = " << (uint32_t)
GetCode () <<
1009 uint16_t checksum = 0;
1048 static TypeId tid =
TypeId (
"ns3::Icmpv6DestinationUnreachable")
1050 .AddConstructor<Icmpv6DestinationUnreachable> ()
1089 os <<
"( type = " << (uint32_t)
GetType () <<
" (Destination Unreachable) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
1101 uint16_t checksum = 0;
1110 uint8_t *buf =
new uint8_t[size];
1112 i.
Write (buf, size);
1126 uint16_t length = start.
GetSize () - 8;
1127 uint8_t*
data =
new uint8_t[length];
1134 i.
Read (data, length);
1148 .AddConstructor<Icmpv6TooBig> ()
1200 os <<
"( type = " << (uint32_t)
GetType () <<
" (Too Big) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
" mtu = " << (uint32_t)
GetMtu () <<
")";
1212 uint16_t checksum = 0;
1221 uint8_t *buf =
new uint8_t[size];
1223 i.
Write (buf, size);
1237 uint16_t length = start.
GetSize () - 8;
1238 uint8_t*
data =
new uint8_t[length];
1245 i.
Read (data, length);
1259 .AddConstructor<Icmpv6TimeExceeded> ()
1298 os <<
"( type = " << (uint32_t)
GetType () <<
" (Destination Unreachable) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
")";
1311 uint16_t checksum = 0;
1320 uint8_t *buf =
new uint8_t[size];
1322 i.
Write (buf, size);
1337 uint16_t length = start.
GetSize () - 8;
1338 uint8_t*
data =
new uint8_t[length];
1345 i.
Read (data, length);
1357 static TypeId tid =
TypeId (
"ns3::Icmpv6ParameterError")
1359 .AddConstructor<Icmpv6ParameterError> ()
1411 os <<
"( type = " << (uint32_t)
GetType () <<
" (Destination Unreachable) code = " << (uint32_t)
GetCode () <<
" checksum = " << (uint32_t)
GetChecksum () <<
" ptr = " << (uint32_t)
GetPtr () <<
")";
1423 uint16_t checksum = 0;
1432 uint8_t *buf =
new uint8_t[size];
1434 i.
Write (buf, size);
1448 uint16_t length = start.
GetSize () - 8;
1449 uint8_t*
data =
new uint8_t[length];
1456 i.
Read (data, length);
1470 .AddConstructor<Icmpv6OptionHeader> ()
1522 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
")";
1549 .AddConstructor<Icmpv6OptionMtu> ()
1609 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
" MTU = " <<
m_mtu <<
")";
1644 static TypeId tid =
TypeId (
"ns3::Icmpv6OptionPrefixInformation")
1646 .AddConstructor<Icmpv6OptionPrefixInformation> ()
1672 NS_LOG_FUNCTION (
this << prefix << static_cast<uint32_t> (prefixlen));
1764 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
" prefix " <<
m_prefix <<
")";
1779 memset (buf, 0x00,
sizeof (buf));
1818 static TypeId tid =
TypeId (
"ns3::Icmpv6OptionLinkLayerAddress")
1820 .AddConstructor<Icmpv6OptionLinkLayerAddress> ()
1877 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
" L2 Address = " <<
m_addr <<
")";
1899 for (uint8_t nb = 0; nb<len; nb++)
1926 static TypeId tid =
TypeId (
"ns3::Icmpv6OptionRedirected")
1928 .AddConstructor<Icmpv6OptionRedirected> ()
1963 SetLength (1 + (m_packet->GetSize () / 8));
1969 os <<
"( type = " << (uint32_t)
GetType () <<
" length = " << (uint32_t)
GetLength () <<
")";
1990 uint8_t *buf =
new uint8_t[size];
1992 i.
Write (buf, size);
2002 uint8_t length = i.
ReadU8 ();
2008 uint8_t* buff =
new uint8_t[len2];
2009 i.
Read (buff, len2);
2010 m_packet = Create<Packet> (buff, len2);
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint16_t CalculateIpChecksum(uint16_t size)
Calculate the checksum.
virtual void Print(std::ostream &os) const
Print informations.
uint32_t GetReserved() const
Get the reserved field.
Ipv6Address m_destination
IPv6 destination address.
uint32_t m_reserved
Reserved value.
void SetPacket(Ptr< Packet > packet)
Set the redirected packet.
uint16_t GetReserved() const
Get the reserved field.
Doxygen introspection did not find any typical Config paths.
uint16_t GetId() const
Get the ID of the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint32_t m_RetransmissionTimer
The retransmission timer.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint32_t GetPtr() const
Get the pointer field.
static TypeId GetTypeId()
Get the UID of this class.
virtual void Print(std::ostream &os) const
Print informations.
#define NS_LOG_FUNCTION(parameters)
Doxygen introspection did not find any typical Config paths.
uint32_t GetReserved() const
Get the reserved field.
Doxygen introspection did not find any typical Config paths.
Doxygen introspection did not find any typical Config paths.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual void Print(std::ostream &os) const
Print informations.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
Ptr< Packet > GetPacket() const
Get the incorrect packet.
Ptr< Packet > m_packet
The incorrect packet.
Ptr< Packet > m_packet
The incorrect Packet.
Icmpv6OptionMtu()
Constructor.
Ipv6Address GetTarget() const
Get the IPv6 target address.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void SetReserved(uint32_t reserved)
Set the reserved field.
virtual ~Icmpv6TimeExceeded()
Destructor.
Doxygen introspection did not find any typical Config paths.
Icmpv6TimeExceeded()
Constructor.
automatically resized byte buffer
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Doxygen introspection did not find any typical Config paths.
virtual void Print(std::ostream &os) const
Print informations.
Doxygen introspection did not find any typical Config paths.
uint16_t m_reserved
The reserved value.
uint32_t m_reserved
The reserved value.
static TypeId GetTypeId()
Get the UID of this class.
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Icmpv6DestinationUnreachable()
Constructor.
bool GetFlagH() const
Get the H flag.
void SetPtr(uint32_t ptr)
Set the pointer field.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Ptr< Packet > m_packet
The redirected packet.
bool GetFlagS() const
Get the S flag.
uint32_t GetSize(void) const
void SetRetransmissionTime(uint32_t r)
Set the node Retransmission time (Neighbor Discovery).
static TypeId GetTypeId()
Get the UID of this class.
Ipv6Address m_target
IPv6 target address.
static TypeId GetTypeId()
Get the UID of this class.
Ipv6Address m_target
The IPv6 target address.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
uint16_t m_id
ID of the packet (to distinguish response between many ping program).
uint8_t GetCurHopLimit() const
Get the IPv6 maximum number of jumps.
void SetMtu(uint32_t mtu)
Set the MTU.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetTarget(Ipv6Address target)
Set the IPv6 target address.
static TypeId GetTypeId()
Get the UID of this class.
uint32_t ReadNtohU32(void)
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
Icmpv6Echo()
Default constructor.
uint16_t GetLifeTime() const
Get the node Life time (Neighbor Discovery).
Icmpv6ParameterError()
Constructor.
static TypeId GetTypeId()
Get the UID of this class.
static TypeId GetTypeId()
Get the UID of this class.
iterator in a Buffer instance
a polymophic address class
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
virtual void Print(std::ostream &os) const
Print informations.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
bool GetFlagR() const
Get the R flag.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
Doxygen introspection did not find any typical Config paths.
virtual ~Icmpv6ParameterError()
Destructor.
void SetCurHopLimit(uint8_t m)
Set the IPv6 maximum number of jumps.
virtual ~Icmpv6NA()
Destructor.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
uint32_t m_reserved
The reserved value.
virtual TypeId GetInstanceTypeId(void) const
Get the instance type ID.
Ptr< Packet > GetPacket() const
Get the incorrect packet.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
virtual void Print(std::ostream &os) const
Print informations.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
Icmpv6OptionLinkLayerAddress()
Constructor.
uint32_t GetMtu() const
Get the MTU.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
void WriteU16(uint16_t data)
Ipv6Address m_target
The IPv6 target address.
Ptr< Packet > m_packet
the incorrect packet.
virtual void Print(std::ostream &os) const
Print informations.
uint32_t m_reserved
The reserved value.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void WriteHtonU16(uint16_t data)
virtual void Print(std::ostream &os) const
Print informations.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint8_t GetLength(void) const
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Print(std::ostream &os) const
Print informations.
uint8_t m_curHopLimit
The max jumps.
void Next(void)
go forward by one byte
Doxygen introspection did not find any typical Config paths.
Ptr< Packet > GetPacket() const
Get the incorrect packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
bool GetFlagO() const
Get the O flag.
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the address.
uint32_t GetReserved() const
Get the reserved field.
static TypeId GetTypeId()
Get the UID of this class.
uint32_t m_mtu
The MTU value.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
bool GetFlagO() const
Get the O flag.
virtual ~Icmpv6OptionLinkLayerAddress()
Destructor.
void SetReserved(uint16_t reserved)
Set the reserved field.
static TypeId GetTypeId()
Get the UID of this class.
Address m_addr
The hardware address.
Buffer::Iterator Begin(void) const
void SetReserved(uint32_t reserved)
Set the reserved field.
uint16_t GetSeq() const
Get the sequence number.
void Set(char const *address)
Sets an Ipv6Address by parsing the input C-string.
void SetReserved(uint32_t reserved)
Set the reserved field.
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 informations.
uint8_t m_flags
The flags field value.
virtual ~Icmpv6OptionMtu()
Destructor.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual ~Icmpv6RS()
Destructor.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Doxygen introspection did not find any typical Config paths.
virtual ~Icmpv6OptionRedirected()
Destructor.
uint32_t GetRetransmissionTime() const
Get the node Retransmission time (Neighbor Discovery).
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual ~Icmpv6Redirection()
Destructor.
uint32_t GetReserved() const
Get the reserved field.
uint32_t m_ReachableTime
The reachable time value.
virtual void Print(std::ostream &os) const
Print informations.
void Read(uint8_t *buffer, uint32_t size)
void SetFlagO(bool o)
Set the O flag.
void SetFlagH(bool h)
Set the H flag.
virtual ~Icmpv6RA()
Destructor.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void WriteHtonU32(uint32_t data)
void SetReserved(uint32_t reserved)
Set the reserved field.
void SetFlagR(bool r)
Set the R flag.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
virtual void Print(std::ostream &os) const
Print informations.
Doxygen introspection did not find any typical Config paths.
void SetFlagS(bool s)
Set the S flag.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetFlagM(bool m)
Set the M flag.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetReachableTime(uint32_t r)
Set the node Reachable time (Neighbor Discovery).
uint32_t m_ptr
The pointer field.
Describes an IPv6 address.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void WriteU8(uint8_t data)
Icmpv6TooBig()
Constructor.
virtual void Print(std::ostream &os) const
Print informations.
virtual ~Icmpv6Echo()
Destructor.
void SetDestination(Ipv6Address destination)
Set the IPv6 destination address.
uint8_t GetFlags() const
Getflags.
Ptr< Packet > GetPacket() const
Get the redirected packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual ~Icmpv6TooBig()
Destructor.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
uint16_t m_LifeTime
The lifetime value.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual ~Icmpv6NS()
Destructor.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void Write(uint8_t const *buffer, uint32_t size)
Ptr< Packet > m_packet
The incorrect packet.
Ipv6Address GetDestination() const
Get the IPv6 destination address.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
Icmpv6OptionRedirected()
Constructor.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual ~Icmpv6DestinationUnreachable()
Destructor.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
static TypeId GetTypeId()
Get the UID of this class.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Doxygen introspection did not find any typical Config paths.
bool AddAtStart(uint32_t start)
void SetFlags(uint8_t f)
Setflags.
void SetSeq(uint16_t seq)
Set the sequence number.
uint32_t m_mtu
The MTU value.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Address GetAddress() const
Get the hardware address.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint16_t ReadNtohU16(void)
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void WriteU32(uint32_t data)
Icmpv6Redirection()
Constructor.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
uint32_t GetMtu() const
Get the MTU field.
bool GetFlagM() const
Get the M flag.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
uint16_t m_seq
Sequence number (to distinguish response).
uint32_t GetSize(void) const
Doxygen introspection did not find any typical Config paths.
a unique identifier for an interface.
Ptr< Packet > GetPacket() const
Get the incorrect packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
void SetFlagO(bool o)
Set the O flag.
static TypeId GetTypeId()
Get the UID of this class.
TypeId SetParent(TypeId tid)
static TypeId GetTypeId()
Get the UID of this class.
static TypeId GetTypeId()
Get the UID of this class.
uint32_t GetReachableTime() const
Get the node Reachable time (Neighbor Discovery).
void SetId(uint16_t id)
Set the ID of the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void SetMtu(uint32_t mtu)
Set the MTU.
void SetAddress(Address addr)
Set the hardware address.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.