A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
27using namespace ns3;
28
29/**
30 * \ingroup wimax-test
31 * \ingroup tests
32 *
33 * \brief Test the network entry procedure.
34 * Create a network with a BS and 10 SS and check that all the SS perform the
35 * network entry correctly
36 *
37 */
39{
40 public:
43
44 private:
45 void DoRun() override;
46};
47
49 : TestCase("Test the network entry procedure")
50{
51}
52
54{
55}
56
57void
59{
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,
75 scheduler);
76 bsDevs = wimax.Install(bsNodes,
79 scheduler);
82 for (int i = 0; i < 10; i++)
83 {
85 ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>()->IsRegistered(),
86 true,
87 "SS[" << i << "] IsNotRegistered");
88 }
90}
91
92/**
93 * \ingroup wimax-test
94 * \ingroup tests
95 *
96 * \brief Test if the management connections are correctly setup.
97 * Create a network with a BS and 10 SS and check that the management
98 * connections are correctly setup for all SS
99 *
100 */
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
120void
122{
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,
138 scheduler);
139 bsDevs = wimax.Install(bsNodes,
142 scheduler);
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 }
154}
155
156/**
157 * \ingroup wimax-test
158 * \ingroup tests
159 *
160 * \brief Ns3 Wimax SS Mac Test Suite
161 */
163{
164 public:
166};
167
169 : TestSuite("wimax-ss-mac-layer", Type::UNIT)
170{
171 AddTestCase(new Ns3WimaxNetworkEntryTestCase, TestCase::Duration::QUICK);
172 AddTestCase(new Ns3WimaxManagementConnectionsTestCase, TestCase::Duration::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.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
bool GetAreManagementConnectionsAllocated() const
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
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
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition: wimax-helper.h:87
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
Definition: wimax-helper.h:67
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition: wimax-helper.h:68
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:252
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