Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2004

Tip: Looking for answers? Try searching our database.

ICMP socket reply from false host

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tronex - 24 Aug 2004 09:07 GMT
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?
Jochen Kalmbach - 24 Aug 2004 09:18 GMT
Hello =?Utf-8?B?VHJvbmV4?=,

> 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...

This is by design!
ICMP is not connection orientend and therefor you will receive every ICMP
reply!

Signature

Greetings
 Jochen

Tronex - 24 Aug 2004 09:47 GMT
> This is by design!
> ICMP is not connection orientend and therefor you will receive every ICMP
> reply!

Thanks!

I've got a question though:
As I wrote earlier, I am getting the IP Address from the reply buffer and
compare it with the source address, I am waiting to get an answer from. I
guess, this is the correct solution then. But I am not sure if the way I am
doing this is the best solution:

Dim strIPAddress As String = String.Format("{0}.{1}.{2}.{3}",
ReplyBuffer(12), ReplyBuffer(13), ReplyBuffer(14), ReplyBuffer(15))

srcIPAddress = System.Net.IPAddress.Parse(strIPAddress)

If srcIPAddress.Equals(dstIPAddress) Then
...
End If

1. Is there a better way to extract the IP Address out of the buffer?
2. Is it given, that the source IP Address is always encoded into the ICMP
echo reply buffer?

Greetings,
Tronex

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.