title: Python Raw Socket cannot recieve ICMP messages; show up in Wireshark
body: <p>I am trying to implement a python traceroute that sends UDP messages and receives the ICMP responses via raw sockets. I've run into an issue where the ICMP packets seem to avoid capture at all cost. The ICMP responses show up in wireshark as exactly what I'd expect, but the socket never receives any data to read. Another complication is that I am running the code on VirtualBox running Ubuntu, as the sendto() would not get the packets on the wire in Windows 7. (I'm running wireshark in windows to capture the packets). The strange thing is that wireshark will capture the ICMP messages when I run the python script from the virtual machine. However, when I try to run the script on windows, the ICMP messages don't show up in wireshark. (The UDP packets have magically started working on windows)</p>
  
  <p>I've played around with all sorts of different versions of setting up the socket from online examples, and played around with using bind() and not using it, but no configuration seems to produce a socket that reads. It will just time out waiting to read the ICMP message.</p>
  
  <p>It should also be noted that if I try to read my udp sending socket, it successfully reads the udp packets. As soon as I set IPPROTO_ICMP the read times out.</p>
  
  <p>receive_response method:</p>
  
  <pre><code>def receive_response(rec_socket, packetid, tsend, timeout):
  remain = timeout
  print packetid
  while remain &gt; 0:
      ready = select.select([rec_socket], [], [], remain)
      if ready[0] == []:
          return
      print 'got something'
  </code></pre>
  
  <p>setting up the socket:</p>
  
  <pre><code>rec_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, ICMP_CODE)
  rec_socket.setsockopt(socket.SOL_IP, socket.IP_HDRINCL, 1)
  rec_socket.bind(("",0))      #played with using this statement and skipping it
  </code></pre>
  
  <p>call to receive is simply:</p>
  
  <pre><code>reached = receive_response(rec_socket, packetid, time.time(), timeout)
  </code></pre>