View | Details | Raw Unified | Return to bug 167
Collapse All | Expand All

(-)a/examples/mixed-wireless.cc (-21 / +24 lines)
 Lines 166-172   main (int argc, char *argv[]) Link Here 
166
                              "Bounds", Rectangle (0, 1000, 0, 1000),
166
                              "Bounds", Rectangle (0, 1000, 0, 1000),
167
                              "Speed", ConstantVariable (2000),
167
                              "Speed", ConstantVariable (2000),
168
                              "Pause", ConstantVariable (0.2));
168
                              "Pause", ConstantVariable (0.2));
169
  mobility.Layout (backbone);
169
  mobility.Install (backbone);
170
170
171
  /////////////////////////////////////////////////////////////////////////// 
171
  /////////////////////////////////////////////////////////////////////////// 
172
  //                                                                       //
172
  //                                                                       //
 Lines 178-194   main (int argc, char *argv[]) Link Here 
178
  // the "172.16 address space
178
  // the "172.16 address space
179
  ipAddrs.SetBase ("172.16.0.0", "255.255.255.0");
179
  ipAddrs.SetBase ("172.16.0.0", "255.255.255.0");
180
180
181
181
  for (uint32_t i = 0; i < backboneNodes; ++i)
182
  for (uint32_t i = 0; i < backboneNodes; ++i)
182
    {
183
    {
183
      NS_LOG_INFO ("Configuring local area network for backbone node " << i);
184
      NS_LOG_INFO ("Configuring local area network for backbone node " << i);
184
      //
185
      //
185
      // Create a container to manage the nodes of the LAN.  Pick one of 
186
      // Create a container to manage the nodes of the LAN.  We need
186
      // the backbone nodes to be part of the LAN and first add it to 
187
      // two containers here; one with all of the new nodes, and one
187
      // the container.  Then create the rest of the nodes we'll need.
188
      // with all of the nodes including new and existing nodes
188
      //
189
      //
189
      NodeContainer lan;
190
      NodeContainer newLanNodes;
190
      lan.Add (backbone.Get (i));
191
      newLanNodes.Create (lanNodes - 1);
191
      lan.Create (lanNodes - 1);
192
      // Now, create the container with all nodes on this link
193
      NodeContainer lan (backbone.Get (i), newLanNodes);
192
      //
194
      //
193
      // Create the CSMA net devices and install them into the nodes in our 
195
      // Create the CSMA net devices and install them into the nodes in our 
194
      // collection.
196
      // collection.
 Lines 198-206   main (int argc, char *argv[]) Link Here 
198
      csma.SetChannelParameter ("Delay", MilliSeconds (2));
200
      csma.SetChannelParameter ("Delay", MilliSeconds (2));
199
      NetDeviceContainer lanDevices = csma.Install (lan);
201
      NetDeviceContainer lanDevices = csma.Install (lan);
200
      //
202
      //
201
      // Add the IPv4 protocol stack to the nodes in our container
203
      // Add the IPv4 protocol stack to the new LAN nodes
202
      //
204
      //
203
      internet.Install (lan);
205
      internet.Install (newLanNodes);
204
      //
206
      //
205
      // Assign IPv4 addresses to the device drivers (actually to the 
207
      // Assign IPv4 addresses to the device drivers (actually to the 
206
      // associated IPv4 interfaces) we just created.
208
      // associated IPv4 interfaces) we just created.
 Lines 227-239   main (int argc, char *argv[]) Link Here 
227
    {
229
    {
228
      NS_LOG_INFO ("Configuring wireless network for backbone node " << i);
230
      NS_LOG_INFO ("Configuring wireless network for backbone node " << i);
229
      //
231
      //
230
      // Create a container to manage the nodes of the network.  Pick one of 
232
      // Create a container to manage the nodes of the LAN.  We need
231
      // the backbone nodes to be part of the network and first add it to 
233
      // two containers here; one with all of the new nodes, and one
232
      // the container.  Then create the rest of the nodes we'll need.
234
      // with all of the nodes including new and existing nodes
233
      //
235
      //
234
      NodeContainer infra;
236
      NodeContainer newInfraNodes;
235
      infra.Add (backbone.Get (i));
237
      newInfraNodes.Create (infraNodes - 1);
236
      infra.Create (infraNodes - 1);
238
      // Now, create the container with all nodes on this link
239
      NodeContainer infra (backbone.Get (i), newInfraNodes);
237
      //
240
      //
238
      // Create another ad hoc network and devices
241
      // Create another ad hoc network and devices
239
      //
242
      //
 Lines 244-250   main (int argc, char *argv[]) Link Here 
244
247
245
      // Add the IPv4 protocol stack to the nodes in our container
248
      // Add the IPv4 protocol stack to the nodes in our container
246
      //
249
      //
247
      internet.Install (infra);
250
      internet.Install (newInfraNodes);
248
      //
251
      //
249
      // Assign IPv4 addresses to the device drivers (actually to the associated
252
      // Assign IPv4 addresses to the device drivers (actually to the associated
250
      // IPv4 interfaces) we just created.
253
      // IPv4 interfaces) we just created.
 Lines 272-278   main (int argc, char *argv[]) Link Here 
272
                                 "Bounds", Rectangle (-25, 25, -25, 25),
275
                                 "Bounds", Rectangle (-25, 25, -25, 25),
273
                                 "Speed", ConstantVariable (30),
276
                                 "Speed", ConstantVariable (30),
274
                                 "Pause", ConstantVariable (0.4));
277
                                 "Pause", ConstantVariable (0.4));
275
      mobility.Layout (infra);
278
      mobility.Install (infra);
276
    }
279
    }
277
  /////////////////////////////////////////////////////////////////////////// 
280
  /////////////////////////////////////////////////////////////////////////// 
278
  //                                                                       //
281
  //                                                                       //
 Lines 282-288   main (int argc, char *argv[]) Link Here 
282
285
283
  NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes");
286
  NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes");
284
  OlsrHelper olsr;
287
  OlsrHelper olsr;
285
  olsr.Enable (backbone);
288
  olsr.Install (backbone);
286
289
287
  /////////////////////////////////////////////////////////////////////////// 
290
  /////////////////////////////////////////////////////////////////////////// 
288
  //                                                                       //
291
  //                                                                       //
(-)a/examples/simple-point-to-point-olsr.cc (-1 / +1 lines)
 Lines 120-126   main (int argc, char *argv[]) Link Here 
120
  // Enable OLSR
120
  // Enable OLSR
121
  NS_LOG_INFO ("Enabling OLSR Routing.");
121
  NS_LOG_INFO ("Enabling OLSR Routing.");
122
  OlsrHelper olsr;
122
  OlsrHelper olsr;
123
  olsr.EnableAll ();
123
  olsr.InstallAll ();
124
124
125
  // Create the OnOff application to send UDP datagrams of size
125
  // Create the OnOff application to send UDP datagrams of size
126
  // 210 bytes at a rate of 448 Kb/s
126
  // 210 bytes at a rate of 448 Kb/s
(-)a/examples/wifi-adhoc.cc (-1 / +1 lines)
 Lines 126-132   Experiment::Run (const WifiHelper &wifi) Link Here 
126
  mobility.SetPositionAllocator (positionAlloc);
126
  mobility.SetPositionAllocator (positionAlloc);
127
  mobility.SetMobilityModel ("ns3::StaticMobilityModel");
127
  mobility.SetMobilityModel ("ns3::StaticMobilityModel");
128
128
129
  mobility.Layout (c);
129
  mobility.Install (c);
130
130
131
  PacketSocketAddress socket;
131
  PacketSocketAddress socket;
132
  socket.SetSingleDevice(devices.Get (0)->GetIfIndex ());
132
  socket.SetSingleDevice(devices.Get (0)->GetIfIndex ());
(-)a/examples/wifi-ap.cc (-2 / +2 lines)
 Lines 151-158   int main (int argc, char *argv[]) Link Here 
151
  wifi.Install (ap, channel);
151
  wifi.Install (ap, channel);
152
152
153
  // mobility.
153
  // mobility.
154
  mobility.Layout (stas);
154
  mobility.Install (stas);
155
  mobility.Layout (ap);
155
  mobility.Install (ap);
156
156
157
  Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0));
157
  Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0));
158
158
(-)a/samples/main-grid-topology.cc (-1 / +1 lines)
 Lines 37-43   int main (int argc, char *argv[]) Link Here 
37
  // finalize the setup by attaching to each object
37
  // finalize the setup by attaching to each object
38
  // in the input array a position and initializing
38
  // in the input array a position and initializing
39
  // this position with the calculated coordinates.
39
  // this position with the calculated coordinates.
40
  mobility.Layout (nodes);
40
  mobility.Install (nodes);
41
41
42
  // iterate our nodes and print their position.
42
  // iterate our nodes and print their position.
43
  for (NodeContainer::Iterator j = nodes.Begin ();
43
  for (NodeContainer::Iterator j = nodes.Begin ();
(-)a/samples/main-random-topology.cc (-1 / +1 lines)
 Lines 31-37   int main (int argc, char *argv[]) Link Here 
31
                                 "Y", String ("100.0"),
31
                                 "Y", String ("100.0"),
32
                                 "Rho", String ("Uniform:0:30"));
32
                                 "Rho", String ("Uniform:0:30"));
33
  mobility.SetMobilityModel ("ns3::StaticMobilityModel");
33
  mobility.SetMobilityModel ("ns3::StaticMobilityModel");
34
  mobility.Layout (c);
34
  mobility.Install (c);
35
35
36
  Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
36
  Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
37
                              MakeCallback (&CourseChange));
37
                              MakeCallback (&CourseChange));
(-)a/samples/main-random-walk.cc (-1 / +1 lines)
 Lines 41-47   int main (int argc, char *argv[]) Link Here 
41
                             "Time", String ("2s"),
41
                             "Time", String ("2s"),
42
                             "Speed", String ("Constant:1.0"),
42
                             "Speed", String ("Constant:1.0"),
43
                             "Bounds", String ("0:200:0:100"));
43
                             "Bounds", String ("0:200:0:100"));
44
  mobility.LayoutAll ();
44
  mobility.InstallAll ();
45
  Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
45
  Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
46
                              MakeCallback (&CourseChange));
46
                              MakeCallback (&CourseChange));
47
47
(-)a/src/helper/internet-stack-helper.cc (+10 lines)
 Lines 17-22    Link Here 
17
 *
17
 *
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 */
19
 */
20
#include "ns3/assert.h"
21
#include "ns3/log.h"
22
#include "ns3/object.h"
23
#include "ns3/ipv4.h"
20
#include "internet-stack-helper.h"
24
#include "internet-stack-helper.h"
21
#include "ns3/internet-stack.h"
25
#include "ns3/internet-stack.h"
22
#include "ns3/packet-socket-factory.h"
26
#include "ns3/packet-socket-factory.h"
 Lines 33-38   InternetStackHelper::Install (NodeContai Link Here 
33
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
37
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
34
    {
38
    {
35
      Ptr<Node> node = *i;
39
      Ptr<Node> node = *i;
40
      if (node->GetObject<Ipv4> () != 0)
41
        {
42
          NS_FATAL_ERROR ("InternetStackHelper::Install(): Aggregating " 
43
             "an InternetStack to a node with an existing Ipv4 object");
44
          return;
45
        } 
36
      AddInternetStack (node);
46
      AddInternetStack (node);
37
      Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
47
      Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
38
      node->AggregateObject (factory);
48
      node->AggregateObject (factory);
(-)a/src/helper/internet-stack-helper.h (-1 / +4 lines)
 Lines 37-43   public: Link Here 
37
   * \param c the set of nodes
37
   * \param c the set of nodes
38
   *
38
   *
39
   * For each node in the input container, aggregate implementations
39
   * For each node in the input container, aggregate implementations
40
   * of the ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes.
40
   * of the ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes.  The program
41
   * will assert if this method is called on a container with a node
42
   * that already has an Ipv4 object aggregated to it.
43
   * 
41
   */
44
   */
42
  void Install (NodeContainer c);
45
  void Install (NodeContainer c);
43
46
(-)a/src/helper/mobility-helper.cc (-3 / +3 lines)
 Lines 122-128   MobilityHelper::GetMobilityModelType (vo Link Here 
122
}
122
}
123
123
124
void 
124
void 
125
MobilityHelper::Layout (NodeContainer c)
125
MobilityHelper::Install (NodeContainer c)
126
{
126
{
127
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
127
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
128
    {
128
    {
 Lines 167-175   MobilityHelper::Layout (NodeContainer c) Link Here 
167
}
167
}
168
168
169
void 
169
void 
170
MobilityHelper::LayoutAll (void)
170
MobilityHelper::InstallAll (void)
171
{
171
{
172
  Layout (NodeContainer::GetGlobal ());
172
  Install (NodeContainer::GetGlobal ());
173
}
173
}
174
174
175
} // namespace ns3
175
} // namespace ns3
(-)a/src/helper/mobility-helper.h (-10 / +10 lines)
 Lines 34-40   class MobilityModel; Link Here 
34
/**
34
/**
35
 * \brief assign positions and mobility models to nodes.
35
 * \brief assign positions and mobility models to nodes.
36
 *
36
 *
37
 * MobilityHelper::Layout is the most important method here.
37
 * MobilityHelper::Install is the most important method here.
38
 */
38
 */
39
class MobilityHelper
39
class MobilityHelper
40
{
40
{
 Lines 43-56   public: Link Here 
43
  ~MobilityHelper ();
43
  ~MobilityHelper ();
44
44
45
  /**
45
  /**
46
   * After this method is called, every call to MobilityHelper::Layout
46
   * After this method is called, every call to MobilityHelper::Install
47
   * will also attach to the new ns3::MobilityModel an ns3::MobilityModelNotifier
47
   * will also attach to the new ns3::MobilityModel an ns3::MobilityModelNotifier
48
   * which can be used to listen to CourseChange events.
48
   * which can be used to listen to CourseChange events.
49
   */
49
   */
50
  void EnableNotifier (void);
50
  void EnableNotifier (void);
51
  /**
51
  /**
52
   * After this method is called, no ns3::MobilityModelNotifier object will
52
   * After this method is called, no ns3::MobilityModelNotifier object will
53
   * be associated to any new ns3::MobilityModel created by MobilityHelper::Layout.
53
   * be associated to any new ns3::MobilityModel created by MobilityHelper::Install.
54
   * This will make it impossible to listen to "CourseChange" events from these
54
   * This will make it impossible to listen to "CourseChange" events from these
55
   * new ns3::MobilityModel instances.
55
   * new ns3::MobilityModel instances.
56
   */
56
   */
 Lines 60-66   public: Link Here 
60
   * \param allocator allocate initial node positions
60
   * \param allocator allocate initial node positions
61
   *
61
   *
62
   * Set the position allocator which will be used to allocate
62
   * Set the position allocator which will be used to allocate
63
   * the initial position of every node in MobilityModel::Layout.
63
   * the initial position of every node in MobilityModel::Install.
64
   */
64
   */
65
  void SetPositionAllocator (Ptr<PositionAllocator> allocator);
65
  void SetPositionAllocator (Ptr<PositionAllocator> allocator);
66
66
 Lines 117-123   public: Link Here 
117
   * \param n9 the name of the attribute to set in the mobility model.
117
   * \param n9 the name of the attribute to set in the mobility model.
118
   * \param v9 the value of the attribute to set in the mobility model.
118
   * \param v9 the value of the attribute to set in the mobility model.
119
   *
119
   *
120
   * Calls to MobilityHelper::Layout will create an instance of a matching 
120
   * Calls to MobilityHelper::Install will create an instance of a matching 
121
   * mobility model for each node.
121
   * mobility model for each node.
122
   */
122
   */
123
  void SetMobilityModel (std::string type,
123
  void SetMobilityModel (std::string type,
 Lines 136-144   public: Link Here 
136
   *
136
   *
137
   * Push an item on the top of the stack of "reference mobility models".
137
   * Push an item on the top of the stack of "reference mobility models".
138
   * The input item should be a node instance to which a mobility model
138
   * The input item should be a node instance to which a mobility model
139
   * has already been aggregated (usually by a call to Layout).
139
   * has already been aggregated (usually by a call to Install).
140
   *
140
   *
141
   * If this this stack is not empty when MobilityHelper::Layout
141
   * If this this stack is not empty when MobilityHelper::Install
142
   * is called, the model from the top of the stack is used
142
   * is called, the model from the top of the stack is used
143
   * to create a ns3::HierarchicalMobilityModel to make the
143
   * to create a ns3::HierarchicalMobilityModel to make the
144
   * newly-created models define their positions relative to that
144
   * newly-created models define their positions relative to that
 Lines 173-185   public: Link Here 
173
   * ns3::MobilityModelNotifier to generate 'CourseChange' events based on the 
173
   * ns3::MobilityModelNotifier to generate 'CourseChange' events based on the 
174
   * boolean flag set by MobilityHelper::EnableNotifier and MobilityHelper::DisableNotifier.
174
   * boolean flag set by MobilityHelper::EnableNotifier and MobilityHelper::DisableNotifier.
175
   */
175
   */
176
  void Layout (NodeContainer container);
176
  void Install (NodeContainer container);
177
177
178
  /**
178
  /**
179
   * Perform the work of MobilityHelper::Layout on _all_ nodes which
179
   * Perform the work of MobilityHelper::Install on _all_ nodes which
180
   * exist in the simulation.
180
   * exist in the simulation.
181
   */
181
   */
182
  void LayoutAll (void);
182
  void InstallAll (void);
183
private:
183
private:
184
184
185
  std::vector<Ptr<MobilityModel> > m_mobilityStack;
185
  std::vector<Ptr<MobilityModel> > m_mobilityStack;
(-)a/src/helper/ns2-mobility-helper.cc (-2 / +2 lines)
 Lines 154-162   Ns2MobilityHelper::LayoutObjectStore (co Link Here 
154
}
154
}
155
155
156
void 
156
void 
157
Ns2MobilityHelper::Layout (void) const
157
Ns2MobilityHelper::Install (void) const
158
{
158
{
159
  Layout (NodeList::Begin (), NodeList::End ());
159
  Install (NodeList::Begin (), NodeList::End ());
160
}
160
}
161
161
162
} // namespace ns3
162
} // namespace ns3
(-)a/src/helper/ns2-mobility-helper.h (-3 / +3 lines)
 Lines 51-57   public: Link Here 
51
   * whose nodeId is matches the nodeId of the nodes in the trace
51
   * whose nodeId is matches the nodeId of the nodes in the trace
52
   * file.
52
   * file.
53
   */
53
   */
54
  void Layout (void) const;
54
  void Install (void) const;
55
55
56
  /**
56
  /**
57
   * \param begin an iterator which points to the start of the input
57
   * \param begin an iterator which points to the start of the input
 Lines 65-71   public: Link Here 
65
   * the index of the object in the input array.
65
   * the index of the object in the input array.
66
   */
66
   */
67
  template <typename T>
67
  template <typename T>
68
  void Layout (T begin, T end) const;
68
  void Install (T begin, T end) const;
69
private:
69
private:
70
  class ObjectStore
70
  class ObjectStore
71
  {
71
  {
 Lines 86-92   namespace ns3 { Link Here 
86
86
87
template <typename T>
87
template <typename T>
88
void 
88
void 
89
Ns2MobilityHelper::Layout (T begin, T end) const
89
Ns2MobilityHelper::Install (T begin, T end) const
90
{
90
{
91
  class MyObjectStore : public ObjectStore
91
  class MyObjectStore : public ObjectStore
92
  {
92
  {
(-)a/src/helper/olsr-helper.cc (-5 / +11 lines)
 Lines 51-76   OlsrHelper::SetAgent (std::string tid, Link Here 
51
}
51
}
52
52
53
void 
53
void 
54
OlsrHelper::Enable (NodeContainer container)
54
OlsrHelper::Install (NodeContainer container)
55
{
55
{
56
  for (NodeContainer::Iterator i = container.Begin (); i != container.End (); ++i)
56
  for (NodeContainer::Iterator i = container.Begin (); i != container.End (); ++i)
57
    {
57
    {
58
      Ptr<Node> node = *i;
58
      Ptr<Node> node = *i;
59
      Enable (node);
59
      Install (node);
60
    }
60
    }
61
}
61
}
62
void 
62
void 
63
OlsrHelper::Enable (Ptr<Node> node)
63
OlsrHelper::Install (Ptr<Node> node)
64
{
64
{
65
  if (node->GetObject<olsr::Agent> () != 0)
66
    {
67
      NS_FATAL_ERROR ("OlsrHelper::Install(): Aggregating "
68
         "an Olsr Agent to a node with an existing Olsr Agent");
69
      return;
70
    }
65
  Ptr<olsr::Agent> agent = m_agentFactory.Create<olsr::Agent> ();
71
  Ptr<olsr::Agent> agent = m_agentFactory.Create<olsr::Agent> ();
66
  agent->SetNode (node);
72
  agent->SetNode (node);
67
  node->AggregateObject (agent);
73
  node->AggregateObject (agent);
68
  agent->Start ();
74
  agent->Start ();
69
}
75
}
70
void 
76
void 
71
OlsrHelper::EnableAll (void)
77
OlsrHelper::InstallAll (void)
72
{
78
{
73
  Enable (NodeContainer::GetGlobal ());
79
  Install (NodeContainer::GetGlobal ());
74
}
80
}
75
81
76
} // namespace ns3
82
} // namespace ns3
(-)a/src/helper/olsr-helper.h (-3 / +3 lines)
 Lines 41-49   public: Link Here 
41
		 std::string n6 = "", Attribute v6 = Attribute (),
41
		 std::string n6 = "", Attribute v6 = Attribute (),
42
		 std::string n7 = "", Attribute v7 = Attribute ());
42
		 std::string n7 = "", Attribute v7 = Attribute ());
43
43
44
  void Enable (NodeContainer container);
44
  void Install (NodeContainer container);
45
  void Enable (Ptr<Node> node);
45
  void Install (Ptr<Node> node);
46
  void EnableAll (void);
46
  void InstallAll (void);
47
private:
47
private:
48
  ObjectFactory m_agentFactory;
48
  ObjectFactory m_agentFactory;
49
};
49
};
(-)a/src/internet-node/internet-stack.cc (-5 lines)
 Lines 36-46   void Link Here 
36
void 
36
void 
37
AddInternetStack (Ptr<Node> node)
37
AddInternetStack (Ptr<Node> node)
38
{
38
{
39
  // This may be called on a node with a previously added stack
40
  if (node->GetObject<Ipv4> ())
41
    {
42
      return;
43
    }
44
  Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
39
  Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
45
  Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
40
  Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
46
  ipv4->SetNode (node);
41
  ipv4->SetNode (node);

Return to bug 167