Commit dd704aab authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Fix non-zero error rate if redundancy is off.

parent 17917a5f
......@@ -7,7 +7,7 @@ PrrtReceptionTable *PrrtReceptionTable_create(void) {
PrrtReceptionTable* t = calloc(1, sizeof(PrrtReceptionTable));
check_mem(t);
t->start = 0;
t->maxNumberInWindow = 0;
t->nextNumberAfterWindow = 0;
t->windowSize = 1000;
t->bitmap = Bitmap_create(false, SEQNO_SPACE);
......@@ -33,12 +33,12 @@ bool PrrtReceptionTable_destroy(PrrtReceptionTable *t) {
bool PrrtReceptionTable_mark_received(PrrtReceptionTable *t, prrtSequenceNumber_t markedNumber) {
check(pthread_mutex_lock(&t->lock) == EXIT_SUCCESS, "Lock failed.");
prrtSequenceNumber_t markedNumber_relative = (prrtSequenceNumber_t) (markedNumber - t->start);
prrtSequenceNumber_t maxNumberInWindow_relative = (prrtSequenceNumber_t) (t->maxNumberInWindow - t->start);
prrtSequenceNumber_t maxNumberInWindow_relative = (prrtSequenceNumber_t) (t->nextNumberAfterWindow - t->start);
if (markedNumber_relative < t->windowSize) {
Bitmap_set_1(t->bitmap, markedNumber);
if(markedNumber_relative > maxNumberInWindow_relative) {
t->maxNumberInWindow = markedNumber;
t->nextNumberAfterWindow = (prrtSequenceNumber_t) (markedNumber + 1);
}
}
......@@ -58,7 +58,16 @@ bool PrrtReceptionTable_mark_received(PrrtReceptionTable *t, prrtSequenceNumber_
PrrtLossStatistics PrrtReceptionTable_calculate_statistics(PrrtReceptionTable *t) {
check(pthread_mutex_lock(&t->lock) == EXIT_SUCCESS, "Lock failed.");
prrtSequenceNumber_t length = (prrtSequenceNumber_t) ((t->maxNumberInWindow - t->start) + 1);
if(t->nextNumberAfterWindow == t->start) {
return (PrrtLossStatistics) {
.erasureCount = 0,
.packetCount = 0,
.gapCount = 0,
.burstCount = 0,
};
}
prrtSequenceNumber_t length = (prrtSequenceNumber_t) ((t->nextNumberAfterWindow - t->start));
bool x0 = Bitmap_get(t->bitmap, t->start) == false;
PrrtLossStatistics statistics = {
.erasureCount = (uint16_t) x0,
......
......@@ -11,7 +11,7 @@
typedef struct {
prrtSequenceNumber_t start;
Bitmap* bitmap;
prrtSequenceNumber_t maxNumberInWindow;
prrtSequenceNumber_t nextNumberAfterWindow;
prrtSequenceNumber_t windowSize;
pthread_mutex_t lock;
} PrrtReceptionTable;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment