Expand Minimize

GetRTTAndHopCount function

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

Syntax


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

Parameters

DestIpAddress [in]

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

HopCount [out]

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

MaxHops [in]

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 [out]

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]

Header

Iphlpapi.h

Library

Iphlpapi.lib

DLL

Iphlpapi.dll

See also

IP Helper Start Page
IP Helper Function Reference
IPAddr
GetBestInterface
GetBestRoute

 

 

Community Additions

ADD
Show:
© 2014 Microsoft