title: Parse PCAP files for IGMPv3 packets with scapy
body: <p>I'm attempting to parse IGMPv3 packets with the RawPcapReader in scapy. For some reason unbeknownst to me it's not detecting the IGMP layer:</p>
  <pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python3
  
  import argparse
  import os.path
  import sys
  
  from scapy.contrib.igmpv3 import IGMPv3
  from scapy.utils import RawPcapReader
  from scapy.layers.l2 import CookedLinux
  from scapy.layers.inet import IP
  
  
  def pcap_parser(pcap_file):
      for (pkt_data, pkt_metadata) in RawPcapReader(pcap_file):
  
          ether_pkt = CookedLinux(pkt_data)
          if ether_pkt.proto != 0x800:
              # Ignore non-ip packets.
              continue
  
          ip_pkt = ether_pkt[IP]
          ip_proto = ip_pkt.fields['proto']
          if ip_proto == 2:
              igmp_pkt = ip_pkt[IGMPv3]
  
  
  def _command_line_args():
      parser = argparse.ArgumentParser()
      parser.add_argument('--pcap', metavar='&lt;input pcap file&gt;', help='pcap file to parse', required=True)
      args = parser.parse_args()
      return args
  
  
  def main():
      args = _command_line_args()
  
      if not os.path.exists(args.pcap):
          print(f'Input pcap file &quot;{args.pcap}&quot; does not exist', file=sys.stderr)
          sys.exit(-1)
  
      pcap_parser(args.pcap)
  
  
  if __name__ == '__main__':
      main()
  
  </code></pre>
  <p>I get a <strong>IndexError: Layer [IGMPv3] not found</strong> error, despite the packets being detected in Wireshark:</p>
  <p><a href="https://i.stack.imgur.com/qfRAj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qfRAj.png" alt="wireshark screenshot" /></a></p>