Bluetooth: Throughput¶
The Bluetooth Throughput sample uses the GATT Throughput Service to measure Bluetooth Low Energy throughput performance. You can use it to determine the maximum throughput, or to experiment with different connection parameters and check their influence on the throughput.
Overview¶
The sample transmits data between two boards, the tester and the peer, and measures the throughput performance. To do so, it uses the GATT Throughput Service.
The sample demonstrates the interaction of the following connection parameters:
- ATT_MTU size
In Bluetooth Low Energy, the default Maximum Transmission Unit (MTU) is 23 bytes. When increasing this value, longer ATT payloads can be achieved, increasing ATT throughput.
- Data length
In Bluetooth Low Energy, 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.
- Physical layer (PHY) data rate
Starting with Bluetooth 5, the over-the-air data rate in Bluetooth Low Energy can exceed 1 Ms/s (mega symbol per second), which allows for faster transmission. In addition, it is possible to use coded PHY (available on the nRF52840 SoC only) for long-range transmission.
By default, the following connection parameter values are used:
Parameter |
Value |
---|---|
ATT_MTU size |
247 bytes |
Data length |
251 bytes |
Connection interval |
320 units (400 ms) |
PHY data rate |
2 Ms/s |
Changing connection parameter values¶
You can experiment with different connection parameter values by reconfiguring the values using menuconfig and then compiling and programming the sample again to at least one of the boards.
Note
In a Bluetooth Low Energy connection, the different devices negotiate the connection parameters that are used. If the configuration parameters for the devices differ, they agree on the lowest common denominator.
By default, the sample uses the fastest connection parameters. If you change them to lower values, it is sufficient to program them to one of the boards. If you were to change them to higher values, you would need to program both boards again.
Requirements¶
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10095 |
|
||
PCA10056 |
|
||
PCA10010 |
|
||
PCA10040 |
|
You can use any two of the development kits listed above and mix different development kits.
Note
If you use nRF5340 DK, add the following options to the configuration of the network sample:
CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_RX_BUF_LEN=255
The sample also requires a connection to a computer with a serial terminal for each of the development kits.
Building and running¶
This sample can be found under samples/bluetooth/throughput
in the nRF Connect SDK folder structure.
See Building and programming a sample application for information about how to build and program the application.
Testing¶
After programming the sample to both boards, test it by performing the following steps:
Connect to both boards with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.
Reset both boards.
In one of the terminal emulators, type “s” to start the application on the connected board in the slave (peer) role.
In the other terminal emulator, type “m” to start the application in the master (tester) role.
Observe that the boards establish a connection. The tester outputs the following information:
Ready, press any key to start
Press a key in the terminal that is connected to the tester.
Observe the output while the tester sends data to the peer. At the end of the test, both tester and peer display the results of the test.
Sample output¶
The result should look similar to the following output.
For the tester:
***** Booting Zephyr OS 1.12.99 *****
[bt] [INF] hci_vs_init: HW Platform: Nordic Semiconductor (0x0002)
[bt] [INF] hci_vs_init: HW Variant: nRF52x (0x0002)
[bt] [INF] hci_vs_init: Firmware: Standard Bluetooth controller (0x00) Version 1.12 Build 99
[bt] [INF] bt_dev_show_info: Identity: c5:ca:14:98:3b:90 (random)
[bt] [INF] bt_dev_show_info: HCI: version 5.0 (0x09) revision 0x0000, manufacturer 0x05f1
[bt] [INF] bt_dev_show_info: LMP: version 5.0 (0x09) subver 0xffff
Bluetooth initialized
Choose device role - type s (slave role) or m (master role):
Master role. Starting scanning
Found a peer device c5:6f:8a:38:95:27 (random)
Connected as master
Conn. interval is 320 units
MTU exchange pending
MTU exchange successful
Ready, press any key to start
^.-.^ ^..^
^-/ooooo+:.^ ^.--:+syo/.
^-/oooooooooooo+:. ^.-:::::+yyyyyy+:^
^-/+oooooooooooooooooo/-^ ^.-::::::::/yyyyyyyhhs/-
^-:/++++oooooooooooooooooooo+:. ^.-::::::::::::/yyyyyyyhhhhhho:^
^::///++++oooooooooooooooooooooooo//:::::::::::::::/yyyyyyyhhhhhddds
-::://+++ooooooooooooooooooooooooooooo+/:::::::::::/yyyyyyyhhhhhdddd^
-::::::/++ooooooooooooooooooooooooooooooo+/::::::::/yyyyyyyhhhhhdddd^
-:::::::::/+ooooooooooooooooooooooooooooossso+/::::/yyyyyyyhhhhhdddd^
-::::::::::::/+oooooooooooooooooooooooooossssssso+//yyyyyyyhhhhhdddd^
-::::::::::::::::/+ooooooooooooooooooooooossssssssssyyyyyyyhhhhhdddd.
-:::::::::::::::::::/+oooooooooooooooooooossssssssssyyyyyyyhhhhhdddd.
-:::::::::::::::::::::::/+ooooooooooooooosssssssssssyyyyyyyhhhhhdddd.
-::::::::::::::::::::::::::/+ooooooooooooossssssssssyyyyyyyhhhhhdddd.
-::::::::::::::::::::::::::::::/+ooooooooossssssssssyyyyyyyhhhhhdddd-
-:::::::::::::::::::::::::::::::::/+ooooosssssssssssyyyyyyyhhhhhdddd-
-:::::::::::::::::::::::::::::::::::::/+oossssssssssyyyyyyyhhhhhdddd:
-::::::::::::::::::::::::::::::::::::::::/+ossssssssyyyyyyyhhhhhdddd:
-::::::::::::::::::::::::::::::::::::::::::::/osssssyyyyyyyhhhhhdddd:
-:::::::::::::::::::::::::::::::::::::::::::::::/+ossyyyyyyhhhhhdddd:
-:::::::::::::::::o+/:::::::::::::::::::::::::::::::+oyyyyyhhhhhdddd:
-:::::::::::::::::ossyso/::::::::::::::::::::::::::::::/osyhhhhhdddd/
-:::::::::::::::::ossyyyyys+:::::::::::::::::::::::::::::::+shhhdddd/
-:::::::::::::::::ossyyyyhhhhyo/::::::::::::::::::::::::::::::/oyddd/
.-::::::::::::::::ossyyyyhhhhddddy/-::::::::::::::::::::::::::::::+y:
^.-:::::::::::::ossyyyyhhhhdhs/. ^.--:::::::::::::::::::::::::-.^
^.--:::::::::ossyyyyhhy+-^ ^.-::::::::::::::::::--.^
^.-::::::ossyyyo/. ^^.-:::::::::::-.^
^..-::oss+:^ ^.-:::::-.^
^.:.^ ^^.^^
Done
[local] sent 612684 bytes (598 KB) in 4042 ms at 1212 kbps
[peer] received 612684 bytes (598 KB) in 2511 GATT writes at 1261557 bps
Ready, press any key to start
For the peer:
***** Booting Zephyr OS 1.12.99 *****
[bt] [INF] hci_vs_init: HW Platform: Nordic Semiconductor (0x0002)
[bt] [INF] hci_vs_init: HW Variant: nRr (0x00) Version 1.12 Build 99
[bt] [INF] bt_dev_show_info: Identity: c5:6f:8a:38:95:27 (random)
[bt] [INF] bt_devized
Choose device role - type s (slave role) or m (master role):
Slave role. Starting advertising
Found a peer device c5:ca:14:98:3b:90 (random)
Connected as slave
Conn. interval is 320 units
=============================================================================
=============================================================================
=============================================================================
=============================================================================
=============================================================================
=============================================================================
=============================================================================
===========================================================
[local] received 612684 bytes (598 KB) in 2511 GATT writes at 1261557 bps
Dependencies¶
This sample uses the following nRF Connect SDK libraries:
In addition, it uses the following Zephyr libraries:
include/console.h
-
include/kernel.h
include/sys/printk.h
include/zephyr/types.h
-
include/bluetooth/bluetooth.h
include/bluetooth/conn.h
include/bluetooth/gatt.h
include/bluetooth/hci.h
include/bluetooth/uuid.h
References¶
For more information about the connection parameters that are used in this sample, see the following chapters in the Bluetooth Core Specification:
Vol 3, Part F, 3.2.8 Exchanging MTU Size
Vol 6, Part B, 5.1.1 Connection Update Procedure
Vol 6, Part B, 5.1.9 Data Length Update Procedure
Vol 6, Part B, 5.1.10 PHY Update Procedure