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

This header can store HELP, TC, MID and HNA messages. More...

#include "olsr-header.h"

+ Inheritance diagram for ns3::olsr::MessageHeader:
+ Collaboration diagram for ns3::olsr::MessageHeader:

Classes

struct  Hello
 HELLO Message Format. More...
 
struct  Hna
 HNA (Host Network Association) Message Format. More...
 
struct  Mid
 MID Message Format. More...
 
struct  Tc
 TC Message Format. More...
 

Public Types

enum  MessageType { HELLO_MESSAGE = 1 , TC_MESSAGE = 2 , MID_MESSAGE = 3 , HNA_MESSAGE = 4 }
 Message type. More...
 

Public Member Functions

 MessageHeader ()
 
 ~MessageHeader () override
 
uint32_t Deserialize (Buffer::Iterator start) override
 
HelloGetHello ()
 Set the message type to HELLO and return the message content.
 
const HelloGetHello () const
 Get the HELLO message.
 
HnaGetHna ()
 Set the message type to HNA and return the message content.
 
const HnaGetHna () const
 Get the HNA message.
 
uint8_t GetHopCount () const
 Get the hop count.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
uint16_t GetMessageSequenceNumber () const
 Get the message sequence number.
 
MessageType GetMessageType () const
 Get the message type.
 
MidGetMid ()
 Set the message type to MID and return the message content.
 
const MidGetMid () const
 Get the MID message.
 
Ipv4Address GetOriginatorAddress () const
 Get the originator address.
 
uint32_t GetSerializedSize () const override
 
TcGetTc ()
 Set the message type to TC and return the message content.
 
const TcGetTc () const
 Get the TC message.
 
uint8_t GetTimeToLive () const
 Get the time to live.
 
Time GetVTime () const
 Get the validity time.
 
void Print (std::ostream &os) const override
 
void Serialize (Buffer::Iterator start) const override
 
void SetHopCount (uint8_t hopCount)
 Set the hop count.
 
void SetMessageSequenceNumber (uint16_t messageSequenceNumber)
 Set the message sequence number.
 
void SetMessageType (MessageType messageType)
 Set the message type.
 
void SetOriginatorAddress (Ipv4Address originatorAddress)
 Set the originator address.
 
void SetTimeToLive (uint8_t timeToLive)
 Set the time to live.
 
void SetVTime (Time time)
 Set the validity time.
 
- 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_hopCount
 The hop count.
 
struct { 
 
   Hello   hello 
 HELLO message (optional). More...
 
   Hna   hna 
 HNA message (optional). More...
 
   Mid   mid 
 MID message (optional). More...
 
   Tc   tc 
 TC message (optional). More...
 
m_message 
 Structure holding the message content.
 
uint16_t m_messageSequenceNumber
 The message sequence number.
 
uint16_t m_messageSize
 The message size.
 
MessageType m_messageType
 The message type.
 
Ipv4Address m_originatorAddress
 The originator address.
 
uint8_t m_timeToLive
 The time to live.
 
uint8_t m_vTime
 The validity time.
 

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

This header can store HELP, TC, MID and HNA messages.

The header size is variable, and depends on the actual message type.

  0                   1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |  Message Type |     Vtime     |         Message Size          |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                      Originator Address                       |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |  Time To Live |   Hop Count   |    Message Sequence Number    |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               |
 :                            MESSAGE                            :
 |                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Definition at line 149 of file olsr-header.h.

Member Enumeration Documentation

◆ MessageType

Message type.

Enumerator
HELLO_MESSAGE 
TC_MESSAGE 
MID_MESSAGE 
HNA_MESSAGE 

Definition at line 155 of file olsr-header.h.

Constructor & Destructor Documentation

◆ MessageHeader()

ns3::olsr::MessageHeader::MessageHeader ( )

Definition at line 150 of file olsr-header.cc.

◆ ~MessageHeader()

ns3::olsr::MessageHeader::~MessageHeader ( )
override

Definition at line 155 of file olsr-header.cc.

Member Function Documentation

◆ Deserialize()

uint32_t ns3::olsr::MessageHeader::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 278 of file olsr-header.cc.

References HELLO_MESSAGE, HNA_MESSAGE, m_hopCount, m_message, m_messageSequenceNumber, m_messageSize, m_messageType, m_originatorAddress, m_timeToLive, m_vTime, MID_MESSAGE, NS_ASSERT, OLSR_MSG_HEADER_SIZE, ns3::Buffer::Iterator::ReadNtohU16(), ns3::Buffer::Iterator::ReadNtohU32(), ns3::Buffer::Iterator::ReadU8(), and TC_MESSAGE.

+ Here is the call graph for this function:

◆ GetHello() [1/2]

Hello & ns3::olsr::MessageHeader::GetHello ( )
inline

Set the message type to HELLO and return the message content.

Returns
The HELLO message.

Definition at line 590 of file olsr-header.h.

References HELLO_MESSAGE, m_message, m_messageType, and NS_ASSERT.

Referenced by OlsrHelloTestCase::DoRun(), ns3::olsr::RoutingProtocol::ProcessHello(), ns3::olsr::HelloRegressionTest::ReceivePktProbeA(), ns3::olsr::TcRegressionTest::ReceivePktProbeA(), ns3::olsr::HelloRegressionTest::ReceivePktProbeB(), ns3::olsr::TcRegressionTest::ReceivePktProbeB(), ns3::olsr::TcRegressionTest::ReceivePktProbeC(), and ns3::olsr::RoutingProtocol::SendHello().

+ Here is the caller graph for this function:

◆ GetHello() [2/2]

const Hello & ns3::olsr::MessageHeader::GetHello ( ) const
inline

Get the HELLO message.

Returns
The HELLO message.

Definition at line 651 of file olsr-header.h.

References HELLO_MESSAGE, m_message, m_messageType, and NS_ASSERT.

◆ GetHna() [1/2]

Hna & ns3::olsr::MessageHeader::GetHna ( )
inline

Set the message type to HNA and return the message content.

Returns
The HNA message.

Definition at line 624 of file olsr-header.h.

References HNA_MESSAGE, m_message, m_messageType, and NS_ASSERT.

Referenced by OlsrHnaTestCase::DoRun(), ns3::olsr::RoutingProtocol::ProcessHna(), and ns3::olsr::RoutingProtocol::SendHna().

+ Here is the caller graph for this function:

◆ GetHna() [2/2]

const Hna & ns3::olsr::MessageHeader::GetHna ( ) const
inline

Get the HNA message.

Returns
The HNA message.

Definition at line 671 of file olsr-header.h.

References HNA_MESSAGE, m_message, m_messageType, and NS_ASSERT.

◆ GetHopCount()

uint8_t ns3::olsr::MessageHeader::GetHopCount ( ) const
inline

Get the hop count.

Returns
The hop count.

Definition at line 251 of file olsr-header.h.

References m_hopCount.

Referenced by ns3::olsr::RoutingProtocol::ForwardDefault().

+ Here is the caller graph for this function:

◆ GetInstanceTypeId()

TypeId ns3::olsr::MessageHeader::GetInstanceTypeId ( ) const
overridevirtual

Get the most derived TypeId for this Object.

This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.

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

Implements ns3::ObjectBase.

Definition at line 170 of file olsr-header.cc.

References GetTypeId().

+ Here is the call graph for this function:

◆ GetMessageSequenceNumber()

uint16_t ns3::olsr::MessageHeader::GetMessageSequenceNumber ( ) const
inline

Get the message sequence number.

Returns
The message sequence number.

Definition at line 269 of file olsr-header.h.

References m_messageSequenceNumber.

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::ForwardDefault(), and ns3::olsr::RoutingProtocol::RecvOlsr().

+ Here is the caller graph for this function:

◆ GetMessageType()

MessageType ns3::olsr::MessageHeader::GetMessageType ( ) const
inline

Get the message type.

Returns
The message type.

Definition at line 179 of file olsr-header.h.

References m_messageType.

Referenced by OlsrMidTestCase::DoRun(), and ns3::olsr::RoutingProtocol::RecvOlsr().

+ Here is the caller graph for this function:

◆ GetMid() [1/2]

Mid & ns3::olsr::MessageHeader::GetMid ( )
inline

Set the message type to MID and return the message content.

Returns
The MID message.

Definition at line 573 of file olsr-header.h.

References m_message, m_messageType, MID_MESSAGE, and NS_ASSERT.

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::ProcessMid(), and ns3::olsr::RoutingProtocol::SendMid().

+ Here is the caller graph for this function:

◆ GetMid() [2/2]

const Mid & ns3::olsr::MessageHeader::GetMid ( ) const
inline

Get the MID message.

Returns
The MID message.

Definition at line 641 of file olsr-header.h.

References m_message, m_messageType, MID_MESSAGE, and NS_ASSERT.

◆ GetOriginatorAddress()

◆ GetSerializedSize()

uint32_t ns3::olsr::MessageHeader::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 176 of file olsr-header.cc.

References HELLO_MESSAGE, HNA_MESSAGE, m_message, m_messageType, MID_MESSAGE, NS_ASSERT, NS_LOG_DEBUG, OLSR_MSG_HEADER_SIZE, and TC_MESSAGE.

Referenced by ns3::olsr::MessageHeader::Mid::Deserialize(), OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::RecvOlsr(), ns3::olsr::RoutingProtocol::SendHello(), and Serialize().

+ Here is the caller graph for this function:

◆ GetTc() [1/2]

Tc & ns3::olsr::MessageHeader::GetTc ( )
inline

Set the message type to TC and return the message content.

Returns
The TC message.

Definition at line 607 of file olsr-header.h.

References m_message, m_messageType, NS_ASSERT, and TC_MESSAGE.

Referenced by OlsrTcTestCase::DoRun(), ns3::olsr::RoutingProtocol::ProcessTc(), ns3::olsr::TcRegressionTest::ReceivePktProbeA(), ns3::olsr::TcRegressionTest::ReceivePktProbeC(), and ns3::olsr::RoutingProtocol::SendTc().

+ Here is the caller graph for this function:

◆ GetTc() [2/2]

const Tc & ns3::olsr::MessageHeader::GetTc ( ) const
inline

Get the TC message.

Returns
The TC message.

Definition at line 661 of file olsr-header.h.

References m_message, m_messageType, NS_ASSERT, and TC_MESSAGE.

◆ GetTimeToLive()

uint8_t ns3::olsr::MessageHeader::GetTimeToLive ( ) const
inline

Get the time to live.

Returns
The time to live.

Definition at line 233 of file olsr-header.h.

References m_timeToLive.

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::ForwardDefault(), and ns3::olsr::RoutingProtocol::RecvOlsr().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::olsr::MessageHeader::GetTypeId ( )
static

Get the type ID.

Returns
The object TypeId.

Definition at line 160 of file olsr-header.cc.

References ns3::TypeId::SetParent().

Referenced by GetInstanceTypeId().

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

◆ GetVTime()

Time ns3::olsr::MessageHeader::GetVTime ( ) const
inline

Get the validity time.

Returns
The validity time.

Definition at line 197 of file olsr-header.h.

References ns3::olsr::EmfToSeconds(), m_vTime, and ns3::Seconds().

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::LinkSensing(), ns3::olsr::RoutingProtocol::PopulateMprSelectorSet(), ns3::olsr::RoutingProtocol::PopulateTwoHopNeighborSet(), ns3::olsr::RoutingProtocol::ProcessHna(), ns3::olsr::RoutingProtocol::ProcessMid(), and ns3::olsr::RoutingProtocol::ProcessTc().

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

◆ Print()

void ns3::olsr::MessageHeader::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 202 of file olsr-header.cc.

References HELLO_MESSAGE, HNA_MESSAGE, m_hopCount, m_message, m_messageSequenceNumber, m_messageSize, m_messageType, m_originatorAddress, m_timeToLive, m_vTime, MID_MESSAGE, NS_ASSERT, and TC_MESSAGE.

Referenced by ns3::olsr::operator<<().

+ Here is the caller graph for this function:

◆ Serialize()

void ns3::olsr::MessageHeader::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 247 of file olsr-header.cc.

References ns3::Ipv4Address::Get(), GetSerializedSize(), HELLO_MESSAGE, HNA_MESSAGE, m_hopCount, m_message, m_messageSequenceNumber, m_messageType, m_originatorAddress, m_timeToLive, m_vTime, MID_MESSAGE, NS_ASSERT, TC_MESSAGE, ns3::Buffer::Iterator::WriteHtonU16(), ns3::Buffer::Iterator::WriteHtonU32(), and ns3::Buffer::Iterator::WriteU8().

+ Here is the call graph for this function:

◆ SetHopCount()

void ns3::olsr::MessageHeader::SetHopCount ( uint8_t hopCount)
inline

Set the hop count.

Parameters
hopCountThe hop count.

Definition at line 242 of file olsr-header.h.

References m_hopCount.

Referenced by ns3::olsr::RoutingProtocol::ForwardDefault(), ns3::olsr::RoutingProtocol::SendHello(), ns3::olsr::RoutingProtocol::SendHna(), ns3::olsr::RoutingProtocol::SendMid(), and ns3::olsr::RoutingProtocol::SendTc().

+ Here is the caller graph for this function:

◆ SetMessageSequenceNumber()

void ns3::olsr::MessageHeader::SetMessageSequenceNumber ( uint16_t messageSequenceNumber)
inline

Set the message sequence number.

Parameters
messageSequenceNumberThe message sequence number.

Definition at line 260 of file olsr-header.h.

References m_messageSequenceNumber.

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::SendHello(), ns3::olsr::RoutingProtocol::SendHna(), ns3::olsr::RoutingProtocol::SendMid(), and ns3::olsr::RoutingProtocol::SendTc().

+ Here is the caller graph for this function:

◆ SetMessageType()

void ns3::olsr::MessageHeader::SetMessageType ( MessageType messageType)
inline

Set the message type.

Parameters
messageTypeThe message type.

Definition at line 170 of file olsr-header.h.

References m_messageType.

Referenced by OlsrMidTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetOriginatorAddress()

void ns3::olsr::MessageHeader::SetOriginatorAddress ( Ipv4Address originatorAddress)
inline

Set the originator address.

Parameters
originatorAddressThe originator address.

Definition at line 206 of file olsr-header.h.

References m_originatorAddress.

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::SendHello(), ns3::olsr::RoutingProtocol::SendHna(), ns3::olsr::RoutingProtocol::SendMid(), and ns3::olsr::RoutingProtocol::SendTc().

+ Here is the caller graph for this function:

◆ SetTimeToLive()

void ns3::olsr::MessageHeader::SetTimeToLive ( uint8_t timeToLive)
inline

Set the time to live.

Parameters
timeToLiveThe time to live.

Definition at line 224 of file olsr-header.h.

References m_timeToLive.

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::ForwardDefault(), ns3::olsr::RoutingProtocol::SendHello(), ns3::olsr::RoutingProtocol::SendHna(), ns3::olsr::RoutingProtocol::SendMid(), and ns3::olsr::RoutingProtocol::SendTc().

+ Here is the caller graph for this function:

◆ SetVTime()

void ns3::olsr::MessageHeader::SetVTime ( Time time)
inline

Set the validity time.

Parameters
timeThe validity time.

Definition at line 188 of file olsr-header.h.

References ns3::Time::GetSeconds(), m_vTime, and ns3::olsr::SecondsToEmf().

Referenced by OlsrMidTestCase::DoRun(), ns3::olsr::RoutingProtocol::SendHello(), ns3::olsr::RoutingProtocol::SendHna(), ns3::olsr::RoutingProtocol::SendMid(), and ns3::olsr::RoutingProtocol::SendTc().

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

Member Data Documentation

◆ hello

Hello ns3::olsr::MessageHeader::hello

HELLO message (optional).

Definition at line 563 of file olsr-header.h.

◆ hna

Hna ns3::olsr::MessageHeader::hna

HNA message (optional).

Definition at line 565 of file olsr-header.h.

◆ m_hopCount

uint8_t ns3::olsr::MessageHeader::m_hopCount
private

The hop count.

Definition at line 279 of file olsr-header.h.

Referenced by Deserialize(), GetHopCount(), Print(), Serialize(), and SetHopCount().

◆ [struct]

struct { ... } ns3::olsr::MessageHeader::m_message

Structure holding the message content.

The actual message being carried.

Referenced by Deserialize(), GetHello(), GetHello(), GetHna(), GetHna(), GetMid(), GetMid(), GetSerializedSize(), GetTc(), GetTc(), Print(), and Serialize().

◆ m_messageSequenceNumber

uint16_t ns3::olsr::MessageHeader::m_messageSequenceNumber
private

The message sequence number.

Definition at line 280 of file olsr-header.h.

Referenced by Deserialize(), GetMessageSequenceNumber(), Print(), Serialize(), and SetMessageSequenceNumber().

◆ m_messageSize

uint16_t ns3::olsr::MessageHeader::m_messageSize
private

The message size.

Definition at line 281 of file olsr-header.h.

Referenced by Deserialize(), and Print().

◆ m_messageType

MessageType ns3::olsr::MessageHeader::m_messageType
private

◆ m_originatorAddress

Ipv4Address ns3::olsr::MessageHeader::m_originatorAddress
private

The originator address.

Definition at line 277 of file olsr-header.h.

Referenced by Deserialize(), GetOriginatorAddress(), Print(), Serialize(), and SetOriginatorAddress().

◆ m_timeToLive

uint8_t ns3::olsr::MessageHeader::m_timeToLive
private

The time to live.

Definition at line 278 of file olsr-header.h.

Referenced by Deserialize(), GetTimeToLive(), Print(), Serialize(), and SetTimeToLive().

◆ m_vTime

uint8_t ns3::olsr::MessageHeader::m_vTime
private

The validity time.

Definition at line 276 of file olsr-header.h.

Referenced by Deserialize(), GetVTime(), Print(), Serialize(), and SetVTime().

◆ mid

Mid ns3::olsr::MessageHeader::mid

MID message (optional).

Definition at line 562 of file olsr-header.h.

◆ tc

Tc ns3::olsr::MessageHeader::tc

TC message (optional).

Definition at line 564 of file olsr-header.h.


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