Skip to content

Commit fff2ac3

Browse files
Add data protocol.
1 parent ef84826 commit fff2ac3

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

data_protocol.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Data protocol
2+
3+
The data protocol transmits messages from `publishers` to `subscribers` via a `proxy server` in a broadcasting fashion.
4+
5+
## Transport layer
6+
7+
The transport layer ensures that a message arrives at its destination.
8+
9+
### Socket configuration
10+
11+
A `proxy server` is the transmitting station, it shall offer an XSUBSCRIBER and an XPUBLISHER socket.
12+
The two sockets shall be connected, e.g. via the `zmq.proxy_server` method.
13+
Each of both sockets shall be bound to its own address.
14+
15+
A `Publisher` is a Component, which sends data messages via the data protocol.
16+
It shall have a PUBLISHER socket connecting to the proxy server's XSUBSCRIBER socket.
17+
18+
A `Subscriber` is a Component, which wants to reveice data messages via the data protocol.
19+
It shall have a SUBSCRIBER socket connecting to the proxy server's XPUBLISHER socket.
20+
It should subscribe to the {ref}`Topics <data_protocol.md#topic>` it wants to receive.
21+
22+
:::{note}
23+
Subscribing to a topic in zmq means to subscribe to all topics which **start** with the given topic name!
24+
:::
25+
26+
#### Recommended configuration
27+
28+
It is recommended to have a single program with two proxy servers.
29+
The first one transfers any data and binds its XSUBSCRIBER to port number 11100 and binds its XPUBLISHER to 11099.
30+
The second one transfers log entries and binds to 11098 and 11097, respectively.
31+
32+
33+
## Message format
34+
35+
A Data Protocol Message consists in three or more frames ([#62](https://github.com/pymeasure/leco-protocol/issues/62)):
36+
1. {ref}`data_protocol.md#topic`
37+
2. {ref}`data_protocol.md#header`
38+
3. One or more data frames, the first one is the {ref}`data_protocol.md#content`
39+
40+
### Topic
41+
42+
The topic is the full name of the sending Component. ([#60](https://github.com/pymeasure/leco-protocol/issues/60))
43+
44+
### Header
45+
46+
Similar to the {ref}`control protocol header <control_protocol.md#message-composition>`, the header consists in
47+
1. UUIDv7
48+
2. a one byte `message_type` (`0` not defined, `1` JSON, `>127` user defined)
49+
50+
### Content
51+
52+
#### Log message content
53+
54+
For log messages, the content is a JSON encoded list of:
55+
- `record.asctime`: Timestamp formatted as `'%Y-%m-%d %H:%M:%S'`
56+
- `record.levelname`: Logger level name
57+
- `record.name`: Logger name
58+
- `record.text` (including traceback)

index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
messages
1717
network-structure
1818
control_protocol
19+
data_protocol
1920
glossary
2021
Hello_world
2122
appendix

0 commit comments

Comments
 (0)