Until the network plugin has been factorized out into a library, it is useful to have some documentation to reimplement it.
- Default UDP port
- Default IPv4 Multicast group
- Default IPv6 multicast group
- Maximum packet size
- 1024 bytes (payload only, not including UDP / IP headers)
Due to a buffer of fixed size inside the Network plugin only the first 1024 bytes of each packet will be received.
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.
There are two part layouts that are used for a couple of “types”: numeric (an 8 byte integer) and string.
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.
Strings are transferred including a null byte at the end. In the example you can see the encoding of the string “foobar”. The string is six characters long, followed by a null-byte and appended to a four byte header, leading to a length of 11 bytes for this part.
The following numeric types are currently used to identify the type of a “part”. Defines are available from src/network.h.
||Signature (HMAC-SHA-256)||other (todo)|
||Encryption (AES-256/OFB/SHA-1)||other (todo)|
- Small Python script by Adrian Perez
- PacketWriter.java of jcollectd
- Of course the network plugin (src/network.c) of collectd itself
- Ruby implementation by Astro.
- Erlang implementation by Astro