building topology in ns3

15
Building Topology [Part-01]

Upload: rahul-hada

Post on 16-Jul-2015

615 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: Building Topology in NS3

Building Topology[Part-01]

Page 2: Building Topology in NS3

Point-To -Point Topology<Reading Code>

Node-1 Node-2

Page 3: Building Topology in NS3

Flow ChartCreate Node

Attach NetDeive &

Channel[NODES]

Install Protocol Stack

[NODES]

Assign Ip Address

[NETDEVICE]

Install Application

[NODES]

Page 4: Building Topology in NS3

Node

● Use to create NODE– To create NODE Object we use Node class with

TEMPLATE function CreateObject<> & Reference Counting Smart Pointer Ptr<>

Ptr<Node> n= CreateObject<Node>();

● Use of Helper Class– To create Group of NODE we use NodeContainer

NodeContainer nc;

nc.Create(3);

Page 5: Building Topology in NS3

Channel & NetDevice

● It is a logical path over which information flows– To create Channel we use following classes:-

● WifiChannel● CsmaChannel● PointToPointChannel● Etc...

– To create NetDevice we use following classes:-● WifiNetDevice● CsmaNetDevice● PointToPointNetDevice● Etc...

Page 6: Building Topology in NS3

Channel & NetDevice

● Use of Helper Classes– We can use Helper Classes:-

● WifiHelper● CsmaHelper● PointToPointHelper

● Now ATTACH NetDevice & Channel– NetDeviceContainer device

– device=pointTopoint.Install(NodeContainer);● At this point we are done with :-

– NODE

– NetDevice

– Channel

Coupling of NetDevice with Channel

NetDevice-0 NetDevice-1Point-to-pointChannel

Node-0 Node-1

Page 7: Building Topology in NS3

Internet Stack & Ipv4Address● Now its time to install Protocol Stack

– Helper Class● InternetStackHelper i

● Now INSTALL protocol stack on Nodes– i.install(NodeContainer);

● Ipv4Address– Now associate the devices on our node with IP addresses

● Ipv4AddressHelper iaddr;● Iaddr.SetBase(“10.1.1.0”,”255.255.255.0”);

– Now assign this IP address to Nodes using Ipv4Interface object● Ipv4InterfaceContainer iinter = iaddr.Assign(device)

NetDevice-0 NetDevice-1Point-to-pointChannel

Node-0 Node-1

Internet Stack Internet Stack10.1.1.1/24 10.1.1.2/24

Page 8: Building Topology in NS3

Application

● Application abstract class– UdpEchoServerApplication – server

application

– UdpEchoClientApplication -client application

● We use Helper classes– UdpEchoServerHelper

– UdpEchoClientHelper

Page 9: Building Topology in NS3

Server Application

UdpEchoServerHelper server(9);– Set up a UDP echo server application on one of the node

– Require the port number as a parameter to the constructorApplicationContainer serApp;

serApp.Install(nodes.Get(1));

servApp.Start(Seconds(1.0));

servApp.Stop(Seconds(10.0));

– Install server application on Node-1

NetDevice-0 NetDevice-1Point-to-pointChannel

Node-0 Node-1

Internet Stack Internet Stack10.1.1.1/24 10.1.1.2/24

Server App

NetDevice-0 NetDevice-1Point-to-pointChannel

Node-0 Node-1

Internet Stack Internet Stack10.1.1.1/24

Server App

Page 10: Building Topology in NS3

Client Application

UdpEchoClientHelper client(i.GetAddress(1),9);

● Pass parameter (to helper) to set the Remote Address and Remote port for for client to connect.

ApplicationContainer clientApp =client.Install(nodes.Get(0));

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(9.0));

NetDevice-0 NetDevice-1Point-to-pointChannel

Node-0 Node-1

Internet Stack Internet Stack10.1.1.1/24

Server AppClient App

10.1.1.2/24

Page 11: Building Topology in NS3

Start Simulation

Simulation::Run();

Simulation::Destroy();

return 0;

NetDevice-0 NetDevice-1Point-to-pointChannel

Node-0 Node-1

Internet Stack Internet Stack

Server AppClient App

Page 12: Building Topology in NS3

Running Example

● Copy program from example to scratch folder

● And run using following commands●./waf --run /scratch/first

Page 13: Building Topology in NS3

Simple Modification in Topology CODE

● Change following values:-● NetDevice

– DataRate

– Delay

● UDP packet– MaxPacket

– Interval

– Packet Size

Page 14: Building Topology in NS3

● What is the use of Helper Classes ?● Why we use Container class ?● Effect of Packet Size on Rx time @Server ?

Page 15: Building Topology in NS3

To be Continued...