Use UDP for testing checksums
This commit is contained in:
parent
2ed8282687
commit
b757a3c2b0
3 changed files with 39 additions and 50 deletions
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#from __future__ import unicode_literals
|
||||
from scapy.all import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -8,39 +9,52 @@ if __name__ == '__main__':
|
|||
e0 = Ether(src="00:00:00:00:00:00",
|
||||
dst="00:00:00:00:00:00")
|
||||
|
||||
e = Ether(src="02:53:55:42:45:01",
|
||||
dst='ff:ff:ff:ff:ff:ff')
|
||||
|
||||
i0 = IP(src = "0.0.0.0",
|
||||
dst = "0.0.0.0")
|
||||
|
||||
i4 = IP(src = "192.168.1.1",
|
||||
dst = "192.168.4.2")
|
||||
|
||||
i6 = IPv6(src = "2001:db8:42::1",
|
||||
dst = "2001:db8::2")
|
||||
|
||||
t0 = TCP(dport=0, sport=0)
|
||||
#t = TCP(dport=80, sport=random.randint(49152,65535))
|
||||
|
||||
# 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")
|
||||
i62 = IPv6(src = "2001:db8:42::2", dst = "2001:db8::2")
|
||||
t = TCP(dport=80, sport=1337)
|
||||
u = UDP(dport=80, sport=1337)
|
||||
|
||||
#print("chk_t = {}".format(t))
|
||||
|
||||
d0 = ""
|
||||
d = "A"
|
||||
|
||||
p.append(e / i4 / t / d)
|
||||
p.append(e / i6 / t / d)
|
||||
p.append(e / i4 / u / d)
|
||||
p.append(e / i6 / u / d)
|
||||
p.append(e / i62 / u / d)
|
||||
|
||||
for packet in p:
|
||||
print("p = {}".format(packet.__repr__()))
|
||||
packet_rebuild = packet.__class__(str(packet))
|
||||
chk_old = packet[TCP].chksum
|
||||
chk_new = packet_rebuild[TCP].chksum
|
||||
print("rebuild = {}".format(packet_rebuild.__repr__()))
|
||||
chk_old = packet[UDP].chksum
|
||||
chk_new = packet_rebuild[UDP].chksum
|
||||
print("chk1 = {} chk2={}".format(chk_old, chk_new))
|
||||
|
||||
# Get diffs -- for UDP
|
||||
# udp_v4 =
|
||||
# hdr.ipv4.src_addr,
|
||||
# hdr.ipv4.dst_addr,
|
||||
# 8w0,
|
||||
# hdr.ipv4.protocol,
|
||||
# meta.length_without_ip_header,
|
||||
|
||||
# // UDP header
|
||||
# hdr.udp.src_port,
|
||||
# hdr.udp.dst_port,
|
||||
# hdr.udp.payload_length
|
||||
|
||||
|
||||
# Checksums:
|
||||
# - tcp
|
||||
# - udp
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from scapy.all import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
p = []
|
||||
|
||||
e0 = Ether(src="00:00:00:00:00:00",
|
||||
dst="00:00:00:00:00:00")
|
||||
|
||||
e = Ether(src="02:53:55:42:45:01",
|
||||
dst='ff:ff:ff:ff:ff:ff')
|
||||
|
||||
i0 = IP(src = "0.0.0.0",
|
||||
dst = "0.0.0.0")
|
||||
|
||||
i4 = IP(src = "192.168.1.1",
|
||||
dst = "192.168.4.2")
|
||||
|
||||
i6 = IPv6(src = "2001:db8:42::1",
|
||||
dst = "2001:db8::2")
|
||||
|
||||
t0 = TCP(dport=0, sport=0)
|
||||
t = TCP(dport=80, sport=random.randint(49152,65535))
|
||||
|
||||
d0 = ""
|
||||
d = "A"
|
||||
|
||||
p.append(e0 / i0 / t0 / d0)
|
||||
p.append(e / i4 / t / d)
|
||||
# p.append(e / i6 / t / d)
|
||||
|
||||
for test in p:
|
||||
print("p = {}".format(test.__repr__())!)
|
||||
packet_raw = str(test)
|
||||
checksum_scapy = IP(packet_raw)[TCP].chksum
|
||||
print("chk = {}".format(checksum_scapy))
|
12
doc/plan.org
12
doc/plan.org
|
@ -3198,6 +3198,18 @@ ERROR: failed to convert p.ethernet.dstAddr of type <type 'str'> to an integer
|
|||
**** TODO Explore PX
|
||||
*** TODO Integrate nat64 code into netfpga
|
||||
**** figure out how to do ANY checksums
|
||||
** Diff / Delta based checksums
|
||||
*** create test case / test theory
|
||||
**** TODO try first v6/v6
|
||||
**** using python/struct
|
||||
***** find right byte orders
|
||||
**** using python/scapy
|
||||
#+BEGIN_CENTER
|
||||
|
||||
#+END_CENTER
|
||||
**** using p4
|
||||
|
||||
**** using p4/netpfga
|
||||
** NAT64/NAT46 Features in jool and tayga
|
||||
*** TODO Static 1:1 NAT46: translate from IPv4 to IPv6 with a table
|
||||
**** TODO TCP
|
||||
|
|
Loading…
Reference in a new issue