Practical 5
Practical 5
5 ROLL NO: 27
THEORY:
1. A Wireless network is a type of the computer network that uses the wireless
connections for connecting network nodes for data transfer.
2. Wireless network topology shows how the computers connect each other when
there is no physical connection. The computers communicate each using the
wireless devices.
3. The wireless networks are very useful, inexpensive, popular and widely used.
They are easy setup and do not require the cables installation.
4. Stations:
a. All components that can connect into a wireless medium in a network are
referred to as stations.
b. All stations are equipped with wireless network interface controllers.
Wireless stations fall into two categories: wireless access points (WAPs),
and clients.
5. Access Point(AP):
a. In computer networking, a wireless access point (WAP), or more
generally just access point (AP), is a networking hardware device that
allows other Wi-Fi devices to connect to a wired network.
b. Wireless devices communicate with the wired LAN through a base station
known as an access point (AP) or wireless access point (WAP).
6. Classes Used In Code:
a. Following different classes are used in code:
i. Node Class:
1. In ns-3 the basic computing device abstraction is called the
node. This abstraction is represented in C++ by the class Node.
2. This abstraction is represented in C++ by the class Node.
ATHARVA KALE PRACTICAL NO.5 ROLL NO: 27
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/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/ssid.h"
#include "ns3/netanim-module.h"
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
ATHARVA KALE PRACTICAL NO.5 ROLL NO: 27
int
main (int argc, char *argv[])
{
bool verbose = true;
uint32_t nCsma = 3;
uint32_t nWifi = 3;
bool tracing = false;
cmd.Parse (argc,argv);
if (verbose)
{
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
ATHARVA KALE PRACTICAL NO.5 ROLL NO: 27
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),
ATHARVA KALE PRACTICAL NO.5 ROLL NO: 27
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
mobility.Install (wifiStaNodes);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (wifiApNode);
AnimationInterface::SetConstantPosition (p2pNodes.Get (1), 10, 30);
AnimationInterface::SetConstantPosition (csmaNodes.Get (1), 10, 33);
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);
}
AnimationInterface anim ("wireless-animation.xml");
for (uint32_t i = 0; i < wifiStaNodes.GetN (); ++i)
{
anim.UpdateNodeDescription (wifiStaNodes.Get (i), "STA"); // Optional
ATHARVA KALE PRACTICAL NO.5 ROLL NO: 27
OUTPUT:
o ./waf output:
o Python Visualizer:
ATHARVA KALE PRACTICAL NO.5 ROLL NO: 27
o NetAnim Output:
ATHARVA KALE PRACTICAL NO.5 ROLL NO: 27
o Wireshark
CONCLUSION:
Hence we successfully simulated Wireless Network Topology.