Skip to Content

Parse Response Packet

One peer need send back a response packet after receiving and handlding request packet.

ℹ️Info

Packet type is 2

Structure

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| type=2|v|g|re.|    cmd_code   |           request_id          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |  status_code  |    body_len   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            body_len           |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                       body(by body_len)                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                        nonce(optional)                        +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                      signature(optional)                      +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Fields Descriptions:

FieldLength in bitLength in bytedescription
cmd_code81Command
request_id32(uint32)4Request id, need to be same as request packet for pairing
status8(uint8)1status code: 0 - success; others show in status code table
body_len24(uint32)3Then length of body in bytes.
Max: 16 MB
If gzip is enabled, the value is after compress
bodyVariable length, decide by body_lenvariable lengthbody,max size: 16 MB
nonce648exists when verify is 1
signature12816exists when verify is 1

Status Code Table

valueflagdescription
0SUCCESSSuccess like HTTP status 200
1SERVER_TIMEOUTTimeout like HTTP status 408
3BAD_REQUESTBad Request like HTTP 400
5UNAUTHENTICATEDUnauthorized like HTTP 401
7SERVER_INTERNAL_ERRORInternal server like HTTP 500