Commit c70109a4 authored by Andreas Schmidt's avatar Andreas Schmidt

Rename forwardPacketTable to deliveredPacketTable

parent f181cf6c
......@@ -9,7 +9,7 @@ add_library(PRRT ../defines.h
../xlap/xlap.c ../xlap/xlap.h
applicationConstraints.c applicationConstraints.h
vdmcode/block_code.c vdmcode/block_code.h
stores/forwardPacketTable.c stores/forwardPacketTable.h
stores/deliveredPacketTable.c stores/deliveredPacketTable.h
stores/lossGatherer.c stores/lossGatherer.h
processes/dataReceiver.c processes/dataReceiver.h
processes/feedbackReceiver.c processes/feedbackReceiver.h
......
......@@ -34,7 +34,7 @@ static void decode_block(PrrtSocket *sock_ptr, PrrtBlock *block) {
while (List_count(block->dataPackets) > 0) {
PrrtPacket *pkt = List_shift(block->dataPackets);
if (PrrtForwardPacketTable_test_set_is_number_relevant(sock_ptr->forwardPacketTable, pkt->sequenceNumber)) {
if (PrrtDeliveredPacketTable_test_set_is_number_relevant(sock_ptr->deliveredPacketTable, pkt->sequenceNumber)) {
PrrtReceiveDataQueue_insert(sock_ptr->receiveDataQueue, pkt);
} else {
PrrtPacket_destroy(pkt);
......@@ -111,13 +111,13 @@ static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct
prrtTimestamp_t now = PrrtClock_get_prrt_time_us(&sock_ptr->clock);
if (is_timeout(now, payload->packetTimeout_us)) {
PrrtForwardPacketTable_test_set_is_number_relevant(sock_ptr->forwardPacketTable, packet->sequenceNumber);
PrrtDeliveredPacketTable_test_set_is_number_relevant(sock_ptr->deliveredPacketTable, packet->sequenceNumber);
// TODO: note this as loss
PrrtPacket_destroy(packet);
debug(DEBUG_RECEIVER, "timeout data packet %u (%lu > %lu)", seqno, (unsigned long) now,
(unsigned long) payload->packetTimeout_us);
} else if (PrrtForwardPacketTable_test_set_is_number_relevant(sock_ptr->forwardPacketTable,
packet->sequenceNumber) ==
} else if (PrrtDeliveredPacketTable_test_set_is_number_relevant(sock_ptr->deliveredPacketTable,
packet->sequenceNumber) ==
false) {
PrrtPacket_destroy(packet);
} else {
......@@ -153,9 +153,9 @@ static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct
static void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet) {
PrrtPacketRedundancyPayload *redundancyPayload = packet->payload;
if (!PrrtForwardPacketTable_test_is_block_relevant(socket->forwardPacketTable,
redundancyPayload->baseSequenceNumber,
redundancyPayload->n)) {
if (!PrrtDeliveredPacketTable_test_is_block_relevant(socket->deliveredPacketTable,
redundancyPayload->baseSequenceNumber,
redundancyPayload->n)) {
PrrtPacket_destroy(packet);
} else {
PrrtBlock *block = PrrtRepairBlockStore_get_block(socket->repairBlockStore,
......
......@@ -16,7 +16,7 @@
#include "processes/dataTransmitter.h"
#include "processes/dataReceiver.h"
#include "processes/feedbackReceiver.h"
#include "stores/forwardPacketTable.h"
#include "stores/deliveredPacketTable.h"
#include "types/packetTimeout.h"
#include "socket.h"
......@@ -70,7 +70,7 @@ PrrtSocket *PrrtSocket_create(const bool is_sender, prrtTimedelta_t target_delay
if (is_sender) {
s->sendDataQueue = Pipe_create();
} else {
s->forwardPacketTable = PrrtForwardPacketTable_create();
s->deliveredPacketTable = PrrtDeliveredPacketTable_create();
s->repairBlockStore = PrrtRepairBlockStore_create();
s->receiveDataQueue = PrrtReceiveDataQueue_create();
......@@ -398,9 +398,9 @@ int PrrtSocket_close(PrrtSocket *s) {
s->receiveDataQueue = NULL;
}
if (s->forwardPacketTable != NULL) {
check(PrrtForwardPacketTable_destroy(s->forwardPacketTable), "Destroy failed.");
s->forwardPacketTable = NULL;
if (s->deliveredPacketTable != NULL) {
check(PrrtDeliveredPacketTable_destroy(s->deliveredPacketTable), "Destroy failed.");
s->deliveredPacketTable = NULL;
}
if (s->packetTimeoutTable != NULL) {
......@@ -496,7 +496,7 @@ bool PrrtSocket_cleanup(PrrtSocket *s) {
prrtSequenceNumber_t lastSequenceNumberBase = (prrtSequenceNumber_t) (last->sequenceNumber -
last->index - 1);
PrrtForwardPacketTable_forward_start(s->forwardPacketTable, lastSequenceNumberBase);
PrrtDeliveredPacketTable_forward_start(s->deliveredPacketTable, lastSequenceNumberBase);
PrrtRepairBlockStore_expire_block_range(s->repairBlockStore, firstSequenceNumberBase,
lastSequenceNumberBase);
......@@ -523,8 +523,8 @@ bool PrrtSocket_cleanup(PrrtSocket *s) {
}
List_destroy(expired_packets);
}
if(s->forwardPacketTable != NULL) {
prrtSequenceNumber_t current_start = s->forwardPacketTable->start;
if(s->deliveredPacketTable != NULL) {
prrtSequenceNumber_t current_start = s->deliveredPacketTable->start;
PrrtRepairBlockStore_expire_block_range(s->repairBlockStore, (prrtSequenceNumber_t) (current_start - SEQNO_SPACE/2),
(prrtSequenceNumber_t) (current_start - 1));
}
......
......@@ -4,13 +4,13 @@
#include <stdatomic.h>
#include "../defines.h"
#include "packet.h"
#include "stores/forwardPacketTable.h"
#include "../util/list.h"
#include "../util/pipe.h"
#include "../util/bptree.h"
#include "channelStateInformation.h"
#include "applicationConstraints.h"
#include "stores/dataPacketStore.h"
#include "stores/deliveredPacketTable.h"
#include "stores/packetTimeoutTable.h"
#include "stores/repairBlockStore.h"
#include "stores/receiveDataQueue.h"
......@@ -45,7 +45,7 @@ typedef struct prrtSocket {
PrrtDataPacketStore *dataPacketStore;
PrrtRepairBlockStore *repairBlockStore;
PrrtForwardPacketTable *forwardPacketTable;
PrrtDeliveredPacketTable *deliveredPacketTable;
PrrtReceiver* receiver;
......
......@@ -3,10 +3,10 @@
#include "../../util/dbg.h"
#include "../../defines.h"
#include "../packet.h"
#include "forwardPacketTable.h"
#include "deliveredPacketTable.h"
static bool is_position_relevant(const PrrtForwardPacketTable *fpt_ptr, prrtSequenceNumber_t seqno)
static bool is_position_relevant(const PrrtDeliveredPacketTable *fpt_ptr, prrtSequenceNumber_t seqno)
{
prrtSequenceNumber_t stop = (prrtSequenceNumber_t) (SEQNO_SPACE / 2 + fpt_ptr->start);
if(fpt_ptr->start < stop && !(fpt_ptr->start <= seqno && seqno <= stop)) {
......@@ -18,7 +18,7 @@ static bool is_position_relevant(const PrrtForwardPacketTable *fpt_ptr, prrtSequ
}
}
static void move_start(PrrtForwardPacketTable *fpt_ptr)
static void move_start(PrrtDeliveredPacketTable *fpt_ptr)
{
prrtSequenceNumber_t seqno = fpt_ptr->start;
......@@ -35,9 +35,9 @@ static void move_start(PrrtForwardPacketTable *fpt_ptr)
fpt_ptr->start = seqno;
}
PrrtForwardPacketTable *PrrtForwardPacketTable_create()
PrrtDeliveredPacketTable *PrrtDeliveredPacketTable_create()
{
PrrtForwardPacketTable *fpt_prt = calloc(1, sizeof(PrrtForwardPacketTable));
PrrtDeliveredPacketTable *fpt_prt = calloc(1, sizeof(PrrtDeliveredPacketTable));
check_mem(fpt_prt);
fpt_prt->start = 1;
fpt_prt->bitmap = Bitmap_create(true, SEQNO_SPACE);
......@@ -48,43 +48,43 @@ PrrtForwardPacketTable *PrrtForwardPacketTable_create()
return NULL;
}
bool PrrtForwardPacketTable_destroy(PrrtForwardPacketTable *fpt_prt)
bool PrrtDeliveredPacketTable_destroy(PrrtDeliveredPacketTable *t)
{
Bitmap_destroy(fpt_prt->bitmap);
free(fpt_prt);
Bitmap_destroy(t->bitmap);
free(t);
return true;
}
bool PrrtForwardPacketTable_test_set_is_number_relevant(PrrtForwardPacketTable *fpt_ptr, prrtSequenceNumber_t seqno)
bool PrrtDeliveredPacketTable_test_set_is_number_relevant(PrrtDeliveredPacketTable *t, prrtSequenceNumber_t seqno)
{
bool res = is_position_relevant(fpt_ptr, seqno);
bool res = is_position_relevant(t, seqno);
if(res) {
Bitmap_set(fpt_ptr->bitmap, seqno, false);
if(seqno == fpt_ptr->start) {
move_start(fpt_ptr);
Bitmap_set(t->bitmap, seqno, false);
if(seqno == t->start) {
move_start(t);
}
}
return res;
}
bool PrrtForwardPacketTable_test_is_block_relevant(PrrtForwardPacketTable *forwardPacketTable,
prrtSequenceNumber_t start,
prrtSequenceNumber_t length)
bool PrrtDeliveredPacketTable_test_is_block_relevant(PrrtDeliveredPacketTable *t,
prrtSequenceNumber_t start,
prrtSequenceNumber_t length)
{
// TODO: implement efficiently
bool res = false;
int i;
for(i = 0; i < length; i++) {
res = res || is_position_relevant(forwardPacketTable, (prrtSequenceNumber_t) (start + i));
res = res || is_position_relevant(t, (prrtSequenceNumber_t) (start + i));
}
return res;
}
void PrrtForwardPacketTable_forward_start(PrrtForwardPacketTable *fpt_ptr, prrtSequenceNumber_t new_start)
void PrrtDeliveredPacketTable_forward_start(PrrtDeliveredPacketTable *fpt_ptr, prrtSequenceNumber_t new_start)
{
prrtSequenceNumber_t seqno = fpt_ptr->start;
......
#ifndef PRRT_DELIVERED_PACKET_TABLE_H
#define PRRT_DELIVERED_PACKET_TABLE_H
#include <stdint.h>
#include <stdbool.h>
#include "../packet.h"
#include "../../util/bitmap.h"
typedef struct {
prrtSequenceNumber_t start;
Bitmap* bitmap;
} PrrtDeliveredPacketTable;
PrrtDeliveredPacketTable * PrrtDeliveredPacketTable_create(void);
bool PrrtDeliveredPacketTable_destroy(PrrtDeliveredPacketTable *t);
bool PrrtDeliveredPacketTable_test_set_is_number_relevant(PrrtDeliveredPacketTable *t, prrtSequenceNumber_t seqno);
bool PrrtDeliveredPacketTable_test_is_block_relevant(PrrtDeliveredPacketTable *t,
prrtSequenceNumber_t start,
prrtSequenceNumber_t length);
void PrrtDeliveredPacketTable_forward_start(PrrtDeliveredPacketTable *fpt_ptr, prrtSequenceNumber_t new_start);
#endif //PRRT_DELIVERED_PACKET_TABLE_H
#ifndef PRRT_FORWARD_PACKET_TABLE_H
#define PRRT_FORWARD_PACKET_TABLE_H
#include <stdint.h>
#include <stdbool.h>
#include "../packet.h"
#include "../../util/bitmap.h"
typedef struct {
prrtSequenceNumber_t start;
Bitmap* bitmap;
} PrrtForwardPacketTable;
PrrtForwardPacketTable * PrrtForwardPacketTable_create(void);
bool PrrtForwardPacketTable_destroy(PrrtForwardPacketTable* fpt_prt);
bool PrrtForwardPacketTable_test_set_is_number_relevant(PrrtForwardPacketTable *fpt_ptr, prrtSequenceNumber_t seqno);
bool PrrtForwardPacketTable_test_is_block_relevant(PrrtForwardPacketTable *forwardPacketTable, prrtSequenceNumber_t start,
prrtSequenceNumber_t length);
void PrrtForwardPacketTable_forward_start(PrrtForwardPacketTable *fpt_ptr, prrtSequenceNumber_t new_start);
#endif //PRRT_FORWARD_PACKET_TABLE_H
......@@ -9,7 +9,7 @@ cdef extern from "proto/applicationConstraints.c":
cdef extern from "proto/stores/dataPacketStore.c":
pass
cdef extern from "proto/stores/forwardPacketTable.c":
cdef extern from "proto/stores/deliveredPacketTable.c":
pass
cdef extern from "proto/stores/lossGatherer.c":
......
add_subdirectory(lib/gtest-1.8.0)
include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_executable(prrtTests bitmap_tests.cpp lossGatherer_tests.cpp forward_packet_table_tests.cpp bptree_tests.cpp PrrtBlock_tests.cpp)
add_executable(prrtTests bitmap_tests.cpp lossGatherer_tests.cpp delivered_packet_table_tests.cpp bptree_tests.cpp PrrtBlock_tests.cpp)
target_link_libraries(prrtTests LINK_PUBLIC gtest PRRT UTIL gtest_main)
\ No newline at end of file
#include <gtest/gtest.h>
#include <cmath>
#include <prrt/proto/packet.h>
extern "C" {
#include "prrt/proto/stores/deliveredPacketTable.h"
}
class DeliveredPacketTableTest : public ::testing::Test {
protected:
virtual void SetUp() {
deliveredPacketTable = PrrtDeliveredPacketTable_create();
}
PrrtDeliveredPacketTable* deliveredPacketTable;
};
TEST_F(DeliveredPacketTableTest, CreateDestroy) {
ASSERT_EQ(deliveredPacketTable->start, 1);
free(deliveredPacketTable);
}
TEST_F(DeliveredPacketTableTest, SimpleTestAndSet) {
for (int i = 1; i < 10; ++i) {
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, i));
ASSERT_FALSE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, i));
}
}
TEST_F(DeliveredPacketTableTest, SimpleMoveStart) {
ASSERT_EQ(deliveredPacketTable->start, 1);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 1));
ASSERT_EQ(deliveredPacketTable->start, 2);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 5));
ASSERT_EQ(deliveredPacketTable->start, 2);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 4));
ASSERT_EQ(deliveredPacketTable->start, 2);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 3));
ASSERT_EQ(deliveredPacketTable->start, 2);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 2));
ASSERT_EQ(deliveredPacketTable->start, 6);
for (int i = 1; i < 6; ++i) {
ASSERT_FALSE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, i));
}
}
TEST_F(DeliveredPacketTableTest, ProperStop) {
prrtSequenceNumber_t seqno = (prrtSequenceNumber_t) (pow(2, 15) + 2);
ASSERT_FALSE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, seqno));
for (int i = 1; i < seqno / 2; ++i) {
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, i));
}
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, seqno));
ASSERT_FALSE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 5));
}
TEST_F(DeliveredPacketTableTest, Sequence) {
ASSERT_EQ(deliveredPacketTable->start, 1);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 4));
ASSERT_EQ(deliveredPacketTable->start, 1);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 7));
ASSERT_EQ(deliveredPacketTable->start, 1);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 1));
ASSERT_EQ(deliveredPacketTable->start, 2);
ASSERT_FALSE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 4));
ASSERT_EQ(deliveredPacketTable->start, 2);
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, 8));
ASSERT_EQ(deliveredPacketTable->start, 2);
}
TEST_F(DeliveredPacketTableTest, ResetToZero) {
for (int i = 1; i < pow(2, 16) + 5; ++i) {
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, i));
ASSERT_FALSE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, i));
}
}
TEST_F(DeliveredPacketTableTest, CheckBlock) {
ASSERT_TRUE(PrrtDeliveredPacketTable_test_is_block_relevant(deliveredPacketTable, 1, 6));
for (int i = 1; i < 7; ++i) {
ASSERT_TRUE(PrrtDeliveredPacketTable_test_set_is_number_relevant(deliveredPacketTable, i));
}
ASSERT_FALSE(PrrtDeliveredPacketTable_test_is_block_relevant(deliveredPacketTable, 1, 6));
}
#include <gtest/gtest.h>
#include <cmath>
#include <prrt/proto/packet.h>
extern "C" {
#include "prrt/proto/stores/forwardPacketTable.h"
}
class ForwardPacketTableTest : public ::testing::Test {
protected:
virtual void SetUp() {
forwardPacketTable = PrrtForwardPacketTable_create();
}
PrrtForwardPacketTable* forwardPacketTable;
};
TEST_F(ForwardPacketTableTest, CreateDestroy) {
ASSERT_EQ(forwardPacketTable->start, 1);
free(forwardPacketTable);
}
TEST_F(ForwardPacketTableTest, SimpleTestAndSet) {
for (int i = 1; i < 10; ++i) {
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, i));
ASSERT_FALSE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, i));
}
}
TEST_F(ForwardPacketTableTest, SimpleMoveStart) {
ASSERT_EQ(forwardPacketTable->start, 1);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 1));
ASSERT_EQ(forwardPacketTable->start, 2);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 5));
ASSERT_EQ(forwardPacketTable->start, 2);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 4));
ASSERT_EQ(forwardPacketTable->start, 2);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 3));
ASSERT_EQ(forwardPacketTable->start, 2);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 2));
ASSERT_EQ(forwardPacketTable->start, 6);
for (int i = 1; i < 6; ++i) {
ASSERT_FALSE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, i));
}
}
TEST_F(ForwardPacketTableTest, ProperStop) {
prrtSequenceNumber_t seqno = (prrtSequenceNumber_t) (pow(2, 15) + 2);
ASSERT_FALSE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, seqno));
for (int i = 1; i < seqno / 2; ++i) {
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, i));
}
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, seqno));
ASSERT_FALSE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 5));
}
TEST_F(ForwardPacketTableTest, Sequence) {
ASSERT_EQ(forwardPacketTable->start, 1);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 4));
ASSERT_EQ(forwardPacketTable->start, 1);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 7));
ASSERT_EQ(forwardPacketTable->start, 1);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 1));
ASSERT_EQ(forwardPacketTable->start, 2);
ASSERT_FALSE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 4));
ASSERT_EQ(forwardPacketTable->start, 2);
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, 8));
ASSERT_EQ(forwardPacketTable->start, 2);
}
TEST_F(ForwardPacketTableTest, ResetToZero) {
for (int i = 1; i < pow(2, 16) + 5; ++i) {
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, i));
ASSERT_FALSE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, i));
}
}
TEST_F(ForwardPacketTableTest, CheckBlock) {
ASSERT_TRUE(PrrtForwardPacketTable_test_is_block_relevant(forwardPacketTable, 1, 6));
for (int i = 1; i < 7; ++i) {
ASSERT_TRUE(PrrtForwardPacketTable_test_set_is_number_relevant(forwardPacketTable, i));
}
ASSERT_FALSE(PrrtForwardPacketTable_test_is_block_relevant(forwardPacketTable, 1, 6));
}
Markdown is supported
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