A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
 

Public Member Functions

 Ipv4InterfaceContainer ()
 
void Add (Ipv4InterfaceContainer other)
 
void Add (Ptr< Ipv4 > ipv4, uint32_t interface)
 
void Add (std::pair< Ptr< Ipv4 >, uint32_t > ipInterfacePair)
 
void Add (std::string ipv4Name, uint32_t interface)
 
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
 
Ipv4Address GetAddress (uint32_t i, uint32_t j=0) const
 
uint32_t GetN (void) const
 
void SetMetric (uint32_t i, uint16_t metric)
 

Private Types

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

Private Attributes

InterfaceVector m_interfaces
 

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 32 of file ipv4-interface-container.h.

Constructor & Destructor Documentation

ns3::Ipv4InterfaceContainer::Ipv4InterfaceContainer ( )

Create an empty Ipv4InterfaceContainer.

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

Member Function Documentation

void ns3::Ipv4InterfaceContainer::Add ( Ipv4InterfaceContainer  other)
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
See Also
Ipv4InterfaceContainer

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

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
See Also
Ipv4InterfaceContainer

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

References Add().

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
See Also
Ipv4InterfaceContainer

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

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

Ipv4InterfaceContainer::Iterator i;
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 21 of file ipv4-interface-container.cc.

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

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

NodeContainer::Iterator i;
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 27 of file ipv4-interface-container.cc.

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

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 entery to retrieve.
See Also
Ipv4InterfaceContainer

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

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

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

Referenced by ns3::EpcHelper::AddEnb(), ns3::EpcHelper::AddX2Interface(), ns3::aodv::Bug772ChainTest::CreateDevices(), ns3::aodv::ChainRegressionTest::CreateDevices(), ns3::olsr::Bug780Test::CreateNodes(), ns3::AnimationInterfaceTestCase::DoRun(), ns3::LenaTdTbfqFfMacSchedulerTestCase1::DoRun(), WifiMsduAggregatorThroughputTest::DoRun(), ns3::LenaFdTbfqFfMacSchedulerTestCase1::DoRun(), ns3::LenaPssFfMacSchedulerTestCase1::DoRun(), UdpClientServerTestCase::DoRun(), Ns3TcpNoDelayTestCase::DoRun(), Ns3TcpSocketTestCase1::DoRun(), NscTcpLossTestCase1::DoRun(), DynamicGlobalRoutingTestCase::DoRun(), ns3::LteX2HandoverTestCase::DoRun(), Ns3TcpLossTestCase::DoRun(), Ns3TcpStateTestCase::DoRun(), ns3::LenaPssFfMacSchedulerTestCase2::DoRun(), ns3::LenaTdTbfqFfMacSchedulerTestCase2::DoRun(), ns3::LenaFdTbfqFfMacSchedulerTestCase2::DoRun(), ns3::EpcS1uDlTestCase::DoRun(), Ns3TcpInteroperabilityTestCase::DoRun(), ns3::LteEpcE2eDataTestCase::DoRun(), ns3::BriteTopologyFunctionTestCase::DoRun(), UdpTraceClientServerTestCase::DoRun(), Ns3TcpSocketTestCase2::DoRun(), NscTcpLossTestCase2::DoRun(), Ns3TcpCwndTestCase1::DoRun(), UdpEchoClientSetFillTestCase::DoRun(), ns3::EpcS1uUlTestCase::DoRun(), Ns3TcpCwndTestCase2::DoRun(), CsmaOneSubnetTestCase::DoRun(), CsmaPingTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), ns3::PointToPointStarHelper::GetHubIpv4Address(), ns3::CsmaStarHelper::GetHubIpv4Address(), ns3::PointToPointDumbbellHelper::GetLeftIpv4Address(), ns3::PointToPointDumbbellHelper::GetRightIpv4Address(), ns3::PointToPointStarHelper::GetSpokeIpv4Address(), ns3::CsmaStarHelper::GetSpokeIpv4Address(), and MeshTest::InstallApplication().

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


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