A Discrete-Event Network Simulator
API
wimax-service-flow-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 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 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 *
20 */
21#include "ns3/cs-parameters.h"
22#include "ns3/internet-stack-helper.h"
23#include "ns3/ipcs-classifier-record.h"
24#include "ns3/ipv4-address-helper.h"
25#include "ns3/ipv4-address.h"
26#include "ns3/ipv4-interface-container.h"
27#include "ns3/service-flow.h"
28#include "ns3/simulator.h"
29#include "ns3/test.h"
30#include "ns3/wimax-helper.h"
31
32using namespace ns3;
33
41{
42 public:
45
46 private:
47 void DoRun() override;
48};
49
51 : TestCase("Test the service flow tlv implementation.")
52{
53}
54
56{
57}
58
59void
61{
62 // default values
63 int duration = 2;
64 WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
65
66 NodeContainer ssNodes;
67 NodeContainer bsNodes;
68
69 ssNodes.Create(1);
70 bsNodes.Create(1);
71
72 WimaxHelper wimax;
73
74 NetDeviceContainer ssDevs;
75 NetDeviceContainer bsDevs;
76
77 ssDevs = wimax.Install(ssNodes,
78 WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
79 WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
80 scheduler);
81 bsDevs = wimax.Install(bsNodes,
82 WimaxHelper::DEVICE_TYPE_BASE_STATION,
83 WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
84 scheduler);
85
86 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
87 WimaxPhy::MODULATION_TYPE_QAM16_12);
88 bsDevs.Get(0)->GetObject<BaseStationNetDevice>();
89
91 stack.Install(bsNodes);
92 stack.Install(ssNodes);
93
95 address.SetBase("10.1.1.0", "255.255.255.0");
96
97 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
98 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
99
100 // Create one UGS Downlink service flow between the ss and the bs
101 ServiceFlow* DlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN);
102 IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"),
103 Ipv4Mask("0.0.0.0"),
104 Ipv4Address("0.0.0.0"),
105 Ipv4Mask("0.0.0.0"),
106 3000,
107 3000,
108 0,
109 35000,
110 17,
111 1);
112 CsParameters DlcsParam(CsParameters::ADD, DlClassifierUgs);
113 DlServiceFlowUgs->SetConvergenceSublayerParam(DlcsParam);
114 DlServiceFlowUgs->SetCsSpecification(ServiceFlow::IPV4);
115 DlServiceFlowUgs->SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS);
116 DlServiceFlowUgs->SetMaxSustainedTrafficRate(1000000);
117 DlServiceFlowUgs->SetMinReservedTrafficRate(1000000);
118 DlServiceFlowUgs->SetMinTolerableTrafficRate(1000000);
119 DlServiceFlowUgs->SetMaximumLatency(10);
120 DlServiceFlowUgs->SetMaxTrafficBurst(1000);
121 DlServiceFlowUgs->SetTrafficPriority(1);
122
123 // Create one UGS Uplink service flow between the ss and the bs
124 ServiceFlow* UlServiceFlowUgs = new ServiceFlow(ServiceFlow::SF_DIRECTION_UP);
125 IpcsClassifierRecord UlClassifierUgs(Ipv4Address("0.0.0.0"),
126 Ipv4Mask("0.0.0.0"),
127 Ipv4Address("0.0.0.0"),
128 Ipv4Mask("0.0.0.0"),
129 0,
130 35000,
131 3000,
132 3000,
133 17,
134 1);
135 CsParameters UlcsParam(CsParameters::ADD, UlClassifierUgs);
136 UlServiceFlowUgs->SetConvergenceSublayerParam(UlcsParam);
137 UlServiceFlowUgs->SetCsSpecification(ServiceFlow::IPV4);
138 UlServiceFlowUgs->SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS);
139 UlServiceFlowUgs->SetMaxSustainedTrafficRate(1000000);
140 UlServiceFlowUgs->SetMinReservedTrafficRate(1000000);
141 UlServiceFlowUgs->SetMinTolerableTrafficRate(1000000);
142 UlServiceFlowUgs->SetMaximumLatency(10);
143 UlServiceFlowUgs->SetMaxTrafficBurst(1000);
144 UlServiceFlowUgs->SetTrafficPriority(1);
145 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(DlServiceFlowUgs);
146 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(UlServiceFlowUgs);
147
148 Simulator::Stop(Seconds(duration));
149 Simulator::Run();
150 Simulator::Destroy();
151}
152
160{
161 public:
163};
164
166 : TestSuite("wimax-service-flow", UNIT)
167{
168 AddTestCase(new Ns3WimaxSfCreationTestCase, TestCase::QUICK);
169}
170
Ns3 Wimax Service Flow Test Suite.
Test the service flow creation.
void DoRun() override
Implementation to actually run this TestCase.
BaseStation NetDevice.
Definition: bs-net-device.h:54
CsParameters class.
Definition: cs-parameters.h:36
aggregate IP/TCP/UDP functionality to existing Nodes.
IpcsClassifierRecord class.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
void SetCsSpecification(CsSpecification spec)
Set CS specification.
void SetMaxTrafficBurst(uint32_t maxTrafficBurst)
Set maximum traffic burst.
void SetMaximumLatency(uint32_t MaximumLatency)
Set maximum latency.
void SetConvergenceSublayerParam(CsParameters csparam)
Set convergence sublayer parameters.
void SetTrafficPriority(uint8_t priority)
Set traffic priority.
void SetMinTolerableTrafficRate(uint32_t minJitter)
Set minimum tolerable traffic rate.
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType schedType)
Set service scheduling type.
void SetMinReservedTrafficRate(uint32_t minResvRate)
Set minimum reserved traffic rate.
void SetMaxSustainedTrafficRate(uint32_t maxSustainedRate)
Set max sustained traffic rate.
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:59
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
address
Definition: first.py:40
stack
Definition: first.py:37
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ IPV4
Definition: packetbb.h:47
static Ns3WimaxServiceFlowTestSuite ns3WimaxServiceFlowTestSuite
the test suite