0 ' Developed by Eugeny Brychkov 07 Sep 2017 1 ' Requires firmware datecode 20170905 or later 2 'ON STOP GOSUB 300:STOP ON:ON ERROR GOTO 300 10 PRINT"This program sends ICMP ping":PRINT"request and receives reply using" 20 PRINT"IPRAW: device" 30 PRINT"Press any key to continue":A$=INPUT$(1):PRINT 40 INPUT"IP address to ping";A$:A$="http://"+A$+":1" 40 ' Open IPRAW device 50 OPEN"IPRAW:A$"AS#1 60 ' Making ping packet in the buffer 70 P=&H6000:S=0:RESTORE 1000:GOSUB 990 80 N=FIX(RND(-TIME)*65535):N1=FIX(N/256):N2=N-N1*256:CALLNETSETMEM(0,P,N1,N2):S=S+2:P=P+2 90 FOR I=0 TO 31:CALLNETSETMEM(0,P,65+(I AND 15)):P=P+1:S=S+1:NEXT I 100 ' Calculating checksum, data size is even 110 P=&H6000:C=0:CY=0:FOR I=1 TO S/2:CALLNETGETMEM(0,P,A1,A2):A=A1*256+A2:C=C+A:P=P+2:NEXT I:C1=FIX(C/65536):C=65535*(C1+1)-C 120 C1=FIX(C/256):C2=C-C1*256:CALLNETSETMEM(0,&H6002,C1,C2) 130 ' Putting packet to output buffer 140 FOR I=0 TO S-1:CALLNETGETMEM(0,&H6000+I,A):PRINT#1,CHR$(A);:NEXT I:PRINT:PRINT"Sending...":CALLNETDUMP(0,&H6000,S):PRINT:PRINT 150 ' Sending ICMP packet, IP and proto are already defined by OPEN 160 CALLNETSNDDTG(1) 170 ' Waiting for reply 180 IF EOF(1) GOTO 180 190 ' Getting packet header 200 A$=INPUT$(6,1):PRINT"Reply from ";:FOR I=1 TO 4:Q$=STR$(ASC(MID$(A$,I,1))):L=LEN(Q$):PRINT RIGHT$(Q$,L-1);:IF I<>4 THEN PRINT"."; 210 NEXT I:S=ASC(MID$(A$,5,1))*256+ASC(MID$(A$,6,1)):PRINT" size";S 220 ' Read packet contents into GR8NET temp buffer 230 FOR I=0 TO S-1:A$=INPUT$(1,1):CALLNETSETMEM(0,&H6100+I,ASC(A$)):NEXT I 240 ' Display packet contents' dump 250 CALLNETDUMP(0,&H6100,S) 260 CLOSE #1:ON ERROR GOTO 0:STOP OFF 270 PRINT:PRINT"Application finished":END 990 READ A:FOR I=1 TO A:READ B:CALLNETSETMEM(0,P,B):P=P+1:S=S+1:NEXT I:RETURN 1000 DATA 6,8,0,0,0,4,0