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

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

#include "sixlowpan-ghc.h"

Inheritance diagram for ns3::SixLowPanGhcUdp:
Collaboration diagram for ns3::SixLowPanGhcUdp:

Public Types

enum  Ports_e { PORTS_INLINE = 0 , PORTS_ALL_SRC_LAST_DST = 1 , PORTS_LAST_SRC_ALL_DST = 2 , PORTS_LAST_SRC_LAST_DST = 3 }
 Port compression modes (same as RFC 6282 UDP NHC). More...

Public Member Functions

 SixLowPanGhcUdp ()
uint32_t Deserialize (Buffer::Iterator start) override
bool GetC () const
 Get the checksum elision flag (C bit).
uint16_t GetChecksum () const
 Get the UDP checksum.
uint16_t GetDstPort () const
 Get the destination port.
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
SixLowPanDispatch::NhcDispatch_e GetNhcDispatchType () const
 Get the NhcDispatch type.
Ports_e GetPorts () const
 Get the port compression mode.
uint32_t GetSerializedSize () const override
uint16_t GetSrcPort () const
 Get the source port.
void Print (std::ostream &os) const override
void Serialize (Buffer::Iterator start) const override
void SetC (bool cField)
 Set the checksum elision flag (C bit).
void SetChecksum (uint16_t checksum)
 Set the UDP checksum.
void SetDstPort (uint16_t port)
 Set the destination port.
void SetPorts (Ports_e port)
 Set the port compression mode.
void SetSrcPort (uint16_t port)
 Set the source port.
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.

Private Attributes

uint8_t m_baseFormat
 NHC byte: 11010CPP.
uint16_t m_checksum
 UDP checksum.
uint16_t m_dstPort
 Destination port.
uint16_t m_srcPort
 Source port.

Static Private Attributes

static constexpr uint8_t C_MASK = 0x04
 Checksum flag mask.
static constexpr uint8_t GHC_UDP_BASE = 0xD0
 11010000
static constexpr uint8_t P_MASK = 0x03
 Port compression mask.

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 UDP NHC Header - see RFC 7400 Section 5.

Replaces the RFC 6282 UDP NHC byte pattern (11110CPP) with the GHC pattern (11010CPP). Port compression uses the same encoding as RFC 6282. GHC bytecodes compress the UDP payload following the header.

*     0   1   2   3   4   5   6   7
*   +---+---+---+---+---+---+---+---+
*   | 1 | 1 | 0 | 1 | 0 | C |   P   |
*   +---+---+---+---+---+---+---+---+
* 

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

Member Enumeration Documentation

◆ Ports_e

Port compression modes (same as RFC 6282 UDP NHC).

Enumerator
PORTS_INLINE 
PORTS_ALL_SRC_LAST_DST 
PORTS_LAST_SRC_ALL_DST 
PORTS_LAST_SRC_LAST_DST 

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

Constructor & Destructor Documentation

◆ SixLowPanGhcUdp()

ns3::SixLowPanGhcUdp::SixLowPanGhcUdp ( )

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

References GHC_UDP_BASE, m_baseFormat, m_checksum, m_dstPort, and m_srcPort.

Referenced by GetTypeId().

Here is the caller graph for this function:

Member Function Documentation

◆ Deserialize()

uint32_t ns3::SixLowPanGhcUdp::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 876 of file sixlowpan-ghc.cc.

References GetC(), GetPorts(), GetSerializedSize(), m_baseFormat, m_checksum, m_dstPort, m_srcPort, PORTS_ALL_SRC_LAST_DST, PORTS_INLINE, PORTS_LAST_SRC_ALL_DST, and PORTS_LAST_SRC_LAST_DST.

Referenced by SixlowpanGhcHeaderTest::DoRun().

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

◆ GetC()

bool ns3::SixLowPanGhcUdp::GetC ( ) const

Get the checksum elision flag (C bit).

Returns
True if checksum is elided.

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

References C_MASK, and m_baseFormat.

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

Here is the caller graph for this function:

◆ GetChecksum()

uint16_t ns3::SixLowPanGhcUdp::GetChecksum ( ) const

Get the UDP checksum.

Returns
The UDP checksum value.

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

References m_checksum.

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

Here is the caller graph for this function:

◆ GetDstPort()

uint16_t ns3::SixLowPanGhcUdp::GetDstPort ( ) const

Get the destination port.

Returns
The destination port.

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

References m_dstPort.

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

Here is the caller graph for this function:

◆ GetInstanceTypeId()

TypeId ns3::SixLowPanGhcUdp::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 806 of file sixlowpan-ghc.cc.

References GetTypeId().

Here is the call graph for this function:

◆ GetNhcDispatchType()

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

Get the NhcDispatch type.

Returns
The NhcDispatch type (LOWPAN_GHC_UDP).

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

References ns3::SixLowPanDispatch::LOWPAN_GHC_UDP.

Referenced by SixlowpanGhcHeaderTest::DoRun().

Here is the caller graph for this function:

◆ GetPorts()

SixLowPanGhcUdp::Ports_e ns3::SixLowPanGhcUdp::GetPorts ( ) const

Get the port compression mode.

Returns
The port compression mode.

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

References m_baseFormat, and P_MASK.

Referenced by Deserialize(), GetSerializedSize(), Print(), and Serialize().

Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::SixLowPanGhcUdp::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 819 of file sixlowpan-ghc.cc.

References GetC(), GetPorts(), PORTS_ALL_SRC_LAST_DST, PORTS_INLINE, PORTS_LAST_SRC_ALL_DST, and PORTS_LAST_SRC_LAST_DST.

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

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

◆ GetSrcPort()

uint16_t ns3::SixLowPanGhcUdp::GetSrcPort ( ) const

Get the source port.

Returns
The source port.

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

References m_srcPort.

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

Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::SixLowPanGhcUdp::GetTypeId ( )
static

Get the type ID.

Returns
The object TypeId.

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

References SixLowPanGhcUdp(), 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::SixLowPanGhcUdp::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 812 of file sixlowpan-ghc.cc.

References GetC(), GetPorts(), m_dstPort, and m_srcPort.

Referenced by ns3::operator<<().

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

◆ Serialize()

void ns3::SixLowPanGhcUdp::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 846 of file sixlowpan-ghc.cc.

References GetC(), GetPorts(), m_baseFormat, m_checksum, m_dstPort, m_srcPort, PORTS_ALL_SRC_LAST_DST, PORTS_INLINE, PORTS_LAST_SRC_ALL_DST, and PORTS_LAST_SRC_LAST_DST.

Referenced by SixlowpanGhcHeaderTest::DoRun().

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

◆ SetC()

void ns3::SixLowPanGhcUdp::SetC ( bool cField)

Set the checksum elision flag (C bit).

Parameters
[in]cFieldTrue if checksum is elided.

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

References C_MASK, and m_baseFormat.

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

Here is the caller graph for this function:

◆ SetChecksum()

void ns3::SixLowPanGhcUdp::SetChecksum ( uint16_t checksum)

Set the UDP checksum.

Parameters
[in]checksumThe UDP checksum value.

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

References m_checksum.

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

Here is the caller graph for this function:

◆ SetDstPort()

void ns3::SixLowPanGhcUdp::SetDstPort ( uint16_t port)

Set the destination port.

Parameters
[in]portThe destination port.

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

References m_dstPort, and port.

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

Here is the caller graph for this function:

◆ SetPorts()

void ns3::SixLowPanGhcUdp::SetPorts ( Ports_e port)

Set the port compression mode.

Parameters
[in]portThe port compression mode.

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

References C_MASK, GHC_UDP_BASE, m_baseFormat, P_MASK, and port.

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

Here is the caller graph for this function:

◆ SetSrcPort()

void ns3::SixLowPanGhcUdp::SetSrcPort ( uint16_t port)

Set the source port.

Parameters
[in]portThe source port.

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

References m_srcPort, and port.

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

Here is the caller graph for this function:

Member Data Documentation

◆ C_MASK

uint8_t ns3::SixLowPanGhcUdp::C_MASK = 0x04
staticconstexprprivate

Checksum flag mask.

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

Referenced by GetC(), SetC(), and SetPorts().

◆ GHC_UDP_BASE

uint8_t ns3::SixLowPanGhcUdp::GHC_UDP_BASE = 0xD0
staticconstexprprivate

11010000

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

Referenced by SixLowPanGhcUdp(), and SetPorts().

◆ m_baseFormat

uint8_t ns3::SixLowPanGhcUdp::m_baseFormat
private

NHC byte: 11010CPP.

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

Referenced by SixLowPanGhcUdp(), Deserialize(), GetC(), GetPorts(), Serialize(), SetC(), and SetPorts().

◆ m_checksum

uint16_t ns3::SixLowPanGhcUdp::m_checksum
private

UDP checksum.

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

Referenced by SixLowPanGhcUdp(), Deserialize(), GetChecksum(), Serialize(), and SetChecksum().

◆ m_dstPort

uint16_t ns3::SixLowPanGhcUdp::m_dstPort
private

Destination port.

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

Referenced by SixLowPanGhcUdp(), Deserialize(), GetDstPort(), Print(), Serialize(), and SetDstPort().

◆ m_srcPort

uint16_t ns3::SixLowPanGhcUdp::m_srcPort
private

Source port.

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

Referenced by SixLowPanGhcUdp(), Deserialize(), GetSrcPort(), Print(), Serialize(), and SetSrcPort().

◆ P_MASK

uint8_t ns3::SixLowPanGhcUdp::P_MASK = 0x03
staticconstexprprivate

Port compression mask.

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

Referenced by GetPorts(), and SetPorts().


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