[P4-dev] udp checksum

Kentaro Ebisawa ebiken.g at gmail.com
Mon Oct 2 04:23:41 EDT 2017


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> <ebiken.g at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171002/0306d860/attachment-0002.html>


More information about the P4-dev mailing list