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

Neighbor-index data structure for nix-vector routing. More...

#include "nix-vector.h"

+ Inheritance diagram for ns3::NixVector:
+ Collaboration diagram for ns3::NixVector:

Public Member Functions

 NixVector ()
 
 NixVector (const NixVector &o)
 
 ~NixVector ()
 
void AddNeighborIndex (uint32_t newBits, uint32_t numberOfBits)
 
uint32_t BitCount (uint32_t numberOfNeighbors) const
 
Ptr< NixVectorCopy () const
 
uint32_t Deserialize (const uint32_t *buffer, uint32_t size)
 
uint32_t ExtractNeighborIndex (uint32_t numberOfBits)
 
uint32_t GetEpoch () const
 Get the NixVector Epoch. More...
 
uint32_t GetRemainingBits () const
 
uint32_t GetSerializedSize () const
 
NixVectoroperator= (const NixVector &o)
 
uint32_t Serialize (uint32_t *buffer, uint32_t maxSize) const
 
void SetEpoch (uint32_t epoch)
 Set the NixVector Epoch. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< NixVector >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount () const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o[[maybe_unused]])
 Assignment operator. More...
 
void Ref () const
 Increment the reference count. More...
 
void Unref () const
 Decrement the reference count. More...
 

Private Types

typedef std::vector< uint32_t > NixBits_t
 Typedef: the NixVector bits storage. More...
 

Private Member Functions

void DumpNixVector (std::ostream &os) const
 Print the NixVector. More...
 
void PrintDec2BinNix (uint32_t decimalNum, uint32_t bitCount, std::ostream &os) const
 Internal for pretty printing of nix-vector (no fill) More...
 

Private Attributes

uint32_t m_epoch
 Epoch of the Nix-vector creation. More...
 
NixBits_t m_nixVector
 the actual nix-vector More...
 
uint32_t m_totalBitSize
 A counter of how total bits are in the nix-vector. More...
 
uint32_t m_used
 For tracking where we are in the nix-vector. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const NixVector &nix)
 Stream insertion operator. More...
 

Detailed Description

Neighbor-index data structure for nix-vector routing.

This data structure holds a vector of "neighbor-indexes" for a simulation specific routing protocol, nix-vector routing. These neighbor-indexes correspond to the net-device which a node should use to route a packet. A nix-vector is built (or fetched from a cache) on-demand. The nix-vector is transmitted with the packet, and along each hop of the route, the current node extracts the appropriate neighbor-index and routes the packet.

Internal:
The implementation of NixVector uses a vector to store the neighbor-indexes. Each entry in the vector is 32 bits long and can store multiple neighbor-indexes. A fair amount of bit manipulation is used to store these neighbor-indexes efficiently. A vector is used so that the nix-vector can grow arbitrarily if the topology and route requires a large number of neighbor-indexes.

As the nix-vector travels along the route, an internal private member variable keeps track of how many bits have been used. At a particular node, the nix-vector is used to return the next neighbor-index. This neighbor-index is used to determine which net-device to use. The number of bits used would then be incremented accordingly, and the packet would be routed.

Definition at line 64 of file nix-vector.h.

Member Typedef Documentation

◆ NixBits_t

typedef std::vector<uint32_t> ns3::NixVector::NixBits_t
private

Typedef: the NixVector bits storage.

Definition at line 168 of file nix-vector.h.

Constructor & Destructor Documentation

◆ NixVector() [1/2]

ns3::NixVector::NixVector ( )

Definition at line 32 of file nix-vector.cc.

References NS_LOG_FUNCTION.

Referenced by Copy().

+ Here is the caller graph for this function:

◆ ~NixVector()

ns3::NixVector::~NixVector ( )

Definition at line 41 of file nix-vector.cc.

References NS_LOG_FUNCTION.

◆ NixVector() [2/2]

ns3::NixVector::NixVector ( const NixVector o)
Parameters
othe NixVector to copy to a new NixVector using a constructor

Definition at line 46 of file nix-vector.cc.

Member Function Documentation

◆ AddNeighborIndex()

void ns3::NixVector::AddNeighborIndex ( uint32_t  newBits,
uint32_t  numberOfBits 
)
Parameters
newBitsthe neighbor-index to be added to the vector
numberOfBitsthe number of bits that newBits contains

Adds the neighbor index to the vector using a fair amount of bit manipulation to pack everything in efficiently.

Note: This function assumes that the number of bits to be added is always less than or equal to 32, ie., you can only span one entry of a nix-vector at a time. This is reasonable, since 32 bits gives you 2^32 possible neighbors.

Definition at line 88 of file nix-vector.cc.

References m_nixVector, m_totalBitSize, NS_FATAL_ERROR, and NS_LOG_FUNCTION.

Referenced by ns3::NixVectorRouting< T >::BuildNixVector().

+ Here is the caller graph for this function:

◆ BitCount()

uint32_t ns3::NixVector::BitCount ( uint32_t  numberOfNeighbors) const
Returns
number of bits of numberOfNeighbors
Parameters
numberOfNeighborsthe total number of neighbors

This function is used to determine the number of bits of numberOfNeighbors so that this value can be passed in to AddNeighborIndex or ExtractNeighborIndex.

Definition at line 331 of file nix-vector.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::NixVectorRouting< T >::BuildNixVector(), ns3::NixVectorRouting< T >::PrintRoutingPath(), ns3::NixVectorRouting< T >::RouteInput(), and ns3::NixVectorRouting< T >::RouteOutput().

+ Here is the caller graph for this function:

◆ Copy()

Ptr< NixVector > ns3::NixVector::Copy ( ) const
Returns
a copy of this nix-vector

Definition at line 69 of file nix-vector.cc.

References NixVector(), and NS_LOG_FUNCTION.

Referenced by ns3::Packet::Packet(), ns3::Packet::operator=(), ns3::NixVectorRouting< T >::PrintRoutingPath(), and ns3::NixVectorRouting< T >::RouteOutput().

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

◆ Deserialize()

uint32_t ns3::NixVector::Deserialize ( const uint32_t *  buffer,
uint32_t  size 
)
Returns
zero if a complete nix-vector is not deserialized
Parameters
bufferpoints to buffer for deserialization
sizenumber of bytes to deserialize

The raw character buffer containing all the nix-vector information is deserialized into this nix-vector.

Definition at line 239 of file nix-vector.cc.

References GetSerializedSize(), m_epoch, m_nixVector, m_totalBitSize, m_used, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Referenced by ns3::Packet::Deserialize().

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

◆ DumpNixVector()

void ns3::NixVector::DumpNixVector ( std::ostream &  os) const
private

Print the NixVector.

Parameters
osthe output stream
Note
: this could be greatly simplified by using std::format (but it's C++20).

Definition at line 289 of file nix-vector.cc.

References m_nixVector, m_totalBitSize, NS_LOG_FUNCTION, and PrintDec2BinNix().

+ Here is the call graph for this function:

◆ ExtractNeighborIndex()

uint32_t ns3::NixVector::ExtractNeighborIndex ( uint32_t  numberOfBits)
Returns
the neighbor index
Parameters
numberOfBitsthe number of bits to extract from the vector

Extracts the number of bits specified from the vector and returns the value extracted

Note: This function assumes that the number of bits to be extracted is always less than or equal to 32, ie., you can only span one entry of a nix-vector at a time. This is reasonable, since 32 bits gives you 2^32 possible neighbors.

Definition at line 144 of file nix-vector.cc.

References GetRemainingBits(), m_nixVector, m_used, NS_FATAL_ERROR, and NS_LOG_FUNCTION.

Referenced by ns3::NixVectorRouting< T >::PrintRoutingPath(), ns3::NixVectorRouting< T >::RouteInput(), and ns3::NixVectorRouting< T >::RouteOutput().

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

◆ GetEpoch()

uint32_t ns3::NixVector::GetEpoch ( ) const

Get the NixVector Epoch.

Returns
the NixVector Epoch

Definition at line 387 of file nix-vector.cc.

References m_epoch.

Referenced by ns3::NixVectorRouting< T >::RouteInput().

+ Here is the caller graph for this function:

◆ GetRemainingBits()

uint32_t ns3::NixVector::GetRemainingBits ( ) const
Returns
number of bits remaining in the nix-vector (ie m_total - m_used)

Definition at line 323 of file nix-vector.cc.

References m_totalBitSize, m_used, and NS_LOG_FUNCTION.

Referenced by ExtractNeighborIndex(), and ns3::NixVectorRouting< T >::RouteOutput().

+ Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::NixVector::GetSerializedSize ( ) const
Returns
the number of bytes required for serialization

Definition at line 199 of file nix-vector.cc.

References m_epoch, m_nixVector, m_totalBitSize, m_used, and NS_LOG_FUNCTION.

Referenced by Deserialize(), ns3::Packet::GetSerializedSize(), Serialize(), and ns3::Packet::Serialize().

+ Here is the caller graph for this function:

◆ operator=()

NixVector & ns3::NixVector::operator= ( const NixVector o)
Returns
a reference to the assignee
Parameters
othe NixVector to copy to a new NixVector using the equals operator

Definition at line 55 of file nix-vector.cc.

References m_epoch, m_nixVector, m_totalBitSize, and m_used.

◆ PrintDec2BinNix()

void ns3::NixVector::PrintDec2BinNix ( uint32_t  decimalNum,
uint32_t  bitCount,
std::ostream &  os 
) const
private

Internal for pretty printing of nix-vector (no fill)

Parameters
decimalNumdecimal divider
bitCountbit counter
osoutput stream

Definition at line 354 of file nix-vector.cc.

References NS_LOG_FUNCTION.

Referenced by DumpNixVector().

+ Here is the caller graph for this function:

◆ Serialize()

uint32_t ns3::NixVector::Serialize ( uint32_t *  buffer,
uint32_t  maxSize 
) const
Returns
zero if buffer not large enough
Parameters
bufferpoints to serialization buffer
maxSizemax number of bytes to write

This nix-vector is serialized into the raw character buffer parameter.

Definition at line 213 of file nix-vector.cc.

References GetSerializedSize(), m_epoch, m_nixVector, m_totalBitSize, m_used, and NS_LOG_FUNCTION.

Referenced by ns3::Packet::Serialize().

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

◆ SetEpoch()

void ns3::NixVector::SetEpoch ( uint32_t  epoch)

Set the NixVector Epoch.

Parameters
epochthe NixVector Epoch

Definition at line 381 of file nix-vector.cc.

References m_epoch.

Referenced by ns3::NixVectorRouting< T >::GetNixVector().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const NixVector nix 
)
friend

Stream insertion operator.

Parameters
osthe stream
nixthe Nixvector
Returns
a reference to the stream

Definition at line 79 of file nix-vector.cc.

Member Data Documentation

◆ m_epoch

uint32_t ns3::NixVector::m_epoch
private

Epoch of the Nix-vector creation.

Definition at line 197 of file nix-vector.h.

Referenced by Deserialize(), GetEpoch(), GetSerializedSize(), operator=(), Serialize(), and SetEpoch().

◆ m_nixVector

NixBits_t ns3::NixVector::m_nixVector
private

the actual nix-vector

Definition at line 188 of file nix-vector.h.

Referenced by AddNeighborIndex(), Deserialize(), DumpNixVector(), ExtractNeighborIndex(), GetSerializedSize(), operator=(), and Serialize().

◆ m_totalBitSize

uint32_t ns3::NixVector::m_totalBitSize
private

A counter of how total bits are in the nix-vector.

Definition at line 195 of file nix-vector.h.

Referenced by AddNeighborIndex(), Deserialize(), DumpNixVector(), GetRemainingBits(), GetSerializedSize(), operator=(), and Serialize().

◆ m_used

uint32_t ns3::NixVector::m_used
private

For tracking where we are in the nix-vector.

Definition at line 189 of file nix-vector.h.

Referenced by Deserialize(), ExtractNeighborIndex(), GetRemainingBits(), GetSerializedSize(), operator=(), and Serialize().


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