def find_layers(pkts, pcap):
  packet = OrderedDict()
  count = 1
  try:
    for p in pkts:
      header = {"Buffer": {"timestamp": datetime.datetime.fromtimestamp(p.time).strftime('%Y-%m-%d %H:%M:%S.%f'), "packetnumber": count, "pcapfile": pcap}}
      packet.update(header)  
      counter = 0
      while True:
        layer = p.getlayer(counter)
        if (layer != None):
          i = int(counter)
          x = p[0][i].fields
          t = exclude_layers(x, layer.name)
          s = rename_layer(t, layer.name)
          v = '{"' + layer.name.replace('.','_') + '[' + str(i) + ']' + '":' + str(s) + '}'
          s = eval(v)
          packet.update(s)
        else:
          break
        counter += 1
      count += 1
      yield packet
      packet.clear()
  except Exception as e:
    print RED + 'Error within packet: ' + str(count) + ', on layer: ' + layer.name + ' . The full error was: ' + str(e) + END
dataset/ETHPy150Open catalyst256/gobbler/gobbler/parsers/packetParser.py/find_layers/original