Section 7.12

Notification versus indication

Definition

Notification and indication are the two ways in which a server of ATT §7.9 (Attribute Protocol), the BLE §7.1 (Bluetooth Low Energy) protocol for reading and writing small data items called attributes, sends an attribute’s current value to a client unasked. A notification gets no reply. An indication must be answered by the client’s ATT layer with a confirmation, and the server sends no further indication until that confirmation arrives. Both travel over the Link Layer §7.6, the radio protocol layer below ATT, which acknowledges and resends every data packet of a connection.

The idea

A heart-rate sensor measures the pulse once per second and sends each reading to a phone. A lost reading is replaced one second later by a newer one, so the sensor gains nothing from waiting for a reply. A door sensor that reports “door opened” to a home hub is different: if the report does not arrive, the sensor should keep it and send it again. The heart-rate sensor uses notifications, and the door sensor uses indications.

A common mistake is to call notifications unreliable at the radio level because nothing answers them. That mixes up acknowledgments at two layers. The Link Layer, which runs in the radio controller of each device, acknowledges every packet of a connection and resends every packet that is not acknowledged, whatever the packet contains, so a notification is as well protected against radio errors as an indication. An indication adds a reply from one layer higher: the client’s ATT layer tells the server’s ATT layer that the value arrived. That reply also reveals losses the radio cannot see, such as a value dropped because the receiving software had no free memory, and it tells the server which value to send again.

How it works

  1. Subscription. GATT §7.10 (Generic Attribute Profile), the layer above ATT that groups attributes into characteristics, each a value together with attributes that describe it, lets a server push a characteristic’s value only after the client has asked for it. The client asks by writing to a small attribute next to the value, the Client Characteristic Configuration descriptor: 0x0001 turns notifications on, and 0x0002 turns indications on.

  2. The message. The server’s ATT layer builds a message of three parts: a 1-byte opcode, a code that names the operation (0x1B for a notification, 0x1D for an indication); the 2-byte handle, the number that identifies the attribute; and the value. Let MM be the ATT MTU §7.14 (maximum transmission unit), the largest ATT message the two devices have agreed to exchange, which is 23 bytes unless they agree on more. The value is at most M−3M - 3 bytes long.

  3. The radio. The Link Layer sends the message in one or more radio packets. Each packet carries two 1-bit counters, SN (sequence number) and NESN (next expected sequence number). The receiver acknowledges a packet by changing NESN in the next packet it sends back. If the packet arrived damaged, which the receiver detects with the CRC §4.32 (cyclic redundancy check, an error-detecting code at the end of every packet), or if the receiver has no room for it, the receiver leaves NESN unchanged, and the sender sends the same packet again. A packet that arrives a second time carries the old SN, and the receiver discards its content. This repeats until the packet is acknowledged or the connection ends.

  4. The client’s ATT layer. For a notification, it passes the value to the application and replies nothing. For an indication, it also sends a Handle Value Confirmation, a 1-byte message that holds only the opcode 0x1E. The client must confirm every indication it receives, even one with an invalid handle or value, which it then discards.

  5. The server’s next step. After a notification, the server may send the next value at once, and several notifications can go out in one connection event, the short exchange of packets that takes place once per connection interval §7.7. After an indication, the server must wait for the confirmation before it sends another indication on the same ATT bearer, the channel that carries ATT messages between the two devices. If no confirmation arrives within 30 seconds, the indication has failed, and the server may send no further ATT message on that bearer; for the usual ATT channel, only a new connection provides a new bearer.

A notification can still be lost, but not to a radio error on a working connection. It is lost if the connection ends while the notification waits in a queue or before its last packet is acknowledged; if the sending stack, the protocol software of the sending device, has no free buffer and refuses it; or if the receiving stack has no free buffer, because the ATT specification requires a client that cannot process a received notification for that reason to discard it. In none of these cases does any reply tell the server’s ATT layer that the value is missing.

Worked example

Take a connection with a connection interval of 30 ms and the default ATT MTU of 23 bytes, so that each value carries at most 23−3=2023 - 3 = 20 bytes. The three traces below are hypothetical.

A retransmission §7.36 without an ATT reply. At 0 ms the server sends a notification. Interference damages the packet, the client’s CRC check fails, and the client’s Link Layer leaves NESN unchanged. At 30 ms, in the next connection event, the server’s Link Layer sends the same packet again. This time the CRC check passes, the client acknowledges the packet, and the client’s ATT layer hands the 20-byte value to the application. No ATT message went back to the server: the radio resent the value although no ATT confirmation was ever asked for.

The cost of waiting. Suppose the server’s stack sends up to 4 notifications in each connection event: 4×20=804 \times 20 = 80 bytes every 30 ms, or 80/0.030≈266780 / 0.030 \approx 2667 bytes per second. Now suppose each indication goes out in one connection event, its confirmation comes back in the next, and the next indication goes out in the event after that: one value every 2×30=602 \times 30 = 60 ms, or 20/0.060≈33320 / 0.060 \approx 333 bytes per second, one eighth of the notification rate.

What the confirmation does not cover. At 0 ms the server sends an indication that carries an alarm, and the client’s ATT layer confirms it at once. At 30 ms the confirmation reaches the server, which marks the alarm as delivered. The client’s application plans to write the alarm to flash memory §6.6 at 50 ms, but the client loses power at 40 ms. The alarm is gone, and the server believes it was delivered.

Stated precisely

Three acknowledgments can be involved, and each states one fact:

On one ATT bearer, the client answers every indication with exactly one confirmation; the server has at most one unconfirmed indication outstanding; and an indication still unconfirmed 30 seconds after it was sent has failed and ends ATT traffic on that bearer. A notification gets no answer, and on the usual (unenhanced) ATT bearer a client whose buffers are full discards it. Beneath both procedures, the Link Layer delivers the packets of one connection in order and without repeats, but only while the connection lasts: a packet not yet acknowledged when the connection ends may or may not have arrived.

Limits and common mistakes

A confirmation is not an application receipt. The client’s ATT layer confirms on receipt, so a server that must know that a value was stored or acted on needs a receipt defined by the application, as the third trace shows.

An indication can arrive twice. If the connection ends after the client received an indication but before the confirmation reached the server, the server cannot tell whether the value arrived, and a careful server sends it again on the next connection. The Link Layer removes repeats only within one connection, so the client must recognize a repeat itself, for example by a sequence number inside the value, or must handle values so that a repeat does no harm, which makes the handling idempotent §8.31. The Retransmission and duplicate delivery entry treats this problem in general.

Neither procedure shows who sent the value. That comes from encrypting the link with keys set up by pairing §7.17, or from a message authentication code §5.7 computed over the value.

Bluetooth 5.2 added the Enhanced ATT (EATT) bearer, which carries ATT over an L2CAP §7.15 (Logical Link Control and Adaptation Protocol) channel that uses LE credit-based flow control §7.16. On an EATT bearer the client must process every notification it receives, so the loss to a full receive buffer does not occur there: the channel’s credits stop the sender before the receiver runs out of room.

Questions answered

Does lack of ATT confirmation mean the radio has no retransmission?

No. In BLE (Bluetooth Low Energy), the Link Layer, the radio protocol layer, acknowledges every data packet on a connection and resends any packet that arrives damaged or is not acknowledged, until the packet is acknowledged or the connection ends. It does this whatever the packet carries, so a notification, which gets no ATT (Attribute Protocol) confirmation, is protected against radio errors exactly as an indication is.

The ATT confirmation of an indication is a separate acknowledgment one layer higher: it tells the server that the client’s ATT layer received the value. Without it, a notification can still be lost unnoticed when the connection ends before delivery or when the sending or receiving software has no free buffer. Neither acknowledgment says that the client’s application stored or acted on the value; that needs a receipt defined by the application.

Related entries: ATT (§7.9), Retransmission and duplicate delivery (§7.36), Durability (§8.2), Link Layer (§7.6), Write request versus write command (§7.13), Idempotency (§8.31). Further reading: [91, 93].