zephyr/samples/bluetooth/iso_connected_benchmark
Rubin Gerritsen 9cb339166e Samples: iso_connected_benchmark: Fix invalid latency
The default transport latency was not valid.
Set it to a value that is large enough.
The minimum possible transport latency is 16580 us,
but this assumes the controller ignores the RTN=2.
If the controller uses the RTN=2, the transport latency will
be slightly larger than 30 ms depending on
how the controller chooses to setup the ISO link.

Therefore, we set it to 40 ms to ensure the default
configuration is valid.

How these numbers were found:

For unframed PDUs this is defined in Core_v5.4, Vol 6,
Part G, Section 3.2.2:
  Transport_Latency =
    CIG_Sync_Delay + FT * ISO_Interval - SDU_Interval

Because unframed PDUs are being used, the ISO interval needs
to be a multiple of SDU interval.
If MaxPDU = MaxSDU and the PHY is 2M, this results in that
the maximum subevent size is:
2120 * 2 + 2 * 150 = 4540.
For 2 CISes this is 9080 us > 7500
Therefore, the controller has to set the ISO interval to a
minimum of 15000 us in order to fit the packets.

Based upon this info, the controller has the freedom to ignore
or use the requested RTN=2.
1. Ignore -> NSE is 2: Minimum ISO interval is 15000 us
2. RTN = 2, Increase NSE: 4 * 4540 = 18160 -> ISO_Interval = 22500 us
3. RTN = 2, Increase the FT to 2, NSE = 2 -> ISO_Interval = 15000 us

For (1):
  Transport_Latency = CIG_Sync_Delay + 15000 - 7500
                    = CIG_Sync_Delay + 7500
For (2):
  Transport_Latency = CIG_Sync_Delay + 22500 - 7500
                    = CIG_Sync_Delay + 15000
For (3):
  Transport_Latency = CIG_Sync_Delay + 2 * 15000 - 7500
                    = CIG_Sync_Delay + 22500

As shown in Core_v5.4, Vol 6, Part B, Section 4.5.14,
CIG_Sync_Delay needs to be larger than or equal to the length of
all ISO events. That is, the sum of the subevents:

For (1): CIG_Sync_Delay = 2 * 4540 = 9080
For (2): CIG_Sync_Delay = 4 * 4540 = 18160
For (3): CIG_Sync_Delay = 2 * 4540 = 9080

This results in the following transport latencies:

For (1): Transport_Latency = 9080 + 7500 = 16580
For (2): Transport_Latency = 18160 + 15000 = 33160
For (3): Transport_Latency = 9080 + 22500 = 31580

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-06-09 14:16:34 -04:00
..
src Samples: iso_connected_benchmark: Fix invalid latency 2023-06-09 14:16:34 -04:00
CMakeLists.txt
prj.conf Bluetooth: ISO: Add Kconfig for ISO central/peripheral 2022-05-13 12:44:47 -07:00
README.rst
sample.yaml samples, tests: convert string-based twister lists to YAML lists 2023-05-10 09:52:37 +02:00

.. _iso_connected_benchmark:

Bluetooth: Throughput
#####################

The ISO Connected Channels Benchmark sample measures and reports packet loss
and sync loss in connected ISO channels.


Overview
********

The sample transmits data between the *central* and the *peripheral*
and measures the quality of the ISO channels.

The application can be used as both a central and a peripheral, and the mode
can easily be changed.

Requirements
************

* BlueZ running on the host, or
* A board with Bluetooth Low Energy 5.2 support
* A Bluetooth Controller and board that supports setting
  CONFIG_BT_CTLR_CENTRAL_ISO=y
* A remote board running the same sample as the reversed role that supports
  setting CONFIG_BT_CTLR_PERIPHERAL_ISO=y

Building and running
********************

This sample can be found under
:zephyr_file:`samples/bluetooth/iso_connected_benchmark` in the Zephyr tree.

See :ref:`bluetooth samples section <bluetooth-samples>` for details.


Testing
=======

After programming the sample to both boards, test it by performing the following
steps:

1. Connect to both boards with a terminal emulator (for example, PuTTY or
   minicom).
#. Reset both boards.
#. In one of the terminal emulators, type "c" to start the application on the
   connected board in the central role.
#. In the other terminal emulator, type "p" to start the application in the
   peripheral role.
#. Optionally modify the central ISO settings using the console.
#. Observe that the central and the peripheral connects.
#. Observe the receive statistics on the devices (the connected ISO channels may
   by uni- or bidirectional).

Sample output
==============
The peripheral will output overall data (since boot),
current connection (since the CIG was connected) and latest 1000 received
packets::

  *** Booting Zephyr OS build zephyr-v2.5.0-4098-gdcaaee6db2f5  ***
   [00:00:00.392,333] <inf> iso_connected: Starting Bluetooth Throughput example
   [00:00:00.405,395] <inf> iso_connected: Bluetooth initialized
   Choose device role - type c (central role) or p (peripheral role), or q to quit: p
   Peripheral role
   [00:00:10.281,555] <inf> iso_connected: Registering ISO server
   [00:00:10.281,555] <inf> iso_connected: Starting advertising
   [00:00:10.282,684] <inf> iso_connected: Waiting for ACL connection
   [00:00:16.711,517] <inf> iso_connected: Connected: FA:4C:4B:DB:D3:89 (public)
   [00:00:16.711,669] <inf> iso_connected: Waiting for ISO connection
   [00:00:16.802,856] <inf> iso_connected: Incoming ISO request
   [00:00:16.802,856] <inf> iso_connected: Returning instance 0
   [00:00:17.016,845] <inf> iso_connected: ISO Channel 0x20002934 connected
   [00:00:17.769,439] <inf> iso_connected: Sending value 100
   [00:00:17.774,902] <inf> iso_connected: Overall     : Received 100/100 (100.00%) - Total packets lost 0
   [00:00:17.774,932] <inf> iso_connected: Current Conn: Received 100/100 (100.00%) - Total packets lost 0
   [00:00:17.774,963] <inf> iso_connected: Latest 1000 : Received 100/100 (100.00%) - Total packets lost 0
   [00:00:17.774,963] <inf> iso_connected:
   [00:00:18.529,510] <inf> iso_connected: Sending value 200
   [00:00:18.532,409] <inf> iso_connected: Overall     : Received 200/200 (100.00%) - Total packets lost 0
   [00:00:18.532,470] <inf> iso_connected: Current Conn: Received 200/200 (100.00%) - Total packets lost 0
   [00:00:18.532,501] <inf> iso_connected: Latest 1000 : Received 200/200 (100.00%) - Total packets lost 0


The central will ask if any changes to the current settings are wanted.
If y/Y is chosen, then it will create a prompt to changes the settings,
otherwise continue with the current settings. The central will then start
scanning for and connecting to a peer device running the sample as peripheral
role. Once connected, the central will output overall data (since boot),
current connection (since the CIG was connected) and latest 1000 received
packets::

   *** Booting Zephyr OS build zephyr-v2.5.0-4098-gdcaaee6db2f5  ***
   [00:00:00.459,869] <inf> iso_connected: Starting Bluetooth Throughput example
   [00:00:00.472,961] <inf> iso_connected: Bluetooth initialized
   Choose device role - type c (central role) or p (peripheral role), or q to quit: c
   Central role
   Change ISO settings (y/N)?
   [00:00:03.277,893] <inf> iso_connected: Scan started
   [00:00:03.277,893] <inf> iso_connected: Waiting for advertiser
   [00:00:03.899,963] <inf> iso_connected: Found peripheral with address F4:5A:12:BF:4F:2C (public) (RSSI -24)
   [00:00:03.900,024] <inf> iso_connected: Stopping scan
   [00:00:03.908,020] <inf> iso_connected: Scan stopped
   [00:00:03.908,020] <inf> iso_connected: Connecting
   [00:00:04.007,232] <inf> iso_connected: Connected: F4:5A:12:BF:4F:2C (public)
   [00:00:04.007,354] <inf> iso_connected: Binding ISO
   [00:00:04.007,812] <inf> iso_connected: Connecting ISO channels
   [00:00:04.312,744] <inf> iso_connected: ISO Channel 0x20002934 connected
   [00:00:05.065,368] <inf> iso_connected: Sending value 100
   [00:00:05.072,052] <inf> iso_connected: Overall     : Received 100/100 (100.00%) - Total packets lost 0
   [00:00:05.072,113] <inf> iso_connected: Current Conn: Received 100/100 (100.00%) - Total packets lost 0
   [00:00:05.072,143] <inf> iso_connected: Latest 1000 : Received 100/100 (100.00%) - Total packets lost 0
   [00:00:05.072,143] <inf> iso_connected:
   [00:00:05.825,439] <inf> iso_connected: Sending value 200
   [00:00:05.829,589] <inf> iso_connected: Overall     : Received 200/200 (100.00%) - Total packets lost 0
   [00:00:05.829,620] <inf> iso_connected: Current Conn: Received 200/200 (100.00%) - Total packets lost 0
   [00:00:05.829,650] <inf> iso_connected: Latest 1000 : Received 200/200 (100.00%) - Total packets lost 0