title: How can get last index in Scapy packet?
body: <p>I am using Scapy to craft and sniff packets. I am trying to get last payload index of the sniffing packet. For example:</p>
  
  <pre><code>p=IPv6()/UDP()/DHCPv6_Solicit()
  </code></pre>
  
  <p>DHPCv6_Solicit() will be the last payload and the index for it is 2</p>
  
  <pre><code>p[2] #print DHCPv6_Solicit() object
  </code></pre>
  
  <p>I tried to get the last index by using -1 but the Scapy gave me this error</p>
  
  <pre><code>Traceback (most recent call last):
     File "/usr/lib/python3.5/code.py", line 91, in runcode
     exec(code, self.locals)
     File "&lt;console&gt;", line 1, in &lt;module&gt;
     File "/usr/local/lib/python3.5/dist-packages/scapy/packet.py", line 966, in __getitem__
     raise IndexError("Layer [%s] not found" % lname)
  IndexError: Layer [-1] not found
  </code></pre>
  
  <p>I tried to get length of the array by using</p>
  
  <pre><code>len(p2)
  </code></pre>
  
  <p>but Scapy showed the length of the packet in bytes
  So how can I find the last payload index of the Scapy packet?</p>