Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

permit slight changes to protocol messages without breaking compatibility #913

Open
rade opened this issue Jun 13, 2015 · 2 comments
Open

Comments

@rade
Copy link
Member

rade commented Jun 13, 2015

Weave protocol messages are represented by a []byte, with the first element being a tag identifying the message type, and the remainder being a payload, which is decoded differently, or not at all, depending on the message type.

Here are all the current message types and payloads:

ProtocolHeartbeat             ...
ProtocolConnectionEstablished ...
ProtocolFragmentationReceived ...
ProtocolPMTUVerified          pmtu
ProtocolGossip                (channel, srcName, payload, ...)
ProtocolGossipUnicast         (channel, srcName, dstName, payload, ...)
ProtocolGossipBroadcast       (channel, srcName, payload, ...)

... indicates an extension point where extra data can be added without breaking the decoding.

Note that for gossip messages the entire payload is another gob encoded value stream. The gossip payload - a []byte in turn is typically also a representation of a gob-encode value or value stream.

This gob layering is all a bit mad. It's also more prone to compatibility breakage when things change even slightly. The only compatible change is the addition of extra data at the end (the ... in the above). We can't remove or reorder information. And the ProtocolPMTUVerified is completely fixed.

Perhaps we should switch to representing protocol message types as struct types that implement a common (possibly empty) interface. I have experimented with that a bit. This ought to simplify the encoding/decoding and give us all the compatibility benefits built into gob.

@rade rade added the chore label Jun 13, 2015
@rade rade added this to the 1.0 milestone Jun 13, 2015
@rade
Copy link
Member Author

rade commented Jun 13, 2015

Perhaps we should switch to representing protocol message types as struct types that implement a common (possibly empty) interface.

One issue here is that our crypto operates on individual protocol messages. That makes the above scheme highly inefficient. gob is optimised for encoding/decoding a stream of values. So, for example, it transmits type information only once, and builds codec state machines. Here this would happen for every single message.

We'd really want to insert crypto between the tcp socket and gob encoder/decoder. #912 is somewhat related here.

@rade rade changed the title permit slight changes to protocol messages without breaking compatbility permit slight changes to protocol messages without breaking compatibility Jun 13, 2015
@dpw
Copy link
Contributor

dpw commented Jun 13, 2015

Might be relevant: For the sake of decoupling, https://github.com/weaveworks/weave/tree/fast-datapath turns the three UDP-related message types into a single one, with a []byte payload that is generated and interpreted by packet transport mechanism in use.

@rade rade modified the milestone: 1.0 Jun 15, 2015
@rade rade added the icebox label Dec 29, 2015
@rade rade removed the icebox label Jul 4, 2016
@rade rade modified the milestone: icebox Jul 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants