# Experimention :- TCP flow vs UDP 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_Exp1.tr w] #Save throughput for the Second tcp flow set f2 [open tcp-udp_Exp2.tr w] #Open the nam trace file set nf [open tcp_udp_nam.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 25 #Creation of TCP agent and attach it to node n0 set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp # Max bound on window size $tcp set window_ 10 # Set flow ID field $tcp set fid_ 1 #Creation of a UDP agent and attach it to node n1 set udp [new Agent/UDP] $ns attach-agent $n1 $udp # max bound on window size $udp set window_ 10 # set flow ID field $udp set fid_ 2 #Creation of TCP sinks agents set sink1 [new Agent/TCPSink] #Creation of UDP Reciver Agent set sink2 [new Agent/LossMonitor] #Attach Sinks to nodes $ns attach-agent $n4 $sink1 $ns attach-agent $n5 $sink2 $ns connect $tcp $sink1 $ns connect $udp $sink2 #Creation of FTP applications + attach to agents set ftp [new Application/FTP] $ftp attach-agent $tcp #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false #Define a 'finish' procedure proc finish {} { global ns $ns flush-trace puts "running nam..." exec nam -a tcp_udp_nam.nam & exec xgraph tcp-tcp_Exp1.tr tcp-udp_Exp2.tr -geometry 800x400+10+10 -x "Time -ms" -y "Throughtput -Kbps" -t "Vanjikumaran's TCP-UDP 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 "$ftp start" $ns at 0.4 "$cbr start" $ns at 2.0 "$ftp stop" $ns at 2.0 "$cbr stop" $ns at 2.2 "finish" $ns run
you can run these codes using ns .tcl
Above NS2 scripts help you to simulate how TCP's functionality in the real network.
Lets see what has happened!
As shown in Figure 1, the network model was configured with two TCP
(TransmissionControl Protocol) flows for two milliseconds and recorded
observation in trace files.
Figure 1 |
Figure 2 |
As shown in Figure 3, additional another experiment was conducted in respect to model the TCP flow and UDP (User Datagram Protocol) flow in shared network environment, which experiment was inspected for two milliseconds. Furthermore, observations were recorded in the trace file as previous experiment.
Figure 3 |
In accordance with the second experimental result given in the Figure 4,
UPD flow was taken over the shared network resource from TCP flow and
it did not moderately shared the band with it .
Figure 4 |
According to Figure 5, in first experiment; first TCP flow was shared the bandwidth with second TCP flow. In second experiment; TCP flow was trampled by UDP flow.Hence, as a conclusion of those two experiments, TCP Shares the network resource fairly.Nevertheless, UPD does not share the network resource.
Even though this is irrelevant to this topic, this help us to understand the behavior of the TCP connections.
No comments:
Post a Comment