Program 3
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]
#===================================
# 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
#===================================
# 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"
#===================================
# 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
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