-
Notifications
You must be signed in to change notification settings - Fork 0
protocol definition
RRDTP version 1 is a subscription based data streaming protocol. One host acts as the server, manages the subscriptions, and serves as the authoritative source for all data values. Multiple clients can connect to the server to send and receive updates to data values. Values can be stored hierarchically in categories. Clients will only receive values that they have subscribed to.
Each packet will contain an event type. The currently defined event types are listed below.
- Subscribe (0): the client that this packet was sent from wishes to subscribe to a value.
- Unsubscribe (1): the client that this packet was sent from wishes to unsubscribe from a value.
- Value update (2): sent to indicate that a value was updated. Either a client, or the server can send this type of packet.
Values can be one of 7 types.
- int - signed 32-bit integer
- long - signed 64-bit integer
- float - single precision floating point number
- double - double precision floating point number
- boolean - true/false boolean flag
- string - string (ASCII or UTF8)
- unformatted - plain unformatted data. The calling code is responsible for endianness conversion.
Values are identified by a hierarchical naming scheme similar to Java packages. If the value isn't stored in any category, then it can be referred to simply by its name, such as "value1". If the value is stored within a category and any number of subcategories, then it can be referred to by separating the categories with a period ".", for example "category.sub-category.value1". Valid characters that can be used in category and value names are letters, numbers, underscores "_", and hyphens "-". Identifiers are case insensitive ("Value1" == "VALUE1" == "VaLuE1"). Value identifiers are always specified as ASCII format strings ending in a null terminator.
Each RRDTP packet begins with a header containing the 4-bit protocol version number, and the 4-bit event type (see Events section above). The rest of the packet format depends on the event type.
A "subscribe" packet (0) contains only the value identifier. Subscription packets are only sent from a client to the server. When the server receives the subscription request, it will begin sending value updates to the client the packet was received from. The server will send the current value to the client immediately upon subscription, then will only send the client further updates when the value is actually changed.
An "unsubscribe" packet (1) contains only the packet identifier. Unsubscription packets are only sent from a client to the server. When the server receives the unsubscription request, it simply stops sending value updates for the specified value to the client.
A "value update" packet (2) has a different function depending on where it was sent from. Values are owned by either a client, or the server. The first system to create a value is considered the owner. When the server receives a value update packet from the owning client, the value will be updated on the server and propagated to all other clients. If a client tries to update a value that it doesn't own, then the packet is ignored. The server will send a value update packet to all subscribed clients whenever a value changes. A value update packet contains the packet identifier, the data type ID (4-bits), the size of the data (16-bits), and the data itself.