Decide on the wire protocol for VyConf
Closed, ResolvedPublic

Description

The vyconf daemon needs to communicate to its clients, and we need to decide on the wire protocol for this communication.

Some considerations:
First, since we need to support arbitrary length messages (e.g. "run show configuration commands", or configs, they may be quite huge for big setups), we cannot easily use anything as simplistic as reading until \n or null byte or similar. The delimiter-based approach would also be problematic because we need a delimiter that cannot appear in normal output under any circumstances, so we'll need some encoding to prevent it (SMTP all over again).

Length header seems like a better approach to me. If we send say a 4 bytes length header (in network byte order) before each message, we can create a buffer of the right size right away and avoid the not so big but still real penalty of reallocations, and we can also reject messages that are longer than max message size set in the config right away (a malicious client may keep trying of course, but for a well-intentioned client is can be good way to avoid transfers that are doomed to fail and do something about it).

The most popular options are protobuf, msgpack, BSON, and ASN.1. ASN.1, despite being an ITU standard, is not very popular other than for serializing encryption keys and certs, though it does have a specification language (I don't know of code generators though). BSON and msgpack have a built-in set of types that are pretty much equivalent to JSON. Neither of those provide any formal specification tools.
Protobuf has a richer set of types, including optional fields and enums, and, most importantly, it does have a specification language and ptotobuf serializers/deserializers are normally autogenerated from it rather than handwritten.

Protobuf seems like a clear winner to me. Let me know if you have any arguments for the other ones.

Originally I considered JSON, but the length header issue means the format would be mixed text/binary, which is a very bad idea.

Details

Difficulty level
Normal (likely a few hours)
dmbaturin closed this task as "Resolved".Jan 14 2017, 6:46 PM

Protobuf schema has been written.