diff --git a/README.md b/README.md index 51fcc6f0..c51d351b 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,7 @@ A list of [known ITS machines](doc/machines.md). - TELSER, Telnet/Supdup server. - TIME, displays date/time/uptime and other info. - TIMOON, displays the time and phase of the moon. + - TIMSRV, RFC 868 network time protocol. - TMPKIL, clean out old files in .TEMP.;. - TTLOC, Advertises physical location of logged in users. - TYPE8, type 8-bit file diff --git a/build/build.tcl b/build/build.tcl index 99b08441..b8e089fe 100644 --- a/build/build.tcl +++ b/build/build.tcl @@ -780,6 +780,11 @@ expect ":KILL" respond "*" ":midas sys1;ts arcsal_sysen1;arcsal\r" expect ":KILL" +# timsrv +respond "*" ":midas sysbin;timsrv bin_sysnet;timsrv\r" +expect ":KILL" +respond "*" ":link device;tcp syn045,sysbin;timesrv bin\r" + # rmtdev respond "*" ":midas device;atsign rmtdev_gz;rmtdev\r" diff --git a/src/sysnet/timsrv.10 b/src/sysnet/timsrv.10 new file mode 100755 index 00000000..da977855 --- /dev/null +++ b/src/sysnet/timsrv.10 @@ -0,0 +1,106 @@ +;-*- Mode: MIDAS -*- +TITLE TIMSRV ; Net time server + +GMTDIF==5 ; # hours difference between local zone and GMT. + +F=0 ;TCP flag. +A=1 +B=2 +C=3 + +P=17 + +NETO==1 +NETI==2 + +.INSRT KSC;MACROS > +LOC 42 + JSR TSINT +LOC 100 +PAT: BLOCK 20 +PDL: BLOCK 20 +DEBUG: 0 + +ICPSOC==45 ; Official ICP socket for Time Server. + + ;Interrupt handler - mostly for fatal conditions +TSINT: 0 + 0 + JSR LOGOUT ; Any interrupt is cause for death. + + ; Start of program +GO: MOVEI P,PDL ;init pdl pointer + + .SUSET [.RJNAME,,A] + CAME A,[SIXBIT /TCP/] + JRST NCPICP +TCPICP: SYSCAL TCPOPN,[ MOVEI NETI ? MOVEI NETO + MOVEI ICPSOC ? [-1] ? [-1]] + JSR LOGOUT ; Failed (should timeout!) + MOVEI B,3*30. ; Try for 30 sec +TCPIP1: MOVEI A,10. + .SLEEP A, + SYSCAL WHYINT,[MOVEI NETO ? MOVEM A ? MOVEM A] + .LOSE %LSSYS + CAIE A,%NSOPN + CAIN A,%NSRFN + CAIA + SOJG B,TCPIP1 + CAIG B, + JSR LOGOUT ; Timed out... + SETO F, + JRST SERVE ; Or got connected... + + ;set timer to log out if icp not finished within 60 sec. +NCPICP: MOVE A,[600000,,[60.*60.]] ;flush old ticks, start + .REALT A, ;new rate, 60 sec frame(ints). + JFCL + .SUSET [.SMASK,,[%PIRLT+%PIIOC]] ;enable ioc and realt + .SUSET [.SPICLR,,[-1]] ;enable ints + + ;start icp + .OPEN NETO,[40060+.UIO,,'NET ? ICPSOC] ;open 32-bit listen on ICP socket. + JSR LOGOUT + MOVEI A,NETO + NETHANG 900.,A,%NSLSN,[%NSRFC] ;hang until rfc received + JSR LOGOUT + .NETAC NETO, ;accept it + JSR LOGOUT + MOVEI A,NETO + NETHANG 900.,A,%NSRFC,[%NSOPN] ;wait until open + JSR LOGOUT + SETZ F, + +SERVE: .RLPDTM A, ; Get in A, # secs since beg of year. + CAME A,[-1] + CAMN B,[-1] + JSR LOGOUT ; If either is -1, time not known. + CAIGE B, ; If 4.9 on, + SUBI A,24.*3600. ; subtract 1 day - .RLPDTM misfeature! + TLNE B,100000 ; Bit 4.7 = Daylight Savings time? + SUBI A,3600. ; If on, subtract one hour to get Standard. + MOVEI B,-1900.(B) ; Get year, relative to 1900. + MOVEI C,-1(B) ; Adjust and + LSH C,-2 ; Get # leap years since 1900 + ; not including this year. + IMULI B,365. ; Find # days in years thus far + ADDI B,(C) ; Plus # LY's, to get total days in years past. + IMULI B,86400. ; Now get # seconds in all them days. + ADD A,B ; and produce total seconds since 1/1/00 ! + ADD A,[GMTDIF*3600.] ; Adjust to GMT. + SKIPN F ; If connected via NCP + JRST [ .IOT NETO,A ; Send out a word of the 32-bit time. + JRST SRVDUN ] + MOVE B,[401000,,A] ; If connected via TCP + MOVEI C,4. ; Send four 8-bit bytes of the 32-bit time. + SYSCAL SIOT,[MOVEI NETO ? B ? C] + JSR LOGOUT +SRVDUN: .NETS NETO, ; Force the output. + .CLOSE NETO, ; Disconnect. + CAIA +LOGOUT: 0 + SKIPE DEBUG + .VALUE + .LOGOUT ; All done + +END GO diff --git a/src/sysnet/timsrv.info b/src/sysnet/timsrv.info new file mode 100755 index 00000000..6d73697e --- /dev/null +++ b/src/sysnet/timsrv.info @@ -0,0 +1,71 @@ + +Date: 30 AUG 1976 1202-PDT +From: POSTEL at USC-ISIC +Subject: Time Of Day Socket Number +To: KLH at MIT-AI +cc: postel + +Ken: +The number is 37 decimal (45 octal). +--jon. +------- + +RMS@MIT-AI 08/15/76 19:35:47 +To: KLH at MIT-AI +I forgot to say in the time algorithm +that a sublist is acceptible only if it contains at least half +the hosts that responded. If there is no sublist, all the hosts +get mailed messages. The intent if the messages is to get +people on the hosts to intervene. + +RMS@MIT-AI 08/15/76 16:48:11 +To: KLH at MIT-AI +I would like to have the system's time itself set according +to the other sites' times. I have worked out an algorithm +that I think does the right things in all cases: +1) contact all the sites on the list. +2) make a list of all the sites that gave answers, + and what they gave, including the local host. + Contact all of them in parallel to save real time. +3) sort that list numerically by time returned. +4) find the longest subsequence which has the property +that its beginning and end are within 5 minutes. +"Length" can actually be weighted, with more related hosts +counting for more. +5) compute the average time of the hosts in the sublist +6) Send mail to the appropriate name at all hosts not in +that sublist, telling them the names of the hosts in the +sublist and the amount of time they're off from the sublist +average. +7) If the local host isn't in the sublist, set its time +to the sublist average. +8) this program should be run whenever the system starts up, +and everything else should wait for its completion. +Thus, it should be done by TARAKA before anything else. + +KLH@MIT-AI 08/15/76 03:32:42 +To: RMS at MIT-AI +CC: [KSC;TIMSRV INFO] at MIT-AI +P.S. to message about time server etc. The following routines +are fairly modular: +NETIM - in TIMES >, is a non-interrupt routine that gets the "network time word" + given a site # to connect to. +TIMGTN - in TIMRTS >, is a routine that returns current local time in + network-time format. +TIMCAS/TIMCAD - in TIMRTS >, will convert network-time format into standard + DSK-style format. + + Since hacking time stuff is so painful, however straightforward, +I thought I would point those out, particularly TIMCAS. The network-time +format is # seconds since 1/1/1900, GMT - this makes instant +comparisions easy from any point in network, and is simple enough to +encode. It is much more of a win than I thought it would be; TIMES^K +scans very fast. + The algorithm mailer uses is to poll all sites known +to have Time Servers, and proceed with its local time if it agrees +with more sites than it disagrees, or if all sites are down. This +implies that finding 1 match and 1 mismatch will cause mailer to +hang up and wait, but 2 matches and 1 mismatch will be taken as confirmation +of local time. Criteria for a match is that the absolute difference +must not be more than 15 minutes, which is extremely liberal I think. +