0% found this document useful (0 votes)
4 views4 pages

Computernetwork Program 2

The document outlines a simulation setup for transmitting Ping messages and traceroute over a network with 6 nodes, including the configuration of links and queue limits. It specifies the simulation duration, node creation, and the process for sending Ping messages. An AWK program is included to count and report the number of packets dropped due to congestion during the simulation.

Uploaded by

deadshotlev
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)
4 views4 pages

Computernetwork Program 2

The document outlines a simulation setup for transmitting Ping messages and traceroute over a network with 6 nodes, including the configuration of links and queue limits. It specifies the simulation duration, node creation, and the process for sending Ping messages. An AWK program is included to count and report the number of packets dropped due to congestion during the simulation.

Uploaded by

deadshotlev
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/ 4

2.

Implement transmission of Ping message/traceroute over a network topology consisting of 6


nodes and find the number of Packets dropped due to congestion.

set val(stop) 10.0; # time of simulation end

#Create a ns simulator

set ns [new Simulator]

#Open the NS trace file

set tracefile [open 3.tr w]

$ns trace-all $tracefile

#Open the NAM trace file

set namfile [open 3.nam w]

$ns namtrace-all $namfile

#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]

#Create links between nodes

$ns duplex-link $n0 $n1 1Mb 50ms DropTail

$ns queue-limit $n0 $n1 50

$ns duplex-link $n0 $n3 1Mb 50ms DropTail

$ns queue-limit $n0 $n3 50

$ns duplex-link $n0 $n4 1Mb 50ms DropTail

$ns queue-limit $n0 $n4 50

$ns duplex-link $n0 $n5 1Mb 50ms DropTail

$ns queue-limit $n0 $n5 2

$ns duplex-link $n0 $n2 1Mb 50ms DropTail

$ns queue-limit $n0 $n2 2


$ns duplex-link $n0 $n6 1Mb 50ms DropTail

$ns queue-limit $n0 $n6 1

#Give node position (for NAM)

$ns duplex-link-op $n0 $n1 orient right-up

$ns duplex-link-op $n0 $n2 orient right

$ns duplex-link-op $n0 $n3 orient right-down

$ns duplex-link-op $n0 $n4 orient left-down

$ns duplex-link-op $n0 $n5 orient left

$ns duplex-link-op $n0 $n6 orient left-up

Agent/Ping instproc recv {from rtt} {

$self instvar node_

puts "node [$node_ id] received ping answer from $from with round-trip-time $rtt ms."

#creating Ping

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]

#attaching Ping between Node

$ns attach-agent $n1 $p1

$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 connect $p1 $p4


$ns connect $p2 $p5

$ns connect $p3 $p6

#sending Process

$ns at 0.2 "$p1 send"

$ns at 0.4 "$p2 send"

$ns at 0.6 "$p3 send"

$ns at 1.0 "$p4 send"

$ns at 1.2 "$p5 send"

$ns at 1.4 "$p6 send"

#Finish Procedure

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam 3.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

AWK Program

BEGIN {

count=0;

event=$1;
if(event=="d") {

count++;

END {

printf("No of packets dropped : %d\n",count);

You might also like