A Discrete-Event Network Simulator
API
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/test.h"
23#include "ns3/simulator.h"
24#include "ns3/node-container.h"
25#include "ns3/net-device-container.h"
26#include "ns3/wimax-helper.h"
27#include "ns3/snr-to-block-error-rate-manager.h"
28
29using namespace ns3;
30
31NS_LOG_COMPONENT_DEFINE ("WimaxPhyTest");
32
33/*
34 * Configure a network with 3 SS and 1 BS
35 * Install a SIMPLE OFDM PHY layer on all nodes and check that all SSs
36 * could register with the BS
37 *
38 */
39
47{
48public:
51
52private:
53 virtual void DoRun (void);
59 bool DoRunOnce (double FrameDuration);
60
61};
62
64 : TestCase ("Test the Phy model with different frame durations")
65{
66}
67
69{
70}
71
72bool
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 {
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
106void
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
129{
130public:
133
134private:
135 virtual void DoRun (void);
141 bool DoRunOnce (uint8_t modulationType);
142
143};
144
146 : TestCase ("Test the SNR to block error rate module")
147{
148}
149
151{
152}
153
154bool Ns3WimaxSNRtoBLERTestCase::DoRunOnce (uint8_t modulationType)
155{
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,
164 modulationType);
165 delete BLERRec;
166 }
167 return false;
168}
169
170void
172{
173 for (int i = 0; i < 7; i++)
174 {
175 DoRunOnce (i);
176 }
177}
178
186{
187public:
189};
191 : TestSuite ("wimax-phy-layer", UNIT)
192{
193 AddTestCase (new Ns3WimaxSNRtoBLERTestCase, TestCase::QUICK);
194 AddTestCase (new Ns3WimaxSimpleOFDMTestCase, TestCase::QUICK);
195
196}
197
The test suite.
Definition: phy-test.cc:186
Test the SNr tom block error rate module.
Definition: phy-test.cc:129
bool DoRunOnce(uint8_t modulationType)
Run once function.
Definition: phy-test.cc:154
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: phy-test.cc:171
virtual ~Ns3WimaxSNRtoBLERTestCase()
Definition: phy-test.cc:150
Ns3 Wimax Simple OFDM Test Case.
Definition: phy-test.cc:47
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: phy-test.cc:107
virtual ~Ns3WimaxSimpleOFDMTestCase()
Definition: phy-test.cc:68
bool DoRunOnce(double FrameDuration)
Run once function.
Definition: phy-test.cc:73
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.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
This class handles the SNR to BlcER traces.
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value
void LoadTraces(void)
Loads the traces form the repository specified in the constructor or set by SetTraceFilePath function...
This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between ...
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:49
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
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
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:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ns3WimaxPhyTestSuite ns3WimaxPhyTestSuite
the test suite
Definition: phy-test.cc:198