A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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/abort.h"
23
#include "ns3/test.h"
24
#include "ns3/config.h"
25
#include "ns3/string.h"
26
#include "ns3/uinteger.h"
27
#include "ns3/inet-socket-address.h"
28
#include "ns3/point-to-point-helper.h"
29
#include "ns3/internet-stack-helper.h"
30
#include "ns3/ipv4-address-helper.h"
31
#include "ns3/ipv4-header.h"
32
#include "ns3/packet-sink-helper.h"
33
#include "ns3/udp-client-server-helper.h"
34
#include "ns3/udp-header.h"
35
#include "ns3/simulator.h"
36
#include "ns3/wimax-helper.h"
37
#include "ns3/mobility-helper.h"
38
#include <iostream>
39
#include "ns3/global-route-manager.h"
40
41
using namespace
ns3;
42
43
/*
44
* Test the network entry procedure.
45
* Create a network with a BS and 10 SS and check that all the SS perform the
46
* network entry correctly
47
*
48
*/
49
class
Ns3WimaxNetworkEntryTestCase
:
public
TestCase
50
{
51
public
:
52
Ns3WimaxNetworkEntryTestCase
();
53
virtual
~
Ns3WimaxNetworkEntryTestCase
();
54
55
private
:
56
virtual
void
DoRun (
void
);
57
58
};
59
60
Ns3WimaxNetworkEntryTestCase::Ns3WimaxNetworkEntryTestCase
()
61
:
TestCase
(
"Test the network entry procedure"
)
62
{
63
}
64
65
Ns3WimaxNetworkEntryTestCase::~Ns3WimaxNetworkEntryTestCase
()
66
{
67
}
68
69
void
70
Ns3WimaxNetworkEntryTestCase::DoRun
(
void
)
71
{
72
WimaxHelper::SchedulerType
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
73
NodeContainer
ssNodes;
74
NodeContainer
bsNodes;
75
76
ssNodes.
Create
(10);
77
bsNodes.
Create
(1);
78
79
WimaxHelper
wimax;
80
81
NetDeviceContainer
ssDevs, bsDevs;
82
83
ssDevs = wimax.
Install
(ssNodes,
84
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
85
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
86
scheduler);
87
bsDevs = wimax.
Install
(bsNodes,
88
WimaxHelper::DEVICE_TYPE_BASE_STATION,
89
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
90
scheduler);
91
Simulator::Stop (
Seconds
(1));
92
Simulator::Run
();
93
for
(
int
i = 0; i < 10; i++)
94
{
95
NS_TEST_EXPECT_MSG_EQ
(ssDevs.
Get
(i)->
GetObject
<
SubscriberStationNetDevice
> ()->IsRegistered (),
true
,
96
"SS["
<< i <<
"] IsNotRegistered"
);
97
}
98
Simulator::Destroy ();
99
}
100
101
/*
102
* Test if the management connections are correctly setup.
103
* Create a network with a BS and 10 SS and check that the management
104
* connections are correctly setup for all SS
105
*
106
*/
107
108
class
Ns3WimaxManagementConnectionsTestCase
:
public
TestCase
109
{
110
public
:
111
Ns3WimaxManagementConnectionsTestCase
();
112
virtual
~Ns3WimaxManagementConnectionsTestCase
();
113
114
private
:
115
virtual
void
DoRun
(
void
);
116
117
};
118
119
Ns3WimaxManagementConnectionsTestCase::Ns3WimaxManagementConnectionsTestCase
()
120
:
TestCase
(
"Test if the management connections are correctly setup"
)
121
{
122
}
123
124
Ns3WimaxManagementConnectionsTestCase::~Ns3WimaxManagementConnectionsTestCase
()
125
{
126
}
127
128
void
129
Ns3WimaxManagementConnectionsTestCase::DoRun
(
void
)
130
{
131
WimaxHelper::SchedulerType
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
132
NodeContainer
ssNodes;
133
NodeContainer
bsNodes;
134
135
ssNodes.
Create
(10);
136
bsNodes.
Create
(1);
137
138
WimaxHelper
wimax;
139
140
NetDeviceContainer
ssDevs, bsDevs;
141
142
ssDevs = wimax.
Install
(ssNodes,
143
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
144
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
145
scheduler);
146
bsDevs = wimax.
Install
(bsNodes,
147
WimaxHelper::DEVICE_TYPE_BASE_STATION,
148
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
149
scheduler);
150
Simulator::Stop (
Seconds
(1));
151
Simulator::Run
();
152
for
(
int
i = 0; i < 10; i++)
153
{
154
NS_TEST_EXPECT_MSG_EQ
(ssDevs.
Get
(i)->
GetObject
<
SubscriberStationNetDevice
> ()->GetAreManagementConnectionsAllocated (),
155
true
,
"Management connections for SS["
<< i <<
"] are not allocated"
);
156
}
157
Simulator::Destroy ();
158
}
159
class
Ns3WimaxSSMacTestSuite
:
public
TestSuite
160
{
161
public
:
162
Ns3WimaxSSMacTestSuite
();
163
};
164
165
Ns3WimaxSSMacTestSuite::Ns3WimaxSSMacTestSuite
()
166
:
TestSuite
(
"wimax-ss-mac-layer"
, UNIT)
167
{
168
AddTestCase
(
new
Ns3WimaxNetworkEntryTestCase
);
169
AddTestCase
(
new
Ns3WimaxManagementConnectionsTestCase
);
170
}
171
172
static
Ns3WimaxSSMacTestSuite
ns3WimaxSSMacTestSuite
;
src
wimax
test
ss-mac-test.cc
Generated on Tue Oct 9 2012 16:45:50 for ns-3 by
1.8.1.2