A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::Ipv6InterfaceContainer Class Reference

Keep track of a set of IPv6 interfaces. More...

#include "ipv6-interface-container.h"

+ Collaboration diagram for ns3::Ipv6InterfaceContainer:

Public Types

typedef std::vector< std::pair< Ptr< Ipv6 >, uint32_t > >::const_iterator Iterator
 Container Const Iterator for pairs of Ipv6 smart pointer / Interface Index.
 

Public Member Functions

 Ipv6InterfaceContainer ()
 Constructor.
 
void Add (const Ipv6InterfaceContainer &c)
 Fusion with another Ipv6InterfaceContainer.
 
void Add (Ptr< Ipv6 > ipv6, uint32_t interface)
 Add a couple IPv6/interface.
 
void Add (std::string ipv6Name, uint32_t interface)
 Add a couple of name/interface.
 
Iterator Begin () const
 Get an iterator which refers to the first pair in the container.
 
Iterator End () const
 Get an iterator which indicates past-the-last Node in the container.
 
std::pair< Ptr< Ipv6 >, uint32_tGet (uint32_t i) const
 Get the std::pair of an Ptr<Ipv6> and interface stored at the location specified by the index.
 
Ipv6Address GetAddress (uint32_t i, uint32_t j) const
 Get the address for the specified index.
 
uint32_t GetInterfaceIndex (uint32_t i) const
 Get the interface index for the specified node index.
 
Ipv6Address GetLinkLocalAddress (Ipv6Address address)
 Get the link-local address for the node with the specified global address.
 
Ipv6Address GetLinkLocalAddress (uint32_t i)
 Get the link-local address for the specified index.
 
uint32_t GetN () const
 
void SetDefaultRoute (uint32_t i, Ipv6Address routerAddr)
 Set the default route for the specified index.
 
void SetDefaultRoute (uint32_t i, uint32_t router)
 Set the default route for the specified index.
 
void SetDefaultRouteInAllNodes (Ipv6Address routerAddr)
 Set the default route for all the devices (except the router itself).
 
void SetDefaultRouteInAllNodes (uint32_t router)
 Set the default route for all the devices (except the router itself).
 
void SetForwarding (uint32_t i, bool state)
 Set the state of the stack (act as a router or as an host) for the specified index.
 

Private Types

typedef std::vector< std::pair< Ptr< Ipv6 >, uint32_t > > InterfaceVector
 Container for pairs of Ipv6 smart pointer / Interface Index.
 

Private Attributes

InterfaceVector m_interfaces
 List of IPv6 stack and interfaces index.
 

Detailed Description

Keep track of a set of IPv6 interfaces.

Definition at line 39 of file ipv6-interface-container.h.

Member Typedef Documentation

◆ InterfaceVector

typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> > ns3::Ipv6InterfaceContainer::InterfaceVector
private

Container for pairs of Ipv6 smart pointer / Interface Index.

Definition at line 231 of file ipv6-interface-container.h.

◆ Iterator

typedef std::vector<std::pair<Ptr<Ipv6>,uint32_t>>::const_iterator ns3::Ipv6InterfaceContainer::Iterator

Container Const Iterator for pairs of Ipv6 smart pointer / Interface Index.

Definition at line 45 of file ipv6-interface-container.h.

Constructor & Destructor Documentation

◆ Ipv6InterfaceContainer()

ns3::Ipv6InterfaceContainer::Ipv6InterfaceContainer ( )

Constructor.

Definition at line 32 of file ipv6-interface-container.cc.

Member Function Documentation

◆ Add() [1/3]

void ns3::Ipv6InterfaceContainer::Add ( const Ipv6InterfaceContainer c)

Fusion with another Ipv6InterfaceContainer.

Parameters
ccontainer

Definition at line 82 of file ipv6-interface-container.cc.

References m_interfaces.

◆ Add() [2/3]

void ns3::Ipv6InterfaceContainer::Add ( Ptr< Ipv6 ipv6,
uint32_t  interface 
)

Add a couple IPv6/interface.

Parameters
ipv6IPv6 address
interfaceinterface index

Definition at line 69 of file ipv6-interface-container.cc.

References m_interfaces.

Referenced by ns3::Ipv6AddressHelper::Assign(), ns3::CsmaStarHelper::AssignIpv6Addresses(), ns3::PointToPointDumbbellHelper::AssignIpv6Addresses(), ns3::PointToPointGridHelper::AssignIpv6Addresses(), ns3::PointToPointStarHelper::AssignIpv6Addresses(), and RadvdTestCase::DoRun().

+ Here is the caller graph for this function:

◆ Add() [3/3]

void ns3::Ipv6InterfaceContainer::Add ( std::string  ipv6Name,
uint32_t  interface 
)

Add a couple of name/interface.

Parameters
ipv6Namename of a node
interfaceinterface index to add

Definition at line 75 of file ipv6-interface-container.cc.

References m_interfaces.

◆ Begin()

Ipv6InterfaceContainer::Iterator ns3::Ipv6InterfaceContainer::Begin ( ) const

Get an iterator which refers to the first pair in the container.

Pairs can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the iterator method and is typically used in a for-loop to run through the pairs

for (i = container.Begin (); i != container.End (); ++i)
{
std::pair<Ptr<Ipv6>, uint32_t> pair = *i;
method (pair.first, pair.second); // use the pair
}
std::vector< std::pair< Ptr< Ipv6 >, uint32_t > >::const_iterator Iterator
Container Const Iterator for pairs of Ipv6 smart pointer / Interface Index.
Returns
an iterator which refers to the first pair in the container.

Definition at line 37 of file ipv6-interface-container.cc.

References m_interfaces.

Referenced by ns3::PointToPointDumbbellHelper::AssignIpv6Addresses(), ns3::AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(), and ns3::PcapHelperForIpv6::EnablePcapIpv6().

+ Here is the caller graph for this function:

◆ End()

Ipv6InterfaceContainer::Iterator ns3::Ipv6InterfaceContainer::End ( ) const

Get an iterator which indicates past-the-last Node in the container.

Nodes can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the iterator method and is typically used in a for-loop to run through the Nodes

for (i = container.Begin (); i != container.End (); ++i)
{
std::pair<Ptr<Ipv6>, uint32_t> pair = *i;
method (pair.first, pair.second); // use the pair
}
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Returns
an iterator which indicates an ending condition for a loop.

Definition at line 43 of file ipv6-interface-container.cc.

References m_interfaces.

Referenced by ns3::AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(), and ns3::PcapHelperForIpv6::EnablePcapIpv6().

+ Here is the caller graph for this function:

◆ Get()

std::pair< Ptr< Ipv6 >, uint32_t > ns3::Ipv6InterfaceContainer::Get ( uint32_t  i) const

Get the std::pair of an Ptr<Ipv6> and interface stored at the location specified by the index.

Parameters
ithe index of the container entry to retrieve.
Returns
the std::pair of a Ptr<Ipv6> and an interface index
Note
The returned Ptr<Ipv6> cannot be used directly to fetch the Ipv6Interface using the returned index (the GetInterface () method is provided in class Ipv6L3Protocol, and not class Ipv6). An example usage is provided below.
...
std::pair<Ptr<Ipv6>, uint32_t> returnValue = c.Get (0);
Ptr<Ipv6> ipv6 = returnValue.first;
uint32_t index = returnValue.second;
Ptr<Ipv6Interface> iface = DynamicCast<Ipv6L3Protocol> (ipv6)->GetInterface (index);
Keep track of a set of IPv6 interfaces.
std::pair< Ptr< Ipv6 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv6> and interface stored at the location specified by the index.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77

Definition at line 91 of file ipv6-interface-container.cc.

References m_interfaces.

Referenced by FlushTest::DoRun(), ns3::NeighborCacheHelper::PopulateNeighborCache(), and NeighborCacheExample::Run().

+ Here is the caller graph for this function:

◆ GetAddress()

Ipv6Address ns3::Ipv6InterfaceContainer::GetAddress ( uint32_t  i,
uint32_t  j 
) const

◆ GetInterfaceIndex()

uint32_t ns3::Ipv6InterfaceContainer::GetInterfaceIndex ( uint32_t  i) const

Get the interface index for the specified node index.

Parameters
iindex of the node
Returns
interface index

Definition at line 55 of file ipv6-interface-container.cc.

References m_interfaces.

Referenced by RadvdTestCase::DoRun().

+ Here is the caller graph for this function:

◆ GetLinkLocalAddress() [1/2]

Ipv6Address ns3::Ipv6InterfaceContainer::GetLinkLocalAddress ( Ipv6Address  address)

Get the link-local address for the node with the specified global address.

Parameters
addressthe address to find.
Returns
the link-local address, or "::" if the interface has no link local address.

Definition at line 251 of file ipv6-interface-container.cc.

References ns3::Ipv6InterfaceAddress::GetAddress(), ns3::Ipv6Address::GetAny(), ns3::Ipv6InterfaceAddress::GetScope(), ns3::Ipv6InterfaceAddress::LINKLOCAL, m_interfaces, and NS_ASSERT_MSG.

+ Here is the call graph for this function:

◆ GetLinkLocalAddress() [2/2]

Ipv6Address ns3::Ipv6InterfaceContainer::GetLinkLocalAddress ( uint32_t  i)

Get the link-local address for the specified index.

Parameters
iindex
Returns
the link-local address, or "::" if the interface has no link local address.

Definition at line 235 of file ipv6-interface-container.cc.

References ns3::Ipv6InterfaceAddress::GetAddress(), ns3::Ipv6Address::GetAny(), ns3::Ipv6InterfaceAddress::GetScope(), ns3::Ipv6InterfaceAddress::LINKLOCAL, and m_interfaces.

Referenced by SetDefaultRoute(), and SetDefaultRouteInAllNodes().

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

◆ GetN()

uint32_t ns3::Ipv6InterfaceContainer::GetN ( ) const
Returns
the number of Ptr<Ipv6> and interface pairs stored in this Ipv6InterfaceContainer.

Pairs can be retrieved from the container in two ways. First, directly by an index into the container, and second, using an iterator. This method is used in the direct method and is typically used to define an ending condition in a for-loop that runs through the stored Nodes

uint32_t nNodes = container.GetN ();
for (uint32_t i = 0 i < nNodes; ++i)
{
std::pair<Ptr<Ipv6>, uint32_t> pair = container.Get (i);
method (pair.first, pair.second); // use the pair
}

Definition at line 49 of file ipv6-interface-container.cc.

References m_interfaces.

Referenced by ThreeGppHttpObjectTestCase::CreateSimpleInternetNode(), and ns3::NeighborCacheHelper::PopulateNeighborCache().

+ Here is the caller graph for this function:

◆ SetDefaultRoute() [1/2]

void ns3::Ipv6InterfaceContainer::SetDefaultRoute ( uint32_t  i,
Ipv6Address  routerAddr 
)

Set the default route for the specified index.

Note that the route will be set to the link-local address of the node with the specified address.

Parameters
iindex
routerAddrthe default router address

Definition at line 195 of file ipv6-interface-container.cc.

References GetLinkLocalAddress(), ns3::Ipv6StaticRoutingHelper::GetStaticRouting(), m_interfaces, and NS_ASSERT_MSG.

+ Here is the call graph for this function:

◆ SetDefaultRoute() [2/2]

void ns3::Ipv6InterfaceContainer::SetDefaultRoute ( uint32_t  i,
uint32_t  router 
)

Set the default route for the specified index.

Parameters
iindex
routerthe default router

Definition at line 173 of file ipv6-interface-container.cc.

References ns3::Ipv6Address::GetAny(), GetLinkLocalAddress(), ns3::Ipv6StaticRoutingHelper::GetStaticRouting(), m_interfaces, and NS_ASSERT_MSG.

+ Here is the call graph for this function:

◆ SetDefaultRouteInAllNodes() [1/2]

void ns3::Ipv6InterfaceContainer::SetDefaultRouteInAllNodes ( Ipv6Address  routerAddr)

Set the default route for all the devices (except the router itself).

Note that the route will be set to the link-local address of the node with the specified address.

Parameters
routerAddrthe default router address

Definition at line 131 of file ipv6-interface-container.cc.

References ns3::Ipv6StaticRoutingHelper::GetStaticRouting(), m_interfaces, and NS_ASSERT_MSG.

+ Here is the call graph for this function:

◆ SetDefaultRouteInAllNodes() [2/2]

void ns3::Ipv6InterfaceContainer::SetDefaultRouteInAllNodes ( uint32_t  router)

Set the default route for all the devices (except the router itself).

Parameters
routerthe default router index

Definition at line 104 of file ipv6-interface-container.cc.

References ns3::Ipv6Address::GetAny(), GetLinkLocalAddress(), ns3::Ipv6StaticRoutingHelper::GetStaticRouting(), m_interfaces, and NS_ASSERT_MSG.

Referenced by ns3::NoBackhaulEpcHelper::NoBackhaulEpcHelper(), IcmpV6TimeExceedTestCase::DoRun(), Ipv6RipngTest::DoRun(), Ipv6RipngCountToInfinityTest::DoRun(), LteIpv6RoutingTestCase::DoRun(), and NeighborCacheExample::Run().

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

◆ SetForwarding()

void ns3::Ipv6InterfaceContainer::SetForwarding ( uint32_t  i,
bool  state 
)

Set the state of the stack (act as a router or as an host) for the specified index.

This automatically sets all the node's interfaces to the same forwarding state.

Parameters
iindex
statetrue : is a router, false : is an host

Definition at line 97 of file ipv6-interface-container.cc.

References m_interfaces.

Referenced by ns3::NoBackhaulEpcHelper::NoBackhaulEpcHelper(), RadvdTestCase::DoRun(), IcmpV6TimeExceedTestCase::DoRun(), Ipv6RipngTest::DoRun(), Ipv6RipngCountToInfinityTest::DoRun(), Ipv6RipngSplitHorizonStrategyTest::DoRun(), LteIpv6RoutingTestCase::DoRun(), and NeighborCacheExample::Run().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_interfaces

InterfaceVector ns3::Ipv6InterfaceContainer::m_interfaces
private

List of IPv6 stack and interfaces index.

Definition at line 236 of file ipv6-interface-container.h.

Referenced by Add(), Begin(), End(), Get(), GetAddress(), GetInterfaceIndex(), GetLinkLocalAddress(), GetN(), SetDefaultRoute(), SetDefaultRouteInAllNodes(), and SetForwarding().


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