transports - SkycoinWikis/dmsg GitHub Wiki

dmsg HOME » SOFTWARE » DMSG » TRANSPORTS

Transports

Transports are represented by transport IDs and facilitate duplex communication between two dmsg.Clients which are connected to a common dmsg.Server.

Transport IDs are assigned in such a manner:

  • A dmsg.Client manages the assignment of even transport IDs between itself and each connected dmsg.Server. The set of transport IDs will be unique between itself and each dmsg.Server.
  • A dmsg.Server manages the assignment of odd transport IDs between itself and each connected dmsg.Client. The set of transport IDs will be unique between itself and each dmsg.Client.

For a given transport:

  • Between the initiating client and the common server - the transport ID is always a even value.
  • Between the responding client and the common server - the transport ID is always a odd value.

Hence, a transport in it's entirety, is represented by 2 transport IDs.

Transport Establishment

  1. The initiating client chooses an even transport ID and forms a REQUEST frame with the chosen transport ID, initiating client's public key (itself) and also the responding client's public key. The REQUEST frame is then sent to the common server. The transport ID chosen must be unused between the initiating client and the server.
  2. The common server receives the REQUEST frame and checks the contents. If valid, and the responding client exists, the server chooses an odd transport ID, swaps this original transport ID of the REQUEST frame with the chosen odd transport ID, and continues to forward it to the responding client. In doing this, the server records a rule relating the initiating/responding clients and the associated odd/even transport IDs.
  3. The responding client receives the REQUEST frame and checks the contents. If valid, the responding client sends an ACCEPT frame (containing the same payload as the REQUEST) back to the common server. The common server changes the transport ID, and forwards the ACCEPT to the initiating client.

On any step, if an error occurs, any entity can send a CLOSE frame.

Acknowledgement Logic

Each FWD frame is to be met with an ACK frame in order to be considered delivered.

  • Each FWD payload has a 2-byte prefix (represented by a uint16 sequence). This sequence is unique per transport.
  • The destination of the transport, after receiving the FWD frame, responds with an ACK frame with the same sequence as the payload.