[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Simple mod to CBR traffic generator



Hi,

I wanted to use the CBR traffic generator in one of my simulations.
However, I didn't want the source to be completely periodic - I wanted
some random behaviour. I had a look at the random_ parameter in the class
to see what it does and found that it introduces some random jitter into
the generated traffic.

However, the CBR source does not facilitate very great control over the
amount of jitter that was introduced. I made the following simple mod to
introduce more control over the amount of jitter introduced:

[murphys@testbed3 ns-2.1b6]$ diff -c cbr_traffic.cc cbr_traffic.cc.old
*** cbr_traffic.cc      Sat Aug 26 12:16:55 2000
--- cbr_traffic.cc.old  Sat Aug 26 13:12:44 2000
***************
*** 81,91 ****
        // Recompute interval in case rate_ or size_ has changes
        interval_ = (double)(size_ << 3)/(double)rate_;
        double t = interval_;
!       if (random_) {
!               if (random_ > 1)
!                       random_=1 ;
!               t += interval_ * Random::uniform(-random_/2, random_/2);
!       }
        size = size_;
        if (++seqno_ < maxpkts_)
                return(t);
--- 81,88 ----
        // Recompute interval in case rate_ or size_ has changes
        interval_ = (double)(size_ << 3)/(double)rate_;
        double t = interval_;
!       if (random_)
!               t += interval_ * Random::uniform(-0.5, 0.5);
        size = size_;
        if (++seqno_ < maxpkts_)
                return(t);


The random_ parameter is now a variable parameter that controls the amount
of jitter introduced instead of a simple on/off flag. If the random_
parameter is 0, then no jitter is introduced - the source is periodic. If
the random_ parameter is 1, then the source behaves as before: the jitter
window is (-0.5t, 0.5t). But now the random_ parameter can have values
between 0 and 1 such that more jitter is introduced as the parameter
increases.

It's a small simple change which I thought might be useful to someone -
perhaps it could be introduced into the distribution.

Regards,
Sean.

-----
***NOTE NEW PHONE AND FAX NUMBER***
-----
Sean Murphy,			Email: [email protected]
Teltec Ireland,			Phone: +353-1-7005080
DCU, Dublin 9,			Fax:   +353-1-7005092
Ireland.