Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum packet length for Bluetooth LE?

I was wondering what was the maximum packet length in Bluetooth Low Energy. The 20 bytes limit if often said, for example here

"BLE allow you transfer maximum is 20 bytes."

"You are correct that the BLE specification doesn't allow write operations to exceed 20 bytes."

However, reading the Bluetooth Core Specification, we can see that the ATT_MTU value is written with 2 bytes, meaning that it can go up to 65 535 bytes.

What's the truth behind all this ?

like image 475
jdoe Avatar asked Aug 12 '16 08:08

jdoe


People also ask

How much data can send over BLE?

For Bluetooth 4.0, the BLE Radio is capable of transmitting 1 symbol per microsecond and one bit of data can be encoded in each symbol. This gives a raw radio bitrate of 1 Megabit per second (Mbps).

How many bytes are in a packet of BLE?

It allows up to 254 bytes of advertising data in the packet payload.

What is data length extension in BLE?

The data length extension feature allows the LE controller to send data channel packet data units (PDUs) with payloads of up to 251 bytes of application data, while in the connected state. Furthermore, a new PDU size can be negotiated by either side at any time during a connection.


1 Answers

Specification is always right !

In Bluetooth 4.0, BLE was introduced with a maximum payload of 33 bytes (not including Access Address and CRC fields). Each layer in the protocol stack takes its cut:

  • 2 bytes for packet header (type and length),
  • 4 bytes for MIC (when encryption is enabled),
  • 4 bytes for L2CAP header (channel ID and packet length),
  • ATT protocol is left with 23 bytes, which is the default and minimal MTU for ATT protocol.

With an ATT write request (or notification), 3 bytes are used by command type and attribute ID, 20 bytes are left for the attribute data.

At the ATT level, this limit may be enlarged in two ways:

  • Using fragmentation at the L2CAP level:

    L2CAP will split ATT PDUs in 27 bytes fragments (23 for the first one).

    Drawbacks:

    • It needs memory on both sides,
    • It is less reliable as packets may get lost by some implementation (even if spec do not speak about packet loss at the L2CAP level, it happens)
  • Using packet length extension introduced in Bluetooth 4.2:

    Up to 251 bytes at the radio level (255 with MIC), so 242 bytes available for attribute data.

    Drawbacks:

    • Still new, needs hardware support, so not implemented everywhere (even if announcing BLE 4.2 support),

    • Packet with longer airtime will have more chances of getting jammed, so longer packets implies more retransmissions.

If both methods are used, L2CAP may use bigger fragments.

Whatever low-level splitting of ATT PDU, Attribute value length is limited to 512 by 3.F 3.2.9.

like image 124
Nipo Avatar answered Sep 16 '22 22:09

Nipo