YHEchoPackage/消息结构.md

36 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!-- TOC -->
* [结构](#结构)
* [Body 加密、解密](#body-加密解密)
* [过程](#过程)
* [ChkSum](#chksum)
<!-- TOC -->
# 结构
![](/home/mic/Pictures/Screenshots/截图_选择区域_20230426173011.png)
消息结构由两部分组成即消息头和消息体。消息头大小固定20个字节在解析数据流时先读取20个字节解析出消息头数据后再读取Body数据。
| 参数 | 字节书byte | 说明 |
| ----- | ---- |----------------------|
| Magic | 4 | 协议头,固定值,由服务端提供 |
| Seq | 2 | 请求编号。返回数据时系统会并带上请求编号 |
| Cmd | 2 | 消息命令ID |
| UT | 4 | Unix时间戳,精确到秒 |
| ChkSum | 4 | 校验和 |
| Len | 4 | body的长度 |
| Body | 不固定 | 加密的body数据 |
---
## Body 加密、解密
- 算法AES-128-CBC
- key`example key 1234`(正式环境另外提供)。
#### 过程
## ChkSum
- 算法CRC-32校验和,使用IEEE多项式。
>说明将Seq、Cmd、UT、body(加密后)按顺序写入buffer后通过CRC-32计算校验和。