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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 * <amine.ismail@udcast.com>
19 */
20
21//
22// Default network topology includes a base station (BS) and some number of
23// subscriber station (SS) specified by the variable nbSS (defaults to six).
24// The SSs are grouped into two groups: senders and receivers. SSs from 0 to
25// nbSS/2 are designed as senders and SSs from (nbSS/2 + 1) to nbSS-1 will
26// designed as receivers.
27// Each SS creates 3 transport connection with the BS. the fist one has as QoS
28// scheduling type UGS, the second one rtPS and the third one BE.
29// Senders SSs send some stamped IP packets with variable bitrate to receiver SSs
30// through the BS station. receiver SSs receive the IP packets analyze them and
31// based on a sequence number decide if all the packets are coorectly received
32
33// +-----+ +-----+ +-----+
34// | SS0 | | SS1 | | SS2 |
35// +-----+ +-----+ +-----+
36// 10.1.1.1 10.1.1.2 10.1.1.3
37// -------- -------- -------
38// ((*)) ((*)) ((*))
39//
40// 10.1.1.7
41// +------------+
42// |Base Station| ==((*))
43// +------------+
44//
45// ((*)) ((*)) ((*))
46// ------- -------- --------
47// 10.1.1.4 10.1.1.5 10.1.1.6
48// +-----+ +-----+ +-----+
49// | SS3 | | SS4 | | SS5 |
50// +-----+ +-----+ +-----+
51
52#include "ns3/applications-module.h"
53#include "ns3/core-module.h"
54#include "ns3/global-route-manager.h"
55#include "ns3/internet-module.h"
56#include "ns3/mobility-module.h"
57#include "ns3/network-module.h"
58#include "ns3/wimax-module.h"
59
60#include <iostream>
61
62using namespace ns3;
63
64NS_LOG_COMPONENT_DEFINE("wimaxIpV4Simulation");
65
66int
67main(int argc, char* argv[])
68{
69 // default values
70 int nbSS = 4;
71 int duration = 7;
72 int schedType = 0;
73 bool verbose = false;
77
78 CommandLine cmd(__FILE__);
79 cmd.AddValue("nbSS", "number of subscriber station to create", nbSS);
80 cmd.AddValue("scheduler", "type of scheduler to use with the network devices", schedType);
81 cmd.AddValue("duration", "duration of the simulation in seconds", duration);
82 cmd.AddValue("verbose", "turn on all WimaxNetDevice log components", verbose);
83 cmd.Parse(argc, argv);
84
85 switch (schedType)
86 {
87 case 0:
89 break;
90 case 1:
92 break;
93 case 2:
95 break;
96 default:
98 }
99
100 NodeContainer ssNodes;
101 NodeContainer bsNodes;
102
103 ssNodes.Create(nbSS);
104 bsNodes.Create(1);
105
106 WimaxHelper wimax;
107
108 NetDeviceContainer ssDevs;
109 NetDeviceContainer bsDevs;
110
111 ssDevs = wimax.Install(ssNodes,
114 scheduler);
115 bsDevs = wimax.Install(bsNodes,
118 scheduler);
119
121
122 for (int i = 0; i < nbSS; i++)
123 {
124 ss[i] = ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>();
125 ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_12);
126 }
127
129 bs = bsDevs.Get(0)->GetObject<BaseStationNetDevice>();
130
132 mobility.Install(bsNodes);
133 mobility.Install(ssNodes);
134
136 stack.Install(bsNodes);
137 stack.Install(ssNodes);
138
140 address.SetBase("10.1.1.0", "255.255.255.0");
141
142 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
143 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
144 if (verbose)
145 {
146 WimaxHelper::EnableLogComponents(); // Turn on all wimax logging
147 }
148 /*------------------------------*/
149 UdpServerHelper* udpServer = new UdpServerHelper[nbSS / 2];
151 UdpClientHelper* udpClient = new UdpClientHelper[nbSS / 2];
153
154 for (int i = 0; i < nbSS / 2; i++)
155 {
156 // set server port to 100+(i*10)
157 udpServer[i] = UdpServerHelper(100 + (i * 10));
158 serverApps[i] = udpServer[i].Install(ssNodes.Get(i));
159 serverApps[i].Start(Seconds(6));
160 serverApps[i].Stop(Seconds(duration));
161
162 udpClient[i] = UdpClientHelper(SSinterfaces.GetAddress(i), 100 + (i * 10));
163 udpClient[i].SetAttribute("MaxPackets", UintegerValue(1200));
164 udpClient[i].SetAttribute("Interval", TimeValue(Seconds(0.12)));
165 udpClient[i].SetAttribute("PacketSize", UintegerValue(800));
166
167 clientApps[i] = udpClient[i].Install(ssNodes.Get(i + (nbSS / 2)));
168 clientApps[i].Start(Seconds(6));
169 clientApps[i].Stop(Seconds(duration));
170 }
171
172 Simulator::Stop(Seconds(duration + 0.1));
173 /*
174 * Setup 1 transport connections between each SS and the BS
175 */
176 for (int i = 0; i < nbSS / 2; i++)
177 {
178 IpcsClassifierRecord DlClassifierBe(Ipv4Address("0.0.0.0"),
179 Ipv4Mask("0.0.0.0"),
180 SSinterfaces.GetAddress(i),
181 Ipv4Mask("255.255.255.255"),
182 0,
183 65000,
184 100 + (i * 10),
185 100 + (i * 10),
186 17,
187 1);
190 DlClassifierBe);
191 ss[i]->AddServiceFlow(DlServiceFlowBe);
192 IpcsClassifierRecord ulClassifierBe(SSinterfaces.GetAddress(i + (nbSS / 2)),
193 Ipv4Mask("255.255.255.255"),
194 Ipv4Address("0.0.0.0"),
195 Ipv4Mask("0.0.0.0"),
196 0,
197 65000,
198 100 + (i * 10),
199 100 + (i * 10),
200 17,
201 1);
204 ulClassifierBe);
205 ss[i + (nbSS / 2)]->AddServiceFlow(ulServiceFlowBe);
206 }
207
208 NS_LOG_INFO("Starting simulation.....");
210
211 delete[] clientApps;
212 delete[] udpClient;
213 delete[] serverApps;
214 delete[] udpServer;
215 for (int i = 0; i < nbSS; i++)
216 {
217 ss[i] = nullptr;
218 }
219 delete[] ss;
220
221 bs = nullptr;
222
224 NS_LOG_INFO("Done.");
225
226 return 0;
227}
holds a vector of ns3::Application pointers.
BaseStation NetDevice.
Definition: bs-net-device.h:54
Parse command-line arguments.
Definition: command-line.h:232
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:42
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
Definition: ipv4-address.h:257
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.
Definition: ptr.h:78
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void Run()
Run the simulation.
Definition: simulator.cc:176
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:184
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
AttributeValue implementation for Time.
Definition: nstime.h:1423
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ApplicationContainer Install(NodeContainer c)
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.
Hold an unsigned integer type.
Definition: uinteger.h:45
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
@ SCHED_TYPE_RTPS
A simple scheduler - rtPS based scheduler.
Definition: wimax-helper.h:88
@ SCHED_TYPE_MBQOS
An migration-based uplink scheduler.
Definition: wimax-helper.h:89
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition: wimax-helper.h:87
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
Definition: wimax-helper.h:67
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition: wimax-helper.h:68
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 schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
@ MODULATION_TYPE_QAM16_12
Definition: wimax-phy.h:58
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
ns serverApps
Definition: first.py:48
ns clientApps
Definition: first.py:58
ns address
Definition: first.py:40
ns stack
Definition: first.py:37
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:302
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition: log.h:104
ns cmd
Definition: second.py:33
ns mobility
Definition: third.py:96
bool verbose