title: Why can't I send this IP packet?
body: <p>I'm trying to send an IP packet using c#.</p>
  
  <pre><code>    destAddress = IPAddress.Parse("192.168.0.198"),
      destPort = 80;
  
      // Create a raw socket to send this packet
      rawSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
  
      // Bind the socket to the interface specified
      IPEndPoint iep = new IPEndPoint(IPAddress.Parse("192.168.0.140"),0);
      rawSocket.Bind(iep);
  
      // Set the HeaderIncluded option since we include the IP header
      rawSocket.SetSocketOption( socketLevel, SocketOptionName.HeaderIncluded, 1 );
  
      // Send the packet!
      int rc = rawSocket.SendTo(builtPacket, new IPEndPoint(destAddress, destPort));
      Console.WriteLine("sent {0} bytes to {1}", rc, destAddress.ToString());
  </code></pre>
  
  <p>The content of builtPacket is shown below. It's an IP packet containing a TCP SYN packet (That's what I think I created anyway).</p>
  
  <p>45 00 00 28 00 00 00 00 02 06 36 6E C0 A8 00 8C</p>
  
  <p>C0 A8 00 C6 14 1E 00 50 00 00 00 00 00 00 00 00</p>
  
  <p>05 02 FF FF E6 4F 00 00</p>
  
  <p>The output is:</p>
  
  <pre><code>sent 40 bytes to 192.168.0.198
  </code></pre>
  
  <p>The problem is I don't see anything in the Wireshark trace. It's like the data is not getting far enough down the stack for Wireshark to see it? If I use a browser to connect to 192.168.0.198, Wireshark shows all the packets, but shows nothing when I try to send a packet using the above code and data. </p>
  
  <p>My config:</p>
  
  <ul>
  <li><p>I am running as admin so it's not a permissions problem. </p></li>
  <li><p>Windows7 ( Not running in a VM)</p></li>
  <li><p>Wireless connection only (IP config reports its IP as 192.168.0.140)</p></li>
  </ul>
  
  <p>What am I doing wrong?</p>
  
  <p>I'm sure Occam's Razor applies here, but I've been looking at this for hours and can't figure out what's wrong.</p>