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-test-suite.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
* Author: Mitch Watrous (watrous@u.washington.edu)
19
*/
20
21
#include <string>
22
23
#include "ns3/ascii-test.h"
24
#include "ns3/trace-helper.h"
25
#include "ns3/double.h"
26
#include "ns3/uinteger.h"
27
#include "ns3/string.h"
28
#include "ns3/simulator.h"
29
#include "ns3/rectangle.h"
30
#include "ns3/mobility-model.h"
31
#include "ns3/mobility-helper.h"
32
#include "ns3/node-container.h"
33
#include "ns3/test.h"
34
35
using namespace
ns3;
36
37
38
//===========================================================================
39
// Class: MobilityTraceTestCase
40
//
41
//
42
// Test case.
43
//===========================================================================
44
45
class
MobilityTraceTestCase
:
public
TestCase
46
{
47
public
:
48
MobilityTraceTestCase
();
49
virtual
~
MobilityTraceTestCase
();
50
51
private
:
52
virtual
void
DoRun (
void
);
53
};
54
55
MobilityTraceTestCase::MobilityTraceTestCase
()
56
:
57
TestCase
(
"Mobility Trace Test Case"
)
58
{
59
}
60
61
MobilityTraceTestCase::~MobilityTraceTestCase
()
62
{
63
}
64
65
void
66
MobilityTraceTestCase::DoRun
(
void
)
67
{
68
//***************************************************************************
69
// Create the new mobility trace.
70
//***************************************************************************
71
72
NodeContainer
sta;
73
sta.
Create
(4);
74
MobilityHelper
mobility;
75
mobility.
SetPositionAllocator
(
"ns3::GridPositionAllocator"
,
76
"MinX"
,
DoubleValue
(1.0),
77
"MinY"
,
DoubleValue
(1.0),
78
"DeltaX"
,
DoubleValue
(5.0),
79
"DeltaY"
,
DoubleValue
(5.0),
80
"GridWidth"
,
UintegerValue
(3),
81
"LayoutType"
,
StringValue
(
"RowFirst"
));
82
mobility.
SetMobilityModel
(
"ns3::RandomWalk2dMobilityModel"
,
83
"Mode"
,
StringValue
(
"Time"
),
84
"Time"
,
StringValue
(
"2s"
),
85
"Speed"
,
StringValue
(
"ns3::ConstantRandomVariable[Constant=1.0]"
),
86
"Bounds"
,
RectangleValue
(
Rectangle
(0.0, 20.0, 0.0, 20.0)));
87
mobility.
Install
(sta);
88
// Set mobility random number streams to fixed values
89
mobility.
AssignStreams
(sta, 0);
90
91
SetDataDir
(NS_TEST_SOURCEDIR);
92
std::string referenceMobilityFilePath =
CreateDataDirFilename
(
"mobility-trace-example.mob"
);
93
std::string testMobilityFilePath =
CreateTempDirFilename
(
"mobility-trace-test.mob"
);
94
95
AsciiTraceHelper
ascii;
96
MobilityHelper::EnableAsciiAll (ascii.
CreateFileStream
(testMobilityFilePath));
97
Simulator::Stop (
Seconds
(5.0));
98
Simulator::Run
();
99
Simulator::Destroy ();
100
101
102
//***************************************************************************
103
// Test the new mobility trace against the reference mobility trace.
104
//***************************************************************************
105
106
NS_ASCII_TEST_EXPECT_EQ
(testMobilityFilePath, referenceMobilityFilePath);
107
}
108
109
110
//===========================================================================
111
// Class: MobilityTraceTestSuite
112
//
113
//
114
// Test suite.
115
//===========================================================================
116
117
class
MobilityTraceTestSuite
:
public
TestSuite
118
{
119
public
:
120
MobilityTraceTestSuite
();
121
};
122
123
MobilityTraceTestSuite::MobilityTraceTestSuite
()
124
:
TestSuite
(
"mobility-trace"
, UNIT)
125
{
126
AddTestCase
(
new
MobilityTraceTestCase
, TestCase::QUICK);
127
}
128
129
static
MobilityTraceTestSuite
mobilityTraceTestSuite
;
src
mobility
test
mobility-trace-test-suite.cc
Generated on Tue May 14 2013 11:08:29 for ns-3 by
1.8.1.2