IP tracert

  • Thread starter Thread starter Just D.
  • Start date Start date
J

Just D.

We all know that we can use TRACERT as a standalone application in Windows
to get a whole way of IP nodes to go through. I need to implement almost
same feature from my own application. What's the easiest way to do that? The
idea is to enter the remote address or URL and call some method to get a
full trace between two machines in the form like:

111.111.111;222.222.222;333.333.333

Is it already done by somebody or maybe we have some standard way for that?

Just D.
 
Well, first of all, it's not as simple as it seems on the face. The first
thing you want to do is read RFC 792
(ftp://ftp.rfc-editor.org/in-notes/rfc792.txt) "Internet Control Message
Protocol" (a.k.a. ICMP).

I don't say that to be glib or to send you off on some needless reading. You
won't find much existing code to do anything like a tracert. The code I have
seen to do pings (which are very similar), are horribly written. There may
be some good ones out there, but I haven't seen them.

A ping works by sending an ICMP echo packet. The destination returns an ICMP
echo reply message.

A traceroute works on the same principal except what it does is starts with
a TTL value of 1 (TTL=Time to Live). The TTL is decremented at each hop.
When it reaches 0, the host that decremented it to 0 sends an ICMP time
exceeded message, I believe.

Anyway, what you do is send the first packet. The host at the first hop will
return an ICMP time exceeded message. You'll be able to determine their IP
address from the message. Then you increment the TTL by 1 and ping again.
The host at the second hope will return an ICMP time exceeded message. And
you continue increasing the TTL by 1 until you actually reach the
destination.

While sending echo messages isn't rocket science, it's not entirely trivial
either. Do a google search for C# and ping and you'll find some samples.
Like I said, the ones I've seen are not well written, but that should at
least give you some ideas on how to assemble the packets.

Pete
 
Hi Pete,

Thanks for your answer. You know maybe there is an additional way to do
that, I'm not sure yet, but... I know that when we write ASPX page it works
inside some IIS Web App and we can send a request to the remote browser to
return back the HostName, Remote user name, IP address, etc. It always
returns back the correct IP address even if the remote user works at the
remote LAN, the browser returns back the public IP address which is
required. When we use a Web Service we can't send the same request, it
doesn't work. All we can do is to use a remote Windows Application, but it
returns the LAN address, not the public address. I'm trying to solve this
problem in a few different ways including the way like I asked about. I also
know that even the port 80 is unblocked all other ports can be blocked and
we can't use tracert or ping, it will be operational. I'm not sure what can
we do in this case. If we can use some kind of detection of remote LAN
parameters, maybe DNS server IP/Name, whatever. I'm looking for this IP and
other parameters of the remote network and machine itself to log the remote
user which wants to get some information from our server. It should be done
for HIPAA and not discussible. But I realize that sometimes it's not very
easy to get a correct parameter that we need. I don't discuss the case when
the remote user works via anonymizer or via the system like that, these
connections can be restricted. All users will know that we're logging this
info for their own security. The question is to get this info using any
possible way, maybe the remote Windows Application is a more preferable way
for that.

Do you have any idea how to get the right parameters from the remote
machine? Since it's using Web Service the remote app is C# or at least a
COM+ component written in C# and using the Web Access.

Just D.
 
Back
Top