A Discrete-Event Network Simulator
API
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/test.h"
23 #include "ns3/internet-stack-helper.h"
24 #include "ns3/ipv4-address-helper.h"
25 #include "ns3/ipv4-interface-container.h"
26 #include "ns3/ipv4-address.h"
27 #include "ns3/simulator.h"
28 #include "ns3/wimax-helper.h"
29 #include "ns3/cs-parameters.h"
30 #include "ns3/ipcs-classifier-record.h"
31 #include "ns3/service-flow.h"
32 
33 using namespace ns3;
34 
42 {
43 public:
45  virtual ~Ns3WimaxSfCreationTestCase ();
46 
47 private:
48  virtual void DoRun (void);
49 
50 };
51 
53  : TestCase ("Test the service flow tlv implementation.")
54 {
55 }
56 
58 {
59 }
60 
61 void
63 {
64 
65  // default values
66  int duration = 2;
67  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
68 
69  NodeContainer ssNodes;
70  NodeContainer bsNodes;
71 
72  ssNodes.Create (1);
73  bsNodes.Create (1);
74 
75  WimaxHelper wimax;
76 
77  NetDeviceContainer ssDevs, bsDevs;
78 
79  ssDevs = wimax.Install (ssNodes,
80  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
81  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
82  scheduler);
83  bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
84 
85  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
86  bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
87 
89  stack.Install (bsNodes);
90  stack.Install (ssNodes);
91 
93  address.SetBase ("10.1.1.0", "255.255.255.0");
94 
95  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
96  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
97 
98  // Create one UGS Downlink service flow between the ss and the bs
99  ServiceFlow * DlServiceFlowUgs = new ServiceFlow (ServiceFlow::SF_DIRECTION_DOWN);
100  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
101  Ipv4Mask ("0.0.0.0"),
102  Ipv4Address ("0.0.0.0"),
103  Ipv4Mask ("0.0.0.0"),
104  3000,
105  3000,
106  0,
107  35000,
108  17,
109  1);
110  CsParameters DlcsParam (CsParameters::ADD, DlClassifierUgs);
111  DlServiceFlowUgs->SetConvergenceSublayerParam (DlcsParam);
112  DlServiceFlowUgs->SetCsSpecification (ServiceFlow::IPV4);
113  DlServiceFlowUgs->SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
114  DlServiceFlowUgs->SetMaxSustainedTrafficRate (1000000);
115  DlServiceFlowUgs->SetMinReservedTrafficRate (1000000);
116  DlServiceFlowUgs->SetMinTolerableTrafficRate (1000000);
117  DlServiceFlowUgs->SetMaximumLatency (10);
118  DlServiceFlowUgs->SetMaxTrafficBurst (1000);
119  DlServiceFlowUgs->SetTrafficPriority (1);
120 
121  // Create one UGS Uplink service flow between the ss and the bs
122  ServiceFlow * UlServiceFlowUgs = new ServiceFlow (ServiceFlow::SF_DIRECTION_UP);
123  IpcsClassifierRecord UlClassifierUgs (Ipv4Address ("0.0.0.0"),
124  Ipv4Mask ("0.0.0.0"),
125  Ipv4Address ("0.0.0.0"),
126  Ipv4Mask ("0.0.0.0"),
127  0,
128  35000,
129  3000,
130  3000,
131  17,
132  1);
133  CsParameters UlcsParam (CsParameters::ADD, UlClassifierUgs);
134  UlServiceFlowUgs->SetConvergenceSublayerParam (UlcsParam);
135  UlServiceFlowUgs->SetCsSpecification (ServiceFlow::IPV4);
136  UlServiceFlowUgs->SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
137  UlServiceFlowUgs->SetMaxSustainedTrafficRate (1000000);
138  UlServiceFlowUgs->SetMinReservedTrafficRate (1000000);
139  UlServiceFlowUgs->SetMinTolerableTrafficRate (1000000);
140  UlServiceFlowUgs->SetMaximumLatency (10);
141  UlServiceFlowUgs->SetMaxTrafficBurst (1000);
142  UlServiceFlowUgs->SetTrafficPriority (1);
143  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlowUgs);
144  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlowUgs);
145 
146  Simulator::Stop (Seconds (duration));
147  Simulator::Run ();
148  Simulator::Destroy ();
149 }
150 
158 {
159 public:
161 };
162 
164  : TestSuite ("wimax-service-flow", UNIT)
165 {
166  AddTestCase (new Ns3WimaxSfCreationTestCase, TestCase::QUICK);
167 }
168 
Ns3 Wimax Service Flow Test Suite.
Test the service flow creation.
virtual void DoRun(void)
Implementation to actually run this TestCase.
BaseStation NetDevice.
Definition: bs-net-device.h:53
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:41
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
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.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:40
void SetMaxTrafficBurst(uint32_t maxTrafficBurst)
Set maximum traffic burst.
void SetMaximumLatency(uint32_t MaximumLatency)
Set maximum latency.
void SetCsSpecification(enum CsSpecification spec)
Set CS specification.
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:49
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
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:1244
address
Definition: first.py:44
stack
Definition: first.py:41
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ IPV4
Definition: packetbb.h:46
static Ns3WimaxServiceFlowTestSuite ns3WimaxServiceFlowTestSuite
the test suite