mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-03 11:30:53 +00:00
Merge pull request #270 from pabigot/push/trickle-example
examples/trickle-library: correct probability expression
This commit is contained in:
commit
4340b86649
@ -70,7 +70,7 @@ static uip_ipaddr_t ipaddr; /* destination: link-local all-nodes multicast *
|
|||||||
* with probability 1/NEW_TOKEN_PROB. This is controlled by etimer et.
|
* with probability 1/NEW_TOKEN_PROB. This is controlled by etimer et.
|
||||||
*/
|
*/
|
||||||
#define NEW_TOKEN_INTERVAL 10 * CLOCK_SECOND
|
#define NEW_TOKEN_INTERVAL 10 * CLOCK_SECOND
|
||||||
#define NEW_TOKEN_PROB 0x80
|
#define NEW_TOKEN_PROB 2
|
||||||
static uint8_t token;
|
static uint8_t token;
|
||||||
static struct etimer et; /* Used to periodically generate inconsistencies */
|
static struct etimer et; /* Used to periodically generate inconsistencies */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -180,7 +180,7 @@ PROCESS_THREAD(trickle_protocol_process, ev, data)
|
|||||||
} else if(etimer_expired(&et)) {
|
} else if(etimer_expired(&et)) {
|
||||||
/* Periodically (and randomly) generate a new token. This will trigger
|
/* Periodically (and randomly) generate a new token. This will trigger
|
||||||
* a trickle inconsistency */
|
* a trickle inconsistency */
|
||||||
if((random_rand() & NEW_TOKEN_PROB) == 0) {
|
if((random_rand() % NEW_TOKEN_PROB) == 0) {
|
||||||
token++;
|
token++;
|
||||||
PRINTF("At %lu: Generating a new token 0x%02x\n",
|
PRINTF("At %lu: Generating a new token 0x%02x\n",
|
||||||
(unsigned long)clock_time(), token);
|
(unsigned long)clock_time(), token);
|
||||||
|
Loading…
Reference in New Issue
Block a user