Main Content

Simulate Noncollaborative Coexistence of Bluetooth LE, Bluetooth BR/EDR, and WLAN Networks

This example shows how to simulate noncollaborative coexistence of Bluetooth® low energy (LE), Bluetooth basic rate/enhanced data rate (BR/EDR), and WLAN networks.

Using this example, you can:

  • Create and configure a noncollaborative coexistence scenario consisting of a Bluetooth LE piconet, Bluetooth BR/EDR piconet, and WLAN basic service set (BSS).

  • Add a custom path loss model.

  • Capture the in-phase and quadrature (IQ) samples for all nodes.

  • Simulate and analyze the performance of each node.

  • Visualize the packet communication in the time and frequency domains for all the nodes.

Additionally, you can use this example script to perform these tasks.

Noncollaborative Coexistence Scenario

You can mitigate the interference between Bluetooth and WLAN by using two types of coexistence mechanisms: noncollaborative and collaborative. Noncollaborative coexistence mechanisms do not exchange information between two wireless networks. Collaborative coexistence mechanisms collaborate and exchange network-related information between two wireless networks. For more information about coexistence between Bluetooth and WLAN, see Bluetooth-WLAN Coexistence.

This figure shows the coexistence scenario that this example simulates.

Bluetooth BREDR LE WLAN Coexistence Scenario

The scenario consists of these networks in an office environment. The office environment is configured by using a custom office path loss model [7].

  • Bluetooth BR/EDR piconet consisting of a laptop (Bluetooth BR/EDR Central node) and a speaker (Bluetooth BR/EDR Peripheral node).

  • Bluetooth LE piconet consisting of a mobile phone (Bluetooth LE Central node) and a fitness watch (Bluetooth LE Peripheral node).

  • WLAN BSS consisting of a WiFi® Router (WLAN AP) and an Android® TV (WLAN STA).

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

Create and Configure Scenario

Set the seed for the random number generator to 1 to ensure the 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. To improve the accuracy of your simulation results, after running the simulation, you can change the seed value, run the simulation again, and average the results over multiple simulations.

rng(1,"twister")

Create a wireless network simulator object.

networkSimulator = wirelessNetworkSimulator.init;

Specify the simulation time in seconds.

simulationTime = 0.5;

Bluetooth BR/EDR Piconet

To enable the Bluetooth BR/EDR network, set enableBluetoothBREDRNetwork to true.

enableBluetoothBREDRNetwork = true;

Create a Bluetooth BR/EDR node, specifying the role as "central". Specify the name and position of the Central node.

if enableBluetoothBREDRNetwork    
    centralBREDRNode = bluetoothNode("central", ...
        Name="Central BR EDR", ...
        Position=[8 7 2]);                         % x-, y-, and z-coordinates in meters

Create a Bluetooth BR/EDR node, specifying the role as "peripheral". Specify the name and position of the Peripheral node.

    peripheralBREDRNode = bluetoothNode("peripheral", ...
        Name="Peripheral BR EDR", ...                                  
        Position=[7 8 5]);                                % x-, y-, and z-coordinates in meters

Create and configure a Bluetooth BR/EDR connection configuration object. Assign the configuration to the Central and Peripheral nodes.

    connectionConfig = bluetoothConnectionConfig;
    connectionConfig.TransmitterPower = 0;                                      % In dBm
    configureConnection(connectionConfig,centralBREDRNode,peripheralBREDRNode);

Create a networkTrafficOnOff object to generate an On-Off application traffic pattern. Configure the On-Off application traffic pattern at the Central and Peripheral nodes by specifying the application data rate, packet size, and On-state duration. Add application traffic between the Central and the Peripheral nodes.

    central2PeripheralTrafficSourceBR = networkTrafficOnOff(...
        OnTime=Inf, ...                                                           % In seconds
        OffTime=0, ...
        DataRate=200, ...                                                         % In Kbps
        PacketSize=27);                                                           % In bytes
    addTrafficSource(centralBREDRNode,central2PeripheralTrafficSourceBR, ...
        DestinationNode=peripheralBREDRNode)
    
    peripheral2CentralTrafficSourceBR = networkTrafficOnOff(...
        OnTime=Inf, ...
        OffTime=0, ...
        DataRate=200, ...
        PacketSize=27);
    addTrafficSource(peripheralBREDRNode,peripheral2CentralTrafficSourceBR, ...
        DestinationNode=centralBREDRNode)

Add the Bluetooth BR/EDR nodes to the wireless network simulator.

    bluetoothBREDRNodes = [centralBREDRNode peripheralBREDRNode];
    addNodes(networkSimulator,bluetoothBREDRNodes)
end

Bluetooth LE Piconet

To enable the Bluetooth LE network, set enableBluetoothLENetwork to true.

enableBluetoothLENetwork = true;

Create a Bluetooth LE node, specifying the role as "central". Specify the name and position of the Central node.

if enableBluetoothLENetwork    
    centralLENode = bluetoothLENode("central", ...
        Name="Central LE", ...
        Position=[8 8 3], ...                      % x-, y-, and z-coordinates in meters
        TransmitterPower=0);                       % In dBm

Create a Bluetooth LE node, specifying the role as "peripheral". Specify the name and position of the Peripheral node.

    peripheralLENode = bluetoothLENode("peripheral", ...
        Name="Peripheral LE", ...                                  
        Position=[7 7 2], ...                            % x-, y-, and z-coordinates in meters
        TransmitterPower=0);                             % In dBm

Create a default Bluetooth LE connection configuration object. Set the connection interval and active period. For each connection interval, the LE node triggers the connection events throughout the simulation. The active period is the active communication period within each connection interval, after which the connection event ends. Assign the configuration to the Central and Peripheral nodes.

    connectionConfig = bluetoothLEConnectionConfig( ...
        ConnectionInterval=0.01, ...                                     % In seconds
        ActivePeriod=0.01);                                              % In seconds
    configureConnection(connectionConfig,centralLENode,peripheralLENode);

Create a networkTrafficOnOff object to generate an On-Off application traffic pattern. Configure the On-Off application traffic pattern at the Central and Peripheral nodes by specifying the application data rate, packet size, and on state duration. Add application traffic between the Central and the Peripheral nodes.

    central2PeripheralTrafficSourceLE = networkTrafficOnOff(...
        OnTime=Inf,OffTime=0, ...
        DataRate=350,PacketSize=20, ...
        GeneratePacket=true);
    addTrafficSource(centralLENode,central2PeripheralTrafficSourceLE, ...
        DestinationNode=peripheralLENode)
    
    peripheral2CentralTrafficSourceLE = networkTrafficOnOff(...
        OnTime=Inf,OffTime=0, ...
        DataRate=350,PacketSize=20, ...
        GeneratePacket=true);
    addTrafficSource(peripheralLENode,peripheral2CentralTrafficSourceLE, ...
        DestinationNode=centralLENode)

Add the Bluetooth LE nodes to the wireless network simulator.

    bluetoothLENodes = [centralLENode peripheralLENode];
    addNodes(networkSimulator,bluetoothLENodes)
end

WLAN BSS

To enable the WLAN BSS, set enableWLANBSS to true.

enableWLANBSS = true;

Specify the operating frequency band, in GHz, and the channel number.

if enableWLANBSS
    bandAndChannel = [2.4 7];

Create a WLAN device configuration for an access point (AP) and a station (STA) by using the wlanDeviceConfig (WLAN Toolbox) object. Set the properties of the AP and STA device configurations.

    apDeviceConfig = wlanDeviceConfig( ...
        Mode="AP", ...
        BandAndChannel=bandAndChannel, ...
        TransmitPower=20, ...                                   % In dBm
        InterferenceModeling="overlapping-adjacent-channel");

    staDeviceConfig = wlanDeviceConfig( ...
        Mode="STA", ...
        BandAndChannel=bandAndChannel, ...
        TransmitPower=20, ...                                   % In dBm
        InterferenceModeling="overlapping-adjacent-channel");

From the specified configuration, create an AP and an STA node by using the wlanNode (WLAN Toolbox) object. Specify the names and positions of the nodes. Disable the MAC and PHY abstraction.

    wlanAPNode = wlanNode(DeviceConfig=apDeviceConfig, ...
        Name="WLAN AP", ...
        Position=[6.5 7 2], ...                                % x-, y-, and z-coordinates in meters
        MACFrameAbstraction=false, ...
        PHYAbstractionMethod="none");

    wlanSTANode = wlanNode(DeviceConfig=staDeviceConfig, ...
        Name="WLAN STA", ...
        Position=[8.5 8 3], ...                                % x-, y-, and z-coordinates in meters
        MACFrameAbstraction=false, ...
        PHYAbstractionMethod="none");

Associate the STA to the AP node.

     associateStations(wlanAPNode,wlanSTANode,BandAndChannel=bandAndChannel);

Create a networkTrafficOnOff object to generate an On-Off application traffic pattern. Configure the On-Off application traffic pattern at the AP and STA nodes by specifying the application data rate, packet size, and on state duration. Add application traffic between the AP and STA nodes.

    ap2staTraffic = networkTrafficOnOff( ...
        OnTime=Inf,OffTime=0, ...
        DataRate=35000,PacketSize=200);
    addTrafficSource(wlanAPNode,ap2staTraffic,DestinationNode=wlanSTANode);
    
    sta2apTraffic = networkTrafficOnOff( ...
        OnTime=Inf,OffTime=0, ...
        DataRate=35000,PacketSize=200);
    addTrafficSource(wlanSTANode,sta2apTraffic,DestinationNode=wlanAPNode);

Add the WLAN nodes to the network simulator.

    wlanNodes = [wlanAPNode wlanSTANode];
    addNodes(networkSimulator,wlanNodes)
end

Retrieve the nodes added to the wireless network simulator.

nodes = networkSimulator.Nodes;

To ensure all nodes are configured properly, use the validateCoexistenceConfig local function.

validateCoexistenceConfig(nodes);

Add Custom Path Loss Model

To add your own custom path loss model, enable the enableCustomPathloss flag. If you set this flag to false, the example uses the free-space path loss model.

enableCustomPathloss = true;

To determine the path loss between the nodes, this example uses NIST PAP02-Task 6 [7] path loss model.

Create a path loss model by using the bluetoothPathLossConfig object and bluetoothPathLoss function. Set the signal propagation environment to an office. The updatePathLoss function creates a path loss model function handle. Add the path loss model to the network simulator by using the addChannelModel object function. This custom path loss model is applicable only for the 2.4 GHz frequency band.

if enableCustomPathloss
    pathlossCfg = bluetoothPathLossConfig(Environment="Office");
    pathlossHandle = @(rxInfo,txData) updatePathLoss(rxInfo,txData,pathlossCfg); % Path loss function
    addChannelModel(networkSimulator,pathlossHandle);
end

Capture IQ Samples

To capture IQ samples for all the nodes in the simulation, enable the enableIQSampleCapture flag. The receiving node captures the IQ samples based on the relevant packets received.

enableIQSampleCapture = false;

Capture the IQ samples of the nodes by using the helperCaptureIQSamples helper object. At the end of the simulation, the simulation stores the IQ samples of the corresponding nodes in a MAT file with the filename format NodeName_NodeID_yyyyMMdd_HHmmss.mat, where:

  • NodeName — Name of the node.

  • NodeID — Numeric ID of the node.

  • yyyyMMdd — Date of file creation, in the format year, month, day.

  • HHmmss — Time of file creation, in the format hour, minute, second, using the 24-hour clock format.

The IQSamples property of the iqSampleObj object contains the captured IQ samples. A MAT file corresponding to each node stores the captured IQ samples. If the network contains several nodes or when the simulation time is long, the process of capturing the IQ samples consume significant memory. The MAT file generated at the end of the simulation can consume significant disk space. For example, a system-level simulation that captures 100 million IQ samples creates a MAT file of approximate size 1.5 GB.

iqSampleObj = helperCaptureIQSamples.empty;
for nodeIdx = 1:numel(nodes)*enableIQSampleCapture
    iqSampleObj(nodeIdx) = helperCaptureIQSamples(nodes{nodeIdx});
end

Configure Packet and Node Performance Visualization

To visualize packet communication in the Bluetooth BR/EDR piconet, Bluetooth LE piconet, and WLAN BSS, set enablePacketVisualization to true. The visualization shows these plots:

  • Packet communication over the time and frequency domains.

  • State transitions of Bluetooth and WLAN packets, for each node, over time.

At the end of the simulation, you can visualize packets at any time instance.

enablePacketVisualization = true;

Initialize visualization by using the helperPlotPacketTransitions helper object. To display the visualization at the end of simulation, enable the VisualizeAtEnd property of the helperPlotPacketTransitions helper object.

if enablePacketVisualization
    packetVisObj = helperPlotPacketTransitions(nodes,simulationTime);
end

To view the node performance visualization, set enableNodePerformancePlot to true. The visualization displays the packet loss ratio, throughput, and latency of the Bluetooth BR/EDR, Bluetooth LE, and WLAN nodes at the end of simulation.

enableNodePerformancePlot = true;

Initialize the visualization of the node performance plot by using the helperVisualizePerformance helper object.

if enableNodePerformancePlot
    performancePlotObj = helperVisualizePerformance(nodes,simulationTime);
end

Simulation and Results

Run the simulation for the specified time and generate these results:

  • Runtime plot for all the nodes, showing the state transitions and packet transmissions over time and frequency domains.

  • Bar plot for all the nodes, showing the packet loss ratio, throughput, and average application layer (APP) packet latency. You can find these results in the performancePlotObj variable.

  • APP, link layer (LL), and PHY statistics for all the simulated nodes.

run(networkSimulator,simulationTime)

Figure Packet Communication Over Time And Frequency contains 2 axes objects and another object of type uigridlayout. Axes object 1 with title Packet Communication over Frequency, xlabel Time (seconds), ylabel Frequency (MHz) contains 4 objects of type patch, constantline. Axes object 2 with title State Transitions of Nodes, xlabel Time (seconds), ylabel Node Names contains 6 objects of type patch, constantline.

Figure contains 3 axes objects and another object of type subplottext. Axes object 1 with title Throughput at Each Node, xlabel Node Name, ylabel Throughput (Mbps) contains an object of type bar. Axes object 2 with title Packet Loss at Each Node, xlabel Node Name, ylabel Packet Loss Ratio contains an object of type bar. Axes object 3 with title Average Packet Latency at Each Node, xlabel Node Name, ylabel Latency (s) contains an object of type bar.

Figure contains 3 axes objects and another object of type subplottext. Axes object 1 with title Throughput at Each Node, xlabel Node Name, ylabel Throughput (Mbps) contains an object of type bar. Axes object 2 with title Packet Loss at Each Node, xlabel Node Name, ylabel Packet Loss Ratio contains an object of type bar. Axes object 3 with title Average Packet Latency at Each Node, xlabel Node Name, ylabel Latency (s) contains an object of type bar.

Retrieve the statistics of all the nodes. For more information about WLAN node statistics, see WLAN System-Level Simulation Statistics (WLAN Toolbox). For more information about Bluetooth BR/EDR and LE node statistics, see Bluetooth BR/EDR Node Statistics and Bluetooth LE Node Statistics, respectively.

nodeStats = cellfun(@(x) x.statistics,nodes,UniformOutput=false);

The packet communication visualization shows the MAC state for all the nodes in the time domain. The frequency plot shows the coexistence of Bluetooth and WLAN nodes in the 2.4 GHz frequency band. The overlapping of the packets in the time and frequency domains can result in a packet failure.

The Performance of Bluetooth Nodes bar graph shows that the Bluetooth BR/EDR packets experience more packet loss than the Bluetooth LE packets. However, the Bluetooth BR/EDR piconet has a higher throughput than the Bluetooth LE piconet. In cases of packet loss, the Bluetooth LE nodes close their connection, which results in a lower packet loss ratio. In cases of packet loss, the Bluetooth BR/EDR nodes continue to communicate with each other, which results in higher throughput. Because of Bluetooth interference impacting WLAN, the AP and STA nodes also have packet losses.

Further Exploration

You can use this example to further explore these capabilities.

Analyze Performance of Nodes by Varying Any Parameter

To analyze the impact of any parameter on the performance of any node or network, perform these steps.

  1. Vary the parameter value and run the simulation in a loop.

  2. Retrieve and save the statistics in a variable.

  3. Plot the required statistics.

For example, you can simulate and analyze the impact of Bluetooth BR/EDR and Bluetooth LE node transmit power on the packet loss ratio, throughput, and average packet latency of the WLAN nodes. Vary the Bluetooth node transmit power from -20 dBm to 20 dBm. The transmit power of the WLAN nodes is constant at 0 dBm. Run the simulation in a loop for a simulation time of 10 s, obtaining these results.

Performance of WLAN Nodes for Varying Bluetooth BREDR PowersPerformance of WLAN Nodes for Varying Bluetooth LE Powers

By disabling the Bluetooth nodes, preventing interference, you can see that the WLAN network has a throughput of 2.89 Mbps and latency of 0.14 s. You can observe that, as the transmit power of the Bluetooth nodes increases, the packet loss in the WLAN BSS also increases. Furthermore, as the packet loss increases, the throughput decreases and latency increases.

Add Custom Channel Classification for Bluetooth Nodes

To add a custom channel classification algorithm to the Bluetooth nodes, perform these steps.

  1. Create a custom channel classification object.

  2. Create a channel classification function handle.

  3. Classify the channels by passing the classification function at an absolute simulation time, or at a particular periodicity, by using the scheduleAction object function of the wirelessNetworkSimulator object.

  4. Instead of scheduling or calling the classification at certain simulation time instances, you can implement a custom channel classification by classifying the channels based on the status of the received packets.

  5. Update the status of the received packets, and classify the channels based on the status of the received packets. Update the used channel of the Bluetooth nodes by using the updateChannelList function of the bluetoothNode object or bluetoothLENode object.

  6. To visualize the channel classification at the Bluetooth nodes over time, initialize the helperVisualizeClassification helper object at the start of the simulation.

For more information on how to add channel classification for Bluetooth nodes, see the Bluetooth BR/EDR Data and Voice Communication with WLAN Signal Interference and Noncollaborative Bluetooth LE Coexistence with WLAN Signal Interference examples.

Add Multiple Piconets and WLAN BSSs to the Network

For information on how to add multiple nodes or piconets to the Bluetooth network, see the Simulate Multiple Bluetooth BR/EDR Piconets with ACL Traffic example. For information on how to add multiple nodes or BSSs to the WLAN network, see the Simulate an 802.11ax Hybrid Mesh Network (WLAN Toolbox) example.

Visualize Captured IQ Samples

Capture the IQ samples by enabling the enableIQSampleCapture flag. To visualize the captured IQ samples, use the Signal Analyzer (Signal Processing Toolbox) app. For example, to visualize the IQ samples captured at the WLAN AP, uncomment this code.

% if enableWLANBSS
%     signalAnalyzer(iqSampleObj(5).IQSamples);
% end

Appendix

The example uses these helpers:

References

  1. Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed January 20, 2023. https://www.bluetooth.com/.

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

  3. Institute of Electrical and Electronics Engineers (IEEE). “IEEE Recommended Practice for Information Technology-- Local and Metropolitan Area Networks-- Specific Requirements-- Part 15.2: Coexistence of Wireless Personal Area Networks with Other Wireless Devices Operating in Unlicensed Frequency Bands.” IEEE Standard 802.15.2. IEEE, August 28, 2003. https://doi.org/10.1109/IEEESTD.2003.94386.

  4. Institute of Electrical and Electronics Engineers (IEEE). "IEEE Standard for Information Technology--Telecommunications and Information Exchange between Systems Local and Metropolitan Area Networks--Specific Requirements Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications Amendment 1: Enhancements for High-Efficiency WLAN." IEEE 802.11ax-2021. IEEE, May 19, 2021. https://doi.org/10.1109/IEEESTD.2021.9442429.

  5. Institute of Electrical and Electronics Engineers (IEEE). TGax Simulation Scenarios. IEEE 802.11-14/0980r16. IEEE, 2015.

  6. Institute of Electrical and Electronics Engineers (IEEE). 11ax Evaluation Methodology. IEEE 802.11-14/0571r12. IEEE, January 2016.

  7. NIST Smart Grid Interoperability Panel Priority Action Plan 2: Guidelines for Assessing Wireless Standards for Smart Grid Applications. National Institute of Standards and Technology, U.S. Department of Commerce, 2014.

Local Functions

Custom Path Loss Model

Create a custom path loss model by using the bluetoothPathLoss function, and attach it to the wireless network simulator.

function rxData = updatePathLoss(rxInfo,txData,pathlossCfg)

    % Apply path loss and update output signal
    rxData = txData;
    % Calculate distance between transmitter and receiver in meters
    distance = norm(rxData.TransmitterPosition - rxInfo.Position);
    pathloss = bluetoothPathLoss(distance,pathlossCfg);
    rxData.Power = rxData.Power-pathloss;                           % In dBm
    scale = 10.^(-pathloss/20);
    [numSamples,~] = size(rxData.Data);
    rxData.Data(1:numSamples,:) = rxData.Data(1:numSamples,:)*scale;
end

Check Coexistence Configuration

If Bluetooth and WLAN nodes coexist in the scenario, the validateCoexistenceConfig function checks these conditions:

  • WLAN has only a single-input single-output (SISO) stream.

  • WLAN has a channel bandwidth of 20 MHz.

function validateCoexistenceConfig(nodes)

    % Validate coexistence configuration
    isWLAN = cellfun(@(x) isa(x,"wlanNode"),nodes);
    if any(isWLAN) && ~all(isWLAN)
        for wlanNodeIdx = find(isWLAN)'
            deviceConfig = nodes{wlanNodeIdx}.DeviceConfig;
            if deviceConfig.NumTransmitAntennas>1||deviceConfig.NumSpaceTimeStreams>1
                error("Bluetooth nodes coexist with WLAN nodes that work only with SISO stream.");
            elseif deviceConfig.ChannelBandwidth~=20000000
                error("WLAN nodes coexist with the Bluetooth nodes only when the channel bandwidth is 20 MHz.");
            end
        end
    end
end

See Also

Objects

Related Topics