4D Ping


ACI - Documentation Français English German ACI Technical Notes ACI Technical Notes, By Subject Back Previous Next Find

4D Ping

By Arnaud Lion, 4D S.A. Technical Support

Technical Note 00-43

Technical Notes for Technical Notes for 00-09 September 2000

Introduction


This technical note introduces an utility program that allows you to "ping" a computer on the network. This tool can help you to isolate network-related problems while deploying applications.

The code used in this utility program takes advantage of 4D Internet commands.

The Sample Database's Form


The form used for the interface of the sample database is organized into four areas:

Local computer

This area allows you to enter the IP address and subnet mask of the machine from which the test is performed.

Ping Settings

This area allows you to:

enter the address of the machine to test (It also displays the list of addresses tested since the database was started)

select the number of packets to send

select continuous pinging

Packet Settings

This area allows you to:

enter the actual contents of the test packet (it also displays its size).

enter the interval between two consecutive packets

Ping Report

This area displays:

the sequence number for every ping test in a sequence.

the address tested and a DNS name if one is detected.

the duration of the pinging (in ticks), if the test was successful

The methods of the Sample Database


The On startup database method:

Before using the 4D IC commands, you always need to initialize the TCP layer.

SET ABOUT("A propos...";"About_NT") 
C_LONGINT($ERROR)
C_BOOLEAN($SUITE)
HIDE WINDOW(Frontmost window(*))
$ERROR:=IT_MacTCPInit 
$Suite:=IC_Error ($ERROR;"IT_MacTCPInit")
If ($Suite)
   $ERROR:=IT_SetTimeOut (15)
   $Suite:=IC_Error ($ERROR;"IT_SetTimeOut")
End if 
If ($Suite)
   Dialog_Ping 
End if 

The IC_Error method:



   C_TEXT($ERRORTXT;$2)
   C_BOOLEAN($0)
   C_LONGINT($1)
   $Errortxt:=""
   $0:=False
   
   If ($1=0)
      $0:=True
   Else 
      $Errortxt:=IT_ErrorText ($1)
      
      If ($2#"")
         $Errortxt:="Command : "+$2+Char(13)+$Errortxt
      End if 
      
      $0:=False
      ALERT($Errortxt)
      
   End if 

The Form method:

C_LONGINT($Event;$Error)
C_BOOLEAN($Suite)
$Event:=Form event
Case of
   : ($Event=On Load)
      $Error:=IT_MyTCPAddr (vIPPerso;vLocalSubnet)
      $Suite:=IC_Error ($Error;"IT_MyTCPAddr")
      If ($Suite)
         vPacketNumber:=5
         vText:=""
         vBytes:=0
         vticks:=60
         ARRAY TEXT(tIP;0)
         tType:=1
         bSend:=1
         <>Report:=""
      Else 
         CANCEL
         ALERT("The TCP/IP layer is not active.")
      End if 
      
   : ($Event=On Close Box)
      CANCEL
      
   : ($Event=On Outside Call)
      If (<>End)
         ENABLE BUTTON(bStart)
         SET ENTERABLE(tIP;True)
         SET ENTERABLE(vPacketNumber;True)
         SET ENTERABLE(vText;True)
         SET ENTERABLE(vticks;True)
      End if 
   
End case 
   

The Ping method:

C_TEXT($IPOUSERVEUR;$REPORT;$SERVER;$LIGNESEP;$1;$2)
C_LONGINT($I;$3;$4;$5;$ERROR;$TICKSPING;$Status;$NB;$TICKSF;$NUMBER;$NOMBREPING;$TICKS)

<>End:=False
$Nb:=Count parameters
Case of 
   : ($nb=0)
      <>ProcessPing:=New process("Ping";64*1024;"Ping";tIP{0};vText;bSend;vPacketNumber;vticks;*)
   : ($Nb#0)
      $LigneSep:=Char(Ascii("*"))*35+Char(13)
      <>Report:=$LigneSep
      $NUMBER:=0
      $ERROR:=NET_Resolve ($1;$IPOuServeur)
      $NombrePing:=0
      $Ticks:=Tickcount
      Repeat 
         $NombrePing:=$NombrePing+1
         <>Report:=Char(13)+"Adresse IP ["+$1+"] ["+$IPOuServeur+"]"+Char(13)+<>Report
         $TicksPing:=Tickcount
         $ERROR:=NET_Ping ($1;$2;$Status)
         $Suite:=IC_Error ($ERROR;"NET_Ping")
         $TicksPing:=Tickcount-$TicksPing
         If ($Suite)
            If ($Status=0)
               <>Report:="The computer is off line."+Char(13)+<>Report
               <>End:=True
            Else 
               <>Report:=String($TicksPing)+" ticks."+<>Report
            End if 
            <>Report:="Ping n° "+String($NombrePing)+":"+Char(Tab)+<>Report
            Case of 
               : ($3=1)
               $NUMBER:=$NUMBER+1
               If ($NUMBER=$4)
                  <>End:=True
               End if 
            End case 
         Else 
            <>Report:=Char(13)+" A problem occured during the TCP/IP connection."
            <>End:=True
         End if 
         <>Report:=$LigneSep+<>Report
         CALL PROCESS(-1)
         $TicksF:=Tickcount-$Ticks
         If ($TicksF<$5)
            DELAY PROCESS(<>ProcessPing;($5-$TicksF))
         End if 
      Until (<>End)
End case 
CALL PROCESS(<>DIALOG)

Summary


The utility database that comes with this technical note is designed to help you diagnose network problems.

Note: 4D Internet commands need to be installed for the database to operate properly.


ACI - Documentation Français English German ACI Technical Notes ACI Technical Notes, By Subject Back Previous Next Find