[P4-dev] udp checksum

Dingyuan Hu h-dy at outlook.com
Mon Oct 23 21:24:45 EDT 2017


Hi all,
I have the same question.
And I use P4_16, so there is no `payload` keyword.
How can I calculate UDP checksum for IPv6? It can’t be ignored.

Thanks,
Dingyuan Hu

From: P4-dev [mailto:p4-dev-bounces at lists.p4.org] On Behalf Of Kentaro Ebisawa
Sent: Monday, 2 October 2017 4:24 PM
To: p4-dev <p4-dev at lists.p4.org>
Subject: [P4-dev] udp checksum

Hi,

Is there any example code to calculate udp checksum?
I went through examples under https://github.com/p4lang/tutorials but could not find one.

BTW, I wrote with below P4-14 code but checksum wasn't calculated correctly.
Also, p4c shown warning for 8'0. Could it be related? (Assuming not but ...)

* Warning:
p4can.p4:84:6: warning: missing terminating ' character
     8'0;
      ^

* UDP Checksum code I tried with.
field_list udp_checksum_list {
    // IPv4 Pseudo Header Format. Must modify for IPv6 support.
    ipv4.srcAddr;
    ipv4.dstAddr;
    8'0;
    ipv4.protocol;
    udp.length_;
    udp.srcPort;
    udp.dstPort;
    udp.length_;
    // udp.checksum;
    payload;
}
field_list_calculation udp_checksum {
    input {
        udp_checksum_list;
    }
    algorithm : csum16;
    output_width : 16;
}
calculated_field udp.checksum {
    verify udp_checksum;
    update udp_checksum;
}


--
Kentaro Ebisawa <ebiken.g at gmail.com><mailto:ebiken.g at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171024/59900b8c/attachment-0002.html>


More information about the P4-dev mailing list