A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::NixVector Class Reference

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

#include <nix-vector.h>

+ Inheritance diagram for ns3::NixVector:

Public Member Functions

 NixVector (const NixVector &o)
 
void AddNeighborIndex (uint32_t newBits, uint32_t numberOfBits)
 
uint32_t BitCount (uint32_t numberOfNeighbors) const
 
Ptr< NixVectorCopy (void) const
 
uint32_t Deserialize (const uint32_t *buffer, uint32_t size)
 
uint32_t ExtractNeighborIndex (uint32_t numberOfBits)
 
uint32_t GetRemainingBits (void)
 
uint32_t GetSerializedSize (void) const
 
NixVectoroperator= (const NixVector &o)
 
uint32_t Serialize (uint32_t *buffer, uint32_t maxSize) const
 
- Public Member Functions inherited from ns3::SimpleRefCount< NixVector >
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 

Private Types

typedef std::vector< uint32_t > NixBits_t
 

Private Member Functions

void DumpNixVector (std::ostream &os) const
 
void PrintDec2BinNix (uint32_t, uint32_t, std::ostream &os) const
 
void PrintDec2BinNixFill (uint32_t, uint32_t, std::ostream &os) const
 

Private Attributes

uint32_t m_currentVectorBitSize
 
NixBits_t m_nixVector
 
uint32_t m_totalBitSize
 
uint32_t m_used
 

Friends

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

Additional Inherited Members

- Static Public Member Functions inherited from ns3::SimpleRefCount< NixVector >
static void Cleanup (void)
 

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. Theses 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.

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 63 of file nix-vector.h.

Constructor & Destructor Documentation

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

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

Member Function Documentation

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 87 of file nix-vector.cc.

References NS_FATAL_ERROR, and NS_LOG_FUNCTION.

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 364 of file nix-vector.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::Ipv4NixVectorRouting::RouteInput().

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

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

References NS_LOG_FUNCTION.

Referenced by ns3::Ipv4NixVectorRouting::RouteOutput().

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 281 of file nix-vector.cc.

References NS_ASSERT, and NS_LOG_FUNCTION.

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 159 of file nix-vector.cc.

References GetRemainingBits(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4NixVectorRouting::RouteInput().

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

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

References NS_LOG_FUNCTION.

Referenced by ExtractNeighborIndex().

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

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

References NS_LOG_FUNCTION.

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

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

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

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 224 of file nix-vector.cc.

References NS_LOG_FUNCTION.


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