The XDCR binary protocol consists of the add with meta, get with meta, set with meta, and delete with meta commands. Their binary format is defined below.
Set With Meta
Byte/ 0 | 1 | 2 | 3 |
/ | | | |
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
+---------------+---------------+---------------+---------------+
0| 0x80 | 0xa2 | 0x00 | 0x05 |
+---------------+---------------+---------------+---------------+
4| 0x14 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
8| 0x00 | 0x00 | 0x00 | 0x20 |
+---------------+---------------+---------------+---------------+
12| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
16| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
20| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
24| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
28| 0x00 | 0x00 | 0x00 | 0x0a |
+---------------+---------------+---------------+---------------+
32| 0xbe | 0xef | 0xca | 0xfe |
+---------------+---------------+---------------+---------------+
36| 0xca | 0xfe | 0xba | 0xbe |
+---------------+---------------+---------------+---------------+
40| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
44| 0x6d ('m') | 0x79 ('y') | 0x6b ('k') | 0x65 ('e') |
+---------------+---------------+---------------+---------------+
48| 0x79 ('y') | 0x6d ('m') | 0x79 ('y') | 0x76 ('v') |
+---------------+---------------+---------------+---------------+
52| 0x61 ('a') | 0x6c ('l') | 0x75 ('u') | 0x65 ('e') |
+---------------+---------------+---------------+---------------+
set with meta command
Field (offset) (value)
Magic (0) : 0x80
Opcode (1) : 0xa2
Key length (2,3) : 0x0005
Extra length (4) : 0x14
Data type (5) : 0x00
Vbucket (6,7) : 0x0000
Total body (8-11) : 0x00000020 == 0x14 + 5 + 7
Opaque (12-15): 0xdeadbeef
CAS (16-23): 0x0000000000000000
Flags (24-27): 0x00000000
Expiration (28-31): 0x0000000a
Seqno (32-35): 0xbeefcafe
Remote CAS (36-43): 0xcafebabedeadbeef
Key (44-48): mykey
Value (49-55): myvalue
Note that the format above can be used with different opcodes to define slightly different behavior. These opcodes define setq with meta (0xa3), add with meta (0xa4), and addq with meta (0xa5).
Delete With Meta
Byte/ 0 | 1 | 2 | 3 |
/ | | | |
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
+---------------+---------------+---------------+---------------+
0| 0x80 | 0xa8 | 0x00 | 0x05 |
+---------------+---------------+---------------+---------------+
4| 0x14 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
8| 0x00 | 0x00 | 0x00 | 0x19 |
+---------------+---------------+---------------+---------------+
12| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
16| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
20| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
24| 0x00 | 0x00 | 0x00 | 0x00 |
+---------------+---------------+---------------+---------------+
28| 0x00 | 0x00 | 0x00 | 0x0a |
+---------------+---------------+---------------+---------------+
32| 0xbe | 0xef | 0xca | 0xfe |
+---------------+---------------+---------------+---------------+
36| 0xca | 0xfe | 0xba | 0xbe |
+---------------+---------------+---------------+---------------+
40| 0xde | 0xad | 0xbe | 0xef |
+---------------+---------------+---------------+---------------+
44| 0x6d ('m') | 0x79 ('y') | 0x6b ('k') | 0x65 ('e') |
+---------------+---------------+---------------+---------------+
48| 0x79 ('y') |
+---------------+
delete with meta command
Field (offset) (value)
Magic (0) : 0x80
Opcode (1) : 0xa8
Key length (2,3) : 0x0005
Extra length (4) : 0x14
Data type (5) : 0x00
Vbucket (6,7) : 0x0000
Total body (8-11) : 0x00000019 == 0x14 + 5 + 0
Opaque (12-15): 0xdeadbeef
CAS (16-23): 0x0000000000000000
Flags (24-27): 0x00000000
Expiration (28-31): 0x0000000a
Seqno (32-35): 0xbeefcafe
Remote CAS (36-43): 0xcafebabedeadbeef
Key (44-48): mykey
For deleteq with meta use opcode 0xa9.