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
* 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/test.h"
14
#include "ns3/wimax-helper.h"
15
16
using namespace
ns3
;
17
18
/**
19
* @ingroup wimax-test
20
* @ingroup tests
21
*
22
* @brief Test the network entry procedure.
23
* Create a network with a BS and 10 SS and check that all the SS perform the
24
* network entry correctly
25
*
26
*/
27
class
Ns3WimaxNetworkEntryTestCase
:
public
TestCase
28
{
29
public
:
30
Ns3WimaxNetworkEntryTestCase
();
31
~Ns3WimaxNetworkEntryTestCase
()
override
;
32
33
private
:
34
void
DoRun
()
override
;
35
};
36
37
Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase
()
38
:
TestCase
(
"Test the network entry procedure"
)
39
{
40
}
41
42
Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase
()
43
{
44
}
45
46
void
47
Ns3WimaxNetworkEntryTestCase::DoRun
()
48
{
49
WimaxHelper::SchedulerType
scheduler =
WimaxHelper::SCHED_TYPE_SIMPLE
;
50
NodeContainer
ssNodes;
51
NodeContainer
bsNodes;
52
53
ssNodes.
Create
(10);
54
bsNodes.
Create
(1);
55
56
WimaxHelper
wimax;
57
58
NetDeviceContainer
ssDevs;
59
NetDeviceContainer
bsDevs;
60
61
ssDevs = wimax.
Install
(ssNodes,
62
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION
,
63
WimaxHelper::SIMPLE_PHY_TYPE_OFDM
,
64
scheduler);
65
bsDevs = wimax.
Install
(bsNodes,
66
WimaxHelper::DEVICE_TYPE_BASE_STATION
,
67
WimaxHelper::SIMPLE_PHY_TYPE_OFDM
,
68
scheduler);
69
Simulator::Stop
(
Seconds
(1));
70
Simulator::Run
();
71
for
(
int
i = 0; i < 10; i++)
72
{
73
NS_TEST_EXPECT_MSG_EQ
(
74
ssDevs.
Get
(i)->GetObject<
SubscriberStationNetDevice
>()->
IsRegistered
(),
75
true
,
76
"SS["
<< i <<
"] IsNotRegistered"
);
77
}
78
Simulator::Destroy
();
79
}
80
81
/**
82
* @ingroup wimax-test
83
* @ingroup tests
84
*
85
* @brief Test if the management connections are correctly setup.
86
* Create a network with a BS and 10 SS and check that the management
87
* connections are correctly setup for all SS
88
*
89
*/
90
class
Ns3WimaxManagementConnectionsTestCase
:
public
TestCase
91
{
92
public
:
93
Ns3WimaxManagementConnectionsTestCase
();
94
~Ns3WimaxManagementConnectionsTestCase
()
override
;
95
96
private
:
97
void
DoRun
()
override
;
98
};
99
100
Ns3WimaxManagementConnectionsTestCase::Ns3WimaxManagementConnectionsTestCase
()
101
:
TestCase
(
"Test if the management connections are correctly setup"
)
102
{
103
}
104
105
Ns3WimaxManagementConnectionsTestCase::~Ns3WimaxManagementConnectionsTestCase
()
106
{
107
}
108
109
void
110
Ns3WimaxManagementConnectionsTestCase::DoRun
()
111
{
112
WimaxHelper::SchedulerType
scheduler =
WimaxHelper::SCHED_TYPE_SIMPLE
;
113
NodeContainer
ssNodes;
114
NodeContainer
bsNodes;
115
116
ssNodes.
Create
(10);
117
bsNodes.
Create
(1);
118
119
WimaxHelper
wimax;
120
121
NetDeviceContainer
ssDevs;
122
NetDeviceContainer
bsDevs;
123
124
ssDevs = wimax.
Install
(ssNodes,
125
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION
,
126
WimaxHelper::SIMPLE_PHY_TYPE_OFDM
,
127
scheduler);
128
bsDevs = wimax.
Install
(bsNodes,
129
WimaxHelper::DEVICE_TYPE_BASE_STATION
,
130
WimaxHelper::SIMPLE_PHY_TYPE_OFDM
,
131
scheduler);
132
Simulator::Stop
(
Seconds
(1));
133
Simulator::Run
();
134
for
(
int
i = 0; i < 10; i++)
135
{
136
NS_TEST_EXPECT_MSG_EQ
(ssDevs.
Get
(i)
137
->GetObject<
SubscriberStationNetDevice
>()
138
->
GetAreManagementConnectionsAllocated
(),
139
true
,
140
"Management connections for SS["
<< i <<
"] are not allocated"
);
141
}
142
Simulator::Destroy
();
143
}
144
145
/**
146
* @ingroup wimax-test
147
* @ingroup tests
148
*
149
* @brief Ns3 Wimax SS Mac Test Suite
150
*/
151
class
Ns3WimaxSSMacTestSuite
:
public
TestSuite
152
{
153
public
:
154
Ns3WimaxSSMacTestSuite
();
155
};
156
157
Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite
()
158
:
TestSuite
(
"wimax-ss-mac-layer"
,
Type
::UNIT)
159
{
160
AddTestCase
(
new
Ns3WimaxNetworkEntryTestCase
, TestCase::Duration::QUICK);
161
AddTestCase
(
new
Ns3WimaxManagementConnectionsTestCase
, TestCase::Duration::QUICK);
162
}
163
164
static
Ns3WimaxSSMacTestSuite
ns3WimaxSSMacTestSuite
;
///< the test suite
Ns3WimaxManagementConnectionsTestCase
Test if the management connections are correctly setup.
Definition
ss-mac-test.cc:91
Ns3WimaxManagementConnectionsTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
ss-mac-test.cc:110
Ns3WimaxManagementConnectionsTestCase::Ns3WimaxManagementConnectionsTestCase
Ns3WimaxManagementConnectionsTestCase()
Definition
ss-mac-test.cc:100
Ns3WimaxManagementConnectionsTestCase::~Ns3WimaxManagementConnectionsTestCase
~Ns3WimaxManagementConnectionsTestCase() override
Definition
ss-mac-test.cc:105
Ns3WimaxNetworkEntryTestCase
Test the network entry procedure.
Definition
ss-mac-test.cc:28
Ns3WimaxNetworkEntryTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
ss-mac-test.cc:47
Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase
~Ns3WimaxNetworkEntryTestCase() override
Definition
ss-mac-test.cc:42
Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase
Ns3WimaxNetworkEntryTestCase()
Definition
ss-mac-test.cc:37
Ns3WimaxSSMacTestSuite
Ns3 Wimax SS Mac Test Suite.
Definition
ss-mac-test.cc:152
Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite
Ns3WimaxSSMacTestSuite()
Definition
ss-mac-test.cc:157
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition
net-device-container.h:32
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:56
ns3::NodeContainer
keep track of a set of node pointers.
Definition
node-container.h:29
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:73
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition
simulator.cc:131
ns3::Simulator::Run
static void Run()
Run the simulation.
Definition
simulator.cc:167
ns3::Simulator::Stop
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition
simulator.cc:175
ns3::SubscriberStationNetDevice
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition
ss-net-device.h:39
ns3::SubscriberStationNetDevice::GetAreManagementConnectionsAllocated
bool GetAreManagementConnectionsAllocated() const
Definition
ss-net-device.cc:541
ns3::SubscriberStationNetDevice::IsRegistered
bool IsRegistered() const
Definition
ss-net-device.cc:1320
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
ns3::WimaxHelper
helps to manage and create WimaxNetDevice objects
Definition
wimax-helper.h:48
ns3::WimaxHelper::SchedulerType
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition
wimax-helper.h:75
ns3::WimaxHelper::SCHED_TYPE_SIMPLE
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition
wimax-helper.h:76
ns3::WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
Definition
wimax-helper.h:56
ns3::WimaxHelper::DEVICE_TYPE_BASE_STATION
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition
wimax-helper.h:57
ns3::WimaxHelper::SIMPLE_PHY_TYPE_OFDM
@ SIMPLE_PHY_TYPE_OFDM
Definition
wimax-helper.h:67
ns3::WimaxHelper::Install
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
Definition
wimax-helper.cc:254
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:241
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1344
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:164
src
wimax
test
ss-mac-test.cc
Generated on Thu Dec 5 2024 18:20:57 for ns-3 by
1.11.0