Main Content

Packet Distribution in Bluetooth Piconet

Bluetooth® Toolbox features enable you to distribute packets in a Bluetooth piconet using discrete time simulation (DTS). In DTS, you can call the node only if it has an operation to perform. To increase the speed of the simulation, the DTS implements these two core time values.

  • Next invoke time — At this time, the simulator runs all of the node instances. This value is given by each node through discrete time operations such as sending data, receiving data, retransmissions, or transferring data from the higher layer to lower layer. The simulator is called at the time that is the minimum of the next invoke time values given by each node.

  • Elapsed time — This value is the time elapsed between the last and current call of the simulator.

Packet Distribution

To distribute packets in a Bluetooth piconet using DTS, follow these steps.

Packet distribution in a Bluetooth piconet using discrete time simulation

Create Bluetooth Piconet

Create a Bluetooth piconet and configure the nodes as Central and Peripheral. For information about how to create a Bluetooth piconet, see Create Bluetooth Piconet by Enabling ACL Traffic, SCO Traffic, and AFH. In that example, a cell array, btNodes, is created representing the Bluetooth piconet. btNodes contains all of the nodes in the piconet with the complete stack enabled. The Bluetooth Toolbox features enables you to create a Bluetooth piconet with basic rate (BR) physical layer (PHY) mode.

Run Node Instance

Set the simulation time, current time, elapsed time, and next invoke time.

simulationTime = 2*1e6;                               % In microseconds                                 
currentTime = 0;
nextInvokeTime = zeros(1,numel(btNodes));

Simulate the Bluetooth nodes by running node instance for each Bluetooth node.

while(curTime < simulationTimeInUs)
  for nodeIdx = 1:numel(btNodes)                                           % Simulate all the Bluetooth nodes
    nextInvokeTimes(nodeIdx) = runNode(btNodes{nodeIdx},elapsedTime);      % Run the Bluetooth node instance

Distribute Packets

To distribute packets from each node to the receiving buffer of other nodes, use helperBluetoothDistributePackets function. This helper function accepts btNodes as an input and returns the transmission flag, isPacketDistributed, indicating whether the channel is free or not.

isPacketDistributed = helperBluetoothDistributePackets(btNodes);

Update Elapsed Time and Invoke Simulator

Based on the transmission flag, update the elapsed time. If no packets are to be distributed, update the elapsed time to the next event at a node.

  if isPacketDistributed
    elapsedTime = 0;
    elapsedTime = min(nextInvokeTimes(nextInvokeTimes ~= -1));


[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed December 27, 2021.

[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3.

Related Topics