How long it takes to establish a BLE pairing?

Is there any reference information on how long (in ms) different steps in a BLE pairing process takes? e.g. Pairing Feature Exchange, Short Term Key Generation, Long Term Key Generation, Key Distribution, Bonding, etc.

Assuming that we use BLE 5.0+ and Nordic SoftDevice S.140. 

Please advise. 

Parents
  • Hi,

    I do not have numbers for the various steps, but the by far most processing intencive (and thus time consuming) operation is the Diffie–Hellman (DH) key exchange when doing LESC pairing. For this reason, the nRF5 SDK has a separate call to nrf_ble_lesc_request_handler() in the sample applications that use LESC, and this is called from the application main loop as calling it from an interrupt priority would block other interrupts of same or lower priority for a long time. This is done in software in the nRF52 series devices (except for nRF52840 which has a hardware crypto accelerator). Normally, a LESC pairing operation takes in the order of a couple of seconds.

    PS: There are quite a few packets sent back and forth during a pairing/bonding procedure, so the connection parmeters also play a significant role in the the time it takes to complete it (particularily a very long connection interval will slow it down).

Reply
  • Hi,

    I do not have numbers for the various steps, but the by far most processing intencive (and thus time consuming) operation is the Diffie–Hellman (DH) key exchange when doing LESC pairing. For this reason, the nRF5 SDK has a separate call to nrf_ble_lesc_request_handler() in the sample applications that use LESC, and this is called from the application main loop as calling it from an interrupt priority would block other interrupts of same or lower priority for a long time. This is done in software in the nRF52 series devices (except for nRF52840 which has a hardware crypto accelerator). Normally, a LESC pairing operation takes in the order of a couple of seconds.

    PS: There are quite a few packets sent back and forth during a pairing/bonding procedure, so the connection parmeters also play a significant role in the the time it takes to complete it (particularily a very long connection interval will slow it down).

Children
  • The ECDH operation takes a few tens of milliseconds and is indeed the most CPU intense part of the pairing, but considering even the minimal allowed connection interval of 7.5 ms, exchanging packets over the air is what is typically dominating the pairing time.

    When you use the LESC Passkey Entry pairing method, the Bluetooth standard uses an extremely slow custom way to check the 20-bit long passkey which requires 4 packets to verify and reveal each bit, in total 80 packets going back and forth (which is also why a passkey may never be static between pairing attempts). Even if the peripheral responds to each packet during the same connection event, theoretically this would require at least 40 connection intervals, so at least 300 ms at 7.5 ms connection interval. In practice BLE stacks are typically not optimised to be able to reply in the same connection event so the reply will come in the next, doubling the time to 600 ms.

    If you don't use the passkey entry method, the process is much quicker. Every step that you mention is typically one pair of packets being exchanged so you can take roughly the number of steps times two times the connection interval to get an estimate.

    I would suggest you to use a BLE sniffer or use the HCI packet log feature for example on a smartphone to see the exact procedure and the timing if you want to know more.

  • Thanks. How can I use a BLE sniffer to get an estimate of the time it takes for pairing? Is there an example or tutorial? 

  • Hi,

    You can use the nRF Sniffer for Bluetooth LE if you have an additional nRF52 series DK or dongle. This tutorial describe how to use it, and you can also refer to the sniffer documentation.

Related