Thank your answers, that helped me out.



------------------ ???????? ------------------
??????: "Shyam Shrivastav"<[email protected]>;
????????: 2018??12??6??(??????) ????2:22
??????: "bai bakari"<[email protected]>;
????: "dev"<[email protected]>; 
????: 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 <[email protected]> 
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 <[email protected]> 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 via email to