Align helper API use of Install()
This commit is contained in:
@@ -166,7 +166,7 @@ main (int argc, char *argv[])
|
||||
"Bounds", Rectangle (0, 1000, 0, 1000),
|
||||
"Speed", ConstantVariable (2000),
|
||||
"Pause", ConstantVariable (0.2));
|
||||
mobility.Layout (backbone);
|
||||
mobility.Install (backbone);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -178,17 +178,19 @@ main (int argc, char *argv[])
|
||||
// the "172.16 address space
|
||||
ipAddrs.SetBase ("172.16.0.0", "255.255.255.0");
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < backboneNodes; ++i)
|
||||
{
|
||||
NS_LOG_INFO ("Configuring local area network for backbone node " << i);
|
||||
//
|
||||
// Create a container to manage the nodes of the LAN. Pick one of
|
||||
// the backbone nodes to be part of the LAN and first add it to
|
||||
// the container. Then create the rest of the nodes we'll need.
|
||||
// Create a container to manage the nodes of the LAN. We need
|
||||
// two containers here; one with all of the new nodes, and one
|
||||
// with all of the nodes including new and existing nodes
|
||||
//
|
||||
NodeContainer lan;
|
||||
lan.Add (backbone.Get (i));
|
||||
lan.Create (lanNodes - 1);
|
||||
NodeContainer newLanNodes;
|
||||
newLanNodes.Create (lanNodes - 1);
|
||||
// Now, create the container with all nodes on this link
|
||||
NodeContainer lan (backbone.Get (i), newLanNodes);
|
||||
//
|
||||
// Create the CSMA net devices and install them into the nodes in our
|
||||
// collection.
|
||||
@@ -198,9 +200,9 @@ main (int argc, char *argv[])
|
||||
csma.SetChannelParameter ("Delay", MilliSeconds (2));
|
||||
NetDeviceContainer lanDevices = csma.Install (lan);
|
||||
//
|
||||
// Add the IPv4 protocol stack to the nodes in our container
|
||||
// Add the IPv4 protocol stack to the new LAN nodes
|
||||
//
|
||||
internet.Install (lan);
|
||||
internet.Install (newLanNodes);
|
||||
//
|
||||
// Assign IPv4 addresses to the device drivers (actually to the
|
||||
// associated IPv4 interfaces) we just created.
|
||||
@@ -227,13 +229,14 @@ main (int argc, char *argv[])
|
||||
{
|
||||
NS_LOG_INFO ("Configuring wireless network for backbone node " << i);
|
||||
//
|
||||
// Create a container to manage the nodes of the network. Pick one of
|
||||
// the backbone nodes to be part of the network and first add it to
|
||||
// the container. Then create the rest of the nodes we'll need.
|
||||
// Create a container to manage the nodes of the LAN. We need
|
||||
// two containers here; one with all of the new nodes, and one
|
||||
// with all of the nodes including new and existing nodes
|
||||
//
|
||||
NodeContainer infra;
|
||||
infra.Add (backbone.Get (i));
|
||||
infra.Create (infraNodes - 1);
|
||||
NodeContainer newInfraNodes;
|
||||
newInfraNodes.Create (infraNodes - 1);
|
||||
// Now, create the container with all nodes on this link
|
||||
NodeContainer infra (backbone.Get (i), newInfraNodes);
|
||||
//
|
||||
// Create another ad hoc network and devices
|
||||
//
|
||||
@@ -244,7 +247,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Add the IPv4 protocol stack to the nodes in our container
|
||||
//
|
||||
internet.Install (infra);
|
||||
internet.Install (newInfraNodes);
|
||||
//
|
||||
// Assign IPv4 addresses to the device drivers (actually to the associated
|
||||
// IPv4 interfaces) we just created.
|
||||
@@ -272,7 +275,7 @@ main (int argc, char *argv[])
|
||||
"Bounds", Rectangle (-25, 25, -25, 25),
|
||||
"Speed", ConstantVariable (30),
|
||||
"Pause", ConstantVariable (0.4));
|
||||
mobility.Layout (infra);
|
||||
mobility.Install (infra);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -282,7 +285,7 @@ main (int argc, char *argv[])
|
||||
|
||||
NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes");
|
||||
OlsrHelper olsr;
|
||||
olsr.Enable (backbone);
|
||||
olsr.Install (backbone);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
|
||||
@@ -120,7 +120,7 @@ main (int argc, char *argv[])
|
||||
// Enable OLSR
|
||||
NS_LOG_INFO ("Enabling OLSR Routing.");
|
||||
OlsrHelper olsr;
|
||||
olsr.EnableAll ();
|
||||
olsr.InstallAll ();
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
|
||||
@@ -126,7 +126,7 @@ Experiment::Run (const WifiHelper &wifi)
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
|
||||
|
||||
mobility.Layout (c);
|
||||
mobility.Install (c);
|
||||
|
||||
PacketSocketAddress socket;
|
||||
socket.SetSingleDevice(devices.Get (0)->GetIfIndex ());
|
||||
|
||||
@@ -151,8 +151,8 @@ int main (int argc, char *argv[])
|
||||
wifi.Install (ap, channel);
|
||||
|
||||
// mobility.
|
||||
mobility.Layout (stas);
|
||||
mobility.Layout (ap);
|
||||
mobility.Install (stas);
|
||||
mobility.Install (ap);
|
||||
|
||||
Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0));
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ int main (int argc, char *argv[])
|
||||
// finalize the setup by attaching to each object
|
||||
// in the input array a position and initializing
|
||||
// this position with the calculated coordinates.
|
||||
mobility.Layout (nodes);
|
||||
mobility.Install (nodes);
|
||||
|
||||
// iterate our nodes and print their position.
|
||||
for (NodeContainer::Iterator j = nodes.Begin ();
|
||||
|
||||
@@ -31,7 +31,7 @@ int main (int argc, char *argv[])
|
||||
"Y", String ("100.0"),
|
||||
"Rho", String ("Uniform:0:30"));
|
||||
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
|
||||
mobility.Layout (c);
|
||||
mobility.Install (c);
|
||||
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
@@ -41,7 +41,7 @@ int main (int argc, char *argv[])
|
||||
"Time", String ("2s"),
|
||||
"Speed", String ("Constant:1.0"),
|
||||
"Bounds", String ("0:200:0:100"));
|
||||
mobility.LayoutAll ();
|
||||
mobility.InstallAll ();
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "internet-stack-helper.h"
|
||||
#include "ns3/internet-stack.h"
|
||||
#include "ns3/packet-socket-factory.h"
|
||||
@@ -33,6 +37,12 @@ InternetStackHelper::Install (NodeContainer c)
|
||||
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
if (node->GetObject<Ipv4> () != 0)
|
||||
{
|
||||
NS_FATAL_ERROR ("InternetStackHelper::Install(): Aggregating "
|
||||
"an InternetStack to a node with an existing Ipv4 object");
|
||||
return;
|
||||
}
|
||||
AddInternetStack (node);
|
||||
Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
|
||||
node->AggregateObject (factory);
|
||||
|
||||
@@ -37,7 +37,10 @@ public:
|
||||
* \param c the set of nodes
|
||||
*
|
||||
* For each node in the input container, aggregate implementations
|
||||
* of the ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes.
|
||||
* of the ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes. The program
|
||||
* will assert if this method is called on a container with a node
|
||||
* that already has an Ipv4 object aggregated to it.
|
||||
*
|
||||
*/
|
||||
void Install (NodeContainer c);
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ MobilityHelper::GetMobilityModelType (void) const
|
||||
}
|
||||
|
||||
void
|
||||
MobilityHelper::Layout (NodeContainer c)
|
||||
MobilityHelper::Install (NodeContainer c)
|
||||
{
|
||||
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
|
||||
{
|
||||
@@ -167,9 +167,9 @@ MobilityHelper::Layout (NodeContainer c)
|
||||
}
|
||||
|
||||
void
|
||||
MobilityHelper::LayoutAll (void)
|
||||
MobilityHelper::InstallAll (void)
|
||||
{
|
||||
Layout (NodeContainer::GetGlobal ());
|
||||
Install (NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -34,7 +34,7 @@ class MobilityModel;
|
||||
/**
|
||||
* \brief assign positions and mobility models to nodes.
|
||||
*
|
||||
* MobilityHelper::Layout is the most important method here.
|
||||
* MobilityHelper::Install is the most important method here.
|
||||
*/
|
||||
class MobilityHelper
|
||||
{
|
||||
@@ -43,14 +43,14 @@ public:
|
||||
~MobilityHelper ();
|
||||
|
||||
/**
|
||||
* After this method is called, every call to MobilityHelper::Layout
|
||||
* After this method is called, every call to MobilityHelper::Install
|
||||
* will also attach to the new ns3::MobilityModel an ns3::MobilityModelNotifier
|
||||
* which can be used to listen to CourseChange events.
|
||||
*/
|
||||
void EnableNotifier (void);
|
||||
/**
|
||||
* After this method is called, no ns3::MobilityModelNotifier object will
|
||||
* be associated to any new ns3::MobilityModel created by MobilityHelper::Layout.
|
||||
* be associated to any new ns3::MobilityModel created by MobilityHelper::Install.
|
||||
* This will make it impossible to listen to "CourseChange" events from these
|
||||
* new ns3::MobilityModel instances.
|
||||
*/
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
* \param allocator allocate initial node positions
|
||||
*
|
||||
* Set the position allocator which will be used to allocate
|
||||
* the initial position of every node in MobilityModel::Layout.
|
||||
* the initial position of every node in MobilityModel::Install.
|
||||
*/
|
||||
void SetPositionAllocator (Ptr<PositionAllocator> allocator);
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
* \param n9 the name of the attribute to set in the mobility model.
|
||||
* \param v9 the value of the attribute to set in the mobility model.
|
||||
*
|
||||
* Calls to MobilityHelper::Layout will create an instance of a matching
|
||||
* Calls to MobilityHelper::Install will create an instance of a matching
|
||||
* mobility model for each node.
|
||||
*/
|
||||
void SetMobilityModel (std::string type,
|
||||
@@ -136,9 +136,9 @@ public:
|
||||
*
|
||||
* Push an item on the top of the stack of "reference mobility models".
|
||||
* The input item should be a node instance to which a mobility model
|
||||
* has already been aggregated (usually by a call to Layout).
|
||||
* has already been aggregated (usually by a call to Install).
|
||||
*
|
||||
* If this this stack is not empty when MobilityHelper::Layout
|
||||
* If this this stack is not empty when MobilityHelper::Install
|
||||
* is called, the model from the top of the stack is used
|
||||
* to create a ns3::HierarchicalMobilityModel to make the
|
||||
* newly-created models define their positions relative to that
|
||||
@@ -173,13 +173,13 @@ public:
|
||||
* ns3::MobilityModelNotifier to generate 'CourseChange' events based on the
|
||||
* boolean flag set by MobilityHelper::EnableNotifier and MobilityHelper::DisableNotifier.
|
||||
*/
|
||||
void Layout (NodeContainer container);
|
||||
void Install (NodeContainer container);
|
||||
|
||||
/**
|
||||
* Perform the work of MobilityHelper::Layout on _all_ nodes which
|
||||
* Perform the work of MobilityHelper::Install on _all_ nodes which
|
||||
* exist in the simulation.
|
||||
*/
|
||||
void LayoutAll (void);
|
||||
void InstallAll (void);
|
||||
private:
|
||||
|
||||
std::vector<Ptr<MobilityModel> > m_mobilityStack;
|
||||
|
||||
@@ -154,9 +154,9 @@ Ns2MobilityHelper::LayoutObjectStore (const ObjectStore &store) const
|
||||
}
|
||||
|
||||
void
|
||||
Ns2MobilityHelper::Layout (void) const
|
||||
Ns2MobilityHelper::Install (void) const
|
||||
{
|
||||
Layout (NodeList::Begin (), NodeList::End ());
|
||||
Install (NodeList::Begin (), NodeList::End ());
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
* whose nodeId is matches the nodeId of the nodes in the trace
|
||||
* file.
|
||||
*/
|
||||
void Layout (void) const;
|
||||
void Install (void) const;
|
||||
|
||||
/**
|
||||
* \param begin an iterator which points to the start of the input
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
* the index of the object in the input array.
|
||||
*/
|
||||
template <typename T>
|
||||
void Layout (T begin, T end) const;
|
||||
void Install (T begin, T end) const;
|
||||
private:
|
||||
class ObjectStore
|
||||
{
|
||||
@@ -86,7 +86,7 @@ namespace ns3 {
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
Ns2MobilityHelper::Layout (T begin, T end) const
|
||||
Ns2MobilityHelper::Install (T begin, T end) const
|
||||
{
|
||||
class MyObjectStore : public ObjectStore
|
||||
{
|
||||
|
||||
@@ -51,26 +51,32 @@ OlsrHelper::SetAgent (std::string tid,
|
||||
}
|
||||
|
||||
void
|
||||
OlsrHelper::Enable (NodeContainer container)
|
||||
OlsrHelper::Install (NodeContainer container)
|
||||
{
|
||||
for (NodeContainer::Iterator i = container.Begin (); i != container.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
Enable (node);
|
||||
Install (node);
|
||||
}
|
||||
}
|
||||
void
|
||||
OlsrHelper::Enable (Ptr<Node> node)
|
||||
OlsrHelper::Install (Ptr<Node> node)
|
||||
{
|
||||
if (node->GetObject<olsr::Agent> () != 0)
|
||||
{
|
||||
NS_FATAL_ERROR ("OlsrHelper::Install(): Aggregating "
|
||||
"an Olsr Agent to a node with an existing Olsr Agent");
|
||||
return;
|
||||
}
|
||||
Ptr<olsr::Agent> agent = m_agentFactory.Create<olsr::Agent> ();
|
||||
agent->SetNode (node);
|
||||
node->AggregateObject (agent);
|
||||
agent->Start ();
|
||||
}
|
||||
void
|
||||
OlsrHelper::EnableAll (void)
|
||||
OlsrHelper::InstallAll (void)
|
||||
{
|
||||
Enable (NodeContainer::GetGlobal ());
|
||||
Install (NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -41,9 +41,9 @@ public:
|
||||
std::string n6 = "", Attribute v6 = Attribute (),
|
||||
std::string n7 = "", Attribute v7 = Attribute ());
|
||||
|
||||
void Enable (NodeContainer container);
|
||||
void Enable (Ptr<Node> node);
|
||||
void EnableAll (void);
|
||||
void Install (NodeContainer container);
|
||||
void Install (Ptr<Node> node);
|
||||
void InstallAll (void);
|
||||
private:
|
||||
ObjectFactory m_agentFactory;
|
||||
};
|
||||
|
||||
@@ -36,11 +36,6 @@ namespace ns3 {
|
||||
void
|
||||
AddInternetStack (Ptr<Node> node)
|
||||
{
|
||||
// This may be called on a node with a previously added stack
|
||||
if (node->GetObject<Ipv4> ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
|
||||
Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
|
||||
ipv4->SetNode (node);
|
||||
|
||||
Reference in New Issue
Block a user