The reason is that wireshark shows checksum error in received packets (I've 
built). in python prompt I 
tried:data=array.array('B',"example")arr=array.array('H', data)and the result 
was an array of bytes! modifying the code I don't receive any erroneous packets.
Is this my special casa or maybe a python issue?Thanks,
Ibrahim
Subject: Re: [nox-dev] FW: Checksum calculation bug?
From: jam...@nau.edu
Date: Wed, 24 Aug 2011 04:35:20 -0700
CC: nox-dev@noxrepo.org
To: ibrahim.me...@alumnos.upm.es



Do you have any reason to suspect that it isn't functioning correctly?
It seems like you are assuming that arr is an array of bytes.  However, if you 
look at the top of the function, you'll see that it's actually an array.array 
of "H" values, which are unsigned two-byte values.
-- Murphy
On Aug 24, 2011, at 4:19 AM, ibrahim mun wrote:Hi,

I think we have a bug in packet_utils.checksum, please check it:
=============================
def checksum(data, start, skip_word = 0):

    if len(data) % 2 != 0:
        arr = array.array('H', data[:-1])
    else:
        arr = array.array('H', data)

    if skip_word:
        for i in range(0, len(arr)):
            if i == skip_word:
                continue
            start +=  arr[i]
    else:        
       for i in range(0,len(arr)): # BUG?   
            start +=  arr[i]        # BUG? 
       # IT should be :
       # for i in range(0, len(arr)-1,2):
       # start +=  arr[i]*0x100 +arr[i+1]

    if len(data) % 2 != 0:
        start += struct.unpack('H', data[-1]+'\0')[0]

    start  = (start >> 16) + (start & 0xffff)
    start += (start >> 16);

    return ntohs(~start & 0xffff)
===============================

Thanks,

Ibrahim


_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

                                          
_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to