From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id A86206895 for ; Fri, 14 Mar 2014 12:07:34 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 14 Mar 2014 04:09:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,654,1389772800"; d="scan'208";a="499793925" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga002.jf.intel.com with ESMTP; 14 Mar 2014 04:09:03 -0700 Received: from irsmsx106.ger.corp.intel.com (163.33.3.31) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.123.3; Fri, 14 Mar 2014 11:08:58 +0000 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.27]) by IRSMSX106.ger.corp.intel.com ([169.254.8.26]) with mapi id 14.03.0123.003; Fri, 14 Mar 2014 11:08:58 +0000 From: "Richardson, Bruce" To: sabu kurian Thread-Topic: [dpdk-dev] Packet crafting.... Thread-Index: AQHPP2hUbAIFcBny4k6YxtDmOL10iJrgVz8wgAAE0YCAAA1t4A== Date: Fri, 14 Mar 2014 11:08:57 +0000 Message-ID: <59AF69C657FD0841A61C55336867B5B01A9C452F@IRSMSX103.ger.corp.intel.com> References: <59AF69C657FD0841A61C55336867B5B01A9C4436@IRSMSX103.ger.corp.intel.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Packet crafting.... X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Mar 2014 11:07:35 -0000 > From: sabu kurian [mailto:sabu2kurian@gmail.com]=20 > Sent: Friday, March 14, 2014 10:09 AM > To: Richardson, Bruce > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] Packet crafting.... > > Thank you very much Richardson for your valuable reply. But is there anot= her way of doing it using the=A0rte_pktmbuf_append / rte_pktmbuf_prepend ? = Can you please tell me on how to do that ? You could use pktmbuf_append and pktmbuf_prepend, but they are primarily de= signed to add headers/footers on to an existing packet that already has hea= ders, so that you don't need to move the existing data. In the case of havi= ng to craft a packet from scratch, there is no existing data in the mbuf, s= o the whole packet can just be filled in sequentially. [Don't forget that w= hen you get the mbuf from rte_pktmbuf_alloc, you also need to set the lengt= h value to the appropriate size.] However, if you first write the data to the mbuf and then want to add the h= eaders in order, like a packet moving down through layers of a stack, you = can use prepend to add udp, then ip, then your ethernet header, but this wi= ll be no faster than just writing the data directly to the mbuf space, and = may be slightly slower as each prepend call has to just the length values a= nd data pointer values in the mbuf. Each header prepended also uses up head= room in the mbuf, so you can only add 128-bytes of headers by default to ea= ch packet. In short, if you are creating a single packet, I'd recommend just getting t= he data pointer from the returned mbuf and writing directly to that.=20 Regards, /Bruce