building complex topology using ns3
TRANSCRIPT
Building Topology[Part-2]
Topology
STA-1
STA-2
STA-3
AP
CSMA
P2P
WIFI
P1 P2
C1 C2 C3 C4
CLIENT
SERVERUdpEchoServerHelper
UdpEchoCientHelper
RoadMap
● Writing Code● Detail Understanding
– Logging
– Tracing
– Attributes
Flow Chart
Point To Point
CSMA
WIFI Station
WIFI AP
NODE Container
Point To Point
CSMA
WIFI Station
WIFI AP
NetDe`vice Container
Point To Point
CSMA
WIFI Station
WIFI AP
SetAttributes NetDevice
Point To Point
CSMA
Attach NetDevice to
PHY &CHANNEL
WIFI Station
WIFI AP
Configure PHY & MAC
WIFI Station
WIFI AP
Attach NetDevice to
PHY &CHANNEL
Point To Point
CSMA
WIFI Station
WIFI AP
Install ProtocolStack
Point To Point
CSMA
WIFI Station
WIFI AP
Assign IP Address
Install Application
Topology Description
● Channels & Net Device– Wireless
– Point to Point
– CSMA
● Node Container– Access Point Node
– Station Nodes
– Point to Point Nodes
– CSMA Nodes
● Node P1 & P2 having two Net Device of different types
Classes
● NodeContainer● PointToPointHelper● CsmaHelper● YansWifiChannelHelper● YansWifiPhyHelper● WifiHelper● NetDeviceContainer● MobilityHelper● InternetStackHelper● Ipv4AddressHelper● Ipv4InterfaceContainer● UdpEchoServerHelper● UdpEchoClientHelper● ApplicationContainer
`
Include
#include "ns3/core-module.h"#include "ns3/network-module.h"#include "ns3/csma-module.h"#include "ns3/internet-module.h"#include "ns3/point-to-point-module.h"#include "ns3/applications-module.h"#include "ns3/ipv4-global-routing-helper.h"
NODE
● We are having four different types of nodes.● Create Four Different NodeContainer
– Point to Point
– Station Nodes
– Access Point
– CSMA NodeContainer n1,n2;n1.Create(3);[...]N2.Create(1);n2.Add(n1.Get(0));
void Create(uint32_t n);
Add()- used to add node in a node container
Create() - used to create node/s
NetDevice and Channel
● Three different NetDevice and Channel:-– PointToPointHelper – NetDevice & Channel
– CsmaHelper – NetDevice & Channel
– YansWifiChannelHelper – Channel
– YansWifiPhyHelper – PHY
– WifiHelper – NetDevice
We use Install()method to attach NetDevice with Node
It will return an object to NetDeviceContainer
Configure WIFI NetDevice
`
NetDevice
PHY
MAC<attach>
YansWifiPhyHelper
NqosWifiMacHelper
YansWifiChannelHelper
WifiHelper
Node
Configure WIFI NetDevice
● WifiChannel & WifiPhy abstract class – YansWifiChannel
● We use Helper [YansWifiChannelHelper]● Set Channel related attributes
– [channel switch delay, energy of received signal,etc]
– YansWifiPhy ● We use Helper [YansWifiPhyHelper]● Set PHY Layer related attributes
– [propogation delay] Set CHANNEL to PHY
void SetChannel(Ptr<YansWifiChannel>)-
Class YansWifiPhy
Configure MAC● WifiMac abstract class
– List of MAC Types● AdhocWifiMac – Infrastructure less network● ApWifiMac – Access point Node MAC● StaWifiMac – Station Node MAC● Etc.
– We use Helper Class● NqosWifiMacHelper or WifiMacHelper
– Set the appropiate MAC from the list and Set Attributes● void SetType(T,A,V....);● T- Type of MAC● A- Name of Attribute● V –Value of Attribute
Mobility
● It is used to track and maintain the – Current Cartesian position
– Speed of an object
– Placement of Node
– Setup Mobility Model
Mobility[Cartesian Position]
Source:http://en.wikipedia.org/wiki/Cartesian_coordinate_system
Mobility
● Assign Mobility to WIFI Nodes– List of Mobility Model
● ConstantAccelerationMobilityModel ● ConstantPositionMobilityModel ● ConstantVelocityMobilityModel● RandomDirection2dMobilityModel● RandomWalk2dMobilityModel● Etc
– List of Allocator Model (placement of Node)● RandomDiscPositionAllocator● RandomRectanglePositionAllocator● GridPositionAllocator● Etc.
Mobility Model
● RandomWalk2dMobilityModel– 2D random walk mobility model
– Each instance moves with a speed and direction choosen at random
– Nodes moves in Boundaries specified by Rectangle– Rectangle(double xMin,double xMax,double yMin,double yMax)
x-axis
y-ax
is
xMin xMax
yMin
yMax
Allocator Model
● GridPositionAllocator– Allocate position on a rectangular 2D grid
– List of Attributes● MinX● MinY● DeltaX● DeltaY● GridWidth● LayoutType
– ROW_FIRST– COLUMN_FIRST
1 2 3
4
(MinX,MinY) DeltaX
DeltaY GridWidth
x-axis
y-ax
is
Mobility
● We use Helper Class– MobilityHelper
● SetMobilityModel()-Set Mobility Model● SetPositionAllocator() - Set Position Allocator
– Install the mobility on Nodes
– Mobility Model [Access Point & CSMA Nodes]● ConstantPositionMobilityModel
Internet Stack & Ipv4Address
● Now its time to install Protocol Stack– InternetStackHelper
● Install()
● Assign IP address to the NetDevice– Ipv4InterfaceContainer
● Assign()
Application
STA-1
STA-2
STA-3
AP
CSMA
P2P
WIFI
P1 P2
C1 C2 C3 C4
CLIENT
SERVERUdpEchoServerHelper
UdpEchoCientHelper
Animation
● AnimationInterface – Set Methods for Nodes
● Description – SetNodeDescription(NodeContainer,”AP”)● Color – SetNodeColor(NodeContainer , R,G,B)● Position – SetConstantPosition(Node,X,Y)● Etc.
– Add Background Image ● SetBackgroundImage(..,..,..,);
vodi EnablePacketMetadata(boolean value)
Start Simulation
Simulation::Run();Simulation::Destroy();return 0;
● Modify the Mobility Pattern using
– RandomWalk2dMobilityModel● Distance- Change current direction and
speed after moving for this distance.● Speed – speed of node● Bounds – Area
To be Continued...