From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id B6DAD1B1FF for ; Sat, 29 Sep 2018 16:40:15 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Sep 2018 07:40:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,320,1534834800"; d="scan'208";a="96044291" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 29 Sep 2018 07:39:41 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 29 Sep 2018 07:39:40 -0700 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.34]) by FMSMSX109.amr.corp.intel.com ([169.254.15.83]) with mapi id 14.03.0319.002; Sat, 29 Sep 2018 07:39:40 -0700 From: "Wiles, Keith" To: Michael Barker CC: "users@dpdk.org" Thread-Topic: [dpdk-users] Calculating Packet Length Thread-Index: AQHUV93xPEKZM3QuM0SPWRgf2yiBIKUHyhsA Date: Sat, 29 Sep 2018 14:39:39 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.81.84] Content-Type: text/plain; charset="us-ascii" Content-ID: <6EAF354D15845E4AA8A9BD3897062E60@intel.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-users] Calculating Packet Length X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Sep 2018 14:40:16 -0000 > On Sep 29, 2018, at 5:19 AM, Michael Barker wrote: >=20 > Hi, >=20 > 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 d= id > the following: >=20 > struct rte_mbuf* arp_pkt =3D rte_pktmbuf_alloc(mbuf_pool); > const size_t pkt_size =3D sizeof(struct ether_addr) + sizeof(struct > arp_hdr); This does seem to be wrong and sizeof(struct ether_hdr) should have used. A= s the L2 header is normally 14 bytes in size. A packet in DPDK must be at least 60 bytes in length is the hardware append= s 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 len= gth 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 su= re the length of the frame is 60 bytes at least using a software check. Hope that helps you.=20 Also it looks like the3 ptpclient.c file may need to be fixed. >=20 > arp_pkt->data_len =3D pkt_size; > arp_pkt->pkt_len =3D pkt_size; >=20 > 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 modi= fy > the size to be the following: >=20 > const size_t pkt_size =3D sizeof(struct ether_addr) + sizeof(struct > arp_hdr) + 8; >=20 > It works as expected. I'm wondering where the extra 8 bytes come from? = Is > there a better way to calculate the packet length? >=20 > Using dpdk 18.08, Linux - kernel 4.15.0-33. >=20 > Mike. Regards, Keith