1, Overview [ 概览 ]
BTSnoop 文件格式适用于存储 Bluetooth HCI 通讯数据。它与 RFC 1761 中记录的 snoop 格式非常相似。
The BTSnoop file format is suitable for storing Bluetooth® HCI traffic. It closely resembles the snoop format, as documented in RFC 1761.
2, File Format [ 文件格式 ]
侦测包的格式,是一个多字节数组,结构如下:
The snoop packet capture file is an array of octets structured as follows:
文件头是一个固定长度的字段,包含数据包文件的一般信息及其所含数据包记录的格式。文件头字段后是一个或多个长度可变的数据包记录字段。捕获到的数据包的数据就存放在各个数据包记录字段中。
The File Header is a fixed-length field containing general information about the packet file and the format of the packet records it contains. One or more variable-length Packet Record fields follow the File Header field. Each Packet Record field holds the data of one captured packet.
3, File Header [ 文件头 ]
文件头的结构如下:
The structure of the File Header is as follows:
3.1, Identification Pattern [ 识别模式 ] :
一个8字节的数据,用于将文件识别为窥探数据包捕获文件。识别模式由 8 个十六进制表示的字节组成:
A 64-bit (8 octet) pattern used to identify the file as a snoop packet capture file. The Identification Pattern consists of the 8 hexadecimal octets:
62 74 73 6E 6F 6F 70 00
这是一个ASCII字符串,“btsnoop”,后面以null字节结尾。
This is the ASCII string "btsnoop" followed by one null octets.
3.2, Version Number [ 版本号 ] :
一个4字节的无符号整数值,表示数据包捕获文件所使用的版本。本文档描述的版本号为1,按字节流顺序的值就是:00 00 00 01。
A 32-bit (4 octet) unsigned integer value representing the version of the packet capture file being used. This document describes version number 1.
3.3, Datalink Type [ 数据链路类型 ] :
一个4字节字段,用于标识后面的数据包记录中使用的数据链路头的类型。数据链路类型代码列于下表。值 0 - 1000 为保留值,以最大限度地与 RFC1761 snoop version 2 格式兼容。
A 32-bit (4 octet) field identifying the type of datalink header used in the packet records that follow. The datalink type codes are listed in the table below. Values 0 - 1000 are reserved, to maximize compatibility with the RFC1761 snoop version 2 format.
[ Datalink Codes ]
Datalink Type |
Code |
Reserved |
0 - 1000 |
Un-encapsulated HCI (H1) |
1001 |
HCI UART (H4) |
1002 |
HCI BSCP |
1003 |
HCI Serial (H5) |
1004 |
Unassigned |
1005 - 4294967295 |
比如我看到的一个snoop log文件,值就是1002,表示HCI的UART通讯数据包,按文件字节流顺序的值就是:00 00 03 ea,是大端顺序。
4, Packet Record Format [ 数据包记录格式 ]
每个数据包记录包含一个数据包的部分或完整副本,以及该数据包的一些描述性信息。数据包可能会被截断,以限制数据包文件中存储的数据量。
Each packet record holds a partial or complete copy of one packet as well as some descriptive information about that packet. The packet may be truncated in order to limit the amount of data to be stored in the packet file.
每个数据包记录包含 24 个字节的数据包描述信息,然后是长度可变的数据包数据和一个可选的填充字段。描述信息的结构是 6 个 32 位(4 个字节)整数值。
Each packet record holds 24 octets of descriptive information about the packet, followed by the packet data, which is variable-length, and an optional pad field. The descriptive information is structured as six 32-bit (4-octet) integer values.
数据包记录的结构如下:
The structure of the packet record is as follows:
4.1, Original Length [ 原始数据包长度 ]
一个 32 位无符号整数,表示通过网络接收到的所捕获数据包的长度,以字节为单位。
A 32-bit unsigned integer representing the length in octets of the captured packet as received via a network.