[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] cbr rate
On Mon, 7 Jan 2002, Eno Thereska wrote:
> I posted this message some time ago, but I didn't get any reply.
> I have the following problem:
> I am using a UDP agent and a CBR traffic generator on top of it. I have to
> dynamically change the rate the CBR transmits at and I do it by writing:
> $ns at 5 "$cbr set rate_ x", where $crb is the traffic source and x is the
> new rate I want. My problem is that once I set the rate to 0, I cannot
> change it again, i.e the source stays at rate 0 ever after. E.g when I do
>
> $ns at 5 "$cbr set rate_ 0k",
> $ns at 6 "$cbr set rate_ 100k",
>
> Te second statement doesn't have any effect. Any suggestions on why this
> may happen?
looking in ~ns/cbr_traffic.cc
void CBR_Traffic::init()
{
// compute inter-packet interval
interval_ = (double)(size_ << 3)/(double)rate_;
[..]
double CBR_Traffic::next_interval(int& size)
{
// Recompute interval in case rate_ or size_ has changes
interval_ = (double)(size_ << 3)/(double)rate_;
[..]
so division by zero does... what? depends on the compiler? And once
you've set a rate of zero you can't schedule another event, so your at
6 command (which I think would take effect the next time CBR fired off
a packet scheduled at the old rate) then doesn't do anything.
There's a lot of division by rate_ or rtt_ in the code that really
needs to be some function protecting against division by zero. And
some sort of supend/reawaken functionality is needed; setting rate 0
really says 'suspend until something touches this object', but you
don't have an obvious way of touching the object and forcing an event
AFAIK.
No idea how this would be best fixed...
hth,
L.
<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>