A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::SixLowPanGhcExtension Class Reference

GHC NHC Extension Header - see RFC 7400 Section 5. More...

#include "sixlowpan-ghc.h"

Inheritance diagram for ns3::SixLowPanGhcExtension:
Collaboration diagram for ns3::SixLowPanGhcExtension:

Public Types

enum  Eid_e {
  EID_HOPBYHOP_OPTIONS_H = 0 , EID_ROUTING_H = 1 , EID_FRAGMENTATION_H = 2 , EID_DESTINATION_OPTIONS_H = 3 ,
  EID_MOBILITY_H = 4 , EID_IPv6_H = 7
}
 Extension Header ID (same encoding as RFC 6282). More...

Public Member Functions

 SixLowPanGhcExtension ()
uint32_t CopyBlob (uint8_t *blob, uint32_t size) const
 Copy the GHC-compressed bytecode blob.
uint32_t Deserialize (Buffer::Iterator start) override
uint32_t GetBlobLength () const
 Get the blob length.
Eid_e GetEid () const
 Get the Extension Header Type.
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
uint8_t GetNextHeader () const
 Get the Next Header field value.
bool GetNh () const
 Get the NH field.
SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType () const
 Get the NhcDispatch type.
uint32_t GetSerializedSize () const override
void Print (std::ostream &os) const override
void Serialize (Buffer::Iterator start) const override
void SetBlob (const uint8_t *blob, uint32_t size)
 Set the GHC-compressed bytecode blob.
void SetEid (Eid_e eid)
 Set the Extension Header Type.
void SetNextHeader (uint8_t nextHeader)
 Set the Next Header field value.
void SetNh (bool nhField)
 Set the NH field (next header compressed flag).
Public Member Functions inherited from ns3::Header
 ~Header () override
virtual uint32_t Deserialize (Buffer::Iterator start, Buffer::Iterator end)
 Deserialize the object from a buffer iterator.
Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
Static Public Member Functions inherited from ns3::Header
static TypeId GetTypeId ()
 Get the type ID.
Static Public Member Functions inherited from ns3::Chunk
static TypeId GetTypeId ()
 Get the type ID.
Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.

Static Public Attributes

static constexpr uint32_t MAX_BLOB_SIZE = 255
 Maximum blob size: the blob length field is 8 bits.

Private Attributes

uint8_t m_blob [MAX_BLOB_SIZE+1]
 GHC compressed bytecodes.
uint8_t m_blobLength
 Length of GHC compressed data.
uint8_t m_nextHeader
 Next Header value (if NH=0).
uint8_t m_nhcByte
 NHC header byte: 1011EID[NH].

Static Private Attributes

static constexpr uint8_t EID_MASK = 0x0E
 Mask for EID field extraction (bits 1-3).
static constexpr uint8_t GHC_EXT_BASE = 0xB0
 Base NHC byte pattern for GHC extension: 10110000 = 0xB0.
static constexpr uint8_t NH_MASK = 0x01
 Mask for NH flag extraction (bit 0).

Additional Inherited Members

Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.

Detailed Description

GHC NHC Extension Header - see RFC 7400 Section 5.

Replaces the RFC 6282 extension header NHC byte pattern (1110EID[NH]) with the GHC pattern (1011EID[NH]).

*     0   1   2   3   4   5   6   7
*   +---+---+---+---+---+---+---+---+
*   | 1 | 0 | 1 | 1 |    EID    |NH |
*   +---+---+---+---+---+---+---+---+
* 

The compressed payload following this header contains GHC bytecodes. Decompression terminates upon encountering the Stop Code (0x90). The Length field of the original extension header is elided.

Definition at line 248 of file sixlowpan-ghc.h.

Member Enumeration Documentation

◆ Eid_e

Extension Header ID (same encoding as RFC 6282).

Enumerator
EID_HOPBYHOP_OPTIONS_H 
EID_ROUTING_H 
EID_FRAGMENTATION_H 
EID_DESTINATION_OPTIONS_H 
EID_MOBILITY_H 
EID_IPv6_H 

Definition at line 254 of file sixlowpan-ghc.h.

Constructor & Destructor Documentation

◆ SixLowPanGhcExtension()

ns3::SixLowPanGhcExtension::SixLowPanGhcExtension ( )

Definition at line 612 of file sixlowpan-ghc.cc.

References GHC_EXT_BASE, m_blob, m_blobLength, m_nextHeader, and m_nhcByte.

Referenced by GetTypeId().

Here is the caller graph for this function:

Member Function Documentation

◆ CopyBlob()

uint32_t ns3::SixLowPanGhcExtension::CopyBlob ( uint8_t * blob,
uint32_t size ) const

Copy the GHC-compressed bytecode blob.

Parameters
[out]blobBuffer to copy blob into.
[in]sizeBuffer size.
Returns
Bytes copied.

Definition at line 761 of file sixlowpan-ghc.cc.

References m_blob, and m_blobLength.

Referenced by SixlowpanGhcHeaderTest::DoRun().

Here is the caller graph for this function:

◆ Deserialize()

uint32_t ns3::SixLowPanGhcExtension::Deserialize ( Buffer::Iterator start)
overridevirtual
Parameters
startan iterator which points to where the header should read from.
Returns
the number of bytes read.

This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet. The data read is expected to match bit-for-bit the representation of this header in real networks.

Note that data is not actually removed from the buffer to which the iterator points. Both Packet::RemoveHeader() and Packet::PeekHeader() call Deserialize(), but only the RemoveHeader() has additional statements to remove the header bytes from the underlying buffer and associated metadata.

Implements ns3::Header.

Definition at line 668 of file sixlowpan-ghc.cc.

References GetNh(), GetSerializedSize(), m_blob, m_blobLength, m_nextHeader, and m_nhcByte.

Referenced by SixlowpanGhcHeaderTest::DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlobLength()

uint32_t ns3::SixLowPanGhcExtension::GetBlobLength ( ) const

Get the blob length.

Returns
Length of the compressed bytecode blob.

Definition at line 769 of file sixlowpan-ghc.cc.

References m_blobLength.

Referenced by SixlowpanGhcHeaderTest::DoRun().

Here is the caller graph for this function:

◆ GetEid()

SixLowPanGhcExtension::Eid_e ns3::SixLowPanGhcExtension::GetEid ( ) const

Get the Extension Header Type.

Returns
The Extension Header Type.

Definition at line 716 of file sixlowpan-ghc.cc.

References EID_MASK, and m_nhcByte.

Referenced by SixlowpanGhcHeaderTest::DoRun(), and Print().

Here is the caller graph for this function:

◆ GetInstanceTypeId()

TypeId ns3::SixLowPanGhcExtension::GetInstanceTypeId ( ) const
overridevirtual

Get the most derived TypeId for this Object.

This method is provided by ns3::Object::GetInstanceTypeId but classes which derive from ns3::ObjectBase directly have to implement it themselves. Typically, this method should simply return the output of GetTypeId().

Returns
The TypeId associated to the most-derived type of this instance.

Implements ns3::ObjectBase.

Definition at line 631 of file sixlowpan-ghc.cc.

References GetTypeId().

Here is the call graph for this function:

◆ GetNextHeader()

uint8_t ns3::SixLowPanGhcExtension::GetNextHeader ( ) const

Get the Next Header field value.

Returns
The Next Header value.

Definition at line 728 of file sixlowpan-ghc.cc.

References m_nextHeader.

◆ GetNh()

bool ns3::SixLowPanGhcExtension::GetNh ( ) const

Get the NH field.

Returns
True if next header is compressed.

Definition at line 747 of file sixlowpan-ghc.cc.

References m_nhcByte, and NH_MASK.

Referenced by Deserialize(), SixlowpanGhcHeaderTest::DoRun(), GetSerializedSize(), Print(), and Serialize().

Here is the caller graph for this function:

◆ GetNhcDispatchType()

SixLowPanDispatch::NhcDispatch_e ns3::SixLowPanGhcExtension::GetNhcDispatchType ( ) const

Get the NhcDispatch type.

Returns
The NhcDispatch type (LOWPAN_GHC_EXT).

Definition at line 704 of file sixlowpan-ghc.cc.

References ns3::SixLowPanDispatch::LOWPAN_GHC_EXT.

Referenced by SixlowpanGhcHeaderTest::DoRun().

Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::SixLowPanGhcExtension::GetSerializedSize ( ) const
overridevirtual
Returns
the expected size of the header.

This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. This method should return the number of bytes which are needed to store the full header data by Serialize.

Implements ns3::Header.

Definition at line 644 of file sixlowpan-ghc.cc.

References GetNh(), and m_blobLength.

Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcNhc(), Deserialize(), and SixlowpanGhcHeaderTest::DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::SixLowPanGhcExtension::GetTypeId ( )
static

Get the type ID.

Returns
The object TypeId.

Definition at line 621 of file sixlowpan-ghc.cc.

References SixLowPanGhcExtension(), and ns3::TypeId::SetParent().

Referenced by GetInstanceTypeId().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Print()

void ns3::SixLowPanGhcExtension::Print ( std::ostream & os) const
overridevirtual
Parameters
osoutput stream This method is used by Packet::Print to print the content of a header as ascii data to a c++ output stream. Although the header is free to format its output as it wishes, it is recommended to follow a few rules to integrate with the packet pretty printer: start with flags, small field values located between a pair of parens. Values should be separated by whitespace. Follow the parens with the important fields, separated by whitespace. i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5

Implements ns3::Header.

Definition at line 637 of file sixlowpan-ghc.cc.

References GetEid(), GetNh(), and m_blobLength.

Referenced by ns3::operator<<().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Serialize()

void ns3::SixLowPanGhcExtension::Serialize ( Buffer::Iterator start) const
overridevirtual
Parameters
startan iterator which points to where the header should be written.

This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. The data written is expected to match bit-for-bit the representation of this header in a real network.

Implements ns3::Header.

Definition at line 657 of file sixlowpan-ghc.cc.

References GetNh(), m_blob, m_blobLength, m_nextHeader, and m_nhcByte.

Referenced by SixlowpanGhcHeaderTest::DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBlob()

void ns3::SixLowPanGhcExtension::SetBlob ( const uint8_t * blob,
uint32_t size )

Set the GHC-compressed bytecode blob.

Parameters
[in]blobBuffer holding compressed bytecodes.
[in]sizeBlob length.

Definition at line 753 of file sixlowpan-ghc.cc.

References m_blob, m_blobLength, MAX_BLOB_SIZE, and NS_ASSERT.

Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcNhc(), and SixlowpanGhcHeaderTest::DoRun().

Here is the caller graph for this function:

◆ SetEid()

void ns3::SixLowPanGhcExtension::SetEid ( Eid_e eid)

Set the Extension Header Type.

Parameters
[in]eidThe Extension Header Type.

Definition at line 710 of file sixlowpan-ghc.cc.

References GHC_EXT_BASE, m_nhcByte, and NH_MASK.

Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcNhc(), and SixlowpanGhcHeaderTest::DoRun().

Here is the caller graph for this function:

◆ SetNextHeader()

void ns3::SixLowPanGhcExtension::SetNextHeader ( uint8_t nextHeader)

Set the Next Header field value.

Parameters
[in]nextHeaderThe Next Header value.

Definition at line 722 of file sixlowpan-ghc.cc.

References m_nextHeader.

Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcNhc().

Here is the caller graph for this function:

◆ SetNh()

void ns3::SixLowPanGhcExtension::SetNh ( bool nhField)

Set the NH field (next header compressed flag).

Parameters
[in]nhFieldTrue if next header is compressed via NHC/GHC.

Definition at line 734 of file sixlowpan-ghc.cc.

References m_nhcByte, and NH_MASK.

Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcNhc(), and SixlowpanGhcHeaderTest::DoRun().

Here is the caller graph for this function:

Member Data Documentation

◆ EID_MASK

uint8_t ns3::SixLowPanGhcExtension::EID_MASK = 0x0E
staticconstexprprivate

Mask for EID field extraction (bits 1-3).

Definition at line 360 of file sixlowpan-ghc.h.

Referenced by GetEid().

◆ GHC_EXT_BASE

uint8_t ns3::SixLowPanGhcExtension::GHC_EXT_BASE = 0xB0
staticconstexprprivate

Base NHC byte pattern for GHC extension: 10110000 = 0xB0.

Definition at line 355 of file sixlowpan-ghc.h.

Referenced by SixLowPanGhcExtension(), and SetEid().

◆ m_blob

uint8_t ns3::SixLowPanGhcExtension::m_blob[MAX_BLOB_SIZE+1]
private

GHC compressed bytecodes.

Definition at line 350 of file sixlowpan-ghc.h.

Referenced by SixLowPanGhcExtension(), CopyBlob(), Deserialize(), Serialize(), and SetBlob().

◆ m_blobLength

uint8_t ns3::SixLowPanGhcExtension::m_blobLength
private

Length of GHC compressed data.

Definition at line 349 of file sixlowpan-ghc.h.

Referenced by SixLowPanGhcExtension(), CopyBlob(), Deserialize(), GetBlobLength(), GetSerializedSize(), Print(), Serialize(), and SetBlob().

◆ m_nextHeader

uint8_t ns3::SixLowPanGhcExtension::m_nextHeader
private

Next Header value (if NH=0).

Definition at line 348 of file sixlowpan-ghc.h.

Referenced by SixLowPanGhcExtension(), Deserialize(), GetNextHeader(), Serialize(), and SetNextHeader().

◆ m_nhcByte

uint8_t ns3::SixLowPanGhcExtension::m_nhcByte
private

NHC header byte: 1011EID[NH].

Definition at line 347 of file sixlowpan-ghc.h.

Referenced by SixLowPanGhcExtension(), Deserialize(), GetEid(), GetNh(), Serialize(), SetEid(), and SetNh().

◆ MAX_BLOB_SIZE

uint32_t ns3::SixLowPanGhcExtension::MAX_BLOB_SIZE = 255
staticconstexpr

Maximum blob size: the blob length field is 8 bits.

Definition at line 323 of file sixlowpan-ghc.h.

Referenced by SetBlob().

◆ NH_MASK

uint8_t ns3::SixLowPanGhcExtension::NH_MASK = 0x01
staticconstexprprivate

Mask for NH flag extraction (bit 0).

Definition at line 365 of file sixlowpan-ghc.h.

Referenced by GetNh(), SetEid(), and SetNh().


The documentation for this class was generated from the following files: