Neighbor-index data structure for nix-vector routing. More...
#include "nix-vector.h"
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< NixVector > | Copy () 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. | |
uint32_t | GetRemainingBits () const |
uint32_t | GetSerializedSize () const |
NixVector & | operator= (const NixVector &o) |
uint32_t | Serialize (uint32_t *buffer, uint32_t maxSize) const |
void | SetEpoch (uint32_t epoch) |
Set the NixVector Epoch. | |
Public Member Functions inherited from ns3::SimpleRefCount< NixVector > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Private Types | |
typedef std::vector< uint32_t > | NixBits_t |
Typedef: the NixVector bits storage. | |
Private Member Functions | |
void | DumpNixVector (std::ostream &os) const |
Print the NixVector. | |
void | PrintDec2BinNix (uint32_t decimalNum, uint32_t bitCount, std::ostream &os) const |
Internal for pretty printing of nix-vector (no fill) | |
Private Attributes | |
uint32_t | m_epoch |
Epoch of the Nix-vector creation. | |
NixBits_t | m_nixVector |
the actual nix-vector | |
uint32_t | m_totalBitSize |
A counter of how total bits are in the nix-vector. | |
uint32_t | m_used |
For tracking where we are in the nix-vector. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const NixVector &nix) |
Stream insertion operator. | |
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.
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 53 of file nix-vector.h.
|
private |
Typedef: the NixVector bits storage.
Definition at line 157 of file nix-vector.h.
ns3::NixVector::NixVector | ( | ) |
Definition at line 21 of file nix-vector.cc.
References NS_LOG_FUNCTION.
Referenced by Copy().
ns3::NixVector::~NixVector | ( | ) |
Definition at line 30 of file nix-vector.cc.
References NS_LOG_FUNCTION.
ns3::NixVector::NixVector | ( | const NixVector & | o | ) |
Definition at line 35 of file nix-vector.cc.
newBits | the neighbor-index to be added to the vector |
numberOfBits | the 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 77 of file nix-vector.cc.
References m_nixVector, m_totalBitSize, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
numberOfNeighbors | the 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 320 of file nix-vector.cc.
References NS_LOG_FUNCTION.
Definition at line 58 of file nix-vector.cc.
References NixVector(), and NS_LOG_FUNCTION.
Referenced by ns3::Packet::Packet(), and ns3::Packet::operator=().
buffer | points to buffer for deserialization |
size | number of bytes to deserialize |
The raw character buffer containing all the nix-vector information is deserialized into this nix-vector.
Definition at line 228 of file nix-vector.cc.
References GetSerializedSize(), m_epoch, m_nixVector, m_totalBitSize, m_used, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
|
private |
Print the NixVector.
os | the output stream |
Definition at line 278 of file nix-vector.cc.
References m_nixVector, m_totalBitSize, NS_LOG_FUNCTION, and PrintDec2BinNix().
numberOfBits | the 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 133 of file nix-vector.cc.
References GetRemainingBits(), m_nixVector, m_used, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
uint32_t ns3::NixVector::GetEpoch | ( | ) | const |
Get the NixVector Epoch.
Definition at line 376 of file nix-vector.cc.
References m_epoch.
uint32_t ns3::NixVector::GetRemainingBits | ( | ) | const |
Definition at line 312 of file nix-vector.cc.
References m_totalBitSize, m_used, and NS_LOG_FUNCTION.
Referenced by ExtractNeighborIndex().
uint32_t ns3::NixVector::GetSerializedSize | ( | ) | const |
Definition at line 188 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().
Definition at line 44 of file nix-vector.cc.
References m_epoch, m_nixVector, m_totalBitSize, and m_used.
|
private |
Internal for pretty printing of nix-vector (no fill)
decimalNum | decimal divider |
bitCount | bit counter |
os | output stream |
Definition at line 343 of file nix-vector.cc.
References NS_LOG_FUNCTION, and PrintDec2BinNix().
Referenced by DumpNixVector(), and PrintDec2BinNix().
buffer | points to serialization buffer |
maxSize | max number of bytes to write |
This nix-vector is serialized into the raw character buffer parameter.
Definition at line 202 of file nix-vector.cc.
References GetSerializedSize(), m_epoch, m_nixVector, m_totalBitSize, m_used, and NS_LOG_FUNCTION.
Referenced by ns3::Packet::Serialize().
void ns3::NixVector::SetEpoch | ( | uint32_t | epoch | ) |
Set the NixVector Epoch.
epoch | the NixVector Epoch |
Definition at line 370 of file nix-vector.cc.
References m_epoch.
|
friend |
Stream insertion operator.
os | the stream |
nix | the Nixvector |
Definition at line 68 of file nix-vector.cc.
|
private |
Epoch of the Nix-vector creation.
Definition at line 186 of file nix-vector.h.
Referenced by Deserialize(), GetEpoch(), GetSerializedSize(), operator=(), Serialize(), and SetEpoch().
|
private |
the actual nix-vector
Definition at line 177 of file nix-vector.h.
Referenced by AddNeighborIndex(), Deserialize(), DumpNixVector(), ExtractNeighborIndex(), GetSerializedSize(), operator=(), and Serialize().
|
private |
A counter of how total bits are in the nix-vector.
Definition at line 184 of file nix-vector.h.
Referenced by AddNeighborIndex(), Deserialize(), DumpNixVector(), GetRemainingBits(), GetSerializedSize(), operator=(), and Serialize().
|
private |
For tracking where we are in the nix-vector.
Definition at line 178 of file nix-vector.h.
Referenced by Deserialize(), ExtractNeighborIndex(), GetRemainingBits(), GetSerializedSize(), operator=(), and Serialize().