jasonbstubbs
Newcomer
Raw sockets corrupting IP headers (SOLVED)
I'm listening for ICMP packets using the following method to capture packets. I'm also running a packet sniffer to see what goes in and out of the box.
However, what I'm finding is that some of the values in the IP header returned differ from what the sniffer is showing. Specifically, the TTL is different.
Does anybody know what could be causing this? Even better, does anybody know how to prevent this?
I'm listening for ICMP packets using the following method to capture packets. I'm also running a packet sniffer to see what goes in and out of the box.
C#:
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 100);
socket.Bind((EndPoint)new IPEndPoint(System.Net.IPAddress.Any, 0));
byte[] buffer = new byte[2000];
IPEndPoint ipendpoint = new IPEndPoint(System.Net.IPAddress.Any, 0);
EndPoint endpoint = (EndPoint)ipendpoint;
socket.ReceiveFrom(buffer, buffer.Length, SocketFlags.Peek, ref endpoint);
However, what I'm finding is that some of the values in the IP header returned differ from what the sniffer is showing. Specifically, the TTL is different.
Does anybody know what could be causing this? Even better, does anybody know how to prevent this?
Last edited: