Class BackendLibfabric

Inheritance Relationships

Base Type

Class Documentation

class BackendLibfabric : public netio3::NetworkBackend

The libfabric backend for netio3.

The libfabric backend allows sending data using the libfabric library. It allows using high-performance RDMA operations. The config object passed into the constructor is used to set the mode (TCP or RDMA, RDMA is strongly recommended, for TCP use BackendTcp).

Public Functions

BackendLibfabric(const NetworkConfig &config, std::shared_ptr<BaseEventLoop> evloop)

Constructs a BackendLibfabric object with the specified network configuration and event loop.

The network configuration decides whether RDMA or TCP is used. It also sets up the backend to be thread safe or not. Only use unsafe mode if you are using it in a single threaded environment (that is no user thread interacting with the backend).

Parameters:
  • config – The network configuration

  • evloop – The event loop to use for network operations

virtual void open_send_endpoint(const EndPointAddress &address, const ConnectionParameters &connection_params) override

Opens a send endpoint for the specified address with the given connection parameters.

Depending on the connection parameters either an endpoint for buffered sending (SendSocketBuffered) or for zero-copy sending (SendSocketZeroCopy) is opened.

Throws:
  • InvalidEndpointAddress – if the endpoint address is invalid

  • FailedOpenSendEndpoint – if the send endpoint could not be opened

  • SendEndpointAlreadyExists – if the send endpoint already exists

Parameters:
  • address – The address of the endpoint to open.

  • connection_params – The connection parameters for the endpoint.

virtual EndPointAddress open_listen_endpoint(const EndPointAddress &address, const ConnectionParametersRecv &connection_params) override

Opens a listen endpoint for the specified address with the given connection parameters.

Accepts all incoming connection requests and spawns a ReceiveSocket for each of them. The connection parameters are passed to the spawned receive sockets. If port 0 was passed in, it figures out the port number that was used to open the connection and returns the actual address.

Throws:
  • InvalidEndpointAddress – if the endpoint address is invalid

  • ListenEndpointAlreadyExists – If already requested to listen on this address and port

  • FailedOpenListenEndpoint – if the listen endpoint could not be opened

Parameters:
  • address – The address of the endpoint to open

  • connection_params – The connection parameters for the endpoint

Returns:

The actual address the server is listening on

virtual void close_send_endpoint(const EndPointAddress &address) override

Closes the send endpoint for the specified address.

The endpoint is not closed immediately but is queued to be closed by the event loop for thread synchronization purposes.

Throws:
  • InvalidEndpointAddress – if the endpoint address is invalid

  • UnknownSendEndpoint – if the send endpoint does not exist

  • FailedCloseSendEndpoint – if closing the send socket failed

Parameters:

address – The address of the endpoint to close

virtual void close_listen_endpoint(const EndPointAddress &address) override

Closes the listen endpoint for the specified address.

Also closes all receive sockets that were spawned by this listen socket.

The endpoint is not closed immediately but is queued to be closed by the event loop for thread synchronization purposes.

Throws:
  • InvalidEndpointAddress – if the endpoint address is invalid

  • UnknownListenEndpoint – if the listen endpoint does not exist

Parameters:

address – The address of the endpoint to close

virtual NetioStatus send_data(const EndPointAddress &address, std::span<std::uint8_t> data, std::span<const std::uint8_t> header_data, std::uint64_t key) override

Sends data to the specified address in zero-copy mode.

Copies the header data into a header buffer slot and sends it together with the data to the provided address. The data itself is not copied and has to be inide a registered memory region. The key will be provided on the on_send_completed callback to the user.

Throws:

UnknownSendEndpoint – if the send endpoint does not exist

Parameters:
  • address – The address to send the data to

  • data – The data to send

  • header_data – User data to be added to the header

  • key – Key to be returned in on_send_completed callback

Returns:

The status of the send operation

virtual NetioStatus send_data(const EndPointAddress &address, std::span<const iovec> iov, std::span<const std::uint8_t> header_data, std::uint64_t key) override

Sends data in the iovec vector to the specified address in zero-copy mode.

Copies the header data into a header buffer slot and sends it together with the data to the provided address. The data itself is not copied and has to be inide a registered memory region. The key will be provided on the on_send_completed callback to the user.

Throws:

UnknownSendEndpoint – if the send endpoint does not exist

Parameters:
  • address – The address to send the data to

  • iov – The iovec vector containing the data to send

  • header_data – User data to be added to the header

  • key – Key to be returned in on_send_completed callback

Returns:

The status of the send operation

virtual NetioStatus send_data_copy(const EndPointAddress &address, std::span<const std::uint8_t> data, std::span<const std::uint8_t> header_data, std::uint64_t key) override

Sends data to the specified address copying the data.

Warning

Not implemented for RDMA. Always throws.

Parameters:
  • address – The address to send the data to

  • data – The data to send

  • header_data – User data to be added to the header

  • key – Key to be returned in on_send_completed callback

Throws:

NotSupported – if the function is called

Returns:

The status of the send operation

virtual NetioStatus send_data_copy(const EndPointAddress &address, std::span<const iovec> iov, std::span<const std::uint8_t> header_data, std::uint64_t key) override

Sends data to the specified address in zero-copy mode.

Warning

Not implemented for RDMA. Always throws.

Parameters:
  • address – The address to send the data to

  • iov – The iovec vector containing the data to send

  • header_data – User data to be added to the header

  • key – Key to be returned in on_send_completed callback

Throws:

NotSupported – if the function is called

Returns:

The status of the send operation

virtual NetworkBuffer *get_buffer(const EndPointAddress &address) override

Retrieves a network buffer for the specified endpoint address.

Only works for endpoints that are opened for buffered sending. If no buffer is available returns a nullptr.

@important The user needs to check that the returned buffer is not null.

Throws:
  • UnknownSendEndpoint – if the send endpoint does not exist

  • NoBuffersAllocated – if no buffers were allocated

Parameters:

address – The address of the endpoint to retrieve the buffer for

Returns:

A pointer to the network buffer

virtual NetioStatus send_buffer(const EndPointAddress &address, NetworkBuffer *buffer) override

Sends a network buffer to the specified address.

This function sends the data buffer to the specified endpoint. A connection must be registered for this endpoint before sending data. If the buffer is not a buffer handed out through get_buffer FAILED is returned. The buffer will be returned to the connection after the send operation is completed.

Throws:

UnknownSendEndpoint – if the send endpoint does not exist

Parameters:
  • address – The address to send the buffer to

  • buffer – The network buffer to send

Returns:

The status of the send operation

virtual std::size_t get_num_available_buffers(const EndPointAddress &address) override

Retrieves the number of available buffers for the specified endpoint address.

Returns the number of availble buffers for buffered sending and the number of available header slots for zero-copy sending. Returns the mininum number of available buffers since the last call to this function.

Throws:

UnknownSendEndpoint – if the send endpoint does not exist

Parameters:

address – The address of the endpoint to retrieve the buffer count for

Returns:

The number of available buffers