[dpdk-users] How to change IP and port in packet header and recalculate checksum

Murad Kablan Murad.Kablan at Colorado.EDU
Sat Apr 9 12:34:37 CEST 2016


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


More information about the users mailing list