├── CHANGELOG.md ├── LICENSE ├── README.md └── docs └── index.md /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Protocol Spec 5.1.0 2 | 3 | ## Implemented Proposals 4 | 5 | 6 | - [[SDL 0162] Define Handling of Duplicate Correlation IDs](https://github.com/smartdevicelink/protocol_spec/issues/17) 7 | 8 | - [[SDL 0141] Supporting simultaneous multiple transports](https://github.com/smartdevicelink/protocol_spec/issues/15) 9 | 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of protocol_spec nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SmartDeviceLink Protocol 2 | 3 | **Current Version: 5.4.1** 4 | 5 | ## 1. Overview 6 | The SmartDeviceLink protocol specification describes the method for establishing communication between an application and head unit and registering the application for continued communication with the head unit. The protocol is used as the base formation of packets sent from one module to another. 7 | 8 | All new SDL implementations should implement the newest version of the protocol. 9 | 10 | ### 1.1 Common Terms 11 | 12 | | Term | Description | 13 | |------|-------------| 14 | |**Module / Head Unit**| Hardware implementing the sdl_core software| 15 | |**Application**| Smart device application that implements the proxy library (iOS or Android)| 16 | 17 | ## 2. Frames 18 | All transported data is formed with a header followed by an optional payload. The combination of header and payload is referred to as a frame. 19 | 20 | ### 2.1 Version 1 Frame Header 21 | >Deprecated: Protocol versions 2 and higher. Only used as initial `StartService` packet for establishing communication and version negotiation from application 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
Byte 1Byte 2Byte 3Byte 4
VersionCFrame TypeService TypeFrame InfoSession ID
40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
Byte 5Byte 6Byte 7Byte 8
Data Size
52 | 53 | ### 2.2 Version 2 Frame Header 54 | >Required: Protocol versions 2 and higher 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
Byte 1Byte 2Byte 3Byte 4
VersionEFrame TypeService TypeFrame InfoSession ID
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
Byte 5Byte 6Byte 7Byte 8
Data Size
84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
Byte 9Byte 10Byte 11Byte 12
Message ID
96 | 97 | ### 2.3 Frame Header Fields 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 138 | 139 | 140 | 141 | 142 | 153 | 154 | 155 | 156 | 157 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 198 | 199 | 200 | 201 | 202 | 204 | 205 |
FieldSizeDescription
Version4 bit 109 | Protocol Version
110 | 0x1 Protocol version 1 - uses a version 1 Frame Header
111 | 0x2 Protocol version 2 - uses a version 2 Frame Header
112 | 0x3 Protocol version 3 - uses a version 2 Frame Header
113 | 0x4 Protocol version 4 - uses a version 2 Frame Header
114 | 0x5 Protocol version 5 - uses a version 2 Frame Header
115 | 0x6 - 0xF Reserved 116 |
C1 bitCompression Flag
0x0 This packet is not compressed
0x1 This packet is compressed
Note: Only available in Protocol Version 1
E1 bitEncryption Flag
0x0 This packet is not encrypted
0x1 This packet is encrypted
Note: Only available in Protocol Version 2 and higher. Must be always set to zero for a First Frame
Frame Type3 bit 132 | 0x00 Control Frame
133 | 0x01 Single Frame
134 | 0x02 First Frame
135 | 0x03 Consecutive Frame
136 | 0x04 - 0x07 Reserved 137 |
Service Type8 bit 143 | 0x00 Control Service
144 | 0x01 - 0x06 Reserved
145 | 0x07 Remote Procedure Call (RPC) Service
146 | 0x08 - 0x09 Reserved
147 | 0x0A Audio Service
148 | 0x0B Video Service
149 | 0x0C - 0x0E Reserved
150 | 0x0F Bulk Data (Hybrid Service)
151 | 0x10 - 0xFF Reserved 152 |
Frame Info8 bit 158 | Frame Type = 0x00 (Control Frame)
159 | 0x00 Heartbeat
160 | 0x01 Start Service
161 | 0x02 Start Service ACK
162 | 0x03 Start Service NAK
163 | 0x04 End Service
164 | 0x05 End Service ACK
165 | 0x06 End Service NAK
166 | 0x07 Register Secondary Transport
167 | 0x08 Register Secondary Transport ACK
168 | 0x09 Register Secondary Transport NAK
169 | 0x0A - 0xFC Reserved
170 | 0xFD Transport Event Update
171 | 0xFE Service Data ACK
172 | 0xFF Heartbeat ACK
173 | Frame Type = 0x01 (Single Frame)
174 | 0x00 - 0xFF Reserved
175 | Frame Type = 0x02 (First Frame)
176 | 0x00 - 0xFF Reserved
177 | Frame Type = 0x03 (Consecutive Frame)
178 | 0x00 Last Frame
179 | 0x01 - 0xFF Frame Number 180 |
Session ID8 bitThe session identifier
Data Size32 bit 191 | Frame Type = 0x00 (Control Frame)
192 | 0x0 - 0xFFFFFFFF reserved.
193 | Frame Type = 0x02 (First Frame)
194 | 0x08 The data size for a first frame is always 8 bytes. In the payload, the first four bytes denote the Total Size of the data contained in all consecutive frames. This is always the size of whole non-encrypted payload (even if consecutive frames are encrypted). The second four bytes denote the number of consecutive frames following this one
195 | Frame Type = 0x01 or 0x03 (Single or Consecutive Frame)
196 | The total bytes in this frame's payload. If frame is encrypted this is the size of encrypted payload, otherwise size of non-encrypted payload. 197 |
Message ID32 bitThe message identifier, used to uniquely identify this message.
203 | Note: Only included in protocol version 2 frame headers and higher
206 | 207 | ### 2.4 Max Transport Units 208 | The max transport unit (MTU) of a frame varies based on version. The MTU includes the frame header and payload. The current supported versions and their MTU's respectively are described below. 209 | 210 | | Version | MTU (bytes) | 211 | |------|-------------| 212 | |**1**| 1500| 213 | |**2**| 1500| 214 | |**3**| 131,084 | 215 | |**4**| 131,084| 216 | |**5**| 131,084 default or negotiated *(See Control Frame Payloads)* 217 | 218 | 219 | #### 2.4.1 Payload Size 220 | The payload size is determined by the MTU - Frame Header Size. 221 | 222 | | Version | Max Payload Size (bytes) | 223 | |------|-------------| 224 | |**1**| 1488| 225 | |**2**| 1488| 226 | |**3**| 131,072 | 227 | |**4**| 131,072| 228 | |**5**| 131,072 default or (Negotiated MTU - 12 bytes) *(See Control Frame Payloads)* 229 | 230 | #### 2.4.2 Encrypted MTU 231 | While the supported MTU is the maximum size for that version, if a frame is encrypted it will be subject to the MTU of that encryption protocol as well. That means the MTU will have to be the minimum between SDL's MTU and the encryption protocol's MTU. 232 | 233 | ## 3. Frame Types 234 | 235 | ### 3.1 Control Frame 236 | Control frames are the lowest-level type of packets. They can be sent over any of the defined services. They are used for the control of the services in which they are sent. 237 | 238 | #### 3.1.1 Special Header Definitions: 239 | | Header Value |Expected values| Description | 240 | |--------------|---------------|-------------| 241 | |Frame Info| `0x00` - `0x06`, `0xFE`, `0xFF`|See below "Frame Info Definitions"| 242 | |Data Size| `0x00`, `0x04`|`0x00` - Majority of control packets do not have payloads

`0x04` - Used for `StartServiceACK` where the payload is a HashID | 243 | 244 | 245 | #### 3.1.2 Frame Info Definitions: 246 | | Frame Info Value| Name | Description | 247 | |------------|------|-------------| 248 | | 0x00| Heartbeat| A ping packet that is sent to ensure the connection is still active and the service is still valid| 249 | | 0x01 | Start Service |Requests that a specific type of service is started | 250 | | 0x02 | Start Service ACK | Acknowledges that the specific service has been started successfully 251 | | 0x03 | Start Service NAK | Negatively acknowledges that the specific service was *not* started 252 | | 0x04 | End Service | Requests that a specific type of service is ended 253 | | 0x05 | End Service ACK | Acknowledges that the specific service has been ended successfully 254 | | 0x06 | End Service NAK | Negatively acknowledges that the specific service was *not* ended or has not yet been started 255 | | 0x07 | Register Secondary Transport | Request for a session registered on a primary transport to use a secondary transport.
This frame should only be sent on the Secondary Transport that the session is requesting. 256 | | 0x08 | Register Secondary Transport ACK | Acknowledges that the supplied session is registered to use the requested Secondary Transport. The application is only allowed to send additional frames on the Secondary Transport after this frame is received.
This frame must be sent on the Secondary Transport in which the original request was sent. 257 | | 0x09 | Register Secondary Transport NAK | Negatively acknowledges that the session is not registered or able to use the current Secondary Transport. The application cannot use this transport for any other messages.
This frame must be sent on the Secondary Transport in which the original request was sent. 258 | | 0xFD | Transport Event Update | Indicates that status or configuration of one or more transports are updated. This frame must only be sent after the successful starting of the RPC service which includes the protocol version negotiation. 259 | | 0xFE | Service Data ACK | *Deprecated* 260 | | 0xFF | Heartbeat ACK | Acknowledges that a Heartbeat control packet has been received 261 | 262 | #### 3.1.3 Payloads 263 | >Added: Protocol Version 5
264 | >*Note: All parameters are optional*
265 | 266 | Control frames use [BSON](http://bsonspec.org) to store payload data. All payload types are directly from the BSON spec. Each control frame info type will have a defined set of available data. Most types will also have differently available data based on their service type. 267 | 268 | If there is no data to send for a given parameter, the parameter should not be included. 269 | 270 | **Note:** Heartbeat, Heartbeat ACK, and Service Data ACK control frame types are not covered for any service as they were deprecated before payloads were introduced. 271 | 272 | ##### 3.1.3.1 Control Service 273 | 274 | ###### 3.1.3.1.1 Register Secondary Transport 275 | 276 | >No parameters 277 | 278 | ###### 3.1.3.1.2 Register Secondary Transport ACK 279 | 280 | >No parameters 281 | 282 | ###### 3.1.3.1.3 Register Secondary Transport NAK 283 | 284 | | Tag Name | Type | Introduced | Description | 285 | |----------|------|------------|-------------| 286 | | reason | String | 5.1.0 | A string describing the reason of failure | 287 | 288 | ###### 3.1.3.1.4 Transport Event Update 289 | 290 | | Tag Name | Type | Introduced | Description | 291 | |----------|------|------------|-------------| 292 | | tcpIpAddress | String | 5.1.0 | IP address that can be used to establish a TCP connection. It can be IPv4 address (example: "192.168.1.1") or IPv6 address (example: "fd12:3456:789a::1").
An empty string indicates that the TCP transport becomes unavailable. | 293 | | tcpPort | int32 | 5.1.0 | TCP Port number that can be used along with the supplied `tcpIpAddress` to establish a TCP connection. If parameter is included, the `tcpIpAddress` parameter must also be included.| 294 | 295 | ##### 3.1.3.2 RPC Service 296 | 297 | ###### 3.1.3.2.1 Start Service 298 | **Note:** While this includes a payload, it will remain a v1 frame header to ensure backwards compatibility with older systems. 299 | 300 | | Tag Name | Type | Introduced | Description | 301 | |----------|------|------------|-------------| 302 | |protocolVersion|String| 5.0.0 | The max version of the protocol supported by client requesting service to start. Must be in the format *"Major.Minor.Patch"*| 303 | 304 | ###### 3.1.3.2.2 Start Service ACK 305 | | Tag Name | Type | Introduced | Description | 306 | |----------|------|------------|-------------| 307 | |protocolVersion|String| 5.0.0 |The negotiated version of the protocol. Must be in the format *"Major.Minor.Patch"*. The frame header version should match the major version exactly.| 308 | |hashId|int32| 5.0.0 | Hash ID to identify this session and used when sending an `EndService` control frame for the RPC service type| 309 | |mtu| int64 | 5.0.0 | Max transport unit to be used for this service|. If not included the client should use the protocol version default.| 310 | |secondaryTransports|String Array| 5.1.0 | Array of transport types which are allowed to be used as a Secondary Transport. Refer to the table below for possible values.
As of this protocol spec version (5.1.0) only a single Secondary Transport may be used beyond a primary transport for a given session.
If there are no currently available Secondary Transports or the functionality is not supported, this parameter should be omitted or be an empty array.| 311 | |audioServiceTransports|int32 array| 5.1.0 | Ordered list of transport priority types that support the audio service (`0x0A`). Only the values of `1` ("Primary Transport") or `2` ("Secondary Transport") shall be used. If both the primary and secondary transport support the audio service, both should be included (`1` and `2`) in the order they are preferred; otherwise only the single transport priority type should be included. An application must not start the audio service on a transport priority type that is not listed in the array.
If this parameter is not included the Primary Transport should be used for the audio service.| 312 | |videoServiceTransports|int32 array| 5.1.0 | Ordered list of transport priority types that support the video service (`0x0B`). Only the values of `1` ("Primary Transport") or `2` ("Secondary Transport") shall be used. If both the primary and secondary transport support the video service, both should be included (`1` and `2`) in the order they are preferred; otherwise only the single transport priority type should be included. An application must not start the video service on a transport priority type that is not listed in the array.
If this parameter is not included the Primary Transport should be used for the video service.| 313 | |authToken|String| 5.2.0 | Included exclusively when communicating with cloud applications. This token is used by a cloud application to authenticate a user account associated with the vehicle. | 314 | |make|String| 5.4.0 | Vehicle make value. Used by OEM exclusive apps to identify whether current vehicle is supported or not. | 315 | |model|String| 5.4.0 | Vehicle model value. Used by OEM exclusive apps to identify whether current vehicle is supported or not. | 316 | |modelYear|String| 5.4.0 | Vehicle model year value. Used by OEM exclusive apps to identify whether current vehicle is supported or not. | 317 | |trim|String| 5.4.0 | Vehicle trim value. Used by OEM exclusive apps to identify whether current vehicle is supported or not. | 318 | |systemSoftwareVersion|String| 5.4.0 | Vehicle system software version value. Can be specified in any format desired by the OEM. | 319 | |systemHardwareVersion|String| 5.4.0 | Vehicle system hardware version value. Can be specified in any format desired by the OEM. | 320 | 321 | **list of transport type strings** 322 | 323 | | String | Description | 324 | |--------|-------------| 325 | | IAP\_BLUETOOTH | iAP over Bluetooth | 326 | | IAP\_USB | iAP over USB where it is not possible to distinguish between host or device mode| 327 | | IAP\_USB\_HOST\_MODE | iAP over USB, and the phone is running as host | 328 | | IAP\_USB\_DEVICE\_MODE | iAP over USB, and the phone is running as device | 329 | | IAP\_CARPLAY | iAP over Carplay wireless | 330 | | SPP\_BLUETOOTH | Bluetooth SPP. | 331 | | AOA\_USB | Android Open Accessory | 332 | | TCP\_WIFI | TCP connection over Wi-Fi | 333 | 334 | ###### 3.1.3.2.3 Start Service NAK 335 | | Tag Name | Type | Introduced | Description | 336 | |----------|------|------------|-------------| 337 | | rejectedParams |String Array| 5.0.0 | An array of rejected parameters| 338 | | reason | String | 5.3.0 | A string describing the reason of failure | 339 | 340 | ###### 3.1.3.2.4 End Service 341 | | Tag Name | Type | Introduced | Description | 342 | |----------|------|------------|-------------| 343 | |hashId|int32| 5.0.0 | Hash ID supplied in the `StartServiceACK` for this service type| 344 | 345 | ###### 3.1.3.2.5 End Service ACK 346 | 347 | ###### 3.1.3.2.6 End Service NAK 348 | | Tag Name | Type | Introduced | Description | 349 | |----------|------|------------|-------------| 350 | | rejectedParams |String Array| 5.0.0 | An array of rejected parameters such as: [`hashId`] | 351 | | reason | String | 5.3.0 | A string describing the reason of failure | 352 | 353 | ##### 3.1.3.3 Audio Service 354 | ###### 3.1.3.3.1 Start Service 355 | >No parameters 356 | 357 | ###### 3.1.3.3.2 Start Service ACK 358 | | Tag Name | Type | Introduced | Description | 359 | |----------|------|------------|-------------| 360 | |mtu| int64 | 5.0.0 | Max transport unit to be used for this service. If not included the client should use the one set via the RPC service or protocol version default.| 361 | 362 | ###### 3.1.3.3.3 Start Service NAK 363 | | Tag Name | Type | Introduced | Description | 364 | |----------|------|------------|-------------| 365 | | rejectedParams |String Array| 5.0.0 | An array of rejected parameters such as: [`videoProtocol`, `videoCodec`] | 366 | | reason | String | 5.3.0 | A string describing the reason of failure | 367 | 368 | ###### 3.1.3.3.4 End Service 369 | >No parameters 370 | 371 | ###### 3.1.3.3.5 End Service ACK 372 | >No parameters 373 | 374 | ###### 3.1.3.3.6 End Service NAK 375 | | Tag Name | Type | Introduced | Description | 376 | |----------|------|------------|-------------| 377 | | rejectedParams |String Array| 5.0.0 | An array of rejected parameters such as: [`hashId`] | 378 | | reason | String | 5.3.0 | A string describing the reason of failure | 379 | 380 | ##### 3.1.3.4 Video Service 381 | 382 | ###### 3.1.3.4.1 Start Service 383 | | Tag Name | Type | Introduced | Description | 384 | |----------|------|------------|-------------| 385 | |height|int32| 5.0.0 | Desired height from the client requesting the video service to start| 386 | |width|int32| 5.0.0 | Desired width from the client requesting the video service to start| 387 | |videoProtocol|String| 5.0.0 | Desired video protocol to be used. See `VideoStreamingProtocol ` RPC| 388 | |videoCodec|String| 5.0.0 | Desired video codec to be used. See `VideoStreamingCodec` RPC| 389 | 390 | ###### 3.1.3.4.2 Start Service ACK 391 | | Tag Name | Type | Introduced | Description | 392 | |----------|------|------------|-------------| 393 | |mtu| int64 | 5.0.0 | Max transport unit to be used for this service. If not included the client should use the one set via the RPC service or protocol version default.| 394 | |height|int32| 5.0.0 | Accepted height from the client requesting the video service to start| 395 | |width|int32| 5.0.0 | Accepted width from the client requesting the video service to start| 396 | |videoProtocol|String| 5.0.0 | Accepted video protocol to be used. See `VideoStreamingProtocol ` RPC| 397 | |videoCodec|String| 5.0.0 | Accepted video codec to be used. See `VideoStreamingCodec` RPC| 398 | 399 | 400 | ###### 3.1.3.4.3 Start Service NAK 401 | | Tag Name | Type | Introduced | Description | 402 | |----------|------|------------|-------------| 403 | | rejectedParams |String Array| 5.0.0 | An array of rejected parameters such as: [`videoProtocol`, `videoCodec`] | 404 | | reason | String | 5.3.0 | A string describing the reason of failure | 405 | 406 | ###### 3.1.3.4.4 End Service 407 | >No parameters 408 | 409 | ###### 3.1.3.4.5 End Service ACK 410 | >No parameters 411 | 412 | ###### 3.1.3.4.6 End Service NAK 413 | | Tag Name | Type | Introduced | Description | 414 | |----------|------|------------|-------------| 415 | | rejectedParams |String Array| 5.0.0 | An array of rejected parameters such as: [`hashId`] | 416 | | reason | String | 5.3.0 | A string describing the reason of failure | 417 | 418 | 419 | 420 | ### 3.2 Single Frame 421 | A frame of type Single Frame contains all the data for a particular packet in the payload. The majority of frames sent over the protocol utilize this frame type. 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 |
Single Frame
HeaderPayload
Data
436 | 437 | #### 3.2.1 Special Header Definitions: 438 | 439 | | Header Value |Expected values| Description | 440 | |--------------|---------------|-------------| 441 | |Frame Info| `0x00`|Reserved| 442 | |Data Size| 0x01-0xFFFFFFFF|Total payload size in bytes for this frame| 443 | 444 | ### 3.3 Multiple Frame Packets 445 | Some payloads will be larger than the maximum transport unit will allow. If that is the case, the payload will be broken up over multiple frames. These frame types are First and Consecutive. 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 |
Data
Data Chunk 1 Data Chunk 2 ...Data Chunk n
First Frame
HeaderPayload
Consecutive Frame 1
HeaderPayload
Consecutive Frame 2
HeaderPayload
...
Consecutive Frame n
HeaderPayload
515 | 516 | 517 | #### 3.3.1 First Frame 518 | The First Frame in a multiple frame payload contains information about the entire sequence of frames so that the receiving end can correctly parse all the frames and reassemble the entire payload. The payload of this frame is only eight bytes and contains information regarding the rest of the sequence. 519 | 520 | ##### 3.3.1.1 Payload: 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 |
Byte01234567
Total size of the original payload being parsedNumber of Consecutive Frames in this sequence
540 | 541 | ##### 3.3.1.2 Special Header Definitions: 542 | 543 | | Header Value |Expected values| Description | 544 | |--------------|---------------|-------------| 545 | |Frame Info| `0x00`|Reserved| 546 | |Data Size| `0x08`|This frame contains a fixed data size (8 bytes) for the payload.| 547 | 548 | #### 3.3.2 Consecutive Frame 549 | The Consecutive Frames in a multiple frame payload contain the actual raw data of the original payload. The parsed payload contained in each of the Consecutive Frames' payloads should be buffered until the entire sequence is complete. 550 | 551 | ##### 3.3.2.1 Special Header Definitions: 552 | 553 | | Header Value |Expected values| Description | 554 | |--------------|---------------|-------------| 555 | |Frame Info| `0x00` - `0xFF`|Values `0x01` - `0xFF` are used incrementally as each consecutive frame is created and sent in the sequence. eg The first consecutive packet in the sequence will have the value `0x01`, the next consecutive frame that contains the next chunk of data in the sequence will have the value `0x02`.

If the sequence reaches `0xFF` with more frames to create, it shall rollover to `0x01` **not** `0x00` as it is reserved.

`0x00` is only used for the last consecutive frame in a multi-frame sequence and the last frame must have this value.| 556 | |Data Size| `0x01` - `0xFFFFFFFF`|Payload size in bytes for only this frame | 557 | 558 | ## 4. Establishing Communication 559 | 560 | ### 4.1 Transport Layer 561 | >Required: All Protocol Versions 562 | 563 | A physical transport must be established between a head unit and an application before an SDL session can start. 564 | 565 | ### 4.2 Version Negotiation 566 | >Required: All Protocol Versions 567 | 568 | #### 4.2.1 Overview 569 | Once a physical transport is established, each application must negotiate the maximum supported protocol version with the head unit. To establish basic communication and register with the head unit, the application must start an RPC service (Service Type: 0x07), using a *Version 1 Protocol Header*. 570 | 571 | There are two types of version negotiation. Protocol versions 1 through 4 use an old style of negotiation, where as versions 5 and newer use a faster and more intelligent negotiation scheme. 572 | 573 | ##### 4.2.1.1 Version 1-4 Negotiation 574 | >Required for Protocol Versions 1 through 4 575 | 576 | | Proxy| Direction | Core | 577 | |------------|------|-------------| 578 | |`StartService`
**Version:** v1
**Payload:** no payload| ----------->| 579 | || <-----------|`StartServiceACK`
**Version:** Max supported by Core
**Payload:** raw bytes for hashID 580 | |`SingleFrame` *(or other RPC supporting Frame Type)*
**Version:** Highest version supported by both Core and Proxy
**Payload:** Lots of bytes| ----------->| Sets negotiated version. 581 | 582 | ##### 4.2.1.2 Version 5+ Negotiation 583 | >Required for Protocol Versions 5 and newer 584 | 585 | | Proxy| Direction | Core | 586 | |------------|------|-------------| 587 | |`StartService`
**Version:** v1
**Payload:** Constructed payload [protocolVersion: 5.x.x]| ----------->| **v4 Core**: Ignores payload, sends protocol version 4 frame and uses previous negotiation scheme.
**v5+ Core:** Reads in payload data, uses this information to determine version. 588 | || <-----------|`StartServiceACK`
**Version:** Highest version supported by both Core and Proxy
**Payload:** Constructed payload [protocolVersion: 5.x.x, hashId: 0x9873, mtu: 130687] 589 | |`SingleFrame`
**Version:** Highest version supported by both Core and Proxy
**Payload:** Lots of bytes| ----------->| 590 | 591 | #### 4.2.2 Starting Communication 592 | The application sends a `StartService` frame to the module containing no payload. 593 | 594 | ##### Application -> Head Unit 595 | 596 | #### 4.2.2.1 Versions 1 - 4 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 |
VersionCFrame TypeService TypeFrame InfoSession IdData Size
1noControlRPCStart Service00
0b00010b00b0000x070x010x000x00000000
627 | 628 | #### 4.2.2.2 Versions 5 and newer 629 | >**Note:** Even though this is a Protocol Version 1 frame header it includes a payload. This is a very special exception. 630 | 631 | Payload includes a constructed BSON object that has a single parameter of `protocolVersion` that describes the applications max supported Protocol Version. 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 |
VersionCFrame TypeService TypeFrame InfoSession IdData Size
1noControlRPCStart Service0Size of Payload
0b00010b00b0000x070x010x000xNNNNNNNN
662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 |
Payload
[protocolVersion: x.x.x]
671 | 672 | #### 4.2.3 Success 673 | If the head unit allows the RPC service to start, it will respond with a `StartServiceACK`. At this time the version will finish its negotiation process. 674 | 675 | ##### Head Unit -> Application 676 | 677 | ##### 4.2.3.1 Protocol Versions 1-4 678 | 679 | The `StartServiceACK` will contain the module's maximum supported protocol version. The packet structure will also match that of the supplied version; if the module's maximum supported version is 1, the packet will contain an 8 byte header (version 1), otherwise it will contain a 12 byte header (version 2). The application will then find the highest version supported by both the module and the application. This will be the determined version used for this session and will be used for all other packets sent from this point forward as well as all other services. 680 | 681 | The payload of the `StartServiceACK` will contain a hash of the service which was started on the head unit if the payload size is greater than 0. This hash should be stored by an application and is needed in the end communication flow. 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max Module Version (4)noControlRPCStart Service ACKAssigned Session42
0b01000b00b0000x070x020x010x000000040x0000000n
716 | 717 | ##### 4.2.3.2 Protocol Versions 5 and newer 718 | 719 | The `StartServiceACK` will contain a negotiated version between what the application provided in the `StartService` frame and what the module's maximum supported protocol version. Thus, if it is determined that no such information was sent in the `StartService` frame, the module will assume the previous method of version negotiation and send version 4 to assume it's max version supplied to the application and wait for the incoming `RegisterAppInterface` RPC from the application to finally determine the negotiated version. Either way, the determined version will be used for this session including all other packets sent from this point forward as well as all other services. 720 | 721 | The packet structure will also match that of the supplied version; if the module's maximum supported version is 1, the packet will contain an 8 byte header (version 1), otherwise it will contain a 12 byte header (version 2). If the protocol version was determined to be 5 or higher, the payload it contains will be constructed in nature as a BSON object. The application will then find the highest version supported by both the module and the application. This will be the determined version used for this session and will be used for all other packets sent from this point forward as well as all other services. 722 | 723 | The payload of the `StartServiceACK` will contain the agreed upon full protocol version *"Major.Minor.Patch"*, a hash of the service which was started on the head unit, and the max transport unit for that session (0x07 RPC). The hash should be stored by an application and is needed in the end communication flow. The MTU should be used as the default MTU for all other services for that session unless otherwise provided in the corresponding `StartServiceACK` for that service. 724 | 725 | ###### 4.2.3.2.1 Protocol Version Supplied in `StartService` 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max major version supported by module and application noControlRPCStart Service ACKAssigned SessionSize of payload2
0bNNNN0b00b0000x070x020x010xNNNNNNNN0x0000000n
759 | 760 | 761 | 762 | 763 | 764 | 765 | 767 |
Payload
[protocolVersion: x.x.x, hashId: 0xNNNN, mtu: 130687]
768 | 769 | ###### 4.2.3.2.2 Protocol Version Not Supplied in `StartService` 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max version application can possibly support (4)noControlRPCStart Service ACKAssigned Session42
0b01000b00b0000x070x020x010x000000040x0000000n
803 | 804 | 805 | ##### 4.2.4 Failure 806 | If a session has already been started, or can't be started, a `StartServiceNAK` will be sent in response to the `StartService` packet. 807 | 808 | ##### Head Unit -> Application 809 | 810 | ##### 4.2.4.1 Protocol Versions 1 through 4 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max Module Version (4)noControlRPCStart Service NAK000
0b01000b00b0000x070x030x000x000000000x00000000
844 | 845 | ##### 4.2.4.1 Protocol Versions 5 and Newer 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max Module Version (4)noControlRPCStart Service NAK0Size of Payload0
0b01000b00b0000x070x030x000xNNNNNNNN0x00000000
879 | 880 | 881 | 882 | 883 | 884 | 885 | 887 |
Payload
[rejectedParams:[protocolVersion, x, x]]
888 | 889 | ##### 4.2.5 Start Service 890 | 891 | The RPC service always needs to be started as unencrypted first, then it can be moved to an encrypted state by sending another `StartService` request containing an encryption flag set to `1` at a later point. Services of another type can be started as encrypted initially, i.e. it is not necessary to start them as unencrypted and then move to encrypted state using second `StartService` request (however such sequence of actions is also valid). See "7. Secured Communication" section for more details. 892 | 893 | ### 4.3 Registration 894 | >Required: All Protocol Versions 895 | 896 | Each application registers for continued communication with the head unit by sending a `RegisterAppInterface` Request RPC to the head unit via the RPC Service. Additional services can only be started after a successful `RegisterAppInterface` Response RPC has been sent from the head unit to the application. 897 | 898 | ### 4.4 Starting other services 899 | While the RPC service is the default service that is started to establish a connection and a session, the application may wish to start other services. Similar to the process in Section 4, all services that are to be to started in a session require a `StartService` packet to be sent from the application. If the module supports and allows that service type to be started, it will respond with a `StartServiceACK` that has a payload of the hash ID for that service. If the module is unable to start that service or that application does not have access to that service, it will respond with a `StartServiceNAK`. 900 | 901 | ### 4.5 Heartbeat 902 | >**Deprecated: Protocol Versions 4 and higher**
903 | >Required: Protocol Version 3
904 | >Added: Protocol Version 3 905 | 906 | After a successful start service exchange between the application and head unit both the application and head unit are required to be able to respond to heartbeat messages if the negotiated protocol version is 3. After sending a heartbeat, if the application or head unit does not respond within a timeout (custom per app/head unit), the sender will disconnect. The sender's timer for the heartbeat timeout should be reset every time any message is received. Heartbeats are sent using the Control Service Type (0x00) 907 | 908 | #### 4.5.1 Heartbeat Request 909 | 910 | >Note: The request can originate from either the Head Unit or the Application 911 | 912 | ##### Head Unit -> Application 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
4noControlControlHeartbeat000
0b01000b00b0000x000x000x000x000000000x00000000
946 | 947 | #### 4.5.2 Heartbeat ACK 948 | 949 | >Note: The response ACK will originate from the Head Unit or the Application based on the origin of the request 950 | 951 | ##### Application -> Head Unit 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
4noControlControlHeartbeat ACK000
0b01000b00b0000x000xFF0x000x000000000x00000000
985 | 986 | #### 4.5.3 Heartbeat NAK 987 | There is currently no heartbeat NAK. 988 | 989 | ### 4.6 Secondary Transport 990 | 991 | >Added: Protocol version 5.1.0 992 | 993 | After the RPC service has been established on an initial transport, it is possible to utilize a different transport beyond the initial transport for certain services. This additional transport is called the "Secondary Transport". The initial transport used to start the RPC service is called the "Primary Transport". 994 | 995 | #### 4.6.1 Secondary Transport Registration 996 | 997 | The RPC `StartServiceACK` will include information on potential Secondary Transports in the parameter `secondaryTransports` if any are supported. Once received, it is possible to register the session on the Secondary Transport if connected; if the transport is not connected it will have to either wait until an update is received through the `TransportEventUpdated` frame or the physical connection is made. 998 | 999 | Once the connection for Secondary Transport is established, if the application wishes to utilize that transport as a SecondaryTransport, the application is required to send a `RegisterSecondaryTransport` frame on that transport. The head unit will respond with either a`RegisterSecondaryTransportACK` or `RegisterSecondaryTransportNAK` frame. If the registration was successful and the application receives a `RegisterSecondaryTransportACK`, it may then utilize the Secondary Transport to start services. 1000 | 1001 | ##### 4.6.1.1 RegisterSecondaryTransport 1002 | 1003 | ##### Application -> Head Unit 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max major version supported by module and applicationnoControlControlRegister Secondary TransportSession Id assigned on Primary Transport01
0bNNNN0b00b0000x000x070xNN0x000000000x00000001
1037 | 1038 | ##### 4.6.1.2 RegisterSecondaryTransportACK 1039 | 1040 | ##### Head Unit -> Application 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max major version supported by module and applicationnoControlControlRegister Secondary Transport ACKSession Id assigned on Primary Transport02
0bNNNN0b00b0000x000x080xNN0x000000000x00000002
1074 | 1075 | ##### 4.6.1.3 RegisterSecondaryTransportNAK 1076 | 1077 | ##### Head Unit -> Application 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max major version supported by module and application if known, otherwise 5noControlControlRegister Secondary Transport NAKSession Id assigned on Primary Transport02
0bNNNN0b00b0000x000x090xNN0x000000000x00000002
1111 | 1112 | 1113 | #### 4.6.2 Transport Event Update 1114 | 1115 | Some Secondary Transports might require additional details on how they can be established. For example, in order to establish a TCP connection between the application and head unit the IP address and port number are required. The `TransportEventUpdate` control frame is used for this purpose. 1116 | 1117 | The head unit will send out a `TransportEventUpdate` frame whenever its transport configuration is changed, for example when its IP address is updated or Wi-Fi network goes down. The head unit will also send out a `TransportEventUpdate` frame right after the `StartServiceACK` frame that establishes the RPC service so the application can initiate a connection immediately. 1118 | 1119 | The `TransportEventUpdate` frame must always be sent through the Primary Transport. The head unit should not send the frame to applications that don't support protocol versions 5.1.0 or newer. 1120 | 1121 | ##### 4.6.2.1 TransportEventUpdate 1122 | 1123 | ##### Head Unit -> Application 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max major version supported by module and applicationnoControlControlTransport Event UpdateSession Id assigned on Primary TransportSize of payloadVariable
0bNNNN0b00b0000x000xFD0xNN0xNNNNNNNN0xNNNNNNNN
1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1165 |
Payload
[tcpIpAddress:"x.x.x.x", tcpPort:NNNN]
1166 | 1167 | #### 4.6.3 Starting Services on Secondary Transports 1168 | 1169 | A Secondary Transport is capable of carrying the video and audio services. Other services, including RPC and Hybrid service, must always run on the Primary Transport. (Note: Control service is an inherently started service on a transport and does not need to be established, but frames will be handled on a frame by frame basis of Primary vs Secondary Transport support) 1170 | 1171 | The RPC `StartServiceACK` might include the parameters `audioServiceTransports` and `videoServiceTransports` describing which service is allowed to run on which transport priority type (Primary, Secondary or both). An application honors this information and starts the service(s) only on an allowed transport. For example, if video service is allowed only on a Secondary Transport, the application will not start video streaming until Secondary Transport is established and registered. 1172 | 1173 | The transport priority types included in these parameters are listed in preferred order, for example, `[2,1]` (Secondary , Primary). In this case the priority of the Secondary Transport is higher than that of Primary Transport, the application may stop and restart service(s) when the Secondary Transport is added or removed. However, each service type must only be started and carried on a single transport at a time. 1174 | 1175 | When starting a service over a Secondary Transport the application, it must follow the previous sections to establish the transport connection and register its session over that transport. At that point it runs the normal sequence described in section 4.4. When starting a service over a Secondary Transport, the session ID that was provided during the establishment of the RPC service should be used. 1176 | 1177 | #### 4.6.4 Terminating Secondary Transport 1178 | 1179 | There is no procedure to terminate a Secondary Transport. However, if the Primary Transport is disconnected or the RPC service is stopped, any Secondary Transport for that session should be unregistered and if no other sessions are registered over that Secondary Transport it should be disconnected. 1180 | 1181 | ## 5. Services 1182 | Every active session has the ability to start any of the services defined in this protocol spec as long as they have permission on the module in which they are connected. Every session can only have one of each type of service open at a time. 1183 | 1184 | Messages sent have a priority based on their Service Type. Lower values for service type have higher delivery priority. A message's payload's format is based on the different service types defined below. 1185 | 1186 | ### 5.1 Control Service 1187 | >Required: All Protocol Versions 1188 | 1189 | The control service is the lowest level service available. While Control Frame packets are used frequently, the control service itself is rarely used. 1190 | 1191 | #### 5.1.1 Security Query 1192 | 1193 | When establishing a secure connection, the TLS Payload is sent in a control service message with a binary query header. The size of this header is 12 bytes, similar to the RPC Payload Binary Header. 1194 | 1195 | ##### 5.1.1.1 Payload 1196 | 1197 | The security query is able to contain JSON data as well as binary data. During the handshake the TLS handshake data is sent as binary data. See "Send Handshake Data" section for details. 1198 | 1199 | In case of an error, a notification is sent with an error code and error message as JSON data. See "Send Internal Error" section for details. 1200 | 1201 | 1202 | 1203 | 1204 | 1205 |
Binary Query Header
JSON Data
Binary Data
1206 | 1207 | ##### 5.1.1.2 Binary Header 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 |
Byte 1Byte 2Byte 3Byte 4
Query TypeQuery ID
Sequential Number
JSON Size
1227 | 1228 | ###### 5.1.1.2.1 Binary Header Fields 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1248 | 1249 | 1250 | 1251 | 1252 | 1258 | 1259 | 1260 | 1261 | 1262 | 1266 | 1267 | 1268 | 1269 | 1270 | 1274 | 1275 |
FieldSizeDescription
Query Type8 bit 1240 | 0x00 Request
1241 | 0x01 - 0x0F Reserved
1242 | 0x10 Response
1243 | 0x11 - 0x1F Reserved
1244 | 0x20 Notification
1245 | 0x21 - 0xFE Reserved
1246 | 0xFF Invalid Query Type 1247 |
Query ID24 bit 1253 | 0x000001 Send Handshake Data
1254 | 0x000002 Send Internal Error
1255 | 0x000003 - 0xFFFFFE Reserved
1256 | 0xFFFFFF Invalid Query ID 1257 |
Sequential Number32 bit 1263 | Message ID can be set by the mobile libraries to track security messages.
1264 | The system uses the same Message ID when replying to the query allowing the mobile libraries to correlate messages. 1265 |
JSON Size32 bit 1271 | The size of the JSON data following the binary query header.
1272 | Any additional data following the JSON data in the payload is binary data. 1273 |
1276 | 1277 | ##### 5.1.1.3 Send Handshake Data 1278 | 1279 | When performing the TLS handshake, the server sends a "Send Handshake Data" request containing its handshake data to the client, and the client sends a response with its own handshake data accordingly. 1280 | 1281 | ###### 5.1.1.3.1 Request Payload 1282 | 1283 | **Note:** Prior to SDL Core version 8.0.0, Core sent the "Notification" type (`0x20`) in this message instead of "Request" (`0x00`). Client libraries should account for this when communicating with older versions of SDL Core. 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1310 |
Binary Query Header
Query TypeTLS Message TypeSequential NumberJSON Size
RequestSend Handshake DataAny number to be used to correlate query messagesZero
0x000x0000010xNNNNNNNN0x00000000
Binary Data: SSL Handshake Request 1309 |
1311 | 1312 | ###### 5.1.1.3.2 Response Payload 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | 1320 | 1321 | 1322 | 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1338 |
Binary Query Header
Query TypeTLS Message TypeSequential NumberJSON Size
ResponseSend Handshake DataAny number to be used to correlate query messagesZero
0x100x0000010xNNNNNNNN0x00000000
Binary Data: SSL Handshake Response 1337 |
1339 | 1340 | #### 5.1.1.4 Send Internal Error 1341 | 1342 | If an error occurs during the TLS handshake, a notification is sent with both JSON data and binary data describing the error. The JSON data contains the error code and an error text. The binary data is one single byte and only contains the error code. 1343 | 1344 | The error code in JSON data and the binary data are the same value from the same code list. 1345 | 1346 | ##### 5.1.1.4.1 Payload 1347 | 1348 | The following query header is used by the system and the application to send error messages. 1349 | 1350 | 1351 | 1352 | 1353 | 1354 | 1355 | 1356 | 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 |
Binary Query Header
Query TypeTLS Message TypeSequential NumberJSON Size
NotificationSend Internal ErrorUnusedSize of the JSON data
0x200x0000020xNNNNNNNN0xNNNNNNNN
JSON Data
Binary Data: Single Byte Error Code
1379 | 1380 | ##### 5.1.1.4.2 JSON structure 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 |
KeyDescription
idA decimal value representing an Error code.
textA string describing the error.
1396 | 1397 | ##### 5.1.1.4.3 Error codes 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1414 | 1415 | 1416 | 1417 | 1418 | 1419 | 1420 | 1421 | 1422 | 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | 1431 | 1432 | 1433 | 1434 | 1435 | 1436 | 1437 | 1438 | 1439 | 1440 | 1441 | 1442 | 1443 | 1444 | 1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 1452 | 1453 | 1454 | 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1474 | 1475 | 1476 |
Error codeByteValueDescription
ERROR_SUCCESS0x000Internal Security Manager value
ERROR_INVALID_QUERY_SIZE0x011Wrong size of query data
ERROR_INVALID_QUERY_ID0x022Unknown Query ID
ERROR_NOT_SUPPORTED0x033SDL does not support encryption
ERROR_SERVICE_ALREADY_PROTECTED0x044Received request to protect a service that was protected before
ERROR_SERVICE_NOT_PROTECTED0x055Received handshake or encrypted data for not protected service
ERROR_DECRYPTION_FAILED0x066Decryption failed
ERROR_ENCRYPTION_FAILED0x077Encryption failed
ERROR_SSL_INVALID_DATA0x088SSL invalid data
ERROR_HANDSHAKE_FAILED0x099In case of all other handshake errors
INVALID_CERT0x0A10Handshake failed because certificate is invalid
EXPIRED_CERT0x0B11Handshake failed because certificate is expired
ERROR_INTERNAL0xFF255Internal error
ERROR_UNKNOWN_INTERNAL_ERROR0xFE254Error value for testing
1477 | 1478 | ### 5.2 RPC Service 1479 | >Required: All Protocol Versions 1480 | 1481 | The RPC service is used to send requests, responses, and notifications between an application and a head unit. Valid messages are defined in the [RPC Specification](https://github.com/smartdevicelink/sdl_core/blob/master/src/components/interfaces/MOBILE_API.xml). 1482 | 1483 | The payload of a message sent via the RPC service, which directly follows the Frame Header in the packet, consists of a Binary Header, and JSON data representing the RPC. 1484 | 1485 | ##### RPC Payload 1486 | 1487 | 1488 | 1489 | 1490 | 1491 | 1492 | 1493 | 1494 |
Binary Header
JSON Data
1495 | 1496 | #### 5.2.1 Binary Header 1497 | >Required: Protocol Version 2 and greater 1498 | 1499 | 1500 | 1501 | 1502 | 1503 | 1504 | 1505 | 1506 | 1507 | 1508 | 1509 | 1510 | 1511 | 1512 | 1513 | 1514 | 1515 | 1516 |
Byte 1Byte 2Byte 3Byte 4
RPC TypeRPC Function ID
Correlation ID
JSON Size
1517 | 1518 | ##### 5.2.1.1 Binary Header Fields 1519 | 1520 | 1521 | 1522 | 1523 | 1524 | 1525 | 1526 | 1527 | 1528 | 1529 | 1536 | 1537 | 1538 | 1539 | 1540 | 1542 | 1543 | 1544 | 1545 | 1546 | 1547 | 1548 | 1549 | 1550 | 1551 | 1552 |
FieldSizeDescription
RPC Type4 bit 1530 | 0x0 Request
1531 | 0x1 Response
1532 | 0x2 Notification
1533 | 0x3 Erroneous Response
1534 | 0x4 - 0xF Reserved 1535 |
RPC Function ID28 bitThe Function ID of each RPC is specific to each version of the RPC Specification but in general do not change from version to version. 1541 |
Correlation ID32 bits (signed)The Correlation ID is used to map a request to its response. Requests sent in the same session with the same Correlation ID as a pending request will be rejected with an `INVALID_ID` response. Requests that use a Correlation ID less than 0 will be rejected with an `INVALID_ID` response. In Protocol Version 1, when the Binary Header did not exist, the Correlation ID was included as part of the JSON and has a max value of 65536.
JSON Size32 bitsThe size of the JSON Data following the Binary Header in the RPC Payload
1553 | 1554 | ### 5.3 Hybrid (Bulk Data) Service 1555 | >Required: Protocol Version 2 and greater 1556 | 1557 | The Hybrid Service does not need to be explicitly started; all applications that have successfully started the RPC Service have access to the Hybrid Service. 1558 | 1559 | The Hybrid Service is similar to the RPC Service but adds a bulk data field. The payload of a message sent via the Hybrid service consists of a Binary Header, JSON Data, and Bulk Data. 1560 | 1561 | The size of the Bulk Data field is the Data Size (Found in the Frame Header) minus the 12 Bytes of the Binary Header minus the JSON Size (Found in the Binary Header). 1562 | 1563 | The Binary Header of a message using the Hybrid Service is the same as the Binary Header of a message using the RPC Service. 1564 | 1565 | ##### Hybrid Service Payload 1566 | 1567 | 1568 | 1569 | 1570 | 1571 | 1572 | 1573 | 1574 | 1575 | 1576 | 1577 |
Binary Header
JSON Data
Bulk Data
1578 | 1579 | ### 5.4 Audio Service (PCM) 1580 | >Available: Protocol Version 3 and greater 1581 | 1582 | The application can start the audio service to send PCM audio data to the head unit. After the `StartService` packet is sent and the ACK received, the payload for the Audio Service is only PCM audio data. 1583 | 1584 | ### 5.5 Video Service (H.264) 1585 | >Available: Protocol Version 3 and greater 1586 | 1587 | The application can start the video service to send H.264 video data to the head unit. After the `StartService` packet is sent and the ACK received, the payload for the Video Service is only H.264 video data. 1588 | 1589 | 1590 | ## 6. Ending Communication 1591 | The application may request it's session to be ended outside of a transport disconnect, module power cycle, etc. 1592 | ### 6.1 Completely Closing a Session and Ending All Services 1593 | To close out a communication session with the head unit, an application sends an `EndService` packet with service type 7 (RPC) to the module. The `EndService` packet payload should include the correct hash ID supplied with the `StartServiceACK`. 1594 | 1595 | ### 6.2 Closing Specific Services 1596 | If the application doesn't want to completely stop its session, but only wishes to close a specific session it can do so using an `EndService` packet that's service type matches the service that the application is trying to close. The `EndService` packet should include the hash ID in its payload that was contained in the `StartServiceACK` for that specific service. 1597 | 1598 | ## 7. Secured Communication 1599 | 1600 | It is possible to establish a secured and encrypted communication with the system by setting the frame header encryption flag to `1` when starting a new service or by sending another `StartService` with the encryption flag set to `1` when the service is already established (this the required flow for the RPC service). If the authentication is successful, the system will reply with a `StartService ACK` frame with the encryption flag also set to `1` indicating that encrypted data is now accepted. If the authentication fails for some reason, the system will reset the TLS connection and return a `StartService NAK` frame. 1601 | 1602 | Below are possible combinations of the service encryption status and RPCs protection flag value. 1603 | 1604 | 1605 | 1606 | 1607 | 1608 | 1609 | 1610 | 1611 | 1612 | 1613 | 1614 | 1615 | 1616 | 1617 | 1618 | 1619 | 1620 | 1621 | 1622 | 1623 | 1624 | 1625 | 1626 | 1627 | 1628 | 1629 | 1630 | 1631 | 1632 | 1633 | 1634 | 1635 | 1639 | 1640 | 1641 | 1642 | 1646 | 1647 | 1648 | 1649 | 1650 | 1651 | 1652 | 1653 | 1654 | 1655 | 1656 | 1657 |
Service Encryption StatusRPC TypeRequires ProtectionExpected SDL Behavior
Encryption is not establishedRequestyesSDL Core rejects the request with result code `ENCRYPTION_NEEDED` (please see policy updates for which RPCs need protection).
noSDL Core continues processing the RPC request.
NotificationyesSDL Core does not send the notification.
noSDL Core sends the notification unencrypted.
Encryption is establishedRequestyes 1636 | If unencrypted, SDL Core rejects the request with an unencrypted response and result code `ENCRYPTION_NEEDED`.
1637 | If encrypted, SDL Core continues processing the request and sends an encrypted response. 1638 |
no 1643 | If unencrypted, SDL Core continues processing the request and sends an unencrypted response.
1644 | If encrypted, SDL Core continues processing the request and sends an encrypted response. 1645 |
NotificationyesSDL Core sends the notification encrypted.
noSDL Core sends the notification unencrypted.
1658 | 1659 | ### 7.1 Authentication 1660 | 1661 | The authentication is done using TLS handshake. The TLS handshake process is defined by TLS and is not part of the SDL protocol. 1662 | 1663 | The below diagram shows the sequence of how the TLS handshake exchanges certificates to compute the master secret. 1664 | 1665 | ![TLS Handshake activity diagram](https://user-images.githubusercontent.com/5848997/122258220-cb8b7100-ce9e-11eb-9b2a-a6194b0d1b68.png) 1666 | 1667 | Please see [SDL Overview Guides](https://smartdevicelink.com/en/guides/pull_request/sdl-overview-guides/security/protected-services/) for more details. 1668 | 1669 | The system can be configured to support one encryption method. The following methods are supported: 1670 | 1671 | - TLSv1 1672 | - TLSv1.1 1673 | - TLSv1.2 1674 | - DTLSv1 1675 | - SSLv3 (not supported on most newer systems) 1676 | 1677 | The system has to initiate with the corresponding client method. For instance, if the system is configured to use `DTLSv1`, it has to use the method `DTLSv1_client`. The application role has to be server and must use `DTLSv1_server`. 1678 | 1679 | The system also supports configurable [SSL Security level](https://www.openssl.org/docs/man1.1.0/man3/SSL_CTX_get_security_level.html) introduced in OpenSSL 1.1.0. This parameter can be changed by `SecurityLevel` parameter in the Core configuration file. By default, system uses security level 1 for TLS handshakes. At this time setting the security level higher than 1 for general internet use is likely to cause considerable interoperability issues and is not recommended. This is because the SHA1 algorithm is very widely used in certificates and will be rejected at levels higher than 1 because it only offers 80 bits of security. 1680 | 1681 | ### 7.2 Handshake Frames 1682 | 1683 | The system will initiate a TLS handshake to authenticate the application where the system's role will be the client while the application's role will be the server. The system will do this only once if the application was not authenticated before in the current transport connection. The TLS handshake data is always sent in single frames. The service type for TLS handshake is the control service. 1684 | 1685 | #### 7.2.1 SDL Protocol Frame Header 1686 | 1687 | The following SDL frame header is used for every frame related to TLS handshake. 1688 | 1689 | 1690 | 1691 | 1692 | 1693 | 1694 | 1695 | 1696 | 1697 | 1698 | 1699 | 1700 | 1701 | 1702 | 1703 | 1704 | 1705 | 1706 | 1707 | 1708 | 1709 | 1710 | 1715 | 1716 | 1717 | 1718 | 1719 | 1720 | 1721 | 1722 | 1723 | 1724 | 1725 | 1726 | 1727 |
SDL Protocol Frame Header
VersionEFrame TypeService TypeFrame InfoSession IDData SizeMessage ID
Max major version supported
by module and application
noSingle FrameControl ServiceSingle Frame InfoAssigned Session ID 1711 | Query Binary Header +
1712 | JSON Data size +
1713 | Binary Handshake Data size 1714 |
Enumerated number
0xN0b00b0010x000x000xNN0xC + 0xNNNNNNNN + 0xNNNNNNNN0xNNNNNNNN
1728 | 1729 | #### 7.2.2 Security Query Binary Header 1730 | 1731 | The following query header is used by the system and the application to send TLS handshake data. 1732 | 1733 | 1734 | 1735 | 1736 | 1737 | 1738 | 1739 | 1740 | 1741 | 1742 | 1743 | 1744 | 1745 | 1746 | 1747 | 1748 | 1749 | 1750 | 1751 | 1752 | 1753 | 1754 | 1755 | 1756 | 1757 | 1758 |
Binary Query Header
Query TypeTLS Message TypeSequential NumberJSON Size
RequestSend Handshake DataAny number to be used to correlate query messagesZero
0x000x0000010xNNNNNNNN0x00000000
Binary TLS Handshake Data
1759 | 1760 | ### 7.3 Error handling 1761 | 1762 | In case of an error, the system and the application should reset the active SSL connection of the current transport connection. This impacts already established secured service sessions as all of them will be closed. The application will need to restart all services which require protection. 1763 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # SmartDeviceLink Protocol 2 | 3 | **Current Version: 4.0.0** 4 | 5 | ## 1. Overview 6 | The SmartDeviceLink protocol specification describes the method for establishing communication between an application and head unit and registering the application for continued communication with the head unit. The protocol is used as the base formation of packets sent from one module to another. 7 | 8 | All new SDL implementations should implement the newest version of the protocol. 9 | 10 | ### 1.1 Common Terms 11 | 12 | | Term | Description | 13 | |------|-------------| 14 | |**Module / Head Unit**| Hardware implementing the sdl_core software| 15 | |**Application**| Smart device application that implements the proxy library (iOS or Android)| 16 | 17 | ## 2. Frames 18 | All transported data is formed with a header followed by an optional payload. The combination of header and payload is referred to as a frame. 19 | 20 | ### 2.1 Version 1 Frame Header 21 | >Deprecated: Protocol versions 2 and higher. Only used as initial `StartService` packet for establishing communication and version negotiation from application 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
Byte 1Byte 2Byte 3Byte 4
VersionCFrame TypeService TypeFrame InfoSession ID
40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
Byte 5Byte 6Byte 7Byte 8
Data Size
52 | 53 | ### 2.2 Version 2 Frame Header 54 | >Required: Protocol versions 2 and higher 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
Byte 1Byte 2Byte 3Byte 4
VersionEFrame TypeService TypeFrame InfoSession ID
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
Byte 5Byte 6Byte 7Byte 8
Data Size
84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
Byte 9Byte 10Byte 11Byte 12
Message ID
96 | 97 | ### 2.3 Frame Header Fields 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 136 | 137 | 138 | 139 | 140 | 151 | 152 | 153 | 154 | 155 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 192 | 193 | 194 | 195 | 196 | 198 | 199 |
FieldSizeDescription
Version4 bit 108 | Protocol Version
109 | 0x1 Protocol version 1 - uses a version 1 Frame Header
110 | 0x2 Protocol version 2 - uses a version 2 Frame Header
111 | 0x3 Protocol version 3 - uses a version 2 Frame Header
112 | 0x4 Protocol version 4 - uses a version 2 Frame Header
113 | 0x5 - 0xF Reserved 114 |
C1 bitCompression Flag
0x0 This packet is not compressed
0x1 This packet is compressed
Note: Only available in Protocol Version 1
E1 bitEncryption Flag
0x0 This packet is not encrypted
0x1 This packet is encrypted
Note: Only available in Protocol Version 2 and higher
Frame Type3 bit 130 | 0x00 Control Frame
131 | 0x01 Single Frame
132 | 0x02 First Frame
133 | 0x03 Consecutive Frame
134 | 0x04 - 0x07 Reserved 135 |
Service Type8 bit 141 | 0x00 Control Service
142 | 0x01 - 0x06 Reserved
143 | 0x07 Remote Procedure Call (RPC) Service
144 | 0x08 - 0x09 Reserved
145 | 0x0A PCM Service
146 | 0x0B Video Service
147 | 0x0C - 0x0E Reserved
148 | 0x0F Bulk Data (Hybrid Service)
149 | 0x10 - 0xFF Reserved 150 |
Frame Info8 bit 156 | Frame Type = 0x00 (Control Frame)
157 | 0x00 Heartbeat
158 | 0x01 Start Service
159 | 0x02 Start Service ACK
160 | 0x03 Start Service NAK
161 | 0x04 End Service
162 | 0x05 End Service ACK
163 | 0x06 End Service NAK
164 | 0x07 - 0xFD Reserved
165 | 0xFE Service Data ACK
166 | 0xFF Heartbeat ACK
167 | Frame Type = 0x01 (Single Frame)
168 | 0x00 - 0xFF Reserved
169 | Frame Type = 0x02 (First Frame)
170 | 0x00 - 0xFF Reserved
171 | Frame Type = 0x03 (Consecutive Frame)
172 | 0x00 Last Frame
173 | 0x01 - 0xFF Frame Number 174 |
Session ID8 bitThe session identifier
Data Size32 bit 185 | Frame Type = 0x00 (Control Frame)
186 | 0x0 - 0xFFFFFFFF reserved.
187 | Frame Type = 0x02 (First Frame)
188 | 0x08 The data size for a first frame is always 8 bytes. In the payload, the first four bytes denote the Total Size of the data contained in all consecutive frames, and the second four bytes denote the number of consecutive frames following this one
189 | Frame Type = 0x01 or 0x03 (Single or Consecutive Frame)
190 | The total bytes in this frame's payload 191 |
Message ID32 bitThe message identifier, used to uniquely identify this message.
197 | Note: Only included in protocol version 2 frame headers and higher
200 | 201 | ### 2.4 Max Transport Units 202 | The max transport unit (MTU) of a frame varies based on version. The MTU includes the frame header and payload. The current supported versions and their MTU's respectively are described below. 203 | 204 | | Version | MTU (bytes) | 205 | |------|-------------| 206 | |**1**| 1500| 207 | |**2**| 1500| 208 | |**3**| 131,084 | 209 | |**4**| 131,084| 210 | 211 | 212 | #### 2.4.1 Payload Size 213 | The payload size is determined by the MTU - Frame Header Size. 214 | 215 | | Version | Max Payload Size (bytes) | 216 | |------|-------------| 217 | |**1**| 1488| 218 | |**2**| 1488| 219 | |**3**| 131,072 | 220 | |**4**| 131,072| 221 | 222 | #### 2.4.2 Encrypted MTU 223 | While the supported MTU is the maximum size for that version, if a frame is encrypted it will be subject to the MTU of that encryption protocol as well. That means the MTU will have to be the minimum between SDL's MTU and the encryption protocol's MTU. 224 | 225 | ## 3. Frame Types 226 | ### 3.1 Control Frame 227 | Control frames are the lowest-level type of packets. They can be sent over any of the defined services. They are used for the control of the services in which they are sent. 228 | 229 | #### 3.1.1 Special Header Definitions: 230 | | Header Value |Expected values| Description | 231 | |--------------|---------------|-------------| 232 | |Frame Info| `0x00` - `0x06`, `0xFE`, `0xFF`|See below "Frame Info Definitions"| 233 | |Data Size| `0x00`, `0x04`|`0x00` - Majority of control packets do not have payloads

`0x04` - Used for `StartServiceACK` where the payload is a HashID | 234 | 235 | 236 | #### 3.1.2 Frame Info Definitions: 237 | | Frame Info Value| Name | Description | 238 | |------------|------|-------------| 239 | | 0x00| Heartbeat| A ping packet that is sent to ensure the connection is still active and the service is still valid| 240 | | 0x01 | Start Service |Requests that a specific type of service is started | 241 | | 0x02 | Start Service ACK | Acknowledges that the specific service has been started successfully 242 | | 0x03 | Start Service NAK | Negatively acknowledges that the specific service was *not* started 243 | | 0x04 | End Service | Requests that a specific type of service is ended 244 | | 0x05 | End Service ACK | Acknowledges that the specific service has been ended successfully 245 | | 0x06 | End Service NAK | Negatively acknowledges that the specific service was *not* ended or has not yet been started 246 | | 0xFE | Service Data ACK | *Deprecated* 247 | | 0xFF | Heartbeat ACK | Acknowledges that a Heartbeat control packet has been received 248 | 249 | ### 3.2 Single Frame 250 | A frame of type Single Frame contains all the data for a particular packet in the payload. The majority of frames sent over the protocol utilize this frame type. 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 |
Single Frame
HeaderPayload
Data
264 | 265 | #### 3.2.1 Special Header Definitions: 266 | 267 | | Header Value |Expected values| Description | 268 | |--------------|---------------|-------------| 269 | |Frame Info| `0x00`|Reserved| 270 | |Data Size| 0x01-0xFFFFFFFF|Total payload size in bytes for this frame| 271 | 272 | ### 3.3 Multiple Frame Packets 273 | Some payloads will be larger than the maximum transport unit will allow. If that is the case, the payload will be broken up over multiple frames. These frame types are First and Consecutive. 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 |
Data
Data Chunk 1 Data Chunk 2 ...Data Chunk n
First Frame
HeaderPayload
Consecutive Frame 1
HeaderPayload
Consecutive Frame 2
HeaderPayload
...
Consecutive Frame n
HeaderPayload
343 | 344 | 345 | #### 3.3.1 First Frame 346 | The First Frame in a multiple frame payload contains information about the entire sequence of frames so that the receiving end can correctly parse all the frames and reassemble the entire payload. The payload of this frame is only eight bytes and contains information regarding the rest of the sequence. 347 | 348 | ##### 3.3.1.1 Payload: 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 |
Byte01234567
Total size of the original payload being parsedNumber of Consecutive Frames in this sequence
367 | 368 | ##### 3.3.1.2 Special Header Definitions: 369 | 370 | | Header Value |Expected values| Description | 371 | |--------------|---------------|-------------| 372 | |Frame Info| `0x00`|Reserved| 373 | |Data Size| `0x08`|This frame contains a fixed data size (8 bytes) for the payload.| 374 | 375 | #### 3.3.2 Consecutive Frame 376 | The Consecutive Frames in a multiple frame payload contain the actual raw data of the original payload. The parsed payload contained in each of the Consecutive Frames' payloads should be buffered until the entire sequence is complete. 377 | 378 | ##### 3.3.2.1 Special Header Definitions: 379 | 380 | | Header Value |Expected values| Description | 381 | |--------------|---------------|-------------| 382 | |Frame Info| `0x00` - `0xFF`|Values `0x01` - `0xFF` are used incrementally as each consecutive frame is created and sent in the sequence. eg The first consecutive packet in the sequence will have the value `0x01`, the next consecutive frame that contains the next chunk of data in the sequence will have the value `0x02`.

If the sequence reaches `0xFF` with more frames to create, it shall rollover to `0x01` **not** `0x00` as it is reserved.

`0x00` is only used for the last consecutive frame in a multi-frame sequence and the last frame must have this value.| 383 | |Data Size| `0x01` - `0xFFFFFFFF`|Payload size in bytes for only this frame | 384 | 385 | ## 4. Establishing Communication 386 | 387 | ### 4.1 Transport Layer 388 | >Required: All Protocol Versions 389 | 390 | A physical transport must be established between a head unit and an application before an SDL session can start. 391 | 392 | ### 4.2 Version Negotiation 393 | >Required: All Protocol Versions 394 | 395 | Once a transport is established, each application must negotiate the maximum supported protocol version with the head unit. To establish basic communication and register with the head unit, the application must start an RPC service (Service Type: 0x07), using a *Version 1 Protocol Header*. 396 | 397 | ##### Application -> Head Unit 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 |
VersionCFrame TypeService TypeFrame InfoSession IdData Size
1noControlRPCStart Service00
0b00010b00b0000x070x010x000x00000000
427 | 428 | #### 4.2.1 Success 429 | 430 | If the head unit allows the RPC service to start, it will respond with a `StartServiceACK` containing its maximum supported protocol version. The packet structure will also match that of the supplied version; if the module's maximum supported version is 1, the packet will contain an 8 byte header (version 1), otherwise it will contain a 12 byte header (version 2). The application will then find the highest version supported by both the module and the application. This will be the determined version used for this session and will be used for all other packets sent from this point forward. 431 | 432 | The payload of the `StartServiceACK` will contain a hash of the service which was started on the head unit if the payload size is greater than 0. This hash should be stored by an application and is needed in the end communication flow. 433 | 434 | ##### Head Unit -> Application 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max Module Version (4)noControlRPCStart Service ACKAssigned Session42
0b01000b00b0000x070x020x010x000000040x0000000n
467 | 468 | #### 4.2.2 Failure 469 | If a session has already been started, or can't be started, a `StartServiceNAK` will be sent in response to the `StartService` packet. 470 | 471 | ##### Head Unit -> Application 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
Max Module Version (4)noControlRPCStart Service NAK000
0b01000b00b0000x070x030x000x000000000x00000000
504 | 505 | ### 4.3 Registration 506 | >Required: All Protocol Versions 507 | 508 | Each application registers for continued communication with the head unit by sending a `RegisterAppInterface` Request RPC to the head unit via the RPC Service. Additional services can only be started after a successful `RegisterAppInterface` Response RPC has been sent from the head unit to the application. 509 | 510 | ### 4.4 Starting other services 511 | While the RPC service is the default service that is started to establish a connection and a session, the application may wish to start other services. Similar to the process in Section 4, all services that are to be to started in a session require a `StartService` packet to be sent from the application. If the module supports and allows that service type to be started, it will respond with a `StartServiceACK` that has a payload of the hash ID for that service. If the module is unable to start that service or that application does not have access to that service, it will respond with a `StartServiceNAK`. 512 | 513 | ### 4.5 Heartbeat 514 | >**Deprecated: Protocol Versions 4 and higher**
515 | >Required: Protocol Version 3
516 | >Added: Protocol Version 3 517 | 518 | After a successful start service exchange between the application and head unit both the application and head unit are required to be able to respond to heartbeat messages if the negotiated protocol version is 3. After sending a heartbeat, if the application or head unit does not respond within a timeout (custom per app/head unit), the sender will disconnect. The sender's timer for the heartbeat timeout should be reset every time any message is received. Heartbeats are sent using the Control Service Type (0x00) 519 | 520 | #### 4.5.1 Heartbeat Request 521 | 522 | >Note: The request can originate from either the Head Unit or the Application 523 | 524 | ##### Head Unit -> Application 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
4noControlControlHeartbeat000
0b01000b00b0000x000x000x000x000000000x00000000
557 | 558 | #### 4.5.2 Heartbeat ACK 559 | 560 | >Note: The response ACK will originate from the Head Unit or the Application based on the origin of the request 561 | 562 | ##### Application -> Head Unit 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 |
VersionEFrame TypeService TypeFrame InfoSession IdData SizeMessage ID
4noControlControlHeartbeat ACK000
0b01000b00b0000x000xFF0x000x000000000x00000000
595 | 596 | #### 4.5.3 Heartbeat NAK 597 | There is currently no heartbeat NAK. 598 | 599 | ## 5. Services 600 | Every active session has the ability to start any of the services defined in this protocol spec as long as they have permission on the module in which they are connected. Every session can only have one of each type of service open at a time. 601 | 602 | Messages sent have a priority based on their Service Type. Lower values for service type have higher delivery priority. A message's payload's format is based on the different service types defined below. 603 | 604 | ### 5.1 Control Service 605 | >Required: All Protocol Versions 606 | 607 | The control service is the lowest level service available. While Control Frame packets are used frequently, the control service itself is rarely used. 608 | 609 | ### 5.2 RPC Service 610 | >Required: All Protocol Versions 611 | 612 | The RPC service is used to send requests, responses, and notifications between an application and a head unit. Valid messages are defined in the [RPC Specification](https://github.com/smartdevicelink/sdl_core/blob/master/src/components/interfaces/MOBILE_API.xml). 613 | 614 | The payload of a message sent via the RPC service, which directly follows the Frame Header in the packet, consists of a Binary Header, and JSON data representing the RPC. 615 | 616 | ##### RPC Payload 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 |
Binary Header
JSON Data
626 | 627 | #### 5.2.1 Binary Header 628 | >Required: Protocol Version 2 and greater 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 |
Byte 1Byte 2Byte 3Byte 4
RPC TypeRPC Function ID
Correlation ID
JSON Size
648 | 649 | ##### 5.2.1.1 Binary Header Fields 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 665 | 666 | 667 | 668 | 669 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 |
FieldSizeDescription
RPC Type4 bit 660 | 0x0 Request
661 | 0x1 Response
662 | 0x2 Notification
663 | 0x3 - 0xF Reserved 664 |
RPC Function ID28 bitThe Function ID of each RPC is specific to each version of the RPC Specification but in general do not change from version to version. 670 |
Correlation ID32 bitsThe Correlation ID is used to map a request to its response. In Protocol Version 1, when the Binary Header did not exist, the Correlation ID was included as part of the JSON and has a max value of 65536
JSON Size32 bitsThe size of the JSON Data following the Binary Header in the RPC Payload
682 | 683 | ### 5.3 Hybrid (Bulk Data) Service 684 | >Required: Protocol Version 2 and greater 685 | 686 | The Hybrid Service does not need to be explicitly started; all applications that have successfully started the RPC Service have access to the Hybrid Service. 687 | 688 | The Hybrid Service is similar to the RPC Service but adds a bulk data field. The payload of a message sent via the Hybrid service consists of a Binary Header, JSON Data, and Bulk Data. 689 | 690 | The size of the Bulk Data field is the Data Size (Found in the Frame Header) minus the 12 Bytes of the Binary Header minus the JSON Size (Found in the Binary Header). 691 | 692 | The Binary Header of a message using the Hybrid Service is the same as the Binary Header of a message using the RPC Service. 693 | 694 | ##### Hybrid Service Payload 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 |
Binary Header
JSON Data
Bulk Data
707 | 708 | ### 5.4 Audio Service (PCM) 709 | >Available: Protocol Version 3 and greater 710 | 711 | The application can start the audio service to send PCM audio data to the head unit. After the `StartService` packet is sent and the ACK received, the payload for the Audio Service is only PCM audio data. 712 | 713 | ### 5.5 Video Service (H.264) 714 | >Available: Protocol Version 3 and greater 715 | 716 | The application can start the video service to send H.264 video data to the head unit. After the `StartService` packet is sent and the ACK received, the payload for the Video Service is only H.264 video data. 717 | 718 | 719 | ## 6. Ending Communication 720 | The application may request it's session to be ended outside of a transport disconnect, module power cycle, etc. 721 | ### 6.1 Completely Closing a Session and Ending All Services 722 | To close out a communication session with the head unit, an application sends an `EndService` packet with service type 7 (RPC) to the module. The `EndService` packet payload should include the correct hash ID supplied with the `StartServiceACK`. 723 | 724 | ### 6.2 Closing Specific Services 725 | If the application doesn't want to completely stop its session, but only wishes to close a specific session it can do so using an `EndService` packet that's service type matches the service that the application is trying to close. The `EndService` packet should include the hash ID in its payload that was contained in the `StartServiceACK` for that specific service. 726 | --------------------------------------------------------------------------------