Skip to content

Commit 3a1f62d

Browse files
authored
Update 009_dxb_structure.md
1 parent f84f6a5 commit 3a1f62d

1 file changed

Lines changed: 85 additions & 114 deletions

File tree

009_dxb_structure.md

Lines changed: 85 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -15,117 +15,88 @@ A DATEX Block consists of 4 main sections:
1515

1616
<DXBProtocolViewer speck="./assets/structures/dxb.json"></DXBProtocolViewer>
1717

18-
## 9.2 The Routing Header
19-
20-
The Routing Header is not encrypted or signed, the content always needs to be
21-
parseable by all nodes.
22-
23-
| Name | Start | End | Size | Content | Description |
24-
| ------------------ | :---: | :-: | :--: | ----------------------------------------------------- | ---------------------------------------------------------------------------------------- |
25-
| Magic Number | 0 | 2 | 2 | 01 64 | Fixed value (0x01 and 'd') |
26-
| Version Number | 2 | 3 | 1 | <pre class="language-yaml">VERSION: Uint8&#10;</pre> | Version number starting from 0x01 |
27-
| Block Size | 3 | 5 | 2 | <pre class="language-yaml">SIZE: Uint16&#10;</pre> | Total block size in bytes |
28-
| TTL | 5 | 6 | 1 | <pre class="language-yaml">TTL: Uint8&#10;</pre> | Time-to-live for this block, get decremented with each node redirection |
29-
| Priority | 6 | 7 | 1 | <pre class="language-yaml">PRIORITY: Uint8&#10;</pre> | Routing priority of this block |
30-
| Signed / Encrypted | 7 | 8 | 1 | <pre class="language-yaml">SECURITY: Uint8&#10;</pre> | 0x00: not signed or encrypted, 0x01: signed, 0x02: encrypted, 0x03: signed and encrypted |
31-
32-
```
33-
DATEX.Endpoint {
34-
TYPE: Uint8
35-
ID: Uint8[18]
36-
INSTANCE: Uint16
37-
}
38-
39-
PointerId {
40-
TYPE: Uint8
41-
IDENTIFIER: Uint8[18]
42-
INSTANCE: Uint16
43-
TIMESTAMP: Uint32 # unix ts in seconds, starting from 25. Juli 23
44-
COUNTER: Uint8
45-
}
46-
47-
ReceiverEndpoint {
48-
ENDPOINT: Endpoint
49-
optional KEY: Uint8[512] # only if Receivers.FLAGS.ENDPOINTS_HAVE_KEYS
50-
}
51-
52-
ReceiverEndpoints {
53-
COUNT: Uint16 # if MAX, flood, no RECEIVERS
54-
ENDPOINTS: ReceiverEndpoint[COUNT]
55-
}
56-
57-
Receivers {
58-
FLAGS: Uint8
59-
HAS_POINTER_ID: FLAGS & 0b00000001,
60-
HAS_ENDPOINTS: FLAGS & 0b00000010,
61-
ENDPOINTS_HAVE_KEYS: FLAGS & 0b00000100
62-
optional POINTER_ID: PointerId
63-
optional ENDPOINTS: ReceiverEndpoints
64-
}
65-
66-
RoutingHeader {
67-
MAGIC_NUMBER: Uint16 {0x01, 0x64},
68-
VERSION: Uint8,
69-
TTL: Uint8,
70-
FLAGS: Uint8
71-
HAS_UNENCRYPTED_SIGNATURE: FLAGS & 0b00000001,
72-
HAS_ENCRYPTION: FLAGS & 0b00000010,
73-
HAS_ENCRYPTED_SIGNATURE: FLAGS & 0b00000100,
74-
IS_LARGE_SIZE: FLAGS & 0b00001000
75-
BLOCK_SIZE: IS_LARGE_SIZE ? Uint32 : Uint16,
76-
77-
SCOPE_ID: Uint32
78-
BLOCK_INDEX: Uint16
79-
BLOCK_SUB_INDEX: Uint16
80-
81-
SENDER_TYPE: Uint8,
82-
optional SENDER: Uint8[20] # only exists if SENDER_TYPE != 255, otherwise SENDER is @@any
83-
optional RECEIVERS: Receivers
84-
}
85-
86-
BlockHeader {
87-
88-
FLAGS: Uint21
89-
BLOCK_TYPE: FLAGS & 0b111100000000000000000,
90-
ALLOW_EXECUTE: FLAGS & 0b000010000000000000000,
91-
END_OF_BLOCK: FLAGS & 0b000001000000000000000, # if a subdivided block has only a single signature, it is sent with the last block containing the END_OF_BLOCK flag
92-
END_OF_SCOPE: FLAGS & 0b000000100000000000000,
93-
HAS_EXPIRATION_TIMESTAMP: FLAGS & 0b000000010000000000000,
94-
HAS_ON_BEHALF_OF: FLAGS & 0b000000001000000000000,
95-
HAS_REPRESENTED_BY: FLAGS & 0b000000000100000000000,
96-
IS_COMPRESSED: FLAGS & 0b000000000010000000000,
97-
_RESERVED_: FLAGS & 0b000000000001111111111,
98-
CREATION_TIMESTAMP: Uint43, # unix ts in ms, starting from 25. Juli 23
99-
optional EXPIRATION_OFFSET: Uint32, # unix ts in seconds, starting from CREATION_TIMESTAMP
100-
optional REPRESENTED_BY: Endpoint
101-
optional IV: Uint8[16]
102-
}
103-
104-
DXB {
105-
ROUTING_HEADER: RoutingHeader,
106-
optional UNENCRYPTED_SIGNATURE: Uint8[192],
107-
optional ENCRYPTED_SIGNATURE: Uint[x] # used instead SIGNATURE to hide identity of signing endpoint (when using ON_BEHALF_OF)
108-
# optional start signed part:
109-
optional BLOCK_HEADER: BlockHeader
110-
# optional start encrypted part:
111-
ENCRYPTED_FLAGS: Uint8
112-
DEVICE_TYPE: ENCRYPTED_FLAGS & 0b11110000
113-
optional ON_BEHALF_OF: Endpoint,
114-
BODY: DXBBody
115-
}
116-
```
117-
118-
## 9.3 The Block Header
119-
120-
The Block Header is part of the signed and encrypted part. If the block is
121-
signed, the header cannot be altered, and it can't be read by non-receiving
122-
parties if the block is encrypted.
123-
124-
| Name | Start | End | Size | Content | Description |
125-
| ----------------- | :---: | :-: | :--: | --------------------------------------------------------- | ------------------------------------------------------------------ |
126-
| Scope ID | 0 | 4 | 4 | <pre class="language-yaml">SID: Uint32&#10;</pre> | Scope ID, unique for a certain sender for a certain period of time |
127-
| Scope Block Index | 4 | 6 | 2 | <pre class="language-yaml">BLOCK_INDEX: Uint16&#10;</pre> | Index of the block within the current scope |
128-
| Scope Block Inc | 6 | 8 | 2 | <pre class="language-yaml">SIZE: Uint16&#10;</pre> | Incremented for each block of a scope |
129-
| Type | 8 | 9 | 1 | <pre class="language-yaml">TYPE: Uint8&#10;</pre> | Block type. See _Block Types_ |
130-
| Flags | 9 | 10 | 1 | <pre class="language-yaml">FLAGS: Uint8&#10;</pre> | executable, end of scope, device type |
131-
| Timestamp | 10 | 18 | 8 | <pre class="language-yaml">TIME: Uint64&#10;</pre> | Time in ms since 2022-01-22 (to be changed) |
18+
## 9.2 The Routing Header {#id}
19+
20+
<speck-table file="./assets/structures/dxb.json" section="Routing Header">
21+
22+
| Field | Size | Type | Condition (for optional fields) |
23+
| :-------------------------------------------------------------- | :--------------------------------------------------------------- | :---------------------------- | :------------------------------------------------------------------------ |
24+
| Magic Number | 2 bytes | - | - |
25+
| Version | 1 byte | uint8 | - |
26+
| Block Size | 2 bytes | uint16 | - |
27+
| Flags | 1 byte | bitmask | - |
28+
| - Signature Type | 2 bits | enum (0b00, 0b10, 0b11, 0b01) | - |
29+
| - Encryption Type | 1 bits | enum (0, 1) | - |
30+
| - Receiver Type | 2 bits | enum (0b00, 0b01, 0b10, 0b11) | - |
31+
| - Is Bounce Back | 1 bits | boolean | - |
32+
| - Has Checksum | 1 bits | boolean | - |
33+
| Checksum | 4 bytes | uint32 | - |
34+
| Distance | 1 byte | uint8 | - |
35+
| TTL | 1 byte | uint8 | - |
36+
| Sender | 21 bytes | endpoint | - |
37+
| Receivers Pointer ID | 26 bytes | pointer | [Receiver Type](#routing-header-receiver-type) equals "Pointer" |
38+
| <a name="routing-header-receiver-count">Number of Receivers</a> | 1 byte | uint8 | receiver-type in ("Receivers","ReceiversWithKeys") |
39+
| Receivers | 21 bytes x [Number of Receivers](#routing-header-receiver-count) | endpoint | receiver-type in ("Receivers","ReceiversWithKeys") |
40+
| Receivers with Keys | 21 bytes x [Number of Receivers](#routing-header-receiver-count) | endpoint | [Receiver Type](#routing-header-receiver-type) equals "ReceiversWithKeys" |
41+
| Signature | 255 bytes | string | [Signature Type](#routing-header-signature-type) equals "Unencrypted" |
42+
| Encrypted Signature | 300 bytes | string | [Signature Type](#routing-header-signature-type) equals "Encrypted" |
43+
44+
45+
<a name="routing-header-magic-number"></a>
46+
# Magic Number
47+
48+
49+
<a name="routing-header-version"></a>
50+
# Version
51+
52+
53+
<a name="routing-header-block-size"></a>
54+
# Block Size
55+
56+
57+
<a name="routing-header-flags"></a>
58+
# Flags
59+
60+
61+
<a name="routing-header-checksum"></a>
62+
# Checksum
63+
64+
65+
<a name="routing-header-distance"></a>
66+
# Distance
67+
68+
69+
<a name="routing-header-ttl"></a>
70+
# TTL
71+
72+
73+
<a name="routing-header-sender"></a>
74+
# Sender
75+
76+
77+
<a name="routing-header-receivers-pointer-id"></a>
78+
# Receivers Pointer ID
79+
80+
81+
<a name="routing-header-receiver-count"></a>
82+
# Number of Receivers
83+
84+
85+
<a name="routing-header-receivers"></a>
86+
# Receivers
87+
88+
89+
<a name="routing-header-receivers-with-keys"></a>
90+
# Receivers with Keys
91+
92+
93+
<a name="routing-header-signature"></a>
94+
# Signature
95+
96+
97+
<a name="routing-header-encrypted-signature"></a>
98+
# Encrypted Signature
99+
100+
101+
102+
</speck-table>

0 commit comments

Comments
 (0)