!********************** !* lmcoxs/lmcoxy * !* date: 28.jan.81 * !********************* %conststring (13) vsn = "Lmco..2a" #options #datestring !! stack = 300, streams = 1 %control x'4001' %include "b_deimosspecs" %begin #if ~b %recordformat lev3f(%byteintegerarray reserved(0:8), %c %byteintegerarray a(0:239)) %recordformat mef(%record(mef)%name link,%byteinteger len,type, %c (%record(lev3f) lev3 %or %bytearray params(0:241))) %recordformat pf(%byteinteger service,reply,(%byte fn,ss1, %c %record(mef)%name mes,%byteinteger gate port, task port %or %c %byte a1, a2, b1, b2, c1, c2)) #else %recordformat lev3f(%bytearray reserved(0:6), %bytearray a(0:239)) %recordformat mef(%integer buff no, len, %byte owner, type, %c (%record (lev3f) lev3 %or %bytearray params(0:241))) %recordformat pf(%byte service, reply, (%byte fn, ss1, %c %integer buff no, %byte gate port, task port %or %c %byte a1, a2, b1, b2, c1, c2)) #fi %record (pf) p %constinteger gate ser=24, buffer manager=17 %constinteger request buffer=0, release buffer=1 %include "b_ygatecalls" %integer i, node, term, strm, k, flag, pktlen, pktinc %owninteger seq number %owninteger sta, pkts, tim, ticks, pk %owninteger fast = 30 %owninteger conn ok, g port, power, kill it %record (mef) %name mes %ownstring (63) address = "" %ownstring (63) facil = "" %owninteger mon = 1 %owninteger slow = 0; ! send a packet every 2 secs or so %ownstring(1) snil = "" %routine readstring(%string (*) %name s) %integer i s = "" %cycle readsymbol(i); %exit %if i = nl s = s.tostring(i) %repeat %end %routine mon mes(%record (mef) %name mes) %integer i, j, k, n %recordformat itp2f(%bytearray a(0:128)) %record (itp2f) %name itp k = mes_len; itp == mes_lev3 write(k, 1); space; space j = 0 %cycle i = 0, 1, k %if mon > 0 %and i > 3 %start; ! 'p' and not header n = itp_a(i) printsymbol(n) %unless n = 0 %or n = 4 %else write(itp_a(i), 1) j = j+1; %if j = 25 %then j = 0 %and newline %finish %repeat newline; select output(0) %end %routine mon p(%record (pf)%name p) %record (mef) %name mes %integer i printstring(" fn ="); write(p_fn, 1) printstring(" gate port"); write(p_gate port, 1) printstring(" task port"); write(p_task port, 1) printstring(" a2"); write(p_a2, 1) #if b printstring(", buff:"); write(p_buff no, 1) #fi newline %end %routine pack(%record(mef) %name mes, %string (*) %name s) string(addr(mes_params(mes_len))) = s mes_len = mes_len+length(s)+1 %end %routine do connect(%record (mef) %name mes) !============================================================ %string (63) facn p_service = gate ser; p_reply = own id p_fn = connect p_gate port = 0; p_task port = 1 p_ss1 = 0 #if ~b p_mes == mes #else p_buff no = mes_buff no #fi mes_len = 0 facn = address pack(mes, facn) pack(mes,snil); ! calling address facn = facil pack(mes, facn) pack(mes, snil) %if mon < 0 %start select output(1); spaces(5) printstring("xxx: to gate:"); {t} mon p(p) select output(0) %finish pon(p) %end #if ~b %routine get buffer(%integer reason) p_service=buffer manager; p_reply=id p_fn=request buffer; p_c2=0; p_a2=reason p_c1 = 0 pon(p) %end %routine free buffer(%record(mef)%name mes) p_service=buffer manager; p_reply=id p_fn=release buffer; p_mes==mes pon(p) %end #else %record (mef) %map map(%integer buff no) ! New compiler - so must get 0 *mov_1,0 *mov_#8,1; ! desired vm seg no *2 ie 4*2 *iot %result == record(k'100000') %end %routine free buff no(%integer buff no) ! not mapped, so send it straight back p_service= buffer manager; p_reply = id p_fn = release buffer p_buff no = buff no pon(p) %end %routine free buffer(%record (mef) %name mes) %record (pf) p %integer buff no ! nb: routine ASSUMES buffer is mapped on buff no = mes_buff no %unless mes == null %start !There really is a buffer !Tell Buffer Manager it can have its buffer back. p_service = buffer manager ;p_reply = id p_fn = release buffer p_buff no = buff no pon(p) %finish %end ;!of Free Buffer %routine get buffer(%byte reason) p_a2 = reason !Check on reason prevents recursive calls p_service = buffer manager ;p_reply = id p_fn = request buffer p_c1 = 0 pon(p) %end ;!of get buffer #fi %routine to gate(%integer fn,%record(mef)%name mes,%integer flag) p_service=gate ser; p_reply=id #if ~b p_fn=fn; p_mes==mes; p_ss1=flag #else p_fn = fn; p_buff no = mes_buff no; p_ss1 = flag #fi p_gate port = g port; p_task port = 1 pon(p) %end %routine block(%record (mef) %name mes) %integer i %record (lev3f) %name lev3 lev3 == mes_lev3 %cycle i = 0, 1, pktlen-1 lev3_a(i) = 'A' %repeat lev3_a(pktlen-2) = 13; lev3_a(pktlen-1) = 10 mes_len = pktlen lev3_a(0) = 0 pkts = pkts+1 to gate(put output, mes, 0) %end printstring(vsn); printstring(datestring); newline i = map virt(buffer manager,4, 3) i = map virt(buffer manager, 5, 4) i = map virt(buffer manager, 6, 5) prompt("Whole address?") readstring(address) prompt("Extra facilities:"); readstring(facil) %if facil = "SLOW" %then facil = "" %and slow = 1 prompt("Packet Len & Inc?") read(pktlen); read(pktinc) use tt(t3 ser) sta = 1 get buffer(-1) alarm(2*50) %cycle p_service = 0; poff(p) %if p_reply = 0 %start; ! clock alarm(2*50); ! 2 secs %if int = 'A' %start kill it = -1 printstring("killing it ") to gate(disconnect, null, 0) %if conn ok # 0 int = 0 %continue %finish ticks = ticks+1 %if slow # 0 %then get buffer(0); ! send on clock tick %if ticks = fast %start ticks = 0 printstring("block len is "); write(pktlen, 2) printstring(", blocks sent = "); write(pkts, 4) %if fast = 30 %then pk = pkts//6 %else pk = pkts printstring(", per 10 secs ="); write(pk, 3) printstring(", bytes sent/sec =") %if fast = 30 %start pk = pkts//15 pk = (pk*pktlen)//4 %else pk = pkts//5 pk = (pk*pktlen)//2 %finish write(pk, 4); pkts = 0 pktlen = pktlen+pktinc %if pktlen > 256 %then pktlen = 256 %if int = 'F' %then fast = 5 %and int = 0 %if int = 'Q' %then pktlen = pktlen+5 newline %finish %if int='?' %start write(flag, 1) write(pkts, 4); newline int = 0 %finish %continue %finish %if 'M' <= int <= 'P' %start mon = int-'O'; int = 0 %finish %if mon < 0 %start select output(1) printstring("poff:"); write(p_reply, 1) write(p_fn, 1); write(p_ss1, 1) %if p_reply = gate ser %then mon p(p) newline select output(0) %finish %if p_reply = buffer manager %start #if b mes == map(p_buff no) mes_owner = own id #else mes == p_mes #fi %if kill it < 0 %then free buffer(mes) %and %continue %if p_ss1 = 255 %then do connect(mes) %else %c block(mes) %continue %finish %if p_reply = gate ser %start #if b mes == map(p_buff no) mes_owner = own id %unless p_buff no = 0 #else mes == p_mes #fi %if p_fn = accept call %start; ! 2nd reply free buffer(mes) %unless mes == null %stop %if kill it < 0 i = p_gate port; ! gate port number !! g port = i printstring("call accepted ") conn ok = 1 %if slow = 0 %start get buffer(0) get buffer(0); ! send another (for gate to q) %finish %continue %finish %if p_fn=disconnect %start; ! my end i hope free buffer(mes) %unless mes == null printstring("call gone") write(p_ss1, 1); newline To Gate(disconnect, null, 1) %unless kill it < 0 p_service = 0; poff(p); ! wait for clock tick %stop %finish %if p_fn = enable output %start %if slow = 0 %start get buffer(0) %for i = 1, 1, p_ss1 %finish %continue %finish %if p_fn = input here %start pkts = pkts+1 free buffer(mes) to gate(enable input,null,1) %continue %finish %if p_fn = reset %start free buffer(mes) %unless mes == null to gate(Disconnect, null, 0); kill it = -1 %continue %finish printstring("funny fn"); write(p_fn, 1); newline %continue %finish %repeat %endofprogram