1.概述
* MTU: 最大传输单元(MAXIMUM TRANSMISSION UNIT) , 指在一个PDU (Protocol Data Unit: 协议数据单元,在一个传输单元中的有效传输数
据)能够传输的最大数据量(多少字节可以一次性传输到对方)。
* MTU 交换是为了在主从双方设置一个PDU中最大能够交换的数据量,通过MTU的交换和双方确认(注意这个MTU是不可以协商的,只是通知对方,双方在知道对方的极限后会选择一个较小的值作为以后的MTU,比如说,主设备发出一个150个字节的MTU请求,但是从设备回应MTU是23字节,那么今后双方要以较小的值23字节作为以后的MTU),主从双方约定每次在做数据传输时不超过这个最大数据单元
MTU交换通常发生在主从双方建立连接关系后(参见“一分钟读懂低功耗蓝牙连接数据包“”)
做个对比就可以知道BLE MTU 比较小(不过新的BLE 标准MTU 已经大幅提升,详见即将发表在VIEWTOOL BBS上的后续文章)。
****************************************************************“*************************
以太网:1500
IEEE 802.3/802.2: 1492
X.25: 576
BLE: 23 => 这就是为什么WIFI 可以用于传输视频,传统蓝牙(BT)可以传输音频,而低功耗蓝牙(BTLE 或者BLE)只能够传输控制数据的原因了。
******************************************************************************************
* MTU 交换命令:属于ATT 命令
* MTU 交换过程:如下图

* MTU 两个命令(“MTU 请求”及“MTU 响应”)详解如下(见“4”)
2.关键字:Hollong BLE 侦听仪,低功耗蓝牙嗅探器, BLE 分析仪,BLE 数据抓取
Keyword: Hollong BLE Sniffer, BLE Data Analyzer,BLE Capture
3.抓取数据包的准备工作
* 硬件:一个BLE设备(从设备)及对应的主设备(如智能手机里面的相关应用程序,或者通用BLE 工具软件);
一台HOLLONG BLE SNIFFER (Hollong BLE 侦听仪)
* 软件:Hollong 蓝牙4.0/4.1 BLE协议监控分析仪 软件, 使用本软件可以打开本文中的数据包附件,进而可以更加方便及更加全面地了解更多细节(包括最全面的数据及数据解析)
下载链接:
http://www.viewtool.com/index.ph ... hollong-4-0-4-1-ble
4. MTU 请求(REQEUST)
完整数据(以下关注蓝色标注部分)

1) 存取地址
Access Address: 0xaf9a8c69
固定为4个字节,其值由连接请求数据包指定(详见“一分钟读懂低功耗蓝牙连接数据包”)

2) 头信息
Data Header: 0x0706 000. .... = RFU: 0
...0 .... = More Data: False
.... 0... = Sequence Number: 0
.... .1.. = Next Expected Sequence Number: 1
.... ..10 = LLID: Start of an L2CAP message or a complete L2CAP message with no fragmentation (0x2)
000. .... = RFU: 0
...0 0111 = Length: 7

3) L2CAP 长度
在BLE中,GAP,GATT,SMP 都使用L2CAP 通道将命令及数据打包送到链路层(LINK LAYER),L2CAP 打包过程中需要指定L2CAP的长度及通道号。
Length: 3

4) L2CAP 通道号(CID):channel ID
CID: Attribute Protocol (0x0004)

5) ATT 命令
标准发下:

实际数据包:
Opcode: Exchange MTU Request (0x02)
0... .... = Authentication Signature: False
.0.. .... = Command: False
..00 0010 = Method: Exchange MTU Request (0x02)

6) MTU 值 (请求的值)
Client Rx MTU: 185

7) CRC

4. MTU 响应(RESPONSE)
完整数据包:

1) 存取地址
Access Address: 0xaf9a8c69
固定为4个字节,其值由连接请求数据包指定(详见“一分钟读懂低功耗蓝牙连接数据包”)

2. 头信息
Data Header: 0x0712 000. .... = RFU: 0
...1 .... = More Data: True
.... 0... = Sequence Number: 0
.... .0.. = Next Expected Sequence Number: 0
.... ..10 = LLID: Start of an L2CAP message or a complete L2CAP message with no fragmentation (0x2)
000. .... = RFU: 0
...0 0111 = Length: 7

3. L2CAP 长度
解释同(请求包)。
Length: 3

4. L2CAP 通道号
解释同(请求包)。
CID: Attribute Protocol (0x0004)

5. ATT 命令
标准:

实例:
Opcode: Exchange MTU Response (0x03) 0... .... = Authentication Signature: False
.0.. .... = Command: False
..00 0011 = Method: Exchange MTU Response (0x03)

6) MTU 值
Server Rx MTU: 23

7)CRC
CRC: 0xf4767e
[Expert Info (Note/Checksum): CRC unchecked, not all data available]

网友评论