[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to get the throughput out for ftp application/tcp agent



Hi,

I followed Huang's advice and implemented an application class and
attached it to TcpSink. However, after running the simulation, I don't 
see any bytes received. Attached is the tcl script for a simple two
node topology. If anyone has any ideas about that, please let me know.

Thanks in advance,

--Hussein

--------------------------------------------------------------

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_
}



#Define a 'finish' procedure
proc finish {trace} {
	puts "[$trace set bytes_]"
        exit 0
}


proc test { } {
#
#Create a simulator object
set ns [new Simulator]
#puts "myrates= $myrates"

# Create a simple two node topology:
#
#  n0 ------------ n1 
#
set n0 [$ns node]
set n1 [$ns node]

#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 0.8Mb 0.01s DropTail

#Assign a limited buffer size to the bottleneck link
$ns queue-limit $n0 $n1 4


#Create a TCP-Reno  agent and attach it to node n0
set tcp [new Agent/TCP/Reno]
$tcp set window_ 10000
$tcp set windowInit_ 1
$tcp set packetSize_ 1000
$tcp set tcpTick_ 0.001
$tcp set maxrto_ 64
$tcp set dupacks_ 0
$tcp set ack_ 0
$tcp set cwnd_ 0
$tcp set rtt_ 0
$tcp set rttvar_ 0
$tcp set backoff_ 0
$tcp set maxseq_ 0

$ns attach-agent $n0 $tcp

#Create a standard TCP Sink and attach it to node n1
set sink [new Agent/TCPSink]
$ns attach-agent $n1 $sink

set traceapp [new TraceApp]
$traceapp attach-agent $sink
puts "[$traceapp set bytes_]"

#create an FTP application and attach it to tcp
set ftp [new Application/FTP]
$ftp attach-agent $tcp

#Connect the application to the sink
$ns connect $tcp $sink  


#Schedule events
$ns at 0.0 "$ftp start"
$ns at 60.0 "$ftp stop"
$ns at 70.0 "finish  $traceapp" 

#Run the simulation
$ns run
}

test 


-------------------------------------------------------------------------


> 
> 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]
> 
> 
>