A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
13
using namespace
ns3
;
14
15
int
16
main(
int
argc,
char
* argv[])
17
{
18
CommandLine
cmd
(__FILE__);
19
cmd
.Parse(argc, argv);
20
21
NodeContainer
sta;
22
sta.
Create
(4);
23
MobilityHelper
mobility
;
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"
,
34
UintegerValue
(3),
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
53
Simulator::Stop
(
Seconds
(5.0));
54
Simulator::Run
();
55
Simulator::Destroy
();
56
57
return
0;
58
}
ns3::AsciiTraceHelper
Manage ASCII trace files for device models.
Definition
trace-helper.h:163
ns3::AsciiTraceHelper::CreateFileStream
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.
Definition
trace-helper.cc:182
ns3::CommandLine
Parse command-line arguments.
Definition
command-line.h:221
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition
mobility-helper.h:33
ns3::MobilityHelper::EnableAsciiAll
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
Definition
mobility-helper.cc:200
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition
node-container.cc:73
ns3::Rectangle
a 2d rectangle
Definition
rectangle.h:24
ns3::RectangleValue
Definition
rectangle.h:114
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition
simulator.cc:131
ns3::Simulator::Run
static void Run()
Run the simulation.
Definition
simulator.cc:167
ns3::Simulator::Stop
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition
simulator.cc:175
ns3::StringValue
Hold variables of type string.
Definition
string.h:45
ns3::UintegerValue
Hold an unsigned integer type.
Definition
uinteger.h:34
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1308
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.cmd
cmd
Definition
second.py:29
third.mobility
mobility
Definition
third.py:92
src
mobility
examples
mobility-trace-example.cc
Generated on Fri Nov 8 2024 13:59:04 for ns-3 by
1.11.0