Commit 2624dda2 authored by Stefan Reif's avatar Stefan Reif

Need proper timeout detection

It is possible that the timeout value overflows, and then, the 'now'
timestamp is always larger than the packet timeout. We need a proper
timeout detection.
parent efca654a
......@@ -437,6 +437,7 @@ PrrtPacket *PrrtPacket_create_data_packet(uint8_t priority, const void *payloadP
dataPayload->timestamp = PrrtClock_get_current_time_us();
dataPayload->packetTimeout_us = dataPayload->timestamp + targetDelay;
debug(DEBUG_PACKET, "timeout = %lu + %lu", (unsigned long) dataPayload->timestamp, (unsigned long) targetDelay);
dataPayload->groupRTT_us = 0;
dataPayload->decodingTimeout_us = 150; // TODO: payload->decodingTimeout_us
dataPayload->feedbackTimer_us = 170; // TODO: payload->feedback_timer
......
......@@ -94,6 +94,12 @@ static bool send_feedback(const PrrtSocket *sock_ptr, struct sockaddr_in remote)
return false;
}
static bool is_timeout(prrtTimestamp_t now, prrtTimestamp_t to)
{
/* TODO: implement */
return false;
}
static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct sockaddr_in remote)
{
PrrtPacketDataPayload *payload = packet->payload;
......@@ -111,10 +117,11 @@ static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct
PrrtTimeStampCycle(sock_ptr, ts_data_packet, seqno, SendFeedbackEnd);
prrtTimestamp_t now = PrrtClock_get_prrt_time_us(&sock_ptr->clock);
if(now > payload->packetTimeout_us) {
if(is_timeout(now, payload->packetTimeout_us)) {
PrrtForwardPacketTable_test_set_is_number_relevant(sock_ptr->forwardPacketTable, 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) ==
......
......@@ -10,6 +10,7 @@
#define DEBUG_ALL 0
#define DEBUG_BLOCK 0
#define DEBUG_PACKET 1
#define DEBUG_RECEIVER 1
#define DEBUG_SENDER 0
#define DEBUG_SOCKET 1
......
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