GHC NHC Extension Header - see RFC 7400 Section 5. More...
#include "sixlowpan-ghc.h"
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. | |
| Related Symbols inherited from ns3::ObjectBase | |
| static TypeId | GetObjectIid () |
| Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
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.
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.
| 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().
Copy the GHC-compressed bytecode blob.
Definition at line 761 of file sixlowpan-ghc.cc.
References m_blob, and m_blobLength.
Referenced by SixlowpanGhcHeaderTest::DoRun().
|
overridevirtual |
| start | an iterator which points to where the header should read from. |
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().
| uint32_t ns3::SixLowPanGhcExtension::GetBlobLength | ( | ) | const |
Get the blob length.
Definition at line 769 of file sixlowpan-ghc.cc.
References m_blobLength.
Referenced by SixlowpanGhcHeaderTest::DoRun().
| SixLowPanGhcExtension::Eid_e ns3::SixLowPanGhcExtension::GetEid | ( | ) | const |
Get 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().
|
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().
Implements ns3::ObjectBase.
Definition at line 631 of file sixlowpan-ghc.cc.
References GetTypeId().
| uint8_t ns3::SixLowPanGhcExtension::GetNextHeader | ( | ) | const |
Get the Next Header field value.
Definition at line 728 of file sixlowpan-ghc.cc.
References m_nextHeader.
| bool ns3::SixLowPanGhcExtension::GetNh | ( | ) | const |
Get the NH field.
Definition at line 747 of file sixlowpan-ghc.cc.
References m_nhcByte, and NH_MASK.
Referenced by Deserialize(), SixlowpanGhcHeaderTest::DoRun(), GetSerializedSize(), Print(), and Serialize().
| SixLowPanDispatch::NhcDispatch_e ns3::SixLowPanGhcExtension::GetNhcDispatchType | ( | ) | const |
Get the NhcDispatch type.
Definition at line 704 of file sixlowpan-ghc.cc.
References ns3::SixLowPanDispatch::LOWPAN_GHC_EXT.
Referenced by SixlowpanGhcHeaderTest::DoRun().
|
overridevirtual |
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().
|
static |
Get the type ID.
Definition at line 621 of file sixlowpan-ghc.cc.
References SixLowPanGhcExtension(), and ns3::TypeId::SetParent().
Referenced by GetInstanceTypeId().
|
overridevirtual |
| os | output 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<<().
|
overridevirtual |
| start | an 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().
| void ns3::SixLowPanGhcExtension::SetBlob | ( | const uint8_t * | blob, |
| uint32_t | size ) |
Set the GHC-compressed bytecode blob.
| [in] | blob | Buffer holding compressed bytecodes. |
| [in] | size | Blob 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().
| void ns3::SixLowPanGhcExtension::SetEid | ( | Eid_e | eid | ) |
Set the Extension Header Type.
| [in] | eid | The 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().
| void ns3::SixLowPanGhcExtension::SetNextHeader | ( | uint8_t | nextHeader | ) |
Set the Next Header field value.
| [in] | nextHeader | The Next Header value. |
Definition at line 722 of file sixlowpan-ghc.cc.
References m_nextHeader.
Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcNhc().
| void ns3::SixLowPanGhcExtension::SetNh | ( | bool | nhField | ) |
Set the NH field (next header compressed flag).
| [in] | nhField | True 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().
|
staticconstexprprivate |
Mask for EID field extraction (bits 1-3).
Definition at line 360 of file sixlowpan-ghc.h.
Referenced by GetEid().
|
staticconstexprprivate |
Base NHC byte pattern for GHC extension: 10110000 = 0xB0.
Definition at line 355 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcExtension(), and SetEid().
|
private |
GHC compressed bytecodes.
Definition at line 350 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcExtension(), CopyBlob(), Deserialize(), Serialize(), and SetBlob().
|
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().
|
private |
Next Header value (if NH=0).
Definition at line 348 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcExtension(), Deserialize(), GetNextHeader(), Serialize(), and SetNextHeader().
|
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().
|
staticconstexpr |
Maximum blob size: the blob length field is 8 bits.
Definition at line 323 of file sixlowpan-ghc.h.
Referenced by SetBlob().
|
staticconstexprprivate |
Mask for NH flag extraction (bit 0).
Definition at line 365 of file sixlowpan-ghc.h.