A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-ipv4.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//
11// Default network topology includes a base station (BS) and some number of
12// subscriber station (SS) specified by the variable nbSS (defaults to six).
13// The SSs are grouped into two groups: senders and receivers. SSs from 0 to
14// nbSS/2 are designed as senders and SSs from (nbSS/2 + 1) to nbSS-1 will
15// designed as receivers.
16// Each SS creates 3 transport connection with the BS. the fist one has as QoS
17// scheduling type UGS, the second one rtPS and the third one BE.
18// Senders SSs send some stamped IP packets with variable bitrate to receiver SSs
19// through the BS station. receiver SSs receive the IP packets analyze them and
20// based on a sequence number decide if all the packets are coorectly received
21
22// +-----+ +-----+ +-----+
23// | SS0 | | SS1 | | SS2 |
24// +-----+ +-----+ +-----+
25// 10.1.1.1 10.1.1.2 10.1.1.3
26// -------- -------- -------
27// ((*)) ((*)) ((*))
28//
29// 10.1.1.7
30// +------------+
31// |Base Station| ==((*))
32// +------------+
33//
34// ((*)) ((*)) ((*))
35// ------- -------- --------
36// 10.1.1.4 10.1.1.5 10.1.1.6
37// +-----+ +-----+ +-----+
38// | SS3 | | SS4 | | SS5 |
39// +-----+ +-----+ +-----+
40
41#include "ns3/applications-module.h"
42#include "ns3/core-module.h"
43#include "ns3/global-route-manager.h"
44#include "ns3/internet-module.h"
45#include "ns3/mobility-module.h"
46#include "ns3/network-module.h"
47#include "ns3/wimax-module.h"
48
49#include <iostream>
50
51using namespace ns3;
52
53NS_LOG_COMPONENT_DEFINE("wimaxIpV4Simulation");
54
55int
56main(int argc, char* argv[])
57{
58 // default values
59 int nbSS = 4;
60 int duration = 7;
61 int schedType = 0;
62 bool verbose = false;
66
67 CommandLine cmd(__FILE__);
68 cmd.AddValue("nbSS", "number of subscriber station to create", nbSS);
69 cmd.AddValue("scheduler", "type of scheduler to use with the network devices", schedType);
70 cmd.AddValue("duration", "duration of the simulation in seconds", duration);
71 cmd.AddValue("verbose", "turn on all WimaxNetDevice log components", verbose);
72 cmd.Parse(argc, argv);
73
74 switch (schedType)
75 {
76 case 0:
78 break;
79 case 1:
81 break;
82 case 2:
84 break;
85 default:
87 }
88
89 NodeContainer ssNodes;
90 NodeContainer bsNodes;
91
92 ssNodes.Create(nbSS);
93 bsNodes.Create(1);
94
95 WimaxHelper wimax;
96
97 NetDeviceContainer ssDevs;
98 NetDeviceContainer bsDevs;
99
100 ssDevs = wimax.Install(ssNodes,
103 scheduler);
104 bsDevs = wimax.Install(bsNodes,
107 scheduler);
108
109 auto ss = new Ptr<SubscriberStationNetDevice>[nbSS];
110
111 for (int i = 0; i < nbSS; i++)
112 {
113 ss[i] = ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>();
115 }
116
118 bs = bsDevs.Get(0)->GetObject<BaseStationNetDevice>();
119
121 mobility.Install(bsNodes);
122 mobility.Install(ssNodes);
123
125 stack.Install(bsNodes);
126 stack.Install(ssNodes);
127
129 address.SetBase("10.1.1.0", "255.255.255.0");
130
131 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
132 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
133 if (verbose)
134 {
135 WimaxHelper::EnableLogComponents(); // Turn on all wimax logging
136 }
137 /*------------------------------*/
138 auto udpServer = new UdpServerHelper[nbSS / 2];
139 auto serverApps = new ApplicationContainer[nbSS / 2];
140 auto udpClient = new UdpClientHelper[nbSS / 2];
141 auto clientApps = new ApplicationContainer[nbSS / 2];
142
143 for (int i = 0; i < nbSS / 2; i++)
144 {
145 // set server port to 100+(i*10)
146 udpServer[i] = UdpServerHelper(100 + (i * 10));
147 serverApps[i] = udpServer[i].Install(ssNodes.Get(i));
148 serverApps[i].Start(Seconds(6));
149 serverApps[i].Stop(Seconds(duration));
150
151 udpClient[i] = UdpClientHelper(SSinterfaces.GetAddress(i), 100 + (i * 10));
152 udpClient[i].SetAttribute("MaxPackets", UintegerValue(1200));
153 udpClient[i].SetAttribute("Interval", TimeValue(Seconds(0.12)));
154 udpClient[i].SetAttribute("PacketSize", UintegerValue(800));
155
156 clientApps[i] = udpClient[i].Install(ssNodes.Get(i + (nbSS / 2)));
157 clientApps[i].Start(Seconds(6));
158 clientApps[i].Stop(Seconds(duration));
159 }
160
161 Simulator::Stop(Seconds(duration + 0.1));
162 /*
163 * Setup 1 transport connections between each SS and the BS
164 */
165 for (int i = 0; i < nbSS / 2; i++)
166 {
167 IpcsClassifierRecord DlClassifierBe(Ipv4Address("0.0.0.0"),
168 Ipv4Mask("0.0.0.0"),
169 SSinterfaces.GetAddress(i),
170 Ipv4Mask("255.255.255.255"),
171 0,
172 65000,
173 100 + (i * 10),
174 100 + (i * 10),
175 17,
176 1);
179 DlClassifierBe);
180 ss[i]->AddServiceFlow(DlServiceFlowBe);
181 IpcsClassifierRecord ulClassifierBe(SSinterfaces.GetAddress(i + (nbSS / 2)),
182 Ipv4Mask("255.255.255.255"),
183 Ipv4Address("0.0.0.0"),
184 Ipv4Mask("0.0.0.0"),
185 0,
186 65000,
187 100 + (i * 10),
188 100 + (i * 10),
189 17,
190 1);
193 ulClassifierBe);
194 ss[i + (nbSS / 2)]->AddServiceFlow(ulServiceFlowBe);
195 }
196
197 NS_LOG_INFO("Starting simulation.....");
199
200 delete[] clientApps;
201 delete[] udpClient;
202 delete[] serverApps;
203 delete[] udpServer;
204 for (int i = 0; i < nbSS; i++)
205 {
206 ss[i] = nullptr;
207 }
208 delete[] ss;
209
210 bs = nullptr;
211
213 NS_LOG_INFO("Done.");
214
215 return 0;
216}
holds a vector of ns3::Application pointers.
BaseStation NetDevice.
Parse command-line arguments.
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.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Helper class used to assign positions and mobility models to nodes.
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< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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
SubscriberStationNetDevice subclass of WimaxNetDevice.
void SetModulationType(WimaxPhy::ModulationType modulationType)
Set the most efficient modulation and coding scheme (MCS) supported by the device.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Create a server application which waits for input UDP packets and uses the information carried into t...
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_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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
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
mobility
Definition third.py:92
bool verbose