#animated single TCP connection over a slow access link

#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

#Define a 'finish' procedure
proc finish {} {
        global ns nf
        $ns flush-trace
	#Close the trace file
        close $nf
	#Execute nam on the trace file
        exec nam out.nam &
        exit 0
}

#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]

#Create links between the nodes
$ns duplex-link $n0 $n1 300Kb 20ms DropTail
$ns duplex-link $n1 $n2 30Kb 200ms DropTail

#Monitor the queue for the link between node 2 and node 3
$ns duplex-link-op $n1 $n2 queuePos 0.5

$ns queue-limit $n1 $n2 4

#Create a UDP agent and attach it to node n0
set tcp0 [new Agent/TCP/Reno]
$tcp0 set class_ 1
$ns attach-agent $n0 $tcp0

set tcp0_s [new Agent/TCPSink]
$ns attach-agent $n2 $tcp0_s

$ns connect $tcp0 $tcp0_s
$tcp0_s listen

set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp0
$ns at 0.1 "$ftp1 start"


#Call the finish procedure after 5 seconds of simulation time
$ns at 150.0 "finish"

#Run the simulation
$ns run


