A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
mobility-trace-example.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
// Test that mobility tracing works
20
21
#include "ns3/core-module.h"
22
#include "ns3/mobility-module.h"
23
#include "ns3/network-module.h"
24
25
using namespace
ns3
;
26
27
int
main (
int
argc,
char
*argv[])
28
{
29
CommandLine
cmd
(__FILE__);
30
cmd
.Parse (argc, argv);
31
32
NodeContainer
sta;
33
sta.
Create
(4);
34
MobilityHelper
mobility
;
35
mobility
.SetPositionAllocator (
"ns3::GridPositionAllocator"
,
36
"MinX"
,
DoubleValue
(1.0),
37
"MinY"
,
DoubleValue
(1.0),
38
"DeltaX"
,
DoubleValue
(5.0),
39
"DeltaY"
,
DoubleValue
(5.0),
40
"GridWidth"
,
UintegerValue
(3),
41
"LayoutType"
,
StringValue
(
"RowFirst"
));
42
mobility
.SetMobilityModel (
"ns3::RandomWalk2dMobilityModel"
,
43
"Mode"
,
StringValue
(
"Time"
),
44
"Time"
,
StringValue
(
"2s"
),
45
"Speed"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1.0]"
),
46
"Bounds"
,
RectangleValue
(
Rectangle
(0.0, 20.0, 0.0, 20.0)));
47
mobility
.Install (sta);
48
// Set mobility random number streams to fixed values
49
mobility
.AssignStreams (sta, 0);
50
51
AsciiTraceHelper
ascii;
52
MobilityHelper::EnableAsciiAll
(ascii.
CreateFileStream
(
"mobility-trace-example.mob"
));
53
54
Simulator::Stop
(
Seconds
(5.0));
55
Simulator::Run
();
56
Simulator::Destroy
();
57
}
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:191
ns3::CommandLine
Parse command-line arguments.
Definition:
command-line.h:229
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:41
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition:
mobility-helper.h:43
ns3::MobilityHelper::EnableAsciiAll
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
Definition:
mobility-helper.cc:250
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:39
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:98
ns3::Rectangle
a 2d rectangle
Definition:
rectangle.h:35
ns3::RectangleValue
AttributeValue implementation for Rectangle.
Definition:
rectangle.h:97
ns3::Simulator::Stop
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition:
simulator.cc:180
ns3::Simulator::Destroy
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition:
simulator.cc:136
ns3::Simulator::Run
static void Run(void)
Run the simulation.
Definition:
simulator.cc:172
ns3::StringValue
Hold variables of type string.
Definition:
string.h:41
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:44
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1244
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.cmd
cmd
Definition:
second.py:35
third.mobility
mobility
Definition:
third.py:108
src
mobility
examples
mobility-trace-example.cc
Generated on Tue Feb 6 2024 19:21:24 for ns-3 by
1.9.1