transports - SkycoinWikis/dmsg GitHub Wiki
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.Clientmanages the assignment of even transport IDs between itself and each connecteddmsg.Server. The set of transport IDs will be unique between itself and eachdmsg.Server. - A
dmsg.Servermanages the assignment of odd transport IDs between itself and each connecteddmsg.Client. The set of transport IDs will be unique between itself and eachdmsg.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
- The initiating client chooses an even transport ID and forms a
REQUESTframe with the chosen transport ID, initiating client's public key (itself) and also the responding client's public key. TheREQUESTframe is then sent to the common server. The transport ID chosen must be unused between the initiating client and the server. - The common server receives the
REQUESTframe and checks the contents. If valid, and the responding client exists, the server chooses an odd transport ID, swaps this original transport ID of theREQUESTframe 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. - The responding client receives the
REQUESTframe and checks the contents. If valid, the responding client sends anACCEPTframe (containing the same payload as theREQUEST) back to the common server. The common server changes the transport ID, and forwards theACCEPTto 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
FWDpayload has a 2-byte prefix (represented by a uint16 sequence). This sequence is unique per transport. - The destination of the transport, after receiving the
FWDframe, responds with anACKframe with the same sequence as the payload.