Main Content

Simulate Multiple Bluetooth BR Piconets with ACL Traffic

This example shows how to create, configure, and simulate multiple Bluetooth® basic rate (BR) piconets with asynchronous connection-oriented logical (ACL) transport.

Using this example, you can:

  1. Create and configure two Bluetooth BR piconets.

  2. Create, configure, and share connections between the Central and Peripheral nodes.

  3. Add application traffic between the Central and Peripheral nodes.

  4. Simulate a Bluetooth BR piconet with ACL traffic, and retrieve the statistics of the Central and Peripheral nodes.

Create a wireless network simulator.

networkSimulator = wirelessNetworkSimulator.init;

Create two Bluetooth BR nodes, specifying the role as "central".

centralNode1 = bluetoothNode("central");
centralNode2 = bluetoothNode("central");

Create three Bluetooth BR nodes, specifying the role as "peripheral".

peripheralNode1 = bluetoothNode("peripheral");
peripheralNode2 = bluetoothNode("peripheral");
peripheralNode3 = bluetoothNode("peripheral");

Create a default Bluetooth BR connection configuration object to configure and share a connection between Central node 1 and Peripheral node 1.

cfgConnection1 = bluetoothConnectionConfig
cfgConnection1 = 
  bluetoothConnectionConfig with properties:

    CentralToPeripheralACLPacketType: "DH1"
    PeripheralToCentralACLPacketType: "DH1"
                       SCOPacketType: "None"
                 HoppingSequenceType: "Connection adaptive"
                        UsedChannels: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 ... ]
                        PollInterval: 40
                       InstantOffset: 240
                    TransmitterPower: 20
                  SupervisionTimeout: 32000

   Read-only properties:
                      CentralAddress: [1x0 char]
                    PrimaryLTAddress: []

Create a default Bluetooth BR connection configuration object to configure and share a connection between Central node 2 and Peripheral nodes 2 and 3. Specify the ACL packet type to be transmitted.

cfgConnection2 = bluetoothConnectionConfig;
cfgConnection2.CentralToPeripheralACLPacketType = "DH3";
cfgConnection2.PeripheralToCentralACLPacketType = "DH3"
cfgConnection2 = 
  bluetoothConnectionConfig with properties:

    CentralToPeripheralACLPacketType: "DH3"
    PeripheralToCentralACLPacketType: "DH3"
                       SCOPacketType: "None"
                 HoppingSequenceType: "Connection adaptive"
                        UsedChannels: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 ... ]
                        PollInterval: 40
                       InstantOffset: 240
                    TransmitterPower: 20
                  SupervisionTimeout: 32000

   Read-only properties:
                      CentralAddress: [1x0 char]
                    PrimaryLTAddress: []

Configure these connections between the Central and Peripheral nodes.

  • Central node 1 and Peripheral node 1

  • Central node 2 and Peripheral node 2

  • Central node 2 and Peripheral node 3

Note that, you must configure each Peripheral node to only one Central node.

connection1 = configureConnection(cfgConnection1,centralNode1,peripheralNode1);
connection2 = configureConnection(cfgConnection2,centralNode2,peripheralNode2);
connection3 = configureConnection(cfgConnection2,centralNode2,peripheralNode3);

Create and configure a networkTrafficOnOff object for each connection, to generate an On-Off application traffic pattern between the corresponding Central and Peripheral nodes.

traffic1 = networkTrafficOnOff(DataRate=200,PacketSize=27, ...
    GeneratePacket=true,OnTime=inf);
traffic2 = networkTrafficOnOff(DataRate=200,PacketSize=27, ...
    GeneratePacket=true,OnTime=inf);
traffic3 = networkTrafficOnOff(DataRate=200,PacketSize=27, ...
    GeneratePacket=true,OnTime=inf);
traffic4 = networkTrafficOnOff(DataRate=400,PacketSize=80, ...
    GeneratePacket=true,OnTime=inf);

Add application traffic from the Central to the Peripheral nodes and vice versa. To transmit packets on an ACL transport, you must add application traffic between the nodes.

addTrafficSource(centralNode1,traffic1,DestinationNode=peripheralNode1);
addTrafficSource(peripheralNode1,traffic2,DestinationNode=centralNode1);
addTrafficSource(centralNode2,traffic3,DestinationNode=peripheralNode2);
addTrafficSource(centralNode2,traffic4,DestinationNode=peripheralNode3);

Create a Bluetooth network consisting of two piconets. The first piconet includes Central node 1 and Peripheral node 1, and the second piconet consists of Central node 2, Peripheral node 2, and Peripheral node 3.

nodes = [centralNode1 centralNode2 peripheralNode1 peripheralNode2 peripheralNode3];

Add the Bluetooth nodes to the simulator.

addNodes(networkSimulator,nodes);

Set the simulation time in seconds, and run the simulation.

simulationTime = 0.5;
run(networkSimulator,simulationTime);
Custom channel model is not added. Using free space path loss (fspl) model as the default channel model.

Retrieve application, baseband, and physical layer (PHY) statistics corresponding to the Central and Peripheral nodes.

central1Stats = statistics(centralNode1);
central2Stats = statistics(centralNode1);
peripheral1Stats = statistics(peripheralNode1);
peripheral2Stats = statistics(peripheralNode2);
peripheral3Stats = statistics(peripheralNode3);

References

[1] Bluetooth® Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed June 22, 2022. https://www.bluetooth.com/.

[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com/.

See Also

Objects

Functions

Related Topics