22 #include "ns3/assert.h" 24 #include "ns3/abort.h" 25 #include "ns3/address-utils.h" 108 .SetGroupName (
"SixLowPan")
131 os <<
"encoding " <<
static_cast<int> (encoding) <<
", hopLimit " << static_cast<int> (
m_hopLimit);
136 uint32_t serializedSize = 3;
141 serializedSize += 16;
155 serializedSize += 16;
177 return serializedSize;
200 for (
int j = 0; j < 8; j++ )
204 for (
int j = 0; j < 8; j++ )
210 for (
int j = 0; j < 8; j++ )
216 for (
int j = 0; j < 8; j++ )
227 for (
int j = 0; j < 8; j++ )
231 for (
int j = 0; j < 8; j++ )
237 for (
int j = 0; j < 8; j++ )
243 for (
int j = 0; j < 8; j++ )
274 uint32_t serializedSize = 3;
276 uint8_t dispatch = i.
ReadU8 ();
282 uint8_t encoding = i.
ReadU8 ();
294 for (
int j = 0; j < 8; j++)
298 for (
int j = 0; j < 8; j++)
302 serializedSize += 16;
305 for (
int j = 0; j < 8; j++)
312 for (
int j = 0; j < 8; j++)
324 for (
int j = 0; j < 8; j++)
328 for (
int j = 0; j < 8; j++)
332 serializedSize += 16;
335 for (
int j = 0; j < 8; j++)
342 for (
int j = 0; j < 8; j++)
457 for (
int i = 0; i < 8; i++)
465 for (
int i = 0; i < 8; i++)
504 for (
int i = 0; i < 8; i++)
512 for (
int i = 0; i < 8; i++)
547 : m_datagramSize (0),
556 .SetGroupName (
"SixLowPan")
582 i.
WriteU8 (uint8_t (temp >> 8));
583 i.
WriteU8 (uint8_t (temp & 0xff));
592 uint8_t temp = i.
ReadU8 ();
634 : m_datagramSize (0),
646 .SetGroupName (
"SixLowPan")
672 i.
WriteU8 (uint8_t (temp >> 8));
673 i.
WriteU8 (uint8_t (temp & 0xff));
683 uint8_t temp = i.
ReadU8 ();
743 .SetGroupName (
"SixLowPan")
755 os <<
"Uncompressed IPv6";
806 .SetGroupName (
"SixLowPan")
818 os <<
"Compression kind: " <<
static_cast<int> (
m_baseFormat);
823 uint32_t serializedSize = 2;
843 if (
GetNh () ==
false )
856 serializedSize += 16;
869 if (
GetM () ==
false)
876 serializedSize += 16;
897 serializedSize += 16;
928 return serializedSize;
956 temp = (m_ecn << 6) | (m_flowLabel >> 16 );
971 if (
GetNh () ==
false )
994 i.
Write (temp + 8, 8);
998 i.
Write (temp + 14, 2);
1005 if (
GetM () ==
false)
1011 if (
GetDac () ==
false )
1019 i.
Write (temp + 8, 8);
1023 i.
Write (temp + 14, 2);
1036 if (
GetDac () ==
false )
1044 i.
Write (temp + 1, 2);
1045 i.
Write (temp + 12, 4);
1049 if (
GetDac () ==
false )
1052 i.
Write (temp + 1, 1);
1053 i.
Write (temp + 11, 5);
1057 if (
GetDac () ==
false )
1060 i.
Write (temp + 1, 1);
1061 i.
Write (temp + 13, 3);
1066 if (
GetDac () ==
false )
1119 if (
GetNh () ==
false )
1146 if (
GetSac () ==
false )
1153 memset (temp, 0x00,
sizeof (temp));
1154 i.
Read (temp + 8, 8);
1160 memset (temp, 0x00,
sizeof (temp));
1161 i.
Read (temp + 14, 2);
1177 if (
GetM () ==
false)
1183 if (
GetDac () ==
false )
1190 memset (temp, 0x00,
sizeof (temp));
1191 i.
Read (temp + 8, 8);
1197 memset (temp, 0x00,
sizeof (temp));
1198 i.
Read (temp + 14, 2);
1216 if (
GetDac () ==
false )
1223 memset (temp, 0x00,
sizeof (temp));
1224 i.
Read (temp + 1, 2);
1225 i.
Read (temp + 12, 4);
1231 if (
GetDac () ==
false )
1233 memset (temp, 0x00,
sizeof (temp));
1234 i.
Read (temp + 1, 1);
1235 i.
Read (temp + 11, 5);
1241 if (
GetDac () ==
false )
1243 memset (temp, 0x00,
sizeof (temp));
1244 i.
Read (temp + 1, 1);
1245 i.
Read (temp + 13, 3);
1252 if (
GetDac () ==
false )
1254 memset (temp, 0x00,
sizeof (temp));
1272 uint16_t field = tfField;
1283 uint16_t field = nhField;
1294 uint16_t field = hlimField;
1305 uint16_t field = cidField;
1316 uint16_t field = sacField;
1327 uint16_t field = samField;
1338 uint16_t field = mField;
1349 uint16_t field = dacField;
1360 uint16_t field = damField;
1371 NS_ASSERT_MSG (srcContextId < 16,
"Src Context ID too large");
1382 NS_ASSERT_MSG (dstContextId < 16,
"Dst Context ID too large");
1415 NS_ASSERT_MSG (flowLabel < 0x100000,
"Flow Label too large");
1466 NS_ABORT_MSG (
"Unsupported; Context destination is not implemented");
1472 NS_ABORT_MSG (
"Unsupported; Context destination is not implemented");
1497 static TypeId tid =
TypeId (
"ns3::SixLowPanNhcExtension")
1499 .SetGroupName (
"SixLowPan")
1516 uint32_t serializedSize = 2;
1517 if (
GetNh () ==
false )
1528 if (
GetNh () ==
false )
1540 if (
GetNh () ==
false )
1558 uint8_t field = extensionHeaderType;
1579 uint8_t field = nhField;
1626 static TypeId tid =
TypeId (
"ns3::SixLowPanUdpNhcExtension")
1628 .SetGroupName (
"SixLowPan")
1640 os <<
"Compression kind: " <<
static_cast<int> (
m_baseFormat);
1645 uint32_t serializedSize = 1;
1648 serializedSize += 2;
1653 serializedSize += 4;
1657 serializedSize += 3;
1660 serializedSize += 1;
1665 return serializedSize;
1752 uint16_t field = ports;
1783 uint16_t field = cField;
uint8_t GetEcn(void) const
Get the ECN.
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 value.
NhcDispatch_e
Dispatch values for Next Header compression.
uint8_t GetDstContextId(void) const
Get the DstContextId.
void SetTcflCompression(bool tcflCompression)
Set the Traffic Class and Flow Labels as compressed.
Ipv6Address m_dstAddress
Dst address.
TrafficClassFlowLabel_e
TF: Traffic Class, Flow Label.
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.
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 uncompressed header - see RFC 4944.
uint8_t GetDscp(void) const
Get the DSCP.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint16_t GetDstPort() const
Get the Destination Port.
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.
Hlim_e GetHlim(void) const
Get the HLIM (Hop Limit) 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.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
HeaderCompression_e GetSam(void) const
Get the SAM (Source Address Mode) compression.
LowPanHc1Addr_e m_srcCompression
Source compression type.
bool GetNh(void) const
Get the Next Header field value.
LOWPAN_NHC Extension Header Encoding - see RFC 6282.
void SetDatagramOffset(uint8_t datagramOffset)
Set the datagram offset.
void SetSam(HeaderCompression_e samField)
Set the SAM (Source Address Mode) compression.
6LoWPAN FRAGN header - see RFC 4944.
uint32_t GetFlowLabel(void) const
Get the Flow Label.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
static TypeId GetTypeId(void)
Get the type ID.
const uint8_t * GetSrcInterface() const
Get the source interface.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
void SetTrafficClass(uint8_t trafficClass)
Set the Traffic Class value.
iterator in a Buffer instance
uint8_t m_srcPrefix[8]
Source prefix.
uint16_t m_checksum
Checksum.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
static TypeId GetTypeId(void)
Get the type ID.
void SetHlim(Hlim_e hlimField)
Set the HLIM (Hop Limit) compression.
virtual void Print(std::ostream &os) const
uint16_t m_srcPort
Source port.
virtual void Print(std::ostream &os) const
uint8_t GetHopLimit(void) const
Get the "Hop limit" field (TTL).
uint8_t GetSrcContextId(void) const
Get the SrcContextId.
void SetBlob(const uint8_t *blob, uint32_t size)
Set the option header data blob.
HeaderCompression_e GetDam(void) const
Get the DAM (Destination Address Mode) compression.
void SetHc2HeaderPresent(bool hc2HeaderPresent)
Set the next header a HC2 compressed header.
void SetDscp(uint8_t dscp)
Set the DSCP (6bits).
uint16_t m_datagramTag
Datagram tag.
uint8_t m_hopLimit
Hop Limit.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
void SetDstInterface(const uint8_t *dstInterface)
Set the destination interface.
LowPanHc1Addr_e m_dstCompression
Destination compression type.
bool GetNh(void) const
Get the NH (Next Header) compression.
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
void WriteU16(uint16_t data)
void WriteHtonU16(uint16_t data)
uint16_t m_datagramSize
Datagram size.
void SetNh(bool nhField)
Set the NH (Next Header) compression.
virtual void Print(std::ostream &os) const
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
Ipv6Address GetSrcAddress() const
Get the Source Address.
uint8_t GetNextHeader(void) const
Get the Next Header field.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetDstPort(uint16_t port)
Set the Destination Port.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
uint32_t m_flowLabel
Flow Label.
uint8_t GetTrafficClass() const
Get the Traffic Class value.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
static TypeId GetTypeId(void)
Get the type ID.
bool IsHc2HeaderPresent() const
Check if there is a HC2 compressed header.
virtual void Print(std::ostream &os) const
virtual void Print(std::ostream &os) const
void SetSrcPort(uint16_t port)
Set the Source Port.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
uint16_t m_datagramTag
Datagram tag.
SixLowPanNhcExtension(void)
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
const uint8_t * GetDstPrefix() const
Get the destination prefix.
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
bool GetCid(void) const
Get the CID (Context Identifier Extension) compression.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
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 GetTf(void) const
Get the TF (Traffic Class, Flow Label) compression.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
bool IsTcflCompression() const
Check if the Traffic Class and Flow Labels are compressed.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint8_t m_trafficClass
Traffic Class.
uint16_t GetSrcPort() const
Get the Source Port.
void SetDstContextId(uint8_t dstContextId)
Set the DstContextId.
LowPanHc1Addr_e GetDstCompression() const
Get Destination Compression type.
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType(void) const
Get the NhcDispatch type.
void SetSrcAddress(Ipv6Address srcAddress)
Set the Source Address.
uint8_t GetDatagramOffset(void) const
Get the datagram offset.
LowPanHc1NextHeader_e m_nextHeaderCompression
Next header compression.
void Read(uint8_t *buffer, uint32_t size)
bool GetSac(void) const
Get the SAC (Source Address Compression) compression.
SixLowPanUdpNhcExtension(void)
uint16_t GetChecksum(void) const
Get the Checksum field value.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint16_t GetDatagramSize(void) const
Get the datagram size.
6LoWPAN HC1 header - see RFC 4944.
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
void SetDac(bool dacField)
Set the DAC (Destination Address Compression) compression.
uint8_t m_hopLimit
Hop Limit.
uint8_t m_nhcExtensionHeader
NHC extension header type.
void SetSrcInterface(const uint8_t *srcInterface)
Set the source interface.
void SetDstPrefix(const uint8_t *dstPrefix)
Set the destination prefix.
uint16_t GetDatagramTag(void) const
Get the datagram tag.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Describes an IPv6 address.
Ipv6Address m_srcAddress
Src address.
uint32_t GetFlowLabel() const
Get the Flow Label value.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label (20bits).
void WriteU8(uint8_t data)
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
uint8_t m_datagramOffset
Datagram offset.
bool m_tcflCompression
Is TC and FL compressed.
uint32_t m_flowLabel
Flow Label bits.
uint8_t GetHopLimit(void) const
Get the Hop Limit field.
uint8_t m_dstPrefix[8]
Destination prefix.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint16_t m_datagramSize
Datagram size.
uint8_t m_baseFormat
Dispatch + encoding fields.
uint8_t m_srcInterface[8]
Source interface.
LowPanHc1Addr_e GetSrcCompression() const
Get Source Compression type.
uint8_t m_nhcBlobLength
Length of the NHC compressed header.
virtual void Print(std::ostream &os) const
static NhcDispatch_e GetNhcDispatchType(uint8_t dispatch)
Get the NhcDispatch type.
uint16_t m_baseFormat
Dispatch + encoding fields.
Eid_e
EID: IPv6 Extension Header ID.
void SetEid(Eid_e extensionHeaderType)
Set the Extension Header Type.
Eid_e GetEid(void) const
Get the Extension Header Type.
void Write(uint8_t const *buffer, uint32_t size)
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
bool m_hc2HeaderPresent
Is next header HC2 compressed.
Ports_e GetPorts(void) const
Get the compressed Src and Dst Ports.
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.
uint16_t GetDatagramSize(void) const
Get the datagram size.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
Dispatch_e
Dispatch values, as defined in RFC 4944 and RFC 6282
LowPanHc1NextHeader_e
Next header information.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
HeaderCompression_e
Source or Destination Address Mode.
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.
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType(void) const
Get the NhcDispatch type.
void SetSrcPrefix(const uint8_t *srcPrefix)
Set the source prefix.
bool GetM(void) const
Get the M (Multicast) compression.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint16_t ReadNtohU16(void)
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Get the option header data blob.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
void SetEcn(uint8_t ecn)
Set the ECN (2bits).
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
bool GetC(void) const
Get the C (Checksum).
uint16_t GetDatagramTag(void) const
Get the datagram tag.
6LoWPAN FRAG1 header - see RFC 4944.
a unique identifier for an interface.
bool GetDac(void) const
Get the DAC (Destination Address Compression) compression.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
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).
const uint8_t * GetSrcPrefix() const
Get the source prefix.
uint8_t m_srcdstContextId
Src and Dst Context ID.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header value.
void SetDam(HeaderCompression_e damField)
Set the DAM (Destination Address Mode) compression.
LowPanHc1Addr_e
Kind of address compression.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label value.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
Ipv6Address GetDstAddress() const
Get the Destination Address.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
void PostProcessSac()
Post-process the Source address stateful compression.
const uint8_t * GetDstInterface() const
Get the destination interface.
uint8_t GetNextHeader() const
Get the Next Header value.
virtual void Print(std::ostream &os) const