traceroute code example
Example 1: traceroute
tracert [ipadress]
Example 2: traceroute command
Windows - $tracert ip or domain
Linux and MAC - $traceroute ip or domain
Example 3: what is traceroute
Traceroute is a network diagnostic tool used to track
in real-time
the pathway taken by a packet on an IP network from source to destination,
reporting the IP addresses of all the routers it pinged in between.
Traceroute also records the time taken for each hop the packet makes \
during its route to the destination.
Example 4: browserrouter
<BrowserRouter
basename={optionalString}
forceRefresh={optionalBool}
getUserConfirmation={optionalFunc}
keyLength={optionalNumber}
>
<App />
</BrowserRouter>
Example 5: Traceroute
#################################################################################
# ActiveXperts Network Monitor PowerShell script, © ActiveXperts Software B.V.
# For more information about ActiveXperts Network Monitor, visit the ActiveXperts
# Network Monitor web site at http://www.activexperts.com
#################################################################################
# Script
# TraceRoute.ps1
# Description:
# Tracks the route packets taken from an IP network on their way to a given host.
# This function uses ActiveXperts Network Component.
# ActiveXperts Network Component is automatically licensed when ActiveXperts Network Monitor is purchased.
# For more information about ActiveXperts Network Component, see: www.activexperts.com/network-component
# Declare Parameters:
# 1) strHost (string) - Host name or IP address or target
# 2) nMaxHops (int) - Maximum number of hops to search for target
# 3) nMaxResponseTime (int) - Wait timeout milliseconds for each reply
# Usage:
# .\TraceRoute.ps1 '<Hostname | IP>' <MaximumHops> <MaximumResponseTimeMsecs>
# Sample:
# .\TraceRoute.ps1 'www.activexperts.com' 30 500
#################################################################################
# -- Declare Parameters
param( [string]$strHost = '', [int]$nMaxHops = '', [int]$nMaxResponseTime = '' )
# -- Use _activexperts.ps1 with common functions
. 'C:\Program Files\ActiveXperts\Network Monitor\Scripts\Monitor (ps1)\_activexperts.ps1'
#################################################################################
#
#################################################################################
# -- Clear screen and clear error
cls
$Error.Clear()
# -- Validate parameters, return on parameter mismatch
if( $strHost -eq '' -or $nMaxHops -eq '' -or $nMaxResponseTime -eq '' )
{
$res = 'UNCERTAIN: Invalid number of parameters - Usage: .\TraceRoute.ps1 "<Hostname | IP>" <MaximumHops> <MaximumResponseTimeMsecs>'
echo $res
exit
}
# Create a instance
$objTraceRt = new-object -comobject AxNetwork.TraceRoute
$objTraceRt.ResolveHostName = $True
$objTraceRt.MaxHops = $nMaxHops
$objTraceRt.Timeout = $nMaxResponseTime
$nHops = 0
$objHop = $objTraceRt.FindFirstHop( $strHost )
if( $objTraceRt.LastError -ne 0 )
{
$res = 'ERROR: Route to [' + $strHost + '] not found; result=[' + $objTraceRt.LastError + ': ' + $objTraceRt.GetErrorDescription( $objTraceRt.LastError ) + '] DATA:0'
echo $res
exit
}
do
{
if( $objHop.Host -ne '' )
{
$strHopName = $objHop.Host
}
else
{
$strHopName = $objHop.IP
}
$nHops = $nHops + 1
if( $objHop.ResponseTime -gt $nMaxResponseTime )
{
$res = 'ERROR: Hop [' + $strHopName + '] response timeout [' + $nMaxResponseTime + 'ms] exceeded, time=[' + $objHop.ResponseTime + 'ms] DATA:' + $nHops
echo $res
exit
}
$objHop = $objTraceRt.FindNextHop()
} while( $objTraceRt.LastError -eq 0 )
$res = 'SUCCESS: TraceRoute succeeded, all [' + $nHops + '] hops replied within [' + $objTraceRt.Timeout + 'ms] DATA:' + $nHops
echo $res
exit
#################################################################################
#
#################################################################################
trap [Exception]
{
$res = 'UNCERTAIN: ' + $_.Exception.Message
echo $res
exit
}
Example 6: tracert
Tracing route to 11.1.0.1 over a maximum of 30 hops --------------------------------------------------- 1 2 ms 3 ms 2 ms 157.54.48.1 2 75 ms 83 ms 88 ms 11.1.0.67 3 73 ms 79 ms 93 ms 11.1.0.1 Trace complete.