#
# (0)tcp0,ftp0 (4)tcpSink0
# \ /
# \ 1Mbps / 2Mbps
# \ 3Mbps /
# (2)----------------(3)
# / \
# / 1Mbps \ 2Mbps
# / \
# (1)udp0,cbr0 (5)null0
#
# [.005s]
# udp0 [1000b]----------> null0
# [.005s]
# tcp0 [1000b]----------> tcpsink0
# All 10ms DropTail
#
set ns [new Simulator]
set nf [open trace.tr w]
$ns trace-all $nf
set nm [open out.nam w]
$ns namtrace-all $nm
#Define a 'finish' procedure
proc finish {} {
global ns nf nm
$ns flush-trace
#Close the NAM trace file
close $nf
close $nm
exec nam out.nam
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
#creating links
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 3Mb 10ms DropTail
$ns duplex-link $n3 $n4 2Mb 10ms DropTail
$ns duplex-link $n3 $n5 2Mb 10ms DropTail
#set up a tcp, connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ftp0 set packetSize_ 1000
$ftp0 set interval_ 0.005
set tcpsink0 [new Agent/TCPSink]
$ns attach-agent $n4 $tcpsink0
#create a udp agent and attach it to node n1
set udp0 [new Agent/UDP]
$ns attach-agent $n1 $udp0
#Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 1000
$cbr0 set interval_ 0.005
#create a Null agent(a traffic sink) and attach it to node n1
set null0 [new Agent/Null]
$ns attach-agent $n5 $null0
#Connect the traffic source to the sink
$ns connect $udp0 $null0
$ns connect $tcp0 $tcpsink0
$ns at 1.0 "$ftp0 start"
$ns at 1.1 "$cbr0 start"
$ns at 4.5 "$ftp0 stop"
$ns at 4.5 "$cbr0 stop"
$ns at 5 "finish"
$ns run
====throTCP.awk
#!/usr/bin/awk -f
BEGIN{
data = 0
#print"throughput calculation"
}
{
if( $1=="r" && $4=="4" && $5=="tcp")
{
data+=$6
print $2,data*8.0/$2/1000000
}
}
END{
#print "completed"
}
No comments:
Post a Comment