Sunday, January 22, 2012

Re: [ns] getting values from trace file during execution of tcl script

Hello!

You don't need to pull the data from the trace file, you can get it from the sender / receiver objects (like bytes_ variable in TCPSink and LossMonitor for received bytes). You can also use ns "at" function to schedule the logging. Here is an example for bytes received:

[code]
proc record {} {
global sink0

set ns [Simulator instance]
#Set the time after which the procedure should be called again
set time 0.5
#How many bytes have been received by the traffic sink?
set bw0 [$sink0 set bytes_]
#Get the current time
set now [$ns now]
#Output the current time and received bytes
puts "$now $bw0"
#You can reset bytes count to get only the bytes received from the previous log ($now-$time)
#If you exclude the following line you will get all the bytes that were received from the simulation start up untill now
$sink0 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
}


#Start the record
$ns at 0.0 "record"
[/code]

(taken from some presentation and changed a bit, you can find these resources online, search for "recording throughput in ns")

So you basically have a function that recursively schedules its execution. Check the manual for the ways of getting the sent and received packets od the agent you are using, it should work. I'm currently using this method to log the used throughput of several TCP connections. I must admit, I have some unexpected results, like I have a time period when more packets are transmitted than a maximum throughput should allow. I must find the error.

Hope this helps.

Andrej


> Date: Sun, 22 Jan 2012 03:45:32 +0500
> From: zubiyaa@gmail.com
> To: ns-users@ISI.EDU
> Subject: [ns] getting values from trace file during execution of tcl script
>
>
> Hi,
> during execution of tcl script, is there some way to get values from trace
> file (e.g number of sent packets) after a specific time interval (e.g.3ms)?
> I need to write a function to count number of sent/received packets or
> bytes after every 2ms.
>
> I hope many researchers are present at this platform so plz consider it and
> do reply me.
>
> Thanks in advance
>
> --
> Regards

No comments:

Post a Comment

Counter

blogger analytics