A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
main-random-topology.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 
3 #include "ns3/core-module.h"
4 #include "ns3/mobility-module.h"
5 
6 using namespace ns3;
7 
8 static void
9 CourseChange (std::string context, Ptr<const MobilityModel> position)
10 {
11  Vector pos = position->GetPosition ();
12  std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
13  << ", z=" << pos.z << std::endl;
14 }
15 
16 int main (int argc, char *argv[])
17 {
18  CommandLine cmd;
19  cmd.Parse (argc, argv);
20 
21 
22  NodeContainer c;
23  c.Create (10000);
24 
25  MobilityHelper mobility;
26  mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
27  "X", StringValue ("100.0"),
28  "Y", StringValue ("100.0"),
29  "Rho", StringValue ("ns3::UniformRandomVariable[Min=0|Max=30]"));
30  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
31  mobility.Install (c);
32 
33  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
35 
36  Simulator::Stop (Seconds (100.0));
37 
38  Simulator::Run ();
39 
41  return 0;
42 }