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
wimax-service-flow-test.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 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
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19
* <amine.ismail@udcast.com>
20
*
21
*/
22
#include "ns3/log.h"
23
#include "ns3/abort.h"
24
#include "ns3/test.h"
25
#include "ns3/uinteger.h"
26
#include "ns3/inet-socket-address.h"
27
#include "ns3/point-to-point-helper.h"
28
#include "ns3/internet-stack-helper.h"
29
#include "ns3/ipv4-address-helper.h"
30
#include "ns3/ipv4-header.h"
31
#include "ns3/packet-sink-helper.h"
32
#include "ns3/udp-client-server-helper.h"
33
#include "ns3/udp-header.h"
34
#include "ns3/simulator.h"
35
#include "ns3/wimax-helper.h"
36
#include "ns3/mobility-helper.h"
37
#include "ns3/global-route-manager.h"
38
#include "ns3/wimax-tlv.h"
39
#include "ns3/ipcs-classifier-record.h"
40
#include "ns3/service-flow.h"
41
#include <iostream>
42
43
using namespace
ns3;
44
45
/*
46
* Test the service flow creation.
47
*/
48
class
Ns3WimaxSfCreationTestCase
:
public
TestCase
49
{
50
public
:
51
Ns3WimaxSfCreationTestCase
();
52
virtual
~
Ns3WimaxSfCreationTestCase
();
53
54
private
:
55
virtual
void
DoRun (
void
);
56
57
};
58
59
Ns3WimaxSfCreationTestCase::Ns3WimaxSfCreationTestCase
()
60
:
TestCase
(
"Test the service flow tlv implementation."
)
61
{
62
}
63
64
Ns3WimaxSfCreationTestCase::~Ns3WimaxSfCreationTestCase
()
65
{
66
}
67
68
void
69
Ns3WimaxSfCreationTestCase::DoRun
(
void
)
70
{
71
72
// default values
73
int
duration = 2;
74
WimaxHelper::SchedulerType
scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
75
76
NodeContainer
ssNodes;
77
NodeContainer
bsNodes;
78
79
ssNodes.
Create
(1);
80
bsNodes.
Create
(1);
81
82
WimaxHelper
wimax;
83
84
NetDeviceContainer
ssDevs, bsDevs;
85
86
ssDevs = wimax.
Install
(ssNodes,
87
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
88
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
89
scheduler);
90
bsDevs = wimax.
Install
(bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
91
92
ssDevs.
Get
(0)->
GetObject
<
SubscriberStationNetDevice
> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
93
bsDevs.
Get
(0)->
GetObject
<
BaseStationNetDevice
> ();
94
95
InternetStackHelper
stack;
96
stack.
Install
(bsNodes);
97
stack.Install (ssNodes);
98
99
Ipv4AddressHelper
address;
100
address.
SetBase
(
"10.1.1.0"
,
"255.255.255.0"
);
101
102
Ipv4InterfaceContainer
SSinterfaces = address.
Assign
(ssDevs);
103
Ipv4InterfaceContainer
BSinterface = address.
Assign
(bsDevs);
104
105
// Create one UGS Downlink service flow between the ss and the bs
106
ServiceFlow
* DlServiceFlowUgs =
new
ServiceFlow
(ServiceFlow::SF_DIRECTION_DOWN);
107
IpcsClassifierRecord
DlClassifierUgs (
Ipv4Address
(
"0.0.0.0"
),
108
Ipv4Mask
(
"0.0.0.0"
),
109
Ipv4Address
(
"0.0.0.0"
),
110
Ipv4Mask
(
"0.0.0.0"
),
111
3000,
112
3000,
113
0,
114
35000,
115
17,
116
1);
117
CsParameters
DlcsParam (CsParameters::ADD, DlClassifierUgs);
118
DlServiceFlowUgs->
SetConvergenceSublayerParam
(DlcsParam);
119
DlServiceFlowUgs->
SetCsSpecification
(
ServiceFlow::IPV4
);
120
DlServiceFlowUgs->
SetServiceSchedulingType
(ServiceFlow::SF_TYPE_UGS);
121
DlServiceFlowUgs->
SetMaxSustainedTrafficRate
(1000000);
122
DlServiceFlowUgs->
SetMinReservedTrafficRate
(1000000);
123
DlServiceFlowUgs->
SetMinTolerableTrafficRate
(1000000);
124
DlServiceFlowUgs->
SetMaximumLatency
(10);
125
DlServiceFlowUgs->
SetMaxTrafficBurst
(1000);
126
DlServiceFlowUgs->
SetTrafficPriority
(1);
127
128
// Create one UGS Uplink service flow between the ss and the bs
129
ServiceFlow
* UlServiceFlowUgs =
new
ServiceFlow
(ServiceFlow::SF_DIRECTION_UP);
130
IpcsClassifierRecord
UlClassifierUgs (
Ipv4Address
(
"0.0.0.0"
),
131
Ipv4Mask
(
"0.0.0.0"
),
132
Ipv4Address
(
"0.0.0.0"
),
133
Ipv4Mask
(
"0.0.0.0"
),
134
0,
135
35000,
136
3000,
137
3000,
138
17,
139
1);
140
CsParameters
UlcsParam (CsParameters::ADD, UlClassifierUgs);
141
UlServiceFlowUgs->
SetConvergenceSublayerParam
(UlcsParam);
142
UlServiceFlowUgs->
SetCsSpecification
(
ServiceFlow::IPV4
);
143
UlServiceFlowUgs->
SetServiceSchedulingType
(ServiceFlow::SF_TYPE_UGS);
144
UlServiceFlowUgs->
SetMaxSustainedTrafficRate
(1000000);
145
UlServiceFlowUgs->
SetMinReservedTrafficRate
(1000000);
146
UlServiceFlowUgs->
SetMinTolerableTrafficRate
(1000000);
147
UlServiceFlowUgs->
SetMaximumLatency
(10);
148
UlServiceFlowUgs->
SetMaxTrafficBurst
(1000);
149
UlServiceFlowUgs->
SetTrafficPriority
(1);
150
ssDevs.
Get
(0)->
GetObject
<
SubscriberStationNetDevice
> ()->AddServiceFlow (DlServiceFlowUgs);
151
ssDevs.
Get
(0)->
GetObject
<
SubscriberStationNetDevice
> ()->AddServiceFlow (UlServiceFlowUgs);
152
153
Simulator::Stop (
Seconds
(duration));
154
Simulator::Run
();
155
Simulator::Destroy ();
156
}
157
158
// ==============================================================================
159
class
Ns3WimaxServiceFlowTestSuite
:
public
TestSuite
160
{
161
public
:
162
Ns3WimaxServiceFlowTestSuite
();
163
};
164
165
Ns3WimaxServiceFlowTestSuite::Ns3WimaxServiceFlowTestSuite
()
166
:
TestSuite
(
"wimax-service-flow"
, UNIT)
167
{
168
AddTestCase
(
new
Ns3WimaxSfCreationTestCase
);
169
}
170
171
static
Ns3WimaxServiceFlowTestSuite
ns3WimaxServiceFlowTestSuite
;
src
wimax
test
wimax-service-flow-test.cc
Generated on Fri Dec 21 2012 19:00:51 for ns-3 by
1.8.1.2