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 
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 }
holds a vector of ns3::Application pointers.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
An migration-based uplink scheduler.
Definition: wimax-helper.h:89
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:85
void SetModulationType(WimaxPhy::ModulationType modulationType)
Set the most efficient modulation and coding scheme (MCS) supported by the device.
serverApps
Definition: first.py:45
static void Run(void)
Run the simulation.
Definition: simulator.cc:226
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:278
cmd
Definition: second.py:35
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
stack
Definition: first.py:34
IpcsClassifierRecord class.
ApplicationContainer Install(NodeContainer c)
mobility
Definition: third.py:101
A simple scheduler - rtPS based scheduler.
Definition: wimax-helper.h:88
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:369
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
AttributeValue implementation for Time.
Definition: nstime.h:1076
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
Definition: uinteger.h:44
LOG_INFO and above.
Definition: log.h:104
holds a vector of ns3::NetDevice pointers
Create a server application which waits for input UDP packets and uses the information carried into t...
Parse command-line arguments.
Definition: command-line.h:213
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:190
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
address
Definition: first.py:37
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:234
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:58
clientApps
Definition: first.py:54
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:48
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
static void EnableLogComponents(void)
Helper to enable all WimaxNetDevice log components with one statement.
void AddServiceFlow(ServiceFlow *sf)
adds a new service flow
A simple priority-based FCFS scheduler.
Definition: wimax-helper.h:87
bool verbose