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

holds a vector of std::pair of Ptr<Ipv4> and interface index. More...

#include "ipv4-interface-container.h"

+ Collaboration diagram for ns3::Ipv4InterfaceContainer:

Public Types

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

Public Member Functions

 Ipv4InterfaceContainer ()
 Create an empty Ipv4InterfaceContainer.
 
void Add (const Ipv4InterfaceContainer &other)
 Concatenate the entries in the other container with ours.
 
void Add (Ptr< Ipv4 > ipv4, uint32_t interface)
 Manually add an entry to the container consisting of the individual parts of an entry std::pair.
 
void Add (std::pair< Ptr< Ipv4 >, uint32_t > ipInterfacePair)
 Manually add an entry to the container consisting of a previously composed entry std::pair.
 
void Add (std::string ipv4Name, uint32_t interface)
 Manually add an entry to the container consisting of the individual parts of an entry std::pair.
 
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< Ipv4 >, uint32_tGet (uint32_t i) const
 Get the std::pair of an Ptr<Ipv4> and interface stored at the location specified by the index.
 
Ipv4Address GetAddress (uint32_t i, uint32_t j=0) const
 
uint32_t GetN () const
 
void SetMetric (uint32_t i, uint16_t metric)
 Set a metric for the given interface.
 

Private Types

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

Private Attributes

InterfaceVector m_interfaces
 List of IPv4 stack and interfaces index.
 

Detailed Description

holds a vector of std::pair of Ptr<Ipv4> and interface index.

Typically ns-3 Ipv4Interfaces are installed on devices using an Ipv4 address helper. The helper's Assign() method takes a NetDeviceContainer which holds some number of Ptr<NetDevice>. For each of the NetDevices in the NetDeviceContainer the helper will find the associated Ptr<Node> and Ptr<Ipv4>. It makes sure that an interface exists on the node for the device and then adds an Ipv4Address according to the address helper settings (incrementing the Ipv4Address somehow as it goes). The helper then converts the Ptr<Ipv4> and the interface index to a std::pair and adds them to a container – a container of this type.

The point is then to be able to implicitly associate an index into the original NetDeviceContainer (that identifies a particular net device) with an identical index into the Ipv4InterfaceContainer that has a std::pair with the Ptr<Ipv4> and interface index you need to play with the interface.

See also
Ipv4AddressHelper
Ipv4

Definition at line 55 of file ipv4-interface-container.h.

Member Typedef Documentation

◆ InterfaceVector

typedef std::vector<std::pair<Ptr<Ipv4>, uint32_t> > ns3::Ipv4InterfaceContainer::InterfaceVector
private

Container for pairs of Ipv4 smart pointer / Interface Index.

Definition at line 215 of file ipv4-interface-container.h.

◆ Iterator

typedef std::vector<std::pair<Ptr<Ipv4>,uint32_t>>::const_iterator ns3::Ipv4InterfaceContainer::Iterator

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

Definition at line 61 of file ipv4-interface-container.h.

Constructor & Destructor Documentation

◆ Ipv4InterfaceContainer()

ns3::Ipv4InterfaceContainer::Ipv4InterfaceContainer ( )

Create an empty Ipv4InterfaceContainer.

Definition at line 28 of file ipv4-interface-container.cc.

Member Function Documentation

◆ Add() [1/4]

void ns3::Ipv4InterfaceContainer::Add ( const Ipv4InterfaceContainer other)

Concatenate the entries in the other container with ours.

Parameters
othercontainer

Definition at line 33 of file ipv4-interface-container.cc.

References m_interfaces.

Referenced by Add(), ns3::Ipv4AddressHelper::Assign(), ns3::CsmaStarHelper::AssignIpv4Addresses(), ns3::PointToPointStarHelper::AssignIpv4Addresses(), ns3::PointToPointDumbbellHelper::AssignIpv4Addresses(), ns3::PointToPointGridHelper::AssignIpv4Addresses(), and ns3::DhcpHelper::InstallFixedAddress().

+ Here is the caller graph for this function:

◆ Add() [2/4]

void ns3::Ipv4InterfaceContainer::Add ( Ptr< Ipv4 ipv4,
uint32_t  interface 
)

Manually add an entry to the container consisting of the individual parts of an entry std::pair.

Parameters
ipv4pointer to Ipv4 object
interfaceinterface index of the Ipv4Interface to add to the container

Definition at line 76 of file ipv4-interface-container.cc.

References m_interfaces.

◆ Add() [3/4]

void ns3::Ipv4InterfaceContainer::Add ( std::pair< Ptr< Ipv4 >, uint32_t ipInterfacePair)

Manually add an entry to the container consisting of a previously composed entry std::pair.

Parameters
ipInterfacePairthe pair of a pointer to Ipv4 object and interface index of the Ipv4Interface to add to the container

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

References Add().

+ Here is the call graph for this function:

◆ Add() [4/4]

void ns3::Ipv4InterfaceContainer::Add ( std::string  ipv4Name,
uint32_t  interface 
)

Manually add an entry to the container consisting of the individual parts of an entry std::pair.

Parameters
ipv4Namestd:string referring to the saved name of an Ipv4 Object that has been previously named using the Object Name Service.
interfaceinterface index of the Ipv4Interface to add to the container

Definition at line 88 of file ipv4-interface-container.cc.

References m_interfaces.

◆ Begin()

Ipv4InterfaceContainer::Iterator ns3::Ipv4InterfaceContainer::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<Ipv4>, uint32_t> pair = *i;
method (pair.first, pair.second); // use the pair
}
std::vector< std::pair< Ptr< Ipv4 >, uint32_t > >::const_iterator Iterator
Container Const Iterator for pairs of Ipv4 smart pointer / Interface Index.
Returns
an iterator which refers to the first pair in the container.

Definition at line 42 of file ipv4-interface-container.cc.

References m_interfaces.

Referenced by ns3::AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(), and ns3::PcapHelperForIpv4::EnablePcapIpv4().

+ Here is the caller graph for this function:

◆ End()

Ipv4InterfaceContainer::Iterator ns3::Ipv4InterfaceContainer::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<Ipv4>, 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 48 of file ipv4-interface-container.cc.

References m_interfaces.

Referenced by ns3::AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(), and ns3::PcapHelperForIpv4::EnablePcapIpv4().

+ Here is the caller graph for this function:

◆ Get()

std::pair< Ptr< Ipv4 >, uint32_t > ns3::Ipv4InterfaceContainer::Get ( uint32_t  i) const

Get the std::pair of an Ptr<Ipv4> 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<Ipv4> and an interface index
Note
The returned Ptr<Ipv4> cannot be used directly to fetch the Ipv4Interface using the returned index (the GetInterface () method is provided in class Ipv4L3Protocol, and not class Ipv4). An example usage is provided below.
...
std::pair<Ptr<Ipv4>, uint32_t> returnValue = c.Get (0);
Ptr<Ipv4> ipv4 = returnValue.first;
uint32_t index = returnValue.second;
Ptr<Ipv4Interface> iface = DynamicCast<Ipv4L3Protocol> (ipv4)->GetInterface (index);
holds a vector of std::pair of Ptr<Ipv4> and interface index.
std::pair< Ptr< Ipv4 >, uint32_t > Get(uint32_t i) const
Get the std::pair of an Ptr<Ipv4> 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 95 of file ipv4-interface-container.cc.

References m_interfaces.

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

+ Here is the caller graph for this function:

◆ GetAddress()

Ipv4Address ns3::Ipv4InterfaceContainer::GetAddress ( uint32_t  i,
uint32_t  j = 0 
) const
Parameters
iindex of ipInterfacePair in container
jinterface address index (if interface has multiple addresses)
Returns
the IPv4 address of the j'th address of the interface corresponding to index i.

If the second parameter is omitted, the zeroth indexed address of the interface is returned. Unless IP aliasing is being used on the interface, the second parameter may typically be omitted.

Definition at line 60 of file ipv4-interface-container.cc.

References m_interfaces.

Referenced by ns3::NoBackhaulEpcHelper::NoBackhaulEpcHelper(), ns3::EmuEpcHelper::AddEnb(), ns3::PointToPointEpcHelper::AddEnb(), ns3::NoBackhaulEpcHelper::AddX2Interface(), BuildAppsTest(), ns3::olsr::Bug780Test::CreateNodes(), ThreeGppHttpObjectTestCase::CreateSimpleInternetNode(), BulkSendBasicTestCase::DoRun(), BulkSendSeqTsSizeTestCase::DoRun(), UdpClientServerTestCase::DoRun(), UdpTraceClientServerTestCase::DoRun(), BriteTopologyFunctionTestCase::DoRun(), PingTestCase::DoRun(), IcmpEchoReplyTestCase::DoRun(), IcmpTimeExceedTestCase::DoRun(), Ipv4DynamicGlobalRoutingTestCase::DoRun(), ns3::TcpGeneralTest::DoRun(), EpcS1uDlTestCase::DoRun(), EpcS1uUlTestCase::DoRun(), LenaCqaFfMacSchedulerTestCase1::DoRun(), LenaCqaFfMacSchedulerTestCase2::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), LenaFdTbfqFfMacSchedulerTestCase1::DoRun(), LenaFdTbfqFfMacSchedulerTestCase2::DoRun(), LteDistributedFfrAreaTestCase::DoRun(), LenaPssFfMacSchedulerTestCase1::DoRun(), LenaPssFfMacSchedulerTestCase2::DoRun(), LteRadioLinkFailureTestCase::DoRun(), LenaTdTbfqFfMacSchedulerTestCase1::DoRun(), LenaTdTbfqFfMacSchedulerTestCase2::DoRun(), LteEpcE2eDataTestCase::DoRun(), LteX2HandoverMeasuresTestCase::DoRun(), LteX2HandoverTestCase::DoRun(), NixVectorRoutingTest::DoRun(), CsmaPingTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), Ns3TcpCubicTestCase::DoRun(), Ns3TcpLossTestCase::DoRun(), Ns3TcpNoDelayTestCase::DoRun(), Ns3TcpSocketTestCaseP2P::DoRun(), Ns3TcpSocketTestCaseCsma::DoRun(), Ns3TcpStateTestCase::DoRun(), WifiAcMappingTest::DoRun(), Issue211Test::DoRun(), WifiMsduAggregatorThroughputTest::DoRun(), Ns3WimaxSFTypeTestCase::DoRunOnce(), Ns3WimaxSchedulingTestCase::DoRunOnce(), experiment(), ns3::CsmaStarHelper::GetHubIpv4Address(), ns3::PointToPointStarHelper::GetHubIpv4Address(), ns3::PointToPointDumbbellHelper::GetLeftIpv4Address(), ns3::PointToPointDumbbellHelper::GetRightIpv4Address(), ns3::CsmaStarHelper::GetSpokeIpv4Address(), ns3::PointToPointStarHelper::GetSpokeIpv4Address(), LteAggregationThroughputScaleTestCase::GetThroughput(), MeshTest::InstallApplication(), AodvExample::InstallApplications(), DsdvManetExample::InstallApplications(), HwmpProactiveRegressionTest::InstallApplications(), HwmpReactiveRegressionTest::InstallApplications(), HwmpSimplestRegressionTest::InstallApplications(), HwmpDoRfRegressionTest::InstallApplications(), FlameRegressionTest::InstallApplications(), RoutingExperiment::Run(), NeighborCacheExample::Run(), and Experiment::Run().

+ Here is the caller graph for this function:

◆ GetN()

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

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<Ipv4>, uint32_t> pair = container.Get (i);
method (pair.first, pair.second); // use the pair
}
Returns
the number of Ptr<Node> stored in this container.

Definition at line 54 of file ipv4-interface-container.cc.

References m_interfaces.

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

+ Here is the caller graph for this function:

◆ SetMetric()

void ns3::Ipv4InterfaceContainer::SetMetric ( uint32_t  i,
uint16_t  metric 
)

Set a metric for the given interface.

Parameters
iInterface index
metricthe interface metric

Definition at line 68 of file ipv4-interface-container.cc.

References m_interfaces.

Member Data Documentation

◆ m_interfaces

InterfaceVector ns3::Ipv4InterfaceContainer::m_interfaces
private

List of IPv4 stack and interfaces index.

Definition at line 220 of file ipv4-interface-container.h.

Referenced by Add(), Begin(), End(), Get(), GetAddress(), GetN(), and SetMetric().


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