How can I Trace Route using TIdTraceRoute from Indy?

140 views Asked by At

Whenever I try to Trace the route of a Host, then I get the following error:

raised exception class EIdSocketError with message 'Socket Error # 10040 Message too long.'

These are my component design-time properties:

  object IdTraceRoute: TIdTraceRoute
    ReceiveTimeout = 5000
    Protocol = 1
    ProtocolIPv6 = 58
    ResolveHostNames = True
    OnReply = IdTraceRouteReply
    Left = 640
    Top = 472
  end

This is my code:

procedure TFrame_TraceRoute.TraceRoute;
begin
  memOutput.Lines.Clear;

  IdTraceRoute.ReceiveTimeout := Round(sbTimeout.Value);
  IdTraceRoute.PacketSize := Round(sbPacketSize.Value);
  IdTraceRoute.Host := edtIPDomain.Text;

  memOutput.Lines.Add('Pings:');
  memOutput.Lines.Add('======================================');

  IdTraceRoute.Trace();
end;

procedure TFrame_TraceRoute.IdTraceRouteReply(ASender: TComponent; const AReplyStatus: TReplyStatus);
begin
  if AReplyStatus.ReplyStatusType = rsEcho then
  begin
    var RoundTripTime := AReplyStatus.MsRoundTripTime;
    memOutput.Lines.Add('Reply from ' + AReplyStatus.FromIpAddress + ': time=' + RoundTripTime.ToString + 'ms');
  end
  else if AReplyStatus.ReplyStatusType = rsTimeout then
    memOutput.Lines.Add('Ping request timed out')
  else
    memOutput.Lines.Add('Ping request failed');
end;

My code is also on GitHub if you want to see the full unit.

The error happens as soon as IdTraceRoute.Trace() is called.

I found this question where the error is the same when doing a ping via TIdIcmpClient and the answer suggests setting the PacketSize to 24. This doesn't fix my issue though. I've set the PacketSize to 24 and even lower, but I still get the same error.

When I do a ping with TIdIcmpClient and the same properties (ReceiveTimeout, PacketSize, Host, etc), then it works. Although once I switch to doing Trace Route using TIdTraceRoute, then it doesn't work.


What am I doing wrong? What could be the cause of the error?

0

There are 0 answers