Browse Source

Include diff complement

master
Nico Schottelius 3 years ago
parent
commit
5a093cf0cf
  1. 10
      bin/checksum_delta_diff_test.py
  2. 4
      bin/send_udp_packet_v4.py
  3. 2
      p4src/checksum_diff.p4

10
bin/checksum_delta_diff_test.py

@ -149,9 +149,13 @@ if __name__ == '__main__':
# print("chk_t = {}".format(t))
e = Ether(src="02:53:55:42:45:01", dst='ff:ff:ff:ff:ff:ff')
i4 = IP(src = "192.168.1.1", dst = "192.168.4.2")
i6 = IPv6(src = "2001:db8:42::1", dst = "2001:db8::2")
e = Ether(src="00:00:0a:00:00:03", dst='00:00:0a:00:00:01')
i4 = IP(src = "10.0.0.1", dst = "10.1.1.1")
i6 = IPv6(src="2001:db8:1::a00:1", dst="2001:db8::1")
# e = Ether(src="02:53:55:42:45:01", dst='ff:ff:ff:ff:ff:ff')
# i4 = IP(src = "192.168.1.1", dst = "192.168.4.2")
# i6 = IPv6(src = "2001:db8:42::1", dst = "2001:db8::2")
i62 = IPv6(src = "2001:db8:42::2", dst = "2001:db8::2")
t = TCP(dport=80, sport=1337)
u = UDP(dport=80, sport=1337)

4
bin/send_udp_packet_v4.py

@ -3,6 +3,8 @@
import sys
from scapy.all import *
import checksum_from_scapy
if __name__ == '__main__':
iface = sys.argv[1]
@ -25,5 +27,7 @@ if __name__ == '__main__':
v6_rebuild = pkg_v6.__class__(str(pkg_v6))
print("v6: {} - {}".format(v6_rebuild.__repr__(), v6_rebuild[UDP].chksum))
checksum_from_scapy.checksum()
sendp(pkg, iface=iface, verbose=True)

2
p4src/checksum_diff.p4

@ -198,7 +198,7 @@ control MyIngress(inout headers hdr,
v6sum();
bit<16> diff = meta.v6sum - meta.v4sum;
# hdr.udp.checksum = hdr.udp.checksum + diff;
hdr.udp.checksum = diff;
hdr.udp.checksum = ~diff;
#else
meta.chk_udp_v6 = 1;

Loading…
Cancel
Save