A Discrete-Event Network Simulator
API
ss-mac-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/test.h"
25 #include "ns3/wimax-helper.h"
26 
27 using namespace ns3;
28 
39 {
40  public:
42  ~Ns3WimaxNetworkEntryTestCase() override;
43 
44  private:
45  void DoRun() override;
46 };
47 
49  : TestCase("Test the network entry procedure")
50 {
51 }
52 
54 {
55 }
56 
57 void
59 {
60  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
61  NodeContainer ssNodes;
62  NodeContainer bsNodes;
63 
64  ssNodes.Create(10);
65  bsNodes.Create(1);
66 
67  WimaxHelper wimax;
68 
69  NetDeviceContainer ssDevs;
70  NetDeviceContainer bsDevs;
71 
72  ssDevs = wimax.Install(ssNodes,
73  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
74  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
75  scheduler);
76  bsDevs = wimax.Install(bsNodes,
77  WimaxHelper::DEVICE_TYPE_BASE_STATION,
78  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
79  scheduler);
80  Simulator::Stop(Seconds(1));
81  Simulator::Run();
82  for (int i = 0; i < 10; i++)
83  {
85  ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>()->IsRegistered(),
86  true,
87  "SS[" << i << "] IsNotRegistered");
88  }
89  Simulator::Destroy();
90 }
91 
102 {
103  public:
106 
107  private:
108  void DoRun() override;
109 };
110 
112  : TestCase("Test if the management connections are correctly setup")
113 {
114 }
115 
117 {
118 }
119 
120 void
122 {
123  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
124  NodeContainer ssNodes;
125  NodeContainer bsNodes;
126 
127  ssNodes.Create(10);
128  bsNodes.Create(1);
129 
130  WimaxHelper wimax;
131 
132  NetDeviceContainer ssDevs;
133  NetDeviceContainer bsDevs;
134 
135  ssDevs = wimax.Install(ssNodes,
136  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
137  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
138  scheduler);
139  bsDevs = wimax.Install(bsNodes,
140  WimaxHelper::DEVICE_TYPE_BASE_STATION,
141  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
142  scheduler);
143  Simulator::Stop(Seconds(1));
144  Simulator::Run();
145  for (int i = 0; i < 10; i++)
146  {
147  NS_TEST_EXPECT_MSG_EQ(ssDevs.Get(i)
148  ->GetObject<SubscriberStationNetDevice>()
150  true,
151  "Management connections for SS[" << i << "] are not allocated");
152  }
153  Simulator::Destroy();
154 }
155 
163 {
164  public:
166 };
167 
169  : TestSuite("wimax-ss-mac-layer", UNIT)
170 {
171  AddTestCase(new Ns3WimaxNetworkEntryTestCase, TestCase::QUICK);
173 }
174 
Test if the management connections are correctly setup.
Definition: ss-mac-test.cc:102
void DoRun() override
Implementation to actually run this TestCase.
Definition: ss-mac-test.cc:121
Test the network entry procedure.
Definition: ss-mac-test.cc:39
void DoRun() override
Implementation to actually run this TestCase.
Definition: ss-mac-test.cc:58
~Ns3WimaxNetworkEntryTestCase() override
Definition: ss-mac-test.cc:53
Ns3WimaxNetworkEntryTestCase()
Definition: ss-mac-test.cc:48
Ns3 Wimax SS Mac Test Suite.
Definition: ss-mac-test.cc:163
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.
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
bool GetAreManagementConnectionsAllocated() const
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_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:251
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 Ns3WimaxSSMacTestSuite ns3WimaxSSMacTestSuite
the test suite
Definition: ss-mac-test.cc:175