DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] About the data payload of rte_mbuf?
@ 2018-12-06  3:45 bai bakari
  2018-12-06  4:20 ` Varghese, Vipin
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: bai bakari @ 2018-12-06  3:45 UTC (permalink / raw)
  To: dev

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!

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-12-06 17:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` [dpdk-dev] =?gb18030?b?u9i4tKO6ICBBYm91dCB0aGUgZGF0YSBwYXlsb2Fk?= =?gb18030?q?_of_rte=5Fmbuf=3F?=  =?gb18030?B?YmFpIGJha2FyaQ==?=
2018-12-06  7:09 ` [dpdk-dev] About the data payload of rte_mbuf? Stephen Hemminger
2018-12-06 15:17   ` Wiles, Keith
2018-12-06 17:22     ` Stephen Hemminger

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).