DPDK usage discussions
 help / color / mirror / Atom feed
From: Jesper Wramberg <jesper.wramberg@gmail.com>
To: Murad.Kablan@colorado.edu
Cc: users <users@dpdk.org>
Subject: Re: [dpdk-users] How to change IP and port in packet header and recalculate checksum
Date: Sat, 9 Apr 2016 15:45:19 +0200	[thread overview]
Message-ID: <CALhSPovX8C6TsD64cCVG4KbR4A22P6Te4d1AK0dNgS0u8CviLg@mail.gmail.com> (raw)
In-Reply-To: <CAMp4E=8=yFswHdRCEmsQLqPZhrdr5xarMRbcZO9G+3WoEzJE1Q@mail.gmail.com>

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 <Murad.Kablan@colorado.edu>:

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

  reply	other threads:[~2016-04-09 13:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-09 10:34 Murad Kablan
2016-04-09 13:45 ` Jesper Wramberg [this message]
2016-04-09 15:36   ` Murad Kablan
2016-04-09 18:41     ` Jesper Wramberg
2016-04-10 18:06       ` Murad Kablan

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=CALhSPovX8C6TsD64cCVG4KbR4A22P6Te4d1AK0dNgS0u8CviLg@mail.gmail.com \
    --to=jesper.wramberg@gmail.com \
    --cc=Murad.Kablan@colorado.edu \
    --cc=users@dpdk.org \
    /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).