adopt TCP's policies concerning acks & (among others) use the fast
authorKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sat, 7 Sep 1991 08:15:21 +0000 (00:15 -0800)
committerKeith Sklower <sklower@ucbvax.Berkeley.EDU>
Sat, 7 Sep 1991 08:15:21 +0000 (00:15 -0800)
timeout mechanism and delayed acks.

SCCS-vsn: sys/netiso/tp_subr.c 7.13
SCCS-vsn: sys/netiso/tp_stat.h 7.6
SCCS-vsn: sys/netiso/tp.trans 7.13
SCCS-vsn: sys/netiso/iso_proto.c 7.9
SCCS-vsn: sys/netiso/tp_timer.c 7.9
SCCS-vsn: sys/netiso/tp_timer.h 7.6

usr/src/sys/netiso/iso_proto.c
usr/src/sys/netiso/tp.trans
usr/src/sys/netiso/tp_stat.h
usr/src/sys/netiso/tp_subr.c
usr/src/sys/netiso/tp_timer.c
usr/src/sys/netiso/tp_timer.h

index de2580b..47b2213 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)iso_proto.c 7.8 (Berkeley) %G%
+ *     @(#)iso_proto.c 7.9 (Berkeley) %G%
  */
 
 /***********************************************************
  */
 
 /***********************************************************
@@ -60,7 +60,7 @@ int   tp_ctloutput();
 int    tpclnp_ctlinput();
 int    tpclnp_input();
 int    tp_usrreq();
 int    tpclnp_ctlinput();
 int    tpclnp_input();
 int    tp_usrreq();
-int    tp_init(), tp_slowtimo(), tp_drain();
+int    tp_init(), tp_fasttimo(), tp_slowtimo(), tp_drain();
 int    cons_init(), tpcons_input();
 
 int    esis_input(), esis_ctlinput(), esis_init(), esis_usrreq();
 int    cons_init(), tpcons_input();
 
 int    esis_input(), esis_ctlinput(), esis_init(), esis_usrreq();
@@ -121,7 +121,7 @@ struct protosw isosw[] = {
 { SOCK_SEQPACKET,      &isodomain,     ISOPROTO_TP,            PR_CONNREQUIRED|PR_WANTRCVD,
   tpclnp_input,                0,                      tpclnp_ctlinput,        tp_ctloutput,
   tp_usrreq,
 { SOCK_SEQPACKET,      &isodomain,     ISOPROTO_TP,            PR_CONNREQUIRED|PR_WANTRCVD,
   tpclnp_input,                0,                      tpclnp_ctlinput,        tp_ctloutput,
   tp_usrreq,
-  tp_init,                     0,                      tp_slowtimo,            tp_drain,
+  tp_init,                     tp_fasttimo,                    tp_slowtimo,            tp_drain,
 },
 
 #ifdef TPCONS
 },
 
 #ifdef TPCONS
index f8e8953..dae91ad 100644 (file)
@@ -5,7 +5,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tp.trans    7.12 (Berkeley) %G%
+ *     @(#)tp.trans    7.13 (Berkeley) %G%
  */
 
 /***********************************************************
  */
 
 /***********************************************************
@@ -59,7 +59,7 @@ SOFTWARE.
 
 *INCLUDE
 {
 
 *INCLUDE
 {
-/* @(#)tp.trans        7.12 (Berkeley) %G% */
+/* @(#)tp.trans        7.13 (Berkeley) %G% */
 #include "param.h"
 #include "socket.h"
 #include "socketvar.h"
 #include "param.h"
 #include "socket.h"
 #include "socketvar.h"
@@ -1319,19 +1319,20 @@ SAME                    <==             TP_OPEN                                                                         T_USR_rcvd
        DEFAULT
        {       
                if( trick_hc ) {
        DEFAULT
        {       
                if( trick_hc ) {
-
-                       LOCAL_CREDIT($P);
+                       SeqNum ack_thresh;
                        /*
                        /*
-                        * If the window is now closed or has only
-                        * one slot left and an ACK will increase this (local
-                        * credit is greater than or equal to 1) send an AK
-                        * here. Otherwise, we will wait for more data or
-                        * the ack timer to fire.
+                        * If the upper window edge has advanced a reasonable
+                        * amount beyond what was known, send an ACK.
+                        * A reasonable amount is 2 packets, unless the max window
+                        * is only 1 or 2 packets, in which case we
+                        * should send an ack for any advance in the upper window edge.
                         */
                         */
-#define CREDIT_SMALL 1
-                       if (SEQ_GEQ($P, $P.tp_rcvnxt, $P.tp_sent_uwe) &&
-                               $P.tp_lcredit > CREDIT_SMALL) {
+                       LOCAL_CREDIT($P);
+                       ack_thresh = SEQ_SUB($P, $P.tp_lcredit + $P.tp_rcvnxt,
+                                                                        ($P.tp_maxlcredit > 2 ? 2 : 1));
+                       if (SEQ_GT($P, ack_thresh, $P.tp_sent_uwe)) {
                                IncStat(ts_ackreason[_ACK_USRRCV_]);
                                IncStat(ts_ackreason[_ACK_USRRCV_]);
+                               $P.tp_flags &= ~TPF_DELACK;
                                return tp_emit(AK_TPDU_type, $P, $P.tp_rcvnxt, 0, MNULL);
                        }
                }
                                return tp_emit(AK_TPDU_type, $P, $P.tp_rcvnxt, 0, MNULL);
                        }
                }
index fca6df6..7a68387 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tp_stat.h   7.5 (Berkeley) %G%
+ *     @(#)tp_stat.h   7.6 (Berkeley) %G%
  */
 
 /***********************************************************
  */
 
 /***********************************************************
@@ -120,6 +120,8 @@ struct tp_stat {
        u_long  ts_Cset;
        u_long  ts_Ccan_act;
        u_long  ts_Ccan_inact;
        u_long  ts_Cset;
        u_long  ts_Ccan_act;
        u_long  ts_Ccan_inact;
+       u_long  ts_Fdelack;
+       u_long  ts_Fpruned;
 
        u_long  ts_concat_rcvd;
 
 
        u_long  ts_concat_rcvd;
 
index 8eaa1cc..f864856 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tp_subr.c   7.12 (Berkeley) %G%
+ *     @(#)tp_subr.c   7.13 (Berkeley) %G%
  */
 
 /***********************************************************
  */
 
 /***********************************************************
@@ -676,7 +676,7 @@ tp_stash( tpcb, e )
                        E.e_seq, (u_int)PStat(tpcb, Nb_from_ll), (u_int)E.e_datalen);
        ENDPERF
 
                        E.e_seq, (u_int)PStat(tpcb, Nb_from_ll), (u_int)E.e_datalen);
        ENDPERF
 
-       if( E.e_seq == tpcb->tp_rcvnxt ) {
+       if (E.e_seq == tpcb->tp_rcvnxt) {
 
                IFDEBUG(D_STASH)
                        printf("stash EQ: seq 0x%x datalen 0x%x eot 0x%x\n", 
 
                IFDEBUG(D_STASH)
                        printf("stash EQ: seq 0x%x datalen 0x%x eot 0x%x\n", 
@@ -688,6 +688,8 @@ tp_stash( tpcb, e )
                        E.e_seq, E.e_datalen, E.e_eot, 0);
                ENDTRACE
 
                        E.e_seq, E.e_datalen, E.e_eot, 0);
                ENDTRACE
 
+               SET_DELACK(tpcb);
+
                sbappend(&tpcb->tp_sock->so_rcv, E.e_data);
 
                SEQ_INC( tpcb, tpcb->tp_rcvnxt );
                sbappend(&tpcb->tp_sock->so_rcv, E.e_data);
 
                SEQ_INC( tpcb, tpcb->tp_rcvnxt );
@@ -751,25 +753,7 @@ tp_stash( tpcb, e )
                        ack_reason = ACK_DONT;
                }
        }
                        ack_reason = ACK_DONT;
                }
        }
-       /*
-        * an ack should be sent when at least one of the
-        * following holds:
-        * a) the TPDU that just arrived represents the
-        *    full window last advertised, or
-        * b) when seq X arrives [ where
-        *              X = last_sent_uwe - 1/2 last_lcredit_sent 
-        *              (the packet representing 1/2 the last advertised window) ]
-        *              and lcredit at the time of X arrival >  last_lcredit_sent/2
-        *              In other words, if the last ack sent advertised cdt=8 and uwe = 8
-        *              then when seq 4 arrives I'd like to send a new ack
-        *              iff the credit at the time of 4's arrival is > 4.
-        *              The other end thinks it has cdt of 4 so if local cdt
-        *              is still 4 there's no point in sending an ack, but if
-        *              my credit has increased because the receiver has taken
-        *              some data out of the buffer (soreceive doesn't notify
-        *              me until the SYSTEM CALL finishes), I'd like to tell
-        *              the other end.  
-        */
+       /* there were some comments of historical interest here. */
        {
                LOCAL_CREDIT(tpcb);
 
        {
                LOCAL_CREDIT(tpcb);
 
index 9f0297b..712b368 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tp_timer.c  7.8 (Berkeley) %G%
+ *     @(#)tp_timer.c  7.9 (Berkeley) %G%
  */
 
 /***********************************************************
  */
 
 /***********************************************************
@@ -76,6 +76,7 @@ struct        Ecallout *TP_callout;
 struct tp_ref *tp_ref;
 int            N_TPREF = 127;
 struct tp_refinfo tp_refinfo;
 struct tp_ref *tp_ref;
 int            N_TPREF = 127;
 struct tp_refinfo tp_refinfo;
+struct tp_pcb *tp_ftimeolist = (struct tp_pcb *)&tp_ftimeolist;
 
 /*
  * CALLED FROM:
 
 /*
  * CALLED FROM:
@@ -264,6 +265,33 @@ tp_slowtimo()
        return 0;
 }
 
        return 0;
 }
 
+int
+tp_fasttimo()
+{
+       register struct tp_pcb *t;
+       int s = splnet();
+       struct tp_event         E;
+
+       E.ev_number = TM_sendack;
+       while ((t = tp_ftimeolist) != (struct tp_pcb *)&tp_ftimeolist) {
+               if (t == 0) {
+                       printf("tp_fasttimeo: should panic");
+                       tp_ftimeolist = (struct tp_pcb *)&tp_ftimeolist;
+               } else {
+                       if (t->tp_flags & TPF_DELACK) {
+                               t->tp_flags &= ~TPF_DELACK;
+                               IncStat(ts_Fdelack);
+                               tp_driver(t, &E);
+                               t->tp_refcallout[TM_sendack].c_time = t->tp_keepalive_ticks;
+                       } else
+                               IncStat(ts_Fpruned);
+                       tp_ftimeolist = t->tp_fasttimeo;
+                       t->tp_fasttimeo = 0;
+               }
+       }
+       splx(s);
+}
+
 /*
  * CALLED FROM:
  *  tp.trans, tp_emit()
 /*
  * CALLED FROM:
  *  tp.trans, tp_emit()
index 0a38930..bb09676 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)tp_timer.h  7.5 (Berkeley) %G%
+ *     @(#)tp_timer.h  7.6 (Berkeley) %G%
  */
 
 /***********************************************************
  */
 
 /***********************************************************
@@ -58,4 +58,9 @@ struct        Ccallout {
        int     c_time;         /* incremental time */
 };
 
        int     c_time;         /* incremental time */
 };
 
+#define SET_DELACK(t) {\
+    (t)->tp_flags |= TPF_DELACK; \
+    if ((t)->tp_fasttimeo == 0)\
+       { (t)->tp_fasttimeo = tp_ftimeolist; tp_ftimeolist = (t); } }
+
 #endif __TP_CALLOUT__
 #endif __TP_CALLOUT__