Evaluate the Performance of Scheduler in a Bluetooth BR/EDR Piconet
This example shows how to evaluate the performance of the Bluetooth® scheduler by modeling multiple Peripherals with different application traffic rates in a simulation scenario.
Using this example, you can:
Create and configure a Bluetooth BR/EDR piconet with Central and Peripheral nodes.
Configure application traffic at nodes using the generic On-Off traffic model.
Configure the scheduler at the Central node and evaluate the throughput and latency performance of the scheduler at each Peripheral node.
Additionally, you can use this example script to simulate and visualize the impact of varying application data rates and the maximum number of transmissions of the scheduler on throughput and latency at the Peripheral nodes. For more information, see further exploration.
Bluetooth Logical Transports
Bluetooth supports communication over multiple logical transports with different applications running on it. These applications include audio streaming, gaming controls, wireless peripherals, and file transfer applications. Because multiple applications can exist in a Bluetooth piconet, different types of application traffic flow from the higher layers to the baseband. In a Bluetooth piconet, the Central and Peripheral exchange data over multiple logical transports. These logical transports are:
Asynchronous connection-oriented (ACL)
Synchronous connection-oriented (SCO)
Extended synchronous connection-oriented (eSCO)
Active peripheral broadcast (APB)
Connectionless peripheral broadcast (CPB)
This figure shows the communication between a Central and three Peripherals in a piconet over ACL and SCO logical transports. Because Bluetooth is a Central-driven time division duplex (TDD) system, the Central controls the channel access in the piconet. The Peripheral can respond to only a transmission from the Central in the previous Tx slot. This process is called polling. This example enables you to configure and simulate application traffic between Central and Peripheral nodes on ACL and SCO logical transports.
The Central polls a Peripheral with a poll packet (if no data exists) or a data packet in a Tx slot, and the Peripheral responds to the polling. The Central can poll any Peripheral of the SCO or ACL logical transport. For SCO links, the Central reserves the slots for the dedicated SCO Peripheral. The Central polls the ACL Peripherals in the remaining slots. The Peripheral responds to the Central with a data packet or a null packet.
Simulation Scenario
The simulation scenario consists of a laptop (Central) connected to a keyboard (Peripheral 1), speaker (Peripheral 2), smartphone (Peripheral 3), and a headset (Peripheral 4).
In the preceding figure:
The Central transfers data to Peripheral 1 and Peripheral 3 on the ACL link.
The Central streams music to the Peripheral 2 and Peripheral 4 on the ACL link.
In the preceding scenario, the performance of each Peripheral degrades due to these reasons:
Concurrent communication between the Central and multiple Peripherals.
Presence of WLAN interference (if present) in the wireless medium.
To communicate with the Peripherals on the ACL links, the Central uses the baseband scheduling mechanism. You can configure the scheduler at the Central node by using the configureScheduler
object function of the bluetoothNode
object. The example shows how to configure a Bluetooth scheduler and measure the throughput and latency performance at each Peripheral. To add WLAN signal interference to the piconet, see the Bluetooth BR/EDR Data and Voice Communication with WLAN Signal Interference example.
Check for Support Package Installation
Check if the Communications Toolbox™ Wireless Network Simulation Library support package is installed. If the support package is not installed, MATLAB® returns an error with a link to download and install the support package.
wirelessnetworkSupportPackageCheck;
Configure the Scenario
Set the seed for the random number generator to 1 to ensure repeatability of results. The seed value controls the pattern of random number generation. Initializing the random number generator using the same seed, assures the same result. For high fidelity simulation results, change the seed value and average the results over multiple simulations.
rng(1,"twister");
Create a wireless network simulator object.
networkSimulator = wirelessNetworkSimulator.init;
Create a Bluetooth BR/EDR node, specifying the role as "central"
. Set the properties of the Central node.
centralNode = bluetoothNode("central", ... Name="Central", ... Position=[0 0 0]); % x-, y-, and z-coordinates in meters
Create Bluetooth BR/EDR nodes, specifying the role as "peripheral"
. Set the properties of the Peripheral nodes.
numPeripherals = 4; peripheralNodes = bluetoothNode.empty(0,numPeripherals); for peripheralIdx = 1:numPeripherals peripheralNodes(peripheralIdx) = bluetoothNode("peripheral", ... Name="Peripheral "+num2str(peripheralIdx), ... Position=[10*peripheralIdx 0 0]); % x-, y-, and z-coordinates in meters end
Create a Bluetooth BR/EDR connection configuration object for each Central-Peripheral node pair. To configure connection between the Central and Peripheral nodes, use the configureConnection
object function of the bluetoothNode
object.
for peripheralIdx = 1:numPeripherals connectionConfig = bluetoothConnectionConfig(CentralToPeripheralACLPacketType="DH3"); connectionConfig = configureConnection(connectionConfig,centralNode,peripheralNodes(peripheralIdx)); end
Application Traffic
Create a networkTrafficOnOff
object to generate an On-Off application traffic pattern. Configure the On-Off application traffic pattern for ACL communication at the Central and Peripheral nodes by specifying the application data rate, packet size, and on state duration. Attach application traffic from the Central to the Peripheral nodes for ACL communication. If you enable SCO in the connection, by default, the object creates and configures the application traffic for SCO communication in the Bluetooth node.
c2PdataRates = [586 173 116 391 391 391 391]; % In Kbps packetSize = 183; % Maximum packet size for "DH3" in bytes for peripheralIdx=1:numPeripherals c2PTrafficSource = networkTrafficOnOff(... OnTime=Inf, ... DataRate=c2PdataRates(peripheralIdx), ... % In Kbps PacketSize=packetSize); % In bytes addTrafficSource(centralNode,c2PTrafficSource, ... % Central -> Peripheral DestinationNode=peripheralNodes(peripheralIdx)); end
Scheduler
Configure round-robin (RR) scheduler at the Central node by specifying the maximum number of transmissions as 3
.
configureScheduler(centralNode,MaxTransmissions=3);
Create Bluetooth BR/EDR Piconet
Create a Bluetooth BR/EDR network consisting of Central and Peripheral nodes.
bluetoothNodes = [centralNode peripheralNodes];
Calculate end-to-end application packet latency by using the helperBluetoothApplicationLatency
helper object.
packetLatency = helperBluetoothApplicationLatency(bluetoothNodes);
Add the Bluetooth nodes to the wireless network simulator.
addNodes(networkSimulator,bluetoothNodes);
Simulation Results
Run the Simulation
Set the simulation time and run the simulation.
simulationTime = 1; % In seconds
run(networkSimulator,simulationTime);
Results
At each node, the simulation measures these metrics:
Network statistics: These metrics show the packet-related statistics at the Application (APP), baseband, and PHY.
centralStats = statistics(centralNode); for peripheralIdx = 1:numPeripherals peripheralStats(peripheralIdx) = statistics(bluetoothNodes(peripheralIdx+1)); %#ok<*SAGROW> end
Throughput: The amount of data bytes sent by the Baseband layer of the Central node to the Baseband layer of Peripheral node in a fixed time period. This value is calculated for every Peripheral at the Central (Central to Peripheral traffic flow) in the simulation. Units are in Kilobits per second (Kbps).
throughputPeripherals = kpi(centralNode,peripheralNodes,"throughput",Layer="Baseband")
throughputPeripherals = 1×4
158.1120 156.6480 117.1200 155.1840
Latency: The time taken by the application packet to travel from the source to the destination node. Units are in seconds.
latencyPeripherals = packetLatency.LatencyAtPeripherals
latencyPeripherals = 1×4
0.3119 0.0551 0.0126 0.2885
Further Exploration
You can use this example to further explore these functionalities:
Impact of Bluetooth Scheduler on Throughput and Latency of Peripherals
To simulate and visualize the impact of varying application data rates and the maximum number of transmissions of the scheduler on throughput and latency at the Peripheral nodes, perform these steps:
Create a Central node and seven Peripheral nodes by using the
bluetoothNode
object.Create a connection configuration object by using the
bluetoothConnectionConfig
object and set theCentralToPeripheralACLPacketType
property toDH3
.Assign the configuration to the Central node and all Peripheral node.
Add application traffic at the Central for each Peripheral node by setting the application data rate with a fixed packet size of
183
bytes, with on and off mean values of 2 and 4 seconds, respectively.Configure Bluetooth scheduler at the Central node by using the
configureScheduler
object function of thebluetoothNode
object.Create a Bluetooth BR/EDR piconet consisting of all the Central and Peripheral nodes.
Simulate the network for 30 seconds by varying the application data rate and the maximum number of successive transmissions of the scheduler.
Visualize the throughput and latency at each Peripheral node. The results are averaged over 10 simulations by varying the seed to random number generator.
The preceding results show the average throughput and latency for all the Peripheral nodes in the piconet. For the configuration specified in this example, the optimal throughput and latency performance is achieved when you set the maximum number of successive transmissions of the RR scheduler to Inf
(t
=Inf
). At t
=Inf
, the RR scheduler selects the same Peripheral exhaustively until the queue at the Central for that Peripheral is empty and thus ensures that no timeslot is wasted. If there is data to be communicated between the Central-Peripheral node pair, the scheduler selects the same Peripheral node. In this case, all the other Peripherals are starved of the network resources. If there is no data to be communicated between the Central-Peripheral node pair, the scheduler selects the next Peripheral node. For fair scheduling, you can set the value of t
to any integer in the range [1, Inf
).
Appendix
The example uses the following helper:
helperBluetoothApplicationLatency
— Calculate end-to-end application packet latency
References
Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 23, 2022. https://www.bluetooth.com/
Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification". Version 5.3. https://www.bluetooth.com/