diff options
author | Dimitri Staessens <[email protected]> | 2018-10-06 16:39:23 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2018-10-06 17:43:19 +0200 |
commit | 0c1cfca084b0fc6a282f253d6e7c2dad6427de65 (patch) | |
tree | 4aa566103ab4a0837e12b1c999b2e43d00e3dd39 /src/lib | |
parent | 10c0c07265d91dbbadb53b77aa5be8a27b7b3cd0 (diff) | |
download | ouroboros-0c1cfca084b0fc6a282f253d6e7c2dad6427de65.tar.gz ouroboros-0c1cfca084b0fc6a282f253d6e7c2dad6427de65.zip |
lib: Keep track of highest delivered seqno
The FRCT kept only a left window edge in the receiver connection
window, however, it needs to keep track of the left window edge
(highest ACK'd sequence number) and the highest delivered sequence
number, so it can delay ACKs that cannot be piggybacked. TCP
recommends at most 500 ms for delayed ACKs (probably good to keep it
near half of RTO).
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/frct.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/lib/frct.c b/src/lib/frct.c index 424367c3..200a9fe7 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -37,6 +37,7 @@ struct frct_cr { uint32_t rwe; uint8_t cflags; + uint32_t seqno; time_t act; time_t inact; @@ -49,8 +50,6 @@ struct frcti { time_t a; time_t r; - uint32_t seqno; - struct frct_cr snd_cr; struct frct_cr rcv_cr; @@ -236,22 +235,22 @@ static int __frcti_snd(struct frcti * frcti, pci->flags |= FRCT_DATA; /* Set DRF if there are no unacknowledged packets. */ - if (frcti->seqno == snd_cr->lwe) + if (snd_cr->seqno == snd_cr->lwe) pci->flags |= FRCT_DRF; /* Choose a new sequence number if sender inactivity expired. */ if (now.tv_sec - snd_cr->act > snd_cr->inact) { /* There are no unacknowledged packets. */ - assert(frcti->seqno == snd_cr->lwe); + assert(snd_cr->seqno == snd_cr->lwe); #ifdef CONFIG_OUROBOROS_DEBUG - frcti->seqno = 0; + snd_cr->seqno = 0; #else - random_buffer(&frcti->seqno, sizeof(frcti->seqno)); + random_buffer(&snd_cr->seqno, sizeof(snd_cr->seqno)); #endif - frcti->snd_cr.lwe = frcti->seqno; + frcti->snd_cr.lwe = snd_cr->seqno; } - pci->seqno = hton32(frcti->seqno++); + pci->seqno = hton32(snd_cr->seqno++); if (!(snd_cr->cflags & FRCTFRTX)) snd_cr->lwe++; else @@ -294,27 +293,27 @@ static int __frcti_rcv(struct frcti * frcti, if (now.tv_sec - rcv_cr->act > rcv_cr->inact) { /* Inactive receiver, check for DRF. */ if (pci->flags & FRCT_DRF) /* New run. */ - rcv_cr->lwe = seqno; + rcv_cr->seqno = seqno; else goto drop_packet; } - if (seqno == rcv_cr->lwe) { - ++rcv_cr->lwe; + if (seqno == rcv_cr->seqno) { + ++rcv_cr->seqno; } else { /* Out of order. */ - if ((int32_t)(seqno - rcv_cr->lwe) < 0) /* Duplicate. */ + if ((int32_t)(seqno - rcv_cr->seqno) < 0) /* Duplicate. */ goto drop_packet; if (rcv_cr->cflags & FRCTFRTX) { size_t pos = seqno & (RQ_SIZE - 1); - if ((seqno - rcv_cr->lwe) > RQ_SIZE /* Out of rq. */ + if ((seqno - rcv_cr->seqno) > RQ_SIZE /* Out of rq. */ || frcti->rq[pos] != -1) /* Duplicate in rq. */ goto drop_packet; /* Queue. */ frcti->rq[pos] = idx; ret = -EAGAIN; } else { - rcv_cr->lwe = seqno; + rcv_cr->seqno = seqno; } } |