hello ,
I have a long string of data the (80211 frame - if its help) and I want to cut it to pieces according to this logic:
first byte is the TAG
second byte is the lenght
then data length is acoording to the second byte
this is what I have done , is there a way yo make it cleaner?
Thanks,
I have a long string of data the (80211 frame - if its help) and I want to cut it to pieces according to this logic:
first byte is the TAG
second byte is the lenght
then data length is acoording to the second byte
this is what I have done , is there a way yo make it cleaner?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
IE_Data = 010402040b1632080102030405060708 start = 0 BYTE_SIZE = 2 for i in range (start, len (IE_Data)): Tag_ID = IE_Data[start:start + BYTE_SIZE] length = IE_Data[start + BYTE_SIZE: start + BYTE_SIZE + BYTE_SIZE] length_int = int (length, 16 ) * 2 data = IE_Data[start + 4 :start + 4 + length_int] data_length = len (data) start = start + 4 + data_length print ( "id - " + Tag_ID, "\n\rlength - " + length, "\n\rdata - " + data ) ) |