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

Implementation class of Ipv6AddressGenerator This generator assigns addresses sequentially from a provided network address; used in topology code. 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...
 
bool IsAddressAllocated (const Ipv6Address addr)
 Check the Ipv6Address allocation in the list of IPv6 entries. More...
 
bool IsNetworkAllocated (const Ipv6Address addr, const Ipv6Prefix prefix)
 Check if a network has already allocated addresses. 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
 base address More...
 
std::list< Entrym_entries
 contained of allocated addresses More...
 
NetworkState m_netTable [N_BITS]
 the available networks More...
 
bool m_test
 test mode (if true) More...
 

Static Private Attributes

static const uint32_t MOST_SIGNIFICANT_BIT = 0x80
 MSB set to 1. More...
 
static const uint32_t N_BITS = 128
 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.

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

Constructor & Destructor Documentation

◆ Ipv6AddressGeneratorImpl()

ns3::Ipv6AddressGeneratorImpl::Ipv6AddressGeneratorImpl ( )

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

References NS_LOG_FUNCTION, and Reset().

+ Here is the call graph for this function:

◆ ~Ipv6AddressGeneratorImpl()

ns3::Ipv6AddressGeneratorImpl::~Ipv6AddressGeneratorImpl ( )
virtual

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

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddAllocated()

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

Add the Ipv6Address to the list of IPv6 entries.

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 465 of file ipv6-address-generator.cc.

References first::address, ns3::Ipv6AddressGeneratorImpl::Entry::addrHigh, ns3::Ipv6AddressGeneratorImpl::Entry::addrLow, m_entries, m_test, NS_FATAL_ERROR, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by NextAddress().

+ Here is the caller graph for this function:

◆ GetAddress()

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

Get the Ipv6Address that will be allocated upon NextAddress ()

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:

◆ GetNetwork()

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

Get the current network of the given Ipv6Prefix.

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 300 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:

◆ Init()

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

Initialise the base network and interfaceId for the generator.

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 249 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:

◆ InitAddress()

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

Set the interfaceId for the given Ipv6Prefix.

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:

◆ IsAddressAllocated()

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

Check the Ipv6Address allocation in the list of IPv6 entries.

Parameters
addrThe Ipv6Address to be checked in the list of Ipv4 entries
Returns
true if the network is already allocated

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

References first::address, m_entries, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

◆ IsNetworkAllocated()

bool ns3::Ipv6AddressGeneratorImpl::IsNetworkAllocated ( const Ipv6Address  addr,
const Ipv6Prefix  prefix 
)

Check if a network has already allocated addresses.

Parameters
addrThe Ipv6 network to be checked
prefixThe Ipv6 network prefix
Returns
true if the network is already allocated

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

References first::address, ns3::Ipv6Address::CombinePrefix(), m_entries, NS_ABORT_MSG_UNLESS, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

◆ NextAddress()

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

Allocate the next Ipv6Address for the configured network and prefix.

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 418 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:

◆ NextNetwork()

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

Get the next network according to the given Ipv6Prefix.

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:

◆ PrefixToIndex()

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

Create an index number for the prefix.

Parameters
prefixthe prefix to index
Returns
an index

Definition at line 641 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:

◆ Reset()

◆ TestMode()

void ns3::Ipv6AddressGeneratorImpl::TestMode ( void  )

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

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

References m_test, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_base

Ipv6Address ns3::Ipv6AddressGeneratorImpl::m_base
private

base address

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

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

◆ m_entries

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

contained of allocated addresses

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

Referenced by AddAllocated(), IsAddressAllocated(), IsNetworkAllocated(), and Reset().

◆ m_netTable

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

the available networks

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

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

◆ m_test

bool ns3::Ipv6AddressGeneratorImpl::m_test
private

test mode (if true)

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

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

◆ MOST_SIGNIFICANT_BIT

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

MSB set to 1.

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

Referenced by Reset().

◆ N_BITS

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

the number of bits in the address

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

Referenced by PrefixToIndex(), and Reset().


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