A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mobility-trace-example.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7// Test that mobility tracing works
8
9#include "ns3/core-module.h"
10#include "ns3/mobility-module.h"
11#include "ns3/network-module.h"
12
13using namespace ns3;
14
15int
16main(int argc, char* argv[])
17{
18 CommandLine cmd(__FILE__);
19 cmd.Parse(argc, argv);
20
21 NodeContainer sta;
22 sta.Create(4);
24 mobility.SetPositionAllocator("ns3::GridPositionAllocator",
25 "MinX",
26 DoubleValue(1.0),
27 "MinY",
28 DoubleValue(1.0),
29 "DeltaX",
30 DoubleValue(5.0),
31 "DeltaY",
32 DoubleValue(5.0),
33 "GridWidth",
35 "LayoutType",
36 StringValue("RowFirst"));
37 mobility.SetMobilityModel("ns3::RandomWalk2dMobilityModel",
38 "Mode",
39 StringValue("Time"),
40 "Time",
41 StringValue("2s"),
42 "Speed",
43 StringValue("ns3::ConstantRandomVariable[Constant=1.0]"),
44 "Bounds",
45 RectangleValue(Rectangle(0.0, 20.0, 0.0, 20.0)));
46 mobility.Install(sta);
47 // Set mobility random number streams to fixed values
48 mobility.AssignStreams(sta, 0);
49
50 AsciiTraceHelper ascii;
51 MobilityHelper::EnableAsciiAll(ascii.CreateFileStream("mobility-trace-example.mob"));
52
56
57 return 0;
58}
Manage ASCII trace files for device models.
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.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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:24
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
Hold an unsigned integer type.
Definition uinteger.h:34
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition third.py:92