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

Program 3

The document describes an experiment to implement ping messages over a 6 node network topology using the Network Simulator 2 (NS2) and analyze packet drops due to congestion. Node 0 and Node 2 are configured to ping Node 5 and Node 3 respectively at regular intervals, generating traffic in the network. Successive ping messages cause packet drops as nodes experience congestion. The output includes ping responses, a trace log file recording packet drops, and the number of dropped packets analyzed.

Uploaded by

Prathiksha Kulal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Program 3

The document describes an experiment to implement ping messages over a 6 node network topology using the Network Simulator 2 (NS2) and analyze packet drops due to congestion. Node 0 and Node 2 are configured to ping Node 5 and Node 3 respectively at regular intervals, generating traffic in the network. Successive ping messages cause packet drops as nodes experience congestion. The output includes ping responses, a trace log file recording packet drops, and the number of dropped packets analyzed.

Uploaded by

Prathiksha Kulal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

PROGRAM 3

TITLE
Implement transmission of ping messages/trace route over a network topology consisting of 6
nodes and find the number of packets dropped due to congestion.
AIM
To understand the working principle of ICMP Ping message and deeper insights into the
congestion scenario caused by successive ping message among nodes.
DESCRIPTION
Ping is the one of popular mechanism for internet control messaging protocol. Ping
message is used for determining the reachability and aliveness of the remote/ destination
machine in a network. In this experiment, network simulator2 is used for creating network
topology consisting of 6 nodes interconnected by point to point duplex link. Nodes on the
created topology issues ping command to the other nodes in the network and generate traffic.
Node upon receiving the ping message will respond by sending a ping reply message to the
requesting node and generate return traffic in the network. Successive ping message by
different nodes generates huge traffic on the network and causes packet drop.
INPUT
(a) ping message from nodes.
(b) Analyzing the out.tr trace log file and nam file
of packet drop.
EXPECTED OUTPUT
(a) Ping response from corresponding nodes.
(b) generate the out.tr trace log file
(c) number of packet drop
Design

#===================================
# Simulation parameters setup
#===================================
set val(stop) 10.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]

#Open the NS trace file


set tracefile [open exp2.tr w]
$ns trace-all $tracefile

#Open the NAM trace file


set namfile [open exp2.nam w]
$ns namtrace-all $namfile

#===================================
# Nodes Definition
#===================================
#Create 6 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

#===================================
# Links Definition
#===================================
#Createlinks between nodes
$ns duplex-link $n0 $n4 1005.0Mb 1ms DropTail
$ns queue-limit $n0 $n4 5
$ns duplex-link $n1 $n4 50.0Mb 1ms DropTail
$ns queue-limit $n1 $n4 0
$ns duplex-link $n2 $n4 2000.0Mb 1ms DropTail
$ns queue-limit $n2 $n4 3
$ns duplex-link $n3 $n4 200.0Mb 1ms DropTail
$ns queue-limit $n3 $n4 0
$ns duplex-link $n5 $n4 1.0Mb 1ms DropTail
$ns queue-limit $n5 $n4 2

#Give node position (for NAM)


$ns duplex-link-op $n0 $n4 orient right-down
$ns duplex-link-op $n1 $n4 orient left-down
$ns duplex-link-op $n2 $n4 orient left-down
$ns duplex-link-op $n3 $n4 orient left-up
$ns duplex-link-op $n5 $n4 orient right-up

#===================================
# Agents Definition
#===================================
set p1 [new Agent/Ping]
$ns attach-agent $n0 $p1
$p1 set packetSize_ 50000
$p1 set interval_ 0.0001
set p2 [new Agent/Ping]
$ns attach-agent $n1 $p2
set p3 [new Agent/Ping]
$ns attach-agent $n2 $p3
$p3 set packetSize_ 30000
$p3 set interval_ 0.00001
set p4 [new Agent/Ping]
$ns attach-agent $n3 $p4
set p5 [new Agent/Ping]
$ns attach-agent $n5 $p5
Agent/Ping instproc recv {from rtt} {
$self instvar node_
puts "node [$node_ id] received answer from $from with round trip time
$rtt msec"
}
$ns connect $p1 $p5
$ns connect $p3 $p4
proc finish { } {
global ns namfile tracefile
$ns flush-trace
close $namfile
close $tracefile
exec nam m.nam &
exit 0
}
$ns at 0.1 "$p1 send"
$ns at 0.2 "$p1 send"
$ns at 0.3 "$p1 send"
$ns at 0.4 "$p1 send"
$ns at 0.5 "$p1 send"
$ns at 0.6 "$p1 send"
$ns at 0.7 "$p1 send"
$ns at 0.8 "$p1 send"
$ns at 0.9 "$p1 send"
$ns at 1.0 "$p1 send"

$ns at 0.1 "$p3 send"


$ns at 0.2 "$p3 send"
$ns at 0.3 "$p3 send"
$ns at 0.4 "$p3 send"
$ns at 0.5 "$p3 send"
$ns at 0.6 "$p3 send"
$ns at 0.7 "$p3 send"
$ns at 0.8 "$p3 send"
$ns at 0.9 "$p3 send"
$ns at 1.0 "$p3 send"
$ns at 2.0 "finish"
$ns run

#===================================
# Applications Definition
#===================================

#===================================
# Termination
#===================================
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam exp2.nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run

gedit exp2.awk

BEGIN{
count=0;
}
{
if($1=="d")
count++ ;
}
END{
printf("The Total no of Packets Drop is :%d\n\n", count);
}

OUTPUT:
mite@mite-ise-lab12-pc07:~$ ns exp2.tcl
node 0 received answer from 5 with round trip time 404.9 msec
node 2 received answer from 3with round trip time 704.9 msec
node 0 received answer from 5 with round trip time 1004.9 msec
node 2 received answer from 3 with round trip time 1304.9 msec

mite@mite-ise-lab12-pc07:~$ awk -f exp2.awk exp2.tr


No of packets dropped : 10

Viva Questions and Answers


1. Define Ping?
Ping is a computer network administration software utility used to test the reachability of a
host on an Internet Protocol (IP) network. It measures the round-trip time for messages sent
from the originating host to a destination computer that are echoed back to the source.

2. What is network protocol?


Network protocols are formal standards and policies comprised of rules, procedures and
formats that define communication between two or more devices over a network

3. Define Bandwidth?
Bandwidth is the amount of data that can be transmitted in a fixed amount of time

4. Define a router?
Routers perform the traffic directing functions on the Internet. Data sent through
the internet, such as a web page or email, is in the form of data packets. A packet is typically
forwarded from one router to another router through the networks until it reaches its
destination node

5. Describe network congestion?


It is the reduced quality of service that occurs when a network node or link is carrying more
data than it can handle. Typical effects include queuing delay, packet loss or the blocking of
new connections

6. Which are the two congestion control mechanisms?


prevents the congestion from happening
removes congestion after it has taken place

You might also like