Created
December 4, 2012 00:10
-
-
Save cfpp2p/4199256 to your computer and use it in GitHub Desktop.
pactch to fix selective_ack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- J:/!/svn-uTP/utp.cpp.org Fri Nov 30 20:12:44 2012 | |
+++ J:/!/svn-uTP/utp.cpp Mon Dec 3 22:09:56 2012 | |
@@ -60,6 +60,11 @@ | |
// that hasn't been acked yet | |
#define DUPLICATE_ACKS_BEFORE_RESEND 3 | |
+// maximum number of resends SRS 11-30-2012 | |
+// per BEP29 calculations limit is 2040 if so desired | |
+// RESENDS_MAX_COUNT never allowed to be 0 | |
+#define RESENDS_MAX_COUNT 32 | |
+ | |
#define DELAYED_ACK_BYTE_THRESHOLD 2400 // bytes | |
#define DELAYED_ACK_TIME_THRESHOLD 100 // milliseconds | |
@@ -1499,8 +1504,10 @@ | |
// resends is a stack of sequence numbers we need to resend. Since we | |
// iterate in reverse over the acked packets, at the end, the top packets | |
// are the ones we want to resend | |
- int resends[32]; | |
+ // RESENDS_MAX_COUNT SRS 11-30-2012 | |
+ int resends[RESENDS_MAX_COUNT]; | |
int nr = 0; | |
+ bool filled = false; | |
LOG_UTPV("0x%08x: Got EACK [%032b] base:%u", this, *(uint32*)mask, base); | |
do { | |
@@ -1573,6 +1580,12 @@ | |
count >= DUPLICATE_ACKS_BEFORE_RESEND && | |
duplicate_ack < DUPLICATE_ACKS_BEFORE_RESEND) { | |
resends[nr++] = v; | |
+ if (nr >= RESENDS_MAX_COUNT) { | |
+ // we have filled AT LEAST ONCE so start dumpimg the oldest, one at a time | |
+ // maybe again, as we re-fill | |
+ filled = true; | |
+ nr = 0; | |
+ } | |
LOG_UTPV("0x%08x: no ack for %u", this, v); | |
} else { | |
LOG_UTPV("0x%08x: not resending %u count:%d dup_ack:%u fast_resend_seq_nr:%u", | |
@@ -1580,22 +1593,43 @@ | |
} | |
} while (--bits >= -1); | |
- if (((base - 1 - fast_resend_seq_nr) & ACK_NR_MASK) < 256 && | |
- count >= DUPLICATE_ACKS_BEFORE_RESEND && | |
- duplicate_ack < DUPLICATE_ACKS_BEFORE_RESEND) { | |
+ if (((base - 1 - fast_resend_seq_nr) & ACK_NR_MASK) <= OUTGOING_BUFFER_MAX_SIZE && | |
+ count >= DUPLICATE_ACKS_BEFORE_RESEND) { | |
// if we get enough duplicate acks to start | |
// resending, the first packet we should resend | |
// is base-1 | |
- resends[nr++] = base - 1; | |
+ resends[nr++] = (base - 1) & ACK_NR_MASK; | |
+ if (nr >= RESENDS_MAX_COUNT) { | |
+ // we have totally filled on the very last | |
+ // no need to reset | |
+ // no more new can come in, all previous over-fill gone | |
+ filled = false; | |
+ } | |
} else { | |
- LOG_UTPV("0x%08x: not resending %u count:%d dup_ack:%u fast_resend_seq_nr:%u", | |
- this, base - 1, count, duplicate_ack, fast_resend_seq_nr); | |
+ LOG_UTPV("0x%08x: not resending %u count:%d dup_ack:%u fast_resend_seq_nr:%u nr:%d", | |
+ this, base - 1, count, duplicate_ack, fast_resend_seq_nr, nr); | |
} | |
bool back_off = false; | |
int i = 0; | |
- while (nr > 0) { | |
- uint v = resends[--nr]; | |
+ int bottom = 0; | |
+ int top = nr; | |
+ if ((top == 0) && filled) { | |
+ // exactly completely filled, but nothing pushed into over-fill | |
+ top = RESENDS_MAX_COUNT; | |
+ filled = false; | |
+ } | |
+ while (top > bottom) { | |
+ uint v = resends[--top]; | |
+ | |
+ // maybe next iteration begin to utilize what is left over before the last refill | |
+ if ((top == bottom) && filled) { | |
+ top = RESENDS_MAX_COUNT; | |
+ bottom = nr; | |
+ filled = false; | |
+ // iterate overfill only once at most | |
+ } | |
+ | |
// don't consider the tail of 0:es to be lost packets | |
// only unacked packets with acked packets after should | |
// be considered lost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
either revision will work.