title: Sending UDP packets with gopacket
body: <p>I am trying to send UDP packets to a remote host like this</p>
  
  <pre><code>conn, err := net.ListenPacket("ip4:udp", "0.0.0.0")
  if err != nil {
      panic(err)
  }
  ip := &amp;layers.IPv4{
      SrcIP:    saddr,
      DstIP:    dip,
      Protocol: layers.IPProtocolUDP,
  }
  udp := &amp;layers.UDP{
      SrcPort: layers.UDPPort(sport),
      DstPort: layers.UDPPort(us.Port),
  }
  udp.SetNetworkLayerForChecksum(ip)
  buf := gopacket.NewSerializeBuffer()
  opts := gopacket.SerializeOptions{
      ComputeChecksums: true,
      FixLengths:       true,
  }
  if err := gopacket.SerializeLayers(buf, opts, udp); err != nil {
      fmt.Printf("%v", err)
  }
  if _, err := us.Conn.WriteTo(buf.Bytes(), &amp;net.IPAddr{IP: dip}); err != nil {
      panic(err)
  }
  
  // reading
  for {
      buf2 := make([]byte, 4096)
      n, addr, err := us.Conn.ReadFrom(buf2)
      if err != nil {
          fmt.Printf("%v", err)
      }
      if addr.String() == dip.String() {
          fmt.Printf("Got a reply")
      }
  }
  </code></pre>
  
  <p>But this keeps erring out while reading packets with <code>read ip4 0.0.0.0: i/o timeout</code>. When I tcpdump, I see packets being sent out and one UDP response coming back on port 53 others are all ICMP. Why can't my code read those packets?</p>