G
Guest
Hello,
I needed to write a ping tool with VB.NET. Since there are many examples on
how to create the neccessary ICMP paket, this was not so hard at the first
glance.
Then a strange error occured:
SOmetimes, my tool thought it was receiving a ping reply, though this cannot
be, because I used an impossible IP address for testing ... or the host was
unreachable from beginning and although, the ping received a reply.
I found out, that when the ping was waiting for a reply
(socket.receivefrom), actually *any* ICMP echo reply would be interpreted as
a reply, even if sent from a totally different host...
As a workaround, I checked the ICMP echo reply buffer and saw, that the IP
address of the replying host is within the buffer, so I took the Address,
parsed it into an IPAddress and checked for equality against the desired host
address to find out whether the reply came from the correct host.
Anyway ... I though, that the receivefrom method already makes sure, that
only echo replies from the correct hosts are received?
Any comments?
I needed to write a ping tool with VB.NET. Since there are many examples on
how to create the neccessary ICMP paket, this was not so hard at the first
glance.
Then a strange error occured:
SOmetimes, my tool thought it was receiving a ping reply, though this cannot
be, because I used an impossible IP address for testing ... or the host was
unreachable from beginning and although, the ping received a reply.
I found out, that when the ping was waiting for a reply
(socket.receivefrom), actually *any* ICMP echo reply would be interpreted as
a reply, even if sent from a totally different host...
As a workaround, I checked the ICMP echo reply buffer and saw, that the IP
address of the replying host is within the buffer, so I took the Address,
parsed it into an IPAddress and checked for equality against the desired host
address to find out whether the reply came from the correct host.
Anyway ... I though, that the receivefrom method already makes sure, that
only echo replies from the correct hosts are received?
Any comments?