Date post: | 12-Apr-2017 |
Category: |
Engineering |
Upload: | mustafa-khaleel |
View: | 482 times |
Download: | 0 times |
I
WiMAX Implementation in NS3
Master Program
(Advanced Wireless Telecommunication)
By Student:
Mustafa Khaleel
II
Contents 1. Introduction ............................................................................................................................ 1
1.1. Study case ....................................................................................................................... 1
2. Network simulator 3 (NS-3) .................................................................................................... 2
2.1. The basic model .............................................................................................................. 3
2.2. Ns-3 Packets .................................................................................................................... 6
2.3. Simulation Basics ............................................................................................................ 6
3. Simulation and Results ........................................................................................................... 7
Annex ............................................................................................................................................ 14
References ..................................................................................................................................... 17
Figure 1 NS-2 and NS-3 ................................................................................................................... 2
Figure 2 the waf build system ........................................................................................................ 3
Figure 3 a special waf shell ............................................................................................................. 3
Figure 4 the basic model ................................................................................................................. 3
Figure 5 the class Application ......................................................................................................... 4
Figure 6 NetDevices ........................................................................................................................ 5
Figure 7 Udpheader example ......................................................................................................... 6
Figure 8 header files ....................................................................................................................... 7
Figure 9 scheduler and log comopent ........................................................................................... 7
Figure 10 Nodes .............................................................................................................................. 8
Figure 11 netDevice ........................................................................................................................ 8
Figure 12 configuration of PHY layer of Subscribers ..................................................................... 8
Figure 13 configuration of PHY layer of BaseStation ..................................................................... 9
Figure 14 IP addresses ..................................................................................................................... 9
Figure 15 the mobility model ......................................................................................................... 9
Figure 16 server and client-1 ........................................................................................................ 10
Figure 17 server and client-2 ......................................................................................................... 10
Figure 18 IpcsClassifierRecord user-1 ........................................................................................... 10
Figure 19 IpcsClassifierRecord user-2 ........................................................................................... 11
Figure 20 Running simulator ........................................................................................................ 11
Figure 21 simulation output ......................................................................................................... 12
Figure 22 the position of nodes .................................................................................................... 12
Figure 23 Nodes in NetAnim ......................................................................................................... 13
Figure 24 the transmission in time ............................................................................................... 13
III
1
1. Introduction
Network simulator 3 (ns-3) is a discrete-event network simulator, targeted primarily for research and educational use. ns-3 is free software, licensed under the GNU GPLv2 license, and is publicly available for research, development, and use. The goal of the ns-3 project is to develop a preferred, open simulation environment for networking research: it should be aligned with the simulation needs of modern networking research and should encourage community contribution, peer review, and validation of the software.
1.1. Study case
We use two nodes and base station in Wi-max with ns3 program v. 3.24
and simulate the traffic by changing the modulations schemes and we
will demonstrate the results packets, the delay and the packet flow
between the transmitter and receiver with animation environment
images that explain the transmission time between the nodes and the
base station, all these results will be shown in ns3 program and followed
steps.
2
2. Network simulator 3 (NS-3)
NS-3 is discrete-event network simulator, its open source (GNU GPLv2) and
it’s written in written entirely in C++ (with Python bindings).
NS-3 alignment with real systems (sockets, device, driver interface) also its
alignment with input/output standards (papa traces, ns-2 mobility scripts),
and its modular and documented core.
The figure below show the comparison between NS-2 and NS-3 from
Models view,
Figure 1 NS-2 and NS-3
3
NS-3 using the waf build system, and its Python-based framework for configuring, compiling and installing applications.
Figure 2 the waf build system
Can run programs through a special waf shell;
Figure 3 a special waf shell
2.1. The basic model
In figure below show the basic model of ns-3
Figure 4 the basic model
Node is like a computer to which you will add functionality. One add things
like applications, protocol stacks and peripheral cards with their associated
drivers to enable the computer to do useful work. We use the same basic
model in ns-3 and it’s represented in C++ by the class Node.
4
Application
A user would typically run an application that acquires and uses the
resources controlled by the system software to accomplish some goal. It’s
represented in C++ by the class Application.
An Application may specialized versions of the application model
Application called UdpEchoClientApplication and
UdpEchoServerApplication, OnOffApplication, PacketSink, for example
client/server application set used to generate and echo simulated network
packets
Figure 5 the class Application
Channel
In the real world, one can connect a computer to a network. Often the
media over which data flows in these networks are called channels.
And it is represented in C++ by the class Channel. The Channel class
provides methods for managing communication subnetwork objects and
connecting nodes to them.
A Channel may specialized versions of the Channel model called
CsmaChannel, PointToPointChannel and WifiChannel. The CsmaChannel,
for example, models a version of a communication subnetwork that
implements a carrier sense multiple access communication medium. This
gives us Ethernet-like functionality.
5
Net Device
A net device is “installed” in a Node in order to enable the Node to
communicate with other Nodes in the simulation via Channels. Just as in a
real computer, a Node may be connected to more than one Channel via
multiple NetDevices.and NetDevices are strongly bound to Channels of a
matching type.
Figure 6 NetDevices
And there several specialized versions of the NetDevice called
CsmaNetDevice, PointToPointNetDevice, and WifiNetDevice, for example
the CsmaNetDevice is designed to work with a CsmaChannel; the
PointToPointNetDevice is designed to work with a PointToPointChannel
and a WifiNetNevice is designed to work with a WifiChannel.
Topology Helpers
Since connecting NetDevices to Nodes, NetDevices to Channels, assigning
IP addresses, etc., are such common tasks in ns-3, we call topology helpers
to make this as easy as possible, for example, it may take many distinct ns-3
core operations to create a NetDevice, add a MAC address, install that net
device on a Node, configure the node’s protocol stack, and then connect
the NetDevice to a Channel.
6
2.2. Ns-3 Packets
Each network packet contains a byte buffer, a list of tags,metadata and
buffer: bit-by-bit (serialized) representation of headers and trailers, the
tags: set of arbitrary, user-provided data structures (e.g., per-packet cross-
layer messages, or flow identifiers), finally the metadata: describes types of
headers and trailers that have been serialized.
To add a new header, subclass from Header, and write your Serialize() and
Deserialize() methods as we see in figure below, the Udpheader example
Figure 7 Udpheader example
2.3. Simulation Basics
Simulation time moves discretely from event to event as in C++ functions
schedule events to occur at specific simulation times, in ns3 we call Run()
function:
Simulation::Run() gets it all started
And the simulation will stop at specific time or when events end.
7
3. Simulation and Results In our simulation scenario, the wireless network will composed three
nodes:
1. One base Station
2. Two subscriber stations
And subscriber station-1 sends packets to the station subscribe-2.
First we import the necessary header files defines the namespace to use.
Figure 8 header files
We create an object scheduler we will use later,
Figure 9 scheduler and log comopent
The ns-3 logging facility can be used to monitor or debug the progress of
simulation programs.
8
Figure 12 configuration of PHY layer of Subscribers
Now we create the network nodes.
- 1 base station.
- Two subscribers stations.
Figure 10 Nodes
We will create the WiMAX devices (netDevice). And also we define the type
of device for the Subscribe Stations and the Base Station.
Figure 11 netDevice
Adding extra features to the devices of Subscribers and define the configuration of the physical layer like modulation order.
9
Figure 15 the mobility model
Adding extra features in the base station apparatus using the Class BaseStationNetDevice.
Figure 13 configuration of PHY layer of BaseStation
We define the Internet Stack in order to implementation of TCP/IPv4- and IPv6-related components. After that we Specify IP addresses Installing the IP addresses of nodes.
Figure 14 IP addresses
We set positions nodes in our network. By define model the mobility “ConstantPositionMobility” Model. Our nodes are firm on their positions and will not move in space.
10
We set the subscriber station 0 to server and subscriber station 1 as a client.
Figure 16 server and client-1
Figure 17 server and client-2
We define IpcsClassifierRecord of each user , and An IP packet classifier is used to map incoming packets to appropriate connections based on a set of criteria. The classifier maintains a list of mapping rules which associate an IP to one of the service flows.
Figure 18 IpcsClassifierRecord user-1
11
IpcsClassifierRecord of user-2
Figure 19 IpcsClassifierRecord user-2
Finally we start we the simulator with following code
Figure 20 Running simulator
12
Results:
First we run the simulation with. /waf system and the output is,
Next we run the simulation under NetAnim environment,
We using there commands for NetAnim and we define the position of
nodes in x-axis and y-axis,
Figure 22 the position of nodes
Figure 21 simulation output
13
Finally we have the following,
Figure 23 Nodes in NetAnim
The yellow represent the Base Station and red represent Subscribers.
In following table represent the transmission between nodes with time,
Figure 24 the transmission in time
14
Annex
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wimax-module.h"
#include "ns3/internet-module.h"
#include "ns3/global-route-manager.h"
#include "ns3/ipcs-classifier-record.h"
#include "ns3/service-flow.h"
#include <iostream>
#include "ns3/netanim-module.h"
#include "ns3/net-device-container.h"
#include "ns3/netanim-module.h"
using namespace ns3;
int main (int argc, char *argv[]){
WimaxHelper::SchedulerType scheduler =WimaxHelper::SCHED_TYPE_SIMPLE;
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
NodeContainer ssNodes;
NodeContainer bsNodes;
ssNodes.Create (2);
bsNodes.Create (1);
WimaxHelper wimax;
15
NetDeviceContainer ssDevs;
NetDeviceContainer bsDevs;
ssDevs = wimax.Install(ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
bsDevs = wimax.Install(bsNodes,
WimaxHelper::DEVICE_TYPE_BASE_STATION,WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
scheduler);
Ptr<SubscriberStationNetDevice> ss[2];
for (int i = 0; i < 2; i++) {
ss[i] = ssDevs.Get (i)->
GetObject<SubscriberStationNetDevice> ();
ss[i]->SetModulationType
(WimaxPhy::MODULATION_TYPE_QAM64_34);
}
Ptr<BaseStationNetDevice> bs;
bs = bsDevs.Get (0)->
GetObject<BaseStationNetDevice> ();
InternetStackHelper stack;
stack.Install (bsNodes);
stack.Install (ssNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.7.0", "255.255.255.0");
Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
Ptr<ListPositionAllocator>
positionAlloc = CreateObject
<ListPositionAllocator> ();
positionAlloc->Add (Vector(15, 25, 0));
16
positionAlloc->Add (Vector(25, 15, 0));
positionAlloc->Add (Vector(5, 15, 0));
MobilityHelper bs_mobility;
bs_mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
bs_mobility.SetPositionAllocator(positionAlloc);
bs_mobility.Install(bsNodes);
UdpServerHelper udpServer;
ApplicationContainer serverApps;
UdpClientHelper udpClient;
ApplicationContainer clientApps;
udpServer = UdpServerHelper (22000);
serverApps = udpServer.Install (ssNodes.Get (0));
serverApps.Start (Seconds (4.0));
serverApps.Stop (Seconds (10.0));
udpClient=UdpClientHelper(SSinterfaces.GetAddress (0),22000);
udpClient.SetAttribute ("MaxPackets", UintegerValue (15000));
udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.1)));
udpClient.SetAttribute ("PacketSize", UintegerValue (512));
clientApps = udpClient.Install (ssNodes.Get (1));
clientApps.Start (Seconds (5.0));
clientApps.Stop (Seconds (9.5));
Simulator::Stop (Seconds (15.0));
IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
Ipv4Mask ("0.0.0.0"), SSinterfaces.GetAddress (0), Ipv4Mask ("255.255.255.255"), 0, 65000,
22000, 22000, 17, 1);
ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow
(ServiceFlow::SF_DIRECTION_DOWN,ServiceFlow::SF_TYPE_RTPS, DlClassifierUgs);
ss[0]->AddServiceFlow (DlServiceFlowUgs);
IpcsClassifierRecord UlClassifierUgs (SSinterfaces.GetAddress(1), Ipv4Mask ("255.255.255.255"),
Ipv4Address ("0.0.0.0"),
17
Ipv4Mask ("0.0.0.0"), 0, 65000, 22000, 22000, 17, 1);
ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP,
ServiceFlow::SF_TYPE_RTPS,UlClassifierUgs);
ss[1]->AddServiceFlow (UlServiceFlowUgs);
AnimationInterface anim("animationWiMAX.xml");
anim.SetConstantPosition (ssNodes.Get(0),1.0,3.0);
anim.SetConstantPosition (ssNodes.Get(1),4.0,6.0);
anim.SetConstantPosition (bsNodes.Get(0),7.0,8.0);
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
References 1. nsnam.org
2. ns-3 tutorial, Presenter: Tom Henderson,University of Washington,Simutools
Conference,March, 2008.
3.Youtube.com , Hitesh Choudhary channel.
4. ns-3 tutorial,GENI Eng. Conf., Nov. 2010
5. An IEEE 802.16 WiMAX Module for the NS-3 Simulator.