-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser_ACK_Req_special_case.py
73 lines (58 loc) · 6.86 KB
/
Parser_ACK_Req_special_case.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from SCHCPParserTool.parser import SCHCParser
import binascii
parser = SCHCParser()
#parser.rule_file = "lorawan.json"
#parser.rm.Add(file=parser.rule_file)
#parser.rm.Print() # To Check the Rule
# We add a DevEUI and AppSKey to the parser object:
DevEUI = '1122334455667788'
AppSKey = '00AABBCCDDEEFF00AABBCCDDEEFFAABB'
parser.changeDevEUI (DevEUI=DevEUI)
parser.changeAppSKey (AppSKey=AppSKey)
first_frag = binascii.unhexlify("143e1660000000029211fffe8000000000000079cd89438f0cc118fe8000000000000000000000000000015c40307002921de10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
second_frag = binascii.unhexlify("1426000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
third_frag = binascii.unhexlify("140e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
last_all1 = binascii.unhexlify("147ff32d996a000000000000000000")
print(len(first_frag)+len(second_frag)+len(third_frag))
#3e1660000000029211fffe8000000000000079cd89438f0cc118fe8000000000000000000000000000015c40307002921de10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#26000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
schc_parsed_01 = SCHCParser.parse_schc_msg(parser, schc_pkt=first_frag)
#print(schc_parsed_01)
schc_parsed_02 = SCHCParser.parse_schc_msg(parser, schc_pkt=second_frag)
#print(schc_parsed_02)
schc_parsed_03 = SCHCParser.parse_schc_msg(parser, schc_pkt=third_frag)
print(schc_parsed_03)
schc_parsed_all1 = SCHCParser.parse_schc_msg(parser, schc_pkt=last_all1)
#print(schc_parsed_all1_only)
ack = SCHCParser.reassembly(parser, fragment = schc_parsed_01, tiles_all1 = True)
print(ack)
ack = SCHCParser.reassembly(parser, fragment = schc_parsed_02, tiles_all1 = True)
print(ack)
#ack = SCHCParser.reassembly(parser, fragment = schc_parsed_03, tiles_all1 = True)
#print(ack)
print(parser.bitmap)
ack = SCHCParser.reassembly(parser, fragment = schc_parsed_all1, tiles_all1 = True)
#ack = SCHCParser.reassembly(parser, fragment = ack_req_parsed0, tiles_all1 = False)
print(ack)
# DUT should reply with:
rec1_frag = binascii.unhexlify("140e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
rec1_frag_parsed = SCHCParser.parse_schc_msg(parser, schc_pkt=rec1_frag)
print("rec1_frag_parsed", rec1_frag_parsed)
# We create another ACK to get the tiles missing for the second window w=1
ack = SCHCParser.reassembly(parser, fragment = rec1_frag_parsed, tiles_all1 = True)
print(parser.bitmap)
print(ack)
# The DUT replies with this: FCN =62, W=1
rec2_frag = binascii.unhexlify("147e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
rec2_frag_parsed = SCHCParser.parse_schc_msg(parser, schc_pkt=rec2_frag)
print("rec2_frag_parsed", rec2_frag_parsed)
ack = SCHCParser.reassembly(parser, fragment = rec2_frag_parsed, tiles_all1 = True)
print(parser.bitmap)
print(ack)
# Add case for W = 01 and all1 true for ack request
#fullpkt = binascii.unhexlify("1660000000029211fffe80000000000000a06e66666470e5a1fe8000000000000000000000000000015c403070029220300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
#print("deux", bitmap)
#print("lenn",len(full_pkt))
#full_pkt_pars = SCHCParser.parse_schc_msg(parser, schc_pkt=full_pkt)
#print(full_pkt_pars)