22 #include "ns3/assert.h"
24 #include "ns3/abort.h"
25 #include "ns3/address-utils.h"
128 os <<
"encoding " << int(encoding) <<
", hopLimit " << int(
m_hopLimit);
133 uint32_t serializedSize = 3;
138 serializedSize += 16;
152 serializedSize += 16;
174 return serializedSize;
197 for (
int j = 0; j < 8; j++ )
201 for (
int j = 0; j < 8; j++ )
207 for (
int j = 0; j < 8; j++ )
213 for (
int j = 0; j < 8; j++ )
224 for (
int j = 0; j < 8; j++ )
228 for (
int j = 0; j < 8; j++ )
234 for (
int j = 0; j < 8; j++ )
240 for (
int j = 0; j < 8; j++ )
271 uint32_t serializedSize = 3;
273 uint8_t dispatch = i.
ReadU8 ();
279 uint8_t encoding = i.
ReadU8 ();
291 for (
int j = 0; j < 8; j++)
295 for (
int j = 0; j < 8; j++)
299 serializedSize += 16;
302 for (
int j = 0; j < 8; j++)
309 for (
int j = 0; j < 8; j++)
321 for (
int j = 0; j < 8; j++)
325 for (
int j = 0; j < 8; j++)
329 serializedSize += 16;
332 for (
int j = 0; j < 8; j++)
339 for (
int j = 0; j < 8; j++)
454 for (
int i = 0; i < 8; i++)
462 for (
int i = 0; i < 8; i++)
501 for (
int i = 0; i < 8; i++)
509 for (
int i = 0; i < 8; i++)
544 : m_datagramSize (0),
576 i.
WriteU8 (uint8_t (temp >> 8));
577 i.
WriteU8 (uint8_t (temp & 0xff));
586 uint8_t temp = i.
ReadU8 ();
628 : m_datagramSize (0),
663 i.
WriteU8 (uint8_t (temp >> 8));
664 i.
WriteU8 (uint8_t (temp & 0xff));
674 uint8_t temp = i.
ReadU8 ();
743 os <<
"Uncompressed IPv6";
808 uint32_t serializedSize = 2;
828 if (
GetNh () ==
false )
841 serializedSize += 16;
854 if (
GetM () ==
false)
861 serializedSize += 16;
882 serializedSize += 16;
913 return serializedSize;
941 temp = (m_ecn << 6) | (m_flowLabel >> 16 );
956 if (
GetNh () ==
false )
979 i.
Write (temp + 8, 8);
983 i.
Write (temp + 14, 2);
990 if (
GetM () ==
false)
1004 i.
Write (temp + 8, 8);
1008 i.
Write (temp + 14, 2);
1021 if (
GetDac () ==
false )
1029 i.
Write (temp + 1, 2);
1030 i.
Write (temp + 12, 4);
1034 if (
GetDac () ==
false )
1037 i.
Write (temp + 1, 1);
1038 i.
Write (temp + 11, 5);
1042 if (
GetDac () ==
false )
1045 i.
Write (temp + 1, 1);
1046 i.
Write (temp + 13, 3);
1051 if (
GetDac () ==
false )
1104 if (
GetNh () ==
false )
1131 if (
GetSac () ==
false )
1138 memset (temp, 0x00,
sizeof (temp));
1139 i.
Read (temp + 8, 8);
1145 memset (temp, 0x00,
sizeof (temp));
1146 i.
Read (temp + 14, 2);
1162 if (
GetM () ==
false)
1168 if (
GetDac () ==
false )
1175 memset (temp, 0x00,
sizeof (temp));
1176 i.
Read (temp + 8, 8);
1182 memset (temp, 0x00,
sizeof (temp));
1183 i.
Read (temp + 14, 2);
1201 if (
GetDac () ==
false )
1208 memset (temp, 0x00,
sizeof (temp));
1209 i.
Read (temp + 1, 2);
1210 i.
Read (temp + 12, 4);
1216 if (
GetDac () ==
false )
1218 memset (temp, 0x00,
sizeof (temp));
1219 i.
Read (temp + 1, 1);
1220 i.
Read (temp + 11, 5);
1226 if (
GetDac () ==
false )
1228 memset (temp, 0x00,
sizeof (temp));
1229 i.
Read (temp + 1, 1);
1230 i.
Read (temp + 13, 3);
1237 if (
GetDac () ==
false )
1239 memset (temp, 0x00,
sizeof (temp));
1257 uint16_t field = tfField;
1268 uint16_t field = nhField;
1279 uint16_t field = hlimField;
1290 uint16_t field = cidField;
1301 uint16_t field = sacField;
1312 uint16_t field = samField;
1323 uint16_t field = mField;
1334 uint16_t field = dacField;
1345 uint16_t field = damField;
1356 NS_ASSERT_MSG (srcContextId < 16,
"Src Context ID too large");
1367 NS_ASSERT_MSG (dstContextId < 16,
"Dst Context ID too large");
1400 NS_ASSERT_MSG (flowLabel < 0x100000,
"Flow Label too large");
1451 NS_ABORT_MSG (
"Unsupported; Context destination is not implemented");
1457 NS_ABORT_MSG (
"Unsupported; Context destination is not implemented");
1482 static TypeId tid =
TypeId (
"ns3::SixLowPanNhcExtension")
1484 .AddConstructor<SixLowPanNhcExtension> ();
1500 uint32_t serializedSize = 2;
1501 if (
GetNh () ==
false )
1512 if (
GetNh () ==
false )
1524 if (
GetNh () ==
false )
1542 uint8_t field = extensionHeaderType;
1563 uint8_t field = nhField;
1610 static TypeId tid =
TypeId (
"ns3::SixLowPanUdpNhcExtension")
1612 .AddConstructor<SixLowPanUdpNhcExtension> ();
1628 uint32_t serializedSize = 1;
1631 serializedSize += 2;
1636 serializedSize += 4;
1640 serializedSize += 3;
1643 serializedSize += 1;
1648 return serializedSize;
1735 uint16_t field = ports;
1766 uint16_t field = cField;
static TypeId GetTypeId(void)
Get the type ID.
void SetCid(bool cidField)
Set the CID (Context Identifier Extension) compression.
uint8_t GetNextHeader(void) const
Get the Next Header field.
Ports_e GetPorts(void) const
Get the compressed Src and Dst Ports.
void SetTcflCompression(bool tcflCompression)
Set the Traffic Class and Flow Labels as compressed.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
uint8_t GetNextHeader() const
Get the Next Header value.
Ipv6Address m_dstAddress
Dst address.
uint16_t m_dstPort
Destination port.
static TypeId GetTypeId(void)
Get the type ID.
void SetHopLimit(uint8_t hopLimit)
Set the Hop Limit field.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetDstCompression(LowPanHc1Addr_e dstCompression)
Set Destination Compression type.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
6LoWPAN IPv6 uncomprssed header - see RFC 4944
virtual void Print(std::ostream &os) const
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType(void) const
Get the NhcDispatch type.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field values.
uint8_t m_nhcBlob[256]
NHC compressed header.
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
static Dispatch_e GetDispatchType(uint8_t dispatch)
Get the Dispatch type.
LOWPAN_IPHC base Encoding - see RFC 6282.
void PostProcessDac()
Post-process the Destination address stateful compression.
void SetPorts(Ports_e port)
Set the compressed Src and Dst Ports.
void SetSrcCompression(LowPanHc1Addr_e srcCompression)
Set Source Compression type.
void SetSrcContextId(uint8_t srcContextId)
Set the SrcContextId.
uint16_t GetDatagramSize(void) const
Get the datagram size.
LowPanHc1Addr_e m_srcCompression
Source compresison type.
uint16_t GetDatagramSize(void) const
Get the datagram size.
virtual void Print(std::ostream &os) const
LOWPAN_NHC Extension Header Encoding - see RFC 6282.
LowPanHc1NextHeader_e
Next header information.
void SetDatagramOffset(uint8_t datagramOffset)
Set the datagram offset.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
void SetSam(HeaderCompression_e samField)
Set the SAM (Source Address Mode) compression.
virtual void Print(std::ostream &os) const
6LoWPAN FRAGN header - see RFC 4944
TrafficClassFlowLabel_e GetTf(void) const
Get the TF (Traffic Class, Flow Label) compression.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
static TypeId GetTypeId(void)
Return the instance type identifier.
bool IsTcflCompression() const
Check if the Traffic Class and Flow Labels are compressed.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
bool GetM(void) const
Get the M (Multicast) compression.
void SetTrafficClass(uint8_t trafficClass)
Set the Traffic Class value.
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType(void) const
Get the NhcDispatch type.
iterator in a Buffer instance
uint8_t m_srcPrefix[8]
Source prefix.
uint16_t GetDstPort() const
Get the Destination Port.
uint16_t m_checksum
Checksum.
bool GetNh(void) const
Get the Next Header field value.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
static TypeId GetTypeId(void)
Get the type ID.
uint8_t GetDscp(void) const
Get the DSCP.
void SetHlim(Hlim_e hlimField)
Set the HLIM (Hop Limit) compression.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
uint16_t m_srcPort
Source port.
uint16_t GetDatagramTag(void) const
Get the datagram tag.
Ipv6Address GetSrcAddress() const
Get the Source Address.
LowPanHc1Addr_e
Kind of address compression.
uint16_t GetSrcPort() const
Get the Destination Port.
void SetBlob(const uint8_t *blob, uint32_t size)
Set the option header data blob.
const uint8_t * GetSrcInterface() const
Get the source interface.
void SetHc2HeaderPresent(bool hc2HeaderPresent)
Set the next header a HC2 compressed header.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
bool GetCid(void) const
Get the CID (Context Identifier Extension) compression.
void SetDscp(uint8_t dscp)
Set the DSCP (6bits).
uint8_t GetTrafficClass() const
Get the Traffic Class value.
uint16_t m_datagramTag
datagram tag
uint8_t m_hopLimit
Hop Limit.
void SetDstInterface(const uint8_t *dstInterface)
Set the destination interface.
LowPanHc1Addr_e m_dstCompression
Destination compresison type.
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
void WriteU16(uint16_t data)
bool IsHc2HeaderPresent() const
Check if there is a HC2 compressed header.
void WriteHtonU16(uint16_t data)
uint16_t m_datagramSize
datagram size
void SetNh(bool nhField)
Set the NH (Next Header) compression.
Ipv6Address GetDstAddress() const
Get the Destination Address.
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
uint16_t GetDatagramTag(void) const
Get the datagram tag.
uint8_t GetHopLimit(void) const
Get the Hop Limit field.
LowPanHc1Addr_e GetDstCompression() const
Get Destination Compression type.
uint8_t GetEcn(void) const
Get the ECN.
void SetDstPort(uint16_t port)
Set the Destination Port.
uint32_t m_flowLabel
Flow Label.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
static TypeId GetTypeId(void)
Get the type ID.
uint8_t GetHopLimit(void) const
Get the "Hop limit" field (TTL).
bool GetNh(void) const
Get the NH (Next Header) compression.
HeaderCompression_e GetDam(void) const
Get the DAM (Destination Address Mode) compression.
virtual void Print(std::ostream &os) const
Hlim_e GetHlim(void) const
Get the HLIM (Hop Limit) compression.
uint8_t GetSrcContextId(void) const
Get the SrcContextId.
void SetSrcPort(uint16_t port)
Set the Destination Port.
HeaderCompression_e GetSam(void) const
Get the SAM (Source Address Mode) compression.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
virtual void Print(std::ostream &os) const
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
uint16_t m_datagramTag
datagram tag
SixLowPanNhcExtension(void)
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field.
TrafficClassFlowLabel_e
TF: Traffic Class, Flow Label.
uint32_t GetFlowLabel() const
Get the Flow Label value.
virtual void Print(std::ostream &os) const
uint8_t m_trafficClass
Traffic Class.
bool GetC(void) const
Get the C (Checksum).
bool GetSac(void) const
Get the SAC (Source Address Compression) compression.
void SetDstContextId(uint8_t dstContextId)
Set the DstContextId.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
void SetSrcAddress(Ipv6Address srcAddress)
Set the Source Address.
bool GetDac(void) const
Get the DAC (Destination Address Compression) compression.
LowPanHc1NextHeader_e m_nextHeaderCompression
next header compression
void Read(uint8_t *buffer, uint32_t size)
const uint8_t * GetDstPrefix() const
Get the destination prefix.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
SixLowPanUdpNhcExtension(void)
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint8_t GetNextHeader(void) const
Get the Next Header field value.
6LoWPAN HC1 header - see RFC 4944
Dispatch_e
Dispatch values, as defined in RFC4944 and RFC6282.
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
void SetDac(bool dacField)
Set the DAC (Destination Address Compression) compression.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint8_t m_hopLimit
Hop Limit.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
uint8_t m_nhcExtensionHeader
NHC extension header type.
void SetSrcInterface(const uint8_t *srcInterface)
Set the source interface.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
void SetDstPrefix(const uint8_t *dstPrefix)
Set the destination prefix.
Describes an IPv6 address.
Ipv6Address m_srcAddress
Src address.
Eid_e
EID: IPv6 Extension Header ID.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label (20bits).
void WriteU8(uint8_t data)
Eid_e GetEid(void) const
Get the Extension Header Type.
uint8_t m_datagramOffset
datagram offset
bool m_tcflCompression
is TC and FL compressed
uint32_t m_flowLabel
Flow Label bits.
uint8_t m_dstPrefix[8]
Destinaiton prefix.
const uint8_t * GetSrcPrefix() const
Get the source prefix.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint16_t m_datagramSize
datagram size
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint8_t m_baseFormat
Dispatch + encoding fields.
uint8_t m_srcInterface[8]
Source interface.
uint8_t m_nhcBlobLength
Length of the NHC compressed header.
uint32_t GetFlowLabel(void) const
Get the Flow Label.
uint8_t GetDstContextId(void) const
Get the DstContextId.
static NhcDispatch_e GetNhcDispatchType(uint8_t dispatch)
Get the NhcDispatch type.
uint16_t m_baseFormat
Dispatch + encoding fields.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetEid(Eid_e extensionHeaderType)
Set the Extension Header Type.
void Write(uint8_t const *buffer, uint32_t size)
bool m_hc2HeaderPresent
is next header HC2 compressed
void SetNh(bool nhField)
Set the NH field values.
uint8_t m_nhcNextHeader
Next header.
void SetTf(TrafficClassFlowLabel_e tfField)
Set the TF (Traffic Class, Flow Label) compression.
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Get the option header data blob.
const uint8_t * GetDstInterface() const
Get the destination interface.
void SetDstAddress(Ipv6Address dstAddress)
Set the Destination Address.
uint8_t m_nextHeader
Next header.
static TypeId GetTypeId(void)
Get the type ID.
void SetM(bool mField)
Set the M (Multicast) compression.
NhcDispatch_e
Dispatch values for Next Header compression.
void SetSrcPrefix(const uint8_t *srcPrefix)
Set the source prefix.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint16_t ReadNtohU16(void)
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
void SetEcn(uint8_t ecn)
Set the ECN (2bits).
6LoWPAN FRAG1 header - see RFC 4944
uint8_t GetDatagramOffset(void) const
Get the datagram offset.
LowPanHc1Addr_e GetSrcCompression() const
Get Source Compression type.
a unique identifier for an interface.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
TypeId SetParent(TypeId tid)
uint8_t m_dstInterface[8]
Destination interface.
UDP LOWPAN_NHC Extension Header Encoding - see RFC 6282.
uint8_t m_nextHeader
Next header.
void SetC(bool cField)
Set the C (Checksum).
HeaderCompression_e
Source or Destination Address Mode.
uint8_t m_srcdstContextId
Src and Dst Context ID.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header value.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
void SetDam(HeaderCompression_e damField)
Set the DAM (Destination Address Mode) compression.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label value.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
uint16_t GetChecksum(void) const
Get the Checksum field value.
void PostProcessSac()
Post-process the Source address stateful compression.
virtual void Print(std::ostream &os) const
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.