mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
Only use the best rtt calculation once per ack
This commit is contained in:
parent
55db779f8c
commit
5b6ae35a73
@ -554,6 +554,8 @@ int overlay_queue_ack(struct subscriber *neighbour, struct network_destination *
|
|||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
time_ms_t now = gettime_ms();
|
time_ms_t now = gettime_ms();
|
||||||
|
int rtt=0;
|
||||||
|
|
||||||
for (i=0;i<OQ_MAX;i++){
|
for (i=0;i<OQ_MAX;i++){
|
||||||
struct overlay_frame *frame = overlay_tx[i].first;
|
struct overlay_frame *frame = overlay_tx[i].first;
|
||||||
|
|
||||||
@ -570,21 +572,12 @@ int overlay_queue_ack(struct subscriber *neighbour, struct network_destination *
|
|||||||
char acked = (seq_delta==0 || (seq_delta <= 32 && ack_mask&(1<<(seq_delta-1))))?1:0;
|
char acked = (seq_delta==0 || (seq_delta <= 32 && ack_mask&(1<<(seq_delta-1))))?1:0;
|
||||||
|
|
||||||
if (acked){
|
if (acked){
|
||||||
int rtt = now - frame->destinations[j].transmit_time;
|
int this_rtt = now - frame->destinations[j].transmit_time;
|
||||||
// if we're on a fake network, the actual rtt can be unrealistic
|
// if we're on a fake network, the actual rtt can be unrealistic
|
||||||
if (rtt <5)
|
if (this_rtt < 10)
|
||||||
rtt=5;
|
this_rtt = 10;
|
||||||
if (!destination->min_rtt || rtt < destination->min_rtt){
|
if (!rtt || this_rtt < rtt)
|
||||||
destination->min_rtt = rtt;
|
rtt = this_rtt;
|
||||||
int delay = rtt * 2 + 40;
|
|
||||||
if (delay < destination->resend_delay){
|
|
||||||
destination->resend_delay = delay;
|
|
||||||
if (config.debug.linkstate)
|
|
||||||
DEBUGF("Adjusting resend delay to %d", destination->resend_delay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!destination->max_rtt || rtt > destination->max_rtt)
|
|
||||||
destination->max_rtt = rtt;
|
|
||||||
|
|
||||||
if (config.debug.ack)
|
if (config.debug.ack)
|
||||||
DEBUGF("DROPPED DUE TO ACK: Packet %p to %s sent by seq %d, acked with seq %d",
|
DEBUGF("DROPPED DUE TO ACK: Packet %p to %s sent by seq %d, acked with seq %d",
|
||||||
@ -610,5 +603,19 @@ int overlay_queue_ack(struct subscriber *neighbour, struct network_destination *
|
|||||||
frame = frame->next;
|
frame = frame->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rtt){
|
||||||
|
if (!destination->min_rtt || rtt < destination->min_rtt){
|
||||||
|
destination->min_rtt = rtt;
|
||||||
|
int delay = rtt * 2 + 40;
|
||||||
|
if (delay < destination->resend_delay){
|
||||||
|
destination->resend_delay = delay;
|
||||||
|
if (config.debug.linkstate)
|
||||||
|
DEBUGF("Adjusting resend delay to %d", destination->resend_delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!destination->max_rtt || rtt > destination->max_rtt)
|
||||||
|
destination->max_rtt = rtt;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user