DPDK usage discussions
 help / color / mirror / Atom feed
* [dpdk-users] Calculating Packet Length
@ 2018-09-29 10:19 Michael Barker
  2018-09-29 10:39 ` Shyam Shrivastav
  2018-09-29 14:39 ` Wiles, Keith
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Barker @ 2018-09-29 10:19 UTC (permalink / raw)
  To: users

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] Calculating Packet Length
  2018-09-29 10:19 [dpdk-users] Calculating Packet Length Michael Barker
@ 2018-09-29 10:39 ` Shyam Shrivastav
  2018-09-29 14:39 ` Wiles, Keith
  1 sibling, 0 replies; 4+ messages in thread
From: Shyam Shrivastav @ 2018-09-29 10:39 UTC (permalink / raw)
  To: mikeb01; +Cc: users

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@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.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] Calculating Packet Length
  2018-09-29 10:19 [dpdk-users] Calculating Packet Length Michael Barker
  2018-09-29 10:39 ` Shyam Shrivastav
@ 2018-09-29 14:39 ` Wiles, Keith
  2018-09-29 20:10   ` Michael Barker
  1 sibling, 1 reply; 4+ messages in thread
From: Wiles, Keith @ 2018-09-29 14:39 UTC (permalink / raw)
  To: Michael Barker; +Cc: users



> On Sep 29, 2018, at 5:19 AM, Michael Barker <mikeb01@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);

This does seem to be wrong and sizeof(struct ether_hdr) should have used. As the L2 header is normally 14 bytes in size.

A packet in DPDK must be at least 60 bytes in length is the hardware appends the Frame checksum (4 bytes) because all ethernet frames must be at least 64 bytes in the wire. Some hardware will pad the frame out the correct length then add the FCS (Frame Checksum) bytes. Some hardware will discard the frame and count it as a runt or fragment. Just to be safe I always make sure the length of the frame is 60 bytes at least using a software check.

Hope that helps you. 

Also it looks like the3 ptpclient.c file may need to be fixed.

> 
>    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.

Regards,
Keith

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] Calculating Packet Length
  2018-09-29 14:39 ` Wiles, Keith
@ 2018-09-29 20:10   ` Michael Barker
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Barker @ 2018-09-29 20:10 UTC (permalink / raw)
  To: Wiles, Keith, users

>
> Hope that helps you.
>

It does, thank you.


> Also it looks like the3 ptpclient.c file may need to be fixed.
>

No need. The bug is all mine. I mistyped when transcribing. A "not
copy-paste" bug :-).

Mike.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-29 20:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-29 10:19 [dpdk-users] Calculating Packet Length Michael Barker
2018-09-29 10:39 ` Shyam Shrivastav
2018-09-29 14:39 ` Wiles, Keith
2018-09-29 20:10   ` Michael Barker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).