[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Help : Tcp Throughput.
Hi,
I'm trying to obtain the throughput of a tcp connection.
I try to use the TraceApp class method to obtain the total bytes received by
the TCPSink. But everytime I get a value = 0. Could someone point to me what
wrong with my code. I will aslo like to plot a throughput graph, anyone have
sample code???
Thanks,
Don
The following is my code :
Class TraceApp -superclass Application
TraceApp instproc init {args} {
$self set bytes_ 0
eval $self next $args
}
TraceApp instproc recv {byte} {
$self instvar bytes_
set bytes_ [expr $bytes_+$byte]
return $bytes_
}
set ns [new Simulator]
set host1 [$ns node]
set host2 [$ns node]
$ns duplex-link $host1 $host2 10Mb 5ms DropTail
set tcp1 [new Agent/TCP]
$tcp1 set packetSize_ 1000
set sink1 [new Agent/TCPSink]
set traceapp [new TraceApp]
$traceapp attach-agent $sink1
$ns attach-agent $host1 $tcp1
$ns attach-agent $host2 $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns at 0.0 "$traceapp start"
$ns at 10.0 "$ftp1 start"
$ns at 60.0 "$ftp1 stop"
$ns at 65.0 "$traceapp stop ; puts \"total = [$traceapp set bytes_]\""
$ns at 70.0 "puts \"NS Existing ... ...\"; $ns halt"
# start ns
puts "starting simulation ... ..."
puts "\creating topology ... ..."
$ns run