NAME
mnp —
mesh network protocol
DESCRIPTION
mnp is a mesh network built on top of
datagram sockets and little abstractions. It is used to exchange
unique
messages over a set of peers.
Message Structure
The mnp message has the following
structure:
| type | ttl | payload |
| 1 byte | 1 byte | N-2 bytes |
where
N- is the maximum message size supported which is implementation-defined.
- type
- is the type of a message. Supported types are listed in Message Types section.
- ttl
- is the time to live. It is decremented on message receiving. When it is zero, message must not be transferred more.
- payload
- is the additional information for a message. It is type-defined.
Message Types
Message type defines the meaning of a message. It can be any of the following:
TRANSFER0- That message stores an information that should be broadcasted to all the
sessions with an exception of sender. Payload
stores the content which is undefined. If the same content was seen less
than
CONTENT_TIMEOUTseconds ago or less, it is discarded. Equality may be checked via an implementation-defined hash algorithm. CONTENT_TIMEOUT is an implementation-defined integer not less than 10. PING1- Since
mnpis datagram based, peers should know whether connection is still active. Payload is implementation-defined. PONG2- Should be returned in reply to
PING. Payload is implementation-defined. NEIGHBOURS3- Since
mnpis a mesh network protocol, there should be some way to find peers.NEIGHBOURSis that way. Payload is empty. NEIGHBOUR4- Returns a neighbour peer. Payload contains implementation-defined details
of a peer which must be enough information to connect. Should be returned
in reply to
NEIGHBOURS.
Session
Sessions are the way how mnp mesh is
formed. Session is a very implicit thing. Upon receiving
PING or PONG from an unknown
client a session is created. If there was no activity in a session within
SESSION_TIMEOUT seconds, it is destroyed.
SESSION_TIMEOUT
is an implementation-defined natural number.
NOTES
Payload of TRANSFER is undefined. This is
done this way because mnp does not care about data
being transferred, and content should be defined on a higher level.
SEE ALSO
AUTHORS
Nakidai Perumenei <nakidai@disroot.org>
CAVEATS
mnp depends on datagram sockets. If to use
something like UDP, it is important to keep in mind that it is unreliable.
Also, it uses flooding broadcast mechanism. This means, that
mnp wants not too many peers, but enough to not
loose messages.