A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
ss-mac-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/test.h"
23
#include "ns3/simulator.h"
24
#include "ns3/wimax-helper.h"
25
#include "ns3/net-device-container.h"
26
#include "ns3/node-container.h"
27
28
using namespace
ns3
;
29
39
class
Ns3WimaxNetworkEntryTestCase
:
public
TestCase
40
{
41
public
:
42
Ns3WimaxNetworkEntryTestCase
();
43
virtual
~
Ns3WimaxNetworkEntryTestCase
();
44
45
private
:
46
virtual
void
DoRun (
void
);
47
48
};
49
50
Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase
()
51
:
TestCase
(
"Test the network entry procedure"
)
52
{
53
}
54
55
Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase
()
56
{
57
}
58
59
void
60
Ns3WimaxNetworkEntryTestCase::DoRun
(
void
)
61
{
62
WimaxHelper::SchedulerType
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
63
NodeContainer
ssNodes;
64
NodeContainer
bsNodes;
65
66
ssNodes.
Create
(10);
67
bsNodes.
Create
(1);
68
69
WimaxHelper
wimax;
70
71
NetDeviceContainer
ssDevs, bsDevs;
72
73
ssDevs = wimax.
Install
(ssNodes,
74
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
75
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
76
scheduler);
77
bsDevs = wimax.
Install
(bsNodes,
78
WimaxHelper::DEVICE_TYPE_BASE_STATION,
79
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
80
scheduler);
81
Simulator::Stop (
Seconds
(1));
82
Simulator::Run ();
83
for
(
int
i = 0; i < 10; i++)
84
{
85
NS_TEST_EXPECT_MSG_EQ
(ssDevs.
Get
(i)->
GetObject
<
SubscriberStationNetDevice
> ()->
IsRegistered
(),
true
,
86
"SS["
<< i <<
"] IsNotRegistered"
);
87
}
88
Simulator::Destroy ();
89
}
90
100
class
Ns3WimaxManagementConnectionsTestCase
:
public
TestCase
101
{
102
public
:
103
Ns3WimaxManagementConnectionsTestCase
();
104
virtual
~Ns3WimaxManagementConnectionsTestCase
();
105
106
private
:
107
virtual
void
DoRun
(
void
);
108
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
(
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, bsDevs;
133
134
ssDevs = wimax.
Install
(ssNodes,
135
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
136
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
137
scheduler);
138
bsDevs = wimax.
Install
(bsNodes,
139
WimaxHelper::DEVICE_TYPE_BASE_STATION,
140
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
141
scheduler);
142
Simulator::Stop (
Seconds
(1));
143
Simulator::Run ();
144
for
(
int
i = 0; i < 10; i++)
145
{
146
NS_TEST_EXPECT_MSG_EQ
(ssDevs.
Get
(i)->
GetObject
<
SubscriberStationNetDevice
> ()->
GetAreManagementConnectionsAllocated
(),
147
true
,
"Management connections for SS["
<< i <<
"] are not allocated"
);
148
}
149
Simulator::Destroy ();
150
}
151
158
class
Ns3WimaxSSMacTestSuite
:
public
TestSuite
159
{
160
public
:
161
Ns3WimaxSSMacTestSuite
();
162
};
163
164
Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite
()
165
:
TestSuite
(
"wimax-ss-mac-layer"
, UNIT)
166
{
167
AddTestCase
(
new
Ns3WimaxNetworkEntryTestCase
, TestCase::QUICK);
168
AddTestCase
(
new
Ns3WimaxManagementConnectionsTestCase
, TestCase::QUICK);
169
}
170
171
static
Ns3WimaxSSMacTestSuite
ns3WimaxSSMacTestSuite
;
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition:
net-device-container.h:42
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SubscriberStationNetDevice::GetAreManagementConnectionsAllocated
bool GetAreManagementConnectionsAllocated(void) const
Definition:
ss-net-device.cc:532
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition:
object.h:470
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:98
ns3WimaxSSMacTestSuite
static Ns3WimaxSSMacTestSuite ns3WimaxSSMacTestSuite
the test suite
Definition:
ss-mac-test.cc:171
ns3::TestCase
encapsulates test code
Definition:
test.h:1154
Ns3WimaxManagementConnectionsTestCase::Ns3WimaxManagementConnectionsTestCase
Ns3WimaxManagementConnectionsTestCase()
Definition:
ss-mac-test.cc:111
Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase
Ns3WimaxNetworkEntryTestCase()
Definition:
ss-mac-test.cc:50
ns3::WimaxHelper::Install
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
Definition:
wimax-helper.cc:249
Ns3WimaxManagementConnectionsTestCase::~Ns3WimaxManagementConnectionsTestCase
virtual ~Ns3WimaxManagementConnectionsTestCase()
Definition:
ss-mac-test.cc:116
Ns3WimaxManagementConnectionsTestCase
Test if the management connections are correctly setup.
Definition:
ss-mac-test.cc:101
ns3::WimaxHelper
helps to manage and create WimaxNetDevice objects
Definition:
wimax-helper.h:59
Ns3WimaxNetworkEntryTestCase
Test the network entry procedure.
Definition:
ss-mac-test.cc:40
Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite
Ns3WimaxSSMacTestSuite()
Definition:
ss-mac-test.cc:164
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:283
ns3::SubscriberStationNetDevice
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition:
ss-net-device.h:49
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1344
Ns3WimaxManagementConnectionsTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
ss-mac-test.cc:121
Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase
virtual ~Ns3WimaxNetworkEntryTestCase()
Definition:
ss-mac-test.cc:55
ns3::SubscriberStationNetDevice::IsRegistered
bool IsRegistered(void) const
Definition:
ss-net-device.cc:1308
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1289
Ns3WimaxSSMacTestSuite
Ns3 Wimax SS Mac Test Suite.
Definition:
ss-mac-test.cc:159
Ns3WimaxNetworkEntryTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
ss-mac-test.cc:60
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:39
ns3::WimaxHelper::SchedulerType
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition:
wimax-helper.h:86
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:62
src
wimax
test
ss-mac-test.cc
Generated on Fri Oct 1 2021 17:03:55 for ns-3 by
1.8.20