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 
35 /*
36  * Test the service flow creation.
37  */
39 {
40 public:
42  virtual ~Ns3WimaxSfCreationTestCase ();
43 
44 private:
45  virtual void DoRun (void);
46 
47 };
48 
50  : TestCase ("Test the service flow tlv implementation.")
51 {
52 }
53 
55 {
56 }
57 
58 void
60 {
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, bsDevs;
75 
76  ssDevs = wimax.Install (ssNodes,
77  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
78  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
79  scheduler);
80  bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
81 
82  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
83  bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
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  // Create one UGS Downlink service flow between the ss and the bs
96  ServiceFlow * DlServiceFlowUgs = new ServiceFlow (ServiceFlow::SF_DIRECTION_DOWN);
97  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
98  Ipv4Mask ("0.0.0.0"),
99  Ipv4Address ("0.0.0.0"),
100  Ipv4Mask ("0.0.0.0"),
101  3000,
102  3000,
103  0,
104  35000,
105  17,
106  1);
107  CsParameters DlcsParam (CsParameters::ADD, DlClassifierUgs);
108  DlServiceFlowUgs->SetConvergenceSublayerParam (DlcsParam);
109  DlServiceFlowUgs->SetCsSpecification (ServiceFlow::IPV4);
110  DlServiceFlowUgs->SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
111  DlServiceFlowUgs->SetMaxSustainedTrafficRate (1000000);
112  DlServiceFlowUgs->SetMinReservedTrafficRate (1000000);
113  DlServiceFlowUgs->SetMinTolerableTrafficRate (1000000);
114  DlServiceFlowUgs->SetMaximumLatency (10);
115  DlServiceFlowUgs->SetMaxTrafficBurst (1000);
116  DlServiceFlowUgs->SetTrafficPriority (1);
117 
118  // Create one UGS Uplink service flow between the ss and the bs
119  ServiceFlow * UlServiceFlowUgs = new ServiceFlow (ServiceFlow::SF_DIRECTION_UP);
120  IpcsClassifierRecord UlClassifierUgs (Ipv4Address ("0.0.0.0"),
121  Ipv4Mask ("0.0.0.0"),
122  Ipv4Address ("0.0.0.0"),
123  Ipv4Mask ("0.0.0.0"),
124  0,
125  35000,
126  3000,
127  3000,
128  17,
129  1);
130  CsParameters UlcsParam (CsParameters::ADD, UlClassifierUgs);
131  UlServiceFlowUgs->SetConvergenceSublayerParam (UlcsParam);
132  UlServiceFlowUgs->SetCsSpecification (ServiceFlow::IPV4);
133  UlServiceFlowUgs->SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
134  UlServiceFlowUgs->SetMaxSustainedTrafficRate (1000000);
135  UlServiceFlowUgs->SetMinReservedTrafficRate (1000000);
136  UlServiceFlowUgs->SetMinTolerableTrafficRate (1000000);
137  UlServiceFlowUgs->SetMaximumLatency (10);
138  UlServiceFlowUgs->SetMaxTrafficBurst (1000);
139  UlServiceFlowUgs->SetTrafficPriority (1);
140  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlowUgs);
141  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlowUgs);
142 
143  Simulator::Stop (Seconds (duration));
144  Simulator::Run ();
145  Simulator::Destroy ();
146 }
147 
148 // ==============================================================================
150 {
151 public:
153 };
154 
156  : TestSuite ("wimax-service-flow", UNIT)
157 {
158  AddTestCase (new Ns3WimaxSfCreationTestCase, TestCase::QUICK);
159 }
160 
holds a vector of std::pair of Ptr and interface index.
void SetMaxSustainedTrafficRate(uint32_t)
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:257
A suite of tests to run.
Definition: test.h:1333
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:1147
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
void SetMinReservedTrafficRate(uint32_t)
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType)
void SetMaxTrafficBurst(uint32_t)
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
holds a vector of ns3::NetDevice pointers
void SetTrafficPriority(uint8_t)
void SetConvergenceSublayerParam(CsParameters)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
void SetMaximumLatency(uint32_t)
static Ns3WimaxServiceFlowTestSuite ns3WimaxServiceFlowTestSuite
tuple stack
Definition: first.py:34
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void SetMinTolerableTrafficRate(uint32_t)
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:58
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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 SetCsSpecification(enum CsSpecification)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.