Hi, I’m trying to calculate UDP checksum with QUIC header using update_checksum_with_payload
.
However, the checksum computed is incorrect.
Here is my declaration of relevant headers:
header udp_t {
bit<16> srcPort;
bit<16> dstPort;
bit<16> length_;
bit<16> checksum;
}
header udpQuic_t {
bit<1> hdr_type;
bit<1> fixed;
bit<2> pkt_type;
bit<4> version;
}
header quicLong_t{
bit<32> version;
bit<8> dcid_length;
bit<8> dcid_first_byte;
bit<8> app_idx;
bit<48> cookie;
bit<8> scid_length;
bit<64> src_cid;
}
header quicShort_t{
bit<8> dcid_first_byte;
bit<16> cookie;
bit<40> dcid_residue;
}
and here is my checksum computation:
update_checksum_with_payload((hdr.udp.isValid() && !hdr.udpQuic.isValid()),
{ hdr.ipv4.srcAddr,
hdr.ipv4.dstAddr,
8w0,
hdr.ipv4.protocol,
meta.l4Len,
hdr.udp.srcPort,
hdr.udp.dstPort,
hdr.udp.length_,
16w0
},
hdr.udp.checksum, HashAlgorithm.csum16);
update_checksum_with_payload(hdr.quicLong.isValid(),
{ hdr.ipv4.srcAddr,
hdr.ipv4.dstAddr,
8w0,
hdr.ipv4.protocol,
meta.l4Len,
hdr.udp.srcPort,
hdr.udp.dstPort,
hdr.udp.length_,
16w0,
hdr.udpQuic.hdr_type,
hdr.udpQuic.fixed,
hdr.udpQuic.pkt_type,
hdr.udpQuic.version,
hdr.quicLong.version,
hdr.quicLong.dcid_length,
hdr.quicLong.dcid_first_byte,
hdr.quicLong.app_idx,
hdr.quicLong.cookie,
hdr.quicLong.scid_length,
hdr.quicLong.src_cid
},
hdr.udp.checksum, HashAlgorithm.csum16);
update_checksum_with_payload(hdr.quicShort.isValid(),
{ hdr.ipv4.srcAddr,
hdr.ipv4.dstAddr,
8w0,
hdr.ipv4.protocol,
meta.l4Len,
hdr.udp.srcPort,
hdr.udp.dstPort,
hdr.udp.length_,
16w0,
hdr.udpQuic.hdr_type,
hdr.udpQuic.fixed,
hdr.udpQuic.pkt_type,
hdr.udpQuic.version,
hdr.quicShort.dcid_first_byte,
hdr.quicShort.cookie,
hdr.quicShort.dcid_residue
},
hdr.udp.checksum, HashAlgorithm.csum16);
}
Any advice would be appreciated.