Skip to content

Commit

Permalink
Use a more precise seed rather than Unix timestamp in seconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
gamemann committed Apr 25, 2024
1 parent 0b5cb3f commit e1c872c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,17 @@ void *thread_hdl(void *temp)
pckt_len[0] = sizeof(struct ethhdr) + (iph->ihl * 4) + l4_len;
}

// Create timespec for seed.
struct timespec ts = {0};

// Loop.
while (1)
{
// Generate seed for random integers.
seed = time(NULL) ^ count[ti->seq_cnt];
// Retrieve current time.
clock_gettime(CLOCK_BOOTTIME, &ts);

// Generate seed (we use nanoseconds).
seed = ts.tv_nsec;

// Check for random TTL.
if (ti->seq.ip.min_ttl != ti->seq.ip.max_ttl)
Expand Down

0 comments on commit e1c872c

Please sign in to comment.