22#include "ns3/fatal-error.h" 
   47    : m_nixVector(o.m_nixVector),
 
   49      m_totalBitSize(o.m_totalBitSize),
 
   92    if (numberOfBits > 32)
 
   94        NS_FATAL_ERROR(
"Can't add more than 32 bits to a nix-vector at one time");
 
  100    if (currentVectorBitSize == 0)
 
  109    if (currentVectorBitSize + numberOfBits > 32)
 
  114        tempBits = newBits << currentVectorBitSize;
 
  121        newBits = newBits >> (32 - currentVectorBitSize);
 
  131        newBits = newBits << currentVectorBitSize;
 
  148    if (numberOfBits > 32)
 
  150        NS_FATAL_ERROR(
"Can't extract more than 32 bits to a nix-vector at one time");
 
  157    if (numberOfBits > totalRemainingBits)
 
  159        NS_FATAL_ERROR(
"You've tried to extract too many bits of the Nix-vector, " 
  160                       << 
this << 
". NumberBits: " << numberOfBits
 
  161                       << 
" Remaining: " << totalRemainingBits);
 
  164    if (numberOfBits <= 0)
 
  166        NS_FATAL_ERROR(
"You've specified a number of bits for Nix-vector <= 0!");
 
  173    vectorIndex = ((totalRemainingBits - 1) / 32);
 
  179        if ((numberOfBits - 1) > ((totalRemainingBits - 1) % 32)) 
 
  181            extractedBits = 
m_nixVector.at(vectorIndex) << (32 - (totalRemainingBits % 32));
 
  182            extractedBits = extractedBits >> ((32 - (totalRemainingBits % 32)) -
 
  183                                              (numberOfBits - (totalRemainingBits % 32)));
 
  184            extractedBits |= (
m_nixVector.at(vectorIndex - 1) >>
 
  185                              (32 - (numberOfBits - (totalRemainingBits % 32))));
 
  187            return extractedBits;
 
  192    extractedBits = 
m_nixVector.at(vectorIndex) << (32 - (totalRemainingBits % 32));
 
  193    extractedBits = extractedBits >> (32 - (numberOfBits));
 
  195    return extractedBits;
 
  245                  "NixVector minimum serialized length is " << 
sizeof(
m_totalBitSize) << 
" bytes");
 
  264                      "NixVector serialized length should have been " << 16 + nixVectorLength
 
  265                                                                      << 
" but buffer is shorter");
 
  266        if (size < 16 + nixVectorLength * 4)
 
  276        for (
uint32_t j = 0; j < nixVectorLength; j++)
 
  299    std::vector<uint32_t>::const_reverse_iterator rIter;
 
  339    if (numberOfNeighbors < 2)
 
  345        for (numberOfNeighbors -= 1; numberOfNeighbors != 0; numberOfNeighbors >>= 1)
 
  359        for (; bitCount > 0; bitCount--)
 
  367        for (; bitCount > 1; bitCount--)
 
  376        os << decimalNum % 2;
 
Neighbor-index data structure for nix-vector routing.
void AddNeighborIndex(uint32_t newBits, uint32_t numberOfBits)
uint32_t m_used
For tracking where we are in the nix-vector.
uint32_t GetSerializedSize() const
uint32_t m_epoch
Epoch of the Nix-vector creation.
uint32_t GetRemainingBits() const
NixVector & operator=(const NixVector &o)
uint32_t m_totalBitSize
A counter of how total bits are in the nix-vector.
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
uint32_t ExtractNeighborIndex(uint32_t numberOfBits)
NixBits_t m_nixVector
the actual nix-vector
void SetEpoch(uint32_t epoch)
Set the NixVector Epoch.
void DumpNixVector(std::ostream &os) const
Print the NixVector.
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
Ptr< NixVector > Copy() const
uint32_t BitCount(uint32_t numberOfNeighbors) const
void PrintDec2BinNix(uint32_t decimalNum, uint32_t bitCount, std::ostream &os) const
Internal for pretty printing of nix-vector (no fill)
uint32_t GetEpoch() const
Get the NixVector Epoch.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::vector< uint32_t > NixBits_t
typedef for the nixVector