DPDK patches and discussions
 help / color / mirror / Atom feed
From: =?gb18030?B?YmFpIGJha2FyaQ==?= <912873551@qq.com>
To: =?gb18030?B?U2h5YW0gU2hyaXZhc3Rhdg==?=
	<shrivastav.shyam@gmail.com>,
	=?gb18030?B?VmFyZ2hlc2UsIFZpcGlu?= <vipin.varghese@intel.com>
Cc: =?gb18030?B?ZGV2?= <dev@dpdk.org>
Subject: [dpdk-dev] =?gb18030?b?u9i4tKO6ICBBYm91dCB0aGUgZGF0YSBwYXlsb2Fk?= =?gb18030?q?_of_rte=5Fmbuf=3F?=
Date: Thu, 6 Dec 2018 14:19:50 +0800	[thread overview]
Message-ID: <tencent_4BC888D016278BD2994E9F277D5B2C751506@qq.com> (raw)
In-Reply-To: <CAGSp03mXtMRi9=KUu1w8LzuyHgLGfBrXe+HAkQMMK1Wrr_DSsw@mail.gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 2018 bytes --]

Thank your answers, that helped me out.




------------------ ԭʼÓʼþ ------------------
·¢¼þÈË: "Shyam Shrivastav"<shrivastav.shyam@gmail.com>;
·¢ËÍʱ¼ä: 2018Äê12ÔÂ6ÈÕ(ÐÇÆÚËÄ) ÏÂÎç2:22
ÊÕ¼þÈË: "bai bakari"<912873551@qq.com>;
³­ËÍ: "dev"<dev@dpdk.org>; 
Ö÷Ìâ: Re: [dpdk-dev] About the data payload of rte_mbuf?



And if just payload length is required one can get by subtracting  (ip-hdr-len + tcp-offset) from total length in ip header ...



On Thu, Dec 6, 2018 at 11:18 AM Shyam Shrivastav <shrivastav.shyam@gmail.com> wrote:



As per my understanding

payload = (uint8_t *)tcp_hdr + (tcp_hdr->data_off << 2);

should be

payload = (uint8_t *)tcp_hdr + (tcp_hdr->data_off >> 4) << 2);

Note that data offset is 4 most significant bits of the byte, refer tcp header






On Thu, Dec 6, 2018 at 9:15 AM bai bakari <912873551@qq.com> wrote:

Hi,
 
 
 Now, I want to get the data payload of rte_mbuf, and i wrote the following code:
 
 
 struct ipv4_hdr *ipv4_hdr;
 struct tcp_hdr *tcp_hdr;
 uint32_t payload_len, ip_len;
 uint8_t *payload = NULL;
 
 
 
 ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, sizeof(struct ether_hdr));
 ip_len = ntohs(ipv4_hdr->total_length);
 
 
 
 if (ipv4_hdr->next_proto_id == IPPROTO_TCP) {
     tcp_hdr = (struct tcp_hdr *)((uint8_t *)ipv4_hdr + ((ipv4_hdr->version_ihl & 0xf) << 2));
     payload = (uint8_t *)tcp_hdr + (tcp_hdr->data_off << 2);
     payload_len = ip_len - (payload - (uint8_t *)ipv4_hdr);
 
 }
 
 
 when i send packets using dpdk-pktgen, i found:
 ip_len = 46
 ip_header_len = 20
 but the tcp_header_len=(tcp_hdr->data_off << 2)=0, 
 and (payload - (uint8_t *)ipv4_hdr) = 340 > ip_len.
 
 
 I'm confused, is there any errors about the code to compute the payload_len of rte_mbuf? 
 I think maybe the dpdk-pktgen cannot send the packets with payload? 
 
 
 I'm a beginner, anyone can help me how to compute the payload_len of rte_mbuf and test it?
 
 
 Thank you in advance!

  reply	other threads:[~2018-12-06  6:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06  3:45 [dpdk-dev] About the data payload of rte_mbuf? bai bakari
2018-12-06  4:20 ` Varghese, Vipin
2018-12-06  4:59   ` bai bakari
2018-12-06  5:41     ` Varghese, Vipin
2018-12-06  5:48 ` Shyam Shrivastav
2018-12-06  5:52   ` Shyam Shrivastav
2018-12-06  6:19     `  =?gb18030?B?YmFpIGJha2FyaQ==?= [this message]
2018-12-06  7:09 ` Stephen Hemminger
2018-12-06 15:17   ` Wiles, Keith
2018-12-06 17:22     ` Stephen Hemminger

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=tencent_4BC888D016278BD2994E9F277D5B2C751506@qq.com \
    --to=912873551@qq.com \
    --cc=dev@dpdk.org \
    --cc=shrivastav.shyam@gmail.com \
    --cc=vipin.varghese@intel.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).