MATLAB Examples

IEEE 802.15.4 - Asynchronous CSMA MAC

This example shows how to simulate the IEEE® 802.15.4 asynchronous CSMA MAC [ 1 ] using the Communications System Toolbox™ Library for the ZigBee® Protocol.

Contents

Background

The IEEE 802.15.4 standard specifies the MAC and PHY layers of Low-Rate Wireless Personal Area Networks (LR-WPANs) [ 1 ]. The IEEE 802.15.4 MAC and PHY layers provide the basis of other higher-layer standards, such as ZigBee, WirelessHart®, 6LoWPAN and MiWi. Such standards find application in home automation and sensor networking and are highly relevant to the Internet of Things (IoT) trend.

The IEEE 802.15.4 MAC [ 1 ] specifies two-basic MAC modes: (i) non-beacon-enabled, and (ii) beacon-enabled MAC. The non-beacon enabled MAC is an asynchronous CSMA (Carrier-sense Multiple Access) MAC, which is very similar to the IEEE 802.11 MAC. The beacon-enabled MAC allows two different MAC periods: (i) a synchronized-CSMA MAC period, and (ii) a time-slotted, contention-free MAC period. This example provides an extensive simulation of the non-beacon-enabled, asynchronous, CSMA-based IEEE 802.15.4 MAC.

Network Setup

An IEEE 802.15.4 PAN (personal area network) is set up by a standard process between end devices and PAN coordinators. First, devices that would like to join a network perform either active or passive scanning. Active scanning means that a device first transmits a Beacon Request and later on it performs passive scanning. Passive scanning means that the device sniffs to collect beacon frames from PAN coordinators (who may have received their Beacon Request in the case of active scanning). Upon the collection of beacons during passive scanning, the end device chooses the PAN with which it would like to associate. Then it transmits an Association Request to the coordinator of this PAN and the coordinator acknowledges it.

In contrast to IEEE 802.11, the coordinator does not follow the acknowledgement of an Association Request with an immediate transmission of an Association Response. Instead, the IEEE 802.15.4 coordinator first stores the Association Response locally; it is only transmitted when the end device sends a Data Request and the coordinator acknowledges it. The IEEE 802.15.4 standard uses the term indirect transmission to refer to this mechanism for transmitting frames. In general, this mechanism is very useful for battery-powered devices of low-traffic networks (e.g., sensor networks). Such devices may periodically activate their radios to check whether any frames are pending for them, instead of continuously using their radios to receive a frame immediately.

Once the Association response is received and acknowledged, the end device is associated with the PAN. At that time, data frames can be exchanged between the coordinator and the end device in any direction. The data frames may be acknowledged, depending on their 'Acknowledgement Request' indication.

Asyncrhonous Medium-Access Control (MAC)

The asynchronous CSMA IEEE 802.15.4 MAC is similar to the generic CSMA operation and the IEEE 802.11 MAC. In this MAC scheme, acknowledgement frames are transmitted immediately, without using the CSMA method. All other frames are transmitted using CSMA.

Specifically, once a device has a frame to transmit, it randomly chooses a backoff delay (number of backoff periods) from the range [0 2^BE-1], whrere BE is the backoff exponent. The duration of each backoff period is 20 symbols. For the OQPSK PHY in 2.4 GHz, this duration corresponds to 128 chips and 0.32 ms. Once the device has waited for the chosen number of backoff periods, it performs carrier sensing. If the medium is idle, the device begins transmission of its frame, until it is entirely transmitted.

If the medium is busy during carrier sense, then the backoff exponent increments by 1 and a new number of backoff periods is selected from the new [0 2^BE-1] range. When the backoff counter expires again, carrier sensing is performed. If the maximum number of backoff countdowns is reached without the medium being idle during any carrier sensing instance, then the device terminates its attempts to transmit the frame.

Network Simulation Capabilities

This example offers an implementation for the described network setup process and the CSMA method via the lrwpan.MACFullFunctionDevice and the lrwpan.MACReducedFunctionDevice classes. Specifically, the following capabilities are enabled:

  • Active and passive scanning
  • Association Request and Association Response exchange
  • Indirect transmissions using Data Requests
  • Frame acknowledgements and frame retransmissions if acknowledgements are not timely received
  • Short and long interframe spacing (SIFS and LIFS)
  • Binary exponential backoff
  • Carrier sensing

Network Simulation

In this section, we create an IEEE 802.15.4 network of 3 nodes: one PAN coordinator and two end devices. The network simulator is configured to process all devices at increments of a single backoff duration (20 symbols, 0.32 ms).

First, the following code illustrates the association of the first device with the network.

symbolsPerStep = 20;
chipsPerSymbol = 32;
samplesPerChip = 4;
symbolRate = 65.5e3; % symbols/sec
time = 0;
stopTime = 5; % sec

% Create PAN Coordinator
panCoordinator = lrwpan.MACFullFunctionDevice('PANCoordinator', true, 'SamplesPerChip', 4, ....
  'PANIdentifier', '7777', 'ExtendedAddress', [repmat('0', 1, 8) repmat('7', 1, 8)], ...
  'ShortAddress', '1234');

% Create first end-device:
endDevice1 = lrwpan.MACReducedFunctionDevice('SamplesPerChip', 4, ...
  'ShortAddress', '0001', 'ExtendedAddress', [repmat('0', 1, 8) repmat('3', 1, 8)]);

% Initialize device inputs
received1 = zeros(samplesPerChip * chipsPerSymbol * symbolsPerStep/2, 1);
received2 = zeros(samplesPerChip * chipsPerSymbol * symbolsPerStep/2, 1);

while time < stopTime
  % Pass the received signals to the nodes for processing. Also, fetch what
  % they have to transmit:
  transmitted1 = panCoordinator(received1);
  transmitted2 = endDevice1(received2);

  % Ideal wireless channel, where both nodes are within range:
  received1 = transmitted2; % half-duplex radios, none receiving while transmitting
  received2 = transmitted1;

  time = time + symbolsPerStep/symbolRate; % update clock
end
0001: ********* Adding Beacon Request frame to the queue
0001: Passive scanning for 1584 steps
0001: Processing next frame from the queue
0001: Initializing transmission; backoff delay = 1 steps
0001: Backoff delay = 1 steps -> 0 steps
0001: Carrier sensing: Medium is idle.
0001: Clear to transmit
0001: Transmitting Beacon Request
0001: IFS offset = 0 samples
0001: Transmitting 1-1280 of 2050
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
0001: IFS offset = 0 samples
0001: Transmitting 1281-2050 of 2050
0001: Finished transmission
0001: Need to wait for SIFS (12) symbols. Offset = 12, next IFS = 4
0001: Entering passive scanning
1234: PHY decoded IEEE 802.15.4 frame
1234: Need to wait for SIFS (12) symbols. Offset = 12, next IFS = 4
CRC check passed for the MAC frame.
1234: *********** Received frame type = MAC command
1234: *********** Received MAC Command type = Beacon request
1234: ********* Adding Beacon frame to the queue
1234: next IFS = 4
1234: Processing next frame from the queue
1234: Initializing transmission; backoff delay = 7 steps
1234: Backoff delay = 7 steps -> 6 steps
1234: Backoff delay = 6 steps -> 5 steps
1234: Backoff delay = 5 steps -> 4 steps
1234: Backoff delay = 4 steps -> 3 steps
1234: Backoff delay = 3 steps -> 2 steps
1234: Backoff delay = 2 steps -> 1 steps
1234: Backoff delay = 1 steps -> 0 steps
1234: Carrier sensing: Medium is idle.
1234: Clear to transmit
1234: IFS offset = 256 samples
1234: Transmitting 1-1024 of 2562
1234: IFS offset = 0 samples
1234: Transmitting 1025-2304 of 2562
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
1234: IFS offset = 0 samples
1234: Transmitting 2305-2562 of 2562
1234: Finished transmission
1234: Need to wait for LIFS (40) symbols. Offset = 4, next IFS = 24
1234: Decreased wait time by 20 symbols to 4
0001: PHY decoded IEEE 802.15.4 frame
0001: Need to wait for SIFS (12) symbols. Offset = 4, next IFS = -4
CRC check passed for the MAC frame.
0001: *********** Received frame type = Beacon
0001: next IFS = 0
0001: Scanning finished
0001: ********* Adding Association request frame to the queue
0001: Processing next frame from the queue
0001: Initializing transmission; backoff delay = 0 steps
0001: Carrier sensing: Medium is idle.
0001: Clear to transmit
0001: IFS offset = 0 samples
0001: Transmitting 1-1280 of 3458
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
0001: IFS offset = 0 samples
0001: Transmitting 1281-2560 of 3458
0001: IFS offset = 0 samples
0001: Transmitting 2561-3458 of 3458
0001: Finished transmission
0001: Need to wait for LIFS (40) symbols. Offset = 14, next IFS = 34
0001: will wait for ack for 54 symbols additional to IFS = 34
1234: PHY decoded IEEE 802.15.4 frame
1234: Need to wait for LIFS (40) symbols. Offset = 14, next IFS = 34
CRC check passed for the MAC frame.
1234: *********** Received frame type = MAC command
1234: *********** Received MAC Command type = Association request
1234: ********** Directly transmitting acknowledgement frame (no CSMA/CA)
1234: ********* Adding Data response frame to the PENDING queue
1234: next IFS = 34
0001: Decreasing ack wait durations by 20 symbols to 68
1234: IFS offset = 896 samples
1234: Transmitting 1-384 of 1410
0001: Decreasing ack wait durations by 20 symbols to 48
1234: IFS offset = 0 samples
1234: Transmitting 385-1410 of 1410
1234: Finished transmission
1234: Need to wait for SIFS (12) symbols. Offset = 16, next IFS = 8
0001: Decreasing ack wait durations by 20 symbols to 28
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
0001: PHY decoded IEEE 802.15.4 frame
0001: Need to wait for SIFS (12) symbols. Offset = 16, next IFS = 8
CRC check passed for the MAC frame.
0001: *********** Received frame type = Acknowledgment
0001: *********** Adding Data request frame to the queue
0001: next IFS = 1920
0001: Decreased wait time by 20 symbols to 1900
0001: Decreased wait time by 20 symbols to 1880
0001: Decreased wait time by 20 symbols to 1860
0001: Decreased wait time by 20 symbols to 1840
0001: Decreased wait time by 20 symbols to 1820
0001: Decreased wait time by 20 symbols to 1800
0001: Decreased wait time by 20 symbols to 1780
0001: Decreased wait time by 20 symbols to 1760
0001: Decreased wait time by 20 symbols to 1740
0001: Decreased wait time by 20 symbols to 1720
0001: Decreased wait time by 20 symbols to 1700
0001: Decreased wait time by 20 symbols to 1680
0001: Decreased wait time by 20 symbols to 1660
0001: Decreased wait time by 20 symbols to 1640
0001: Decreased wait time by 20 symbols to 1620
0001: Decreased wait time by 20 symbols to 1600
0001: Decreased wait time by 20 symbols to 1580
0001: Decreased wait time by 20 symbols to 1560
0001: Decreased wait time by 20 symbols to 1540
0001: Decreased wait time by 20 symbols to 1520
0001: Decreased wait time by 20 symbols to 1500
0001: Decreased wait time by 20 symbols to 1480
0001: Decreased wait time by 20 symbols to 1460
0001: Decreased wait time by 20 symbols to 1440
0001: Decreased wait time by 20 symbols to 1420
0001: Decreased wait time by 20 symbols to 1400
0001: Decreased wait time by 20 symbols to 1380
0001: Decreased wait time by 20 symbols to 1360
0001: Decreased wait time by 20 symbols to 1340
0001: Decreased wait time by 20 symbols to 1320
0001: Decreased wait time by 20 symbols to 1300
0001: Decreased wait time by 20 symbols to 1280
0001: Decreased wait time by 20 symbols to 1260
0001: Decreased wait time by 20 symbols to 1240
0001: Decreased wait time by 20 symbols to 1220
0001: Decreased wait time by 20 symbols to 1200
0001: Decreased wait time by 20 symbols to 1180
0001: Decreased wait time by 20 symbols to 1160
0001: Decreased wait time by 20 symbols to 1140
0001: Decreased wait time by 20 symbols to 1120
0001: Decreased wait time by 20 symbols to 1100
0001: Decreased wait time by 20 symbols to 1080
0001: Decreased wait time by 20 symbols to 1060
0001: Decreased wait time by 20 symbols to 1040
0001: Decreased wait time by 20 symbols to 1020
0001: Decreased wait time by 20 symbols to 1000
0001: Decreased wait time by 20 symbols to 980
0001: Decreased wait time by 20 symbols to 960
0001: Decreased wait time by 20 symbols to 940
0001: Decreased wait time by 20 symbols to 920
0001: Decreased wait time by 20 symbols to 900
0001: Decreased wait time by 20 symbols to 880
0001: Decreased wait time by 20 symbols to 860
0001: Decreased wait time by 20 symbols to 840
0001: Decreased wait time by 20 symbols to 820
0001: Decreased wait time by 20 symbols to 800
0001: Decreased wait time by 20 symbols to 780
0001: Decreased wait time by 20 symbols to 760
0001: Decreased wait time by 20 symbols to 740
0001: Decreased wait time by 20 symbols to 720
0001: Decreased wait time by 20 symbols to 700
0001: Decreased wait time by 20 symbols to 680
0001: Decreased wait time by 20 symbols to 660
0001: Decreased wait time by 20 symbols to 640
0001: Decreased wait time by 20 symbols to 620
0001: Decreased wait time by 20 symbols to 600
0001: Decreased wait time by 20 symbols to 580
0001: Decreased wait time by 20 symbols to 560
0001: Decreased wait time by 20 symbols to 540
0001: Decreased wait time by 20 symbols to 520
0001: Decreased wait time by 20 symbols to 500
0001: Decreased wait time by 20 symbols to 480
0001: Decreased wait time by 20 symbols to 460
0001: Decreased wait time by 20 symbols to 440
0001: Decreased wait time by 20 symbols to 420
0001: Decreased wait time by 20 symbols to 400
0001: Decreased wait time by 20 symbols to 380
0001: Decreased wait time by 20 symbols to 360
0001: Decreased wait time by 20 symbols to 340
0001: Decreased wait time by 20 symbols to 320
0001: Decreased wait time by 20 symbols to 300
0001: Decreased wait time by 20 symbols to 280
0001: Decreased wait time by 20 symbols to 260
0001: Decreased wait time by 20 symbols to 240
0001: Decreased wait time by 20 symbols to 220
0001: Decreased wait time by 20 symbols to 200
0001: Decreased wait time by 20 symbols to 180
0001: Decreased wait time by 20 symbols to 160
0001: Decreased wait time by 20 symbols to 140
0001: Decreased wait time by 20 symbols to 120
0001: Decreased wait time by 20 symbols to 100
0001: Decreased wait time by 20 symbols to 80
0001: Decreased wait time by 20 symbols to 60
0001: Decreased wait time by 20 symbols to 40
0001: Decreased wait time by 20 symbols to 20
0001: Decreased wait time by 20 symbols to 0
0001: Processing next frame from the queue
0001: Initializing transmission; backoff delay = 2 steps
0001: Backoff delay = 2 steps -> 1 steps
0001: Backoff delay = 1 steps -> 0 steps
0001: Carrier sensing: Medium is idle.
0001: Clear to transmit
0001: IFS offset = 0 samples
0001: Transmitting 1-1280 of 3074
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
0001: IFS offset = 0 samples
0001: Transmitting 1281-2560 of 3074
0001: IFS offset = 0 samples
0001: Transmitting 2561-3074 of 3074
0001: Finished transmission
0001: Need to wait for LIFS (40) symbols. Offset = 8, next IFS = 28
0001: will wait for ack for 54 symbols additional to IFS = 28
1234: PHY decoded IEEE 802.15.4 frame
1234: Need to wait for SIFS (12) symbols. Offset = 8, next IFS = 0
CRC check passed for the MAC frame.
1234: *********** Received frame type = MAC command
1234: *********** Received MAC Command type = Data request
1234: ********** Directly transmitting acknowledgement frame (no CSMA/CA)
1234: Moving frame for 0000000033333333 from pending queue to the transmission queue
1234: next IFS = 0
1234: IFS offset = 0 samples
1234: Transmitting 1-1280 of 1410
0001: Decreasing ack wait durations by 20 symbols to 62
1234: IFS offset = 0 samples
1234: Transmitting 1281-1410 of 1410
1234: Finished transmission
1234: Need to wait for SIFS (12) symbols. Offset = 2, next IFS = -6
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
0001: Decreasing ack wait durations by 20 symbols to 42
1234: Processing next frame from the queue
1234: Initializing transmission; backoff delay = 5 steps
1234: Backoff delay = 5 steps -> 4 steps
0001: PHY decoded IEEE 802.15.4 frame
0001: Need to wait for SIFS (12) symbols. Offset = 2, next IFS = -6
CRC check passed for the MAC frame.
0001: *********** Received frame type = Acknowledgment
0001: next IFS = 0
1234: Backoff delay = 4 steps -> 3 steps
1234: Backoff delay = 3 steps -> 2 steps
1234: Backoff delay = 2 steps -> 1 steps
1234: Backoff delay = 1 steps -> 0 steps
1234: Carrier sensing: Medium is idle.
1234: Clear to transmit
1234: IFS offset = 0 samples
1234: Transmitting 1-1280 of 4226
1234: IFS offset = 0 samples
1234: Transmitting 1281-2560 of 4226
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
1234: IFS offset = 0 samples
1234: Transmitting 2561-3840 of 4226
1234: IFS offset = 0 samples
1234: Transmitting 3841-4226 of 4226
1234: Finished transmission
1234: Need to wait for LIFS (40) symbols. Offset = 6, next IFS = 26
1234: will wait for ack for 54 symbols additional to IFS = 26
1234: Decreasing ack wait durations by 20 symbols to 60
0001: PHY decoded IEEE 802.15.4 frame
0001: Need to wait for LIFS (40) symbols. Offset = 6, next IFS = 26
CRC check passed for the MAC frame.
0001: *********** Received frame type = MAC command
0001: *********** Received MAC Command type = Association response
0001: *********** Association successful, changing short address to = 8CEC
8CEC: *********** Association successful, associated to PAN = 7777
8CEC: ********** Directly transmitting acknowledgement frame (no CSMA/CA)
8CEC: next IFS = 26
1234: Decreasing ack wait durations by 20 symbols to 40
8CEC: IFS offset = 384 samples
8CEC: Transmitting 1-896 of 1410
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
1234: Decreasing ack wait durations by 20 symbols to 20
8CEC: IFS offset = 0 samples
8CEC: Transmitting 897-1410 of 1410
8CEC: Finished transmission
8CEC: Need to wait for SIFS (12) symbols. Offset = 8, next IFS = 0
1234: PHY decoded IEEE 802.15.4 frame
1234: Need to wait for SIFS (12) symbols. Offset = 8, next IFS = 0
CRC check passed for the MAC frame.
1234: *********** Received frame type = Acknowledgment
1234: next IFS = 0
8CEC: ********* (t=4.079360) Injecting data frame to the queue. From: 8CEC -> To: 1234 
8CEC: Processing next frame from the queue
8CEC: Initializing transmission; backoff delay = 6 steps
8CEC: Backoff delay = 6 steps -> 5 steps
8CEC: Backoff delay = 5 steps -> 4 steps
8CEC: Backoff delay = 4 steps -> 3 steps
8CEC: Backoff delay = 3 steps -> 2 steps
8CEC: Backoff delay = 2 steps -> 1 steps
8CEC: Backoff delay = 1 steps -> 0 steps
8CEC: Carrier sensing: Medium is idle.
8CEC: Clear to transmit
8CEC: IFS offset = 0 samples
8CEC: Transmitting 1-1280 of 8578
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
8CEC: IFS offset = 0 samples
8CEC: Transmitting 1281-2560 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 2561-3840 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 3841-5120 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 5121-6400 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 6401-7680 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 7681-8578 of 8578
8CEC: Finished transmission
8CEC: Need to wait for LIFS (40) symbols. Offset = 14, next IFS = 34
8CEC: will wait for ack for 54 symbols additional to IFS = 34
1234: PHY decoded IEEE 802.15.4 frame
1234: Need to wait for LIFS (40) symbols. Offset = 14, next IFS = 34
CRC check passed for the MAC frame.
1234: *********** Received frame type = Data
1234: ********** Directly transmitting acknowledgement frame (no CSMA/CA)
1234: next IFS = 34
8CEC: Decreasing ack wait durations by 20 symbols to 68
1234: IFS offset = 896 samples
1234: Transmitting 1-384 of 1410
8CEC: Decreasing ack wait durations by 20 symbols to 48
1234: IFS offset = 0 samples
1234: Transmitting 385-1410 of 1410
1234: Finished transmission
1234: Need to wait for SIFS (12) symbols. Offset = 16, next IFS = 8
8CEC: Decreasing ack wait durations by 20 symbols to 28
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
8CEC: PHY decoded IEEE 802.15.4 frame
8CEC: Need to wait for SIFS (12) symbols. Offset = 16, next IFS = 8
CRC check passed for the MAC frame.
8CEC: *********** Received frame type = Acknowledgment
8CEC: next IFS = 8
8CEC: ********* (t=4.795200) Injecting data frame to the queue. From: 8CEC -> To: 1234 
8CEC: Processing next frame from the queue
8CEC: Initializing transmission; backoff delay = 6 steps
8CEC: Backoff delay = 6 steps -> 5 steps
8CEC: Backoff delay = 5 steps -> 4 steps
8CEC: Backoff delay = 4 steps -> 3 steps
8CEC: Backoff delay = 3 steps -> 2 steps
8CEC: Backoff delay = 2 steps -> 1 steps
8CEC: Backoff delay = 1 steps -> 0 steps
8CEC: Carrier sensing: Medium is idle.
8CEC: Clear to transmit
8CEC: IFS offset = 512 samples
8CEC: Transmitting 1-768 of 8578
Found preamble of OQPSK PHY.
8CEC: IFS offset = 0 samples
8CEC: Transmitting 769-2048 of 8578
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
8CEC: IFS offset = 0 samples
8CEC: Transmitting 2049-3328 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 3329-4608 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 4609-5888 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 5889-7168 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 7169-8448 of 8578
8CEC: IFS offset = 0 samples
8CEC: Transmitting 8449-8578 of 8578
8CEC: Finished transmission
8CEC: Need to wait for LIFS (40) symbols. Offset = 2, next IFS = 22
8CEC: will wait for ack for 54 symbols additional to IFS = 22
1234: PHY decoded IEEE 802.15.4 frame
1234: Need to wait for LIFS (40) symbols. Offset = 2, next IFS = 22
CRC check passed for the MAC frame.
1234: *********** Received frame type = Data
1234: ********** Directly transmitting acknowledgement frame (no CSMA/CA)
1234: next IFS = 22
8CEC: Decreasing ack wait durations by 20 symbols to 56
1234: IFS offset = 128 samples
1234: Transmitting 1-1152 of 1410
8CEC: Decreasing ack wait durations by 20 symbols to 36
1234: IFS offset = 0 samples
1234: Transmitting 1153-1410 of 1410
1234: Finished transmission
1234: Need to wait for SIFS (12) symbols. Offset = 4, next IFS = -4
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
8CEC: Decreasing ack wait durations by 20 symbols to 16
8CEC: PHY decoded IEEE 802.15.4 frame
8CEC: Need to wait for SIFS (12) symbols. Offset = 4, next IFS = -4
CRC check passed for the MAC frame.
8CEC: *********** Received frame type = Acknowledgment
8CEC: next IFS = 0
1234: ********* (t=5.001280) Injecting data frame to the queue. From: 1234 -> To: 8CEC 
1234: Processing next frame from the queue
1234: Initializing transmission; backoff delay = 1 steps
1234: Backoff delay = 1 steps -> 0 steps
1234: Carrier sensing: Medium is idle.
1234: Clear to transmit
1234: IFS offset = 0 samples
1234: Transmitting 1-1280 of 8578
1234: IFS offset = 0 samples
1234: Transmitting 1281-2560 of 8578
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
1234: IFS offset = 0 samples
1234: Transmitting 2561-3840 of 8578
1234: IFS offset = 0 samples
1234: Transmitting 3841-5120 of 8578
1234: IFS offset = 0 samples
1234: Transmitting 5121-6400 of 8578
1234: IFS offset = 0 samples
1234: Transmitting 6401-7680 of 8578
1234: IFS offset = 0 samples
1234: Transmitting 7681-8578 of 8578
1234: Finished transmission
1234: Need to wait for LIFS (40) symbols. Offset = 14, next IFS = 34
1234: will wait for ack for 54 symbols additional to IFS = 34
1234: Decreasing ack wait durations by 20 symbols to 68
8CEC: PHY decoded IEEE 802.15.4 frame
8CEC: Need to wait for LIFS (40) symbols. Offset = 14, next IFS = 34
CRC check passed for the MAC frame.
8CEC: *********** Received frame type = Data
8CEC: ********** Directly transmitting acknowledgement frame (no CSMA/CA)
8CEC: next IFS = 34
1234: Decreasing ack wait durations by 20 symbols to 48
8CEC: IFS offset = 896 samples
8CEC: Transmitting 1-384 of 1410
1234: Decreasing ack wait durations by 20 symbols to 28
8CEC: IFS offset = 0 samples
8CEC: Transmitting 385-1410 of 1410
8CEC: Finished transmission
8CEC: Need to wait for SIFS (12) symbols. Offset = 16, next IFS = 8
Found preamble of OQPSK PHY.
Found start-of-frame delimiter (SFD) of OQPSK PHY.
1234: PHY decoded IEEE 802.15.4 frame
1234: Need to wait for SIFS (12) symbols. Offset = 16, next IFS = 8
CRC check passed for the MAC frame.
1234: *********** Received frame type = Acknowledgment
1234: next IFS = 8

Once the 1st end device has been associated, data frames are randomly injected into the link between the end device and the PAN Coordinator.

Next, a third device joins the PAN and data frames are subsequently exchanged between the coordinator and both end devices, in a star topology fashion (end devices must only transmit frames to coordinators). In this case, the output is supressed.

% Create second end-device:
endDevice2 = lrwpan.MACReducedFunctionDevice('SamplesPerChip', 4, ...
  'ShortAddress', '0002', 'ExtendedAddress', [repmat('0', 1, 8) repmat('4', 1, 8)], 'Verbosity', false);
% Supress detailed output:
endDevice1.Verbosity = false;
panCoordinator.Verbosity = false;

% Initialize input
received3 = zeros(samplesPerChip * chipsPerSymbol * symbolsPerStep/2, 1);

stopTime = 10; % sec
while time < stopTime
  % Pass the received signals to the nodes for processing. Also, fetch what
  % they have to transmit:
  transmitted1 = panCoordinator(received1);
  transmitted2 = endDevice1(received2);
  transmitted3 = endDevice2(received3);

  % Ideal wireless channel, where all nodes are within range:
  received1 = transmitted2 + transmitted3; % half-duplex radios, none receiving while transmitting
  received2 = transmitted1 + transmitted3;
  received3 = transmitted1 + transmitted2;

  time = time + symbolsPerStep/symbolRate; % update clock
end

More nodes can be added to the network, as long as the channel relationship is established accordingly (i.e., the received signals as a function of the transmitted signals).

Further Exploration

You can further explore the following generator and decoding functions, as well as the configuration object:

Selected Bibliography

  1. IEEE 802.15.4-2011 - IEEE Standard for Local and metropolitan area networks--Part 15.4: Low-Rate Wireless Personal Area Networks (LR-WPANs)