From f0dcb3c2cec8deb4c07df8293c5cf27bd1400553 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 16 Mar 2012 20:02:53 +0000 Subject: [PATCH] Smooth out random starting timing offsets in OS scan. Previously it was taking a random u8 mod 100, which meant that the numbers 0-55 were 50% more likely to come up than any others. Make it a u16 instead, so that the numbers 0-35 are only about 0.15% more likely. --- FPEngine.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FPEngine.cc b/FPEngine.cc index 00ded7b7c..0951714af 100644 --- a/FPEngine.cc +++ b/FPEngine.cc @@ -1901,7 +1901,7 @@ int FPHost6::schedule() { if (o.debugging > 3) log_write(LOG_PLAIN, "[%s] Slots granted!\n", this->target_host->targetipstr()); this->timedprobes_sent = true; - int whentostart = get_random_u8()%100; + int whentostart = get_random_u16()%100; for (size_t i = 0; i < this->timed_probes; i++) { this->netctl->scheduleProbe(&(this->fp_probes[i]), whentostart + i*100); this->probes_sent++; @@ -2125,7 +2125,7 @@ int FPHost6::schedule() { /* Finally do the actual retransmission. Like the first time, * we schedule them 100ms apart, starting at same random point * between right now and 99ms. */ - int whentostart = get_random_u8()%100; + int whentostart = get_random_u16()%100; for (size_t l = 0; l < this->timed_probes; l++) { this->fp_probes[l].incrementRetransmissions(); this->fp_probes[l].resetTimeSent();