0% found this document useful (0 votes)
40 views

TY B.Tech Computer Engineering 2018 Course Wireless Network Sensor Lab

The document describes a lab assignment to simulate packet transmission over a 6 node network topology using the ns2 network simulator. The objective is to determine the number of packets dropped due to congestion. The methodology involves setting up the network topology in ns2 with 6 nodes and bi-directional links. Ping agents are attached to nodes to generate traffic. Code is written to constantly ping between nodes 0 and 4, and nodes 1 and 5. Running the simulation in nam and analyzing the output trace file indicates the number of dropped packets.

Uploaded by

Shubham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

TY B.Tech Computer Engineering 2018 Course Wireless Network Sensor Lab

The document describes a lab assignment to simulate packet transmission over a 6 node network topology using the ns2 network simulator. The objective is to determine the number of packets dropped due to congestion. The methodology involves setting up the network topology in ns2 with 6 nodes and bi-directional links. Ping agents are attached to nodes to generate traffic. Code is written to constantly ping between nodes 0 and 4, and nodes 1 and 5. Running the simulation in nam and analyzing the output trace file indicates the number of dropped packets.

Uploaded by

Shubham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

TY B.

Tech Computer Engineering


2018 Course
Wireless Network Sensor Lab

SUBMITTED TO:
PROF. NITIN SAKHARE

VISHWAKARMA INSTITUTE OF INFORMATION TECHNOLOGY,


PUNE

COMPUTER ENGINEERING DEPARTMENT

BY:

NAME. : SHUBHAM UBHE


G.R NO. : 21810164
ROLL NO. : 421054
CLASS : B.TECH COMP
BATCH : A
Assignment No. 1

Aim: Simulate the transmission of ping messages over a network topology consisting of 6
nodes.

Objectives: Find the number of packets dropped due to congestion.

Methodology:

1)Open ns2g2.jar by right clicking on the jar file and choosing open with java. Ns2g2.jar file
is java dependent.

2)On the editing panel, choose Scenario, and select Wired Scenario.

3)The node tab is to be selected next to place the nodes on the grid. This program requires the
user to have 6 nodes in the network. Draw 6 nodes on the network.

4)The link tab provides the user to link the nodes in the grid. Connect all the nodes.
Select Link type as duplex(bi-directional link), Queue type as Droptail(indication stating the
packets are to be dropped at destination only), capacity as 1Mbps, propagation
delay as 10ms and queue size as desirable(i.e 5, 10, etc.)

5)After finishing the topology, click on TCL tab. It generates the code and save it where
required as a .tcl file.

6)After saving, open the file in a text editor.(like nano, gedit, vi etc)

7)Now enter the following code under the agent definition header:

CODE:

//creating an agent object

set ping0 [new Agent/Ping]

//agent object node0

$ns attach-agent $n0 $ping0

set ping1 [new Agent/Ping]


//agent object node1

$ns attach-agent $n1 $ping1


set ping4 [new Agent/Ping]

//agent object node4

$ns attach-agent $n4 $ping4


set ping5 [new Agent/Ping]

//agent object node5

$ns attach-agent $n5 $ping5


//node2 and node3 acts as an intermediate nodes

//$ns connect $source $destination

$ns connect $ping0 $ping4

$ns connect $ping1 $ping5

//function to constantly ping th destination at an interval of 0.01s

proc sendPingPacket {} {

//global objects

global ns ping0 ping1


//time interval

set time 0.01


//sets now with the current time of simulation

set now [$ns now]

//when the current simulation time($now) + time($time = 0.01) occurs a ping is sent to
the destination

$ns at [expr $now + $time] "$ping0 send"

$ns at [expr $now + $time] "$ping1 send"

//pingPacket is sent

$ns at [expr $now + $time] "sendPingPacket"

}
//In the Tcl code, a procedure 'Agent/Ping recv {from rtt}' has to be defined which allows
the user to react to the ping result.

Agent/Ping instproc recv {from rtt} {

global seq

$self instvar node_

$ns at 0.01 "sendPingPacket"

$ns at 10.0 "finish"

8)Save the file.

9)To run it on terminal, tpye the command, ns *filename.tcl*

10)When the code compiles successfully, the Network Animator(nam) will


automatically open for the simulation.

11)In nam, click on the play button and simulation will be run.

12)Once the simulation ends, in the terminal, type cat out.tr | grep ^d | wc -l to know
the number of packets dropped.

13)Multiple scenarios can be generated by changing the values of bandwidth and


queue size of the links in the ns2.

Snapshots:
Output:

You might also like