Full name: Maximum transmission unit and fragmentation.
Definition
The MTU (maximum transmission unit) of a protocol layer is the largest message, in bytes, that the layer sends or accepts as one unit. Fragmentation splits a message that is too large for a lower layer into pieces that fit, and the receiver joins the pieces again, which is called reassembly or recombination. Each layer has its own limit, counts it in its own way and adds its own header, so a quoted MTU means something only when the layer is named and that layer’s header bytes are subtracted.
The idea
A developer reads that a BLE §7.1 (Bluetooth Low Energy) link has “an MTU of 247” and “a data length of 251”. The developer tries to send 247 bytes of sensor data in one notification, a message that a BLE device sends unasked, and finds that only 244 fit. The three numbers belong to three different layers. The term comes from networking in general: on Ethernet the usual MTU is 1500 bytes, the largest IP (Internet Protocol) packet that one Ethernet frame carries.
Picture envelopes inside envelopes. The application’s data goes into an ATT §7.9 (Attribute Protocol) envelope, which adds 3 bytes; that goes into an L2CAP §7.15 (Logical Link Control and Adaptation Protocol) envelope, which adds 4 bytes; that goes into a Link Layer §7.6 envelope, the radio packet. Each envelope has a maximum size, and when the middle envelope is larger than one radio packet allows, it is cut into pieces: that is fragmentation. The picture fails in one respect. The layers do not count their limits the same way: the ATT MTU includes the ATT header, whereas the Link Layer data length counts only the payload, without the Link Layer’s own header.
How it works
Follow one notification down the layers of a BLE connection.
ATT. The message is a 1-byte opcode, a code that names the operation, then the 2-byte handle that identifies the attribute, then the value. The ATT MTU, written
ATT_MTUin the specification, is the largest whole ATT message, these 3 bytes included. It is 23 bytes until the client sends an Exchange MTU Request stating the largest ATT message it can receive and the server answers with its own number; both then use the smaller of the two. The client may make this exchange only once per connection. A notification, an indication, a write request and a write command therefore carry at most the ATT MTU minus 3 bytes of value; other operations have other overhead. ATT never splits one notification over several messages: if the value is longer, only its first ATT MTU minus 3 bytes are sent.L2CAP. L2CAP puts a 4-byte basic header in front of the ATT message: a 2-byte length and a 2-byte channel identifier, which is
0x0004for ATT.Link Layer. The Link Layer sends packets whose payload is at most the data length in effect. The payload does not include the 2-byte Link Layer header or, on an encrypted link, the 4-byte MIC (message integrity §1.9 check), a code that lets the receiver detect tampering. On the air the radio also adds a preamble, a known bit pattern that lets the receiver lock on; a 4-byte access address that identifies the connection; and a 3-byte CRC §4.32 (cyclic redundancy check), a code that detects transmission errors. Before Bluetooth 4.2 the data length was always 27 bytes. The Data Length Extension (DLE) of Bluetooth 4.2 allows up to 251 bytes: each device states the largest payload, and the longest packet duration, that it can send and receive, and each direction uses the smaller of the sender’s and the receiver’s numbers.
Fragmentation. If the L2CAP message is longer than the data length, it is split into several Link Layer packets. A 2-bit field in each Link Layer header marks the first piece as a start and the others as continuations. The pieces get no further L2CAP header; the receiver joins them until it has as many bytes as the L2CAP length field announced.
These rules explain two common numbers. A Link Layer payload of 27 bytes holds the 4-byte L2CAP header and bytes of ATT message, exactly the default ATT MTU, so a full default-size ATT message fits one default-size packet. A payload of 251 bytes holds bytes of ATT message, so 247 is the largest ATT MTU at which every ATT message still fits in one radio packet.
An application adds a fourth layer when an object is larger than one value. ATT does not split values, so the application cuts the object into chunks and usually gives each chunk a small header of its own, such as a sequence number or an offset, so that the receiver can put the chunks back in order and notice a missing one. That header takes room from every chunk.
Worked example
From 251 to 244. Suppose the devices exchange ATT receive MTUs of 247 bytes each on the fixed ATT channel. The smaller value is 247, their ATT MTU. Separately, assume the Link Layer can carry 251 data bytes in one packet in the sending direction. A 247-byte ATT message and its 4-byte L2CAP header fit exactly. Subtract the 1-byte opcode and the 2-byte handle from 247 to get 244 bytes of value per notification or write request.
The same message without the extension. Keep the ATT MTU at 247 but let the data length be the default 27 bytes. The 251-byte L2CAP message needs packets, where means rounded up to a whole number: 9 full packets carry bytes, and the tenth carries the remaining . To compare air time, assume the uncoded radio mode of 1 megabit per second, in which each byte takes 8 s; an encrypted link; an empty packet in reply to every data packet; and the 150 s gap that the specification requires between packets. An empty packet is bytes on the air (preamble, access address, header, CRC; an empty packet has no MIC), which takes 80 s.
With the extension, one packet of bytes takes s. With the two gaps and the empty reply, the exchange takes s for 244 value bytes: useful bytes per second.
Without it, a full packet of bytes takes s, and its exchange s. The last packet, bytes, takes 176 s, and its exchange s. The total is s for the same 244 bytes: about 35,200 useful bytes per second.
The ATT MTU is the same in both cases. The data length alone makes the transfer times slower, because every extra packet repeats the radio overhead, the two gaps and the empty reply. Both figures are upper limits for continuous sending; a real link also loses time between connection events.
Chunks for an application object. An application sends a 1,000-byte object with an ATT MTU of 247, so each notification carries 244 bytes. A 4-byte application header in each chunk leaves bytes of object data per chunk. The object needs chunks: four full chunks carry bytes, and the fifth carries the remaining .
Stated precisely
Let be the ATT MTU in bytes, and the Link Layer data length in effect for the sending direction, in bytes of payload per packet, not counting the Link Layer header or the MIC. Then:
a notification, indication, write request or write command carries at most value bytes;
an ATT message of bytes, with , becomes an L2CAP message of bytes, which needs Link Layer packets;
every ATT message fits in a single Link Layer packet exactly when ;
an object of bytes sent in chunks of useful bytes each needs chunks.
The allowed values are and . is fixed by at most one exchange per connection and is the same in both directions. is negotiated separately for each direction and may change during the connection.
Limits and common mistakes
Name the layer. The ATT MTU limits an ATT message. The Link Layer data length limits the payload of one radio packet in a given direction. Their values are negotiated separately. A 247-byte message fits into one 251-byte payload in this example because its L2CAP header needs four more bytes. A smaller packet payload requires fragmentation.
A larger limit is not a faster link. The ATT MTU and the data length are ceilings; throughput also depends on the connection interval §7.7, on how many packets each connection event carries, and on the radio mode.
A larger limit costs memory before any check on the content runs. A receiver that agrees to an ATT MTU of 247 must be able to hold a 247-byte message, and a receiver that joins fragments must hold the partial message until the last piece arrives. This memory belongs in the device’s worst-case memory budget.
Bluetooth distinguishes fragmentation from segmentation. Fragmentation splits one L2CAP message into radio packets and adds no L2CAP header to the pieces. Segmentation, used on L2CAP channels with LE credit-based flow control §7.16, splits one upper-layer message into several L2CAP messages, each with its own header.
A disconnection loses a partly joined message. The Link Layer delivers the pieces reliably and in order while the connection lasts, but a message whose last piece had not arrived when the connection ended is discarded, and the application must send the whole message again.
Questions answered
Which layer’s MTU is being quoted, and how much is payload?
Ask which of three limits is meant, because in BLE (Bluetooth Low Energy) each one counts different bytes. The ATT MTU, the maximum transmission unit of ATT (Attribute Protocol), counts the whole ATT message, so a notification or write carries at most the ATT MTU minus 3 bytes of value: 1 byte of opcode and 2 bytes of attribute handle. The Link Layer data length counts the payload of one radio packet, which holds a 4-byte L2CAP (Logical Link Control and Adaptation Protocol) header in front of the ATT message. The MTU of an L2CAP channel counts the largest message the application may hand to that channel.
With a data length of 251 bytes, the ATT message can be bytes and the value bytes; an application that adds its own 4-byte chunk header has 240 bytes of data per chunk. Equal numbers at different layers are not interchangeable: an ATT MTU of 247 over a data length of 27 still works, but every full-size message is then split into 10 radio packets.
Related entries: L2CAP (§7.15), LE credit-based flow control (§7.16), Overflow-safe range check (§4.17), Link Layer (§7.6), Throughput versus goodput (§7.39). Further reading: [91, 92, 93].