building complex topology using ns3

23
Building Topology [Part-2]

Upload: rahul-hada

Post on 16-Jul-2015

859 views

Category:

Engineering


18 download

TRANSCRIPT

Page 1: Building Complex Topology using NS3

Building Topology[Part-2]

Page 2: Building Complex Topology using NS3

Topology

STA-1

STA-2

STA-3

AP

CSMA

P2P

WIFI

P1 P2

C1 C2 C3 C4

CLIENT

SERVERUdpEchoServerHelper

UdpEchoCientHelper

Page 3: Building Complex Topology using NS3

RoadMap

● Writing Code● Detail Understanding

– Logging

– Tracing

– Attributes

Page 4: Building Complex Topology using NS3

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

Page 5: Building Complex Topology using NS3

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

Page 6: Building Complex Topology using NS3

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"

Page 7: Building Complex Topology using NS3

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

Page 8: Building Complex Topology using NS3

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

Page 9: Building Complex Topology using NS3

Configure WIFI NetDevice

`

NetDevice

PHY

MAC<attach>

YansWifiPhyHelper

NqosWifiMacHelper

YansWifiChannelHelper

WifiHelper

Node

Page 10: Building Complex Topology using NS3

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

Page 11: Building Complex Topology using NS3

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

Page 12: Building Complex Topology using NS3

Mobility

● It is used to track and maintain the – Current Cartesian position

– Speed of an object

– Placement of Node

– Setup Mobility Model

Page 13: Building Complex Topology using NS3

Mobility[Cartesian Position]

Source:http://en.wikipedia.org/wiki/Cartesian_coordinate_system

Page 14: Building Complex Topology using NS3

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.

Page 15: Building Complex Topology using NS3

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

Page 16: Building Complex Topology using NS3

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

Page 17: Building Complex Topology using NS3

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

Page 18: Building Complex Topology using NS3

Internet Stack & Ipv4Address

● Now its time to install Protocol Stack– InternetStackHelper

● Install()

● Assign IP address to the NetDevice– Ipv4InterfaceContainer

● Assign()

Page 19: Building Complex Topology using NS3

Application

STA-1

STA-2

STA-3

AP

CSMA

P2P

WIFI

P1 P2

C1 C2 C3 C4

CLIENT

SERVERUdpEchoServerHelper

UdpEchoCientHelper

Page 20: Building Complex Topology using NS3

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)

Page 21: Building Complex Topology using NS3

Start Simulation

Simulation::Run();Simulation::Destroy();return 0;

Page 22: Building Complex Topology using NS3

● Modify the Mobility Pattern using

– RandomWalk2dMobilityModel● Distance- Change current direction and

speed after moving for this distance.● Speed – speed of node● Bounds – Area

Page 23: Building Complex Topology using NS3

To be Continued...