[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] link utilization
Your code should work. It seems to me that you get the wrong utilization,
because 1 byte is 8 bit (and not 1 bit is 8 byte as in your case). So try
something like this:
set linkmon [$ns link $node(2) $node(3)]
set bw [[$linkmon link] set bandwidth_]
set Lutil(counter) [expr $eBytes*8*100/$time/$bw]
good luck
Onno
Jonathan Hicks wrote:
> Hello,
> I am trying to dynamically calculate and use in my simulation the percentage
> of a link's bandwidth that is currently being utilized, working towards a
> load-balancing algorithm.
>
> Here is the approach that I am currently trying to take:
> my understanding is that monitor-queue has a member called bdepartures_ that
> measures the bytes being released from the queue and sent across the link.
> If I can measure this for a certain period of time, I can change it to Mbs
> and divide by the link's capacity. This does not seem to be working for me.
> Does anyone have any suggestions?
> thanks,
> Jonathan
>
> Here is the code I am attempting to use:
> --------------------------------------
> #Monitor the queue on link from n2 to n3
> set qmon [$ns monitor-queue $Node2 $Node3 $LFile]
> set counter 0
> proc calc {} {
> global ns qmon LFile counter
> #update after "time" seconds
> set time 0.5
> set capacity 10
> set now [$ns now]
> #amount of bytes leaving the queue, entering the link (I think)
> set ebytes [$qmon set bdepartures_]
> #convert bytes to Megabytes per second
> set eMbytes [expr $ebytes/$time*8/1000000]
> #The proportion of the link's capacity is being used up
> set Lutil(counter) [expr $eMbytes/$capacity]
> #put the bdepartures_ record back to zero
> $qmon set bdepartures_ 0
> set $counter [expr $counter + 1]
> $ns after $time "calc"
> }
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp