On Feb 11, 2007, at 10:44 PM, MINO GB wrote:

There is a problem with Random.rand() function in TOSSIM. The result of this functions is always identical for each mote.
For example:
$ build/pc/main.exe -t=50 9
SIM: Random seed is 46875
4: Random: 25778
1: Random: 49743
2: Random: 30049
6: Random: 31429
7: Random: 6452
5: Random: 51923
3: Random: 38032
8: Random: 30743
0: Random: 24870
Exiting on SIGINT at 0:0:18.00713575 .


$ build/pc/main.exe -t=50 9
SIM: Random seed is 906250
7: Random: 6452
4: Random: 25778
3: Random: 38032
5: Random: 51923
8: Random: 30743
1: Random: 49743
0: Random: 24870
2: Random: 30049
6: Random: 31429
Exiting on SIGINT at 0:0:12.04950600.

How can we generate different random number each time running program?

This is no different than any other random number generator. For example, in UNIX, if you do not call srand(), the first call to rand () always returns the same result. To have the random number sequence start at another random number, you need to input some source of non- determinism. In UNIX, you often call srand() with gettimeofday(). You could make up something in TOSSIM to give them different seeds, but with real motes you'd see this behavior is well.

Generally, for things like cryptographically strong random number generation, modern OS kernels capture bits of entropy through interrupt timing. I.e., generate a string of bits from the LSB of the system clock on each keyboard interrupt.

Phil
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to