Commit 03073905 authored by Kai Vogelgesang's avatar Kai Vogelgesang
Browse files

Update ReceptionTable to use timestamp of when the packet was received

parent f9de22d7
......@@ -136,10 +136,11 @@ static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet) {
PrrtPacketTimeout *packetTimeout = PrrtPacketTimeout_create(packet);
check(PrrtPacketTimeoutTable_insert(sock_ptr->packetTimeoutTable, packetTimeout), "Could not insert data packet.");
prrtTimestamp_t now = PrrtClock_get_prrt_time_us(&sock_ptr->clock);
prrtSequenceNumber_t seqno = packet->sequenceNumber;
PrrtReceptionTable_mark_received(sock_ptr->dataReceptionTable, seqno, sentTimestamp);
PrrtReceptionTable_mark_received(sock_ptr->dataReceptionTable, seqno, sentTimestamp, now);
prrtTimestamp_t now = PrrtClock_get_prrt_time_us(&sock_ptr->clock);
if (is_timeout(now, payload->packetTimeout_us)) {
PrrtDeliveredPacketTable_test_set_is_number_relevant(sock_ptr->deliveredPacketTable, packet->sequenceNumber);
PrrtPacket_destroy(packet);
......@@ -179,8 +180,9 @@ static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet) {
static void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet) {
PrrtPacketRedundancyPayload *redundancyPayload = packet->payload;
prrtTimestamp_t now = PrrtClock_get_prrt_time_us(&socket->clock);
PrrtReceptionTable_mark_received(socket->redundancyReceptionTable, packet->sequenceNumber, redundancyPayload->timestamp);
PrrtReceptionTable_mark_received(socket->redundancyReceptionTable, packet->sequenceNumber, redundancyPayload->timestamp, now);
if (!PrrtDeliveredPacketTable_test_is_block_relevant(socket->deliveredPacketTable,
redundancyPayload->baseSequenceNumber,
......
......@@ -36,11 +36,13 @@ bool PrrtReceptionTable_destroy(PrrtReceptionTable *t) {
return false;
}
bool PrrtReceptionTable_mark_received(PrrtReceptionTable *t, prrtSequenceNumber_t markedNumber, prrtTimestamp_t timestamp) {
bool PrrtReceptionTable_mark_received(PrrtReceptionTable *t, prrtSequenceNumber_t markedNumber, prrtTimestamp_t t_send, prrtTimestamp_t t_recv) {
check(pthread_mutex_lock(&t->lock) == EXIT_SUCCESS, "Lock failed.");
(void) t_send; // unused
// a bit hacky, but faster than malloc/free every time
t->tree = BPTree_insert(t->tree, timestamp, (void*) markedNumber);
t->tree = BPTree_insert(t->tree, t_recv, (void*) markedNumber);
if (markedNumber - t->start > t->windowSize / 2) {
prrtTimestamp_t new_start = markedNumber - t->windowSize / 2;
......@@ -62,6 +64,10 @@ PrrtLossStatistics PrrtReceptionTable_calculate_statistics(PrrtReceptionTable *t
check(pthread_mutex_lock(&t->lock) == EXIT_SUCCESS, "Lock failed.");
List *list = List_create();
if (end < start) {
BPTree_get_range(t->tree, list, start, MAX_TIMESTAMP);
start = 0;
}
BPTree_get_range(t->tree, list, start, end);
if (List_count(list) < 1) {
......@@ -100,9 +106,8 @@ PrrtLossStatistics PrrtReceptionTable_calculate_statistics(PrrtReceptionTable *t
statistics.erasureCount += curr_seqno - prev_seqno - 1;
++statistics.gapCount;
++statistics.burstCount;
} else {
++statistics.burstLength;
}
++statistics.burstLength;
prev_seqno = curr_seqno;
}
......
......@@ -16,7 +16,7 @@ typedef struct {
} PrrtReceptionTable;
PrrtReceptionTable * PrrtReceptionTable_create(void);
bool PrrtReceptionTable_mark_received(PrrtReceptionTable* t, prrtSequenceNumber_t markedNumber, prrtTimestamp_t timestamp);
bool PrrtReceptionTable_mark_received(PrrtReceptionTable* t, prrtSequenceNumber_t markedNumber, prrtTimestamp_t t_send, prrtTimestamp_t t_recv);
PrrtLossStatistics PrrtReceptionTable_calculate_statistics(PrrtReceptionTable *lossGatherer, prrtTimestamp_t start, prrtTimestamp_t end);
bool PrrtReceptionTable_destroy(PrrtReceptionTable * t);
......
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