From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qg0-x232.google.com (mail-qg0-x232.google.com [IPv6:2607:f8b0:400d:c04::232]) by dpdk.org (Postfix) with ESMTP id 8989268A2 for ; Fri, 14 Mar 2014 12:36:31 +0100 (CET) Received: by mail-qg0-f50.google.com with SMTP id q108so6961433qgd.9 for ; Fri, 14 Mar 2014 04:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Io/2ePOltwl+sdYV+TsUPtTiVSvYaARm3D1MNx0WHDM=; b=KVVnP2mQB8CAoQj3VkPTgaToNyB3ssYZIUsI5GbzWpKOQni1yyfiSxChmQq37OsbfN k5DAUy1053JSzMF2MbSVoB1n0Q04apuSENVPWOayhWStLVGdjqSsjFmOKGCgT3NP4lHu 0UVR6UtRxJr6nU7FeYfK+b+5j5OJPIWiTSkCjsW2xS8nre80o4yGZ5j501del3ZkzL+U LU8UmWrDbc5DqOH5zuPNOW97hZ9VAKnL+5vo1JeIFaJ6HgckSzU8WwlajJ/gHLRDJIMJ GTuRFYKSAQ9sviUpWNEp0BhI7T0pOoG/ysfy1RpAI2vEmhFrqbVGty8OTVUBkbcSn8FY ri5w== MIME-Version: 1.0 X-Received: by 10.224.11.136 with SMTP id t8mr9149728qat.26.1394797081781; Fri, 14 Mar 2014 04:38:01 -0700 (PDT) Received: by 10.96.69.97 with HTTP; Fri, 14 Mar 2014 04:38:01 -0700 (PDT) In-Reply-To: <59AF69C657FD0841A61C55336867B5B01A9C452F@IRSMSX103.ger.corp.intel.com> References: <59AF69C657FD0841A61C55336867B5B01A9C4436@IRSMSX103.ger.corp.intel.com> <59AF69C657FD0841A61C55336867B5B01A9C452F@IRSMSX103.ger.corp.intel.com> Date: Fri, 14 Mar 2014 17:08:01 +0530 Message-ID: From: sabu kurian To: "Richardson, Bruce" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 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:36:31 -0000 Thanks on the reply Richardson. You did mention something like "Don't forget that when you get the mbuf from rte_pktmbuf_alloc, you also need to set the length value to the appropriate size." . Like I'm allocating the mbuf using rte_mbuf . The rte_mempool_create has already set the maximum packet size for a mbuf and the number of mbuf's and all. So do I really need to use rte_pktmbuf_alloc ? On Fri, Mar 14, 2014 at 4:38 PM, Richardson, Bruce < bruce.richardson@intel.com> wrote: > > > From: sabu kurian [mailto:sabu2kurian@gmail.com] > > 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 > another way of doing it using the rte_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 > designed to add headers/footers on to an existing packet that already has > headers, so that you don't need to move the existing data. In the case of > having to craft a packet from scratch, there is no existing data in the > mbuf, so the whole packet can just be filled in sequentially. [Don't forget > that when you get the mbuf from rte_pktmbuf_alloc, you also need to set the > length value to the appropriate size.] > > However, if you first write the data to the mbuf and then want to add the > headers 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 > will 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 and data pointer values in the mbuf. Each header prepended also uses > up headroom in the mbuf, so you can only add 128-bytes of headers by > default to each packet. > > In short, if you are creating a single packet, I'd recommend just getting > the data pointer from the returned mbuf and writing directly to that. > > Regards, > /Bruce >