From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by dpdk.org (Postfix) with ESMTP id DAE2E683E for ; Thu, 6 Dec 2018 06:49:06 +0100 (CET) Received: by mail-wm1-f50.google.com with SMTP id a18so15200158wmj.1 for ; Wed, 05 Dec 2018 21:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pddZwEHIMEBa+XnthauC8MhTRMzizARLoecr3lSAkOA=; b=hFsO0+7Z2vRev4JTOOZrcuy66dgjdbegZKXTzJ8i85ksY7fvcYR+7uA/P/5hC/askg VdH2LmoHfzLO4EWiTO8h2V97NAnAcuM2+DTPf9TKLUIWJJfG/VTZmhHcQ4qAXSyatcWy Nyq1r9lrBlHUtn0IWWKzDG1m8vwQdHv+DsBP7rlxBda8uWZdXiScWa1ZFT9q4/aImPIV Kf6ccB/YDCspuMoG0b8jbQD2IT11vE5jimj4J2yaSAxSAJe/ekpI4N8vyfwBxfB1fN1Z fFzWOuO9oc6HLI9je7xIgAaRY8wujLLu281NIH50FblgCTD0oNyLRxJv4X20vSrL3v0Z 22uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pddZwEHIMEBa+XnthauC8MhTRMzizARLoecr3lSAkOA=; b=bBYIkEYUDxLPpLNjyDU4vpQGtV6Wed155utwE4YDW69HAJIZCBsBOMybBkkAg0Bb/5 KGYqKPLN6/qLEA49kqI1IzxtivGCNl3e16oG0RcPIFxlpkGzDyD/byn7Ycj8C5NF9rfB rPtIGNBniiB7BYQkwHgkGBp1uFLRYhPWOG6kqBMIUhTiHNLAbVrT928weglJ8jqI9xZZ wWMeg3SP9BvrZMX8CV0XwG2V9m0keNUSbDVU0KSSnFCGQWhxgMih+VNPU37JsVy5m9om o1Il8t0RG5njkmeBqlgYwKhiOCFXiadicZCF0FtdECJelCLFyq+shhbFP/NOoqW4ojZ+ v+pg== X-Gm-Message-State: AA+aEWb32HOiI2fXJfHcBrUWdm8TUKVir6hJ9XblMaU3UrNUH5xh8FMt 13iWxb8oZk1gZeIUurQGGmdRVodgeuYZjQoqd1c= X-Google-Smtp-Source: AFSGD/WsgKk9Vqf+DnKpkLH8LeQSAvZMu0njDqeEn4rIW03PggbkoKJE+oeHICePJnPAJKFPlvymGiRTH7V08dzVDhg= X-Received: by 2002:a1c:9dcc:: with SMTP id g195mr17708316wme.153.1544075346407; Wed, 05 Dec 2018 21:49:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Shyam Shrivastav Date: Thu, 6 Dec 2018 11:18:49 +0530 Message-ID: To: 912873551@qq.com Cc: dev@dpdk.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] About the data payload of rte_mbuf? X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2018 05:49:07 -0000 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!