Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"uncompressable" data sequence

I would like to generate an "uncompressable" data sequence of X MBytes through an algorithm. I want it that way in order to create a program that measures the network speed through VPN connection (avoiding vpn built-in compression).

Can anybody help me? Thanks!

PS. I need an algorithm, I have used a file compressed to the point that cannot be compressed anymore, but now I need to generate the data sequence from scratch programatically.

like image 359
Tate Avatar asked Feb 07 '12 22:02

Tate


2 Answers

White noise data is truly random and thus incompressible.

Therefore, you should find an algorithm that generates it (or an approximation).

Try this in Linux:

# dd if=/dev/urandom bs=1024 count=10000 2>/dev/null | bzip2 -9 -c -v > /dev/null
(stdin): 0.996:1, 8.035 bits/byte, -0.44% saved, 10240000 in, 10285383 out.

You might try any kind of random number generation though...

like image 57
Kris Avatar answered Sep 28 '22 10:09

Kris


One simple approach to creating statistically hard-to-compress data is just to use a random number generator. If you need it to be repeatable, fix the seed. Any reasonably good random number generator will do. Ironically, the result is incredibly compressible if you know the random number generator: the only information present is the seed. However, it will defeat any real compression method.

like image 45
Jon Skeet Avatar answered Sep 28 '22 11:09

Jon Skeet