This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

802.15.4 Packet Size

Hello,

I've been testing 802.15.4 single PHY (no softdevice) and analyzing packets on a TI CC2531, just to check interoperability. Things seem to work well when the packet size is at most 29 bytes. When I increase the packet size to 30 or more, the packet reception is poor (maybe some packets get through, many get CRC errors). I had thought that the limitation was 127 bytes for the 802.15.4 standard. 

In a way, 29 bytes makes sense: considering the first byte (not in the packet) is the length, then the two auto-generated CRC bytes as the footer, we get the magic number of 32 bytes. Is that what's going on, 32 bytes is the actual limit?

Thanks,

Ted 

Parents
  • Hi,

    Can you post the code you use on the nRF side? The specifications have defined a maximum payload of 127, but the radio on either of the ends could limit this number. 

    Best regards,
    Jørgen

  • OK, this is the code which I modify for experimenting on the nRF side.


    #include <stdbool.h>
    #include <stddef.h>
    #include <stdint.h>
    
    #include "nrf_802154.h"
    #include "boards.h"
    #include "nrf_delay.h"
    #include "IEEE802154.h"
    
    #define MAX_MESSAGE_SIZE 29 
    #define CHANNEL 26
    #define PACKET_MAX_PAYLOAD 18
    
    typedef uint16_t mac_addr_t;
    struct motepacket {
      uint8_t length;
      uint16_t fcf;
      uint8_t data_seq_no;
      mac_addr_t pan;
      mac_addr_t dest;
      mac_addr_t src;
      uint8_t iframe;    // field for 6lowpan, is 0x3f for TinyOS
      uint8_t type;
      uint8_t data[PACKET_MAX_PAYLOAD];
      uint8_t fcs[2];    // will become CRC, don't count this in length.
      };
    typedef struct motepacket motepacket_t;
    
    static volatile bool m_tx_in_progress;
    static volatile bool m_tx_done;
    uint8_t seqno = 0; 
    uint8_t buffer[sizeof(motepacket_t)];
    motepacket_t * p = (motepacket_t *)buffer;
    
    //int main(int argc, char *argv[])
    int main(void)
    {
        bsp_board_init(BSP_INIT_LEDS);
        bsp_board_led_invert(0);
    
        p->fcf = 0x0000;
        // the following FCF lines are copied
        p->fcf &= 1 << IEEE154_FCF_ACK_REQ;
        p->fcf |= ( ( IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE )
                      |  ( 1 << IEEE154_FCF_INTRAPAN )
                      |  ( IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE )
                      |  ( IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE ) );
        p->data_seq_no = 0;
        p->pan = 0x22;     // 
        p->dest = 0xFFFF;  //  
        p->src = 99;       //  
        p->iframe = 0x3f;  //  
        p->type = 0x37;    //  
        //p->length =  offsetof(motepacket_t,data) + PACKET_MAX_PAYLOAD - 1;
        p->length = 29;
        m_tx_in_progress = false;
        m_tx_done        = false;
    
        nrf_802154_init();
        nrf_802154_channel_set(CHANNEL);
        nrf_802154_receive();
    
        while (1)
        {
            p->data_seq_no = seqno++;
            for (int i=0; i<PACKET_MAX_PAYLOAD; i++) p->data[i] = seqno+i;
            bsp_board_led_invert(0);
            // if (m_tx_done)
            // {
            //     m_tx_in_progress = false;
            //     m_tx_done        = false;
            // }
    
            // if (!m_tx_in_progress)
            // {
                //tx_buffer_fill(message, sizeof(message));
    
                //m_tx_in_progress = nrf_802154_transmit(message, sizeof(message), true);
                m_tx_in_progress = nrf_802154_transmit_raw(buffer, true);
                if (m_tx_in_progress) {
                    bsp_board_led_invert(1);
                }
            // }
            printf("sent msg\n");
            nrf_delay_ms(3000);
    
        }
    
        return 0;
    }
    
    void nrf_802154_transmitted(const uint8_t * p_frame, uint8_t * p_ack, uint8_t length, int8_t power, int8_t lqi)
    {
        (void) p_frame;
        (void) length;
        (void) power;
        (void) lqi;
    
        m_tx_done = true;
                 bsp_board_led_invert(2);
    
        if (p_ack != NULL)
        {
            //nrf_802154_buffer_free(p_ack);
            nrf_802154_buffer_free_raw(p_ack);
        }
    }

Reply
  • OK, this is the code which I modify for experimenting on the nRF side.


    #include <stdbool.h>
    #include <stddef.h>
    #include <stdint.h>
    
    #include "nrf_802154.h"
    #include "boards.h"
    #include "nrf_delay.h"
    #include "IEEE802154.h"
    
    #define MAX_MESSAGE_SIZE 29 
    #define CHANNEL 26
    #define PACKET_MAX_PAYLOAD 18
    
    typedef uint16_t mac_addr_t;
    struct motepacket {
      uint8_t length;
      uint16_t fcf;
      uint8_t data_seq_no;
      mac_addr_t pan;
      mac_addr_t dest;
      mac_addr_t src;
      uint8_t iframe;    // field for 6lowpan, is 0x3f for TinyOS
      uint8_t type;
      uint8_t data[PACKET_MAX_PAYLOAD];
      uint8_t fcs[2];    // will become CRC, don't count this in length.
      };
    typedef struct motepacket motepacket_t;
    
    static volatile bool m_tx_in_progress;
    static volatile bool m_tx_done;
    uint8_t seqno = 0; 
    uint8_t buffer[sizeof(motepacket_t)];
    motepacket_t * p = (motepacket_t *)buffer;
    
    //int main(int argc, char *argv[])
    int main(void)
    {
        bsp_board_init(BSP_INIT_LEDS);
        bsp_board_led_invert(0);
    
        p->fcf = 0x0000;
        // the following FCF lines are copied
        p->fcf &= 1 << IEEE154_FCF_ACK_REQ;
        p->fcf |= ( ( IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE )
                      |  ( 1 << IEEE154_FCF_INTRAPAN )
                      |  ( IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE )
                      |  ( IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE ) );
        p->data_seq_no = 0;
        p->pan = 0x22;     // 
        p->dest = 0xFFFF;  //  
        p->src = 99;       //  
        p->iframe = 0x3f;  //  
        p->type = 0x37;    //  
        //p->length =  offsetof(motepacket_t,data) + PACKET_MAX_PAYLOAD - 1;
        p->length = 29;
        m_tx_in_progress = false;
        m_tx_done        = false;
    
        nrf_802154_init();
        nrf_802154_channel_set(CHANNEL);
        nrf_802154_receive();
    
        while (1)
        {
            p->data_seq_no = seqno++;
            for (int i=0; i<PACKET_MAX_PAYLOAD; i++) p->data[i] = seqno+i;
            bsp_board_led_invert(0);
            // if (m_tx_done)
            // {
            //     m_tx_in_progress = false;
            //     m_tx_done        = false;
            // }
    
            // if (!m_tx_in_progress)
            // {
                //tx_buffer_fill(message, sizeof(message));
    
                //m_tx_in_progress = nrf_802154_transmit(message, sizeof(message), true);
                m_tx_in_progress = nrf_802154_transmit_raw(buffer, true);
                if (m_tx_in_progress) {
                    bsp_board_led_invert(1);
                }
            // }
            printf("sent msg\n");
            nrf_delay_ms(3000);
    
        }
    
        return 0;
    }
    
    void nrf_802154_transmitted(const uint8_t * p_frame, uint8_t * p_ack, uint8_t length, int8_t power, int8_t lqi)
    {
        (void) p_frame;
        (void) length;
        (void) power;
        (void) lqi;
    
        m_tx_done = true;
                 bsp_board_led_invert(2);
    
        if (p_ack != NULL)
        {
            //nrf_802154_buffer_free(p_ack);
            nrf_802154_buffer_free_raw(p_ack);
        }
    }

Children
No Data
Related