A Discrete-Event Network Simulator
API
mobility-trace-example.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 University of Washington
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17 
18 // Test that mobility tracing works
19 
20 #include "ns3/core-module.h"
21 #include "ns3/mobility-module.h"
22 #include "ns3/network-module.h"
23 
24 using namespace ns3;
25 
26 int
27 main(int argc, char* argv[])
28 {
29  CommandLine cmd(__FILE__);
30  cmd.Parse(argc, argv);
31 
32  NodeContainer sta;
33  sta.Create(4);
35  mobility.SetPositionAllocator("ns3::GridPositionAllocator",
36  "MinX",
37  DoubleValue(1.0),
38  "MinY",
39  DoubleValue(1.0),
40  "DeltaX",
41  DoubleValue(5.0),
42  "DeltaY",
43  DoubleValue(5.0),
44  "GridWidth",
45  UintegerValue(3),
46  "LayoutType",
47  StringValue("RowFirst"));
48  mobility.SetMobilityModel("ns3::RandomWalk2dMobilityModel",
49  "Mode",
50  StringValue("Time"),
51  "Time",
52  StringValue("2s"),
53  "Speed",
54  StringValue("ns3::ConstantRandomVariable[Constant=1.0]"),
55  "Bounds",
56  RectangleValue(Rectangle(0.0, 20.0, 0.0, 20.0)));
57  mobility.Install(sta);
58  // Set mobility random number streams to fixed values
59  mobility.AssignStreams(sta, 0);
60 
61  AsciiTraceHelper ascii;
62  MobilityHelper::EnableAsciiAll(ascii.CreateFileStream("mobility-trace-example.mob"));
63 
67 
68  return 0;
69 }
Manage ASCII trace files for device models.
Definition: trace-helper.h:174
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Parse command-line arguments.
Definition: command-line.h:232
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Helper class used to assign positions and mobility models to nodes.
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
a 2d rectangle
Definition: rectangle.h:35
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
Hold an unsigned integer type.
Definition: uinteger.h:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:40
mobility
Definition: third.py:105