A Discrete-Event Network Simulator
API
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
ns3::Ipv4InterfaceContainer Class Reference

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

#include "ipv4-interface-container.h"

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. More...
 

Public Member Functions

 Ipv4InterfaceContainer ()
 Create an empty Ipv4InterfaceContainer. More...
 
void Add (const Ipv4InterfaceContainer &other)
 Concatenate the entries in the other container with ours. More...
 
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. More...
 
void Add (std::pair< Ptr< Ipv4 >, uint32_t > ipInterfacePair)
 Manually add an entry to the container consisting of a previously composed entry std::pair. More...
 
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. More...
 
Iterator Begin (void) const
 Get an iterator which refers to the first pair in the container. More...
 
Iterator End (void) const
 Get an iterator which indicates past-the-last Node in the container. More...
 
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. More...
 
Ipv4Address GetAddress (uint32_t i, uint32_t j=0) const
 
uint32_t GetN (void) const
 
void SetMetric (uint32_t i, uint16_t metric)
 Set a metric for the given interface. More...
 

Private Types

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

Private Attributes

InterfaceVector m_interfaces
 List of IPv4 stack and interfaces index. More...
 

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 54 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 213 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 60 of file ipv4-interface-container.h.

Constructor & Destructor Documentation

◆ Ipv4InterfaceContainer()

ns3::Ipv4InterfaceContainer::Ipv4InterfaceContainer ( )

Create an empty Ipv4InterfaceContainer.

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

Member Function Documentation

◆ Add() [1/4]

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

◆ 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 74 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 78 of file ipv4-interface-container.cc.

References Add().

◆ 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 83 of file ipv4-interface-container.cc.

References m_interfaces.

◆ Begin()

Ipv4InterfaceContainer::Iterator ns3::Ipv4InterfaceContainer::Begin ( void  ) 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
}
Returns
an iterator which refers to the first pair in the container.

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

References m_interfaces.

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

◆ End()

Ipv4InterfaceContainer::Iterator ns3::Ipv4InterfaceContainer::End ( void  ) 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
}
Returns
an iterator which indicates an ending condition for a loop.

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

References m_interfaces.

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

◆ 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 = ipv4->GetObject<Ipv4L3Protocol> ()->GetInterface (index);

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

References m_interfaces.

Referenced by ns3::PointToPointDumbbellHelper::AssignIpv4Addresses().

◆ 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 59 of file ipv4-interface-container.cc.

References m_interfaces.

Referenced by ns3::PointToPointEpcHelper::AddEnb(), ns3::EmuEpcHelper::AddEnb(), ns3::PointToPointEpcHelper::AddX2Interface(), BuildAppsTest(), ns3::olsr::Bug780Test::CreateNodes(), ThreeGppHttpObjectTestCase::CreateSimpleInternetNode(), WifiMsduAggregatorThroughputTest::DoRun(), WifiAcMappingTest::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), Ns3TcpNoDelayTestCase::DoRun(), Ns3TcpSocketTestCase1::DoRun(), NscTcpLossTestCase1::DoRun(), UdpClientServerTestCase::DoRun(), LenaCqaFfMacSchedulerTestCase1::DoRun(), LenaPssFfMacSchedulerTestCase1::DoRun(), LenaTdTbfqFfMacSchedulerTestCase1::DoRun(), LenaFdTbfqFfMacSchedulerTestCase1::DoRun(), Ns3TcpLossTestCase::DoRun(), Ns3TcpStateTestCase::DoRun(), LteX2HandoverTestCase::DoRun(), BriteTopologyFunctionTestCase::DoRun(), LenaTdTbfqFfMacSchedulerTestCase2::DoRun(), EpcS1uDlTestCase::DoRun(), LenaCqaFfMacSchedulerTestCase2::DoRun(), LenaPssFfMacSchedulerTestCase2::DoRun(), LenaFdTbfqFfMacSchedulerTestCase2::DoRun(), LteX2HandoverMeasuresTestCase::DoRun(), LteEpcE2eDataTestCase::DoRun(), UdpTraceClientServerTestCase::DoRun(), Ns3TcpSocketTestCase2::DoRun(), NscTcpLossTestCase2::DoRun(), EpcS1uUlTestCase::DoRun(), ns3::TcpGeneralTest::DoRun(), LteDistributedFfrAreaTestCase::DoRun(), Ns3TcpCwndTestCase2::DoRun(), CsmaPingTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), Ipv4DynamicGlobalRoutingTestCase::DoRun(), Ns3WimaxSchedulingTestCase::DoRunOnce(), Ns3WimaxSFTypeTestCase::DoRunOnce(), ns3::PointToPointStarHelper::GetHubIpv4Address(), ns3::CsmaStarHelper::GetHubIpv4Address(), ns3::PointToPointDumbbellHelper::GetLeftIpv4Address(), ns3::PointToPointDumbbellHelper::GetRightIpv4Address(), ns3::PointToPointStarHelper::GetSpokeIpv4Address(), ns3::CsmaStarHelper::GetSpokeIpv4Address(), MeshTest::InstallApplication(), HwmpProactiveRegressionTest::InstallApplications(), FlameRegressionTest::InstallApplications(), HwmpDoRfRegressionTest::InstallApplications(), HwmpSimplestRegressionTest::InstallApplications(), HwmpReactiveRegressionTest::InstallApplications(), AodvExample::InstallApplications(), DsdvManetExample::InstallApplications(), ns3::BsmApplication::ReceiveWavePacket(), RoutingExperiment::Run(), Experiment::Run(), and RoutingHelper::SetupRoutingMessages().

◆ GetN()

uint32_t ns3::Ipv4InterfaceContainer::GetN ( void  ) 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 53 of file ipv4-interface-container.cc.

References m_interfaces.

Referenced by ThreeGppHttpObjectTestCase::CreateSimpleInternetNode(), ns3::BsmApplication::GenerateWaveTraffic(), and ns3::BsmApplication::ReceiveWavePacket().

◆ 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 67 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 218 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: