--- a/examples/mixed-wireless.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/examples/mixed-wireless.cc Sun Apr 13 15:46:17 2008 -0700
@@ -166,7 +166,7 @@
"Bounds", Rectangle (0, 1000, 0, 1000),
"Speed", ConstantVariable (2000),
"Pause", ConstantVariable (0.2));
- mobility.Layout (backbone);
+ mobility.Install (backbone);
///////////////////////////////////////////////////////////////////////////
// //
@@ -178,17 +178,19 @@
// 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 @@
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 @@
{
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 @@
// 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 @@
"Bounds", Rectangle (-25, 25, -25, 25),
"Speed", ConstantVariable (30),
"Pause", ConstantVariable (0.4));
- mobility.Layout (infra);
+ mobility.Install (infra);
}
///////////////////////////////////////////////////////////////////////////
// //
@@ -282,7 +285,7 @@
NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes");
OlsrHelper olsr;
- olsr.Enable (backbone);
+ olsr.Install (backbone);
///////////////////////////////////////////////////////////////////////////
// //
--- a/examples/simple-point-to-point-olsr.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/examples/simple-point-to-point-olsr.cc Sun Apr 13 15:46:17 2008 -0700
@@ -120,7 +120,7 @@
// 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
--- a/examples/wifi-adhoc.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/examples/wifi-adhoc.cc Sun Apr 13 15:46:17 2008 -0700
@@ -126,7 +126,7 @@
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
- mobility.Layout (c);
+ mobility.Install (c);
PacketSocketAddress socket;
socket.SetSingleDevice(devices.Get (0)->GetIfIndex ());
--- a/examples/wifi-ap.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/examples/wifi-ap.cc Sun Apr 13 15:46:17 2008 -0700
@@ -151,8 +151,8 @@
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));
--- a/samples/main-grid-topology.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/samples/main-grid-topology.cc Sun Apr 13 15:46:17 2008 -0700
@@ -37,7 +37,7 @@
// 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 ();
--- a/samples/main-random-topology.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/samples/main-random-topology.cc Sun Apr 13 15:46:17 2008 -0700
@@ -31,7 +31,7 @@
"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));
--- a/samples/main-random-walk.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/samples/main-random-walk.cc Sun Apr 13 15:46:17 2008 -0700
@@ -41,7 +41,7 @@
"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));
--- a/src/helper/internet-stack-helper.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/internet-stack-helper.cc Sun Apr 13 15:46:17 2008 -0700
@@ -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 @@
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);
--- a/src/helper/internet-stack-helper.h Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/internet-stack-helper.h Sun Apr 13 15:46:17 2008 -0700
@@ -37,7 +37,10 @@
* \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);
--- a/src/helper/mobility-helper.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/mobility-helper.cc Sun Apr 13 15:46:17 2008 -0700
@@ -122,7 +122,7 @@
}
void
-MobilityHelper::Layout (NodeContainer c)
+MobilityHelper::Install (NodeContainer c)
{
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
@@ -167,9 +167,9 @@
}
void
-MobilityHelper::LayoutAll (void)
+MobilityHelper::InstallAll (void)
{
- Layout (NodeContainer::GetGlobal ());
+ Install (NodeContainer::GetGlobal ());
}
} // namespace ns3
--- a/src/helper/mobility-helper.h Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/mobility-helper.h Sun Apr 13 15:46:17 2008 -0700
@@ -34,7 +34,7 @@
/**
* \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 @@
~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 @@
* \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 @@
* \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 @@
*
* 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 @@
* 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;
--- a/src/helper/ns2-mobility-helper.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/ns2-mobility-helper.cc Sun Apr 13 15:46:17 2008 -0700
@@ -154,9 +154,9 @@
}
void
-Ns2MobilityHelper::Layout (void) const
+Ns2MobilityHelper::Install (void) const
{
- Layout (NodeList::Begin (), NodeList::End ());
+ Install (NodeList::Begin (), NodeList::End ());
}
} // namespace ns3
--- a/src/helper/ns2-mobility-helper.h Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/ns2-mobility-helper.h Sun Apr 13 15:46:17 2008 -0700
@@ -51,7 +51,7 @@
* 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 @@
* 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 @@
template <typename T>
void
-Ns2MobilityHelper::Layout (T begin, T end) const
+Ns2MobilityHelper::Install (T begin, T end) const
{
class MyObjectStore : public ObjectStore
{
--- a/src/helper/olsr-helper.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/olsr-helper.cc Sun Apr 13 15:46:17 2008 -0700
@@ -51,26 +51,32 @@
}
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
--- a/src/helper/olsr-helper.h Fri Apr 11 11:30:05 2008 -0700
+++ b/src/helper/olsr-helper.h Sun Apr 13 15:46:17 2008 -0700
@@ -41,9 +41,9 @@
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;
};
--- a/src/internet-node/internet-stack.cc Fri Apr 11 11:30:05 2008 -0700
+++ b/src/internet-node/internet-stack.cc Sun Apr 13 15:46:17 2008 -0700
@@ -36,11 +36,6 @@
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);