A Discrete-Event Network Simulator
API
 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 
52 {
53 public:
55  virtual ~Ns3WimaxSimpleOFDMTestCase ();
56 
57 private:
58  virtual void DoRun (void);
59  bool DoRunOnce (double);
60 
61 };
62 
64  : TestCase ("Test the Phy model with different frame durations")
65 {
66 }
67 
69 {
70 }
71 
72 bool
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
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 
127 {
128 public:
130  virtual ~Ns3WimaxSNRtoBLERTestCase ();
131 
132 private:
133  virtual void DoRun (void);
134  bool DoRunOnce (uint8_t);
135 
136 };
137 
139  : TestCase ("Test the SNR to block error rate module")
140 {
141 }
142 
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
165 {
166  for (int i = 0; i < 7; i++)
167  {
168  DoRunOnce (i);
169  }
170 }
171 
172 /*
173  * The test suite
174  */
176 {
177 public:
179 };
181  : TestSuite ("wimax-phy-layer", UNIT)
182 {
183  AddTestCase (new Ns3WimaxSNRtoBLERTestCase, TestCase::QUICK);
184  AddTestCase (new Ns3WimaxSimpleOFDMTestCase, TestCase::QUICK);
185 
186 }
187 
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
A suite of tests to run.
Definition: test.h:1105
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
encapsulates test code
Definition: test.h:929
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
virtual ~Ns3WimaxSNRtoBLERTestCase()
Definition: phy-test.cc:143
This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between ...
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value ...
holds a vector of ns3::NetDevice pointers
bool DoRunOnce(double)
Definition: phy-test.cc:73
virtual ~Ns3WimaxSimpleOFDMTestCase()
Definition: phy-test.cc:68
void LoadTraces(void)
Loads the traces form the repository specified in the constructor or setted by SetTraceFilePath funct...
static Ns3WimaxPhyTestSuite ns3WimaxPhyTestSuite
Definition: phy-test.cc:188
keep track of a set of node pointers.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: phy-test.cc:164
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:213
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: phy-test.cc:107
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:59
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.
bool DoRunOnce(uint8_t)
Definition: phy-test.cc:147