Department of Computer Science & Engineering: Lab Manual of Wireless Communication Lab ETEC 463
Department of Computer Science & Engineering: Lab Manual of Wireless Communication Lab ETEC 463
ENGINEERING
LAB MANUAL OF
WIRELESS COMMUNICATION LAB
ETEC 463
3. List of experiments
5. Projects to be allotted
8. Details of the each section of the lab along with the examples,
Aims:
H/W
Detail 24 Nos.
Intel i3/C2D Processor/2 GB RAM/500GB HDD/MB/Lan
Card/
S/W
Detail Fedora/NS3
3. LIST OF EXPERIMENTS
1. Program in NS 3 to connect WIFI TO BUS(CSMA)
The front page of the lab record prepared by the students should have a cover page as displayed
below.
Roll No.:
Semester:
Group:
PRACTICAL RECORD
PAPER CODE :
Branch :
Section/ Group :
PRACTICAL DETAILS
Experiments according to the lab syllabus prescribed by
GGSIPU
Total Marks: 40
1. Regularity: 30
2. Viva Voice: 10
NOTE: For the regularity, marks are awarded to the student out of 5 for each
experiment performed in the lab and at the end the average marks
It is taken by the concerned lecturer of the batch and by an external examiner. In this exam
student needs to perform the experiment allotted at the time of the examination, a sheet will
be given to the student in which some details asked by the examiner needs to be written and
at the last viva will be taken by the external examiner.
Total Marks: 60
2. Viva Voice: 15
3. Experiment performance: 15
4. File submitted: 10
NOTE:
Expected learning outcome: NS-3 simulation basics. Basic client server paradigm. Reading
pcap traces.
Experiment:
1. Create a simple topology of two nodes (Node1, Node2) separated by a point-to-
point link.
2. Setup a UdpClient on one Node1 and a UdpServer on Node2. Let it be of a fixed
data rate Rate1.
3. Start the client application, and measure end to end throughput whilst varying the
latency of the link.
4. Now add another client application to Node1 and a server instance to Node2. What
do you need to configure to ensure that there is no conflict?
5. Repeat step 3 with the extra client and server application instances. Show
screenshots of pcap traces which indicate that delivery is made to the appropriate
server instance.
TCP variants
Expected learning outcome: TCP internals and the difference between each of the
variants. NS-3 tracing mechanism.
Experiment:
1. Create a simple dumbbell topology, two client Node1 and Node2 on the left side of
the dumbbell and server nodes Node3 and Node4 on the right side of the dumbbell.
Let Node5 and Node6 form the bridge of the dumbbell. Use point to point links.
2. Install a TCP socket instance on Node1 that will connect to Node3.
3. Install a UDP socket instance on Node2 that will connect to Node4.
4. Start the TCP application at time 1s.
5. Start the UDP application at time 20s at rate Rate1 such that it clogs half the
dumbbell bridge's link capacity.
6. Increase the UDP application's rate at time 30s to rate Rate2 such that it clogs the
whole of the dumbbell bridge's capacity.
7. Use the ns-3 tracing mechanism to record changes in congestion window size of the
TCP instance over time. Use gnuplot/matplotlib to visualise plots of cwnd vs time.
8. Mark points of fast recovery and slow start in the graphs.
9. Perform the above experiment for TCP variants Tahoe, Reno and New Reno, all of
which are available with ns-3.
Expected learning outcome: Queues, packet drops and their effect on congestion window
size.
Experiment:
1. As in previous exercise, Create a simple dumbbell topology, two client Node1 and
Node2 on the left side of the dumbbell and server nodes Node3 and Node4 on the
right side of the dumbbell. Let Node5 and Node6 form the bridge of the dumbbell.
Use point to point links.
2. Add drop tail queues of size QueueSize5 and QueueSize6 to Node5 and Node6,
respectively.
3. Install a TCP socket instance on Node1 that will connect to Node3.
4. Install a TCP socket instance on Node2 that will connect to Node3.
5. Install a TCP socket instance on Node2 that will connect to Node4.
6. Start Node1--Node3 flow at time 1s, then measure it's throughput. How long does it
take to fill link's entire capacity?
7. Start Node2--Node3 and Node2--Node4 flows at time 15s, measure their
throughput.
8. Measure packet loss and cwnd size, and plot graphs throughput/time, cwnd/time
and packet loss/time for each of the flows.
9. Plot graph throughput/cwnd and packet loss/cwnd for the first flow. Is there an
optimal value for cwnd?
10. Vary QueueSize5 and QueueSize6. Which one has immediate effect on cwnd size
of the first flow? Explain why.
Routing (Optimised Link State Routing)
Expected learning outcome: What are MANETs and how they work. OLSR basics.
Routing issues associated with MANETs.
Experiment:
1. Create a wireless mobile ad-hoc network with three nodes Node1, Node2 and
Node3. Install the OLSR routing protocol on these nodes.
2. Place them such that Node1 and Node3 are just out of reach of each other.
3. Create a UDP client on Node1 and the corresponding server on Node3.
4. Schedule Node1 to begin sending packets to Node3 at time 1s.
5. Verify whether Node1 is able to send packets to Node3.
6. Make Node2 move between Node1 and Node3 such that Node2 is visible to both A
and C. This should happen at time 20s. Ensure that Node2 stays in that position for
another 15s.
7. Verify whether Node1 is able to send packets to Node3.
8. At time 35s, move Node2 out of the region between Node1 and Node3 such that it
is out of each other's transmission ranges again.
9. Verify whether Node1 is able to send packets to Node3.
10. To verify whether data transmissions occur in the above scenarios, use either the
tracing mechanism or a RecvCallback() for Node3's socket.
11. Plot the number of bytes received versus time at Node3.
12. Show the pcap traces at Node 2's Wifi interface, and indicate the correlation
between Node2's packet reception timeline and Node2's mobility.
Wifi RTS/CTS
Expected learning outcome: How 802.11 works with and without RTS/CTS. An insight
into why its hard to setup efficient wireless networks.
Experiment:
1. Setup a 5x5 wireless adhoc network with a grid. You may use
examples/wireless/wifi-simple-adhoc-grid.cc as a base.
2. Install the OLSR routing protocol.
3. Setup three UDP traffic flows, one along each diagonal and one along the middle
(at high rates of transmission).
4. Setup the ns-3 flow monitor for each of these flows.
5. Now schedule each of the flows at times 1s, 1.5s, and 2s.
6. Now using the flow monitor, observe the throughput of each of the UDP flows.
Furthermore, use the tracing mechanism to monitor the number of packet
collisions/drops at intermediary nodes. Around which nodes are most of the
collisions/drops happening?
7. Now repeat the experiment with RTS/CTS enabled on the wifi devices.
8. Show the difference in throughput and packet drops if any.
Wifi Channels
Expected learning outcome: How Radio channel models affect transmission. An insight
into why its important to correctly model the channel.
Experiment:
1. Setup a 2-nodes wireless adhoc network. Place the nodes at a fixed distance in a 3d
scenario.
2. Install all the relevant network stacks, up to and including UDP.
3. Setup a CBR transmission between the nodes, one acting as a server and one as a
client. Take the iperf[1] behaviour as an example.
4. Setup counters and outputs for packets sent and received.
5. Schedule the simulation to run for enough time to obtain statistically relevant
results (suggestion: analyze some test results and reduce the simulation time
accordingly).
6. Repeat the simulation varying the distance between the nodes from a minimum of
1meter to the point where the nodes can't transmit/receive anymore.
7. Repeat the above varying the channel models and the transmission/receive
parameters like node's position above the ground, transmission power, etc.
8. Show the differences between the various channel models, and comment them.
Identify the channel model that is more appropriate for each case (indoor, outdoor,
LoS, NLoS, etc.).
1. WIFI TO BUS(CSMA) CONNECTION
// Default Network Topology
//
// Number of wifi or csma nodes can be increased up to 250
// |
// Rank 0 | Rank 1
// -------------------------|----------------------------
// Wifi 10.1.3.0
// AP
// * * * *
// | | | | 10.1.1.0
// n5 n6 n7 n0 -------------- n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN 10.1.2.0
#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);
WifiHelper wifi;
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
WifiMacHelper mac;
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;
ApplicationContainer clientApps =
echoClient.Install (wifiStaNodes.Get (nWifi - 1));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
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;
}
2. WIFI SIMPLE INFRASTUCTURE MODE
This script configures two nodes on an 802.11b physical layer, with 802.11b NICs in
infrastructure mode, and by default, the station sends one packet of 1000 (application) bytes to
the access point. The physical layer is configured to receive at a fixed RSS (regardless of the
distance and transmit power); therefore, changing position of the nodes has no effect.
There are a number of command-line options available to control the default behavior. The list
of available command-line options can be listed with the following command:
./waf --run "wifi-simple-infra --help" For instance, for this configuration, the physical layer
will stop successfully receiving packets when rss drops below -97 dBm. To see this effect, try
running:
Note that all ns-3 attributes (not just the ones exposed in the below script) can be changed at
command line; see the documentation.
This script can also be helpful to put the Wifi layer into verbose logging mode; this command
will turn on all wifi logging:
./waf --run "wifi-simple-infra --verbose=1"
When you are done, you will notice two pcap trace files in your directory. If you have tcpdump
installed, you can try this:
tcpdump -r wifi-simple-infra-0-0.pcap -nn -tt
#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");
CommandLine cmd;
NodeContainer c;
c.Create (2);
// The below set of helpers will help us to put together the wifi NICs we want
WifiHelper wifi;
if (verbose)
{
wifi.EnableLogComponents (); // Turn on all Wifi logging
}
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
// The below FixedRssLossModel will cause the rss to be fixed regardless
// of the distance between the two stations, and the transmit power
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss));
wifiPhy.SetChannel (wifiChannel.Create ());
InternetStackHelper internet;
internet.Install (c);
Ipv4AddressHelper ipv4;
NS_LOG_INFO ("Assign IP Addresses.");
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer i = ipv4.Assign (devices);
// Tracing
wifiPhy.EnablePcap ("wifi-simple-infra", devices);
return 0;
}
3. WIFI SIMPLE ADHOC MODE
This script configures two nodes on an 802.11b physical layer, with 802.11b NICs in adhoc
mode, and by default, sends one packet of 1000 (application) bytes to the other node. The
physical layer is configured to receive at a fixed RSS (regardless of the distance and transmit
power); therefore, changing position of the nodes has no effect.
There are a number of command-line options available to control the default behavior. The list
of available command-line options can be listed with the following command: ./waf --run "wifi-
simple-adhoc --help" For instance, for this configuration, the physical layer will stop
successfully receiving packets when rss drops below -97 dBm To see this effect, try running:
Note that all ns-3 attributes (not just the ones exposed in the below script) can be changed at
ommand line; see the documentation.
This script can also be helpful to put the Wifi layer into verbose logging mode; this command
will turn on all wifi logging:
When you are done, you will notice two pcap trace files in your directory. If you have tcpdump
installed, you can try this:
tcpdump -r wifi-simple-adhoc-0-0.pcap -nn -tt
#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");
void ReceivePacket (Ptr<Socket> socket)
{
while (socket->Recv ())
{
NS_LOG_UNCOND ("Received one packet!");
}
}
CommandLine cmd;
NodeContainer c;
c.Create (2);
// The below set of helpers will help us to put together the wifi NICs we want
WifiHelper wifi;
if (verbose)
{
wifi.EnableLogComponents (); // Turn on all Wifi logging
}
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
// The below FixedRssLossModel will cause the rss to be fixed regardless
// of the distance between the two stations, and the transmit power
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss));
wifiPhy.SetChannel (wifiChannel.Create ());
InternetStackHelper internet;
internet.Install (c);
Ipv4AddressHelper ipv4;
NS_LOG_INFO ("Assign IP Addresses.");
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer i = ipv4.Assign (devices);
// Tracing
wifiPhy.EnablePcap ("wifi-simple-adhoc", devices);
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
4. WIFI TO WIRED BRIDGING
Default network topology includes some number of AP nodes specified by the variable nWifis
(defaults to two). Off of each AP node, there are some number of STA nodes specified by the
variable nStas (defaults to two). Each AP talks to its associated STA nodes. There are bridge
net devices on each AP node that bridge the whole thing into one network.
//
// +-----+ +-----+ +-----+ +-----+
// | STA | | STA | | STA | | STA |
// +-----+ +-----+ +-----+ +-----+
// 192.168.0.2 192.168.0.3 192.168.0.5 192.168.0.6
// -------- -------- -------- --------
// WIFI STA WIFI STA WIFI STA WIFI STA
// -------- -------- -------- --------
// ((*)) ((*)) | ((*)) ((*))
// |
// ((*)) | ((*))
// ------- -------
// WIFI AP CSMA ========= CSMA WIFI AP
// ------- ---- ---- -------
// ############## ##############
// BRIDGE BRIDGE
// ############## ##############
// 192.168.0.1 192.168.0.4
// +---------+ +---------+
// | AP Node | | AP Node |
// +---------+ +---------+
//
#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>
CommandLine cmd;
cmd.AddValue ("nWifis", "Number of wifi networks", nWifis);
cmd.AddValue ("nStas", "Number of stations per wifi network", nStas);
cmd.AddValue ("SendIp", "Send Ipv4 or raw packets", sendIp);
cmd.AddValue ("writeMobility", "Write mobility trace", writeMobility);
cmd.Parse (argc, argv);
NodeContainer backboneNodes;
NetDeviceContainer backboneDevices;
Ipv4InterfaceContainer backboneInterfaces;
std::vector<NodeContainer> staNodes;
std::vector<NetDeviceContainer> staDevices;
std::vector<NetDeviceContainer> apDevices;
std::vector<Ipv4InterfaceContainer> staInterfaces;
std::vector<Ipv4InterfaceContainer> apInterfaces;
InternetStackHelper stack;
CsmaHelper csma;
Ipv4AddressHelper ip;
ip.SetBase ("192.168.0.0", "255.255.255.0");
backboneNodes.Create (nWifis);
stack.Install (backboneNodes);
NodeContainer sta;
NetDeviceContainer staDev;
NetDeviceContainer apDev;
Ipv4InterfaceContainer staInterface;
Ipv4InterfaceContainer apInterface;
MobilityHelper mobility;
BridgeHelper bridge;
WifiHelper wifi;
WifiMacHelper wifiMac;
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
sta.Create (nStas);
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (wifiX),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (5.0),
"GridWidth", UintegerValue (1),
"LayoutType", StringValue ("RowFirst"));
NetDeviceContainer bridgeDev;
bridgeDev = bridge.Install (backboneNodes.Get (i), NetDeviceContainer (apDev,
backboneDevices.Get (i)));
wifiX += 20.0;
}
Address dest;
std::string protocol;
if (sendIp)
{
dest = InetSocketAddress (staInterfaces[1].GetAddress (1), 1025);
protocol = "ns3::UdpSocketFactory";
}
else
{
PacketSocketAddress tmp;
tmp.SetSingleDevice (staDevices[0].Get (0)->GetIfIndex ());
tmp.SetPhysicalAddress (staDevices[1].Get (0)->GetAddress ());
tmp.SetProtocol (0x807);
dest = tmp;
protocol = "ns3::PacketSocketFactory";
}
if (writeMobility)
{
AsciiTraceHelper ascii;
MobilityHelper::EnableAsciiAll (ascii.CreateFileStream ("wifi-wired-bridging.mob"));
}
#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");
CommandLine cmd;
cmd.AddValue ("scheduler", "type of scheduler to use with the network devices", schedType);
cmd.AddValue ("duration", "duration of the simulation in seconds", duration);
cmd.AddValue ("verbose", "turn on all WimaxNetDevice log components", verbose);
cmd.Parse (argc, argv);
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
//LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
//LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer ssNodes;
NodeContainer bsNodes;
ssNodes.Create (2);
bsNodes.Create (1);
uint32_t nCsma = 3;
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);
NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, ssNodes);
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, wifiApNode);
MobilityHelper mobility1;
mobility1.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"));
mobility1.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility1.Install (wifiApNode);
(wifiApNode.Get(0) -> GetObject<ConstantPositionMobilityModel>()) ->
SetPosition(Vector(100.0, 501.0, 0.0));
InternetStackHelper stack1;
stack1.Install (csmaNodes);
stack1.Install (wifiApNode);
stack1.Install (ssNodes);
Ipv4AddressHelper address1;
ApplicationContainer clientApps1 =
echoClient.Install (ssNodes.Get (0));
clientApps1.Start (Seconds (2.0));
clientApps1.Stop (Seconds (duration+0.1));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
//pointToPoint.EnablePcapAll ("third");
phy.EnablePcap ("third", apDevices.Get (0));
//csma.EnablePcap ("third", csmaDevices.Get (0), true);
lteHelper->SetEpcHelper (epcHelper);
lteHelper->SetSchedulerType("ns3::RrFfMacScheduler");
lteHelper->SetAttribute ("PathlossModel",
StringValue ("ns3::FriisPropagationLossModel"));
pgw = epcHelper->GetPgwNode ();
remoteHostContainer.Create (1);
remoteHost = remoteHostContainer.Get (0);
internet.Install (remoteHostContainer);
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc;
positionAlloc = CreateObject<ListPositionAllocator> ();
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
mobility.Install(ssNodes.Get(0));
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (NodeContainer(bsNodes.Get(0),ssNodes.Get(1)));
Ipv4InterfaceContainer iueIpIface;
iueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ssDevs));
UdpServerHelper udpServer;
ApplicationContainer serverApps;
UdpClientHelper udpClient;
ApplicationContainer clientApps;
udpServer = UdpServerHelper (100);
Simulator::Run ();
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
return 0;
}
6. CREATING A SIMPLE WIFI ADHOC GRID
Flow 1: 0->24
Flow 2: 20->4
Flow 3: 10->4
STEPS:
1. Setup a 5x5 wireless adhoc network with a grid. You may use examples/wireless/wifi-
simple-adhoc-grid.cc as a base.
3. Setup three UDP traffic flows, one along each diagonal and one along the middle (at high
rates of transmission).
5. Now schedule each of the flows at times 1s, 1.5s, and 2s.
6. Now using the flow monitor, observe the throughput of each of the UDP flows.
Furthermore, use the tracing mechanism to monitor the number of packet collisions/drops at
intermediary nodes. Around which nodes are most of the collisions/drops happening?
7. Now repeat the experiment with RTS/CTS enabled on the wifi devices.
#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 <iostream>
#include <fstream>
#include <vector>
#include <string>
NS_LOG_COMPONENT_DEFINE ("Lab5");
void
MacTxDrop(Ptr<const Packet> p)
{
NS_LOG_INFO("Packet Drop");
MacTxDropCount++;
}
void
PrintDrop()
{
std::cout << Simulator::Now().GetSeconds() << "\t" << MacTxDropCount << "\t"<<
PhyTxDropCount << "\t" << PhyRxDropCount << "\n";
Simulator::Schedule(Seconds(5.0), &PrintDrop);
}
void
PhyTxDrop(Ptr<const Packet> p)
{
NS_LOG_INFO("Packet Drop");
PhyTxDropCount++;
}
void
PhyRxDrop(Ptr<const Packet> p)
{
NS_LOG_INFO("Packet Drop");
PhyRxDropCount++;
}
int main (int argc, char *argv[])
{
std::string phyMode ("DsssRate1Mbps");
double distance = 500; // m
uint32_t numNodes = 25; // by default, 5x5
double interval = 0.001; // seconds
uint32_t packetSize = 600; // bytes
uint32_t numPackets = 10000000;
std::string rtslimit = "1500";
CommandLine cmd;
NodeContainer c;
c.Create (numNodes);
// The below set of helpers will help us to put together the wifi NICs we want
WifiHelper wifi;
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
wifiPhy.SetChannel (wifiChannel.Create ());
// Enable OLSR
OlsrHelper olsr;
Ipv4ListRoutingHelper list;
list.Add (olsr, 10);
InternetStackHelper internet;
internet.SetRoutingHelper (list); // has effect on the next Install ()
internet.Install (c);
Ipv4AddressHelper ipv4;
NS_LOG_INFO ("Assign IP Addresses.");
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer ifcont = ipv4.Assign (devices);
// Create Apps
// Trace Collisions
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx
Drop", MakeCallback(&MacTxDrop));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxD
rop", MakeCallback(&PhyRxDrop));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxD
rop", MakeCallback(&PhyTxDrop));
Simulator::Schedule(Seconds(5.0), &PrintDrop);
PrintDrop();
Simulator::Destroy ();
return 0;
}
7. To Study Architecture of GSM.
System Architecture
ME = Mobile Equipment
BTS = Base Receiving Station
BSC = Base Station Controller
MSC = Mobile Switching Center
VLR = Visitor Location Register
OMC = Operation and Maintenance Center
AuC = Authentication Center
HLR = Home Location Register
EIR = Equipment Identity Register
SMSC = Short Message Service
Centre
• A MSC is also through a Gateway MSC (GMSC) connected to other MSCs and to the
Public Switched Telephone Network (PSTN) with the Integrated Services Digital
Network (ISDN) option. The Inter-Working Function (IWF) of GMSC connects the
circuit switched data paths of a GSM network with the PSTN/ISDN. A GMSC is
usually integrated in an MSC.
• Basic GSM network components,