A Discrete-Event Network Simulator
API
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 
28 using namespace ns3;
29 
30 NS_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 
46 {
47  public:
49  ~Ns3WimaxSimpleOFDMTestCase() override;
50 
51  private:
52  void DoRun() override;
58  bool DoRunOnce(double FrameDuration);
59 };
60 
62  : TestCase("Test the Phy model with different frame durations")
63 {
64 }
65 
67 {
68 }
69 
70 bool
72 {
73  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
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,
85  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
86  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
87  scheduler,
88  FrameDuration);
89  bsDevs = wimax.Install(bsNodes,
90  WimaxHelper::DEVICE_TYPE_BASE_STATION,
91  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
92  scheduler,
93  FrameDuration);
94 
95  Simulator::Stop(Seconds(1));
96  Simulator::Run();
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  }
105  Simulator::Destroy();
106  return false; // Test was ok, all the SSs are registered
107 }
108 
109 void
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 
130 {
131  public:
133  ~Ns3WimaxSNRtoBLERTestCase() override;
134 
135  private:
136  void DoRun() override;
142  bool DoRunOnce(uint8_t modulationType);
143 };
144 
146  : TestCase("Test the SNR to block error rate module")
147 {
148 }
149 
151 {
152 }
153 
154 bool
156 {
157  SNRToBlockErrorRateManager l_SNRToBlockErrorRateManager;
158  l_SNRToBlockErrorRateManager.LoadTraces();
159  SNRToBlockErrorRateRecord* BLERRec;
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 
169 void
171 {
172  for (int i = 0; i < 7; i++)
173  {
174  DoRunOnce(i);
175  }
176 }
177 
185 {
186  public:
188 };
189 
191  : TestSuite("wimax-phy-layer", UNIT)
192 {
193  AddTestCase(new Ns3WimaxSNRtoBLERTestCase, TestCase::QUICK);
194  AddTestCase(new Ns3WimaxSimpleOFDMTestCase, TestCase::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 ...
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
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: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