A Discrete-Event Network Simulator
API
wimax-multicast.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
22// Default network topology includes:
23// - A base station (BS)
24// - Some number of SSs specified by the variable nbSS (defaults to 10)
25// - A multicast router (ASNGW)
26// - A multicast streamer
27
28// Two Lans are setup: The first one between the multicast streamer and the
29// ASNGW, the second one between the ASNGW (router) and the base station
30
31// +-----+ +-----+ +-----+ +-----+ +-----+
32// | SS0 | | SS1 | | SS2 | | SS3 | | SS4 |
33// +-----+ +-----+ +-----+ +-----+ +-----+
34// 10.1.0.1 10.1.0.2 10.1.0.3 10.1.0.4 10.1.0.5
35// -------- -------- ------- ------- --------
36// ((*)) ((*)) ((*)) ((*)) ((*))
37//
38// LAN2 (11.1.1.0)
39// ===============
40// 10.1.0.11 | |
41// +------------+ ASNGW multicast Streamer
42// ((*))==|Base Station| | (12.1.1.0) |
43// +------------+ ==================
44// LAN1
45//
46// ((*)) ((*)) ((*)) ((*)) ((*))
47// ------- -------- -------- ------- --------
48// 10.1.0.6 10.1.0.7 10.1.0.8 10.1.0.9 10.1.0.10
49// +-----+ +-----+ +-----+ +-----+ +-----+
50// | SS5 | | SS6 | | SS7 | | SS8 | | SS9 |
51// +-----+ +-----+ +-----+ +-----+ +-----+
52
53#include "ns3/core-module.h"
54#include "ns3/network-module.h"
55#include "ns3/applications-module.h"
56#include "ns3/mobility-module.h"
57#include "ns3/config-store-module.h"
58#include "ns3/wimax-module.h"
59#include "ns3/csma-module.h"
60#include <iostream>
61#include "ns3/global-route-manager.h"
62#include "ns3/internet-module.h"
63#include "ns3/vector.h"
64#include <vector>
65
66using namespace ns3;
67
68NS_LOG_COMPONENT_DEFINE ("WimaxMulticastSimulation");
69
70int main (int argc, char *argv[])
71{
72 bool verbose = false;
73
74 NodeContainer ssNodes;
75 std::vector<Ptr<SubscriberStationNetDevice> > ss;
76 NetDeviceContainer ssDevs;
77 Ipv4InterfaceContainer SSinterfaces;
78
79 NodeContainer bsNodes;
81 NetDeviceContainer bsDevs, bsDevsOne;
82 Ipv4InterfaceContainer BSinterfaces;
83
84 UdpTraceClientHelper udpClient;
86
88 NodeContainer Streamer_Node;
89 NodeContainer ASNGW_Node;
90
92 std::vector<Ptr<RandomWaypointMobilityModel> > SSPosition;
93 std::vector<Ptr<RandomRectanglePositionAllocator> > SSPosAllocator;
94
95 // default values
96 int nbSS = 10, duration = 7, schedType = 0;
97 WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
98
99 CommandLine cmd (__FILE__);
100 cmd.AddValue ("nbSS", "number of subscriber station to create", nbSS);
101 cmd.AddValue ("scheduler", "type of scheduler to use with the netdevices", schedType);
102 cmd.AddValue ("duration", "duration of the simulation in seconds", duration);
103 cmd.AddValue ("verbose", "turn on all WimaxNetDevice log components", verbose);
104 cmd.Parse (argc, argv);
105
106 LogComponentEnable ("UdpTraceClient", LOG_LEVEL_INFO);
107 LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
108
109 switch (schedType)
110 {
111 case 0:
112 scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
113 break;
114 case 1:
115 scheduler = WimaxHelper::SCHED_TYPE_MBQOS;
116 break;
117 case 2:
118 scheduler = WimaxHelper::SCHED_TYPE_RTPS;
119 break;
120 default:
121 scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
122 }
123
124 ss.resize (nbSS);
125 SSPosition.resize (nbSS);
126 SSPosAllocator.resize (nbSS);
127
128 ssNodes.Create (nbSS);
129 bsNodes.Create (1);
130
131 Streamer_Node.Create (1);
132 ASNGW_Node.Create (1);
133
134 WimaxHelper wimax;
135
136 channel = CreateObject<SimpleOfdmWimaxChannel> ();
137 channel->SetPropagationModel (SimpleOfdmWimaxChannel::COST231_PROPAGATION);
138 ssDevs = wimax.Install (ssNodes,
139 WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
140 WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
141 channel,
142 scheduler);
143 Ptr<WimaxNetDevice> dev = wimax.Install (bsNodes.Get (0),
144 WimaxHelper::DEVICE_TYPE_BASE_STATION,
145 WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
146 channel,
147 scheduler);
148
149 BSPosition = CreateObject<ConstantPositionMobilityModel> ();
150
151 BSPosition->SetPosition (Vector (1000, 0, 0));
152 bsNodes.Get (0)->AggregateObject (BSPosition);
153 bsDevs.Add (dev);
154 if (verbose)
155 {
156 wimax.EnableLogComponents (); // Turn on all wimax logging
157 }
158
159 for (int i = 0; i < nbSS; i++)
160 {
161 SSPosition[i] = CreateObject<RandomWaypointMobilityModel> ();
162 SSPosAllocator[i] = CreateObject<RandomRectanglePositionAllocator> ();
163 Ptr<UniformRandomVariable> xVar = CreateObject<UniformRandomVariable> ();
164 xVar->SetAttribute ("Min", DoubleValue ((i / 40.0) * 2000));
165 xVar->SetAttribute ("Max", DoubleValue ((i / 40.0 + 1) * 2000));
166 SSPosAllocator[i]->SetX (xVar);
167 Ptr<UniformRandomVariable> yVar = CreateObject<UniformRandomVariable> ();
168 yVar->SetAttribute ("Min", DoubleValue ((i / 40.0) * 2000));
169 yVar->SetAttribute ("Max", DoubleValue ((i / 40.0 + 1) * 2000));
170 SSPosAllocator[i]->SetY (yVar);
171 SSPosition[i]->SetAttribute ("PositionAllocator", PointerValue (SSPosAllocator[i]));
172 SSPosition[i]->SetAttribute ("Speed", StringValue ("ns3::UniformRandomVariable[Min=10.3|Max=40.7]"));
173 SSPosition[i]->SetAttribute ("Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.01]"));
174
175 ss[i] = ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ();
176 ss[i]->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
177 ssNodes.Get (i)->AggregateObject (SSPosition[i]);
178
179 }
180
181 bs = bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
182
183 CsmaHelper csmaASN_BS;
184 CsmaHelper csmaStreamer_ASN;
185
186 // First LAN BS and ASN
187 NodeContainer LAN_ASN_BS;
188
189 LAN_ASN_BS.Add (bsNodes.Get (0));
190
191 LAN_ASN_BS.Add (ASNGW_Node.Get (0));
192
193 csmaASN_BS.SetChannelAttribute ("DataRate", DataRateValue (DataRate (10000000)));
194 csmaASN_BS.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
195 csmaASN_BS.SetDeviceAttribute ("Mtu", UintegerValue (1500));
196 NetDeviceContainer LAN_ASN_BS_Devs = csmaASN_BS.Install (LAN_ASN_BS);
197
198 NetDeviceContainer BS_CSMADevs;
199
200 BS_CSMADevs.Add (LAN_ASN_BS_Devs.Get (0));
201
202 NetDeviceContainer ASN_Devs1;
203 ASN_Devs1.Add (LAN_ASN_BS_Devs.Get (1));
204
205 // Second LAN ASN-GW and Streamer
206
207 NodeContainer LAN_ASN_STREAMER;
208 LAN_ASN_STREAMER.Add (ASNGW_Node.Get (0));
209 LAN_ASN_STREAMER.Add (Streamer_Node.Get (0));
210
211 csmaStreamer_ASN.SetChannelAttribute ("DataRate", DataRateValue (DataRate (10000000)));
212 csmaStreamer_ASN.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
213 csmaStreamer_ASN.SetDeviceAttribute ("Mtu", UintegerValue (1500));
214
215 NetDeviceContainer LAN_ASN_STREAMER_Devs = csmaStreamer_ASN.Install (LAN_ASN_STREAMER);
216
217 NetDeviceContainer STREAMER_Devs;
218 NetDeviceContainer ASN_Devs2;
219 ASN_Devs2.Add (LAN_ASN_STREAMER_Devs.Get (0));
220 STREAMER_Devs.Add (LAN_ASN_STREAMER_Devs.Get (1));
221
224 mobility.Install (bsNodes);
225 stack.Install (bsNodes);
226 mobility.Install (ssNodes);
227 stack.Install (ssNodes);
228 stack.Install (Streamer_Node);
229 stack.Install (ASNGW_Node);
230
232
233 address.SetBase ("10.1.0.0", "255.255.255.0");
234 bsDevsOne.Add (bs);
235 BSinterfaces = address.Assign (bsDevsOne);
236 SSinterfaces = address.Assign (ssDevs);
237
238 address.SetBase ("11.1.1.0", "255.255.255.0");
239 Ipv4InterfaceContainer BSCSMAInterfaces = address.Assign (BS_CSMADevs);
240 Ipv4InterfaceContainer ASNCSMAInterfaces1 = address.Assign (ASN_Devs1);
241
242 address.SetBase ("12.1.1.0", "255.255.255.0");
243 Ipv4InterfaceContainer ASNCSMAInterfaces2 = address.Assign (ASN_Devs2);
244 Ipv4InterfaceContainer StreamerCSMAInterfaces = address.Assign (STREAMER_Devs);
245
246 Ipv4Address multicastSource ("12.1.1.2");
247 Ipv4Address multicastGroup ("224.30.10.81");
248
249 Ipv4StaticRoutingHelper multicast;
250 // 1) Configure a (static) multicast route on ASNGW (multicastRouter)
251 Ptr<Node> multicastRouter = ASNGW_Node.Get (0); // The node in question
252 Ptr<NetDevice> inputIf = ASN_Devs2.Get (0); // The input NetDevice
253
254
255 multicast.AddMulticastRoute (multicastRouter, multicastSource, multicastGroup, inputIf, ASN_Devs1);
256
257 // 2) Set up a default multicast route on the sender n0
258 Ptr<Node> sender = Streamer_Node.Get (0);
259 Ptr<NetDevice> senderIf = STREAMER_Devs.Get (0);
260 multicast.SetDefaultMulticastRoute (sender, senderIf);
261
262 // 1) Configure a (static) multicast route on ASNGW (multicastRouter)
263 multicastRouter = bsNodes.Get (0); // The node in question
264 inputIf = BS_CSMADevs.Get (0); // The input NetDevice
265
266 multicast.AddMulticastRoute (multicastRouter, multicastSource, multicastGroup, inputIf, bsDevsOne);
267
268 uint16_t multicast_port = 100;
269
270 UdpServerHelper udpServerHelper = UdpServerHelper (multicast_port);
272 serverApps = udpServerHelper.Install (ssNodes);
273 serverApps.Start (Seconds (6));
274 serverApps.Stop (Seconds (duration));
275
276 udpClient = UdpTraceClientHelper (multicastGroup, multicast_port, "");
277
278 clientApps = udpClient.Install (Streamer_Node.Get (0));
279 clientApps.Start (Seconds (6));
280 clientApps.Stop (Seconds (duration));
281
282 IpcsClassifierRecord MulticastClassifier (Ipv4Address ("0.0.0.0"),
283 Ipv4Mask ("0.0.0.0"),
284 multicastGroup,
285 Ipv4Mask ("255.255.255.255"),
286 0,
287 65000,
288 multicast_port,
289 multicast_port,
290 17,
291 1);
292
293 ServiceFlow MulticastServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN,
294 ServiceFlow::SF_TYPE_UGS,
295 MulticastClassifier);
296
297 bs->GetServiceFlowManager ()->AddMulticastServiceFlow (MulticastServiceFlow, WimaxPhy::MODULATION_TYPE_QPSK_12);
298
299 Simulator::Stop (Seconds (duration + 0.1));
300 NS_LOG_INFO ("Starting simulation.....");
301 Simulator::Run ();
302
303 for (int i = 0; i < nbSS; i++)
304 {
305 ss[i] = 0;
306 SSPosition[i] = 0;
307 SSPosAllocator[i] = 0;
308 }
309
310 bs = 0;
311
312 Simulator::Destroy ();
313 NS_LOG_INFO ("Done.");
314
315 return 0;
316}
holds a vector of ns3::Application pointers.
BaseStation NetDevice.
Definition: bs-net-device.h:53
Parse command-line arguments.
Definition: command-line.h:229
build a set of CsmaNetDevice objects
Definition: csma-helper.h:47
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Definition: csma-helper.cc:67
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
Definition: csma-helper.cc:73
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
Definition: csma-helper.cc:225
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
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
Helper class that adds ns3::Ipv4StaticRouting objects.
void AddMulticastRoute(Ptr< Node > n, Ipv4Address source, Ipv4Address group, Ptr< NetDevice > input, NetDeviceContainer output)
Add a multicast route to a node and net device using explicit Ptr<Node> and Ptr<NetDevice>
void SetDefaultMulticastRoute(Ptr< Node > n, Ptr< NetDevice > nd)
Add a default route to the static routing protocol to forward packets out a particular interface.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
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.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:40
Hold variables of type string.
Definition: string.h:41
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:49
void SetModulationType(WimaxPhy::ModulationType modulationType)
Set the most efficient modulation and coding scheme (MCS) supported by the device.
AttributeValue implementation for Time.
Definition: nstime.h:1308
Create a server application which waits for input UDP packets and uses the information carried into t...
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
Create UdpTraceClient application which sends UDP packets based on a trace file of an MPEG4 stream.
ApplicationContainer Install(NodeContainer c)
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:324
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
static void EnableLogComponents(void)
Helper to enable all WimaxNetDevice log components with one statement.
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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
address
Definition: first.py:44
serverApps
Definition: first.py:52
clientApps
Definition: first.py:61
stack
Definition: first.py:41
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition: log.h:107
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361
cmd
Definition: second.py:35
channel
Definition: third.py:92
mobility
Definition: third.py:107
bool verbose