Python Forum
calculate data using 1 byte checksum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calculate data using 1 byte checksum
#1
hello,
it's not pure Python question but I did all the code except the last part , and I can't understand what to do :
this is what I need to do:


Quote:First, a 6-byte footprint is initialized to zero (00: 00: 00: 00: 00: 00).
The IEs of eachWi-Fi probe are analyzed.
Once the IEs of theWi-Fi probe are checked (avoiding using the ESSID, since it is always present and can be highly variable due to the
fact that the same device can ask for several networks in a small period of time), a mini footprint is calculated.
This mini footprint is a 1-byte value calculated as the checksum of the bytes contained in the analyzed IE.
For those IEs that present highly variable values between probes issued from the same device, e.g., IE_DS_PARAM or IR_EXT_CAP, the
mini footprint is calculated as the code of the IE itself (0x03 for IE_DS_PARAM, 0x7F for IE_EXT_CAP, etc.).
Sequentially, each time a mini footprint is obtained, its value is added
to that of the content of the next byte of the footprint, and the mask 0xFF is applied to it. If
the number of mini footprints is greater than 6, it begins again with the first element of the
footprint, and so on.


I wrote the all code except the last part of the checksum (can't see mto understand the logic of it)
this is an example

The sequence of IE codes 01:32:03:2D:7F:6B:DD
Length of each IE in hexadecimal 04:08:01:26:08:07:11
Values of each IE in hexadecimal 27:9E:06:86:C0:09:18

and from this I need to get this 6 byte mini footprint:
25:3E:12:FF:5D:4E


how to get this?
** I can only assume there is no mistake in the article I read

Thanks ,
Reply
#2
I think I found the document you are referencing.

https://www.researchgate.net/publication...lic_Spaces

I think your IE (Information Element) is missing content.

If length is 4, the content should be 4 bytes. For your example, your first IE should be:
01 04 XX XX XX XX where the XX is a content byte. I suppose it could be 01 04 00 00 00 27, but adding all the bytes doesn't give you a checksum of 25.

My guess is you are parsing the data incorrectly. First you need to read the IE code (1 byte) and the length (1 byte), then you need to read the number of bytes specified by the length. That will give you one IE. Add all the bytes together and use the last byte of the sum as the checksum.
Reply
#3
yes - ths is the document I have read and try to apply.

the problem is that (as you can see in the document) I don't have the full IE data ,just the "final" answer .
and I don't have any other example to work with.
this is why I didn't understand .

take a look of this datat I got from my phone after parsing:

id: 01 length: 8 data: 02040B16 sum value: 27
id: 32 length: 16 data: 0C1218243048606C sum value: 19E
id: 03 length: 2 data: 04 sum value: 4
id: 2d length: 52 data: 2D0113FF00000000000000000000000000000000000000000000 sum value: 140
id: bf length: 24 data: 12F99133FEFF8601FEFF8601 sum value: 6D7
id: dd length: 14 data: 0050F208002600 sum value: 170
id: ff length: 6 data: 020032 sum value: 34
id: 7f length: 20 data: 00000A02000000000001 sum value: D
id: dd length: 16 data: 8CFDF00101020100 sum value: 27E
so from what you are suggesting I should get this :
27:9E:04:40:D7:70:34:0D:7E (because I need to maks it to 0xFF)
then as the document say add location 7 to 1 8 to 2 9 to 3
27+34 = 5B
9E+0D = AB
04+7E = 82
so the final 6 byte footprint will be :
5B:AB:82:40:D7:70

is this correct?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  script to calculate data in csv-files ledgreve 0 1,104 May-19-2023, 07:24 AM
Last Post: ledgreve
  python Checksum No mg24 4 964 Nov-01-2022, 07:28 PM
Last Post: rob101
  How can I add certain elements in this 2d data structure and calculate a mean TheOddCircle 3 1,558 May-27-2022, 09:09 AM
Last Post: paul18fr
  'utf-8' codec can't decode byte 0xe2 in position 122031: invalid continuation byte tienttt 12 11,570 Sep-18-2020, 10:10 PM
Last Post: tienttt
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 8 31,711 Feb-08-2020, 06:58 PM
Last Post: karkas
  First Byte of a string is missing while receiving data over TCP Socket shahrukh1987 3 4,248 Nov-20-2019, 10:34 AM
Last Post: shahrukh1987
  Reading data from serial port as byte array vlad93 1 12,083 May-18-2019, 05:26 AM
Last Post: heiner55
  Read data of Wireless Modem in Byte Format barry76 2 2,645 Jan-31-2019, 11:26 AM
Last Post: barry76
  4 byte hex byte swap from binary file medievil 7 22,117 May-08-2018, 08:16 AM
Last Post: killerrex
  DB_ methods to calculate/manipulate data issac_n 0 2,269 Dec-26-2017, 07:03 AM
Last Post: issac_n

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020