|
|
@@ -31,28 +31,22 @@ Design Philosophy
|
|
|
System Layers
|
|
|
-------------
|
|
|
|
|
|
-1. Connection Layer:
|
|
|
+1. Connection Layer
|
|
|
|
|
|
Handle TCP and WebSocket connections, encode/decode MQTT packets.
|
|
|
|
|
|
-2. Session Layer:
|
|
|
+2. Session Layer
|
|
|
|
|
|
Process MQTT PUBLISH/SUBSCRIBE Packets received from client, and deliver MQTT messages to client.
|
|
|
|
|
|
-3. PubSub Layer:
|
|
|
+3. PubSub Layer
|
|
|
|
|
|
Dispatch MQTT messages to subscribers in a node.
|
|
|
-
|
|
|
-4. Routing(Distributed) Layer:
|
|
|
+
|
|
|
+4. Routing(Distributed) Layer
|
|
|
|
|
|
Route MQTT messages between clustered nodes.
|
|
|
|
|
|
-.. code::
|
|
|
-
|
|
|
- -------------- ----------- ---------- ----------
|
|
|
- Client --> | Connection | --> | Session | --> | PubSub | --> | Router |
|
|
|
- -------------- ----------- ---------- ----------
|
|
|
-
|
|
|
----------------
|
|
|
Connection Layer
|
|
|
----------------
|
|
|
@@ -132,13 +126,12 @@ PacketId and MessageId
|
|
|
|
|
|
The 16bits PacketId is defined by MQTT Protocol Specification, used by client/server to PUBLISH/PUBACK packets. A GUID(128bits globally unique Id) will be generated by the broker and assigned to a MQTT message.
|
|
|
|
|
|
-Format of the globally unique message id:
|
|
|
+Format of the globally unique message id::
|
|
|
|
|
|
-+------------------------+----------------+------------+
|
|
|
-| Timestamp | NodeID + PID | Sequence |
|
|
|
-+------------------------+----------------+------------+
|
|
|
-| <-------64bits-------> | <---48bits---> | <-16bits-> |
|
|
|
-+------------------------+----------------+------------+
|
|
|
+ --------------------------------------------------------
|
|
|
+ | Timestamp | NodeID + PID | Sequence |
|
|
|
+ |<------- 64bits ------->|<--- 48bits --->|<- 16bits ->|
|
|
|
+ --------------------------------------------------------
|
|
|
|
|
|
1. Timestamp: erlang:system_time if Erlang >= R18, otherwise os:timestamp
|
|
|
2. NodeId: encode node() to 2 bytes integer
|