A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
phy-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 */
20#include "ns3/log.h"
21#include "ns3/net-device-container.h"
22#include "ns3/node-container.h"
23#include "ns3/simulator.h"
24#include "ns3/snr-to-block-error-rate-manager.h"
25#include "ns3/test.h"
26#include "ns3/wimax-helper.h"
27
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE("WimaxPhyTest");
31
32/*
33 * Configure a network with 3 SS and 1 BS
34 * Install a SIMPLE OFDM PHY layer on all nodes and check that all SSs
35 * could register with the BS
36 *
37 */
38
39/**
40 * \ingroup wimax-test
41 * \ingroup tests
42 *
43 * \brief Ns3 Wimax Simple OFDM Test Case
44 */
46{
47 public:
50
51 private:
52 void DoRun() override;
53 /**
54 * Run once function
55 * \param FrameDuration the frame duration
56 * \returns true if successful
57 */
58 bool DoRunOnce(double FrameDuration);
59};
60
62 : TestCase("Test the Phy model with different frame durations")
63{
64}
65
67{
68}
69
70bool
72{
74 NodeContainer ssNodes;
75 NodeContainer bsNodes;
76 ssNodes.Create(3);
77 bsNodes.Create(1);
78
79 WimaxHelper wimax;
80
81 NetDeviceContainer ssDevs;
82 NetDeviceContainer bsDevs;
83
84 ssDevs = wimax.Install(ssNodes,
87 scheduler,
88 FrameDuration);
89 bsDevs = wimax.Install(bsNodes,
92 scheduler,
93 FrameDuration);
94
97 for (int i = 0; i < 3; i++)
98 {
99 if (!ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>()->IsRegistered())
100 {
101 NS_LOG_DEBUG("SS[" << i << "] not registered");
102 return true; // Test fail because SS[i] is not registered
103 }
104 }
106 return false; // Test was ok, all the SSs are registered
107}
108
109void
111{
112 double frameDuratioTab[7] = {0.0025, 0.004, 0.005, 0.008, 0.01, 0.0125, 0.02};
113 for (int i = 0; i < 7; i++)
114 {
115 NS_LOG_DEBUG("Frame Duration = " << frameDuratioTab[i]);
116 if (DoRunOnce(frameDuratioTab[i]))
117 {
118 return;
119 }
120 }
121}
122
123/**
124 * \ingroup wimax-test
125 * \ingroup tests
126 *
127 * \brief Test the SNr tom block error rate module
128 */
130{
131 public:
134
135 private:
136 void DoRun() override;
137 /**
138 * Run once function
139 * \param modulationType the modulation type
140 * \returns true if successful
141 */
142 bool DoRunOnce(uint8_t modulationType);
143};
144
146 : TestCase("Test the SNR to block error rate module")
147{
148}
149
151{
152}
153
154bool
156{
157 SNRToBlockErrorRateManager l_SNRToBlockErrorRateManager;
158 l_SNRToBlockErrorRateManager.LoadTraces();
160
161 for (double i = -5; i < 40; i += 0.1)
162 {
163 BLERRec = l_SNRToBlockErrorRateManager.GetSNRToBlockErrorRateRecord(i, modulationType);
164 delete BLERRec;
165 }
166 return false;
167}
168
169void
171{
172 for (int i = 0; i < 7; i++)
173 {
174 DoRunOnce(i);
175 }
176}
177
178/**
179 * \ingroup wimax-test
180 * \ingroup tests
181 *
182 * \brief The test suite
183 */
185{
186 public:
188};
189
191 : TestSuite("wimax-phy-layer", Type::UNIT)
192{
193 AddTestCase(new Ns3WimaxSNRtoBLERTestCase, TestCase::Duration::QUICK);
194 AddTestCase(new Ns3WimaxSimpleOFDMTestCase, TestCase::Duration::QUICK);
195}
196
The test suite.
Definition: phy-test.cc:185
Test the SNr tom block error rate module.
Definition: phy-test.cc:130
void DoRun() override
Implementation to actually run this TestCase.
Definition: phy-test.cc:170
~Ns3WimaxSNRtoBLERTestCase() override
Definition: phy-test.cc:150
bool DoRunOnce(uint8_t modulationType)
Run once function.
Definition: phy-test.cc:155
Ns3 Wimax Simple OFDM Test Case.
Definition: phy-test.cc:46
void DoRun() override
Implementation to actually run this TestCase.
Definition: phy-test.cc:110
~Ns3WimaxSimpleOFDMTestCase() override
Definition: phy-test.cc:66
bool DoRunOnce(double FrameDuration)
Run once function.
Definition: phy-test.cc:71
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
This class handles the SNR to BlcER traces.
void LoadTraces()
Loads the traces form the repository specified in the constructor or set by SetTraceFilePath function...
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value
This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between ...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:59
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition: wimax-helper.h:87
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
Definition: wimax-helper.h:67
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition: wimax-helper.h:68
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ns3WimaxPhyTestSuite ns3WimaxPhyTestSuite
the test suite
Definition: phy-test.cc:197