I am studying a program that my instructor gave me for my Networking class. It is suppose to Ping a server using ICMP. However the program isn't working. I've run it with WireShark and it says that the checksum byte is not returning correctly. Apparently this works for my other classmates but not for me. And for those who might says "ask your professor" I have been trying to ask him about it for a while now but I haven't been able to meet with him yet. Here is the function that implements the checksum.
def checksum(string):
csum = 0
countTo = (len(string) // 2) *2
count = 0
while count < countTo:
thisVal = ord(strin[count+1]) *256 + ord(string[count])
csum = csum + this Val
csum = csum & 0xffffffff
count = count +2
if coutnTo < len(string):
csum = csum = ord(string[len(string) -1])
csum = csum & 0xffffffff
csum = (csumm >> 16) + (csum & 0xffff)
csum = csum + (csum >>16)
answer = ~csum
answer = answer & 0xffff
answer = answer >> 8 | (answer << 8 & 0xff00)
return answer
I should also mention that to create the string argument he uses struct.pack like so:
header = struct.pack("bbHHh", ICMP_ECHO_REQUEST,0,0, ID,1)
data = struct.pack("d",time.time())
checksum(str(header+data))
I am also running this in a Kali Vm if it matters.
User contributions licensed under CC BY-SA 3.0