Welcome to CTraceRoute, a freeware C++ class to implement "TraceRoute" functionality on Windows.
Features |
Copyright |
Usage |
History |
API Reference |
Contacting the Author |
v1.20 (18 March 2022)
v1.19 (28 March 2020)
v1.18 (29 December 2019)
v1.17 (10 November 2019)
v1.16 (5 May 2019)
v1.15 (3 November 2018)
v1.14 (26 December 2017)
v1.13 (8 May 2016)
v1.12 (7 June 2008)
v1.11 (5 May 2002)
v1.1 (25 February 2002)
v1.0 (18 November 1998)
The API consists of the the 3 classes:
CTraceRouteReplyv4 / CTraceRouteReplyv6
CTraceRoute
CTraceRouteReplyv4 / CTraceRouteReplyv6
This is an encapsulation of all the information as returned from a trace route request. The v4 class represents a reply when using IPv4 and the v6 class represents a reply when using IPv6.
The members of CHostTraceMultiReplyv4 / CHostTraceMultiReplyv6 are as follows:
DWORD dwError | This is the error if any which occurred when doing a ping to this host. This corresponds to the values as returned from GetLastError. 0 represents no error occurred. |
SOCKADDR_IN[6] Address | The IP address of the host for this part of the trace route |
DWORD minRTT | Minimum round trip time in milliseconds for this host |
DWORD avgRTT | Average round trip time in milliseconds for this host |
DWORD maxRTT | Maximum round trip time in milliseconds for this host |
Tracev4/Tracev6
OnPingResult
OnSingleHostResult
bool CTraceRoute::Tracev4(LPCTSTR pszHostName, CReplyv4& trr, UCHAR nHopCount = 30, DWORD dwTimeout = 30000, DWORD dwPingsPerHost = 3, WORD wDataSize = 32, UCHAR nTOS = 0, bool bDontFragment = false, bool bFlagReverse = false, LPCTSTR pszLocalBoundAddress = nullptr) const
bool CTraceRoute::Tracev6(LPCTSTR pszHostName, CReplyv6& trr, UCHAR nHopCount = 30, DWORD dwTimeout = 30000, DWORD dwPingsPerHost = 3, WORD wDataSize = 32, UCHAR nTOS = 0, bool bDontFragment = false, bool bFlagReverse = false, LPCTSTR pszLocalBoundAddress = nullptr ) const
Return Value
If the function succeeds, the return value is true. If the function fails, the return value is false. To get extended error information, call ::GetLastError.
Parameters
pszHostName The network address of the socket to connect to: a machine name such as “ftp.yourisp.com”, or a dotted number such as “128.56.22.8” will both work.
trr Upon successful return, this will contain all the information related to the trace route request. See CTraceRouteReply for further details.
nHopCount This is the maximum TTL to use. This corresponds to the farthest router which the ping request will reach.
dwTimeout The timeout for each ping in milliseconds.
dwPingsPerHost The number of pings to perform per host.
wDataSize This is the size of the data to transmit in the ICMP packet.
nTOS The Type of Service IP header field to use
bDontFragment Sets the Don't fragment IP header field
bFlagReverse Sets the Flag Reverse IP header field
pszLocalBoundAddress The local address to bind the request to
Remarks
These functions implements the trace route functionality. The Tracev4 method uses IPv4 while the Tracev6 method uses IPv6.
virtual bool CTraceRoute::OnPingResult(int nPingNum, const CHostTraceSingleReplyv4 htsr);
virtual bool CTraceRoute::OnPingResult(int nPingNum, const CHostTraceSingleReplyv6 htsr);
Return Value
return true to continue the trace route. Returning false will cancel the operation.
Parameters
nPingNum The ping reply which this function is being called for.
htsr Contains the actual results from the ping for this host
Remarks
These functions are called just after each ping reply. You can derive your own class from CTraceRoute and override these functions so that your version is called at the appropriate times
CTraceRoute::OnSingleHostResult
virtual bool CTraceRoute::OnSingleHostResult(int nHostNum, const CHostTraceMultiReplyv4& htmr);
virtual bool CTraceRoute::OnSingleHostResult(int nHostNum, const CHostTraceMultiReplyv6& htmr);
Return Value
return true to continue the trace route. Returning false will cancel the operation.
Parameters
nHostNum The current host which this function is being called for.
htmr Contains the collective results from the ping for this host
Remarks
These functions are called just after all the pings for each host is complete. You can derive your own class from CTraceRoute and override these functions so that your version is called at the appropriate times. See the CMyTraceRoute class in main.cpp for a concrete implementation.
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
18 March 2022