No, it looks problematic in general.

1) Don't wire the component twice. This will just make things confusing.
2) The generate_random() function initializes a seed and then gets a
random number from that seed.
Remember that PRNGs generate the -same sequence- for the same seed
(and the seed is being set each time!).
This is essentially making the random generator non-random (it is
entirely based off of the current 'counter'.)
3) Furthermore, the variable name 'counter' sounds suspicious. See
point #2 and below.

Just set the seed at mote initialization (and maybe *adjust*
periodically from a "random source").
To get many different sequences the seeds MUST COVER the entire
seed-space (2**32).
You can find many examples (some really bad) on how older programs
(most notably C and Perl?) set the seed based on some function of
system time.
Usually this involves extra math to attempt to get a better coverage
of the seed-space.

All that being said, the first thing I would ensure is that -the seeds
you are providing- are as 'random' as you think.
In this implementation the inputs directly determines the 'random'
(see above) output.
Without the re-seeding you would simple get another pseudo-random
number NEXT in the sequence based off of the seed.

HTH,
Paul

> Thank you for your reply, I just want to confirm with you if the code you saw 
> in
> my message to set the seed and then generate a random number is actually
> correct? What did you mean by "correctly applied" when you said:
> "I would ensure an adequate seed is actually being generated and
> correctly applied."
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to