Support for netmap

Introduction

As an experimental feature, it is possible to use the netmap framework to receive packets at a higher rate than is possible with the regular sockets API. This is particularly useful for small packets.

This is not for the faint of heart: it requires root access, it can easily hang the whole machine, and it imposes limitations, including:

  • Only the C++ API is supported. If you need every drop of performance, you shouldn’t be using Python anyway.
  • Only Linux is currently tested. It should be theoretically possible to support FreeBSD, but you’re on your own (patches welcome).
  • Only IPv4 is supported.
  • Fragmented IP packets, and IP headers with optional fields are not supported.
  • Checksums are not validated (although possibly the NIC will check them).
  • Only one reader is supported per network interface.
  • All packets that arrive with the correct UDP port will be processed, regardless of destination address. This could mean, for example, that unrelated multicast streams will be processed even though they aren’t wanted.

Usage

Once netmap is installed and the header file net/netmap_user.h is placed in a system include directory, pass NETMAP=1 to make to include netmap support in the library.

Then, instead of spead2::recv::udp_reader, use spead2::recv::netmap_udp_reader.

class spead2::recv::netmap_udp_reader

Inherits from spead2::recv::reader

Public Functions

netmap_udp_reader(stream &owner, const std::string &device, uint16_t port)

Constructor.

Parameters
  • owner: Owning stream
  • device: Name of the network interface e.g., eth0
  • port: UDP port number to listen to