Author: | Alberto Bertogli (albertito@blitiri.com.ar) |
---|
NOTE: All integers are in network byte order.
The nmdb network protocol relies on a message passing underlying transport protocol. It can be used on top of TIPC, UDP, TCP (with a thin messaging layer) or SCTP. This document describes the protocol in a transport-independent way, assuming the transport protocol can send and receive messages reliably and preserve message boundaries. No ordering guarantee is required for the request-reply part of the protocol, but it is highly desirable to avoid reordering of requests.
All requests begin with a common header, and then have a request-specific payload. They look like this:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Ver | Request ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Request code | Flags | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : Payload : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Where the fields are:
The following table was taken from the server source, which should be the authoritative source of information. The codes are included here just for completeness.
Name | Code |
---|---|
REQ_GET | 0x101 |
REQ_SET | 0x102 |
REQ_DEL | 0x103 |
REQ_CAS | 0x104 |
REQ_INCR | 0x105 |
REQ_STATS | 0x106 |
REQ_FIRSTKEY | 0x107 |
REQ_NEXTKEY | 0x108 |
Note that not all requests accept all the flags. Flags that are not relevant for a given request will be ignored.
Name | Code | Relevant to |
---|---|---|
FLAGS_CACHE_ONLY | 1 | REQ_GET, REQ_SET, REQ_DEL, REQ_CAS, REQ_INCR |
FLAGS_SYNC | 2 | REQ_SET, REQ_DEL |
Replies begin with the ID they correspond to, then a reply code, and then a reply-specific payload. They look like this:
+------------+------------------+--- - - - ---+ | Request ID | Reply code | Payload | +------------+------------------+--- - - - ---+
Where the fields are:
All integers are in network byte ordering.
The following table was taken from the server source, which should be the authoritative source of information. The codes are included here just for completeness.
Name | Code |
---|---|
REP_ERR | 0x800 |
REP_CACHE_HIT | 0x801 |
REP_CACHE_MISS | 0x802 |
REP_OK | 0x803 |
REP_NOTIN | 0x804 |
REP_NOMATCH | 0x805 |
Name | Code | Description |
---|---|---|
ERR_VER | 0x101 | Version mismatch |
ERR_SEND | 0x102 | Error sending data |
ERR_BROKEN | 0x103 | Broken request |
ERR_UNKREQ | 0x104 | Unknown request |
ERR_MEM | 0x105 | Memory allocation error |
ERR_DB | 0x106 | Database error |
ERR_RO | 0x107 | Server in read-only mode |