main content

bluetooth mesh flooding in wireless sensor networks -凯发k8网页登录

this example shows how the managed flooding technique enables you to realize communication in a bluetooth® mesh network by using bluetooth® toolbox and communications toolbox™ wireless network simulation library. using this example, you can:

  • create and configure a bluetooth mesh network.

  • visualize and analyze how managed flooding technique enables communication between the source and destination nodes, even after disabling some intermediate relay nodes.

  • visualize the message flow from the source to destination nodes.

  • analyze performance metrics such as network packet delivery ratio (pdr), end-to-end latency, throughput, and other node-related metrics.

you can also identify critical relay nodes between the source and destination in the bluetooth mesh network through monte carlo simulations.

bluetooth mesh stack

the bluetooth core specification [ ] includes a low energy version for wireless personal area networks (wpan), referred to as bluetooth low energy (le) or bluetooth smart. bluetooth le was added to the standard for low energy devices generating small amounts of data, such as notification alerts used in applications such as home automation, health-care, fitness, and internet of things (iot). for more information about bluetooth le protocol stack, see .

the bluetooth mesh profile [ ] defines the fundamental requirements to implement a mesh networking solution for bluetooth le. bluetooth mesh networking enables large-scale device networks in the applications such as smart lighting, industrial automation, sensor networking, and asset tracking.

this figure shows the bluetooth mesh stack over the advertising bearer.

for more information about bluetooth mesh profile, see .

bluetooth mesh network flooding scenarios

this example uses the advertising bearer to demonstrate managed flooding. this example enables you to create and configure two bluetooth mesh network scenarios. each scenario is a multinode mesh network. each scenario classifies the mesh nodes as node, relay node, source node, and destination node.

  • node: any device in the mesh network

  • relay node: a node that has the relay feature supported and enabled

  • source node: a node that originates and transmits packets

  • destination node: a node at which the packets from the source node are destined

the first mesh network scenario consists of 21 mesh nodes, including relay nodes, a source node, and a destination node. in the second scenario, the example:

  • disables the relay feature of some nodes

  • removes a node from the mesh network

for both the scenarios, you can visualize the message flow in the network and retrieve these statistics.

  • network pdr: ratio of number of packets received at all the destination nodes to the number of packets transmitted by all the source nodes in the mesh network

  • application end-to-end packet latency in seconds

  • link layer (ll) throughput in kbps

  • time spent in listen state, transmit state, idle state and sleep state in seconds

  • packet statistics at the application layer, network layer, transport layer, link layer and physical layer

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 simulation parameters

set the seed for the random number generator to 1. the seed value controls the pattern of random number generation. for high fidelity simulation results, change the seed value for each run and average the results over multiple simulations.

rng(1,"twister");

specify the simulation time for both scenarios.

simulationtime = 0.3; % in seconds

to highlight message transmission in the mesh network visualization, set this flag to true.

highlighttransmissions = true;

number of nodes in the mesh network.

numnodes = 21;

get the node positions from the mat file. specify the positions of bluetooth mesh nodes as a numnodes-by-2 array, where numnodes is the number of nodes in the network. each row specifies the cartesian coordinates of a node, starting from the first node.

load("blemeshnetworknodepositions.mat");
if numnodes ~= size(blemeshnetworknodepositions,1)
    error("invalid bluetooth mesh node position value. specify 'blemeshnetworknodepositions' value in the mat file as a "...
         num2str(numnodes) "-by-2 array.");
end

simulate mesh network scenario one

the first mesh network scenario consists of 21 mesh nodes. set some of the nodes as relay nodes and source-destination node pairs. to specify multiple source-destination pairs, update sourcedestinationpairs by adding a new row specifying the source and destination nodes.

relaynodes = [3 6 7 8 9 12 13 14 15 17];
sourcedestinationpairs = [1 10];

create a wireless network simulator object.

networksimulator = wirelessnetworksimulator.init;

create and configure bluetooth mesh nodes

initialize array to store bluetooth mesh nodes.

nodesscenarioone = bluetoothlenode.empty(0,numnodes);

create bluetooth mesh network for scenario one. use to create mesh profile configuration object. to create a bluetooth mesh node, use the object. specify the role as "broadcaster-observer" and assign the mesh profile to meshconfig.

for nodeindex = 1:numnodes
    % create and configure bluetooth mesh profile by specifying the element
    % address (unique to each node in the network). set network message
    % repetitions to 2, and network transmit interval as a random value in
    % the range [10, 30] milliseconds.
    meshcfg = bluetoothmeshprofileconfig(elementaddress=dec2hex(nodeindex,4),...
        networktransmissions=2,networktransmitinterval=randi([1 3])*10e-3);
    % enable relay feature of the configured relay nodes. set relay message
    % repetitions to 3, and relay retransmit interval as a random value in
    % the range [10, 30] milliseconds.
    if any(nodeindex==relaynodes)
        meshcfg.relay = true;
        meshcfg.relayretransmissions = 3;
        meshcfg.relayretransmitinterval = randi([1 3])*10e-3;
    end
    % create and configure bluetooth mesh node by assigning the mesh profile.
    % set receiver range, advertising interval (seconds) and scan interval (seconds).
    nodesscenarioone(nodeindex) = bluetoothlenode("broadcaster-observer",meshconfig=meshcfg,...
        position=[blemeshnetworknodepositions(nodeindex,:) 0],name="node" num2str(nodeindex),...
        receiverrange=25,advertisinginterval=20e-3,scaninterval=30e-3);
end

add application traffic to source nodes

create a object to generate an on-off application traffic pattern. configure the on-off application traffic pattern by specifying the application data rate, packet size, on, and off state duration. use object function to attach the application traffic source between the specified source-destination node pairs.

for srcidx = 1:numel(sourcedestinationpairs)/2
    % set data rate, packet size, on time, and off time based on the
    % simulation time.
    traffic = networktrafficonoff(datarate=1,packetsize=15,generatepacket=true,...
        ontime=simulationtime*0.3,offtime=simulationtime*0.7);
    % maximum number of hops for a packet is controlled by setting
    % time-to-live (ttl) value
    ttl = 10;
    % attach application traffic to source
    addtrafficsource(nodesscenarioone(sourcedestinationpairs(srcidx,1)),traffic, ...                        % traffic object
        sourceaddress=nodesscenarioone(sourcedestinationpairs(srcidx,1)).meshconfig.elementaddress,...      % source element address
        destinationaddress=nodesscenarioone(sourcedestinationpairs(srcidx,2)).meshconfig.elementaddress,... % destination element address
        ttl=ttl);
end

visualize mesh network

visualize the mesh network scenario by using the helper object.

plotscenarioone = helperblemeshvisualizenetwork(numberofnodes=numnodes,...
    nodepositiontype="userinput",positions=blemeshnetworknodepositions,...
    receiverrange=25,simulationtime=simulationtime,...
    sourcedestinationpairs=sourcedestinationpairs,...
    title="scenario one: bluetooth mesh flooding");

assign the helper object to the networkplot parameter in the helper object.

eventsscenarioone = helperblemesheventcallback(nodesscenarioone,plotscenarioone,...
    highlighttransmissions=highlighttransmissions);

run the simulation

add nodes to the wireless network simulator.

addnodes(networksimulator,nodesscenarioone);

run the network simulation for the specified simulation time.

run(networksimulator,simulationtime);
custom channel model is not added. using free space path loss (fspl) model as the default channel model.

simulate mesh network scenario two

the second mesh network scenario consists of 21 mesh nodes. in this scenario, the relay feature at node7, node12 is disabled and node15 is removed from the network.

relaynodes = [3 6 8 9 13 14 17];
failednodes = 15;

create, configure, and simulate the mesh network for scenario two by using the helper object.

[nodesscenariotwo,eventsscenariotwo] = helperblemeshsimulatescenariotwo(blemeshnetworknodepositions,...
    simulationtime,highlighttransmissions,sourcedestinationpairs,ttl,relaynodes,failednodes);
custom channel model is not added. using free space path loss (fspl) model as the default channel model.

simulation results

use object function to get the statistics of mesh nodes for both scenarios.

% list of statistics (structure array) of the simulated mesh nodes in scenario one
for nodeindex = 1:numel(nodesscenarioone)
    statisticsscenarioone(nodeindex) = statistics(nodesscenarioone(nodeindex)); %#ok<*sagrow>
end
% list of statistics (structure array) of the simulated mesh nodes in scenario two
for nodeindex = 1:numel(nodesscenariotwo)
    statisticsscenariotwo(nodeindex) = statistics(nodesscenariotwo(nodeindex));
end

calculate pdr and path for both scenarios.

[pdrscenarioone,pathscenarioone] = meshresults(eventsscenarioone,statisticsscenarioone)

figure scenario one: bluetooth mesh flooding contains an axes object. the axes object with title scenario one: bluetooth mesh flooding, xlabel x-position (meters), ylabel y-position (meters) contains 4 objects of type graphplot, line. one or more of the lines displays its values using only markers these objects represent scenario one: bluetooth mesh flooding, \color[rgb]{0 0.5 1} node, \color[rgb]{1 0.4980 0.4980} relay node, \color[rgb]{0 0.5 0} source-destination pair (1, 10).

pdrscenarioone = 1
pathscenarioone=1×4 table
    source    destination          path          numberofhops
    ______    ___________    ________________    ____________
      1           10         {[1 6 7 8 9 10]}         5      
[pdrscenariotwo,pathscenariotwo] = meshresults(eventsscenariotwo,statisticsscenariotwo)

figure scenario two: bluetooth mesh flooding contains an axes object. the axes object with title scenario two: bluetooth mesh flooding, xlabel x-position (meters), ylabel y-position (meters) contains 5 objects of type graphplot, line. one or more of the lines displays its values using only markers these objects represent scenario two: bluetooth mesh flooding, \color[rgb]{0 0.5 1} node, \color[rgb]{1 0.4980 0.4980} relay node, \color[rgb]{0.6, 0.6, 0.6} failed node, \color[rgb]{0 0.5 0} source-destination pair (1, 10).

pdrscenariotwo = 1
pathscenariotwo=1×4 table
    source    destination            path            numberofhops
    ______    ___________    ____________________    ____________
      1           10         {[1 6 13 14 8 9 10]}         6      

the obtained results show that there exists a path between the source and destination nodes even if nodes fail randomly in the network.

further exploration

to obtain numerical results averaged over multiple simulations, the example implements the monte carlo method [ ]. to implement monte carlo simulations, use the helper function. during each simulation run, perform these steps.

  1. use a new seed to generate a random number

  2. randomly disable the relay nodes until a path exist between the source and destination nodes

  3. store the pdr value

the monte carlo simulations outputs critical relay nodes required to ensure message delivery from the source to destination. the example performs monte carlo simulations by using these configuration parameters.

% relay nodes
relaynodes = [3 6 7 8 9 12 13 14 15 17];
% source and destination pair
sourcedestinationpairs = [1 10];
% ttl value for messages originated from the source
ttl = 10;

to view the simulation results, see blemeshmontecarloresults mat file.

load("blemeshmontecarloresults.mat");
disp("further exploration: nodes ["   num2str(criticalrelaysinfo{1:5,1}')   ...
    "] are the top 5 critical relays for having communication between node1 and node10.");
further exploration: nodes [9   6   7   8  14] are the top 5 critical relays for having communication between node1 and node10.

appendix

the example uses these helpers:

  • : callback function to visualize message transmissions

  • : bluetooth mesh network visualization

  • : configure and run mesh network for scenario two

  • : bluetooth mesh network monte carlo simulations

selected bibliography

  1. bluetooth technology website. “bluetooth technology website | the official website of bluetooth technology.” accessed may 24, 2022. .

  2. bluetooth special interest group (sig). "bluetooth core specification." version 5.3.

  3. bluetooth special interest group (sig). "bluetooth mesh profile." version 1.0.1

  4. metropolis, nicholas, and s. ulam. "the monte carlo method." journal of the american statistical association 44, no. 247 (september 1949): 335–41. .

see also

functions

objects

  • | | |

related topics

    网站地图