GHC UDP NHC Header - see RFC 7400 Section 5. More...
#include "sixlowpan-ghc.h"
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. | |
| Related Symbols inherited from ns3::ObjectBase | |
| static TypeId | GetObjectIid () |
| Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
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.
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.
| 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().
|
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 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().
| bool ns3::SixLowPanGhcUdp::GetC | ( | ) | const |
Get the checksum elision flag (C bit).
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().
| uint16_t ns3::SixLowPanGhcUdp::GetChecksum | ( | ) | const |
Get the UDP checksum.
Definition at line 978 of file sixlowpan-ghc.cc.
References m_checksum.
Referenced by ns3::SixLowPanNetDevice::DecompressLowPanGhcUdp(), and SixlowpanGhcHeaderTest::DoRun().
| uint16_t ns3::SixLowPanGhcUdp::GetDstPort | ( | ) | const |
Get the destination port.
Definition at line 947 of file sixlowpan-ghc.cc.
References m_dstPort.
Referenced by ns3::SixLowPanNetDevice::DecompressLowPanGhcUdp(), and SixlowpanGhcHeaderTest::DoRun().
|
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 806 of file sixlowpan-ghc.cc.
References GetTypeId().
| SixLowPanDispatch::NhcDispatch_e ns3::SixLowPanGhcUdp::GetNhcDispatchType | ( | ) | const |
Get the NhcDispatch type.
Definition at line 911 of file sixlowpan-ghc.cc.
References ns3::SixLowPanDispatch::LOWPAN_GHC_UDP.
Referenced by SixlowpanGhcHeaderTest::DoRun().
| SixLowPanGhcUdp::Ports_e ns3::SixLowPanGhcUdp::GetPorts | ( | ) | const |
Get 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().
|
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 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().
| uint16_t ns3::SixLowPanGhcUdp::GetSrcPort | ( | ) | const |
Get the source port.
Definition at line 935 of file sixlowpan-ghc.cc.
References m_srcPort.
Referenced by ns3::SixLowPanNetDevice::DecompressLowPanGhcUdp(), and SixlowpanGhcHeaderTest::DoRun().
|
static |
Get the type ID.
Definition at line 796 of file sixlowpan-ghc.cc.
References SixLowPanGhcUdp(), 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 812 of file sixlowpan-ghc.cc.
References GetC(), GetPorts(), m_dstPort, and m_srcPort.
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 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().
| void ns3::SixLowPanGhcUdp::SetC | ( | bool | cField | ) |
Set the checksum elision flag (C bit).
| [in] | cField | True 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().
| void ns3::SixLowPanGhcUdp::SetChecksum | ( | uint16_t | checksum | ) |
Set the UDP checksum.
| [in] | checksum | The UDP checksum value. |
Definition at line 972 of file sixlowpan-ghc.cc.
References m_checksum.
Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcUdp(), and SixlowpanGhcHeaderTest::DoRun().
| void ns3::SixLowPanGhcUdp::SetDstPort | ( | uint16_t | port | ) |
Set the destination port.
| [in] | port | The destination port. |
Definition at line 941 of file sixlowpan-ghc.cc.
References m_dstPort, and port.
Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcUdp(), and SixlowpanGhcHeaderTest::DoRun().
| void ns3::SixLowPanGhcUdp::SetPorts | ( | Ports_e | port | ) |
Set the port compression mode.
| [in] | port | The 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().
| void ns3::SixLowPanGhcUdp::SetSrcPort | ( | uint16_t | port | ) |
Set the source port.
| [in] | port | The source port. |
Definition at line 929 of file sixlowpan-ghc.cc.
References m_srcPort, and port.
Referenced by ns3::SixLowPanNetDevice::CompressLowPanGhcUdp(), and SixlowpanGhcHeaderTest::DoRun().
|
staticconstexprprivate |
Checksum flag mask.
Definition at line 495 of file sixlowpan-ghc.h.
Referenced by GetC(), SetC(), and SetPorts().
|
staticconstexprprivate |
11010000
Definition at line 494 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcUdp(), and SetPorts().
|
private |
NHC byte: 11010CPP.
Definition at line 489 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcUdp(), Deserialize(), GetC(), GetPorts(), Serialize(), SetC(), and SetPorts().
|
private |
UDP checksum.
Definition at line 490 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcUdp(), Deserialize(), GetChecksum(), Serialize(), and SetChecksum().
|
private |
Destination port.
Definition at line 492 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcUdp(), Deserialize(), GetDstPort(), Print(), Serialize(), and SetDstPort().
|
private |
Source port.
Definition at line 491 of file sixlowpan-ghc.h.
Referenced by SixLowPanGhcUdp(), Deserialize(), GetSrcPort(), Print(), Serialize(), and SetSrcPort().
|
staticconstexprprivate |
Port compression mask.
Definition at line 496 of file sixlowpan-ghc.h.
Referenced by GetPorts(), and SetPorts().