Re: icmp command

Dinesh Pullat (dinesh@newsnet.com.au)
Wed, 9 Jul 1997 12:20:55 +1000

I added to that:
proc track {host} {
set last ""
for {set i 1} {1} {incr i} {
set hop [lindex [icmp trace $i $host] 0]
set rtt [lindex $hop 1]
if {$rtt < 0} {
return $last
}
if {$last != [lindex $hop 0]} {
set last [lindex $hop 0]
} else {
return $last
}
}
}
This last bit would get us out of the 'for loop' if the 'host' is reachable.

%
% The icmp trace command is not a full blown traceroute. It only sends
% out a single ICMP echo request with a time to live set to 10 in your
% case. The host does not respond (because it is down) and hence you do
% not get an answer. If you want to find the last reachable host, you
% have to write a loop which increments the time to live value:
%
% set last ""
% for {set i 1} {1} {incr i} {
% set hop [icmp trace $i $host]
% set rtt [lindex $hop 1]
% if {$rtt < 0} {
% return $last
% }
% set last [lindex $hop 0]
% }
%
% Note that sometimes you get no response from hosts somewhere on the
% path so you would like to go on for a while to check if you really
% found the end. Look at the traceroute scripts in the source code for
% more examples.
% Juergen
% --
% Juergen Schoenwaelder <schoenw@gaertner.de> (Tel: +49-531-23873-0)
% Gaertner Datensysteme, Hamburger Strasse 273a, 38114 Braunschweig, Germany
%
--
Dinesh.
--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.