transports - SkycoinWikis/dmsg GitHub Wiki
HOME » SOFTWARE » DMSG » TRANSPORTS
Transports
Transports are represented by transport IDs and facilitate duplex communication between two dmsg.Client
s 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 connecteddmsg.Server
. The set of transport IDs will be unique between itself and eachdmsg.Server
. - A
dmsg.Server
manages 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
REQUEST
frame with the chosen transport ID, initiating client's public key (itself) and also the responding client's public key. TheREQUEST
frame 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
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 theREQUEST
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. - The responding client receives the
REQUEST
frame and checks the contents. If valid, the responding client sends anACCEPT
frame (containing the same payload as theREQUEST
) back to the common server. The common server changes the transport ID, and forwards theACCEPT
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 anACK
frame with the same sequence as the payload.