[Tinyos-devel] Random numbers in TOSSIM
Philip Levis
pal at cs.stanford.edu
Sat Oct 13 10:53:56 PDT 2007
On Oct 13, 2007, at 7:51 AM, Konrad Iwanicki wrote:
> 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.
Hm. I had thought MLCG should take care of this. There's a more
general problem, then, that the function sticks on 0. I'll take a
closer look when I look over some TOSSIM packet communication issues
a few people raised. Your solution looks totally reasonable and I'll
probably commit it, but I also want to make sure that the random
number code is correct.
Phil
More information about the Tinyos-devel
mailing list