A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-multicast.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 */
9
10// Default network topology includes:
11// - A base station (BS)
12// - Some number of SSs specified by the variable nbSS (defaults to 10)
13// - A multicast router (ASNGW)
14// - A multicast streamer
15
16// Two Lans are setup: The first one between the multicast streamer and the
17// ASNGW, the second one between the ASNGW (router) and the base station
18
19// +-----+ +-----+ +-----+ +-----+ +-----+
20// | SS0 | | SS1 | | SS2 | | SS3 | | SS4 |
21// +-----+ +-----+ +-----+ +-----+ +-----+
22// 10.1.0.1 10.1.0.2 10.1.0.3 10.1.0.4 10.1.0.5
23// -------- -------- ------- ------- --------
24// ((*)) ((*)) ((*)) ((*)) ((*))
25//
26// LAN2 (11.1.1.0)
27// ===============
28// 10.1.0.11 | |
29// +------------+ ASNGW multicast Streamer
30// ((*))==|Base Station| | (12.1.1.0) |
31// +------------+ ==================
32// LAN1
33//
34// ((*)) ((*)) ((*)) ((*)) ((*))
35// ------- -------- -------- ------- --------
36// 10.1.0.6 10.1.0.7 10.1.0.8 10.1.0.9 10.1.0.10
37// +-----+ +-----+ +-----+ +-----+ +-----+
38// | SS5 | | SS6 | | SS7 | | SS8 | | SS9 |
39// +-----+ +-----+ +-----+ +-----+ +-----+
40
41#include "ns3/applications-module.h"
42#include "ns3/core-module.h"
43#include "ns3/csma-module.h"
44#include "ns3/global-route-manager.h"
45#include "ns3/internet-module.h"
46#include "ns3/mobility-module.h"
47#include "ns3/network-module.h"
48#include "ns3/vector.h"
49#include "ns3/wimax-module.h"
50
51#include <iostream>
52#include <vector>
53
54using namespace ns3;
55
56NS_LOG_COMPONENT_DEFINE("WimaxMulticastSimulation");
57
58int
59main(int argc, char* argv[])
60{
61 bool verbose = false;
62
63 NodeContainer ssNodes;
64 std::vector<Ptr<SubscriberStationNetDevice>> ss;
65 NetDeviceContainer ssDevs;
66 Ipv4InterfaceContainer SSinterfaces;
67
68 NodeContainer bsNodes;
70 NetDeviceContainer bsDevs;
71 NetDeviceContainer bsDevsOne;
72 Ipv4InterfaceContainer BSinterfaces;
73
74 UdpTraceClientHelper udpClient;
76
78 NodeContainer Streamer_Node;
79 NodeContainer ASNGW_Node;
80
82 std::vector<Ptr<RandomWaypointMobilityModel>> SSPosition;
83 std::vector<Ptr<RandomRectanglePositionAllocator>> SSPosAllocator;
84
85 // default values
86 int nbSS = 10;
87 int duration = 7;
88 int schedType = 0;
90
91 CommandLine cmd(__FILE__);
92 cmd.AddValue("nbSS", "number of subscriber station to create", nbSS);
93 cmd.AddValue("scheduler", "type of scheduler to use with the netdevices", schedType);
94 cmd.AddValue("duration", "duration of the simulation in seconds", duration);
95 cmd.AddValue("verbose", "turn on all WimaxNetDevice log components", verbose);
96 cmd.Parse(argc, argv);
97
98 LogComponentEnable("UdpTraceClient", LOG_LEVEL_INFO);
100
101 switch (schedType)
102 {
103 case 0:
105 break;
106 case 1:
108 break;
109 case 2:
111 break;
112 default:
114 }
115
116 ss.resize(nbSS);
117 SSPosition.resize(nbSS);
118 SSPosAllocator.resize(nbSS);
119
120 ssNodes.Create(nbSS);
121 bsNodes.Create(1);
122
123 Streamer_Node.Create(1);
124 ASNGW_Node.Create(1);
125
126 WimaxHelper wimax;
127
130 ssDevs = wimax.Install(ssNodes,
133 channel,
134 scheduler);
135 Ptr<WimaxNetDevice> dev = wimax.Install(bsNodes.Get(0),
138 channel,
139 scheduler);
140
142
143 BSPosition->SetPosition(Vector(1000, 0, 0));
144 bsNodes.Get(0)->AggregateObject(BSPosition);
145 bsDevs.Add(dev);
146 if (verbose)
147 {
148 WimaxHelper::EnableLogComponents(); // Turn on all wimax logging
149 }
150
151 for (int i = 0; i < nbSS; i++)
152 {
156 xVar->SetAttribute("Min", DoubleValue((i / 40.0) * 2000));
157 xVar->SetAttribute("Max", DoubleValue((i / 40.0 + 1) * 2000));
158 SSPosAllocator[i]->SetX(xVar);
160 yVar->SetAttribute("Min", DoubleValue((i / 40.0) * 2000));
161 yVar->SetAttribute("Max", DoubleValue((i / 40.0 + 1) * 2000));
162 SSPosAllocator[i]->SetY(yVar);
163 SSPosition[i]->SetAttribute("PositionAllocator", PointerValue(SSPosAllocator[i]));
164 SSPosition[i]->SetAttribute("Speed",
165 StringValue("ns3::UniformRandomVariable[Min=10.3|Max=40.7]"));
166 SSPosition[i]->SetAttribute("Pause",
167 StringValue("ns3::ConstantRandomVariable[Constant=0.01]"));
168
169 ss[i] = ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>();
170 ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_12);
171 ssNodes.Get(i)->AggregateObject(SSPosition[i]);
172 }
173
174 bs = bsDevs.Get(0)->GetObject<BaseStationNetDevice>();
175
176 CsmaHelper csmaASN_BS;
177 CsmaHelper csmaStreamer_ASN;
178
179 // First LAN BS and ASN
180 NodeContainer LAN_ASN_BS;
181
182 LAN_ASN_BS.Add(bsNodes.Get(0));
183
184 LAN_ASN_BS.Add(ASNGW_Node.Get(0));
185
186 csmaASN_BS.SetChannelAttribute("DataRate", DataRateValue(DataRate(10000000)));
187 csmaASN_BS.SetChannelAttribute("Delay", TimeValue(MilliSeconds(2)));
188 csmaASN_BS.SetDeviceAttribute("Mtu", UintegerValue(1500));
189 NetDeviceContainer LAN_ASN_BS_Devs = csmaASN_BS.Install(LAN_ASN_BS);
190
191 NetDeviceContainer BS_CSMADevs;
192
193 BS_CSMADevs.Add(LAN_ASN_BS_Devs.Get(0));
194
195 NetDeviceContainer ASN_Devs1;
196 ASN_Devs1.Add(LAN_ASN_BS_Devs.Get(1));
197
198 // Second LAN ASN-GW and Streamer
199
200 NodeContainer LAN_ASN_STREAMER;
201 LAN_ASN_STREAMER.Add(ASNGW_Node.Get(0));
202 LAN_ASN_STREAMER.Add(Streamer_Node.Get(0));
203
204 csmaStreamer_ASN.SetChannelAttribute("DataRate", DataRateValue(DataRate(10000000)));
205 csmaStreamer_ASN.SetChannelAttribute("Delay", TimeValue(MilliSeconds(2)));
206 csmaStreamer_ASN.SetDeviceAttribute("Mtu", UintegerValue(1500));
207
208 NetDeviceContainer LAN_ASN_STREAMER_Devs = csmaStreamer_ASN.Install(LAN_ASN_STREAMER);
209
210 NetDeviceContainer STREAMER_Devs;
211 NetDeviceContainer ASN_Devs2;
212 ASN_Devs2.Add(LAN_ASN_STREAMER_Devs.Get(0));
213 STREAMER_Devs.Add(LAN_ASN_STREAMER_Devs.Get(1));
214
217 mobility.Install(bsNodes);
218 stack.Install(bsNodes);
219 mobility.Install(ssNodes);
220 stack.Install(ssNodes);
221 stack.Install(Streamer_Node);
222 stack.Install(ASNGW_Node);
223
225
226 address.SetBase("10.1.0.0", "255.255.255.0");
227 bsDevsOne.Add(bs);
228 BSinterfaces = address.Assign(bsDevsOne);
229 SSinterfaces = address.Assign(ssDevs);
230
231 address.SetBase("11.1.1.0", "255.255.255.0");
232 Ipv4InterfaceContainer BSCSMAInterfaces = address.Assign(BS_CSMADevs);
233 Ipv4InterfaceContainer ASNCSMAInterfaces1 = address.Assign(ASN_Devs1);
234
235 address.SetBase("12.1.1.0", "255.255.255.0");
236 Ipv4InterfaceContainer ASNCSMAInterfaces2 = address.Assign(ASN_Devs2);
237 Ipv4InterfaceContainer StreamerCSMAInterfaces = address.Assign(STREAMER_Devs);
238
239 Ipv4Address multicastSource("12.1.1.2");
240 Ipv4Address multicastGroup("224.30.10.81");
241
242 Ipv4StaticRoutingHelper multicast;
243 // 1) Configure a (static) multicast route on ASNGW (multicastRouter)
244 Ptr<Node> multicastRouter = ASNGW_Node.Get(0); // The node in question
245 Ptr<NetDevice> inputIf = ASN_Devs2.Get(0); // The input NetDevice
246
247 multicast.AddMulticastRoute(multicastRouter,
248 multicastSource,
249 multicastGroup,
250 inputIf,
251 ASN_Devs1);
252
253 // 2) Set up a default multicast route on the sender n0
254 Ptr<Node> sender = Streamer_Node.Get(0);
255 Ptr<NetDevice> senderIf = STREAMER_Devs.Get(0);
256 multicast.SetDefaultMulticastRoute(sender, senderIf);
257
258 // 1) Configure a (static) multicast route on ASNGW (multicastRouter)
259 multicastRouter = bsNodes.Get(0); // The node in question
260 inputIf = BS_CSMADevs.Get(0); // The input NetDevice
261
262 multicast.AddMulticastRoute(multicastRouter,
263 multicastSource,
264 multicastGroup,
265 inputIf,
266 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
295 MulticastClassifier);
296
297 bs->GetServiceFlowManager()->AddMulticastServiceFlow(MulticastServiceFlow,
299
300 Simulator::Stop(Seconds(duration + 0.1));
301 NS_LOG_INFO("Starting simulation.....");
303
304 for (int i = 0; i < nbSS; i++)
305 {
306 ss[i] = nullptr;
307 SSPosition[i] = nullptr;
308 SSPosAllocator[i] = nullptr;
309 }
310
311 bs = nullptr;
312
314 NS_LOG_INFO("Done.");
315
316 return 0;
317}
holds a vector of ns3::Application pointers.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
BaseStation NetDevice.
Parse command-line arguments.
build a set of CsmaNetDevice objects
Definition csma-helper.h:37
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
Class for representing data rates.
Definition data-rate.h:78
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
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(const NodeContainer &nc)
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 AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition object.cc:298
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
This class implements service flows as described by the IEEE-802.16 standard.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
SubscriberStationNetDevice subclass of WimaxNetDevice.
Create a server application which waits for input UDP packets and uses the information carried into t...
Create UdpTraceClient application which sends UDP packets based on a trace file of an MPEG4 stream.
Hold an unsigned integer type.
Definition uinteger.h:34
helps to manage and create WimaxNetDevice objects
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
@ SCHED_TYPE_RTPS
A simple scheduler - rtPS based scheduler.
@ SCHED_TYPE_MBQOS
An migration-based uplink scheduler.
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
static void EnableLogComponents()
Helper to enable all WimaxNetDevice log components with one statement.
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulingType, IpcsClassifierRecord classifier)
Creates a transport service flow.
@ MODULATION_TYPE_QPSK_12
Definition wimax-phy.h:45
@ MODULATION_TYPE_QAM16_12
Definition wimax-phy.h:47
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
address
Definition first.py:36
serverApps
Definition first.py:43
clientApps
Definition first.py:53
stack
Definition first.py:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition log.h:93
channel
Definition third.py:77
mobility
Definition third.py:92
bool verbose