# Experimention :- TCP flow vs TCP flow # Experimenter :- Sivajothy Vanjikumaran #Create a simulator object set ns [new Simulator] #Colors Define $ns color 1 brown $ns color 2 green #Save throughput for the First tcp flow set f1 [open tcp-tcp-one.tr w] #Save throughput for the Second tcp flow set f2 [open tcp-tcp-two.tr w] #Open the nam trace file set nf [open tcp-out.nam w] $ns namtrace-all $nf #Create 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 between the nodes $ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 10ms DropTail $ns duplex-link $n3 $n4 1Mb 10ms DropTail $ns duplex-link $n3 $n5 1Mb 10ms DropTail # Making a bottle neck connection $ns duplex-link $n2 $n3 1Mb 10ms DropTail # #(0)- -(4) # \ / # (2)-----(3) # / \ #(1)- -(5) # #layout of the data transferring path $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 $ns duplex-link-op $n3 $n4 orient right-up $ns duplex-link-op $n3 $n5 orient right-down #Queue limit between node n2 & n3 (Bottle neck) $ns queue-limit $n2 $n3 10 #Creation of TCP 1 agent and attach it to node n0 set tcp1 [new Agent/TCP/Vegas] $ns attach-agent $n0 $tcp1 # Max bound on window size $tcp1 set window_ 20 # Set flow ID field $tcp1 set fid_ 1 #Creation of a TCP 2 agent and attach it to node n1 set tcp2 [new Agent/TCP/Vegas] $ns attach-agent $n1 $tcp2 # max bound on window size $tcp2 set window_ 20 # set flow ID field $tcp2 set fid_ 2 #Creation of TCP sinks agents set sink1 [new Agent/TCPSink] set sink2 [new Agent/TCPSink] #Attach Sinks to nodes $ns attach-agent $n4 $sink1 $ns attach-agent $n5 $sink2 $ns connect $tcp1 $sink1 $ns connect $tcp2 $sink2 #Creation of FTP applications + attach to agents set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp1 set ftp2 [new Application/FTP] $ftp2 attach-agent $tcp2 #Define a 'finish' procedure proc finish {} { global ns $ns flush-trace puts "running nam..." exec nam -a tcp-out.nam & exec xgraph tcp-tcp-one.tr tcp-tcp-two.tr -geometry 800x400+10+10 -x "Time -ms" -y "Throughtput -Kbps" -t "Vanjikumaran's TCP-TCP Experiment" & exit 0 } proc record {} { global sink1 sink2 ns f1 f2 #Set the time the procedure should be called again set time 0.1 set bw0 [$sink1 set bytes_] set bw1 [$sink2 set bytes_] #Get the current time set now [$ns now] # throughtput in Kbps puts $f1 "$now [expr ($bw0 * 8) / ($time * 1024)]" puts $f2 "$now [expr ($bw1 * 8) / ($time * 1024)]" $sink1 set bytes_ 0 $sink2 set bytes_ 0 #Call procedure again $ns at [expr $now + $time] "record" } $ns at 0.0 "record" $ns at 0.2 "$ftp1 start" $ns at 0.4 "$ftp2 start" $ns at 2.0 "$ftp1 stop" $ns at 2.0 "$ftp2 stop" $ns at 2.2 "finish" $ns run
Saturday, 28 March 2015
TCP flow vs TCP flow using vegas
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment