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

Implementation class of Ipv4AddressGenerator 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::Ipv4AddressGeneratorImpl:

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

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

Private Member Functions

uint32_t MaskToIndex (Ipv4Mask mask) const
 Create an index number for the network mask. More...
 

Private Attributes

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 = 0x80000000
 /internal MSB set to 1 More...
 
static const uint32_t N_BITS = 32
 /internal the number of bits in the address More...
 

Detailed Description

Implementation class of Ipv4AddressGenerator 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 39 of file ipv4-address-generator.cc.

Constructor & Destructor Documentation

ns3::Ipv4AddressGeneratorImpl::Ipv4AddressGeneratorImpl ( )

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

References NS_LOG_FUNCTION, and Reset().

+ Here is the call graph for this function:

ns3::Ipv4AddressGeneratorImpl::~Ipv4AddressGeneratorImpl ( )
virtual

Definition at line 232 of file ipv4-address-generator.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

bool ns3::Ipv4AddressGeneratorImpl::AddAllocated ( const Ipv4Address  addr)

Add the Ipv4Address to the list of IPv4 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 Ipv4Address to be added to the list of Ipv4 entries
Returns
true on success

Definition at line 357 of file ipv4-address-generator.cc.

References ns3::Ipv4AddressGeneratorImpl::Entry::addrHigh, ns3::Ipv4AddressGeneratorImpl::Entry::addrLow, ns3::Ipv4Address::Get(), m_entries, m_test, NS_ABORT_MSG_UNLESS, 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:

Ipv4Address ns3::Ipv4AddressGeneratorImpl::GetAddress ( const Ipv4Mask  mask) const

Get the Ipv4Address 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
maskThe Ipv4Mask for the current network
Returns
the IPv4 address

Definition at line 315 of file ipv4-address-generator.cc.

References m_netTable, MaskToIndex(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Ipv4Address ns3::Ipv4AddressGeneratorImpl::GetNetwork ( const Ipv4Mask  mask) const

Get the current network of the given Ipv4Mask.

Internal:
Does not change the internal state; this just peeks at the current network
Parameters
maskThe Ipv4Mask for the current network
Returns
the IPv4 address of the current network

Definition at line 272 of file ipv4-address-generator.cc.

References m_netTable, MaskToIndex(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::Ipv4AddressGeneratorImpl::Init ( const Ipv4Address  net,
const Ipv4Mask  mask,
const Ipv4Address  addr 
)

Initialise the base network, mask and address for the generator.

Internal:
The first call to NextAddress() or GetAddress() will return the value passed in.
Parameters
netThe network for the base Ipv4Address
maskThe network mask of the base Ipv4Address
addrThe base address used for initialization

Definition at line 238 of file ipv4-address-generator.cc.

References ns3::Ipv4AddressGeneratorImpl::NetworkState::addr, ns3::Ipv4Address::Get(), ns3::Ipv4Mask::Get(), m_netTable, MaskToIndex(), ns3::Ipv4AddressGeneratorImpl::NetworkState::network, NS_ABORT_MSG_UNLESS, NS_LOG_FUNCTION, and ns3::Ipv4AddressGeneratorImpl::NetworkState::shift.

+ Here is the call graph for this function:

void ns3::Ipv4AddressGeneratorImpl::InitAddress ( const Ipv4Address  addr,
const Ipv4Mask  mask 
)

Set the address for the given mask.

Internal:
Parameters
addrThe address to set for the current mask
maskThe Ipv4Mask whose address is to be set

Definition at line 301 of file ipv4-address-generator.cc.

References ns3::Ipv4AddressGeneratorImpl::NetworkState::addr, ns3::Ipv4Address::Get(), m_netTable, MaskToIndex(), NS_ABORT_MSG_UNLESS, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

uint32_t ns3::Ipv4AddressGeneratorImpl::MaskToIndex ( Ipv4Mask  mask) const
private

Create an index number for the network mask.

Internal:
Parameters
maskthe mask to index
Returns
an index

Definition at line 452 of file ipv4-address-generator.cc.

References ns3::Ipv4Mask::Get(), N_BITS, NS_ABORT_MSG_UNLESS, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

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:

Ipv4Address ns3::Ipv4AddressGeneratorImpl::NextAddress ( const Ipv4Mask  mask)

Allocate the next Ipv4Address for the configured network and mask.

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

Definition at line 328 of file ipv4-address-generator.cc.

References AddAllocated(), ns3::Ipv4AddressGeneratorImpl::NetworkState::addr, m_netTable, MaskToIndex(), NS_ABORT_MSG_UNLESS, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Ipv4Address ns3::Ipv4AddressGeneratorImpl::NextNetwork ( const Ipv4Mask  mask)

Get the next network according to the given Ipv4Mask.

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

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

Parameters
maskThe Ipv4Mask used to set the next network
Returns
the IPv4 address of the next network

Definition at line 282 of file ipv4-address-generator.cc.

References m_netTable, MaskToIndex(), ns3::Ipv4AddressGeneratorImpl::NetworkState::network, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::Ipv4AddressGeneratorImpl::TestMode ( void  )

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

Internal:

Definition at line 445 of file ipv4-address-generator.cc.

References m_test, and NS_LOG_FUNCTION.

Member Data Documentation

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

/internal contained of allocated addresses

Definition at line 182 of file ipv4-address-generator.cc.

Referenced by AddAllocated(), and Reset().

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

/internal the available networks

Definition at line 169 of file ipv4-address-generator.cc.

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

bool ns3::Ipv4AddressGeneratorImpl::m_test
private

/internal test mode (if true)

Definition at line 183 of file ipv4-address-generator.cc.

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

const uint32_t ns3::Ipv4AddressGeneratorImpl::MOST_SIGNIFICANT_BIT = 0x80000000
staticprivate

/internal MSB set to 1

Definition at line 145 of file ipv4-address-generator.cc.

Referenced by Reset().

const uint32_t ns3::Ipv4AddressGeneratorImpl::N_BITS = 32
staticprivate

/internal the number of bits in the address

Definition at line 144 of file ipv4-address-generator.cc.

Referenced by MaskToIndex(), and Reset().


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