A Discrete-Event Network Simulator
API
ns3::Ipv4PacketInfoTag Class Reference

This class implements Linux struct pktinfo in order to deliver ancillary information to the socket interface. More...

#include "ipv4-packet-info-tag.h"

+ Inheritance diagram for ns3::Ipv4PacketInfoTag:
+ Collaboration diagram for ns3::Ipv4PacketInfoTag:

Public Member Functions

 Ipv4PacketInfoTag ()
 
virtual void Deserialize (TagBuffer i)
 
Ipv4Address GetAddress (void) const
 Get the tag's address. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
uint32_t GetRecvIf (void) const
 Get the tag's receiving interface. More...
 
virtual uint32_t GetSerializedSize (void) const
 
uint8_t GetTtl (void) const
 Get the tag's Time to Live Implemented, but not used in the stack yet. More...
 
virtual void Print (std::ostream &os) const
 
virtual void Serialize (TagBuffer i) const
 
void SetAddress (Ipv4Address addr)
 Set the tag's address. More...
 
void SetRecvIf (uint32_t ifindex)
 Set the tag's receiving interface. More...
 
void SetTtl (uint8_t ttl)
 Set the tag's Time to Live Implemented, but not used in the stack yet. More...
 
virtual void Deserialize (TagBuffer i)=0
 
virtual uint32_t GetSerializedSize (void) const =0
 
virtual void Print (std::ostream &os) const =0
 
virtual void Serialize (TagBuffer i) const =0
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
virtual TypeId GetInstanceTypeId (void) const =0
 Get the most derived TypeId for this Object. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Tag
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Attributes

Ipv4Address m_addr
 Header destination address. More...
 
uint32_t m_ifindex
 interface index More...
 
uint8_t m_ttl
 Time to Live. More...
 

Additional Inherited Members

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

Detailed Description

This class implements Linux struct pktinfo in order to deliver ancillary information to the socket interface.

This is used with socket option such as IP_PKTINFO, IP_RECVTTL, IP_RECVTOS. See linux manpage ip(7).

See also SocketIpTosTag and SocketIpTtlTag

The Tag does not carry the Local address (as it is not currently used to force a source address).

This tag in the send direction is presently not enabled but we would accept a patch along those lines in the future.

Definition at line 49 of file ipv4-packet-info-tag.h.

Constructor & Destructor Documentation

◆ Ipv4PacketInfoTag()

ns3::Ipv4PacketInfoTag::Ipv4PacketInfoTag ( )

Definition at line 31 of file ipv4-packet-info-tag.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ Deserialize()

void ns3::Ipv4PacketInfoTag::Deserialize ( TagBuffer  i)
virtual
Parameters
ithe buffer to read data from.

Read the content of the tag from the provided tag buffer. DO NOT attempt to read more bytes than you wrote with Tag::Serialize.

Implements ns3::Tag.

Definition at line 117 of file ipv4-packet-info-tag.cc.

References ns3::Ipv4Address::Deserialize(), m_addr, m_ifindex, m_ttl, NS_LOG_FUNCTION, ns3::TagBuffer::Read(), ns3::TagBuffer::ReadU32(), and ns3::TagBuffer::ReadU8().

+ Here is the call graph for this function:

◆ GetAddress()

Ipv4Address ns3::Ipv4PacketInfoTag::GetAddress ( void  ) const

Get the tag's address.

Returns
the address

Definition at line 47 of file ipv4-packet-info-tag.cc.

References m_addr, and NS_LOG_FUNCTION.

Referenced by ns3::PacketSink::HandleRead().

+ Here is the caller graph for this function:

◆ GetInstanceTypeId()

TypeId ns3::Ipv4PacketInfoTag::GetInstanceTypeId ( void  ) const
virtual

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 94 of file ipv4-packet-info-tag.cc.

References GetTypeId(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GetRecvIf()

uint32_t ns3::Ipv4PacketInfoTag::GetRecvIf ( void  ) const

Get the tag's receiving interface.

Returns
the interface index

Definition at line 61 of file ipv4-packet-info-tag.cc.

References m_ifindex, and NS_LOG_FUNCTION.

Referenced by Ipv4DynamicGlobalRoutingTestCase::HandleRead(), ns3::DhcpServer::NetHandler(), ns3::Rip::Receive(), and ns3::olsr::RoutingProtocol::RecvOlsr().

+ Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::Ipv4PacketInfoTag::GetSerializedSize ( void  ) const
virtual
Returns
the number of bytes required to serialize the data of the tag.

This method is typically invoked by Packet::AddPacketTag or Packet::AddByteTag just prior to calling Tag::Serialize.

Implements ns3::Tag.

Definition at line 101 of file ipv4-packet-info-tag.cc.

References NS_LOG_FUNCTION.

◆ GetTtl()

uint8_t ns3::Ipv4PacketInfoTag::GetTtl ( void  ) const

Get the tag's Time to Live Implemented, but not used in the stack yet.

Returns
the TTL

Definition at line 75 of file ipv4-packet-info-tag.cc.

References m_ttl, and NS_LOG_FUNCTION.

◆ GetTypeId()

TypeId ns3::Ipv4PacketInfoTag::GetTypeId ( void  )
static

Get the type ID.

Returns
the object TypeId

Definition at line 84 of file ipv4-packet-info-tag.cc.

References 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::Ipv4PacketInfoTag::Print ( std::ostream &  os) const
virtual
Parameters
osthe stream to print to

This method is typically invoked from the Packet::PrintByteTags or Packet::PrintPacketTags methods.

Implements ns3::Tag.

Definition at line 127 of file ipv4-packet-info-tag.cc.

References m_addr, m_ifindex, m_ttl, and NS_LOG_FUNCTION.

◆ Serialize()

void ns3::Ipv4PacketInfoTag::Serialize ( TagBuffer  i) const
virtual
Parameters
ithe buffer to write data into.

Write the content of the tag in the provided tag buffer. DO NOT attempt to write more bytes than you requested with Tag::GetSerializedSize.

Implements ns3::Tag.

Definition at line 107 of file ipv4-packet-info-tag.cc.

References m_addr, m_ifindex, m_ttl, NS_LOG_FUNCTION, ns3::Ipv4Address::Serialize(), ns3::TagBuffer::Write(), ns3::TagBuffer::WriteU32(), and ns3::TagBuffer::WriteU8().

+ Here is the call graph for this function:

◆ SetAddress()

void ns3::Ipv4PacketInfoTag::SetAddress ( Ipv4Address  addr)

Set the tag's address.

Parameters
addrthe address

Definition at line 40 of file ipv4-packet-info-tag.cc.

References m_addr, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4RawSocketImpl::ForwardUp(), and ns3::UdpSocketImpl::ForwardUp().

+ Here is the caller graph for this function:

◆ SetRecvIf()

void ns3::Ipv4PacketInfoTag::SetRecvIf ( uint32_t  ifindex)

Set the tag's receiving interface.

Parameters
ifindexthe interface index

Definition at line 54 of file ipv4-packet-info-tag.cc.

References m_ifindex, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4RawSocketImpl::ForwardUp(), and ns3::UdpSocketImpl::ForwardUp().

+ Here is the caller graph for this function:

◆ SetTtl()

void ns3::Ipv4PacketInfoTag::SetTtl ( uint8_t  ttl)

Set the tag's Time to Live Implemented, but not used in the stack yet.

Parameters
ttlthe TTL

Definition at line 68 of file ipv4-packet-info-tag.cc.

References m_ttl, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4RawSocketImpl::ForwardUp(), and ns3::UdpSocketImpl::ForwardUp().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_addr

Ipv4Address ns3::Ipv4PacketInfoTag::m_addr
private

Header destination address.

Definition at line 115 of file ipv4-packet-info-tag.h.

Referenced by Deserialize(), GetAddress(), Print(), Serialize(), and SetAddress().

◆ m_ifindex

uint32_t ns3::Ipv4PacketInfoTag::m_ifindex
private

interface index

Definition at line 116 of file ipv4-packet-info-tag.h.

Referenced by Deserialize(), GetRecvIf(), Print(), Serialize(), and SetRecvIf().

◆ m_ttl

uint8_t ns3::Ipv4PacketInfoTag::m_ttl
private

Time to Live.

Definition at line 119 of file ipv4-packet-info-tag.h.

Referenced by Deserialize(), GetTtl(), Print(), Serialize(), and SetTtl().


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