[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: how to get the throughput out for ftp application/tcp agent
Hello Al-hussein,
I am very sorry to miss something important in my last email. You
should add the following line
$ns at 0.0 "$traceapp start"
to start TraceApp. After that, TraceApp can work properly.
AHAZ> Hi,
AHAZ> I followed Huang's advice and implemented an application class and
AHAZ> attached it to TcpSink. However, after running the simulation, I don't
AHAZ> see any bytes received. Attached is the tcl script for a simple two
AHAZ> node topology. If anyone has any ideas about that, please let me know.
AHAZ> Thanks in advance,
AHAZ> --Hussein
AHAZ> --------------------------------------------------------------
AHAZ> Class TraceApp -superclass Application
AHAZ> TraceApp instproc init {args} {
AHAZ> $self set bytes_ 0
AHAZ> eval $self next $args
AHAZ> }
AHAZ> TraceApp instproc recv {byte} {
AHAZ> $self instvar bytes_
AHAZ> set bytes_ [expr $bytes_ + $byte]
AHAZ> return $bytes_
AHAZ> }
AHAZ> #Define a 'finish' procedure
AHAZ> proc finish {trace} {
AHAZ> puts "[$trace set bytes_]"
AHAZ> exit 0
AHAZ> }
AHAZ> proc test { } {
AHAZ> #
AHAZ> #Create a simulator object
AHAZ> set ns [new Simulator]
AHAZ> #puts "myrates= $myrates"
AHAZ> # Create a simple two node topology:
AHAZ> #
AHAZ> # n0 ------------ n1
AHAZ> #
AHAZ> set n0 [$ns node]
AHAZ> set n1 [$ns node]
AHAZ> #Create a duplex link between the nodes
AHAZ> $ns duplex-link $n0 $n1 0.8Mb 0.01s DropTail
AHAZ> #Assign a limited buffer size to the bottleneck link
AHAZ> $ns queue-limit $n0 $n1 4
AHAZ> #Create a TCP-Reno agent and attach it to node n0
AHAZ> set tcp [new Agent/TCP/Reno]
AHAZ> $tcp set window_ 10000
AHAZ> $tcp set windowInit_ 1
AHAZ> $tcp set packetSize_ 1000
AHAZ> $tcp set tcpTick_ 0.001
AHAZ> $tcp set maxrto_ 64
AHAZ> $tcp set dupacks_ 0
AHAZ> $tcp set ack_ 0
AHAZ> $tcp set cwnd_ 0
AHAZ> $tcp set rtt_ 0
AHAZ> $tcp set rttvar_ 0
AHAZ> $tcp set backoff_ 0
AHAZ> $tcp set maxseq_ 0
AHAZ> $ns attach-agent $n0 $tcp
AHAZ> #Create a standard TCP Sink and attach it to node n1
AHAZ> set sink [new Agent/TCPSink]
AHAZ> $ns attach-agent $n1 $sink
AHAZ> set traceapp [new TraceApp]
AHAZ> $traceapp attach-agent $sink
AHAZ> puts "[$traceapp set bytes_]"
AHAZ> #create an FTP application and attach it to tcp
AHAZ> set ftp [new Application/FTP]
AHAZ> $ftp attach-agent $tcp
AHAZ> #Connect the application to the sink
AHAZ> $ns connect $tcp $sink
AHAZ> #Schedule events
AHAZ> $ns at 0.0 "$ftp start"
AHAZ> $ns at 60.0 "$ftp stop"
AHAZ> $ns at 70.0 "finish $traceapp"
AHAZ> #Run the simulation
AHAZ> $ns run
AHAZ> }
AHAZ> test
AHAZ> -------------------------------------------------------------------------
>>
>> Hello Zhiwei,
>>
>> If an application is attached to an TCPSink agent, the agnet will call
>> the application's recv(bytes) method whenever it received and ACKed
>> segments. So you can write an application in TCL to record the
>> throughput.
>>
>> The following code declear a new TCL class - "TraceApp" and implement
>> an instproc - "recv". Currently, it just record the total bytes the
>> receiver has received and ACKed and store it to variable bytes_.
>> You can add anything as you like.
>>
>> 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_
>> }
>>
>> The instproc "recv" will be called automatically whenever TCPSink
>> received and ACKed sengments if you attached TraceApp to the TCPSink.
>> The following code will do this.
>>
>> set sink [new Agent/TCPSink]
>> TraceApp traceapp
>> traceapp attach-agent $sink
>>
>> Good luck.
>>
>> ZX> Hi, there:
>> ZX> without postprocessing the trace file, how to get the
>> ZX> sender/receiver's throughput for the ftp application over tcp agent? is
>> ZX> there any sample code? thanks in advance!
>>
>> ZX> xiao
>>
>>
>>
>>
>> Best regards,
>> Huang mailto:[email protected]
>>
>>
>>
Best regards,
Huang mailto:[email protected]