A Discrete-Event Network Simulator
API
qos-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/node-container.h"
25 #include "ns3/wimax-helper.h"
26 #include "ns3/net-device-container.h"
27 #include "ns3/internet-stack-helper.h"
28 #include "ns3/ipv4-address-helper.h"
29 #include "ns3/ipv4-interface-container.h"
30 #include "ns3/ipv4-address.h"
31 #include "ns3/service-flow.h"
32 #include "ns3/ipcs-classifier-record.h"
33 
34 using namespace ns3;
35 
43 {
44 public:
46  virtual ~Ns3WimaxSchedulingTestCase ();
47 
48 private:
49  virtual void DoRun (void);
55  bool DoRunOnce (WimaxHelper::SchedulerType scheduler);
56 
57 };
58 
60  : TestCase ("Test the 2 different schedulers")
61 {
62 }
63 
65 {
66 }
67 
68 bool
70 {
71  NodeContainer ssNodes;
72  NodeContainer bsNodes;
73  ssNodes.Create (2);
74  bsNodes.Create (1);
75  WimaxHelper wimax;
76  NetDeviceContainer ssDevs, bsDevs;
77  ssDevs = wimax.Install (ssNodes,
78  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
79  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
80  scheduler);
81  bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
82  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
83  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
84 
86  stack.Install (bsNodes);
87  stack.Install (ssNodes);
88 
90  address.SetBase ("10.1.1.0", "255.255.255.0");
91 
92  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
93  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
94 
95  /*------------------------------*/
96  // UdpServerHelper udpServer;
97  // ApplicationContainer serverApps;
98  // UdpClientHelper udpClient;
99  // ApplicationContainer clientApps;
100  //
101  // udpServer = UdpServerHelper (100);
102  // serverApps = udpServer.Install (ssNodes.Get (0));
103  // serverApps.Start (Seconds (1));
104  // serverApps.Stop (Seconds (2));
105  //
106  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
107  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
108  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
109  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
110  // clientApps = udpClient.Install (ssNodes.Get (1));
111  // clientApps.Start (Seconds (1));
112  // clientApps.Stop (Seconds (2));
113 
114  Simulator::Stop (Seconds (2 + 0.1));
115 
116  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
117  Ipv4Mask ("0.0.0.0"),
118  SSinterfaces.GetAddress (0),
119  Ipv4Mask ("255.255.255.255"),
120  0,
121  65000,
122  100,
123  100,
124  17,
125  1);
126  ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN,
127  ServiceFlow::SF_TYPE_RTPS,
128  DlClassifierUgs);
129  IpcsClassifierRecord UlClassifierUgs (SSinterfaces.GetAddress (1),
130  Ipv4Mask ("255.255.255.255"),
131  Ipv4Address ("0.0.0.0"),
132  Ipv4Mask ("0.0.0.0"),
133  0,
134  65000,
135  100,
136  100,
137  17,
138  1);
139  ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP,
140  ServiceFlow::SF_TYPE_RTPS,
141  UlClassifierUgs);
142  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlowUgs);
143  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlowUgs);
144 
145  Simulator::Run ();
146  Simulator::Destroy ();
147  return false;
148 
149 }
150 
151 void
153 {
154  if (DoRunOnce (WimaxHelper::SCHED_TYPE_SIMPLE) == true)
155  {
156  return;
157  }
158  if (DoRunOnce (WimaxHelper::SCHED_TYPE_RTPS) == true)
159  {
160  return;
161  }
162 }
163 
164 
172 {
173 public:
175  virtual ~Ns3WimaxSFTypeTestCase ();
176 
177 private:
178  virtual void DoRun (void);
184  bool DoRunOnce (ServiceFlow::SchedulingType schedulingType);
185 
186 };
187 
189  : TestCase ("Test the service flow scheduling types")
190 {
191 }
192 
194 {
195 }
196 
197 bool
199 {
200  NodeContainer ssNodes;
201  NodeContainer bsNodes;
202  ssNodes.Create (2);
203  bsNodes.Create (1);
204  WimaxHelper wimax;
205  NetDeviceContainer ssDevs, bsDevs;
206  ssDevs = wimax.Install (ssNodes,
207  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
208  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
209  WimaxHelper::SCHED_TYPE_SIMPLE);
210  bsDevs = wimax.Install (bsNodes,
211  WimaxHelper::DEVICE_TYPE_BASE_STATION,
212  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
213  WimaxHelper::SCHED_TYPE_SIMPLE);
214  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
215  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
216 
218  stack.Install (bsNodes);
219  stack.Install (ssNodes);
220 
222  address.SetBase ("10.1.1.0", "255.255.255.0");
223 
224  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
225  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
226 
227  /*------------------------------*/
228  // UdpServerHelper udpServer;
229  // ApplicationContainer serverApps;
230  // UdpClientHelper udpClient;
231  // ApplicationContainer clientApps;
232  //
233  // udpServer = UdpServerHelper (100);
234  // serverApps = udpServer.Install (ssNodes.Get (0));
235  // serverApps.Start (Seconds (1));
236  // serverApps.Stop (Seconds (2));
237  //
238  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
239  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
240  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
241  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
242  // clientApps = udpClient.Install (ssNodes.Get (1));
243  // clientApps.Start (Seconds (1));
244  // clientApps.Stop (Seconds (2));
245 
246  Simulator::Stop (Seconds (2 + 0.1));
247 
248  IpcsClassifierRecord DlClassifier (Ipv4Address ("0.0.0.0"),
249  Ipv4Mask ("0.0.0.0"),
250  SSinterfaces.GetAddress (0),
251  Ipv4Mask ("255.255.255.255"),
252  0,
253  65000,
254  100,
255  100,
256  17,
257  1);
258  ServiceFlow DlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier);
259  IpcsClassifierRecord UlClassifier (SSinterfaces.GetAddress (1),
260  Ipv4Mask ("255.255.255.255"),
261  Ipv4Address ("0.0.0.0"),
262  Ipv4Mask ("0.0.0.0"),
263  0,
264  65000,
265  100,
266  100,
267  17,
268  1);
269  ServiceFlow UlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier);
270  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlow);
271  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlow);
272 
273  Simulator::Run ();
274  Simulator::Destroy ();
275  return false;
276 
277 }
278 
279 void
281 {
282  if (DoRunOnce (ServiceFlow::SF_TYPE_UGS) == true)
283  {
284  return;
285  }
286  if (DoRunOnce (ServiceFlow::SF_TYPE_RTPS) == true)
287  {
288  return;
289  }
290  if (DoRunOnce (ServiceFlow::SF_TYPE_BE) == true)
291  {
292  return;
293  }
294 }
295 
303 {
304 public:
306 };
307 
309  : TestSuite ("wimax-qos", SYSTEM)
310 {
311  AddTestCase (new Ns3WimaxSFTypeTestCase, TestCase::QUICK);
312  AddTestCase (new Ns3WimaxSchedulingTestCase, TestCase::QUICK);
313 }
314 
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:269
Ns3 Wimax SF Type Test Case.
Definition: qos-test.cc:171
A suite of tests to run.
Definition: test.h:1343
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:85
aggregate IP/TCP/UDP functionality to existing Nodes.
encapsulates test code
Definition: test.h:1153
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
stack
Definition: first.py:41
IpcsClassifierRecord class.
virtual ~Ns3WimaxSchedulingTestCase()
Definition: qos-test.cc:64
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: qos-test.cc:280
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition: service-flow.h:58
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite
the test suite
Definition: qos-test.cc:315
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
address
Definition: first.py:44
bool DoRunOnce(ServiceFlow::SchedulingType schedulingType)
Run once function.
Definition: qos-test.cc:198
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: qos-test.cc:152
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
virtual ~Ns3WimaxSFTypeTestCase()
Definition: qos-test.cc:193
bool DoRunOnce(WimaxHelper::SchedulerType scheduler)
Run once function.
Definition: qos-test.cc:69
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:58
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:48
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ns3 Wimax Scheduling Test Case.
Definition: qos-test.cc:42
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ns3 Wimax QoS Test Suite.
Definition: qos-test.cc:302