From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by dpdk.org (Postfix) with ESMTP id A61372BFA for ; Sun, 10 Apr 2016 20:06:29 +0200 (CEST) Received: by mail-lf0-f49.google.com with SMTP id e190so128589162lfe.0 for ; Sun, 10 Apr 2016 11:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=colorado-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc; bh=h9DJ/jKNl0F1H+PdwEMI8RmmqwmBRY2ywS4veqU5moE=; b=uh+1QxAiJsEfEDnroiV78PWuHnvEbO6mPhkvOX26arlyVdDI4KeLorw4ojcbV3OnCW sjXhEkjjxxExXcy/Isr75Xy1Qr+gGIVoF/xAhkKBDGHE6tiTopU3sj0axelKRJMqe0vv Z9FyBBuiwe2s53r+6TuSYl0Zcjj3h/AZoZYbkOUzRgle+cG5oRvUGL/yK52z68MHUNSp Hqq7IcEFRxQtUpTKwT19Vu/Xk3D2Bkd5tZGTNeUQslo49YPETEv1FPz6t6+IU770GNTe CRAtrCZm07U+Tw+atTwSLL7CjpRZq6BedYMdYsrkgQuX/PK9s0HnuXWrGDxi4edlQLs4 lQyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc; bh=h9DJ/jKNl0F1H+PdwEMI8RmmqwmBRY2ywS4veqU5moE=; b=HXvHFK3+IGEMWeuLQ3TFlYgEXWZyEIAkveAeuT1GtrEnva4jsKQRS3LGL5q/b6kOLP Z0wb+ghQjE/VaYHR1zhJO9LPz/vq/GXgjNfLdfq6OG5fbysJNd7gPOPzHF9VYVtuUzdw wBBkwqZBwvdsRcVNo8D71+EYChfQEODpe1GZielKHQgaREGoABYTXat5tohBV+b5h+u9 hWuC8y3oI/o8lZsPYwq4VujASVjx+STOl6+DZYhYdOeUwV6z+b4qYO/BdyqEM6gZNIBs NotHGgNhn6F0KaICVYWtzwyK1NxorSJsp5/txMCfenygZ+MBydorf9StlMPqdsEyJDLB t8Cw== X-Gm-Message-State: AD7BkJJ7kIAw1u/ZQHmhhLnnsz8h6zeG1Qxyi2ys/QSKolXqsSNoRXq8axQivm7E7pedPFueklgMSExZEsjg1nhN MIME-Version: 1.0 X-Received: by 10.25.84.16 with SMTP id i16mr6925336lfb.88.1460311589243; Sun, 10 Apr 2016 11:06:29 -0700 (PDT) Received: by 10.112.200.74 with HTTP; Sun, 10 Apr 2016 11:06:29 -0700 (PDT) Received: by 10.112.200.74 with HTTP; Sun, 10 Apr 2016 11:06:29 -0700 (PDT) In-Reply-To: References: Date: Sun, 10 Apr 2016 12:06:29 -0600 Message-ID: From: Murad Kablan To: Jesper Wramberg Cc: users Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-users] How to change IP and port in packet header and recalculate checksum X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Murad.Kablan@Colorado.EDU List-Id: usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2016 18:06:29 -0000 I see what you are saying now. I tried your solution and it works. Thanks a lot! On Apr 9, 2016 12:41 PM, "Jesper Wramberg" wrote: > Assuming you are working on a standard Intel architecture or alike, the > constants you write are stored in little endian. > Network byte order is big endian, so for the UDP port (which is 16 bit > large) your code would be: > > udp_h->src_port = rte_cpu_to_be_16(88); > > Unless you actually want the port to be read as 22528 by the receiver ;-) > Check out the DPDK byte order API for your other constants. > > 2016-04-09 17:36 GMT+02:00 Murad Kablan : > >> Hi Jesper, >> I'm not running DPDK on the receiving side. Just tcpdump. >> Can you please be more specific? What and how to convert to network byte >> order? >> >> Thanks >> On Apr 9, 2016 7:45 AM, "Jesper Wramberg" >> wrote: >> >>> Hey Murad, >>> >>> Are you running DPDK on the receiving end as well ? >>> In any case, I'm guessing you forgot to convert to network byte order ? >>> :-) >>> >>> >>> >>> 2016-04-09 12:34 GMT+02:00 Murad Kablan : >>> >>>> Hi, >>>> I'm trying to change the IP and port of packets before sending them out. >>>> The captured packet in the receiving machines seems to be corrupted as >>>> the >>>> port is different than the one I inserted. Am I doing the checksum >>>> right? >>>> And do I need to do other HW configurations? >>>> >>>> This is my code: >>>> struct udp_hdr *udp_h; >>>> struct ipv4_hdr *ipv4_h; >>>> struct ether_hdr *eth_hdr; >>>> eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); >>>> ipv4_h = (struct ipv4_hdr *)(eth_hdr + 1); >>>> udp_h = (struct udp_hdr *)((unsigned char *)ipv4_h + sizeof(struct >>>> ipv4_hdr)); >>>> >>>> ipv4_h->dst_addr = 6777226 //(gateway-ip 10.77.0.51) >>>> udp_h->src_port = 88 >>>> ipv4_h->hdr_checksum = 0; >>>> udp_h->dgram_cksum = 0; >>>> udp_h->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_h, udp_h); >>>> ipv4_h->hdr_checksum = rte_ipv4_cksum(ipv4_h); >>>> l2fwd_simple_forward(m, 0); >>>> >>>> Thanks, >>>> >>>> Murad >>>> >>> >>> >