summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2018-10-09 10:03:34 +0200
committerSander Vrijders <[email protected]>2018-10-09 13:04:09 +0200
commit1d4501adf6da8f55dea85c0389b911b24e722620 (patch)
tree80dde95b29d9ef723869fa8f57fde37775781be0 /src
parent664b815345553592b840e6be89384a91f9ee110b (diff)
downloadouroboros-1d4501adf6da8f55dea85c0389b911b24e722620.tar.gz
ouroboros-1d4501adf6da8f55dea85c0389b911b24e722620.zip
lib: Fix initial automated repeat-request
This fixes rudimentary automated repeat-request ARQ to correctly configure the both connection records and use the receiver seqno. The rto variable is moved out of the connection record. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/lib/frct.c20
-rw-r--r--src/lib/rxmwheel.c5
2 files changed, 15 insertions, 10 deletions
diff --git a/src/lib/frct.c b/src/lib/frct.c
index db3572e3..04b8a758 100644
--- a/src/lib/frct.c
+++ b/src/lib/frct.c
@@ -39,7 +39,6 @@ struct frct_cr {
uint8_t cflags;
uint32_t seqno;
- time_t rto; /* ms */
time_t act; /* s */
time_t inact; /* s */
};
@@ -51,6 +50,8 @@ struct frcti {
time_t a;
time_t r;
+ time_t rto; /* ms */
+
struct frct_cr snd_cr;
struct frct_cr rcv_cr;
@@ -61,7 +62,7 @@ struct frcti {
enum frct_flags {
FRCT_DATA = 0x01, /* PDU carries data */
FRCT_DRF = 0x02, /* Data run flag */
- FRCT_ACK = 0x03, /* ACK field valid */
+ FRCT_ACK = 0x04, /* ACK field valid */
FRCT_FC = 0x08, /* FC window valid */
FRCT_RDVZ = 0x10, /* Rendez-vous */
FRCT_MFGM = 0x20, /* More fragments */
@@ -110,10 +111,12 @@ static struct frcti * frcti_create(int fd)
frcti->snd_cr.inact = 3 * delta_t;
frcti->snd_cr.act = now.tv_sec - (frcti->snd_cr.inact + 1);
/* Initial rto. FIXME: recalc using Karn algorithm. */
- frcti->snd_cr.rto = 120;
+ frcti->rto = 120;
- if (ai.flows[fd].spec.loss == 0)
+ if (ai.flows[fd].spec.loss == 0) {
frcti->snd_cr.cflags |= FRCTFRTX;
+ frcti->rcv_cr.cflags |= FRCTFRTX;
+ }
frcti->rcv_cr.inact = 2 * delta_t;
frcti->rcv_cr.act = now.tv_sec - (frcti->rcv_cr.inact + 1);
@@ -243,8 +246,11 @@ static int __frcti_snd(struct frcti * frcti,
snd_cr->lwe++;
} else if (now.tv_sec - rcv_cr->act <= rcv_cr->inact) {
rxmwheel_add(frcti, snd_cr->seqno, sdb);
- pci->flags |= FRCT_ACK;
- pci->ackno = hton32(rcv_cr->lwe);
+ if (rcv_cr->lwe != rcv_cr->seqno) {
+ pci->flags |= FRCT_ACK;
+ pci->ackno = hton32(rcv_cr->seqno);
+ rcv_cr->lwe = rcv_cr->seqno;
+ }
}
snd_cr->seqno++;
@@ -299,7 +305,7 @@ static int __frcti_rcv(struct frcti * frcti,
if (rcv_cr->cflags & FRCTFRTX) {
size_t pos = seqno & (RQ_SIZE - 1);
- if ((seqno - rcv_cr->seqno) > RQ_SIZE /* Out of rq. */
+ if ((seqno - rcv_cr->lwe) > RQ_SIZE /* Out of rq. */
|| frcti->rq[pos] != -1) /* Duplicate in rq. */
goto drop_packet;
/* Queue. */
diff --git a/src/lib/rxmwheel.c b/src/lib/rxmwheel.c
index 697c6a48..69151801 100644
--- a/src/lib/rxmwheel.c
+++ b/src/lib/rxmwheel.c
@@ -201,7 +201,7 @@ static int rxmwheel_move(void)
r->tail = shm_du_buff_tail(sdb);
r->sdb = sdb;
- newtime = ts_to_ms(now) + (snd_cr->rto << ++r->mul);
+ newtime = ts_to_ms(now) + (f->frcti->rto << ++r->mul);
rslot = (newtime >> RXMQ_R) & (RXMQ_SLOTS - 1);
list_add_tail(&r->next, &rw.wheel[rslot]);
@@ -239,8 +239,7 @@ static int rxmwheel_add(struct frcti * frcti,
r->tail = shm_du_buff_tail(sdb);
r->frcti = frcti;
- slot = ((r->t0 + frcti->snd_cr.rto) >> RXMQ_R)
- & (RXMQ_SLOTS - 1);
+ slot = ((r->t0 + frcti->rto) >> RXMQ_R) & (RXMQ_SLOTS - 1);
list_add_tail(&r->next, &rw.wheel[slot]);