I have been seeding TOSSIM from outside (/dev/urandom) with code like this:

#include <stdio.h>
...

  uses interface ParameterInit<uint16_t> as Seed;

...

  event void Boot.booted() {
    uint16_t seed;
    FILE *f;

    f = fopen("/dev/urandom", "r");
    fread(&seed, sizeof(seed), 1, f);
    fclose(f);

    call Seed.init(seed+TOS_NODE_ID+1);
}

Markus


On Thu, Jul 10, 2014 at 4:44 PM, Michiel Konstapel <m.konsta...@sownet.nl>
wrote:

>  Probably not – I bet it compiles the same RandomC as it does for a real
> node, so it still seeds based on TOS_NODE_ID. I have no idea if you can
> access “outside” sources of randomness from a TOSSIM node.
>
>
>
> *From:* tinyos-help-boun...@millennium.berkeley.edu [mailto:
> tinyos-help-boun...@millennium.berkeley.edu] *On Behalf Of *Michiel
> Konstapel
> *Sent:* Thursday, July 10, 2014 16:17
> *To:* Jisha Mary Jose
> *Cc:* Tinyos-Help
>
> *Subject:* Re: [Tinyos-help] random number
>
>
>
> Hi! Please keep replies on the list, so others can contribute/benefit, too.
>
>
>
> I’m not familiar with TOSSIM, so I just googled ‘TOSSIM random seed’ and
> looks like you can initialize its random number generator:
> http://tinyos-help.10906.n7.nabble.com/Reproducible-TOSSIM-simulations-td16341.html.
> This person has the opposite problem, trying to get reproducible run.
>
>
>
> However, I don’t know if the Tossim seed is used by the random number
> generator.
>
>
>
> *From:* Jisha Mary Jose [mailto:jishamary1...@gmail.com
> <jishamary1...@gmail.com>]
> *Sent:* Thursday, July 10, 2014 12:16
> *To:* Michiel Konstapel
> *Subject:* Re: [Tinyos-help] random number
>
>
>
> Hi,
>
> Thankyou for the response. I am working in TOSSIM, so there are no real
> motes. What is any other option to generate random numbers? Please guide
> me..
>
>
>   Regards,
>
> Jisha Mary Jose
> ......jMj......
>
>
>
> On 10 July 2014 15:21, Michiel Konstapel <m.konsta...@sownet.nl> wrote:
>
> Timer.getNow() starts over at zero after every boot, so you’re probably
> using the same seed every time unless something during the boot process
> takes a variable amount of time (and on an embedded system or in the
> simulator, it probably takes the same amount of time, every time – at least
> down to the millisecond level).
>
> Michiel
>
>
>
> *From:* tinyos-help-boun...@millennium.berkeley.edu [mailto:
> tinyos-help-boun...@millennium.berkeley.edu] *On Behalf Of *Jisha Mary
> Jose
> *Sent:* Thursday, July 10, 2014 11:18
> *To:* Eric Decker
> *Cc:* Tinyos Help Request; Tinyos-Help
> *Subject:* Re: [Tinyos-help] random number
>
>
>
> I did that, i changed the seed. But still same numbers are generated again
> and again at a particular node.
>
>
>   Regards,
>
> Jisha Mary Jose
> ......jMj......
>
>
>
> On 10 July 2014 13:05, Eric Decker <cire...@gmail.com> wrote:
>
>
>
> asked and answered.
>
>
>
> The random number generator is pseudo-random.
>
>
>
> It starts up using a SEED which you need to modify to get different
> sequences.
>
>
>
>
>
> On Wed, Jul 9, 2014 at 11:52 PM, Jisha Mary Jose <jishamary1...@gmail.com>
> wrote:
>
>    Hi,
>
> I have to generate random number for a node to use in key generation. But
> i always get the same random number. So ichanged seed value using the
> current system time as shown below.
>
>
> module SecurityC{
>
>     uses interface Boot;
>     uses interface Random;
>     uses interface ParameterInit<uint16_t> as SeedInit;
>     uses interface Timer<TMilli>;
> }
>
> implementation{
>
>     uint32_t rand1;
>     uint32_t t;
>
>     event void Timer.fired() {
>
>          t=call Timer.getNow();
>         dbg("Boot", "%s Current time: %d \n", sim_time_string(), t);
>     }
>
>     event void Boot.booted()
>     {
>
>         dbg("Boot", "Application booted.\n");
>         t=call Timer.getNow();
>         call SeedInit.init(t);
>
>         rand1 = (call Random.rand32()%10)+7;
>
>         dbg("Boot", "%s Random number 1: %d \n", sim_time_string(), rand1);
>
>     }
> }
>
> But still i am getting the same number always. How to solve this?
>
> Regards,
>
> Jisha Mary Jose
> ......jMj......
>
>
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
>
>
>
>
> --
> Eric B. Decker
> Senior (over 50 :-) Researcher
>
>
>
>
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to