GetRTTAndHopCount function (iphlpapi.h)

The GetRTTAndHopCount function determines the round-trip time (RTT) and hop count to the specified destination.

Syntax

IPHLPAPI_DLL_LINKAGE BOOL GetRTTAndHopCount(
  IPAddr DestIpAddress,
  PULONG HopCount,
  ULONG  MaxHops,
  PULONG RTT
);

Parameters

DestIpAddress

IP address of the destination for which to determine the RTT and hop count, in the form of an IPAddr structure.

HopCount

Pointer to a ULONG variable. This variable receives the hop count to the destination specified by the DestIpAddress parameter.

MaxHops

Maximum number of hops to search for the destination. If the number of hops to the destination exceeds this number, the function terminates the search and returns FALSE.

RTT

Round-trip time, in milliseconds, to the destination specified by DestIpAddress.

Return value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. Call GetLastError to obtain the error code for the failure.

Remarks

For information about the IPAddr data type, see Windows Data Types. To convert an IP address between dotted decimal notation and IPAddr format, use the inet_addr and inet_ntoa functions.

Examples

The following example retrieves and prints the round trip time and hop count to the destination IP address 127.0.0.1.

UINT ip = inet_addr("127.0.0.1");
ULONG hopCount = 0;
ULONG RTT = 0;

if(GetRTTAndHopCount(ip, &hopCount, 30, &RTT) == TRUE) {
  printf("Hops: %ld\n", hopCount);
  printf("RTT: %ld\n", RTT);
}
else {
  printf("Error: %ld\n", GetLastError());
}

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header iphlpapi.h
Library Iphlpapi.lib
DLL Iphlpapi.dll

See also

GetBestInterface

GetBestRoute

IP Helper Function Reference

IP Helper Start Page

IPAddr