[Tinyos-devel] Random numbers in TOSSIM

Konrad Iwanicki iwanicki at few.vu.nl
Sat Oct 13 07:51:02 PDT 2007


Hello Phil,

On Fri, 12 Oct 2007, Philip Levis wrote:

> On Oct 11, 2007, at 5:29 AM, Konrad Iwanicki wrote:
>
> > Hi all,
> >
> > TOSSIM has some drawbacks regarding random seed initialization.
> >
> > 1. It may happen that the seed is set to 0. As a result, all randomly
> > generated numbers are 0. This situation occurred a number of times
> > when
> > I was extensively testing of my algorithms with TOSSIM, so it is not
> > unlikely to happen.
> >
> > 2. It is virtually impossible to repeat experiments with the same
> > random
> > seed without modifying TOSSIM.
> >
> > For these reasons, I made some small changes to the sim_init()
> > function
> > in the sim_tossim.c file (see below). Essentially, one can redefine a
> > macro, TOSSIM_RANDOM_SEED, at compile time to set his/her own seed. In
> > addition, the code prevents the seed from being equal to 0.
> >
> > **Can somebody integrate these changes with the sourceforge CVS
> > tree**?
>
> Why does Tossim::randomSeed(int seed) not work?

Yes, true it works in the second case (my mistake). However, my point
was rather, apart from the TOSSIM_RANDOM_SEED macro, providing a mechanism
that ensures that the seed is non-zero by default, and thus, the
modifications to sim_init.

Take care,
--
- Konrad Iwanicki.



More information about the Tinyos-devel mailing list