[dpdk-users] Calculating Packet Length

Shyam Shrivastav shrivastav.shyam at gmail.com
Sat Sep 29 12:39:13 CEST 2018


We have to use sizeof(struct ether_hdr) , length set is wrong and 8 bytes
short

struct ether_hdr {
    struct ether_addr d_addr; /**< Destination address. */
    struct ether_addr s_addr; /**< Source address. */
    uint16_t ether_type;      /**< Frame type. */
} __attribute__((__packed__));


On Sat, Sep 29, 2018 at 3:49 PM Michael Barker <mikeb01 at gmail.com> wrote:

> Hi,
>
> I've new to DPDK and have been started by sending ARP packets.  I have a
> question around how to set the mbuf data_len and pkt_size.  I Initially did
> the following:
>
>     struct rte_mbuf* arp_pkt = rte_pktmbuf_alloc(mbuf_pool);
>     const size_t pkt_size = sizeof(struct ether_addr) + sizeof(struct
> arp_hdr);
>
>     arp_pkt->data_len = pkt_size;
>     arp_pkt->pkt_len = pkt_size;
>
> Which is based on ptpclient.c sample code.  However after setting all of
> the fields, the packet either doesn't get sent or has some of the data
> truncated from the end of the packet when viewed in Wireshark.  If I modify
> the size to be the following:
>
>     const size_t pkt_size = sizeof(struct ether_addr) + sizeof(struct
> arp_hdr) + 8;
>
> It works as expected.  I'm wondering where the extra 8 bytes come from?  Is
> there a better way to calculate the packet length?
>
> Using dpdk 18.08, Linux - kernel 4.15.0-33.
>
> Mike.
>


More information about the users mailing list