A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
NodeContainer
sta;
30
sta.
Create
(4);
31
MobilityHelper
mobility;
32
mobility.
SetPositionAllocator
(
"ns3::GridPositionAllocator"
,
33
"MinX"
,
DoubleValue
(1.0),
34
"MinY"
,
DoubleValue
(1.0),
35
"DeltaX"
,
DoubleValue
(5.0),
36
"DeltaY"
,
DoubleValue
(5.0),
37
"GridWidth"
,
UintegerValue
(3),
38
"LayoutType"
,
StringValue
(
"RowFirst"
));
39
mobility.
SetMobilityModel
(
"ns3::RandomWalk2dMobilityModel"
,
40
"Mode"
,
StringValue
(
"Time"
),
41
"Time"
,
StringValue
(
"2s"
),
42
"Speed"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1.0]"
),
43
"Bounds"
,
RectangleValue
(
Rectangle
(0.0, 20.0, 0.0, 20.0)));
44
mobility.
Install
(sta);
45
// Set mobility random number streams to fixed values
46
mobility.
AssignStreams
(sta, 0);
47
48
AsciiTraceHelper
ascii;
49
MobilityHelper::EnableAsciiAll
(ascii.
CreateFileStream
(
"mobility-trace-example.mob"
));
50
51
Simulator::Stop
(Seconds (5.0));
52
Simulator::Run
();
53
Simulator::Destroy
();
54
}
ns3::AsciiTraceHelper
Manage ASCII trace files for device models.
Definition:
trace-helper.h:109
ns3::StringValue
hold variables of type string
Definition:
string.h:19
main
int main(int argc, char *argv[])
Definition:
mobility-trace-example.cc:27
ns3::Simulator::Run
static void Run(void)
Definition:
simulator.cc:157
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:184
ns3::MobilityHelper::AssignStreams
int64_t AssignStreams(NodeContainer c, int64_t stream)
Definition:
mobility-helper.cc:250
ns3::RectangleValue
hold objects of type ns3::Rectangle
ns3::MobilityHelper::Install
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Definition:
mobility-helper.cc:130
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:46
ns3::Simulator::Destroy
static void Destroy(void)
Definition:
simulator.cc:121
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:38
ns3::MobilityHelper::SetMobilityModel
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
Definition:
mobility-helper.cc:79
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition:
mobility-helper.h:42
ns3::Simulator::Stop
static void Stop(void)
Definition:
simulator.cc:165
ns3::MobilityHelper::EnableAsciiAll
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
Definition:
mobility-helper.cc:245
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:93
ns3::MobilityHelper::SetPositionAllocator
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Definition:
mobility-helper.cc:47
ns3::DoubleValue
Hold an floating point type.
Definition:
double.h:41
ns3::Rectangle
a 2d rectangle
Definition:
rectangle.h:33
src
mobility
examples
mobility-trace-example.cc
Generated on Sun Apr 20 2014 11:14:58 for ns-3 by
1.8.6