Sending data through an 802.15.4 network latency timing

How long does it take to send data through an 802.15.4 network?

 

Digi's XBee Series 1 radio modules run 802.15.4 firmware, which allows them to transmit data in a point-to-point, peer-to-peer or point-to-multipoint (star) network architecture. The time it takes to transmit a data packet is a sum of the Time on Air and Time for CSMA-CA and Retries, as outlined below.


Quick Reference: (The following are described in context below.)

  • XBee 802.15.4 max payload = 100 bytes
  • RF baud rate (802.15.4, 2.4GHz) = 250 Kbps
  • Byte time @ 250 Kbps = 32 us
  • 64-bit: T_air(B) = 0.8 + 0.032B ms
  • 16-bit: T_air(B) = 0.416 + 0.032B ms
  • 16-bit best case (broadcast and unicast): T_total(B) = 0.544 + 0.032B ms
  • 64-bit unicast best case: T_total(B) = 0.928 + 0.032B ms
  • Broadcast worst case: T_total(B) = 9.376 + 0.032B ms
  • 16-bit unicast worst case: T_total(B) = 40.096 + 0.128B ms
  • 64-bit unicast worst case: left for the reader to calculate


Time on Air

The 802.15.4 PHY layer allows a maximum 127 bytes per packet, including payload. Due to the size of the packet header, XBee Series 1 modules can send a maximum payload of 100 bytes.

At 2.4 GHz the 802.15.4 PHY layer specifies an RF baud rate of 250 Kbps, which is a 4 us bit time or 32 us byte time. This gives us enough information to compute the "T_air(B)," the actual time on the air taken to send B payload bytes.

T_air(1) = (25 + 1) * 32 us = 0.832 ms [25-byte header + 1 payload byte) * 32 us byte time]

T_air(100) = (25 + 100) * 32 us = 4.000 ms

T_air(B) = 0.8 + 0.032B ms

The above calculation is assuming 64-bit addressing. It is probably more common to use only 16-bit addressing which allows us to use a 13-byte header instead of a 25-byte header (subtract 48 bits from 64 bits in both source and destination addressing to reduce a total of 96 bits or 12 bytes). Using 16-bit addressing (non-encrypted-encryption will have to be covered in another article):

T_air(1) = (13 + 1) * 32 us = 0.448 ms

T_air(72) = (13 + 72) * 32 us = 2.720 ms

T_air(100) = (13 + 100) * 32 us = 3.616 ms

T_air(B) = 0.416 + 0.032B ms


Time for CSMA-CA and Retries

The above calculations are the "on-air" time only. The total time it takes to transmit an 802.15.4 packet includes the time for CSMA-CA and retries, where applicable.

CSMA-CA stands for Carrier Sense Multiple Access - Collision Avoidance. This basically means that before a radio actually begins transmitting on the air it senses the carrier channel to make sure the air waves are clear (called CCA-Clear Channel Assessment). If it senses strong enough activity on the channel, it will perform a random delay (backoff/wait time) and then try again with another CCA.

For a diagram of the CSMA-CA algorithm, see page 172 of the IEEE 802.15.4-2006 spec. For easier reference we provide an outline of the basic steps here:

  1. Perform random delay.
  2. Perform CCA.
  3. Transmit if CCA is clear. If channel is not clear, then repeat steps 1-3 up to 4 more times.
  4. Done if broadcast (no acknowledgment/retry). If unicast:
    1. Wait for ACK (acknowledgment of packet received) from destination node.
    2. Done if ACK is received. Repeat steps 1-4 up to 3 more times.

Following are the computations for the above steps:

  1. Perform random delay. The random delay function is (0 : 2^BE - 1) * 0.320 ms, where BE starts at RN and increments each time (up to max value of 5) through the loop until step 3 is cleared. (RN is default 0; it is a user-settable parameter for random delay on the XBee 802.15.4). The "0 : à" means it chooses a random number between 0 and...
  2. Perform CCA. This step always takes 0.128 ms.
  3. No computation on this step.
    1. Wait for ACK. This step takes up to 0.864 ms.
    2. No computation on this step.


Total Transmit Time

Let''s do some examples to compute "T_total(B)," the total time taken to send B payload bytes.

Best case:

Broadcast 1 byte, RN = 0

          Random Delay = (0 : 2^0 - 1) * 0.320 = 0 ms

          CCA = 0.128 ms

          T_air(1) = 0.448 ms

          T_total(1) = 0 + 0.128 + 0.448 = 0.576 ms

(Note: We assumed CCA was clear for "best case." Then we used the T_air(B) formula from the first section above to calculate the transmit time. Broadcasts use 16-bit addressing.)

To generalize this "best case" timing calculation (works for both broadcast and unicast since "best case" assumes no time spent waiting on the ACK in step 4.a):

          16-bit: T_total(B) = 0.544 + 0.032B ms

Similarly, we can compute the "best case" timing for a 64-bit addressed unicast packet, assuming ~0 time spent waiting on the ACK:

          64-bit: T_total(B) = 0.928 + 0.032B ms

Worst case:

Example: Broadcast 1 byte, RN = 0

          Random Delay = 0 ms

          CCA = 0.128 ms [Assume CC did not clear. Go back to step 1.]

          Random Delay = (0 : 1) * 0.320 = 0.320 ms

          CCA = 0.128 ms

          Random Delay = (0 : 3) * 0.320 = 0.960 ms [Assuming (0 : 3) yielded 3.]

          CCA = 0.128 ms

          Random Delay = (0 : 7) * 0.320 = 2.240 ms [Assuming (0 : 7) yielded 7.]

          CCA = 0.128 ms

          Random Delay = (0 : 15) * 0.32 = 4.800 ms [Assuming (0 : 15) yielded 15.]

          CCA = 0.128 ms

        

         Subtotal for this CSMA-CA section: 8.96 ms

         T_air(1) = 0.448 ms

         T_total(1) = 8.96 + 0.448 = 9.408 ms

To generalize this "worst case" timing calculation for a broadcast message:

          T_total(B) = 9.376 + 0.032B ms

[Keep in mind it is highly unlikely that the largest number would be chosen from the random number function every time. Perhaps a more likely scenario would be to choose the middle value (e.g. (0 : 15) would yield 7.5, on average).]

Worst case:

Example: 16-bit Unicast 72 bytes, RN = 0

           Worst case CSMA-CA section: 8.96 ms

           T_air(72) = 2.72 ms

           Wait for ACK = 0.864 ms [Assume ACK failed.]

(Retry #1)

           Worst case CSMA-CA section: 8.96 ms

           T_air(72) = 2.72 ms

          Wait for ACK = 0.864 ms [Assume ACK failed.]

(Retry #2)

           Worst case CSMA-CA section: 8.96 ms

           T_air(72) = 2.72 ms

          Wait for ACK = 0.864 ms [Assume ACK failed.]

(Retry #3)

          Worst case CSMA-CA section: 8.96 ms

          T_air(72) = 2.72 ms

          [Success on final attempt! Assume ~0 time was spent waiting on ACK.]

          T_total(72) = ((8.96 + 2.72 + 0.864) * 4) - 0.864 = 49.312 ms

To generalize this "worst case" timing calculation for a 16-bit unicast message:

          T_total(B) = ((8.96 + 0.416 + 0.032B + 0.864) * 4) - 0.864 ms

          T_total(B) = 40.096 + 0.128B ms

The final case that could be calculated here is the "worst case" timing for a 64-bit unicast message. This calculation is left for the reader to perform.

Last updated: Jan 01, 2024

Filed Under

RFRF Dev kits

Recently Viewed

No recently viewed articles

Did you find this article helpful?