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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 */
9#include "ns3/log.h"
10#include "ns3/net-device-container.h"
11#include "ns3/node-container.h"
12#include "ns3/simulator.h"
13#include "ns3/snr-to-block-error-rate-manager.h"
14#include "ns3/test.h"
15#include "ns3/wimax-helper.h"
16
17using namespace ns3;
18
19NS_LOG_COMPONENT_DEFINE("WimaxPhyTest");
20
21/*
22 * Configure a network with 3 SS and 1 BS
23 * Install a SIMPLE OFDM PHY layer on all nodes and check that all SSs
24 * could register with the BS
25 *
26 */
27
28/**
29 * \ingroup wimax-test
30 * \ingroup tests
31 *
32 * \brief Ns3 Wimax Simple OFDM Test Case
33 */
35{
36 public:
39
40 private:
41 void DoRun() override;
42 /**
43 * Run once function
44 * \param FrameDuration the frame duration
45 * \returns true if successful
46 */
47 bool DoRunOnce(double FrameDuration);
48};
49
51 : TestCase("Test the Phy model with different frame durations")
52{
53}
54
58
59bool
61{
63 NodeContainer ssNodes;
64 NodeContainer bsNodes;
65 ssNodes.Create(3);
66 bsNodes.Create(1);
67
68 WimaxHelper wimax;
69
70 NetDeviceContainer ssDevs;
71 NetDeviceContainer bsDevs;
72
73 ssDevs = wimax.Install(ssNodes,
76 scheduler,
77 FrameDuration);
78 bsDevs = wimax.Install(bsNodes,
81 scheduler,
82 FrameDuration);
83
86 for (int i = 0; i < 3; i++)
87 {
88 if (!ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>()->IsRegistered())
89 {
90 NS_LOG_DEBUG("SS[" << i << "] not registered");
91 return true; // Test fail because SS[i] is not registered
92 }
93 }
95 return false; // Test was ok, all the SSs are registered
96}
97
98void
100{
101 double frameDuratioTab[7] = {0.0025, 0.004, 0.005, 0.008, 0.01, 0.0125, 0.02};
102 for (int i = 0; i < 7; i++)
103 {
104 NS_LOG_DEBUG("Frame Duration = " << frameDuratioTab[i]);
105 if (DoRunOnce(frameDuratioTab[i]))
106 {
107 return;
108 }
109 }
110}
111
112/**
113 * \ingroup wimax-test
114 * \ingroup tests
115 *
116 * \brief Test the SNr tom block error rate module
117 */
119{
120 public:
123
124 private:
125 void DoRun() override;
126 /**
127 * Run once function
128 * \param modulationType the modulation type
129 * \returns true if successful
130 */
131 bool DoRunOnce(uint8_t modulationType);
132};
133
135 : TestCase("Test the SNR to block error rate module")
136{
137}
138
142
143bool
145{
146 SNRToBlockErrorRateManager l_SNRToBlockErrorRateManager;
147 l_SNRToBlockErrorRateManager.LoadTraces();
149
150 for (double i = -5; i < 40; i += 0.1)
151 {
152 BLERRec = l_SNRToBlockErrorRateManager.GetSNRToBlockErrorRateRecord(i, modulationType);
153 delete BLERRec;
154 }
155 return false;
156}
157
158void
160{
161 for (int i = 0; i < 7; i++)
162 {
163 DoRunOnce(i);
164 }
165}
166
167/**
168 * \ingroup wimax-test
169 * \ingroup tests
170 *
171 * \brief The test suite
172 */
174{
175 public:
177};
178
180 : TestSuite("wimax-phy-layer", Type::UNIT)
181{
182 AddTestCase(new Ns3WimaxSNRtoBLERTestCase, TestCase::Duration::QUICK);
183 AddTestCase(new Ns3WimaxSimpleOFDMTestCase, TestCase::Duration::QUICK);
184}
185
The test suite.
Definition phy-test.cc:174
Test the SNr tom block error rate module.
Definition phy-test.cc:119
void DoRun() override
Implementation to actually run this TestCase.
Definition phy-test.cc:159
~Ns3WimaxSNRtoBLERTestCase() override
Definition phy-test.cc:139
bool DoRunOnce(uint8_t modulationType)
Run once function.
Definition phy-test.cc:144
Ns3 Wimax Simple OFDM Test Case.
Definition phy-test.cc:35
void DoRun() override
Implementation to actually run this TestCase.
Definition phy-test.cc:99
~Ns3WimaxSimpleOFDMTestCase() override
Definition phy-test.cc:55
bool DoRunOnce(double FrameDuration)
Run once function.
Definition phy-test.cc:60
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:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
SubscriberStationNetDevice subclass of WimaxNetDevice.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
helps to manage and create WimaxNetDevice objects
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
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:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ns3WimaxPhyTestSuite ns3WimaxPhyTestSuite
the test suite
Definition phy-test.cc:186