13#include "ns3/assert.h"
14#include "ns3/ipv6-header.h"
16#include "ns3/mac16-address.h"
17#include "ns3/mac64-address.h"
97 .SetGroupName(
"SixLowPan")
122 os <<
"encoding " << +encoding <<
", hopLimit " << +
m_hopLimit;
133 serializedSize += 16;
145 serializedSize += 16;
165 return serializedSize;
189 for (
int j = 0; j < 8; j++)
193 for (
int j = 0; j < 8; j++)
199 for (
int j = 0; j < 8; j++)
205 for (
int j = 0; j < 8; j++)
216 for (
int j = 0; j < 8; j++)
220 for (
int j = 0; j < 8; j++)
226 for (
int j = 0; j < 8; j++)
232 for (
int j = 0; j < 8; j++)
265 uint8_t dispatch = i.
ReadU8();
271 uint8_t encoding = i.
ReadU8();
283 for (
int j = 0; j < 8; j++)
287 for (
int j = 0; j < 8; j++)
293 for (
int j = 0; j < 8; j++)
299 for (
int j = 0; j < 8; j++)
310 for (
int j = 0; j < 8; j++)
314 for (
int j = 0; j < 8; j++)
320 for (
int j = 0; j < 8; j++)
326 for (
int j = 0; j < 8; j++)
453 for (
int i = 0; i < 8; i++)
462 for (
int i = 0; i < 8; i++)
505 for (
int i = 0; i < 8; i++)
514 for (
int i = 0; i < 8; i++)
561 .SetGroupName(
"SixLowPan")
592 i.
WriteU8(uint8_t(temp & 0xff));
602 uint8_t temp = i.
ReadU8();
662 .SetGroupName(
"SixLowPan")
694 i.
WriteU8(uint8_t(temp & 0xff));
705 uint8_t temp = i.
ReadU8();
773 .SetGroupName(
"SixLowPan")
787 os <<
"Uncompressed IPv6";
845 .SetGroupName(
"SixLowPan")
868 os <<
"TF_FL_ELIDED(" << +
m_ecn <<
", " << +
m_dscp <<
")";
875 GetNh() ? os <<
" NH(1)" : os <<
" NH(0)";
883 os <<
" HLIM_COMPR_1(1)";
886 os <<
" HLIM_COMPR_64(64)";
889 os <<
" HLIM_COMPR_255(255)";
895 GetSac() ? os <<
" SAC(1)" : os <<
" SAC(0)";
896 os <<
" SAM (" <<
GetSam() <<
")";
898 GetM() ? os <<
" M(1)" : os <<
" M(0)";
899 GetDac() ? os <<
" DAC(1)" : os <<
" DAC(0)";
900 os <<
" DAM (" <<
GetDam() <<
")";
939 serializedSize += 16;
959 serializedSize += 16;
980 serializedSize += 16;
1009 return serializedSize;
1263 uint16_t field = tfField;
1276 uint16_t field = nhField;
1289 uint16_t field = hlimField;
1302 uint16_t field = cidField;
1315 uint16_t field = sacField;
1328 uint16_t field = samField;
1355 uint16_t field = mField;
1368 uint16_t field = dacField;
1381 uint16_t field = damField;
1408 NS_ASSERT_MSG(srcContextId < 16,
"Src Context ID too large");
1421 NS_ASSERT_MSG(dstContextId < 16,
"Dst Context ID too large");
1460 NS_ASSERT_MSG(flowLabel < 0x100000,
"Flow Label too large");
1517 static TypeId tid =
TypeId(
"ns3::SixLowPanNhcExtension")
1519 .SetGroupName(
"SixLowPan")
1584 uint8_t field = extensionHeaderType;
1609 uint8_t field = nhField;
1661 static TypeId tid =
TypeId(
"ns3::SixLowPanUdpNhcExtension")
1663 .SetGroupName(
"SixLowPan")
1686 serializedSize += 2;
1691 serializedSize += 4;
1695 serializedSize += 3;
1698 serializedSize += 1;
1703 return serializedSize;
1792 uint16_t field = ports;
1829 uint16_t field = cField;
1873 .SetGroupName(
"SixLowPan")
1908 uint8_t dispatch = i.
ReadU8();
1910 if (dispatch != 0x50)
1958 .SetGroupName(
"SixLowPan")
1972 os <<
"Hops left: " << +
m_hopsLeft <<
", src: ";
2004 serializedSize += 2;
2008 serializedSize += 8;
2013 serializedSize += 2;
2017 serializedSize += 8;
2020 return serializedSize;
2028 uint8_t dispatch = 0x80;
2078 uint8_t temp = i.
ReadU8();
2080 if ((temp & 0xC0) != 0x80)
2105 i.
Read(buffer, addrSize);
2116 i.
Read(buffer, addrSize);
2135 NS_ABORT_MSG(
"SixLowPanMesh::SetOriginator - incompatible address");
2160 NS_ABORT_MSG(
"SixLowPanMesh::SetFinalDst - incompatible address");
a polymophic address class
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 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)
static bool IsMatchingType(const Address &address)
static Mac16Address ConvertFrom(const Address &address)
static bool IsMatchingType(const Address &address)
static Mac64Address ConvertFrom(const Address &address)
6LoWPAN BC0 header - see RFC 4944 .
void Print(std::ostream &os) const override
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetSequenceNumber(uint8_t seqNumber)
Set the "Sequence Number" field.
static TypeId GetTypeId()
Get the type ID.
uint8_t m_seqNumber
Sequence number.
uint8_t GetSequenceNumber() const
Get the "Sequence Number" field.
static Dispatch_e GetDispatchType(uint8_t dispatch)
Get the Dispatch type.
Dispatch_e
Dispatch values, as defined in RFC 4944 and RFC 6282
static NhcDispatch_e GetNhcDispatchType(uint8_t dispatch)
Get the NhcDispatch type.
NhcDispatch_e
Dispatch values for Next Header compression.
6LoWPAN FRAG1 header - see RFC 4944 .
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
static TypeId GetTypeId()
Get the type ID.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
void Print(std::ostream &os) const override
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint16_t GetDatagramSize() const
Get the datagram size.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint16_t m_datagramTag
Datagram tag.
uint16_t GetDatagramTag() const
Get the datagram tag.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint16_t m_datagramSize
Datagram size.
6LoWPAN FRAGN header - see RFC 4944 .
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint16_t m_datagramTag
Datagram tag.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
static TypeId GetTypeId()
Get the type ID.
uint16_t GetDatagramTag() const
Get the datagram tag.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
void SetDatagramOffset(uint8_t datagramOffset)
Set the datagram offset.
uint8_t GetDatagramOffset() const
Get the datagram offset.
uint8_t m_datagramOffset
Datagram offset.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint16_t GetDatagramSize() const
Get the datagram size.
uint16_t m_datagramSize
Datagram size.
void Print(std::ostream &os) const override
6LoWPAN HC1 header - see RFC 4944 .
static TypeId GetTypeId()
Get the type ID.
void SetTcflCompression(bool tcflCompression)
Set the Traffic Class and Flow Labels as compressed.
uint8_t m_dstInterface[8]
Destination interface.
uint8_t GetHopLimit() const
Get the "Hop limit" field (TTL).
const uint8_t * GetSrcPrefix() const
Get the source prefix.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label value.
uint8_t GetTrafficClass() const
Get the Traffic Class value.
void SetDstCompression(LowPanHc1Addr_e dstCompression)
Set Destination Compression type.
void SetTrafficClass(uint8_t trafficClass)
Set the Traffic Class value.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
LowPanHc1Addr_e
Kind of address compression.
uint8_t m_srcInterface[8]
Source interface.
uint8_t m_dstPrefix[8]
Destination prefix.
uint32_t GetFlowLabel() const
Get the Flow Label value.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
bool m_hc2HeaderPresent
Is next header HC2 compressed.
const uint8_t * GetSrcInterface() const
Get the source interface.
const uint8_t * GetDstPrefix() const
Get the destination prefix.
void SetHc2HeaderPresent(bool hc2HeaderPresent)
Set the next header a HC2 compressed header.
LowPanHc1NextHeader_e m_nextHeaderCompression
Next header compression.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
bool m_tcflCompression
Is TC and FL compressed.
uint32_t m_flowLabel
Flow Label.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header value.
LowPanHc1Addr_e m_dstCompression
Destination compression type.
LowPanHc1NextHeader_e
Next header information.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint8_t m_hopLimit
Hop Limit.
void SetSrcCompression(LowPanHc1Addr_e srcCompression)
Set Source Compression type.
uint8_t m_srcPrefix[8]
Source prefix.
void SetDstInterface(const uint8_t *dstInterface)
Set the destination interface.
void SetDstPrefix(const uint8_t *dstPrefix)
Set the destination prefix.
const uint8_t * GetDstInterface() const
Get the destination interface.
LowPanHc1Addr_e m_srcCompression
Source compression type.
uint8_t m_nextHeader
Next header.
void Print(std::ostream &os) const override
void SetSrcPrefix(const uint8_t *srcPrefix)
Set the source prefix.
uint8_t GetNextHeader() const
Get the Next Header value.
void SetSrcInterface(const uint8_t *srcInterface)
Set the source interface.
uint8_t m_trafficClass
Traffic Class.
LowPanHc1Addr_e GetDstCompression() const
Get Destination Compression type.
bool IsHc2HeaderPresent() const
Check if there is a HC2 compressed header.
LowPanHc1Addr_e GetSrcCompression() const
Get Source Compression type.
bool IsTcflCompression() const
Check if the Traffic Class and Flow Labels are compressed.
LOWPAN_IPHC base Encoding - see RFC 6282 .
bool GetSac() const
Get the SAC (Source Address Compression) compression.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field.
uint8_t GetNextHeader() const
Get the Next Header field.
void SetHlim(Hlim_e hlimField)
Set the HLIM (Hop Limit) compression.
void SetDstContextId(uint8_t dstContextId)
Set the DstContextId.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
const uint8_t * GetSrcInlinePart() const
brief Get the source address inline part
uint8_t m_srcdstContextId
Src and Dst Context ID.
void SetSam(HeaderCompression_e samField)
Set the SAM (Source Address Mode) compression.
void SetNh(bool nhField)
Set the NH (Next Header) compression.
uint8_t GetDscp() const
Get the DSCP.
HeaderCompression_e
Source or Destination Address Mode.
HeaderCompression_e GetDam() const
Get the DAM (Destination Address Mode) compression.
uint8_t GetHopLimit() const
Get the Hop Limit field.
bool GetDac() const
Get the DAC (Destination Address Compression) compression.
uint8_t m_srcInlinePart[16]
source address inline part.
void SetEcn(uint8_t ecn)
Set the ECN (2bits).
uint8_t m_hopLimit
Hop Limit.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label (20bits).
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetDscp(uint8_t dscp)
Set the DSCP (6bits).
uint32_t GetFlowLabel() const
Get the Flow Label.
void SetTf(TrafficClassFlowLabel_e tfField)
Set the TF (Traffic Class, Flow Label) compression.
uint8_t GetEcn() const
Get the ECN.
static TypeId GetTypeId()
Get the type ID.
void SetDam(HeaderCompression_e damField)
Set the DAM (Destination Address Mode) compression.
void SetCid(bool cidField)
Set the CID (Context Identifier Extension) compression.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Hlim_e GetHlim() const
Get the HLIM (Hop Limit) compression.
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
bool GetNh() const
Get the NH (Next Header) compression.
void Print(std::ostream &os) const override
TrafficClassFlowLabel_e GetTf() const
Get the TF (Traffic Class, Flow Label) compression.
bool GetM() const
Get the M (Multicast) compression.
HeaderCompression_e GetSam() const
Get the SAM (Source Address Mode) compression.
uint8_t m_dstInlinePart[16]
destination address inline part.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
void SetDstInlinePart(uint8_t dstInlinePart[16], uint8_t size)
brief Set the destination address inline part
void SetSrcContextId(uint8_t srcContextId)
Set the SrcContextId.
void SetSrcInlinePart(uint8_t srcInlinePart[16], uint8_t size)
brief Set the source address inline part
TrafficClassFlowLabel_e
TF: Traffic Class, Flow Label.
void SetM(bool mField)
Set the M (Multicast) compression.
uint16_t m_baseFormat
Dispatch + encoding fields.
uint8_t m_nextHeader
Next header.
const uint8_t * GetDstInlinePart() const
brief Get the destination address inline part
bool GetCid() const
Get the CID (Context Identifier Extension) compression.
uint8_t GetSrcContextId() const
Get the SrcContextId.
uint32_t m_flowLabel
Flow Label bits.
void SetHopLimit(uint8_t hopLimit)
Set the Hop Limit field.
uint8_t GetDstContextId() const
Get the DstContextId.
void SetDac(bool dacField)
Set the DAC (Destination Address Compression) compression.
6LoWPAN IPv6 uncompressed header - see RFC 4944 .
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
static TypeId GetTypeId()
Get the type ID.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void Print(std::ostream &os) const override
6LoWPAN Mesh header - see RFC 4944 .
bool m_f
True if Destination address is 16 bit.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Address GetOriginator() const
Get the "Originator" address.
bool m_v
True if Originator address is 16 bit.
void SetHopsLeft(uint8_t hopsLeft)
Set the "Hops Left" field.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void SetFinalDst(Address finalDst)
Set the "Final Destination" address.
uint8_t m_hopsLeft
Hops left.
Address m_src
Originator (source) address.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint8_t GetHopsLeft() const
Get the "Hops Left" field.
static TypeId GetTypeId()
Get the type ID.
void Print(std::ostream &os) const override
Address GetFinalDst() const
Get the "Final Destination" address.
void SetOriginator(Address originator)
Set the "Originator" address.
Address m_dst
Destination (final) address.
LOWPAN_NHC Extension Header Encoding - see RFC 6282 .
uint8_t m_nhcNextHeader
Next header.
uint8_t m_nhcBlob[256]
NHC compressed header.
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType() const
Get the NhcDispatch type.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
bool GetNh() const
Get the Next Header field value.
uint8_t m_nhcExtensionHeader
NHC extension header type.
Eid_e GetEid() const
Get the Extension Header Type.
void SetNh(bool nhField)
Set the NH field values.
void SetEid(Eid_e extensionHeaderType)
Set the Extension Header Type.
uint8_t m_nhcBlobLength
Length of the NHC compressed header.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void SetBlob(const uint8_t *blob, uint32_t size)
Set the option header data blob.
void Print(std::ostream &os) const override
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Eid_e
EID: IPv6 Extension Header ID.
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Get the option header data blob.
uint8_t GetNextHeader() const
Get the Next Header field value.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field values.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
static TypeId GetTypeId()
Get the type ID.
UDP LOWPAN_NHC Extension Header Encoding - see RFC 6282 .
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
TypeId GetInstanceTypeId() const override
Return the instance type identifier.
uint8_t m_baseFormat
Dispatch + encoding fields.
SixLowPanUdpNhcExtension()
Ports_e GetPorts() const
Get the compressed Src and Dst Ports.
uint16_t GetChecksum() const
Get the Checksum field value.
uint16_t m_checksum
Checksum.
uint16_t GetDstPort() const
Get the Destination Port.
@ PORTS_LAST_SRC_LAST_DST
void SetPorts(Ports_e port)
Set the compressed Src and Dst Ports.
bool GetC() const
Get the C (Checksum).
static TypeId GetTypeId()
Get the type ID.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void Print(std::ostream &os) const override
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
void SetDstPort(uint16_t port)
Set the Destination Port.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetSrcPort(uint16_t port)
Set the Source Port.
void SetC(bool cField)
Set the C (Checksum).
uint16_t m_dstPort
Destination port.
uint16_t m_srcPort
Source port.
virtual SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType() const
Get the NhcDispatch type.
uint16_t GetSrcPort() const
Get the Source Port.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#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.
std::ostream & operator<<(std::ostream &os, const Angles &a)