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
phy-test.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007,2008, 2009 INRIA, UDcast
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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19
* <amine.ismail@udcast.com>
20
*/
21
#include "ns3/log.h"
22
#include "ns3/abort.h"
23
#include "ns3/test.h"
24
#include "ns3/config.h"
25
#include "ns3/string.h"
26
#include "ns3/uinteger.h"
27
#include "ns3/inet-socket-address.h"
28
#include "ns3/point-to-point-helper.h"
29
#include "ns3/internet-stack-helper.h"
30
#include "ns3/ipv4-address-helper.h"
31
#include "ns3/ipv4-header.h"
32
#include "ns3/packet-sink-helper.h"
33
#include "ns3/simulator.h"
34
#include "ns3/wimax-helper.h"
35
#include "ns3/mobility-helper.h"
36
#include "ns3/global-route-manager.h"
37
#include "ns3/snr-to-block-error-rate-manager.h"
38
#include <iostream>
39
40
using namespace
ns3;
41
42
NS_LOG_COMPONENT_DEFINE
(
"WimaxPhyTest"
);
43
44
/*
45
* Configure a network with 3 SS and 1 BS
46
* Install a SIMPLE OFDM PHY layer on all nodes and check that all SSs
47
* could register with the BS
48
*
49
*/
50
51
class
Ns3WimaxSimpleOFDMTestCase
:
public
TestCase
52
{
53
public
:
54
Ns3WimaxSimpleOFDMTestCase
();
55
virtual
~
Ns3WimaxSimpleOFDMTestCase
();
56
57
private
:
58
virtual
void
DoRun (
void
);
59
bool
DoRunOnce (
double
);
60
61
};
62
63
Ns3WimaxSimpleOFDMTestCase::Ns3WimaxSimpleOFDMTestCase
()
64
:
TestCase
(
"Test the Phy model with different frame durations"
)
65
{
66
}
67
68
Ns3WimaxSimpleOFDMTestCase::~Ns3WimaxSimpleOFDMTestCase
()
69
{
70
}
71
72
bool
73
Ns3WimaxSimpleOFDMTestCase::DoRunOnce
(
double
FrameDuration)
74
{
75
WimaxHelper::SchedulerType
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
76
NodeContainer
ssNodes;
77
NodeContainer
bsNodes;
78
ssNodes.
Create
(3);
79
bsNodes.
Create
(1);
80
81
WimaxHelper
wimax;
82
83
NetDeviceContainer
ssDevs, bsDevs;
84
85
ssDevs = wimax.
Install
(ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
86
WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler, FrameDuration);
87
bsDevs = wimax.
Install
(bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION,
88
WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler, FrameDuration);
89
90
Simulator::Stop (
Seconds
(1));
91
Simulator::Run
();
92
for
(
int
i = 0; i < 3; i++)
93
{
94
if
(ssDevs.
Get
(i)->
GetObject
<
SubscriberStationNetDevice
> ()->IsRegistered ()
95
==
false
)
96
{
97
NS_LOG_DEBUG
(
"SS["
<< i <<
"] not registered"
);
98
return
true
;
// Test fail because SS[i] is not registered
99
}
100
}
101
Simulator::Destroy ();
102
return
(
false
);
// Test was ok, all the SSs are registered
103
104
}
105
106
void
107
Ns3WimaxSimpleOFDMTestCase::DoRun
(
void
)
108
{
109
110
double
111
frameDuratioTab[7] = { 0.0025, 0.004, 0.005, 0.008, 0.01, 0.0125, 0.02 };
112
for
(
int
i = 0; i < 7; i++)
113
{
114
NS_LOG_DEBUG
(
"Frame Duration = "
<< frameDuratioTab[i]);
115
if
(
DoRunOnce
(frameDuratioTab[i]) !=
false
)
116
{
117
return
;
118
}
119
}
120
}
121
122
/*
123
* Test the SNr tom block error rate module
124
*/
125
126
class
Ns3WimaxSNRtoBLERTestCase
:
public
TestCase
127
{
128
public
:
129
Ns3WimaxSNRtoBLERTestCase
();
130
virtual
~Ns3WimaxSNRtoBLERTestCase
();
131
132
private
:
133
virtual
void
DoRun
(
void
);
134
bool
DoRunOnce
(uint8_t);
135
136
};
137
138
Ns3WimaxSNRtoBLERTestCase::Ns3WimaxSNRtoBLERTestCase
()
139
:
TestCase
(
"Test the SNR to block error rate module"
)
140
{
141
}
142
143
Ns3WimaxSNRtoBLERTestCase::~Ns3WimaxSNRtoBLERTestCase
()
144
{
145
}
146
147
bool
Ns3WimaxSNRtoBLERTestCase::DoRunOnce
(uint8_t modulationType)
148
{
149
150
SNRToBlockErrorRateManager
l_SNRToBlockErrorRateManager;
151
l_SNRToBlockErrorRateManager.
LoadTraces
();
152
SNRToBlockErrorRateRecord
* BLERRec;
153
154
for
(
double
i = -5; i < 40; i += 0.1)
155
{
156
BLERRec = l_SNRToBlockErrorRateManager.
GetSNRToBlockErrorRateRecord
(i,
157
modulationType);
158
delete
BLERRec;
159
}
160
return
false
;
161
}
162
163
void
164
Ns3WimaxSNRtoBLERTestCase::DoRun
(
void
)
165
{
166
for
(
int
i = 0; i < 7; i++)
167
{
168
DoRunOnce
(i);
169
}
170
}
171
172
/*
173
* The test suite
174
*/
175
class
Ns3WimaxPhyTestSuite
:
public
TestSuite
176
{
177
public
:
178
Ns3WimaxPhyTestSuite
();
179
};
180
Ns3WimaxPhyTestSuite::Ns3WimaxPhyTestSuite
()
181
:
TestSuite
(
"wimax-phy-layer"
, UNIT)
182
{
183
AddTestCase
(
new
Ns3WimaxSNRtoBLERTestCase
);
184
AddTestCase
(
new
Ns3WimaxSimpleOFDMTestCase
);
185
186
}
187
188
static
Ns3WimaxPhyTestSuite
ns3WimaxPhyTestSuite
;
src
wimax
test
phy-test.cc
Generated on Tue Oct 9 2012 16:45:50 for ns-3 by
1.8.1.2