pflarue / ardop

Source for various version of ARDOP
Other
23 stars 4 forks source link

Seed the pseudo-random number generator #39

Closed pflarue closed 1 month ago

pflarue commented 1 month ago

For testing purposes frames containing random data can be produced using the TXFRAME host command. However, when this feature was added, seeding of the pseudo-random number generator was not implemented, so it always produced the same "random" data. srand(time(0)) is commonly used to provide a time dependent seed. However, time(0) changes only once per second, so running ardopcf more than once per second, which might occur during testing, would produce duplicate values. So, gettimeofday(), with microsecond resolution is used instead.