Currently trying to implement a simple ping program to teach myself about network programming in C# and .NET.
I have managed to initialize a raw socket and correctly build an ICMP echo request packet. When running my program, Wireshark confirms that I am sending an Echo Request to the desired destination, however the remote machine will never send back an echo reply. I have tried sending to multiple machines all with the same result (and each of these machines can be pinged using the Windows ping utility). My code goes like this:
IcmpPacket echoReq = new IcmpPacket;
/*Some code to initialize packet*/
rawSocket.Send(echoReq, destinationIP); //syntax may be wrong, dont have the code infront of me sorry
rawSocket.ReceiveFrom(buffer, remoteEndpoint);
If anyone could suggest any reasons why the remote machines do not send any reply, I'd be very grateful.
It's hard to know for sure from the information in your question. There are just too many things that can go wrong. But here are a few that I would start checking through.
destinationIP
and remoteEndpoint
values could point to different addresses. Seems unlikely but wanted to call it out