Distributed Publish Subscribe for IoT
Message Protocol

This section descbribes the DPS message protocol encodings. DPS messages are encoded in CBOR.

DPS Message types

DPS has four messages types.

1 message = pub / sub / ack / sak

Common types

These are types common across the various message types.

UUID

UUIDs identify publications and are also used as key identifiers for encrypted messages.

1 uuid = bstr .size 16

Bit vector control flags

Bits vectors are usually run-length encoded unless the raw unencoded bit vector is more compact than the rle-encoded representation. The rle-encoded flag indicates if the bit vector is encoded or raw.

The rle-complement flags indicates if the complement of the bit vector was was encoded. The bit vector complement is encoded if this results in a more compact encoding. This flag is only useful with run-length encoding.

1 bit-vector-flags = &(
2  rle-encoded: 1,
3  rle-complement: 2
4 )

Bit vector encoding

The bit vector encoding includes control flags, the bit vector length expressed in bits and the raw or run-length encoded bit vector data.

1 bit-vector = [
2  flags: uint .bits bit-vector-flags, ; # bit vector control flags
3  len: uint, ; # bit vector length in bits
4  bits: bstr ; # raw or rle-encoded bit vector
5 ]

### Subscription flags

1 sub-flags = &(
2  delta: 1, ; # indicate interests is a delta
3  mute: 2 ; # mute has been indicated
4 )

Header field member keys.

For compactness the member keys are encoded as integers as listed below.

1 header-field = (
2  ? 1 => uint, ; # port number sender is listening on
3  ? 2 => int, ; # ttl - time to live in seconds
4  ? 3 => uuid, ; # pub-id - unique indentifier for a publication
5  ? 4 => uint, ; # seq-num - sequence number for a publication
6  ? 5 => bool, ; # ack-req - indicates if an publisher is requesting an acknowledgement
7  ? 6 => bit-vector, ; # bloom-filter -the bloom filter for a publication
8  ? 7 => sub-flags, ; # sub-flags - indicates delta or mute
9  ? 8 => uuid, ; # mesh-id - the mesh ID
10  ? 9 => bit-vector, ; # needs - the needs bit vector
11  ? 10 => bit-vector ; # interests - the interests bit vector
12 )

DPS message types

Publication message encoding

The encoding of a publication.

1 pub = [
2  type: 1,
3  headers: { * header-field }, ; # port, ttl
4  body: { * header-field }, ; # ttl, pub-id, seq-num, ack-req, bloom-filter
5  payload: [
6  topics: [ + topic: tstr ]
7  payload: bstr
8  ]
9 ]

Subscription message encoding

The encoding of a subscription.

1 sub = [
2  type: 2,
3  headers: { * header-field }, ; # port, seq-num
4  body: { * header-field } ; # sub-flags, mesh-id, needs, interests or empty for unlink
5 ]

Acknowledgement message encoding

The encoding of an acknowledgement message.

1 ack = [
2  type: 3,
3  body: { * header-field }, ; # pub-id, seq-num
4  payload: bstr
5 ]

Subscription acknowledgement message encoding

The encoding of a subscription acknowledgement message.

1 sak = [
2  type: 4,
3  headers: { * header-field } ; # port, seq-num
4 ]