NS2 Program for Transmission of Ping Messages

set ns [new Simulator]
set nf [open prog4.nam w]
$ns namtrace-all $nf
set nd [open prog4.nam w]
$ns trace-all $nd

proc finish {} {
global ns nf nd
$ns flush-trace
close $nf
close $nd
exec nam prog4.nam &
exit 0
}

set n0 {$ns node]
set n1 {$ns node]
set n2 {$ns node]
set n3 {$ns node]
set n4 {$ns node]
set n5 {$ns node]
set n6 {$ns node]

$ns duplex-link $n1 $n0 1 Mb 12 ms DropTail
$ns duplex-link $n2 $n0 1 Mb 10 ms DropTail
$ns duplex-link $n3 $n0 1 Mb 10 ms DropTail
$ns duplex-link $n4 $n0 1 Mb 10 ms DropTail
$ns duplex-link $n5 $n0 1 Mb 10 ms DropTail
$ns duplex-link $n6 $n0 1 Mb 11 ms DropTail

Agent/Ping instproc recv {from rtt
{ $self instvar node_
puts "node[$node_id] received ping answer from
\$from round-trip-time $rtt ms."
}
set p1 [new Agent/Ping]
set p2 [new Agent/Ping]
set p3 [new Agent/Ping]
set p4 [new Agent/Ping]
set p5 [new Agent/Ping]
set p6 [new Agent/Ping]

$ns attach-agent $n1 $ns attach-agent $n2
$p2 $ns attach-agent $n3 $p3 $ns attach-agent
$n4 $p4 $ns attach-agent $n5 $p5$ns attach-agent $n6 $p6

$ns queue-limit $n0 $n4 3 $ns queue-limit$n0
$n5 2 $ns queue-limit $n0 $n6 2

$ns connect $p1 $p4 $ns connect $p2 $p5 $ns connect $p3 $p6

$ns at 0.1 "$p1 send" $ns at 0.3 "$p2 send"
$ns at 0.5 "$p3 send" $ns at 1.0 "$p4 send"
$ns at 1.2 "$p5 send" $ns at 1.4 "$p6 send"
$ns at 2.0 "finish" $ns run

awk

BEGIN { count=0;
}
{
event=$1;if(event=="d")
{
count++;
}
}
END {
printf("No of packets dropped:%d\n",count);
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *