A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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.
 
Ipv6Address GetAddress (const Ipv6Prefix prefix) const
 Get the Ipv6Address that will be allocated upon NextAddress ()
 
Ipv6Address GetNetwork (const Ipv6Prefix prefix) const
 Get the current network of the given Ipv6Prefix.
 
void Init (const Ipv6Address net, const Ipv6Prefix prefix, const Ipv6Address interfaceId)
 Initialise the base network and interfaceId for the generator.
 
void InitAddress (const Ipv6Address interfaceId, const Ipv6Prefix prefix)
 Set the interfaceId for the given Ipv6Prefix.
 
bool IsAddressAllocated (const Ipv6Address addr)
 Check the Ipv6Address allocation in the list of IPv6 entries.
 
bool IsNetworkAllocated (const Ipv6Address addr, const Ipv6Prefix prefix)
 Check if a network has already allocated addresses.
 
Ipv6Address NextAddress (const Ipv6Prefix prefix)
 Allocate the next Ipv6Address for the configured network and prefix.
 
Ipv6Address NextNetwork (const Ipv6Prefix prefix)
 Get the next network according to the given Ipv6Prefix.
 
void Reset ()
 Reset the networks and Ipv6Address to zero.
 
void TestMode ()
 Used to turn off fatal errors and assertions, for testing.
 

Private Member Functions

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

Private Attributes

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

Static Private Attributes

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

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

Constructor & Destructor Documentation

◆ Ipv6AddressGeneratorImpl()

ns3::Ipv6AddressGeneratorImpl::Ipv6AddressGeneratorImpl ( )

Definition at line 184 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 233 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 448 of file ipv6-address-generator.cc.

References 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 373 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 288 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 239 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 358 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 566 of file ipv6-address-generator.cc.

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

References 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 401 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 310 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 626 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()

void ns3::Ipv6AddressGeneratorImpl::Reset ( )

Reset the networks and Ipv6Address to zero.

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

References ns3::Ipv6AddressGeneratorImpl::NetworkState::addr, ns3::Ipv6AddressGeneratorImpl::NetworkState::addrMax, m_base, m_entries, m_netTable, m_test, MOST_SIGNIFICANT_BIT, N_BITS, ns3::Ipv6AddressGeneratorImpl::NetworkState::network, NS_LOG_FUNCTION, ns3::Ipv6AddressGeneratorImpl::NetworkState::prefix, and ns3::Ipv6AddressGeneratorImpl::NetworkState::shift.

Referenced by Ipv6AddressGeneratorImpl().

+ Here is the caller graph for this function:

◆ TestMode()

void ns3::Ipv6AddressGeneratorImpl::TestMode ( )

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

Definition at line 619 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 180 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 179 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 167 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 181 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 145 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 144 of file ipv6-address-generator.cc.

Referenced by PrefixToIndex(), and Reset().


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