This example requires one of the following SoftDevices: S132, S140
Important: Before you run this example, make sure to program the SoftDevice.
The ATT_MTU Throughput Example shows how different connection parameters influence the throughput performance of BLE connections. The following parameters can be tuned:
- ATT_MTU size: The default Maximum Transmission Unit (MTU) is 23 bytes. When increasing this value, longer ATT payloads can be achieved, increasing ATT throughput.
- Data length: The default data length for a radio packet is 27 bytes. Data length extension allows to use larger radio packets, so that more data can be sent in one packet, increasing throughput.
- Connection interval: The connection interval defines how often the devices must listen on the radio. When increasing this value, more packets may be sent in one interval, but if a packet is lost, the wait until the retransmission is longer. Increasing this value can increase throughput, provided that the GAP event length increases by the same amount or connection event length extension is enabled.
- Physical layer (PHY) data rate: The over-the-air data rate used to be limited to 1 Ms/s in Bluetooth low energy. Starting with Bluetooth 5, higher data data rates are permitted to achieve faster transmission, and it is possible to use coded PHY (available on the nRF52840 SoC only) for long-range transmission.
- Connection event length extension: This option controls if the SoftDevice should attempt to extend the radio time for connections in a connection interval. This can positively affect throughput by making it possible to send more packets in a connection interval. This effect increases with the duration of the connection interval.
- GAP event length: This setting determines the duration of a connection event within a connection interval. Increasing this value can greatly affect the throughput.
The example uses the Experimental: GATT Module. It can be run in different modes and assume either the BLE Central or the BLE Peripheral role.
Testing the example application requires two boards, which are both programmed with the same application. One of the boards must be connected to the computer and will serve as the tester. The other board responds to the requests that are sent by the tester.
When the application starts in tester mode, it uses the following default test configuration:
Parameter | Value |
ATT_MTU size | 247 bytes |
Data length | 27 bytes |
Connection interval | 6 units (7.5 ms) |
PHY data rate | 2 Ms/s |
Connection event extension | ON |
GAP event length | 400 units (500 ms) |
A menu is printed on UART. Through the menu, you can choose to run the test or configure the connection parameters. During the test, the boards connect with the given parameters. The tester then sends 1 MB of data. After that, it queries how much data was received by the other board.
Note that some parameters cannot be changed at runtime and recompilation is required:
Setup
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput
Button assignments - in addition to those defined in BSP BLE Button Assignments:
- Button 3: Put the application into tester mode.
- Button 4: Put the application into responder mode.
LED assignments:
- LED 1 on: Looking for a partner (either advertising or scanning, depending on the mode).
- LED 2 on: Connection established.
- LED 3 blinking: Test is running.
- LED 4 on: Test completed.
Testing
Test the ATT_MTU Throughput Example application by performing the following steps:
- Compile and program the application on both test boards.
- Keep one of the boards connected to the computer. This board will serve as the tester. The other board will serve as responder. The tester board is assigned a COM port, which is visible in the Device Manager.
- Press Button 4 on the responder to put the application into responder mode. Observe that LED 1 is turned on, indicating that the board is scanning and advertising.
- Press Button 3 on the tester to put the application into tester mode.
- Start a terminal emulator like PuTTY (recommended) with the following Terminal settings and UART and USB settings.
- Open a serial connection to the COM port used by tester board. A command prompt is displayed.
- Type
config print
in the terminal to print the current configuration.
- Type
config
in the terminal to configure the test parameters to your choice. Use the Tab key for auto-completion and to view the options available for a parameter.
- Type
run
in the terminal to start the test.
- Observe that LED 3 blinks on both boards and that the tester prints the amount of kilobytes sent on UART.
- Observe that LED 4 turns on on both boards when the test is finished. The tester prints the elapsed time, the throughput, and the amount of bytes received by the responder.
- Observe that LED 1 turns on on the responder and all LEDs are off on the tester, indicating that the boards have disconnected. The tester prints the current parameter configuration and the menu.
- Repeat the test after having changed the parameters. Observe how the throughput changes for different sets of parameters.