kymux is a library that provides a QUIC proxy for Kyber components. Components must use Kymux to communicate over the network, within a single QUIC connection.
Here is an overview of the components interaction:
+----------+ +-----+
| AvServer |<----. .----> | VLC |
+----------+ | IPC | +-----+
| |
+----------+ '--> +-------+ +-------+ <-' +-----+
| AvServer |<-------> | KYMUX |<==============>| KYMUX | <------> | VLC |
+----------+ .--> +-------+ QUIC +-------+ <-. +-----+
| |
+-------------+ | IPC | +-------------+
| InputServer |<--' '-> | InputServer |
+-------------+ +-------------+
Multiples parts are involved:
Kymux: Manage the Quic connection, and provide an higher level API on top of it. Open the required streams and makeLocal Kymux client<->Quic streamtransport. Once Quic connection has been established, each side of the connection has aKymuxinstance, and can register one or moreEndpoint.Endpoint: A logical Kymux stream that is produced and/or consumed by a Kyber component, like AvServer or InputServer. Each component must open an IPC connection toKymuxto interact with theEndpoint.Kymux URI: Components get akymux://URI that describes how to connect toKymux, and theEndpointthat will be linked with the IPC stream.Local Kymux client: A component that is connected toKymux, using aKymux URI.ControlChan: The first Quic stream opened automatically during connection workflow. In charge of authentication,Endpointregistration.
- kymux: The
kymuxlibrary that handle the Quic connection and the interaction withLocal Kymux client. - kymux/examples: A complete example that uses kymux to create a Quic connection, create endpoint and uses kymux_client to produce and consume data.
- kynet: A network transport API for QUIC and WebTranrpot
- kyproto: A media transport API to transmit video, audio and input packets
- kycom: An IPC component to expose kyproto endpoints over a local IPC (TCP) connection
Desktop Browser
(non-WASM) (WASM)
|| ||
\/ ||
+-------+ ||
IPC | kycom | ||
+-------+ ||
| ||
v \/
+---------------+
| kyproto | media transport API
+---------------+
|
v
+---------------+
| kynet | network transport API
+---------------+
Roles
- Listener: The side that listen for incoming connections
- Initiatior: The side that connects to the listener
Steps
- The listener waits for Quic incoming connection
- The initiatior connects to the listener. At this point, no Quic stream is opened.
- The initiator opens a bidirectional Quic stream (the
ControlChan) and sends anAuthenticatepacket on it. TheAuthenticatepacket allows the listener to detect theControlChanopening, and to accept or reject the connection.
After step 3, the Quic connection is established, with a working ControlChan, and the initiator has been authenticated by the listener.
Each side of the Kymux connection can register its own Endpoint. It is done by sending a RegisterEndpoint on the ControlChan. The registration is synchronous: the peer must reply with a EndpointRegistered packet to notify that the registration is complete.
The Endpoint id is a u64 that is randomly generated by the peer that registers the Endpoint.
sequenceDiagram
participant A
participant B
A->>B: RegisterEndpoint(id)
activate A
B-->>A: EndpointRegistered(id)
deactivate A
At this point, no Quic stream has been created, but Kymux URI can be crafted and sent to other components to interact with the Endpoint.
Now that a component gets a Kymux URI, it can connect to Kymux. The IPC connections triggers the QUIC stream opening. Once both sides of the Endpoint gets a Local Kymux client connected, the global forward process is started.
Steps
Aside:Local Kymux clientconnects to theEndpointusing aKymux URI. BecauseKymuxlisten on a single TCP socket, theEndpointmust be sent after the local TCP connection has been established. At this point,Kymuxcan do theLocal Kymux client<->Endpointmapping.Local Kymux clientwaits to receive a single byte that will mean that the connection withB'sLocal Kymux clienthas been established.Aside:Kymuxopens a Quic stream and sends aStreamOpened(endpoint_id, stream_id)on theControlChan. The message allowsBto map correctly the new Quic stream to the correctEndpoint.Aside:Kymuxsends aClientConnected(endpoint_id)to notify that itsLocal Kymux clientis connected.Bside:KymuxreceivesStreamOpened(endpoint_id, stream_id)on theControlChanand detected that Quic streamstream_idhas been opened.Bside:Local Kymux clientconnects to theEndpointusing aKymux URIBside:Kymuxsends aClientConnected(endpoint_id)to notify that itsLocal Kymux clientis connected.Bside:Kymuxsends a single byte to theLocal Kymux clientto notify that the connection has been established. The forwarding tasks are started at this point.Aside:Kymuxsends a single byte to theLocal Kymux clientto notify that the connection has been established. The forwarding tasks are started at this point.
sequenceDiagram
participant A Local client
participant A
participant B
participant B Local client
A Local client->>A: TCP connect
A-->B: Open QUIC stream(stream_id)
A->>B: StreamOpened(endpoint_id, stream_id)
A->>B: ClientConnected(endpoint_id)
B Local client->>B: TCP connect
B->>A: ClientConnected(endpoint_id)
B->>B Local client: Sync byte
A->>A Local client: Sync byte
loop Data forward
A Local client-->>A: Bytes
A-->>B: Bytes
B-->>B Local client: Bytes
B Local client-->>B: Bytes
B-->>A: Bytes
A-->>A Local client: Bytes
end