Difference between revisions of "Binary protocol"

From collectd Wiki
Jump to: navigation, search
(Protocol structure: Add information about integer parts.)
(Part types: Add section.)
Line 18: Line 18:
 
[[Image:Binary protocol part number.png|thumb|Structure of the “number” parts]]
 
[[Image:Binary protocol part number.png|thumb|Structure of the “number” parts]]
 
Numeric integer values, e. g. the ''interval'' and ''time'' values, are transferred using 8 byte integers. The ''length'' field of those parts must therefore always be set to ''12''.
 
Numeric integer values, e. g. the ''interval'' and ''time'' values, are transferred using 8 byte integers. The ''length'' field of those parts must therefore always be set to ''12''.
 +
 +
== Part types ==
 +
 +
The following numeric types are currently used to identify the type of a “part”. Defines are available from {{GitFile|src/network.h}}.
 +
 +
{| class="with_background"
 +
|-
 +
! ID
 +
! Name
 +
! Data type
 +
|-
 +
| <code>0x0000</code>
 +
| Host
 +
| String
 +
|-
 +
| <code>0x0001</code>
 +
| Time
 +
| Integer (8&nbsp;byte)
 +
|-
 +
| <code>0x0002</code>
 +
| Plugin
 +
| String
 +
|-
 +
| <code>0x0003</code>
 +
| Plugin instance
 +
| String
 +
|-
 +
| <code>0x0004</code>
 +
| Type
 +
| String
 +
|-
 +
| <code>0x0005</code>
 +
| Type instance
 +
| String
 +
|-
 +
| <code>0x0006</code>
 +
| Values
 +
| ''other'' '''(todo)'''
 +
|-
 +
| <code>0x0007</code>
 +
| Interval
 +
| Integer (8&nbsp;byte)
 +
|-
 +
| <code>0x0100</code>
 +
| Message (notifications)
 +
| String
 +
|-
 +
| <code>0x0101</code>
 +
| Severity
 +
| Integer (8&nbsp;byte)
 +
|-
 +
|}
  
 
==Implementations==
 
==Implementations==

Revision as of 21:40, 27 April 2009

Until the network plugin has been factorized out into a library, it is useful to have some documentation to reimplement it.

Well-known numbers

Default UDP port
25826
Default IPv4 Multicast group
239.192.74.66
Default IPv6 multicast group
ff18::efc0:4a42

Protocol structure

Beginning of each “part”: Type and length.

Each packet consists of one or more so called “parts”. Each part starts with the same four bytes: Two bytes that specify the “part type” (what kind of information is enclosed in the part) and two bytes which specify the length of the part, including the four header bytes itself. The maximum length of payload in any part is therefore 65531 bytes.

Using this layout, clients can determine the length of a part they don't know and lets them skip unknown data. This makes the protocol forward compatible so that new features can be added easily.

Structure of the “number” parts

Numeric integer values, e. g. the interval and time values, are transferred using 8 byte integers. The length field of those parts must therefore always be set to 12.

Part types

The following numeric types are currently used to identify the type of a “part”. Defines are available from src/network.h.

ID Name Data type
0x0000 Host String
0x0001 Time Integer (8 byte)
0x0002 Plugin String
0x0003 Plugin instance String
0x0004 Type String
0x0005 Type instance String
0x0006 Values other (todo)
0x0007 Interval Integer (8 byte)
0x0100 Message (notifications) String
0x0101 Severity Integer (8 byte)

Implementations

See also