0% found this document useful (0 votes)
40 views6 pages

Assignment 8

The document describes simulations of TCP Tahoe and TCP Reno algorithms over a simple network topology. It defines nodes, links, traffic flows and runs simulations to collect congestion window data to plot the difference between the two algorithms.

Uploaded by

bishal.nitr
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 views6 pages

Assignment 8

The document describes simulations of TCP Tahoe and TCP Reno algorithms over a simple network topology. It defines nodes, links, traffic flows and runs simulations to collect congestion window data to plot the difference between the two algorithms.

Uploaded by

bishal.nitr
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/ 6

Assignment – 8

Name : B.Sai Ram Gandhi


Roll No : 121CS0167

Tahoe:

#Create a simulator object


set ns [new Simulator]

#Define different colors for data flows


$ns color 1 Blue
$ns color 2 Red

#Open the nam trace file


set nf [open out.nam w]
$ns namtrace-all $nf

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

#Create four nodes


set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

#Create links between the nodes


$ns duplex-link $n0 $n2 100Mb 10ms DropTail
$ns duplex-link $n1 $n2 100Mb 10ms DropTail
$ns duplex-link $n2 $n3 0.1Mb 100ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right

#Setup a TCP connection at node


n0 set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $n3 $sink0
$ns connect $tcp0 $sink0
$tcp0 set fid_ 1
#Setup a FTP over TCP connection at node 1
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0

#Setup a TCP connection at node


n1 set tcp1 [new Agent/TCP]
$ns attach-agent $n1 $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $n3 $sink1
$ns connect $tcp1 $sink1
$tcp0 set fid_ 2
#Setup a FTP over TCP connection at node 1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1

#Schedule events for the CBR agents


$ns at 1.0 "$ftp0 start"
$ns at 1.0 "$ftp1 start"
$ns at 99.0 "$ftp0 stop"
$ns at 99.0 "$ftp1 stop"

#Call the finish procedure after 5 seconds of simulation time


$ns at 100.0 "finish"

#Plot Window
proc plotWindow {tcpSource outfile}
{ global ns
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $outfile "$now $cwnd"
$ns at [expr $now+0.1] "plotWindow $tcpSource $outfile"
}

set outfile [open "congestion_t.xg" w]


$ns at 0.0 "plotWindow $tcp0 $outfile"
#Run the simulation
$ns run

Reno:

#Create a simulator object


set ns [new Simulator]

#Define different colors for data flows


$ns color 1 Blue
$ns color 2 Red

#Open the nam trace file


set nf [open out.nam w]
$ns namtrace-all $nf

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

#Create four nodes


set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

#Create links between the nodes


$ns duplex-link $n0 $n2 100Mb 10ms DropTail
$ns duplex-link $n1 $n2 100Mb 10ms DropTail
$ns duplex-link $n2 $n3 0.1Mb 100ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
#Setup a TCP connection at node
n0 set tcp0 [new Agent/TCP/Reno]
$ns attach-agent $n0 $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $n3 $sink0
$ns connect $tcp0 $sink0
$tcp0 set fid_ 1
#Setup a FTP over TCP connection at node 1
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0

#Setup a TCP connection at node


n1 set tcp1 [new Agent/TCP/Reno]
$ns attach-agent $n1 $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $n3 $sink1
$ns connect $tcp1 $sink1
$tcp0 set fid_ 2
#Setup a FTP over TCP connection at node 1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1

#Schedule events for the CBR agents


$ns at 1.0 "$ftp0 start"
$ns at 1.0 "$ftp1 start"
$ns at 99.0 "$ftp0 stop"
$ns at 99.0 "$ftp1 stop"

#Call the finish procedure after 5 seconds of simulation time


$ns at 100.0 "finish"

#Plot Window
proc plotWindow {tcpSource outfile}
{ global ns
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $outfile "$now $cwnd"
$ns at [expr $now+0.1] "plotWindow $tcpSource $outfile"
}

set outfile [open "congestion_r.xg" w]


$ns at 0.0 "plotWindow $tcp1 $outfile"

#Run the simulation


$ns run

Topology:

Plotting Graph:
set terminal png
set output "plot.png"
set xlabel "Time in seconds"
set ylabel "Congestion window size"
plot "congestion_r.xg" using 1:2 with linespoints title "Reno","congestion_t.xg"
using 1:2 with linespoints title "Tahoe"
Output:

You might also like