f4exb / sdrdaemon

Utilities to use a SDR Rx or Tx device remotely over a network via UDP
66 stars 15 forks source link

SDRdaemon

SDRdaemon is going to the end of its life

Soon SDRangel https://github.com/f4exb/sdrangel project is going to take over by absorbing the same functionnality in the form of two new channel plugins. There are many advantages:

Consequently as soon as the new release (4.1) of SDRangel is out this project will be archived.

Introduction

SDRdaemon package can be used to:

sdrdaemonrx is a basic software-defined radio receiver that just sends the I/Q samples over the network via UDP. It was developed on the base of NGSoftFM (also found in this Github repo: https://github.com/f4exb/ngsoftfm) and shares a lot of the code for the interface with the SDR hardware devices.

It conveys meta data in the data flow so that the receiving application is informed about parameters essential to render correctly the data coming next such as the sample rate, the number of bytes used for the samples, the number of effective sample bits, the center frequency... (See the "Data format" chapter for detals).

While running the program accepts configuration commands on a TCP port using nanomsg messages with a content in the same format as the configuration string given on the command line (See the "Running" chapter for details). This provides a dynamic control of the device or features of the application such as the decimation. A Python script is provided to send such messages.

In order to recover possible lost blocks it uses Cauchy MDS Block Erasure codec to encode data with redundancy, It can add a user defined number of redundant block so that if the nominal number of blocks is received (128 blocks) it can recover the lost blocks in any position.

Note that if you set the number of redundant blocks to 0 then no FEC is used.

sdrdaemontx does the same thing as sdrdaemonrx but the other way round. It takes blocks read from UDP possibly with redundant blocks and sends the I/Q data to a SDR transmitter.

Hardware supported:

Receivers:

Transmitters:

SDRdaemon programs can be used conveniently along with SDRangel (found in this Github repo: https://github.com/f4exb/sdrangel) as the client application. So in this remote type of configuration you will need both an angel and a daemon :-)

GNUradio is also supported with a specific sdrdaemonsourcesource block for Rx devices provided in the gr-sdrdaemon OOT module. The sdrdaemonsink sink block for Tx devices does not exist at the moment.

SDRdaemon package requires:

☞ On Raspberry Pi 3 it is recommended to run in a native aarch64 system for better performance. This is particularly true on the Tx side with sdrdaemontx. For the moment only OpenSUSE does that: link.

For the latest version, see https://github.com/f4exb/SDRdaemon

Branches:

Prerequisites

Base requirements

Ubuntu/Debian

OpenSUSE

in particular if you run the aarch64 version with the RPi3. Performance in an aarch64 (ARM 64 bits amrv8) is considerably better than in an armv7 system. This is particularly true with sdradaemontx. Use gcc version 6 to get automatic vectorization.

Do once in the shell where you compile:

You will need to compile and install libnanomsg because it is not available as a package:

Forward Erasure Correction (FEC) support

You have to install CM256cc. You will then have to specify the include and library paths on the cmake command line. Say if you install cm256cc in /opt/install/cm256cc you will have to add -DCM256CC_INCLUDE_DIR=/opt/install/cm256cc/include/cm256cc -DCM256CC_LIBRARIES=/opt/install/cm256cc/lib/libcm256cc.so to the cmake commands.

sdrdaemonrx binary recognizes the configuration commmand fecblk to specify the number of FEC blocks. When fecblk=0 is specified in the commands and hence no FEC blocks are added.

Frames and blocks are numbered and even if no FEC blocks are added this can help in reconstructing frames with appropriate timings.

Airspy support

Airspy support must be installed for SDRdaemon to work with an Airspy device.

If you install from source (https://github.com/airspy/host/tree/master/libairspy) in your own installation path you have to specify the include path and library path. For example if you installed it in /opt/install/libairspy you have to add -DLIBAIRSPY_LIBRARIES=/opt/install/libairspy/lib/libairspy.so -DLIBAIRSPY_INCLUDE_DIR=/opt/install/libairspy/include to the cmake options.

To install the library from a Debian/Ubuntu installation just do:

BladeRF support

BladeRF support must be installed for SDRdaemon to work with a BladeRF device.

If you install from source (https://github.com/Nuand/bladeRF) in your own installation path you have to specify the include path and library path. For example if you installed it in /opt/install/libbladerf you have to add -DLIBBLADERF_LIBRARIES=/opt/install/libbladeRF/lib/libbladeRF.so -DLIBBLADERF_INCLUDE_DIR=/opt/install/libbladeRF/include to the cmake options.

To install the library from a Debian/Ubuntu installation just do:

Note: for the BladeRF to work effectively on FM broadcast frequencies you have to fit it with the XB200 extension board.

HackRF support

HackRF support must be installed for SDRdaemon to work with a HackRF device.

If you install from source (https://github.com/mossmann/hackrf/tree/master/host/libhackrf) in your own installation path you have to specify the include path and library path. For example if you installed it in /opt/install/libhackrf you have to add -DLIBHACKRF_LIBRARIES=/opt/install/libhackrf/lib/libhackrf.so -DLIBHACKRF_INCLUDE_DIR=/opt/install/libhackrf/include to the cmake options.

To install the library from a Debian/Ubuntu installation just do:

RTL-SDR support

The Osmocom RTL-SDR library must be installed before you can use SDRdaemon with a RTL-SDR device. See http://sdr.osmocom.org/trac/wiki/rtl-sdr for more information. SDRdaemon has been tested successfully with RTL-SDR 0.5.3. Normally your distribution should provide the appropriate librtlsdr package. If you go with your own installation of librtlsdr you have to specify the include path and library path. For example if you installed it in -DLIBRTLSDR_LIBRARIES=/opt/install/librtlsdr/lib/librtlsdr.so -DLIBRTLSDR_INCLUDE_DIR=/opt/install/librtlsdr/include to the cmake options

To install the library from a Debian/Ubuntu installation just do:

nanomsg custom installation

If you build nanomsg from source obtained either by git clone or a released source package and install it in your own path (ex: /opt/install/libnanomsg) you will need to specify the include and library paths like this: -DLIBNANOMSG_LIBRARIES=/opt/install/libnanomsg/lib/libnanomsg.so -DLIBNANOMSG_INCLUDE_DIR=/opt/install/libnanomsg/include

Installing

To install SDRdaemon, download and unpack the source code and go to the top level directory. Then do like this:

Compile and install

Running

Rx examples

Typical commands:

Tx examples

Typical commands:

All options

Common configuration option for UDP transmission (sdrdaemonrx, sdrdaemon)

Common configuration option for Forward Erasure Correction (sdrdaemonrx)

Common configuration options for the decimation (sdrdaemonrx, sdrdaemon)

Common configuration options for the interpolation (sdrdaemontx)

Device type specific configuration options

Note that these options can be used both as the initial configuration as the argument of the -c option and as the dynamic configuration sent on the UDP configuration port specified by the -C option.

RTL-SDR

HackRF

Airspy

BladeRF

Test (Rx only)

File sink (Tx only)

Dynamic remote control

SDRdaemon listens on a TCP port (the configuration port) for incoming nanomsg messages consisting of a configuration string as described just above. You can use the utility sdrdmnctl in the bin directory of the installation directory (sits along sdrdaemonrx and other) to send such messages. It defaults to the localhost (127.0.0.1) and port 9091. The configuration string is given as the -c option (same as for sdrdaemon). Example:

/opt/install/sdrdaemon/bin/sdrdmnctl -I 192.168.1.3 -C 9999 -c frequency=433970000

The complete list of options is:

The nanomsg connection is specified as a paired connection (NN_PAIR). The connection can be managed by any program at the convenience of the user as long as the connection type is respected.

Running as a service

Have a look at the service subdirectory.

Data formats

Packaging

The I/Q data is sent in frames of 128 fixed size data blocks including a first block ("block zero") containing only meta data and a variable number of FEC blocks up to 127 FEC blocks. It is possible to use this scheme without FEC in which case no additional FEC blocks are present. All blocks have a fixed size of 512 bytes that represent the UDP payload size. The first 4 bytes are occupied by signalling data consisting of a 2 bytes frame count (wraps around at 65535), a 1 byte block count (0 to 127 (min) or 255 (max)) and a 1 byte filler. The rest is occupied by either the meta data (block zero), actual I/Q samples (127 samples per block resulting in 508 bytes) for data bytes or FEC data. The FEC is calculated on the 128 blocks of 508 bytes of meta data and I/Q samples.

Thus a complete frame contains 127 * 127 = 16129 samples.

Meta data block

The block of "meta" data consists of the following (values expressed in bytes):

Offset Length Type Content
0 4 unsigned integer Center frequency of reception in kHz
4 4 unsigned integer Stream sample rate (Samples/second)
8 1 unsigned char number of bytes per sample. Practically 1 or 2
9 1 unsigned char number of effective bits per sample. Practically 8 to 16
10 1 unsigned char number of (FEC protected) data blocks. Practically 128
11 1 unsigned char number of FEC blocks. Practically 0 to 127
12 4 unsigned integer Seconds of Unix timestamp at the beginning of the sending processing
16 4 unsigned integer Microseconds of Unix timestamp at the beginning of the sending processing
20 4 unsigned integer CRC32 of the above (20 bytes)

Total size is 24 bytes. The 484 (!) remaining bytes are reserved for future use.

GNUradio supoort

The gr-sdrdaemon module is provided in the gr-sdrdaemon subdirectory. This subdirectory is a complete OOT module that can be built independently following GNUradio standards. Please refer to the documentation found in this directory for further information.

License

SDRdaemon, copyright (C) 2015-2017, Edouard Griffiths, F4EXB

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/gpl-2.0.html