Class NetioSender

Nested Relationships

Nested Types

Class Documentation

class NetioSender

The sender class is responsible for sending data to a receiver.

The sender has three different set of send functions:

  • send_data: sends a block of data to a receiver copying data into a buffer

  • buffered_send_data: sends a block of data to a receiver, but buffers the data

  • zero_copy_send_data: sends a block of data to a receiver without copying data

All send functions come in two variants: One taking a span of data, the other one a vector of iov structs.

Public Functions

explicit NetioSender(const NetioSenderConfig &config, std::shared_ptr<BaseEventLoop> evloop, const std::optional<std::string> &local_ip = std::nullopt)

Constructor for the NetioSender.

Parameters:
  • config – configuration of the network backend and buffering

  • evloop – pointer to the event loop that schedules netio ops

  • local_ip – optional local IP address to bind to, if not provided the backend will choose

NetioSender(const NetioSender&) = delete
NetioSender(const NetioSender&&) = delete
NetioSender() = delete
NetioSender &operator=(const NetioSender&) = delete
NetioSender &operator=(const NetioSender&&) = delete
~NetioSender() = default
Connection &open_connection(const EndPointAddress &ep)

Open a connection to a remote endpoint.

This method may return before the connection to the remote endpoint is established. The user can be notified when the connection has been established by setting the appropriate callback.

Parameters:

ep – Remote endpoint to connect to

Throws:

FailedOpenSendEndpoint – or other exceptions from backend

Returns:

Reference to the connection object

void close_connection(const EndPointAddress &ep)

Close a connection to a remote endpoint.

Success will be reported by the on_connection_closed callback.

Parameters:

ep – Remote endpoint to disconnect from

NetioStatus send_data(const EndPointAddress &ep, uint64_t tag, std::span<const uint8_t> data, uint8_t user_status = 0)

Send data to a remote endpoint.

Parameters:
  • ep – Endpoint to send the data to

  • tag – Tag identifying the data

  • data – Descriptor of the data to send

  • user_status – User supplied status code to be added to header

Return values:
  • NetioStatus::OK – The data have been succefully queued for sending

  • NetioStatus::NO_RESOURCES – No data buffers are currently availabe, try again later.

  • NetioStatus::FAILED – Data do not fit in send buffer or some other error occurred in the backend, a retry will not work

NetioStatus send_data(const EndPointAddress &ep, uint64_t tag, std::span<const iovec> data, uint8_t user_status = 0)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus send_data(Connection &con, uint64_t tag, std::span<const uint8_t> data, uint8_t user_status = 0)

Send to the ep given by the existing connection con. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus send_data(Connection &con, uint64_t tag, std::span<const iovec> data, uint8_t user_status = 0)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus send_data(const EndPointAddress &ep, uint64_t tag, std::span<const std::span<const uint8_t>> data, uint8_t user_status = 0)

Send data to a remote endpoint.

Uses buffers for libfabric and copies for asynvmsg.

Parameters:
  • ep – Endpoint to send the data to

  • tag – Tag identifying the data

  • data – Vector of messages to be sent

  • user_status – User supplied status code to be added to header

Return values:
  • NetioStatus::OK – The data have been succefully queued for sending

  • NetioStatus::NO_RESOURCES – No data buffers are currently availabe, try again later.

  • NetioStatus::FAILED – Data do not fit in send buffer or some other error occurred in the backend, a retry will not work

NetioStatus send_data(Connection &con, const EndPointAddress &ep, uint64_t tag, std::span<const std::span<const uint8_t>> data, uint8_t user_status = 0)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus buffered_send_data(const EndPointAddress &ep, uint64_t tag, std::span<const iovec> data, uint8_t user_status = 0)

Send data to a remote endpoint in buffered mode.

Copy the data into a network buffer. If there is insufficient space in the current buffer, the current buffer will be sent and a new one allocated. The current buffer will be sent when it is full or after the flush interval has elapsed.

Parameters:
  • ep – Endpoint to send the data to

  • tag – Tag identifying the data

  • data – Data to be sent

  • user_status – User supplied status code to be added to header

Return values:
  • NetioStatus::OK – The data have been succefully queued for sending

  • NetioStatus::NO_RESOURCES – No data buffers are currently availabe, try again later.

  • NetioStatus::FAILED – Data do not fit in send buffer or some other error occurred in the backend, a retry will not work

NetioStatus buffered_send_data(const EndPointAddress &ep, uint64_t tag, std::span<const uint8_t> data, uint8_t user_status = 0)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus buffered_send_data(Connection &con, uint64_t tag, std::span<const iovec> data, uint8_t user_status = 0)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus buffered_send_data(Connection &con, uint64_t tag, std::span<const uint8_t> data, uint8_t user_status = 0)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus zero_copy_send_data(const EndPointAddress &ep, std::uint64_t tag, std::span<const iovec> iov, uint8_t user_status, std::uint64_t key)

Send data to a remote endpoint in zero-copy mode.

Copies the user status into a header buffer slot and sends it together with the data to the provided address. The data itself is not copies and and has to be inside a registered memory region.

Parameters:
  • ep – Endpoint to send the data to

  • tag – Tag identifying the data

  • iov – iovec describing the data to be sent

  • user_status – User supplied status code to be added to header

  • key – Key provided in on_send_completed callback

Return values:
  • NetioStatus::OK – The data have been succefully queued for sending

  • NetioStatus::NO_RESOURCES – No data buffers are currently availabe, try again later.

  • NetioStatus::FAILED – Data do not fit in send buffer or some other error occurred in the backend, a retry will not work

NetioStatus zero_copy_send_data(const EndPointAddress &ep, std::uint64_t tag, std::span<std::uint8_t> data, uint8_t user_status, std::uint64_t key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus zero_copy_send_data(Connection &con, std::uint64_t tag, std::span<const iovec> iov, uint8_t user_status, std::uint64_t key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus zero_copy_send_data(Connection &con, std::uint64_t tag, std::span<std::uint8_t> data, uint8_t user_status, std::uint64_t key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

NetioStatus flush_buffer(const EndPointAddress &ep)

Flush current buffer for given endpoint.

Parameters:

ep – Endpoint whose buffer is to be flushed

Returns:

NetioStatus Status of sending the buffer

std::vector<BufferStats> get_num_available_buffers()

Get the number of available buffers for all endpoints.

Returns:

the statistics

void set_on_connection_established(const OnConnectionEstablishedSimpleCb &cb)

Set a callback function to be called when connection is established.

Parameters:

cb – Callback function to be called

void set_on_connection_refused(const OnConnectionRefusedCb &cb)

Set a callback function to be called when connection is refused.

Parameters:

cb – Callback function to be called

void set_on_connection_closed(const OnConnectionClosedCb &cb)

Set a callback function to be called when connection is closed.

Parameters:

cb – Callback function to be called

void set_on_connection_closed_internal(const OnConnectionClosedKeysCb &cb)

Set a callback function to be called when connection is closed.

Also get the keys of pending send operations for zero-copy sending. To be used by the publisher and not end users.

Parameters:

cb – Callback function to be called

void set_on_send_completed(const OnSendCompleted &cb)

Set a callback function to be called whenever a data send operation cmpletes.

Parameters:

cb – Callback function to be called

class Connection

Wrapper struct around a connection.

Public Functions

explicit Connection(NetioSender *sender, EndPointAddress ep, bool thread_safe, BaseEventLoop *evloop)

Construct a new Connection object.

Parameters:
  • sender – Pointer to the NetioSender object

  • ep – Remote endpoint to connect to

  • thread_safe – Whether the connection is supposed to be thread safe

  • evloop – Pointer to the event loop

Connection(const Connection&) = delete
Connection(Connection&&) = delete
Connection() = delete
Connection &operator=(const Connection&) = delete
Connection &operator=(Connection&&) = delete
~Connection() = default
inline const EndPointAddress &get_endpoint() const

Get the endpoint of the connection.

Returns:

The endpoint of the connection