[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] Reg bandwidth utilization!!
ANOTHER OPTION WOULD BE TO...
set f0 [open src0.tr w]
proc finish {} {
global ns nf f0
$ns flush-trace
close $f0
exec xgraph -m src0.tr -geometry 800x400 &
exit 0
}
#Define a procedure which periodically records the bandwidth received by
the #traffic sink sink0 and writes it to the file f0.
proc record {} {
global sink0 f0
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]
#Calculate the bandwidth (in MBit/s) and write it to the file
puts $f0 "$now [expr $bw0/$time*8/1000000]"
#Reset the bytes_ values on the traffic sink
$sink0 set bytes_ 0
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
}
U NEED TO CALL THIS PROCEDURE INITIALLY IN THE MAIN PROGRAM.
$ns at 0.0 "record"
$ns at 100.0 "finish" // to stop the simulation.
THEN THE FILE TO WHICH "f0" is the file descipter shows the o/p as
0.0 0.00
0.5 6.7
1.0 6.9
1.5 8.4
--
T.Chitti Babu (H-7, # 133)
KReSIT , IITBombay
MUMBAI-400076
---------------------------------------------
INTERNAL PH NOS:
KReSIT Lab -- 5785
Hostel 7 No - 5607
EXTERNAL PH NOS:
HOSTEL 7 Nos : 5721049, 5720105