How can i get Ethernet Header in C#?
<p>I am using the following C# code for getting network packets.</p>

<pre><code>int len_receive_buf = 4096;
int len_send_buf = 4096;
byte[] receive_buf = new byte[len_receive_buf];
byte[] send_buf = new byte[len_send_buf];
int cout_receive_bytes;
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
socket.Blocking = false;
IPHostEntry IPHost = Dns.GetHostByName(Dns.GetHostName());
socket.Bind(new IPEndPoint(IPAddress.Parse(IPHost.AddressList[0].ToString()), 0));
socket.SetSocketOption(SocketOptionLevel.IP , SocketOptionName.HeaderIncluded, 1);

byte []IN = new byte[4]{1, 0, 0, 0};
byte []OUT = new byte[4];            
int ret_code = socket.IOControl(IOControlCode.ReceiveAll, IN, OUT);           
while (true)
{
    IAsyncResult ar = socket.BeginReceive(receive_buf, 0, len_receive_buf, SocketFlags.None, null, this);
    cout_receive_bytes = socket.EndReceive(ar);
    Receive(receive_buf, cout_receive_bytes, countPckts);
}
</code></pre>

<p>I get network packets too which are starting from 'IP Header'. But I need network packets including 'Frame Header'/'Ethernet Header'. Where i must need to have the Ethernet header portion too.</p>

<p>Please help me, how can i get network packet including 'Ethernet Header' in C#.</p>
