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

Helper class to auto-assign global IPv6 unicast addresses. More...

#include "ipv6-address-helper.h"

+ Collaboration diagram for ns3::Ipv6AddressHelper:

Public Member Functions

 Ipv6AddressHelper ()
 Constructor. More...
 
 Ipv6AddressHelper (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
 Constructor. More...
 
Ipv6InterfaceContainer Assign (const NetDeviceContainer &c)
 Allocate an Ipv6InterfaceContainer with auto-assigned addresses. More...
 
Ipv6InterfaceContainer Assign (const NetDeviceContainer &c, std::vector< bool > withConfiguration)
 Allocate an Ipv6InterfaceContainer, and control whether the interfaces have addresses auto-assigned to them. More...
 
Ipv6InterfaceContainer Assign (const NetDeviceContainer &c, std::vector< bool > withConfiguration, std::vector< bool > onLink)
 Allocate an Ipv6InterfaceContainer, and control whether the interfaces have addresses auto-assigned to them. More...
 
Ipv6InterfaceContainer AssignWithoutAddress (const NetDeviceContainer &c)
 Allocate an Ipv6InterfaceContainer but do not assign any IPv6 addresses. More...
 
Ipv6InterfaceContainer AssignWithoutOnLink (const NetDeviceContainer &c)
 Allocate an Ipv6InterfaceContainer with auto-assigned addresses, but do not set the on-link property for the network. More...
 
Ipv6Address NewAddress ()
 Allocate a new Ipv6Address with interface ID equal to the next one in the underlying generator. More...
 
Ipv6Address NewAddress (Address addr)
 Allocate a new Ipv6Address. More...
 
void NewNetwork ()
 Allocate a new network. More...
 
void SetBase (Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
 Set the base network number, network prefix, and base interface ID. More...
 

Private Attributes

Ipv6Address m_address
 host address More...
 
Ipv6Address m_base
 host base address More...
 
Ipv6Address m_network
 network address More...
 
Ipv6Prefix m_prefix
 prefix length More...
 

Detailed Description

Helper class to auto-assign global IPv6 unicast addresses.

Assign global unicast IPv6 addresses based on RFC 4291 definition.

| n bits | 64-n bits | 64 bits | +----------------------—+--------—+-------------------------—+ | global routing prefix | subnet ID | interface ID | +----------------------—+--------—+-------------------------—+ <----------—network-------------—>

11111111111111111111111111000000000000 <—prefix of length n—>

This class handles the following quantities. 1) The "network" which covers the 64 bit union of the global routing prefix and the subnet ID 2) the "prefix" length "n" which demarcates the global routing prefix and the subnet ID 3) the "base" which is the initial 64-bit interface ID.

The names "network", "prefix" and "base" are chosen to be consistent with a similar address helper for IPv4.

This helper class allows users to set or reset the network and interface components, and call "NewAddress ()" to sequentially increment the interface ID, and call "NewNetwork ()" to allocate a new subnet (until the subnet ID quantity rolls over). A call to NewNetwork () that causes the subnet ID to roll over will trigger an assertion.

By default, the prefix is 32 bits and the network is '2001:db8::/32' (RFC 5156 section 2.6 Documentation prefix). The prefix may range from length 0 to 64, with the value 64 having a special meaning that no subnet ID boundary is enforced (equivalent to value 0).

There are two variants of interface ID supported (RFC 4291, Sec. 2.5.1) The default is a "local" scope, but a "universal" scoped ID may be formed by calling "NewAddress (Address addr)" with a 48-bit MAC address. If this method is called, the addressed returned will include a modified EUI-64-format identifier created from the MAC address as specified in RFC 4291.

BEWARE: the underlying implementation acts as a Singleton. In other terms, two different instances of Ipv6AddressHelper will pick IPv6 numbers from the same pool. Changing the network in one of them will also change the network in the other instances.

Definition at line 83 of file ipv6-address-helper.h.

Constructor & Destructor Documentation

◆ Ipv6AddressHelper() [1/2]

ns3::Ipv6AddressHelper::Ipv6AddressHelper ( )

Constructor.

Definition at line 42 of file ipv6-address-helper.cc.

References m_address, m_base, m_network, m_prefix, and NS_LOG_FUNCTION.

◆ Ipv6AddressHelper() [2/2]

ns3::Ipv6AddressHelper::Ipv6AddressHelper ( Ipv6Address  network,
Ipv6Prefix  prefix,
Ipv6Address  base = Ipv6Address("::1") 
)

Constructor.

Parameters
networkThe IPv6 network
prefixThe prefix
baseThe base interface ID

Definition at line 51 of file ipv6-address-helper.cc.

References ns3::Ipv6Address::CombinePrefix(), ns3::Ipv6Address::GetZero(), m_address, m_base, m_network, m_prefix, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Member Function Documentation

◆ Assign() [1/3]

◆ Assign() [2/3]

Ipv6InterfaceContainer ns3::Ipv6AddressHelper::Assign ( const NetDeviceContainer c,
std::vector< bool >  withConfiguration 
)

Allocate an Ipv6InterfaceContainer, and control whether the interfaces have addresses auto-assigned to them.

Parameters
cnetdevice container
withConfigurationa vector of values for which, for a given device, true : interface automatically addressed, false : no automatic address
Returns
newly created Ipv6InterfaceContainer

Definition at line 228 of file ipv6-address-helper.cc.

References Assign(), ns3::NetDeviceContainer::GetN(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Assign() [3/3]

Ipv6InterfaceContainer ns3::Ipv6AddressHelper::Assign ( const NetDeviceContainer c,
std::vector< bool >  withConfiguration,
std::vector< bool >  onLink 
)

Allocate an Ipv6InterfaceContainer, and control whether the interfaces have addresses auto-assigned to them.

Parameters
cnetdevice container
withConfigurationa vector of values for which, for a given device, true : interface automatically addressed, false : no automatic address
onLinka vector of values for which, for a given device, true : on-link property added, false : network is not on-link Meaningful only if the address is automatically assigned.
Returns
newly created Ipv6InterfaceContainer

Definition at line 236 of file ipv6-address-helper.cc.

References ns3::Ipv6InterfaceContainer::Add(), ns3::TrafficControlHelper::Default(), ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), ns3::Object::GetObject(), ns3::TrafficControlHelper::Install(), NewAddress(), NS_ASSERT_MSG, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

◆ AssignWithoutAddress()

Ipv6InterfaceContainer ns3::Ipv6AddressHelper::AssignWithoutAddress ( const NetDeviceContainer c)

Allocate an Ipv6InterfaceContainer but do not assign any IPv6 addresses.

This method is used when IPv6 address assignment may occur later (such as dynamic address assignment)

Equivalent to AssignWithoutAddress (c, std::vector<bool> of false);

Parameters
cnetdevice container
Returns
newly created Ipv6InterfaceContainer

Definition at line 304 of file ipv6-address-helper.cc.

References Assign(), ns3::NetDeviceContainer::GetN(), and NS_LOG_FUNCTION.

Referenced by RadvdTestCase::DoRun(), Ipv6DadTest::DoRun(), Ipv6RipngTest::DoRun(), Ipv6RipngCountToInfinityTest::DoRun(), and Ipv6RipngSplitHorizonStrategyTest::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AssignWithoutOnLink()

Ipv6InterfaceContainer ns3::Ipv6AddressHelper::AssignWithoutOnLink ( const NetDeviceContainer c)

Allocate an Ipv6InterfaceContainer with auto-assigned addresses, but do not set the on-link property for the network.

This method will assign a valid global address to the interface but the routing will not consider the network as "on-link".

Parameters
cnetdevice container
Returns
newly created Ipv6InterfaceContainer

Definition at line 312 of file ipv6-address-helper.cc.

References Assign(), ns3::NetDeviceContainer::GetN(), and NS_LOG_FUNCTION.

Referenced by RadvdTestCase::DoRun(), Ipv6RipngTest::DoRun(), Ipv6RipngCountToInfinityTest::DoRun(), and Ipv6RipngSplitHorizonStrategyTest::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NewAddress() [1/2]

Ipv6Address ns3::Ipv6AddressHelper::NewAddress ( )

Allocate a new Ipv6Address with interface ID equal to the next one in the underlying generator.

Returns
newly created Ipv6Address

Definition at line 129 of file ipv6-address-helper.cc.

References ns3::Ipv6AddressGenerator::AddAllocated(), ns3::Ipv6Address::CombinePrefix(), ns3::Ipv6Address::GetBytes(), ns3::Ipv6Address::GetZero(), m_address, m_network, m_prefix, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Referenced by Assign().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NewAddress() [2/2]

Ipv6Address ns3::Ipv6AddressHelper::NewAddress ( Address  addr)

Allocate a new Ipv6Address.

If a Mac48Address is passed in, an Ipv6 autoconfigured address according to the current subnet prefix is returned. If something other than Mac48 address is passed in, the program will terminate.

Parameters
addraddress used to generate the interface ID of the IPv6 address
Returns
newly created Ipv6Address

Definition at line 89 of file ipv6-address-helper.cc.

References ns3::Ipv6AddressGenerator::AddAllocated(), first::address, ns3::Mac16Address::ConvertFrom(), ns3::Mac48Address::ConvertFrom(), ns3::Mac64Address::ConvertFrom(), ns3::Mac8Address::ConvertFrom(), ns3::Mac16Address::IsMatchingType(), ns3::Mac48Address::IsMatchingType(), ns3::Mac64Address::IsMatchingType(), ns3::Mac8Address::IsMatchingType(), m_network, ns3::Ipv6Address::MakeAutoconfiguredAddress(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.

Referenced by IpAddressHelperTestCasev6::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NewNetwork()

void ns3::Ipv6AddressHelper::NewNetwork ( )

Allocate a new network.

This method will cause the subnet prefix to increment, for future network IDs, and resets the interface ID to the previously used base.

Definition at line 179 of file ipv6-address-helper.cc.

References ns3::Ipv6Address::GetBytes(), ns3::Ipv6Prefix::GetPrefixLength(), m_address, m_base, m_network, m_prefix, and NS_LOG_FUNCTION.

Referenced by IpAddressHelperTestCasev6::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetBase()

Member Data Documentation

◆ m_address

Ipv6Address ns3::Ipv6AddressHelper::m_address
private

host address

Definition at line 204 of file ipv6-address-helper.h.

Referenced by Ipv6AddressHelper(), NewAddress(), NewNetwork(), and SetBase().

◆ m_base

Ipv6Address ns3::Ipv6AddressHelper::m_base
private

host base address

Definition at line 205 of file ipv6-address-helper.h.

Referenced by Ipv6AddressHelper(), NewNetwork(), and SetBase().

◆ m_network

Ipv6Address ns3::Ipv6AddressHelper::m_network
private

network address

Definition at line 202 of file ipv6-address-helper.h.

Referenced by Ipv6AddressHelper(), NewAddress(), NewNetwork(), and SetBase().

◆ m_prefix

Ipv6Prefix ns3::Ipv6AddressHelper::m_prefix
private

prefix length

Definition at line 203 of file ipv6-address-helper.h.

Referenced by Ipv6AddressHelper(), NewAddress(), NewNetwork(), and SetBase().


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