Monitoring TCP Packet Loss in NS2
Hi,
I am simulating a TCP/FTP to TCP/FTP network and trying to monitor the packet loss.
I am able to monitor and graph data regarding the TCPSinks' bytes received, but I can't monitor packet loss.
Why is it that the TCPSink Agent has a variable for bytes (bytes_) but not one for monitoring packet loss?
Do I have to monitor the packet loss from the queue? If so, how do I write code for this?
Below is part of the code for monitoring bytes received from sinks if anyone was interested.
proc record {} {
global sink sink1 f0 f1 f2
#Get an instance of the simulator
set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.3
#How many bytes have been received by the traffic sinks?
set bw0 [$sink set bytes_]
set bw1 [$sink1 set bytes_]
#Get the current time
set now [$ns now]
#Calculate the bandwidth (in MBit/s) and write it to the files
puts $f0 "$now [expr $bw0/$time*8/1000000]"
puts $f1 "$now [expr $bw1/$time*8/1000000]"
#combination of f0 and f1
puts $f2 "$now [expr $bw0/$time*8/1000000+$bw1/$time*8/1000000]"
#Reset the bytes_ values on the traffic sinks
$sink set bytes_ 0
$sink1 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
}
Thank you for your help.
-Yida
|