|
| 1 | +# Unit Transport Protocol (uTP) |
| 2 | + |
| 3 | +## About uTP |
| 4 | +The uTP (unit Tranport Protocol) specification defines the Client Server message transport protocol. It is light weight, open, simple and designed for communication in Machine to Machine (M2M) and Internet connected devices (IoT) contexts. The uTP protocol runs over TCP/IP, WebSocket, GRPC or other network protocols that provide bi-directional connections. |
| 5 | + |
| 6 | +## Message Flow |
| 7 | +An application transport the data by uTP across network, it contains payload data, delivey mode and topic with optional collection of properties. |
| 8 | + |
| 9 | +### Client |
| 10 | +A Client opens the network connection to the Server using TCP/IP, WebSocket, GRPC or other bi-direction network protocols. |
| 11 | +- Pubslihes Application Mesasges to a topic that other Clients subscribes in. |
| 12 | +- Subscribes to a topic to receive Application Messages. |
| 13 | +- Unsubcribe to remove a topic subscription. |
| 14 | +- Closes the network connection to the Server. |
| 15 | + |
| 16 | +### Server |
| 17 | +- Accepts the network connections from Clients. |
| 18 | +- Recieves and store Application Messages published by Clients. |
| 19 | +- Processes topic subscription requests from Clients. |
| 20 | +- Route Application Messages that match Client subscriptions. |
| 21 | +- Closes the network connection from the Client. |
| 22 | + |
| 23 | +## Application Message |
| 24 | +The Application Messages are transported between Client and Server in the form of data Packets. A data Packet consist of Fixed Header and a uTP Message Type defined in the specification. |
| 25 | + |
| 26 | +### Fixed Header |
| 27 | +Each uTP data packet contains a Fixed Header as shown below: |
| 28 | + |
| 29 | +| Name | Type | |
| 30 | +| :--- | :--- | |
| 31 | +| MessageType | enum | |
| 32 | +| MessageLength | int32 | |
| 33 | + |
| 34 | +### Message Type |
| 35 | + |
| 36 | +| Name | Value | Direction of Flow | |
| 37 | +| :--- | :--- | :--- | |
| 38 | +| RERSERVED | 0 | Forbidden | |
| 39 | +| CONNECT | 1 | Client to Server | |
| 40 | +| CONNACK | 2 | Server to Client | |
| 41 | +| PUBLISH | 3 | Client to Server or Server to Client | |
| 42 | +| PUBNEW | 4 | Server to Client | |
| 43 | +| PUBRECEIVE | 5 | Client to Server | |
| 44 | +| PUBRECEIPT | 6 | Client to Server or Server to Client | |
| 45 | +| PUBCOMPLETE | 7 | Client to Server or Server to Client | |
| 46 | +| SUBSCRIBE | 8 | Client to Server | |
| 47 | +| SUBACK | 9 | Server to Client | |
| 48 | +| UNSUBSCRIBE | 10 | Client to Server | |
| 49 | +| UNSUBACK | 11 | Server to Client | |
| 50 | +| PINGREQ | 12 | Client to Server | |
| 51 | +| PINGRESP | 13 | Server to Client | |
| 52 | +| DISCONNECT | 14 | Client to Server or Server to Client | |
| 53 | + |
| 54 | +## Delivery Mode |
| 55 | +The uTP delivers Application Messages as per the Delivery Mode defined in the publish and subscribe Message type. The Client and Server both can be a publisher or subcriber of messages. |
| 56 | +Th Delivery Mode in the oubound Application Message to the Client could differ from that of inbound Application Message. |
| 57 | + |
| 58 | +### Express Delivery |
| 59 | +The Express Delivery Mode ensures that the Application Message arrives at the receiver at least once. An Express Delivery Mode PUBLISH Message has a Message Identifier and get the receipt acknowledgement by a PUBRECEIPT Message. |
| 60 | + |
| 61 | +In the Express Delivery Mode, the sender |
| 62 | +- Must send a PUBLISH Message containing a Message Identifier with Delivery Mode Express |
| 63 | +- Must treat a PUBLISH Message as "unacknowledged" until it has received the corresponding PUBCOMPLETE Message from the receiver. |
| 64 | + |
| 65 | +A sender is permitted to send further PUBLISH Messages with different Message Identifier while it is waiting to receive publish receipts. |
| 66 | + |
| 67 | +In the Express Delivery Mode, the receiver |
| 68 | +- Must respond with a PUBCOMPLETE Message containing the Message Identifier from the incoming PUBLISH Message. |
| 69 | + |
| 70 | +### Reliable Delivery |
| 71 | +The Reliable Delivery Mode ensures no duplication of Application Messages delivered to the receivers. There is an increased overhead associated to the Reliable Delivery Mode. |
| 72 | + |
| 73 | +### Inbound Message Flow from a Client |
| 74 | +In the Reliable Delivery Mode, the sender |
| 75 | +- Must send a PUBLISH Message containing a Message Identifier with Delivery Mode Reliable |
| 76 | +- Must treat a PUBLISH Message as "unacknowledged" until it has received the corresponding PUBRECEIPT Message from the receiver. |
| 77 | +- Must send a PUBCOMPLETE Message when it receive a PUBRECEIPT Message from the receiver. This PUBCOMPLETE Message must contain the same Message Identifier from original PUBLISH Message. |
| 78 | +- Must NOT re-send the PUBLISH Message once it has received the corresponding PUBRECEIPT Message. |
| 79 | + |
| 80 | +A sender is permitted to send further PUBLISH Messages with different Message Identifier while it is waiting to receive publish receipts. |
| 81 | + |
| 82 | +In the Reliable Delivery Mode, the receiver |
| 83 | +- Must respond with a PUBRECEIPT containing the Message Identifier from the incoming PUBLISH Message. |
| 84 | +- Until it has received a corresponding PUBCOMPLETE Message, the receiver MUST acknowledge any subsequent PUBLISH Message with the same Message Identifier by sending a PUBRECEIPT Message. |
| 85 | + |
| 86 | +### Outbound Message Flow to the Client |
| 87 | +In the Reliable Delivery Mode, the sender |
| 88 | +- Must send a PUBNEW Message containing a Message Identifier |
| 89 | +- Must send PUBLISH Message when it receive a PUBRECEIVE Packet from the receiver. This PUBLISH Message must conrain the same Message Identifier from PUBNEW Message. |
| 90 | +- Must treat a PUBLISH Message as "unacknowledged" until it has received the corresponding PUBRECEIPT Message from the receiver. |
| 91 | +- Must send a PUBCOMPLETE Message when it receive a PUBRECEIPT Message from the receiver. This PUBCOMPLETE Message must contain the same Message Identifier from original PUBNEW Message. |
| 92 | +- Must NOT re-send the PUBLISH Message once it has received the corresponding PUBRECEIPT Message. |
| 93 | + |
| 94 | +A sender is permitted to send further PUBLISH Messages with different Message Identifier while it is waiting to receive publish receipts. |
| 95 | + |
| 96 | +In the Reliable Delivery Mode, the receiver |
| 97 | +- Must respond with a PUBRECEIVE containing the Message Identifier from the incoming PUBNEW Message. |
| 98 | +- Must respond with a PUBRECEIPT Message when it receive a PUBLISH Message from the sender containing the Message Identifier from the incoming PUBNEW Message. |
| 99 | +- Until it has received a corresponding PUBCOMPLETE Message, the receiver MUST acknowledge any subsequent PUBLISH Message with the same Message Identifier by sending a PUBRECEIPT Message. |
| 100 | + |
0 commit comments