A Discrete-Event Network Simulator
API
wimax-ipv4.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 some number of
24 // subscriber station (SS) specified by the variable nbSS (defaults to six).
25 // The SSs are grouped into two groups: senders and receivers. SSs from 0 to
26 // nbSS/2 are designed as senders and SSs from (nbSS/2 + 1) to nbSS-1 will
27 // designed as receivers.
28 // Each SS creates 3 transport connection with the BS. the fist one has as QoS
29 // scheduling type UGS, the second one rtPS and the third one BE.
30 // Senders SSs send some stamped IP packets with variable bitrate to receiver SSs
31 // through the BS station. receiver SSs receive the IP packets analyze them and
32 // based on a sequnece number decide if all the packets are coorectly received
33 
34 // +-----+ +-----+ +-----+
35 // | SS0 | | SS1 | | SS2 |
36 // +-----+ +-----+ +-----+
37 // 10.1.1.1 10.1.1.2 10.1.1.3
38 // -------- -------- -------
39 // ((*)) ((*)) ((*))
40 //
41 // 10.1.1.7
42 // +------------+
43 // |Base Station| ==((*))
44 // +------------+
45 //
46 // ((*)) ((*)) ((*))
47 // ------- -------- --------
48 // 10.1.1.4 10.1.1.5 10.1.1.6
49 // +-----+ +-----+ +-----+
50 // | SS3 | | SS4 | | SS5 |
51 // +-----+ +-----+ +-----+
52 
53 #include "ns3/core-module.h"
54 #include "ns3/network-module.h"
55 #include "ns3/applications-module.h"
56 #include "ns3/mobility-module.h"
57 #include "ns3/config-store-module.h"
58 #include "ns3/wimax-module.h"
59 #include "ns3/internet-module.h"
60 #include "ns3/global-route-manager.h"
61 #include <iostream>
62 
63 using namespace ns3;
64 
65 NS_LOG_COMPONENT_DEFINE ("wimaxIpV4Simulation");
66 
67 int main (int argc, char *argv[])
68 {
69  // default values
70  int nbSS = 4, duration = 7, schedType = 0;
71  bool verbose = false;
73  LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
74  LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
75 
76 
77  CommandLine cmd (__FILE__);
78  cmd.AddValue ("nbSS", "number of subscriber station to create", nbSS);
79  cmd.AddValue ("scheduler", "type of scheduler to use with the network devices", schedType);
80  cmd.AddValue ("duration", "duration of the simulation in seconds", duration);
81  cmd.AddValue ("verbose", "turn on all WimaxNetDevice log components", verbose);
82  cmd.Parse (argc, argv);
83 
84  switch (schedType)
85  {
86  case 0:
88  break;
89  case 1:
91  break;
92  case 2:
93  scheduler = WimaxHelper::SCHED_TYPE_RTPS;
94  break;
95  default:
97  }
98 
99  NodeContainer ssNodes;
100  NodeContainer bsNodes;
101 
102  ssNodes.Create (nbSS);
103  bsNodes.Create (1);
104 
105  WimaxHelper wimax;
106 
107  NetDeviceContainer ssDevs, bsDevs;
108 
109  ssDevs = wimax.Install (ssNodes,
112  scheduler);
114 
116 
117  for (int i = 0; i < nbSS; i++)
118  {
119  ss[i] = ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ();
121  }
122 
124  bs = bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
125 
127  mobility.Install (bsNodes);
128  mobility.Install (ssNodes);
129 
131  stack.Install (bsNodes);
132  stack.Install (ssNodes);
133 
135  address.SetBase ("10.1.1.0", "255.255.255.0");
136 
137  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
138  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
139  if (verbose)
140  {
141  wimax.EnableLogComponents (); // Turn on all wimax logging
142  }
143  /*------------------------------*/
144  UdpServerHelper* udpServer = new UdpServerHelper[nbSS / 2];
146  UdpClientHelper* udpClient = new UdpClientHelper[nbSS / 2];
148 
149  for (int i = 0; i < nbSS / 2; i++)
150  {
151  // set server port to 100+(i*10)
152  udpServer[i] = UdpServerHelper (100 + (i * 10));
153  serverApps[i] = udpServer[i].Install (ssNodes.Get (i));
154  serverApps[i].Start (Seconds (6));
155  serverApps[i].Stop (Seconds (duration));
156 
157  udpClient[i] = UdpClientHelper (SSinterfaces.GetAddress (i), 100 + (i * 10));
158  udpClient[i].SetAttribute ("MaxPackets", UintegerValue (1200));
159  udpClient[i].SetAttribute ("Interval", TimeValue (Seconds (0.12)));
160  udpClient[i].SetAttribute ("PacketSize", UintegerValue (800));
161 
162  clientApps[i] = udpClient[i].Install (ssNodes.Get (i + (nbSS / 2)));
163  clientApps[i].Start (Seconds (6));
164  clientApps[i].Stop (Seconds (duration));
165  }
166 
167  Simulator::Stop (Seconds (duration + 0.1));
168  /*
169  * Setup 1 transport connections between each SS and the BS
170  */
171  for (int i = 0; i < nbSS / 2; i++)
172  {
173  IpcsClassifierRecord DlClassifierBe (Ipv4Address ("0.0.0.0"),
174  Ipv4Mask ("0.0.0.0"),
175  SSinterfaces.GetAddress (i),
176  Ipv4Mask ("255.255.255.255"),
177  0,
178  65000,
179  100 + (i * 10),
180  100 + (i * 10),
181  17,
182  1);
185  DlClassifierBe);
186  ss[i]->AddServiceFlow (DlServiceFlowBe);
187  IpcsClassifierRecord ulClassifierBe (SSinterfaces.GetAddress (i + (nbSS / 2)),
188  Ipv4Mask ("255.255.255.255"),
189  Ipv4Address ("0.0.0.0"),
190  Ipv4Mask ("0.0.0.0"),
191  0,
192  65000,
193  100 + (i * 10),
194  100 + (i * 10),
195  17,
196  1);
199  ulClassifierBe);
200  ss[i + (nbSS / 2)]->AddServiceFlow (ulServiceFlowBe);
201 
202  }
203 
204  NS_LOG_INFO ("Starting simulation.....");
205  Simulator::Run ();
206 
207  delete[] clientApps;
208  delete[] udpClient;
209  delete[] serverApps;
210  delete[] udpServer;
211  for (int i = 0; i < nbSS; i++)
212  {
213  ss[i] = 0;
214  }
215  delete[] ss;
216 
217  bs = 0;
218 
220  NS_LOG_INFO ("Done.");
221 
222  return 0;
223 }
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::ServiceFlow::SF_DIRECTION_UP
@ SF_DIRECTION_UP
Definition: service-flow.h:46
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::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::ServiceFlow::SF_TYPE_BE
@ SF_TYPE_BE
Definition: service-flow.h:62
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::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::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition: mobility-helper.h:43
third.mobility
mobility
Definition: third.py:108
ns3::IpcsClassifierRecord
IpcsClassifierRecord class.
Definition: ipcs-classifier-record.h:36