-
Notifications
You must be signed in to change notification settings - Fork 43
Dmsg
Distributed messaging system.
-
entity - A service of
dmsg(typically being part of an executable running on a machine). -
entity type - The type of entity.
dmsghas three entity types;dmsg.Server,dmsg.Client,dmsg.Discovery. -
entry - A data structure that describes an entity and is stored in
dmsg.Discoveryfor entities to access. -
frame - The data unit of the
dmsgsystem. -
frame type - The type of
dmsgframe. There are four frame types;REQUEST,ACCEPT,CLOSE,FWD,ACK. -
connection - The direct line of duplex communication between a
dmsg.Serveranddmsg.Client. -
transport - A line of communication between two
dmsg.Clients that is proxied via admsg.Server. - transport ID - A uint16 value that identifies a transport.
The dmsg system is made up of three entity types:
-
dmsg.Discoveryis a RESTful API that allowsdmsg.Clients to find remotedmg.Clients anddmsg.Servers. -
dmsg.Serverproxies frames between clients. -
dmsg.Clientestablishes transports between itself and remotedmsg.Clients.
Entities of types dmsg.Server or dmsg.Client are represented by a secp256k1 public key.
[D]
S(1) S(2)
// \\ // \\
// \\ // \\
C(A) C(B) C(C) C(D)
Legend:
-
[D]-dmsg.Discovery -
S(X)-dmsg.Server -
C(X)-dmsg.Client
A Connection refers to the line of communication between a dmsg.Client and dmsg.Server.
To set up a dmsg Connection, dmsg.Client dials a TCP connection to the dmsg.Server and then they perform a handshake via the noise protocol using the XK handshake pattern (with the dmsg.Client as the initiator).
Note that dmsg.Client always initiates the dmsg connection, and it is a given that a dmsg.Client always knows the public key that identifies the dmsg.Server that it wishes to connect with.
Frames are sent and received within a dmsg connection after the noise handshake. A frame has two sections; the header and the payload. Here are the fields of a frame:
|| FrameType | TransportID | PayloadSize || Payload ||
|| 1 byte | 2 bytes | 2 bytes || ~ bytes ||
- The
FrameTypespecifies the frame type via the one byte. - The
TransportIDcontains an encodeduint16which represents a identifier for a transport. A set of IDs are unique for a givendmsgconnection. - The
PayloadSizecontains an encodeduint16which represents the size (in bytes) of the payload. - The
Payloadhave a size that is obtainable viaPayloadSize.
The following is a summary of the frame types:
| FrameType | Name | Payload Contents | Payload Size |
|---|---|---|---|
0x1 |
REQUEST |
initiating client's public key + responding client's public key | 66 |
0x2 |
ACCEPT |
initiating client's public key + responding client's public key | 66 |
0x3 |
CLOSE |
1 byte that represents the reason for closing | 1 |
0xa |
FWD |
uint16 sequence + transport payload | >2 |
0xb |
ACK |
uint16 sequence | 2 |
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.
please contact support via telegram @skywire
for rewards and technical support