doc/protocol.md: wrote documentation.