nvflare.fuel.f3.sfm.sfm_conn module

class SfmConnection(conn: Connection, local_endpoint: Endpoint)[source]

Bases: object

A wrapper of driver connection.

Driver connection deals with frame. This connection handles messages.

The frame format:

+--------------------------------------------------------+
|                    length (4 bytes)                    |
+----------------------------+---------------------------+
|        header_len (2)      |   type (1)  |  reserved   |
+----------------------------+---------------------------+
|          flags (2)         |        app_id (2)         |
+----------------------------+---------------------------+
|        stream_id (2)       |       sequence (2)        |
+--------------------------------------------------------+
|                        Headers                         |
|                    header_len bytes                    |
+--------------------------------------------------------+
|                                                        |
|                        Payload                         |
|              (length-header_len-16) bytes              |
|                                                        |
+--------------------------------------------------------+
get_name() str[source]
static headers_to_bytes(headers: dict | None) bytes | None[source]
next_sequence() int[source]

Get next sequence number for the connection.

Sequence is used to detect lost frames.

send_data(app_id: int, stream_id: int, headers: dict | None, payload: bytes | bytearray | memoryview | list)[source]

Send user data

send_dict(frame_type: int, stream_id: int, data: dict)[source]

Send a dict as payload

send_frame(prefix: Prefix, headers: dict | None, payload: bytes | bytearray | memoryview | list | None)[source]
send_handshake(frame_type: int)[source]

Send HELLO/READY frame

send_heartbeat(frame_type: int, data: dict | None = None)[source]

Send Ping or Pong