This is my code to calculate the checksum manually using RFC 1071:
from scapy.all import *
data = IP(src='192.168.1.34', dst='192.168.1.1')
convert_packet_bytes = bytes(data)
mylst = []
for start,end in zip(convert_packet_bytes[0::1], convert_packet_bytes[2::1]):
multi = start*256+end
mylst.append(multi)
print(sum(mylst) % 65535)
my_code_result = 64954
And this calculates the checksum using Scapy's show2
:
from scapy.all import *
ip_packet = IP(src='192.168.1.34', dst='192.168.1.1')
ip_packet .show2()
scapy_result : 63349
In the first code i am trying to implement a checksum calcolator
using rfc 1071
in python to calculate the checksum
for the ip protocol in scapy
and in the second code i am using the scapy's show2
function to calculate the ip checksum
and compare it with my own implementation of checksum
in the first code using rfc 1071
but the problem is the first checksum code result which is my code is 64954
and the second checksum code which is from the scapy's show2
function is 63349
they are not the same i am trying to get the same result by implementing the rfc 1071
in python