1*9c5db199SXin Lifrom os import path 2*9c5db199SXin Li 3*9c5db199SXin Ligolden_sequences = [['0x04', '0x05', '0x0b', '0x00', '0x01', '0x0c'], 4*9c5db199SXin Li ['0x04', '0x05', '0x0b', '0x01', '0x0c']] 5*9c5db199SXin Li 6*9c5db199SXin Lipcap_filepath = '/tmp/filtered_pcap' 7*9c5db199SXin Liif not path.exists(pcap_filepath): 8*9c5db199SXin Li print('Could not find output file. Follow the steps in section 5 of ' + 9*9c5db199SXin Li 'the codelab to generate a pcap output file.') 10*9c5db199SXin Li exit() 11*9c5db199SXin Lipcap_file = open(pcap_filepath, 'r') 12*9c5db199SXin Li 13*9c5db199SXin Lifor line in pcap_file: 14*9c5db199SXin Li packet_type = line[0:4] 15*9c5db199SXin Li if not packet_type.startswith('0x0'): 16*9c5db199SXin Li print('Failure: Non-connection packet of type ' + packet_type + 17*9c5db199SXin Li ' included in output.') 18*9c5db199SXin Li exit() 19*9c5db199SXin Li for sequence in golden_sequences: 20*9c5db199SXin Li if sequence[0] == packet_type: 21*9c5db199SXin Li sequence.pop(0) 22*9c5db199SXin Li if len(sequence) == 0: 23*9c5db199SXin Li print('Success: The full connection sequence was included in ' + 24*9c5db199SXin Li 'your output!') 25*9c5db199SXin Li exit() 26*9c5db199SXin Lipcap_file.close() 27*9c5db199SXin Li 28*9c5db199SXin Liprint('Failure: Your output file did not include the full connection ' + 29*9c5db199SXin Li 'sequence. You may need to add more packet types to your filter.') 30*9c5db199SXin Liexit()