A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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/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/simulator.h"
34 #include "ns3/wimax-helper.h"
35 #include "ns3/mobility-helper.h"
36 #include <iostream>
37 #include "ns3/global-route-manager.h"
38 
39 using namespace ns3;
40 
42 {
43 public:
45  virtual ~Ns3WimaxSchedulingTestCase ();
46 
47 private:
48  virtual void DoRun (void);
49  bool DoRunOnce (WimaxHelper::SchedulerType scheduler);
50 
51 };
52 
54  : TestCase ("Test the 2 different schedulers")
55 {
56 }
57 
59 {
60 }
61 
62 bool
64 {
65  NodeContainer ssNodes;
66  NodeContainer bsNodes;
67  ssNodes.Create (2);
68  bsNodes.Create (1);
69  WimaxHelper wimax;
70  NetDeviceContainer ssDevs, bsDevs;
71  ssDevs = wimax.Install (ssNodes,
72  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
73  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
74  scheduler);
75  bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
76  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
77  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
78 
80  stack.Install (bsNodes);
81  stack.Install (ssNodes);
82 
84  address.SetBase ("10.1.1.0", "255.255.255.0");
85 
86  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
87  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
88 
89  /*------------------------------*/
90  // UdpServerHelper udpServer;
91  // ApplicationContainer serverApps;
92  // UdpClientHelper udpClient;
93  // ApplicationContainer clientApps;
94  //
95  // udpServer = UdpServerHelper (100);
96  // serverApps = udpServer.Install (ssNodes.Get (0));
97  // serverApps.Start (Seconds (1));
98  // serverApps.Stop (Seconds (2));
99  //
100  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
101  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
102  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
103  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
104  // clientApps = udpClient.Install (ssNodes.Get (1));
105  // clientApps.Start (Seconds (1));
106  // clientApps.Stop (Seconds (2));
107 
108  Simulator::Stop (Seconds (2 + 0.1));
109 
110  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
111  Ipv4Mask ("0.0.0.0"),
112  SSinterfaces.GetAddress (0),
113  Ipv4Mask ("255.255.255.255"),
114  0,
115  65000,
116  100,
117  100,
118  17,
119  1);
120  ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN,
121  ServiceFlow::SF_TYPE_RTPS,
122  DlClassifierUgs);
123  IpcsClassifierRecord UlClassifierUgs (SSinterfaces.GetAddress (1),
124  Ipv4Mask ("255.255.255.255"),
125  Ipv4Address ("0.0.0.0"),
126  Ipv4Mask ("0.0.0.0"),
127  0,
128  65000,
129  100,
130  100,
131  17,
132  1);
133  ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP,
134  ServiceFlow::SF_TYPE_RTPS,
135  UlClassifierUgs);
136  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlowUgs);
137  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlowUgs);
138 
139  Simulator::Run ();
140  Simulator::Destroy ();
141  return false;
142 
143 }
144 
145 void
147 {
148  if (DoRunOnce (WimaxHelper::SCHED_TYPE_SIMPLE) == true)
149  {
150  return;
151  }
152  if (DoRunOnce (WimaxHelper::SCHED_TYPE_RTPS) == true)
153  {
154  return;
155  }
156 }
157 
158 
159 // =============================================================================
161 {
162 public:
164  virtual ~Ns3WimaxSFTypeTestCase ();
165 
166 private:
167  virtual void DoRun (void);
169 
170 };
171 
173  : TestCase ("Test the service flow scheduling types")
174 {
175 }
176 
178 {
179 }
180 
181 bool
183 {
184  NodeContainer ssNodes;
185  NodeContainer bsNodes;
186  ssNodes.Create (2);
187  bsNodes.Create (1);
188  WimaxHelper wimax;
189  NetDeviceContainer ssDevs, bsDevs;
190  ssDevs = wimax.Install (ssNodes,
191  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
192  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
193  WimaxHelper::SCHED_TYPE_SIMPLE);
194  bsDevs = wimax.Install (bsNodes,
195  WimaxHelper::DEVICE_TYPE_BASE_STATION,
196  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
197  WimaxHelper::SCHED_TYPE_SIMPLE);
198  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
199  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
200 
202  stack.Install (bsNodes);
203  stack.Install (ssNodes);
204 
206  address.SetBase ("10.1.1.0", "255.255.255.0");
207 
208  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
209  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
210 
211  /*------------------------------*/
212  // UdpServerHelper udpServer;
213  // ApplicationContainer serverApps;
214  // UdpClientHelper udpClient;
215  // ApplicationContainer clientApps;
216  //
217  // udpServer = UdpServerHelper (100);
218  // serverApps = udpServer.Install (ssNodes.Get (0));
219  // serverApps.Start (Seconds (1));
220  // serverApps.Stop (Seconds (2));
221  //
222  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
223  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
224  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
225  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
226  // clientApps = udpClient.Install (ssNodes.Get (1));
227  // clientApps.Start (Seconds (1));
228  // clientApps.Stop (Seconds (2));
229 
230  Simulator::Stop (Seconds (2 + 0.1));
231 
232  IpcsClassifierRecord DlClassifier (Ipv4Address ("0.0.0.0"),
233  Ipv4Mask ("0.0.0.0"),
234  SSinterfaces.GetAddress (0),
235  Ipv4Mask ("255.255.255.255"),
236  0,
237  65000,
238  100,
239  100,
240  17,
241  1);
242  ServiceFlow DlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier);
243  IpcsClassifierRecord UlClassifier (SSinterfaces.GetAddress (1),
244  Ipv4Mask ("255.255.255.255"),
245  Ipv4Address ("0.0.0.0"),
246  Ipv4Mask ("0.0.0.0"),
247  0,
248  65000,
249  100,
250  100,
251  17,
252  1);
253  ServiceFlow UlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier);
254  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlow);
255  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlow);
256 
257  Simulator::Run ();
258  Simulator::Destroy ();
259  return false;
260 
261 }
262 
263 void
265 {
266  if (DoRunOnce (ServiceFlow::SF_TYPE_UGS) == true)
267  {
268  return;
269  }
270  if (DoRunOnce (ServiceFlow::SF_TYPE_RTPS) == true)
271  {
272  return;
273  }
274  if (DoRunOnce (ServiceFlow::SF_TYPE_BE) == true)
275  {
276  return;
277  }
278 }
279 
281 {
282 public:
284 };
285 
287  : TestSuite ("wimax-qos", SYSTEM)
288 {
289  AddTestCase (new Ns3WimaxSFTypeTestCase, TestCase::QUICK);
290  AddTestCase (new Ns3WimaxSchedulingTestCase, TestCase::QUICK);
291 }
292 
holds a vector of std::pair of Ptr and interface index.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:222
A suite of tests to run.
Definition: test.h:1289
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
aggregate IP/TCP/UDP functionality to existing Nodes.
encapsulates test code
Definition: test.h:1113
bool DoRunOnce(ServiceFlow::SchedulingType)
Definition: qos-test.cc:182
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
virtual ~Ns3WimaxSchedulingTestCase()
Definition: qos-test.cc:58
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: qos-test.cc:264
holds a vector of ns3::NetDevice pointers
static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite
Definition: qos-test.cc:293
keep track of a set of node pointers.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: qos-test.cc:146
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
virtual ~Ns3WimaxSFTypeTestCase()
Definition: qos-test.cc:177
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
tuple stack
Definition: first.py:34
bool DoRunOnce(WimaxHelper::SchedulerType scheduler)
Definition: qos-test.cc:63
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:845
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:59
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
tuple address
Definition: first.py:37
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const