//Oberer Block
lstReplies.Items.Add('
Filiale: ' + edt_host1.Text);
lstReplies.Items.Add('
Gerät : ' + device);
lstReplies.Items.Add('
IP : ' +
IP);
lstReplies.Items.Add('
Dauer : ' + inttostr(strtoint(edCount.Text)*60) + '
Pings' + '
= ~' + inttostr(trunc(strtoint(edCount.text)*1.083)) + '
Min.');
lstreplies.TopIndex := lstreplies.Items.Count-1;
//Zeit definieren
times := timetostr(now());
ms := 0;
try
// Host festlegen
ICMP.Host :=
IP;
// Ping so oft durchführen wie bei 'Anzahl der Pings' festgelegt
for i := 1
to strtoint(edCount.text)*60
do begin
Sleep(1000);
elapsed.Caption := timetostr(now() - strtotime(times));
datetimetostring(formattedDateTime, '
dd.mm.yyyy hh:mm:ss', now());
// Ping senden
ICMP.Ping;
if ICMP.ReplyStatus.ReplyStatusType = rsEcho
then
begin
// got some data, connection is up
datetimetostring(formattedDateTime, '
dd.mm.yyyy hh:mm:ss', now());
lstReplies.Items.Add(formattedDateTime + '
- ' + Format('
Antwort von %s: Bytes=%d Zeit%s%dms TTL=%d',
[ICMP.ReplyStatus.FromIpAddress,
ICMP.ReplyStatus.BytesReceived,
sTime,
ICMP.ReplyStatus.MsRoundTripTime,
ICMP.ReplyStatus.TimeToLive]));
//Werte für Durschschnittszeitberechnung sammeln
ms := ms + strtoint(split(split(Format('
%s%dms',[sTime,ICMP.ReplyStatus.MsRoundTripTime]), '
=', 1), '
m', 0));
end
else if ICMP.ReplyStatus.ReplyStatusType = rsTimeout
then
begin
// have a timeout, link is down
lstReplies.Items.Add(formattedDateTime + '
- ' + '
Zeitüberschreitung der Anforderung');
end
else
begin
// some other response, do something else...
end;
lstreplies.TopIndex := lstreplies.Items.Count-1;
end;
finally
// Button Ping wieder auf Enabled=True
btnPing.Enabled := True;
lstReplies.Items.Add('
');
lstReplies.Items.Add('
Ping Statistik für ' +
IP + '
:');
ms := trunc(ms / (i-1));
lstReplies.Items.Add('
Durschnittliche Zeit: ' + inttostr(ms)+ '
ms' );
lstreplies.TopIndex := lstreplies.Items.Count-1;
end;