This generator assigns addresses sequentially from a provided network address; used in topology code.
More...
#include "ipv4-address-generator.h"
This generator assigns addresses sequentially from a provided network address; used in topology code.
- Note
- BEWARE: this class acts as a Singleton. In other terms, two different instances of Ipv4AddressGenerator will pick IPv4 numbers from the same pool. Changing the network in one of them will also change the network in the other instances.
Definition at line 39 of file ipv4-address-generator.h.
static bool ns3::Ipv4AddressGenerator::AddAllocated |
( |
const Ipv4Address |
addr | ) |
|
|
static |
Add the Ipv4Address to the list of IPv4 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
-
- Returns
- true on success
Referenced by ns3::Ipv4AddressHelper::NewAddress().
Get the Ipv4Address 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
-
mask | The Ipv4Mask for the current network |
- Returns
- the IPv4 address
Get the current network of the given Ipv4Mask.
Does not change the internal state; this just peeks at the current network
- Parameters
-
mask | The Ipv4Mask for the current network |
- Returns
- the IPv4 address of the current network
Initialise the base network, mask and address for the generator.
The first call to NextAddress() or GetAddress() will return the value passed in.
- Parameters
-
net | The network for the base Ipv4Address |
mask | The network mask of the base Ipv4Address |
addr | The base address used for initialization |
static void ns3::Ipv4AddressGenerator::InitAddress |
( |
const Ipv4Address |
addr, |
|
|
const Ipv4Mask |
mask |
|
) |
| |
|
static |
Set the address for the given mask.
- Parameters
-
addr | The address to set for the current mask |
mask | The Ipv4Mask whose address is to be set |
Allocate the next Ipv4Address for the configured network and mask.
This operation is a post-increment, meaning that the first address allocated will be the one that was initially configured.
- Parameters
-
mask | The Ipv4Mask for the current network |
- Returns
- the IPv4 address
Get the next network according to the given Ipv4Mask.
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
-
mask | The Ipv4Mask used to set the next network |
- Returns
- the IPv4 address of the next network
static void ns3::Ipv4AddressGenerator::Reset |
( |
void |
| ) |
|
|
static |
static void ns3::Ipv4AddressGenerator::TestMode |
( |
void |
| ) |
|
|
static |
Used to turn off fatal errors and assertions, for testing.
The documentation for this class was generated from the following file: