gr_compression - compressing gnuradio sample data for files, sockets

Questions, comments: j c o o l e y (at) m e d i a (dot) m i t (dot) e d u
<-- back

The socket extension works... but... you need a fast network connection (gigabit ethernet, probably). A lossless compression method is needed and useful, both for capturing sample data to files and for streaming sample data across a network. (See previous experiment, gr_socket, for the non-compressed version).

compressing sample data for files

First, I tried compressing data into a file in realtime. This is pretty straightforward, and the file can be played back. A very rough guess of data rate is that the compressed file grows at no more than 2MB/sec given that that the usrp, with decimation for wideband fm, outputs at 256kHz/sec. This is a quick and dirty way to achieve this:

We make two utility fifos. You can name them anything, and/or just use one. I just used two in the present directory by default:

#> mkfifo testfifo
#> mkfifo testfifo2

Then, you can use pipes to compress in realtime. Start up the compressor:

#> cat testfifo | gzip -c > testout.gz

Start the gnuradio "client":

When you're done, it's time to decompress. Kill the compressor, and gnuradio, start up decompression:

#> gzip -cd testout.gz > testfifo2

Then, start gnuradio

Given my guess at how fast the file grows, this should work with a 10Mbit connection.

compressing sample data for sockets

Using the same scheme, here's a quick and dirty way of compressing for sockets. First, we setup fifos in linux in order to serve as the "file" output. The defaults for the client and server are testfifo and testfifo2 respectively, but you can name them anything and specify the choice on the command line.

On the client, issue:

#> mkfifo testfifo

And, on the server, issue:

#> mkfifo testfifo2

Next, we can setup the net connection. This can be done in many ways, here's a way to do it on the command-line:

On the server, issue:

#> nc -l -p 8881 | gzip -dc | testfifo2

This assumes you have netcat installed, are using port 8881, and have named your fifo testfifo2 in the current directory

On the client, issue:

#> cat testfifo | gzip -c | nc 192.168.1.1 8881

Fill in your ip and port above.

Next, it's time to start the gnuradio "client" and "server". These are the same scripts as the ones above.

That works, though on my client machine, gzip really maxes out cpu time. On the server, a dual-processor machine, there is no problem. The output sounds choppy, probably due to my stressed client machine. It may be possible to compile in some optimizations to gzip, or come up with a better compression scheme.