22 #include "ns3/assert.h" 24 #include "ns3/abort.h" 25 #include "ns3/ipv6-header.h" 26 #include "ns3/mac64-address.h" 27 #include "ns3/mac16-address.h" 28 #include "ns3/ipv6-header.h" 111 .SetGroupName (
"SixLowPan")
134 os <<
"encoding " << +encoding <<
", hopLimit " << +
m_hopLimit;
139 uint32_t serializedSize = 3;
144 serializedSize += 16;
158 serializedSize += 16;
180 return serializedSize;
203 for (
int j = 0; j < 8; j++ )
207 for (
int j = 0; j < 8; j++ )
213 for (
int j = 0; j < 8; j++ )
219 for (
int j = 0; j < 8; j++ )
230 for (
int j = 0; j < 8; j++ )
234 for (
int j = 0; j < 8; j++ )
240 for (
int j = 0; j < 8; j++ )
246 for (
int j = 0; j < 8; j++ )
277 uint32_t serializedSize = 3;
279 uint8_t dispatch = i.
ReadU8 ();
285 uint8_t encoding = i.
ReadU8 ();
297 for (
int j = 0; j < 8; j++)
301 for (
int j = 0; j < 8; j++)
305 serializedSize += 16;
308 for (
int j = 0; j < 8; j++)
315 for (
int j = 0; j < 8; j++)
327 for (
int j = 0; j < 8; j++)
331 for (
int j = 0; j < 8; j++)
335 serializedSize += 16;
338 for (
int j = 0; j < 8; j++)
345 for (
int j = 0; j < 8; j++)
460 for (
int i = 0; i < 8; i++)
468 for (
int i = 0; i < 8; i++)
507 for (
int i = 0; i < 8; i++)
515 for (
int i = 0; i < 8; i++)
550 : m_datagramSize (0),
559 .SetGroupName (
"SixLowPan")
585 i.
WriteU8 (uint8_t (temp >> 8));
586 i.
WriteU8 (uint8_t (temp & 0xff));
595 uint8_t temp = i.
ReadU8 ();
637 : m_datagramSize (0),
649 .SetGroupName (
"SixLowPan")
675 i.
WriteU8 (uint8_t (temp >> 8));
676 i.
WriteU8 (uint8_t (temp & 0xff));
686 uint8_t temp = i.
ReadU8 ();
746 .SetGroupName (
"SixLowPan")
758 os <<
"Uncompressed IPv6";
809 .SetGroupName (
"SixLowPan")
826 uint32_t serializedSize = 2;
846 if (
GetNh () ==
false )
859 serializedSize += 16;
872 if (
GetM () ==
false)
879 serializedSize += 16;
900 serializedSize += 16;
931 return serializedSize;
959 temp = (m_ecn << 6) | (m_flowLabel >> 16 );
974 if (
GetNh () ==
false )
997 i.
Write (temp + 8, 8);
1001 i.
Write (temp + 14, 2);
1008 if (
GetM () ==
false)
1014 if (
GetDac () ==
false )
1022 i.
Write (temp + 8, 8);
1026 i.
Write (temp + 14, 2);
1039 if (
GetDac () ==
false )
1047 i.
Write (temp + 1, 2);
1048 i.
Write (temp + 12, 4);
1052 if (
GetDac () ==
false )
1055 i.
Write (temp + 1, 1);
1056 i.
Write (temp + 11, 5);
1060 if (
GetDac () ==
false )
1063 i.
Write (temp + 1, 1);
1064 i.
Write (temp + 13, 3);
1069 if (
GetDac () ==
false )
1122 if (
GetNh () ==
false )
1149 if (
GetSac () ==
false )
1156 memset (temp, 0x00,
sizeof (temp));
1157 i.
Read (temp + 8, 8);
1163 memset (temp, 0x00,
sizeof (temp));
1164 i.
Read (temp + 14, 2);
1180 if (
GetM () ==
false)
1186 if (
GetDac () ==
false )
1193 memset (temp, 0x00,
sizeof (temp));
1194 i.
Read (temp + 8, 8);
1200 memset (temp, 0x00,
sizeof (temp));
1201 i.
Read (temp + 14, 2);
1219 if (
GetDac () ==
false )
1226 memset (temp, 0x00,
sizeof (temp));
1227 i.
Read (temp + 1, 2);
1228 i.
Read (temp + 12, 4);
1234 if (
GetDac () ==
false )
1236 memset (temp, 0x00,
sizeof (temp));
1237 i.
Read (temp + 1, 1);
1238 i.
Read (temp + 11, 5);
1244 if (
GetDac () ==
false )
1246 memset (temp, 0x00,
sizeof (temp));
1247 i.
Read (temp + 1, 1);
1248 i.
Read (temp + 13, 3);
1255 if (
GetDac () ==
false )
1257 memset (temp, 0x00,
sizeof (temp));
1275 uint16_t field = tfField;
1286 uint16_t field = nhField;
1297 uint16_t field = hlimField;
1308 uint16_t field = cidField;
1319 uint16_t field = sacField;
1330 uint16_t field = samField;
1341 uint16_t field = mField;
1352 uint16_t field = dacField;
1363 uint16_t field = damField;
1374 NS_ASSERT_MSG (srcContextId < 16,
"Src Context ID too large");
1385 NS_ASSERT_MSG (dstContextId < 16,
"Dst Context ID too large");
1418 NS_ASSERT_MSG (flowLabel < 0x100000,
"Flow Label too large");
1469 NS_ABORT_MSG (
"Unsupported; Context destination is not implemented");
1475 NS_ABORT_MSG (
"Unsupported; Context destination is not implemented");
1500 static TypeId tid =
TypeId (
"ns3::SixLowPanNhcExtension")
1502 .SetGroupName (
"SixLowPan")
1519 uint32_t serializedSize = 2;
1520 if (
GetNh () ==
false )
1531 if (
GetNh () ==
false )
1543 if (
GetNh () ==
false )
1561 uint8_t field = extensionHeaderType;
1582 uint8_t field = nhField;
1629 static TypeId tid =
TypeId (
"ns3::SixLowPanUdpNhcExtension")
1631 .SetGroupName (
"SixLowPan")
1648 uint32_t serializedSize = 1;
1651 serializedSize += 2;
1656 serializedSize += 4;
1660 serializedSize += 3;
1663 serializedSize += 1;
1668 return serializedSize;
1755 uint16_t field = ports;
1786 uint16_t field = cField;
1825 .SetGroupName (
"SixLowPan")
1856 uint8_t dispatch = i.
ReadU8 ();
1858 if (dispatch != 0x50)
1902 .SetGroupName (
"SixLowPan")
1914 os <<
"Hops left: " << +
m_hopsLeft <<
", src: ";
1936 uint32_t serializedSize = 1;
1945 serializedSize += 2;
1949 serializedSize += 8;
1954 serializedSize += 2;
1958 serializedSize += 8;
1961 return serializedSize;
1968 uint8_t dispatch = 0x80;
1996 i.
Write (buffer, 2);
2000 i.
Write (buffer, 8);
2006 i.
Write (buffer, 2);
2010 i.
Write (buffer, 8);
2017 uint8_t temp = i.
ReadU8 ();
2019 if ((temp & 0xC0) != 0x80)
2044 i.
Read (buffer, addrSize);
2055 i.
Read (buffer, addrSize);
2073 NS_ABORT_MSG (
"SixLowPanMesh::SetOriginator - incompatible address");
2096 NS_ABORT_MSG (
"SixLowPanMesh::SetFinalDst - incompatible address");
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.
Address GetOriginator(void) const
Get the "Originator" address.
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.
static TypeId GetTypeId(void)
Get the type ID.
uint8_t GetHopsLeft(void) const
Get the "Hops Left" field.
6LoWPAN IPv6 uncompressed header - see RFC 4944.
uint8_t GetDscp(void) const
Get the DSCP.
uint16_t GetDstPort() const
Get the Destination Port.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field values.
bool m_f
True if Destination address is 16 bit.
uint8_t GetSequenceNumber(void) const
Get the "Sequence Number" field.
static Mac16Address ConvertFrom(const Address &address)
virtual void Print(std::ostream &os) const
static bool IsMatchingType(const Address &address)
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.
uint8_t m_seqNumber
Sequence number.
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
a polymophic address class
uint8_t m_srcPrefix[8]
Source prefix.
uint16_t m_checksum
Checksum.
void SetSequenceNumber(uint8_t seqNumber)
Set the "Sequence Number" field.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
void SetHopsLeft(uint8_t hopsLeft)
Set the "Hops Left" field.
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.
Address GetFinalDst(void) const
Get the "Final Destination" address.
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.
Address m_src
Originator (source) address.
void SetDstInterface(const uint8_t *dstInterface)
Set the destination interface.
LowPanHc1Addr_e m_dstCompression
Destination compression type.
Address m_dst
Destination (final) address.
bool GetNh(void) const
Get the NH (Next Header) compression.
void SetOriginator(Address originator)
Set the "Originator" address.
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
void WriteU16(uint16_t data)
void WriteHtonU16(uint16_t data)
6LoWPAN BC0 header - see RFC 4944.
uint16_t m_datagramSize
Datagram size.
void SetNh(bool nhField)
Set the NH (Next Header) compression.
virtual void Print(std::ostream &os) const
uint8_t m_hopsLeft
Hops left.
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
static TypeId GetTypeId(void)
Get the type ID.
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.
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.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
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.
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
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.
virtual void Print(std::ostream &os) const
uint16_t GetSrcPort() const
Get the Source Port.
void SetDstContextId(uint8_t dstContextId)
Set the DstContextId.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
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.
#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.
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)
void SetFinalDst(Address finalDst)
Set the "Final Destination" address.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
static Mac64Address ConvertFrom(const Address &address)
uint8_t m_datagramOffset
Datagram offset.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
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.
virtual TypeId GetInstanceTypeId(void) const
Return the instance type identifier.
6LoWPAN Mesh header - see RFC 4944.
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 void Serialize(Buffer::Iterator start) const
Serialize the packet.
static bool IsMatchingType(const Address &address)
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.
bool m_v
True if Originator address is 16 bit.
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.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
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