A Discrete-Event Network Simulator
API
wimax-simple.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 //
23 // Default network topology includes a base station (BS) and 2
24 // subscriber station (SS).
25 
26 // +-----+
27 // | SS0 |
28 // +-----+
29 // 10.1.1.1
30 // -------
31 // ((*))
32 //
33 // 10.1.1.7
34 // +------------+
35 // |Base Station| ==((*))
36 // +------------+
37 //
38 // ((*))
39 // -------
40 // 10.1.1.2
41 // +-----+
42 // | SS1 |
43 // +-----+
44 
45 #include "ns3/core-module.h"
46 #include "ns3/network-module.h"
47 #include "ns3/applications-module.h"
48 #include "ns3/mobility-module.h"
49 #include "ns3/config-store-module.h"
50 #include "ns3/wimax-module.h"
51 #include "ns3/internet-module.h"
52 #include "ns3/global-route-manager.h"
53 #include "ns3/ipcs-classifier-record.h"
54 #include "ns3/service-flow.h"
55 #include <iostream>
56 
57 using namespace ns3;
58 
59 NS_LOG_COMPONENT_DEFINE ("WimaxSimpleExample");
60 
61 int main (int argc, char *argv[])
62 {
63  bool verbose = false;
64 
65  int duration = 7, schedType = 0;
67 
68  CommandLine cmd (__FILE__);
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  LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
74  LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
75  switch (schedType)
76  {
77  case 0:
79  break;
80  case 1:
82  break;
83  case 2:
84  scheduler = WimaxHelper::SCHED_TYPE_RTPS;
85  break;
86  default:
88  }
89 
90  NodeContainer ssNodes;
91  NodeContainer bsNodes;
92 
93  ssNodes.Create (2);
94  bsNodes.Create (1);
95 
96  WimaxHelper wimax;
97 
98  NetDeviceContainer ssDevs, bsDevs;
99 
100  ssDevs = wimax.Install (ssNodes,
103  scheduler);
105 
106  wimax.EnableAscii ("bs-devices", bsDevs);
107  wimax.EnableAscii ("ss-devices", ssDevs);
108 
110 
111  for (int i = 0; i < 2; i++)
112  {
113  ss[i] = ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ();
115  }
116 
118 
119  bs = bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
120 
122  stack.Install (bsNodes);
123  stack.Install (ssNodes);
124 
126  address.SetBase ("10.1.1.0", "255.255.255.0");
127 
128  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
129  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
130 
131  if (verbose)
132  {
133  wimax.EnableLogComponents (); // Turn on all wimax logging
134  }
135  /*------------------------------*/
136  UdpServerHelper udpServer;
138  UdpClientHelper udpClient;
140 
141  udpServer = UdpServerHelper (100);
142 
143  serverApps = udpServer.Install (ssNodes.Get (0));
144  serverApps.Start (Seconds (6));
145  serverApps.Stop (Seconds (duration));
146 
147  udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
148  udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
149  udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.5)));
150  udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
151 
152  clientApps = udpClient.Install (ssNodes.Get (1));
153  clientApps.Start (Seconds (6));
154  clientApps.Stop (Seconds (duration));
155 
156  Simulator::Stop (Seconds (duration + 0.1));
157 
158  wimax.EnablePcap ("wimax-simple-ss0", ssNodes.Get (0)->GetId (), ss[0]->GetIfIndex ());
159  wimax.EnablePcap ("wimax-simple-ss1", ssNodes.Get (1)->GetId (), ss[1]->GetIfIndex ());
160  wimax.EnablePcap ("wimax-simple-bs0", bsNodes.Get (0)->GetId (), bs->GetIfIndex ());
161 
162  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
163  Ipv4Mask ("0.0.0.0"),
164  SSinterfaces.GetAddress (0),
165  Ipv4Mask ("255.255.255.255"),
166  0,
167  65000,
168  100,
169  100,
170  17,
171  1);
174  DlClassifierUgs);
175 
176  IpcsClassifierRecord UlClassifierUgs (SSinterfaces.GetAddress (1),
177  Ipv4Mask ("255.255.255.255"),
178  Ipv4Address ("0.0.0.0"),
179  Ipv4Mask ("0.0.0.0"),
180  0,
181  65000,
182  100,
183  100,
184  17,
185  1);
188  UlClassifierUgs);
189  ss[0]->AddServiceFlow (DlServiceFlowUgs);
190  ss[1]->AddServiceFlow (UlServiceFlowUgs);
191 
192  NS_LOG_INFO ("Starting simulation.....");
193  Simulator::Run ();
194 
195  ss[0] = 0;
196  ss[1] = 0;
197  bs = 0;
198 
200  NS_LOG_INFO ("Done.");
201 
202  return 0;
203 }
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition: net-device-container.h:42
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::BaseStationNetDevice
Definition: bs-net-device.h:51
ns3::UdpClientHelper::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Definition: udp-client-server-helper.cc:87
ns3::UdpClientHelper
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Definition: udp-client-server-helper.h:94
ns3::CommandLine
Parse command-line arguments.
Definition: command-line.h:228
ns3::LOG_LEVEL_INFO
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition: log.h:107
ns3::PcapHelperForDevice::EnablePcap
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Definition: trace-helper.cc:401
ns3::ServiceFlow::SF_DIRECTION_UP
@ SF_DIRECTION_UP
Definition: service-flow.h:46
ns3::Node::GetId
uint32_t GetId(void) const
Definition: node.cc:109
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv4AddressHelper
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Definition: ipv4-address-helper.h:48
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
ns3::LogComponentEnable
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::SubscriberStationNetDevice::SetModulationType
void SetModulationType(WimaxPhy::ModulationType modulationType)
Set the most efficient modulation and coding scheme (MCS) supported by the device.
Definition: ss-net-device.cc:514
ns3::WimaxHelper::SCHED_TYPE_SIMPLE
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
Definition: wimax-helper.h:87
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition: node-container.cc:98
ns3::UdpServerHelper
Create a server application which waits for input UDP packets and uses the information carried into t...
Definition: udp-client-server-helper.h:38
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::WimaxNetDevice::GetIfIndex
virtual uint32_t GetIfIndex(void) const
Get interface index.
Definition: wimax-net-device.cc:219
ns3::WimaxHelper::DEVICE_TYPE_BASE_STATION
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
Definition: wimax-helper.h:68
ns3::WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
Definition: wimax-helper.h:67
ns3::WimaxHelper::Install
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
Definition: wimax-helper.cc:249
ns3::ServiceFlow::SF_DIRECTION_DOWN
@ SF_DIRECTION_DOWN
Definition: service-flow.h:45
first.stack
stack
Definition: first.py:41
ns3::Simulator::Stop
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:180
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::WimaxHelper
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:59
ns3::WimaxPhy::MODULATION_TYPE_QAM16_12
@ MODULATION_TYPE_QAM16_12
Definition: wimax-phy.h:54
ns3::Ipv4InterfaceContainer
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Definition: ipv4-interface-container.h:55
ns3::NodeContainer::Get
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Definition: node-container.cc:93
verbose
bool verbose
Definition: openflow-switch.cc:50
first.address
address
Definition: first.py:44
ns3::WimaxHelper::SCHED_TYPE_RTPS
@ SCHED_TYPE_RTPS
A simple scheduler - rtPS based scheduler.
Definition: wimax-helper.h:88
ns3::WimaxHelper::CreateServiceFlow
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
Definition: wimax-helper.cc:422
second.cmd
cmd
Definition: second.py:35
ns3::WimaxHelper::EnableLogComponents
static void EnableLogComponents(void)
Helper to enable all WimaxNetDevice log components with one statement.
Definition: wimax-helper.cc:363
ns3::SubscriberStationNetDevice
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:49
ns3::Simulator::Run
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
ns3::WimaxHelper::SIMPLE_PHY_TYPE_OFDM
@ SIMPLE_PHY_TYPE_OFDM
Definition: wimax-helper.h:78
first.clientApps
clientApps
Definition: first.py:61
ns3::SubscriberStationNetDevice::AddServiceFlow
void AddServiceFlow(ServiceFlow *sf)
adds a new service flow
Definition: ss-net-device.cc:630
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::Simulator::Destroy
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition: application-container.h:43
first.serverApps
serverApps
Definition: first.py:52
ns3::UdpClientHelper::Install
ApplicationContainer Install(NodeContainer c)
Definition: udp-client-server-helper.cc:93
ns3::WimaxHelper::SCHED_TYPE_MBQOS
@ SCHED_TYPE_MBQOS
An migration-based uplink scheduler.
Definition: wimax-helper.h:89
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
ns3::UdpServerHelper::Install
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
Definition: udp-client-server-helper.cc:47
ns3::ServiceFlow::SF_TYPE_RTPS
@ SF_TYPE_RTPS
Definition: service-flow.h:64
ns3::NodeContainer
keep track of a set of node pointers.
Definition: node-container.h:39
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
ns3::WimaxHelper::SchedulerType
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
ns3::Ipv4InterfaceContainer::GetAddress
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Definition: ipv4-interface-container.cc:59
ns3::ServiceFlow
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:40
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::InternetStackHelper
aggregate IP/TCP/UDP functionality to existing Nodes.
Definition: internet-stack-helper.h:88
ns3::NetDeviceContainer::Get
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Definition: net-device-container.cc:62
ns3::IpcsClassifierRecord
IpcsClassifierRecord class.
Definition: ipcs-classifier-record.h:36
ns3::AsciiTraceHelperForDevice::EnableAscii
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
Definition: trace-helper.cc:469