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

Implementation class of Ipv6AddressGenerator This generator assigns addresses sequentially from a provided network address; used in topology code. It also keeps track of all addresses assigned to perform duplicate detection. More...

+ Collaboration diagram for ns3::Ipv6AddressGeneratorImpl:

Classes

class  Entry
 This class holds the allocated addresses. More...
 
class  NetworkState
 This class holds the state for a given network. More...
 

Public Member Functions

 Ipv6AddressGeneratorImpl ()
 
virtual ~Ipv6AddressGeneratorImpl ()
 
bool AddAllocated (const Ipv6Address addr)
 Add the Ipv6Address to the list of IPv6 entries. More...
 
Ipv6Address GetAddress (const Ipv6Prefix prefix) const
 Get the Ipv6Address that will be allocated upon NextAddress () More...
 
Ipv6Address GetNetwork (const Ipv6Prefix prefix) const
 Get the current network of the given Ipv6Prefix. More...
 
void Init (const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId)
 Initialise the base network and interfaceId for the generator. More...
 
void InitAddress (const Ipv6Address interfaceId, const Ipv6Prefix prefix)
 Set the interfaceId for the given Ipv6Prefix. More...
 
Ipv6Address NextAddress (const Ipv6Prefix prefix)
 Allocate the next Ipv6Address for the configured network and prefix. More...
 
Ipv6Address NextNetwork (const Ipv6Prefix prefix)
 Get the next network according to the given Ipv6Prefix. More...
 
void Reset (void)
 Reset the networks and Ipv6Address to zero. More...
 
void TestMode (void)
 Used to turn off fatal errors and assertions, for testing. More...
 

Private Member Functions

uint32_t PrefixToIndex (Ipv6Prefix prefix) const
 Create an index number for the prefix. More...
 

Private Attributes

Ipv6Address m_base
 /internal base address More...
 
std::list< Entrym_entries
 /internal contained of allocated addresses More...
 
NetworkState m_netTable [N_BITS]
 /internal the available networks More...
 
bool m_test
 /internal test mode (if true) More...
 

Static Private Attributes

static const uint32_t MOST_SIGNIFICANT_BIT = 0x80
 /internal MSB set to 1 More...
 
static const uint32_t N_BITS = 128
 /internal the number of bits in the address More...
 

Detailed Description

Implementation class of Ipv6AddressGenerator This generator assigns addresses sequentially from a provided network address; used in topology code. It also keeps track of all addresses assigned to perform duplicate detection.

Internal:

Definition at line 41 of file ipv6-address-generator.cc.

Constructor & Destructor Documentation

ns3::Ipv6AddressGeneratorImpl::Ipv6AddressGeneratorImpl ( )

Definition at line 190 of file ipv6-address-generator.cc.

References NS_LOG_FUNCTION, and Reset().

+ Here is the call graph for this function:

ns3::Ipv6AddressGeneratorImpl::~Ipv6AddressGeneratorImpl ( )
virtual

Definition at line 239 of file ipv6-address-generator.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

bool ns3::Ipv6AddressGeneratorImpl::AddAllocated ( const Ipv6Address  addr)

Add the Ipv6Address to the list of IPv6 entries.

Internal:
Typically, this is used by external address allocators that want to make use of this class's ability to track duplicates. AddAllocated is always called internally for any address generated by NextAddress ()
Parameters
addrThe Ipv6Address to be added to the list of Ipv6 entries
Returns
true on success

Definition at line 473 of file ipv6-address-generator.cc.

References ns3::Ipv6AddressGeneratorImpl::Entry::addrHigh, ns3::Ipv6AddressGeneratorImpl::Entry::addrLow, ns3::Ipv6Address::GetBytes(), m_entries, m_test, NS_FATAL_ERROR, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by NextAddress().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ipv6Address ns3::Ipv6AddressGeneratorImpl::GetAddress ( const Ipv6Prefix  prefix) const

Get the Ipv6Address that will be allocated upon NextAddress ()

Internal:
Does not change the internal state; just is used to peek the next address that will be allocated upon NextAddress ()
Parameters
prefixThe Ipv6Prefix for the current network
Returns
the IPv6 address

Definition at line 390 of file ipv6-address-generator.cc.

References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.

+ Here is the call graph for this function:

Ipv6Address ns3::Ipv6AddressGeneratorImpl::GetNetwork ( const Ipv6Prefix  prefix) const

Get the current network of the given Ipv6Prefix.

Internal:
Does not change the internal state; this just peeks at the current network
Parameters
prefixThe Ipv6Prefix for the current network
Returns
the IPv6 address of the current network

Definition at line 296 of file ipv6-address-generator.cc.

References m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.

+ Here is the call graph for this function:

void ns3::Ipv6AddressGeneratorImpl::Init ( const Ipv6Address  net,
const Ipv6Prefix  prefix,
const Ipv6Address  interfaceId 
)

Initialise the base network and interfaceId for the generator.

Internal:
The first call to NextAddress() or GetAddress() will return the value passed in.
Parameters
netThe network for the base Ipv6Address
prefixThe prefix of the base Ipv6Address
interfaceIdThe base interface ID used for initialization

Definition at line 245 of file ipv6-address-generator.cc.

References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6Address::GetBytes(), ns3::Ipv6Prefix::GetBytes(), m_base, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_DEBUG, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.

+ Here is the call graph for this function:

void ns3::Ipv6AddressGeneratorImpl::InitAddress ( const Ipv6Address  interfaceId,
const Ipv6Prefix  prefix 
)

Set the interfaceId for the given Ipv6Prefix.

Internal:
Parameters
interfaceIdThe interfaceId to set for the current Ipv6Prefix
prefixThe Ipv6Prefix whose address is to be set

Definition at line 373 of file ipv6-address-generator.cc.

References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6Address::GetBytes(), m_netTable, NS_LOG_FUNCTION, and PrefixToIndex().

+ Here is the call graph for this function:

Ipv6Address ns3::Ipv6AddressGeneratorImpl::NextAddress ( const Ipv6Prefix  prefix)

Allocate the next Ipv6Address for the configured network and prefix.

Internal:
This operation is a post-increment, meaning that the first address allocated will be the one that was initially configured.
Parameters
prefixThe Ipv6Prefix for the current network
Returns
the IPv6 address

Definition at line 422 of file ipv6-address-generator.cc.

References AddAllocated(), ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.

+ Here is the call graph for this function:

Ipv6Address ns3::Ipv6AddressGeneratorImpl::NextNetwork ( const Ipv6Prefix  prefix)

Get the next network according to the given Ipv6Prefix.

Internal:
This operation is a pre-increment, meaning that the internal state is changed before returning the new network address.

This also resets the interface ID to the base interface ID that was used for initialization.

Parameters
prefixThe Ipv6Prefix used to set the next network
Returns
the IPv6 address of the next network

Definition at line 323 of file ipv6-address-generator.cc.

References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6Address::GetBytes(), m_base, m_netTable, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, PrefixToIndex(), and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.

+ Here is the call graph for this function:

uint32_t ns3::Ipv6AddressGeneratorImpl::PrefixToIndex ( Ipv6Prefix  prefix) const
private

Create an index number for the prefix.

Internal:
Parameters
prefixthe prefix to index
Returns
an index

Definition at line 594 of file ipv6-address-generator.cc.

References ns3::Ipv6Prefix::GetBytes(), N_BITS, NS_ABORT_MSG_UNLESS, and NS_ASSERT_MSG.

Referenced by GetAddress(), GetNetwork(), Init(), InitAddress(), NextAddress(), and NextNetwork().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv6AddressGeneratorImpl::TestMode ( void  )

Used to turn off fatal errors and assertions, for testing.

Internal:

Definition at line 587 of file ipv6-address-generator.cc.

References m_test, and NS_LOG_FUNCTION.

Member Data Documentation

Ipv6Address ns3::Ipv6AddressGeneratorImpl::m_base
private

/internal base address

Definition at line 186 of file ipv6-address-generator.cc.

Referenced by Init(), NextNetwork(), and Reset().

std::list<Entry> ns3::Ipv6AddressGeneratorImpl::m_entries
private

/internal contained of allocated addresses

Definition at line 185 of file ipv6-address-generator.cc.

Referenced by AddAllocated(), and Reset().

NetworkState ns3::Ipv6AddressGeneratorImpl::m_netTable[N_BITS]
private

/internal the available networks

Definition at line 172 of file ipv6-address-generator.cc.

Referenced by GetAddress(), GetNetwork(), Init(), InitAddress(), NextAddress(), NextNetwork(), and Reset().

bool ns3::Ipv6AddressGeneratorImpl::m_test
private

/internal test mode (if true)

Definition at line 187 of file ipv6-address-generator.cc.

Referenced by AddAllocated(), Reset(), and TestMode().

const uint32_t ns3::Ipv6AddressGeneratorImpl::MOST_SIGNIFICANT_BIT = 0x80
staticprivate

/internal MSB set to 1

Definition at line 148 of file ipv6-address-generator.cc.

Referenced by Reset().

const uint32_t ns3::Ipv6AddressGeneratorImpl::N_BITS = 128
staticprivate

/internal the number of bits in the address

Definition at line 147 of file ipv6-address-generator.cc.

Referenced by PrefixToIndex(), and Reset().


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