A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
qos-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 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 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 */
20#include "ns3/internet-stack-helper.h"
21#include "ns3/ipcs-classifier-record.h"
22#include "ns3/ipv4-address-helper.h"
23#include "ns3/ipv4-address.h"
24#include "ns3/ipv4-interface-container.h"
25#include "ns3/log.h"
26#include "ns3/net-device-container.h"
27#include "ns3/node-container.h"
28#include "ns3/service-flow.h"
29#include "ns3/simulator.h"
30#include "ns3/test.h"
31#include "ns3/wimax-helper.h"
32
33using namespace ns3;
34
35/**
36 * \ingroup wimax-test
37 * \ingroup tests
38 *
39 * \brief Ns3 Wimax Scheduling Test Case
40 */
42{
43 public:
46
47 private:
48 void DoRun() override;
49 /**
50 * Run once function
51 * \param scheduler the wimax scheduler type
52 * \returns true if successful
53 */
55};
56
58 : TestCase("Test the 2 different schedulers")
59{
60}
61
63{
64}
65
66bool
68{
69 NodeContainer ssNodes;
70 NodeContainer bsNodes;
71 ssNodes.Create(2);
72 bsNodes.Create(1);
73 WimaxHelper wimax;
74 NetDeviceContainer ssDevs;
75 NetDeviceContainer bsDevs;
76 ssDevs = wimax.Install(ssNodes,
79 scheduler);
80 bsDevs = wimax.Install(bsNodes,
83 scheduler);
84 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
86 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
88
90 stack.Install(bsNodes);
91 stack.Install(ssNodes);
92
93 Ipv4AddressHelper address;
94 address.SetBase("10.1.1.0", "255.255.255.0");
95
96 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
97 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
98
99 /*------------------------------*/
100 // UdpServerHelper udpServer;
101 // ApplicationContainer serverApps;
102 // UdpClientHelper udpClient;
103 // ApplicationContainer clientApps;
104 //
105 // udpServer = UdpServerHelper (100);
106 // serverApps = udpServer.Install (ssNodes.Get (0));
107 // serverApps.Start (Seconds (1));
108 // serverApps.Stop (Seconds (2));
109 //
110 // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
111 // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
112 // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
113 // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
114 // clientApps = udpClient.Install (ssNodes.Get (1));
115 // clientApps.Start (Seconds (1));
116 // clientApps.Stop (Seconds (2));
117
118 Simulator::Stop(Seconds(2 + 0.1));
119
120 IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"),
121 Ipv4Mask("0.0.0.0"),
122 SSinterfaces.GetAddress(0),
123 Ipv4Mask("255.255.255.255"),
124 0,
125 65000,
126 100,
127 100,
128 17,
129 1);
132 DlClassifierUgs);
133 IpcsClassifierRecord UlClassifierUgs(SSinterfaces.GetAddress(1),
134 Ipv4Mask("255.255.255.255"),
135 Ipv4Address("0.0.0.0"),
136 Ipv4Mask("0.0.0.0"),
137 0,
138 65000,
139 100,
140 100,
141 17,
142 1);
145 UlClassifierUgs);
146 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(DlServiceFlowUgs);
147 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(UlServiceFlowUgs);
148
151 return false;
152}
153
154void
156{
158 {
159 return;
160 }
162 {
163 return;
164 }
165}
166
167/**
168 * \ingroup wimax-test
169 * \ingroup tests
170 *
171 * \brief Ns3 Wimax SF Type Test Case
172 */
174{
175 public:
177 ~Ns3WimaxSFTypeTestCase() override;
178
179 private:
180 void DoRun() override;
181 /**
182 * Run once function
183 * \param schedulingType the scheduling type
184 * \returns true if successful
185 */
186 bool DoRunOnce(ServiceFlow::SchedulingType schedulingType);
187};
188
190 : TestCase("Test the service flow scheduling types")
191{
192}
193
195{
196}
197
198bool
200{
201 NodeContainer ssNodes;
202 NodeContainer bsNodes;
203 ssNodes.Create(2);
204 bsNodes.Create(1);
205 WimaxHelper wimax;
206 NetDeviceContainer ssDevs;
207 NetDeviceContainer bsDevs;
208 ssDevs = wimax.Install(ssNodes,
212 bsDevs = wimax.Install(bsNodes,
216 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
218 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
220
222 stack.Install(bsNodes);
223 stack.Install(ssNodes);
224
225 Ipv4AddressHelper address;
226 address.SetBase("10.1.1.0", "255.255.255.0");
227
228 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
229 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
230
231 /*------------------------------*/
232 // UdpServerHelper udpServer;
233 // ApplicationContainer serverApps;
234 // UdpClientHelper udpClient;
235 // ApplicationContainer clientApps;
236 //
237 // udpServer = UdpServerHelper (100);
238 // serverApps = udpServer.Install (ssNodes.Get (0));
239 // serverApps.Start (Seconds (1));
240 // serverApps.Stop (Seconds (2));
241 //
242 // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
243 // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
244 // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
245 // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
246 // clientApps = udpClient.Install (ssNodes.Get (1));
247 // clientApps.Start (Seconds (1));
248 // clientApps.Stop (Seconds (2));
249
250 Simulator::Stop(Seconds(2 + 0.1));
251
252 IpcsClassifierRecord DlClassifier(Ipv4Address("0.0.0.0"),
253 Ipv4Mask("0.0.0.0"),
254 SSinterfaces.GetAddress(0),
255 Ipv4Mask("255.255.255.255"),
256 0,
257 65000,
258 100,
259 100,
260 17,
261 1);
262 ServiceFlow DlServiceFlow =
263 wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier);
264 IpcsClassifierRecord UlClassifier(SSinterfaces.GetAddress(1),
265 Ipv4Mask("255.255.255.255"),
266 Ipv4Address("0.0.0.0"),
267 Ipv4Mask("0.0.0.0"),
268 0,
269 65000,
270 100,
271 100,
272 17,
273 1);
274 ServiceFlow UlServiceFlow =
275 wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier);
276 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(DlServiceFlow);
277 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(UlServiceFlow);
278
281 return false;
282}
283
284void
286{
288 {
289 return;
290 }
292 {
293 return;
294 }
296 {
297 return;
298 }
299}
300
301/**
302 * \ingroup wimax-test
303 * \ingroup tests
304 *
305 * \brief Ns3 Wimax QoS Test Suite
306 */
308{
309 public:
311};
312
314 : TestSuite("wimax-qos", Type::SYSTEM)
315{
316 AddTestCase(new Ns3WimaxSFTypeTestCase, TestCase::Duration::QUICK);
317 AddTestCase(new Ns3WimaxSchedulingTestCase, TestCase::Duration::QUICK);
318}
319
Ns3 Wimax QoS Test Suite.
Definition: qos-test.cc:308
Ns3 Wimax SF Type Test Case.
Definition: qos-test.cc:174
void DoRun() override
Implementation to actually run this TestCase.
Definition: qos-test.cc:285
~Ns3WimaxSFTypeTestCase() override
Definition: qos-test.cc:194
bool DoRunOnce(ServiceFlow::SchedulingType schedulingType)
Run once function.
Definition: qos-test.cc:199
Ns3 Wimax Scheduling Test Case.
Definition: qos-test.cc:42
~Ns3WimaxSchedulingTestCase() override
Definition: qos-test.cc:62
bool DoRunOnce(WimaxHelper::SchedulerType scheduler)
Run once function.
Definition: qos-test.cc:67
void DoRun() override
Implementation to actually run this TestCase.
Definition: qos-test.cc:155
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:42
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
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
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition: service-flow.h:62
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
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
@ SCHED_TYPE_RTPS
A simple scheduler - rtPS based scheduler.
Definition: wimax-helper.h:88
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition: wimax-helper.h:87
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
Definition: wimax-helper.h:67
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition: wimax-helper.h:68
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
@ MODULATION_TYPE_QAM16_12
Definition: wimax-phy.h:58
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite
the test suite
Definition: qos-test.cc:320