开发者

how i can trace an IP using delphi

i need trace the route of an ip, actually i am using the TIdTraceRoute indy component from the idTraceRoute unit.

   IdTraceRoute1:= TIdTraceRoute.Create(Self);
   IdTraceRoute1.ResolveHostNames:= True;
   IdTraceRoute1.ReceiveTimeout:= 5000;
   IdTraceRoute1.OnReply:= TraceRoute;

    IdTraceRoute1.Host:= 'www.google.com';
    IdTraceRoute1.Trace;


procedure TForm1.TraceRoute(ASender: TComponent;
  const AReplyStatus: TReplyStatus);
begin
   Memo1.Lines.开发者_StackOverflowAdd(AReplyStatus.FromIpAddress);
end;

but always return.

0.0.0.0
0.0.0.0
0.0.0.0
0.0.0.0
0.0.0.0
0.0.0.0

exist another way of trace an ip maybe using windows api or using another indy component?

actually i am using delphi-xe and Windows 7.


I just wrote a entry on my blog, wich can help you.

Building a traceroute application with IP geolocation using delphi


Trace is basically based on sending ICMP packets starting with a TTL of 1 and increasing it until reaching the destination. Because each router decrease the TTL, and when it reaches 0 an error is returned to the caller, it can be used to track the "route" packets takes. Note that to work the ICMP protocol must not be stopped by a firewall. ICMP is a protocol that runs atop IP, like TCP does. It doesn't use TCP. You could code a traceroute utility just using ICMP. But does the Windows tracert utility work on your system?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜