DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Richardson, Bruce" <bruce.richardson@intel.com>
To: sabu kurian <sabu2kurian@gmail.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] Packet crafting....
Date: Fri, 14 Mar 2014 11:08:57 +0000	[thread overview]
Message-ID: <59AF69C657FD0841A61C55336867B5B01A9C452F@IRSMSX103.ger.corp.intel.com> (raw)
In-Reply-To: <CAJ2bnfA8a3_uwiQD5ZxFT9pU-0cv0RB4qRdTfY3xZt_TbcgAfA@mail.gmail.com>


> 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

  reply	other threads:[~2014-03-14 11:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14  9:31 sabu kurian
2014-03-14  9:57 ` Richardson, Bruce
2014-03-14 10:09   ` sabu kurian
2014-03-14 11:08     ` Richardson, Bruce [this message]
2014-03-14 11:38       ` sabu kurian
2014-03-14 11:49         ` Richardson, Bruce
2014-03-14 12:04           ` sabu kurian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59AF69C657FD0841A61C55336867B5B01A9C452F@IRSMSX103.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=sabu2kurian@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).