jasonbstubbs
Member
Raw sockets corrupting IP headers (SOLVED)
Im listening for ICMP packets using the following method to capture packets. Im also running a packet sniffer to see what goes in and out of the box.
However, what Im 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?
Im listening for ICMP packets using the following method to capture packets. Im 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 Im 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 by a moderator: