From 996025edfa112f32a12ed816abc2580c112ef306 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 14 Jun 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-06-14 --- port/ipdat.h | 2 +- port/stil.c | 31 +++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/port/ipdat.h b/port/ipdat.h index 6997bda9c8914ba593e3521cabc86d9078aab0e1..5ccfb80f70c38e410e81119bc3c11b7ff2a8fb5d 100644 --- a/port/ipdat.h +++ b/port/ipdat.h @@ -421,7 +421,7 @@ struct Ipfrag /* Protocol numbers */ #define IP_UDPPROTO 17 #define IP_TCPPROTO 6 -#define IP_ILPROTO 190 /* I have no idea */ +#define IP_ILPROTO 40 /* Protocol port numbers */ #define PORTALLOC 5000 /* First automatic allocated port */ diff --git a/port/stil.c b/port/stil.c index 9b91640e7aefb36b1c1bbf03b80bc02204081dc2..babd363b84e0276a1f31d5d5c7719a2050858836 100644 --- a/port/stil.c +++ b/port/stil.c @@ -37,11 +37,10 @@ enum Querytime = 60*Iltickms, /* time between queries */ Keepalivetime = 10*Querytime, /* keep alive time */ Defaultwin = 20, + ILgain = 8, }; -#define Starttimer(s) {(s)->timeout = 0; (s)->fasttime = Fasttime; } -/* Packet dropping putnext for testing */ -#define DPUTNEXT(q, b) if((MACHP(0)->ticks&7) != 3)PUTNEXT(q, b);else{freeb(b);print(".");} +#define Starttimer(s) {(s)->timeout = 0; (s)->fasttime = (Fasttime*(s)->rtt)/Iltickms; (s)->slowtime = (Slowtime*(s)->rtt)/Iltickms; } void ilrcvmsg(Ipconv*, Block*); void ilackproc(void*); @@ -185,6 +184,12 @@ iloput(Queue *q, Block *bp) if(ilcksum) hnputs(ih->ilsum, ptcl_csum(bp, IL_EHSIZE, dlen+IL_HDRSIZE)); ilackq(ic, bp); + + /* Start the round trip timer for this packet if the timer is free */ + if(ic->rttack == 0) { + ic->rttack = id; + ic->ackms = MACHP(0)->ticks; + } ic->acktime = Ackkeepalive; PUTNEXT(q, bp); @@ -215,7 +220,20 @@ ilackto(Ilcb *ic, ulong ackto) { Ilhdr *h; Block *bp; - ulong id; + ulong id, t; + + if(ic->rttack == ackto) { + t = TK2MS(MACHP(0)->ticks - ic->ackms); + /* Guard against the ulong zero wrap */ + if(t < 100*ic->rtt) + ic->rtt = (ic->rtt*(ILgain-1)+t)/ILgain; + if(ic->rtt < Iltickms) + ic->rtt = Iltickms; + } + + /* Cancel if we lost the packet we were interested in */ + if(ic->rttack <= ackto) + ic->rttack = 0; qlock(&ic->ackq); while(ic->unacked) { @@ -308,6 +326,7 @@ ilrcvmsg(Ipconv *ipc, Block *bp) ic->recvd = 0; ic->rstart = nhgetl(ih->ilid); ic->slowtime = Slowtime; + ic->rtt = Iltickms; ic->querytime = Keepalivetime; ic->deathtime = Keepalivetime; ic->window = Defaultwin; @@ -770,11 +789,11 @@ ilstart(Ipconv *ipc, int type, int window) if(ic->state != Ilclosed) return; - Starttimer(ic); ic->unacked = 0; ic->outoforder = 0; ic->slowtime = Slowtime; - + ic->rtt = Iltickms; + Starttimer(ic); initseq += TK2MS(MACHP(0)->ticks); ic->start = initseq & 0xffffff;