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

Re: [ns] Random Number Generator



On Wed, 25 Jul 2001, Sungwon Yi wrote:
> I am trying to generate random number to use it
> as traffic starting time between 30 to 40 sec.
> I used following ...
>
> set rng [new RNG]
> $rng seed 0
> $rng uniform 30.0 40.0
>
> $ns at $rng "$cbr0 start"
>
> However, It not seems to work. The traffic seems to
> be generated earlier than 30.0., and Please let me
> know if there is a way that I can check this value.
>

  By default, there's a RNG created with every NS simulation.  It's called
defaultRNG.  So, here's what I think you want:

global defaultRNG
$defaultRNG seed 0
set unif [new RandomVariable/Uniform]
$unif set min_ 30.0
$unif set max_ 40.0
$ns at [$unif value] "$cbr0 start"

Michele
--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Michele C. Weigle			[email protected],
CB# 3175, Sitterson Hall		[email protected]
Department of Computer Science		http://www.cs.unc.edu/~clark
University of North Carolina		Sitterson 327
Chapel Hill, NC 27599-3175		(919) 962-1909
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%