Wireless Communication File
Wireless Communication File
Information Technology
Wireless Communications
(ETEC-463)
SUBMITTED BY:
Table of Contents
S.No. Aim
What is NS3?
The ns-3 simulator is a discrete-event network simulator targeted primarily for research and
educational use. The ns-3 project, started in 2006, is an open-source project developing ns-3.
ns-3 has been developed to provide an open, extensible network simulation platform, for
networking research and education. In brief, ns-3 provides models of how packet data networks
work and perform, and provides a simulation engine for users to conduct simulation experiments.
Some of the reasons to use ns-3 include to perform studies that are more difficult or not possible to
perform with real systems, to study system behavior in a highly controlled, reproducible
environment, and to learn about how networks work. Users will note that the available model set in
ns-3 focuses on modeling how Internet protocols and networks work, but ns-3 is not limited to
Internet systems; several users are using ns-3 to model non-Internet-based systems.
Many simulation tools exist for network simulation studies. Below are a few distinguishing
features of ns-3 in contrast to other tools.
ns-3 is designed as a set of libraries that can be combined together and also with other
external software libraries. While some simulation platforms provide users with a single,
integrated graphical user interface environment in which all tasks are carried out, ns-3 is
more modular in this regard. Several external animators and data analysis and visualization
tools can be used with ns-3. However, users should expect to work at the command line and
with C++ and/or Python software development tools.
ns-3 is primarily used on Linux or macOS systems, although support exists for BSD
systems and also for Windows frameworks that can build Linux code, such as Windows
Subsystem for Linux, or Cygwin. Native Windows Visual Studio is not presently supported
although a developer is working on future support. Windows users may also use a Linux
virtual machine.
ns-3 is not an officially supported software product of any company. Support for ns-3 is
done on a best-effort basis on the ns-3-users forum (ns-3-users@googlegroups.com).
Installation
ns-3 is built as a system of software libraries that work together. User programs can be written that
links with (or imports from) these libraries. User programs are written in either the C++ or Python
programming languages.
ns-3 is distributed as source code, meaning that the target system needs to have a software
development environment to build the libraries first, then build the user program. ns-3 could in
principle be distributed as pre-built libraries for selected systems, and in the future it may be
distributed that way, but at present, many users actually do their work by editing ns-3 itself, so
having the source code around to rebuild the libraries is useful. If someone would like to undertake
the job of making pre-built libraries and packages for operating systems, please contact the ns-
developers mailing list.
Downloading a release of ns-3 as a source archive
$ cd
$ mkdir workspace
$ cd workspace
$ wget https://www.nsnam.org/release/ns-allinone-3.30.tar.bz2
$ tar xjf ns-allinone-3.30.tar.bz2
Ns-allinone-3.30 is the extracted file name and you can check it’s content with the following
command.
$ cd ns-allinone-3.30
$ ls
bake constants.py ns-3.30 README
build.py netanim-3.108 pybindgen-0.20.0 util.py
Building ns-3
If users choose to install things outside of the build directory, users may issue the. Waf install
command. By default, the prefix for installation is /user/local, so. Waf install will install programs
into /user/local/bin, libraries into /user/local/lib, and headers into /user/local/include. Super user
privileges are typically needed to install to the default prefix, so the typical command would be
sudo. Waf install. When running programs with Waf, Waf will first prefer to use shared libraries in
the build directory, then will look for libraries in the library path configured in the local
environment. So when installing libraries to the system, it is good practice to check that the
intended libraries are being used.
Users may choose to install to a different prefix by passing the --prefix option at configure time,
such as:
Source Code:
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
int main (int argc, char *argv[])
{
bool verbose = true;
uint32_t nCsma = 3;
uint32_t nWifi = 3;
bool tracing = false;
CommandLine cmd;
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
cmd.AddValue ("tracing", "Enable pcap tracing", tracing);
cmd.Parse (argc,argv);
// Check for valid number of csma or wifi nodes
// 250 should be enough, otherwise IP addresses
// soon become an issue
if (nWifi > 250 || nCsma > 250)
{
std::cout << "Too many wifi or csma nodes, no more than 250 each." <<
std::endl;
return 1;
}
if (verbose)
{
LogComponentEnable ("UdpEchoClientApplication",
LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication",
LOG_LEVEL_INFO);
}
NodeContainer p2pNodes;
p2pNodes.Create (2);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);
NodeContainer wifiStaNodes;
wifiStaNodes.Create (nWifi);
NodeContainer wifiApNode = p2pNodes.Get (0);
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
phy.SetChannel (channel.Create ());
WifiHelper wifi;
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
//WifiMacHelper mac;
//HtWifiMacHelper mac = HtWifiMacHelper::Default ();
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
Ssid ssid = Ssid ("ns-3-ssid");
mac.SetType ("ns3::StaWifiMac","Ssid", SsidValue (ssid),"ActiveProbing",
BooleanValue (false));
NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, wifiStaNodes);
mac.SetType ("ns3::ApWifiMac","Ssid", SsidValue (ssid));
NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, wifiApNode);
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator","MinX",
DoubleValue (0.0),"MinY", DoubleValue (0.0),"DeltaX", DoubleValue (5.0),"DeltaY",
DoubleValue (10.0),"GridWidth", UintegerValue (3),"LayoutType", StringValue
("RowFirst"));
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel","Bounds",
RectangleValue (Rectangle (-50, 50, -50, 50)));
mobility.Install (wifiStaNodes);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (wifiApNode);
InternetStackHelper stack;
stack.Install (csmaNodes);
stack.Install (wifiApNode);
stack.Install (wifiStaNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);
address.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);
address.SetBase ("10.1.3.0", "255.255.255.0");
address.Assign (staDevices);
address.Assign (apDevices);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (wifiStaNodes.Get (nWifi -
1));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
Simulator::Stop (Seconds (10.0));
if (tracing == true)
{
pointToPoint.EnablePcapAll ("third");
phy.EnablePcap ("third", apDevices.Get (0));
csma.EnablePcap ("third", csmaDevices.Get (0), true);
}
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
Output:
EXPERIMENT – 3
Source Code:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
NS_LOG_COMPONENT_DEFINE ("WifiSimpleInfra");
Output:
EXPERIMENT - 4
Aim: To establish a Wifi simple adhoc mode.
Source Code:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
NS_LOG_COMPONENT_DEFINE ("WifiSimpleAdhoc");
Output:
EXPERIMENT – 5
Aim: To establish a Wifi to wired bridging.
Source Code:
#include "ns3/core-module.h"
#include "ns3/mobility-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/network-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/bridge-helper.h"
#include <vector>
#include <stdint.h>
#include <sstream>
#include <fstream>
Source Code:
#include "ns3/lte-helper.h"
#include "ns3/epc-helper.h"
#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/wifi-module.h"
#include "ns3/csma-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/ipv4-global-routing-helper.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/point-to-point-helper.h"
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
NS_LOG_COMPONENT_DEFINE ("WimaxSimpleExample");
Source Code:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include "ns3/olsr-helper.h"
#include "ns3/flow-monitor-module.h"
//#include "myapp.h"
#include "ns3/packet-sink-helper.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
NS_LOG_COMPONENT_DEFINE ("Lab5");
MyApp::MyApp ()
: m_socket (0),
m_peer (),
m_packetSize (0),
m_nPackets (0),
m_dataRate (0),
m_sendEvent (),
m_running (false),
m_packetsSent (0)
{
MyApp::~MyApp ()
{
m_socket = 0;
}
System Architecture
• A GSM network consists of several functional entities, whose functions and interfaces
are defined. The GSM network can be divided into following broad parts.
The Mobile Station (MS)
The Base Station Subsystem (BSS)
The Network Switching Subsystem (NSS)
The Operation Support Subsystem OSS)
• A GSM Public Land Mobile Network (PLMN) consists of at least one Service Area
controlled by a Mobile Switching Center (MSC) connected to the Public Switched
Telephone Network (PSTN)
• The architecture of a GSM Public Land Mobile Network (PLMN)
• A BTS, with its aerial and associated radio frequency components, is the actual
transmission and reception component. A Network Cell is the area of radio coverage by
one BTS. One or more BTSs are in turn managed by a BSC. A network cell cluster
covered by one or several BSSs can be managed as a Location Area (LA). All these BSSs
must however be controlled by a single MSC.
• Figure shows three LAs of 3, 4 and 4 cells respectively with a MS moving across cell
and LA boundaries where a MS moving across cell and LA boundaries. 3 LAs consisting
of 4 and 5 cells respectively are shown.