A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
27
using namespace
ns3
;
28
38
class
Ns3WimaxNetworkEntryTestCase
:
public
TestCase
39
{
40
public
:
41
Ns3WimaxNetworkEntryTestCase
();
42
~Ns3WimaxNetworkEntryTestCase
()
override
;
43
44
private
:
45
void
DoRun
()
override
;
46
};
47
48
Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase
()
49
:
TestCase
(
"Test the network entry procedure"
)
50
{
51
}
52
53
Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase
()
54
{
55
}
56
57
void
58
Ns3WimaxNetworkEntryTestCase::DoRun
()
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
{
84
NS_TEST_EXPECT_MSG_EQ
(
85
ssDevs.
Get
(i)->GetObject<
SubscriberStationNetDevice
>()->
IsRegistered
(),
86
true
,
87
"SS["
<< i <<
"] IsNotRegistered"
);
88
}
89
Simulator::Destroy
();
90
}
91
101
class
Ns3WimaxManagementConnectionsTestCase
:
public
TestCase
102
{
103
public
:
104
Ns3WimaxManagementConnectionsTestCase
();
105
~Ns3WimaxManagementConnectionsTestCase
()
override
;
106
107
private
:
108
void
DoRun
()
override
;
109
};
110
111
Ns3WimaxManagementConnectionsTestCase::Ns3WimaxManagementConnectionsTestCase
()
112
:
TestCase
(
"Test if the management connections are correctly setup"
)
113
{
114
}
115
116
Ns3WimaxManagementConnectionsTestCase::~Ns3WimaxManagementConnectionsTestCase
()
117
{
118
}
119
120
void
121
Ns3WimaxManagementConnectionsTestCase::DoRun
()
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
>()
149
->
GetAreManagementConnectionsAllocated
(),
150
true
,
151
"Management connections for SS["
<< i <<
"] are not allocated"
);
152
}
153
Simulator::Destroy
();
154
}
155
162
class
Ns3WimaxSSMacTestSuite
:
public
TestSuite
163
{
164
public
:
165
Ns3WimaxSSMacTestSuite
();
166
};
167
168
Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite
()
169
:
TestSuite
(
"wimax-ss-mac-layer"
, UNIT)
170
{
171
AddTestCase
(
new
Ns3WimaxNetworkEntryTestCase
,
TestCase::QUICK
);
172
AddTestCase
(
new
Ns3WimaxManagementConnectionsTestCase
,
TestCase::QUICK
);
173
}
174
175
static
Ns3WimaxSSMacTestSuite
ns3WimaxSSMacTestSuite
;
Ns3WimaxManagementConnectionsTestCase
Test if the management connections are correctly setup.
Definition:
ss-mac-test.cc:102
Ns3WimaxManagementConnectionsTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
ss-mac-test.cc:121
Ns3WimaxManagementConnectionsTestCase::Ns3WimaxManagementConnectionsTestCase
Ns3WimaxManagementConnectionsTestCase()
Definition:
ss-mac-test.cc:111
Ns3WimaxManagementConnectionsTestCase::~Ns3WimaxManagementConnectionsTestCase
~Ns3WimaxManagementConnectionsTestCase() override
Definition:
ss-mac-test.cc:116
Ns3WimaxNetworkEntryTestCase
Test the network entry procedure.
Definition:
ss-mac-test.cc:39
Ns3WimaxNetworkEntryTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
ss-mac-test.cc:58
Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase
~Ns3WimaxNetworkEntryTestCase() override
Definition:
ss-mac-test.cc:53
Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase
Ns3WimaxNetworkEntryTestCase()
Definition:
ss-mac-test.cc:48
Ns3WimaxSSMacTestSuite
Ns3 Wimax SS Mac Test Suite.
Definition:
ss-mac-test.cc:163
Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite
Ns3WimaxSSMacTestSuite()
Definition:
ss-mac-test.cc:168
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition:
net-device-container.h:43
ns3::NetDeviceContainer::Get
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Definition:
net-device-container.cc:67
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:40
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition:
node-container.cc:84
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition:
simulator.cc:140
ns3::Simulator::Run
static void Run()
Run the simulation.
Definition:
simulator.cc:176
ns3::Simulator::Stop
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition:
simulator.cc:184
ns3::SubscriberStationNetDevice
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition:
ss-net-device.h:50
ns3::SubscriberStationNetDevice::GetAreManagementConnectionsAllocated
bool GetAreManagementConnectionsAllocated() const
Definition:
ss-net-device.cc:552
ns3::SubscriberStationNetDevice::IsRegistered
bool IsRegistered() const
Definition:
ss-net-device.cc:1341
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::QUICK
@ QUICK
Fast test.
Definition:
test.h:1065
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::WimaxHelper
helps to manage and create WimaxNetDevice objects
Definition:
wimax-helper.h:59
ns3::WimaxHelper::SchedulerType
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition:
wimax-helper.h:86
ns3::WimaxHelper::SCHED_TYPE_SIMPLE
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition:
wimax-helper.h:87
ns3::WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
Definition:
wimax-helper.h:67
ns3::WimaxHelper::DEVICE_TYPE_BASE_STATION
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition:
wimax-helper.h:68
ns3::WimaxHelper::SIMPLE_PHY_TYPE_OFDM
@ SIMPLE_PHY_TYPE_OFDM
Definition:
wimax-helper.h:78
ns3::WimaxHelper::Install
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
Definition:
wimax-helper.cc:265
NS_TEST_EXPECT_MSG_EQ
#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
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1336
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3WimaxSSMacTestSuite
static Ns3WimaxSSMacTestSuite ns3WimaxSSMacTestSuite
the test suite
Definition:
ss-mac-test.cc:175
src
wimax
test
ss-mac-test.cc
Generated on Sun Jul 2 2023 18:22:20 for ns-3 by
1.9.6