A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-simple.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 2
12// subscriber station (SS).
13
14// +-----+
15// | SS0 |
16// +-----+
17// 10.1.1.1
18// -------
19// ((*))
20//
21// 10.1.1.7
22// +------------+
23// |Base Station| ==((*))
24// +------------+
25//
26// ((*))
27// -------
28// 10.1.1.2
29// +-----+
30// | SS1 |
31// +-----+
32
33#include "ns3/applications-module.h"
34#include "ns3/core-module.h"
35#include "ns3/global-route-manager.h"
36#include "ns3/internet-module.h"
37#include "ns3/ipcs-classifier-record.h"
38#include "ns3/mobility-module.h"
39#include "ns3/network-module.h"
40#include "ns3/service-flow.h"
41#include "ns3/wimax-module.h"
42
43#include <iostream>
44
45using namespace ns3;
46
47NS_LOG_COMPONENT_DEFINE("WimaxSimpleExample");
48
49int
50main(int argc, char* argv[])
51{
52 bool verbose = false;
53
54 int duration = 7;
55 int schedType = 0;
57
58 CommandLine cmd(__FILE__);
59 cmd.AddValue("scheduler", "type of scheduler to use with the network devices", schedType);
60 cmd.AddValue("duration", "duration of the simulation in seconds", duration);
61 cmd.AddValue("verbose", "turn on all WimaxNetDevice log components", verbose);
62 cmd.Parse(argc, argv);
65 switch (schedType)
66 {
67 case 0:
69 break;
70 case 1:
72 break;
73 case 2:
75 break;
76 default:
78 }
79
80 NodeContainer ssNodes;
81 NodeContainer bsNodes;
82
83 ssNodes.Create(2);
84 bsNodes.Create(1);
85
86 WimaxHelper wimax;
87
88 NetDeviceContainer ssDevs;
89 NetDeviceContainer bsDevs;
90
91 ssDevs = wimax.Install(ssNodes,
94 scheduler);
95 bsDevs = wimax.Install(bsNodes,
98 scheduler);
99
100 wimax.EnableAscii("bs-devices", bsDevs);
101 wimax.EnableAscii("ss-devices", ssDevs);
102
104
105 for (int i = 0; i < 2; i++)
106 {
107 ss[i] = ssDevs.Get(i)->GetObject<SubscriberStationNetDevice>();
108 ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_12);
109 }
110
112
113 bs = bsDevs.Get(0)->GetObject<BaseStationNetDevice>();
114
116 stack.Install(bsNodes);
117 stack.Install(ssNodes);
118
120 address.SetBase("10.1.1.0", "255.255.255.0");
121
122 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
123 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
124
125 if (verbose)
126 {
127 WimaxHelper::EnableLogComponents(); // Turn on all wimax logging
128 }
129 /*------------------------------*/
130 UdpServerHelper udpServer;
132 UdpClientHelper udpClient;
134
135 udpServer = UdpServerHelper(100);
136
137 serverApps = udpServer.Install(ssNodes.Get(0));
138 serverApps.Start(Seconds(6));
139 serverApps.Stop(Seconds(duration));
140
141 udpClient = UdpClientHelper(SSinterfaces.GetAddress(0), 100);
142 udpClient.SetAttribute("MaxPackets", UintegerValue(1200));
143 udpClient.SetAttribute("Interval", TimeValue(Seconds(0.5)));
144 udpClient.SetAttribute("PacketSize", UintegerValue(1024));
145
146 clientApps = udpClient.Install(ssNodes.Get(1));
147 clientApps.Start(Seconds(6));
148 clientApps.Stop(Seconds(duration));
149
150 Simulator::Stop(Seconds(duration + 0.1));
151
152 wimax.EnablePcap("wimax-simple-ss0", ssNodes.Get(0)->GetId(), ss[0]->GetIfIndex());
153 wimax.EnablePcap("wimax-simple-ss1", ssNodes.Get(1)->GetId(), ss[1]->GetIfIndex());
154 wimax.EnablePcap("wimax-simple-bs0", bsNodes.Get(0)->GetId(), bs->GetIfIndex());
155
156 IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"),
157 Ipv4Mask("0.0.0.0"),
158 SSinterfaces.GetAddress(0),
159 Ipv4Mask("255.255.255.255"),
160 0,
161 65000,
162 100,
163 100,
164 17,
165 1);
168 DlClassifierUgs);
169
170 IpcsClassifierRecord UlClassifierUgs(SSinterfaces.GetAddress(1),
171 Ipv4Mask("255.255.255.255"),
172 Ipv4Address("0.0.0.0"),
173 Ipv4Mask("0.0.0.0"),
174 0,
175 65000,
176 100,
177 100,
178 17,
179 1);
182 UlClassifierUgs);
183 ss[0]->AddServiceFlow(DlServiceFlowUgs);
184 ss[1]->AddServiceFlow(UlServiceFlowUgs);
185
186 NS_LOG_INFO("Starting simulation.....");
188
189 ss[0] = nullptr;
190 ss[1] = nullptr;
191 bs = nullptr;
192
194 NS_LOG_INFO("Done.");
195
196 return 0;
197}
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...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
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
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.
uint32_t GetId() const
Definition node.cc:106
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
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.
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
bool verbose