Commit abd17460 authored by Andreas Schmidt's avatar Andreas Schmidt

Streamline headers, dropping unnecessary fields.

Proper feedback sequence numbers.
parent ddf7d8de
Pipeline #1742 failed with stages
in 1 minute and 16 seconds
...@@ -54,10 +54,6 @@ int PrrtPacket_print(PrrtPacket *packet_ptr) { ...@@ -54,10 +54,6 @@ int PrrtPacket_print(PrrtPacket *packet_ptr) {
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"); printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %61u |\n", payload->packetTimeout_us); printf("| %61u |\n", payload->packetTimeout_us);
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"); printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %61u |\n", payload->decodingTimeout_us);
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %61u |\n", payload->feedbackTimer_us);
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %61s |\n", (char *) (packet_ptr->payload + PRRT_PACKET_DATA_HEADER_SIZE)); printf("| %61s |\n", (char *) (packet_ptr->payload + PRRT_PACKET_DATA_HEADER_SIZE));
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"); printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
} else if (type == PACKET_TYPE_REDUNDANCY) { } else if (type == PACKET_TYPE_REDUNDANCY) {
...@@ -69,12 +65,6 @@ int PrrtPacket_print(PrrtPacket *packet_ptr) { ...@@ -69,12 +65,6 @@ int PrrtPacket_print(PrrtPacket *packet_ptr) {
PrrtPacketFeedbackPayload *payload = packet_ptr->payload; PrrtPacketFeedbackPayload *payload = packet_ptr->payload;
struct sockaddr_in receiver;
receiver.sin_addr.s_addr = payload->receiverAddress;
char *address = inet_ntoa(receiver.sin_addr);
printf("| %61s |\n", address);
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %61u |\n", payload->groupRTT_us); printf("| %61u |\n", payload->groupRTT_us);
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"); printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %61u |\n", payload->forwardTripTimestamp_us); printf("| %61u |\n", payload->forwardTripTimestamp_us);
...@@ -85,8 +75,6 @@ int PrrtPacket_print(PrrtPacket *packet_ptr) { ...@@ -85,8 +75,6 @@ int PrrtPacket_print(PrrtPacket *packet_ptr) {
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"); printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %29u | %29u |\n", payload->burstLength, payload->burstCount); printf("| %29u | %29u |\n", payload->burstLength, payload->burstCount);
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"); printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf("| %61u |\n", payload->bandwidthEstimate);
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
prrtPacketLength_t remainingSpace = ((prrtPacketLength_t) (packet_ptr->payloadLength - prrtPacketLength_t remainingSpace = ((prrtPacketLength_t) (packet_ptr->payloadLength -
PRRT_PACKET_FEEDBACK_HEADER_SIZE)); PRRT_PACKET_FEEDBACK_HEADER_SIZE));
...@@ -191,10 +179,6 @@ void *encode_redundancy_header(void *buf_ptr, const void *payload) { ...@@ -191,10 +179,6 @@ void *encode_redundancy_header(void *buf_ptr, const void *payload) {
void *encode_feedback_header(void *buf_ptr, const void *payload) { void *encode_feedback_header(void *buf_ptr, const void *payload) {
const PrrtPacketFeedbackPayload *feedbackPayload = payload; const PrrtPacketFeedbackPayload *feedbackPayload = payload;
uint32_t *receiverAddress = (uint32_t *) buf_ptr;
*receiverAddress = feedbackPayload->receiverAddress;
buf_ptr += sizeof(uint32_t);
prrtTimedelta_t *groupRoundTripTime = (prrtTimedelta_t *) buf_ptr; prrtTimedelta_t *groupRoundTripTime = (prrtTimedelta_t *) buf_ptr;
*groupRoundTripTime = htonl(feedbackPayload->groupRTT_us); *groupRoundTripTime = htonl(feedbackPayload->groupRTT_us);
buf_ptr += sizeof(prrtTimedelta_t); buf_ptr += sizeof(prrtTimedelta_t);
...@@ -227,10 +211,6 @@ void *encode_feedback_header(void *buf_ptr, const void *payload) { ...@@ -227,10 +211,6 @@ void *encode_feedback_header(void *buf_ptr, const void *payload) {
*burstCount = htons(feedbackPayload->burstCount); *burstCount = htons(feedbackPayload->burstCount);
buf_ptr += sizeof(prrtSequenceNumber_t); buf_ptr += sizeof(prrtSequenceNumber_t);
uint32_t *bandwidth_estimate = (uint32_t *) buf_ptr;
*bandwidth_estimate = htonl(feedbackPayload->bandwidthEstimate);
buf_ptr += sizeof(uint32_t);
// TODO: encode variable number of incomplete blocks // TODO: encode variable number of incomplete blocks
return buf_ptr; return buf_ptr;
} }
...@@ -254,13 +234,6 @@ void *encode_data_header(void *buf_ptr, const void *payload) { ...@@ -254,13 +234,6 @@ void *encode_data_header(void *buf_ptr, const void *payload) {
*packet_timeout = htonl(data_payload->packetTimeout_us); *packet_timeout = htonl(data_payload->packetTimeout_us);
buf_ptr += sizeof(prrtTimedelta_t); buf_ptr += sizeof(prrtTimedelta_t);
prrtTimedelta_t *decoding_timeout = (prrtTimedelta_t *) buf_ptr;
*decoding_timeout = htonl(data_payload->decodingTimeout_us);
buf_ptr += sizeof(prrtTimedelta_t);
prrtTimedelta_t *feedback_timeout = (prrtTimedelta_t *) buf_ptr;
*feedback_timeout = htonl(data_payload->feedbackTimer_us);
buf_ptr += sizeof(prrtTimedelta_t);
return buf_ptr; return buf_ptr;
} }
...@@ -336,10 +309,6 @@ void *decode_redundancy_header(void *dstBuffer, const void *srcBuffer) { ...@@ -336,10 +309,6 @@ void *decode_redundancy_header(void *dstBuffer, const void *srcBuffer) {
void *decode_feedback_header(void *dstBuffer, const void *srcBuffer) { void *decode_feedback_header(void *dstBuffer, const void *srcBuffer) {
PrrtPacketFeedbackPayload *feedback_payload = (PrrtPacketFeedbackPayload *) srcBuffer; PrrtPacketFeedbackPayload *feedback_payload = (PrrtPacketFeedbackPayload *) srcBuffer;
uint32_t *receiverAddr = (uint32_t *) dstBuffer;
feedback_payload->receiverAddress = *receiverAddr;
dstBuffer += sizeof(uint32_t);
prrtTimedelta_t *groupRoundTripTime = (prrtTimedelta_t *) dstBuffer; prrtTimedelta_t *groupRoundTripTime = (prrtTimedelta_t *) dstBuffer;
feedback_payload->groupRTT_us = ntohl(*groupRoundTripTime); feedback_payload->groupRTT_us = ntohl(*groupRoundTripTime);
dstBuffer += sizeof(prrtTimedelta_t); dstBuffer += sizeof(prrtTimedelta_t);
...@@ -372,10 +341,6 @@ void *decode_feedback_header(void *dstBuffer, const void *srcBuffer) { ...@@ -372,10 +341,6 @@ void *decode_feedback_header(void *dstBuffer, const void *srcBuffer) {
feedback_payload->burstCount = ntohs(*nburst); feedback_payload->burstCount = ntohs(*nburst);
dstBuffer += sizeof(prrtSequenceNumber_t); dstBuffer += sizeof(prrtSequenceNumber_t);
uint32_t *bandwidthEstimate = (uint32_t *) dstBuffer;
feedback_payload->bandwidthEstimate = ntohl(*bandwidthEstimate);
dstBuffer += sizeof(uint32_t);
// TODO: decode variable number of incomplete blocks // TODO: decode variable number of incomplete blocks
return dstBuffer; return dstBuffer;
} }
...@@ -399,13 +364,6 @@ void *decode_data_header(void *dstBuffer, const void *srcBuffer) { ...@@ -399,13 +364,6 @@ void *decode_data_header(void *dstBuffer, const void *srcBuffer) {
data_payload->packetTimeout_us = ntohl(*packet_timeout); data_payload->packetTimeout_us = ntohl(*packet_timeout);
dstBuffer += sizeof(prrtTimedelta_t); dstBuffer += sizeof(prrtTimedelta_t);
prrtTimedelta_t *decoding_timeout = (prrtTimedelta_t *) dstBuffer;
data_payload->decodingTimeout_us = ntohl(*decoding_timeout);
dstBuffer += sizeof(prrtTimedelta_t);
prrtTimedelta_t *feedback_timeout = (prrtTimedelta_t *) dstBuffer;
data_payload->feedbackTimer_us = ntohl(*feedback_timeout);
dstBuffer += sizeof(prrtTimedelta_t);
return dstBuffer; return dstBuffer;
} }
...@@ -432,8 +390,6 @@ PrrtPacket *PrrtPacket_create_data_packet(uint8_t priority, const void *payloadP ...@@ -432,8 +390,6 @@ PrrtPacket *PrrtPacket_create_data_packet(uint8_t priority, const void *payloadP
dataPayload->timestamp = PrrtClock_get_current_time_us(); dataPayload->timestamp = PrrtClock_get_current_time_us();
dataPayload->packetTimeout_us = dataPayload->timestamp + targetDelay; dataPayload->packetTimeout_us = dataPayload->timestamp + targetDelay;
dataPayload->groupRTprop_us = 0; dataPayload->groupRTprop_us = 0;
dataPayload->decodingTimeout_us = 150; // TODO: payload->decodingTimeout_us
dataPayload->feedbackTimer_us = 170; // TODO: payload->feedback_timer
PrrtPacket_copy_buffer_to_payload(packet, payloadPointer, PRRT_PACKET_DATA_HEADER_SIZE) PrrtPacket_copy_buffer_to_payload(packet, payloadPointer, PRRT_PACKET_DATA_HEADER_SIZE)
return packet; return packet;
...@@ -489,20 +445,18 @@ PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadP ...@@ -489,20 +445,18 @@ PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadP
return NULL; return NULL;
} }
PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, prrtSequenceNumber_t sequenceNumber, PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, prrtSequenceNumber_t sequenceNumber, prrtTimedelta_t groupRTT,
prrtTimedelta_t groupRTT, prrtSequenceNumber_t gapLength, prrtSequenceNumber_t gapLength, prrtSequenceNumber_t gapCount,
prrtSequenceNumber_t gapCount, prrtSequenceNumber_t burstLength, prrtSequenceNumber_t burstLength, prrtSequenceNumber_t burstCount,
prrtSequenceNumber_t burstCount, uint32_t bandwidth, prrtTimestamp_t forwardTripTime, prrtSequenceNumber_t erasureCount,
uint32_t receiverAddr, prrtTimestamp_t forwardTripTime, prrtSequenceNumber_t packetCount) {
prrtSequenceNumber_t erasureCount, prrtSequenceNumber_t packetCount) {
PrrtPacket *packet = create_header(priority, sequenceNumber, PRRT_PACKET_FEEDBACK_HEADER_SIZE, PACKET_TYPE_FEEDBACK, PrrtPacket *packet = create_header(priority, sequenceNumber, PRRT_PACKET_FEEDBACK_HEADER_SIZE, PACKET_TYPE_FEEDBACK,
index); 0);
PrrtPacketFeedbackPayload *payload = calloc(1, packet->payloadLength); PrrtPacketFeedbackPayload *payload = calloc(1, packet->payloadLength);
check_mem(payload); check_mem(payload);
packet->payload = payload; packet->payload = payload;
payload->receiverAddress = receiverAddr;
payload->groupRTT_us = groupRTT; payload->groupRTT_us = groupRTT;
payload->forwardTripTimestamp_us = forwardTripTime; payload->forwardTripTimestamp_us = forwardTripTime;
payload->erasureCount = erasureCount; payload->erasureCount = erasureCount;
...@@ -511,9 +465,8 @@ PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, p ...@@ -511,9 +465,8 @@ PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, p
payload->gapCount = gapCount; payload->gapCount = gapCount;
payload->burstLength = burstLength; payload->burstLength = burstLength;
payload->burstCount = burstCount; payload->burstCount = burstCount;
payload->bandwidthEstimate = bandwidth;
// TODO: insert incomplete blocks // TODO: Acknowledged packet.
return packet; return packet;
......
...@@ -45,8 +45,6 @@ typedef struct prrtPacketDataPayload { ...@@ -45,8 +45,6 @@ typedef struct prrtPacketDataPayload {
prrtTimestamp_t timestamp; prrtTimestamp_t timestamp;
prrtTimedelta_t groupRTprop_us; prrtTimedelta_t groupRTprop_us;
prrtTimestamp_t packetTimeout_us; prrtTimestamp_t packetTimeout_us;
prrtTimestamp_t decodingTimeout_us;
prrtTimedelta_t feedbackTimer_us;
} PrrtPacketDataPayload; } PrrtPacketDataPayload;
#define PRRT_PACKET_DATA_HEADER_SIZE sizeof(PrrtPacketDataPayload) #define PRRT_PACKET_DATA_HEADER_SIZE sizeof(PrrtPacketDataPayload)
...@@ -58,7 +56,6 @@ typedef struct prrtPacketRedundancyPayload { ...@@ -58,7 +56,6 @@ typedef struct prrtPacketRedundancyPayload {
#define PRRT_PACKET_REDUNDANCY_HEADER_SIZE sizeof(PrrtPacketRedundancyPayload) #define PRRT_PACKET_REDUNDANCY_HEADER_SIZE sizeof(PrrtPacketRedundancyPayload)
typedef struct prrtPacketFeedbackPayload { typedef struct prrtPacketFeedbackPayload {
uint32_t receiverAddress;
prrtTimedelta_t groupRTT_us; prrtTimedelta_t groupRTT_us;
prrtTimestamp_t forwardTripTimestamp_us; prrtTimestamp_t forwardTripTimestamp_us;
prrtSequenceNumber_t erasureCount; prrtSequenceNumber_t erasureCount;
...@@ -67,7 +64,6 @@ typedef struct prrtPacketFeedbackPayload { ...@@ -67,7 +64,6 @@ typedef struct prrtPacketFeedbackPayload {
prrtSequenceNumber_t gapCount; prrtSequenceNumber_t gapCount;
prrtSequenceNumber_t burstLength; prrtSequenceNumber_t burstLength;
prrtSequenceNumber_t burstCount; prrtSequenceNumber_t burstCount;
uint32_t bandwidthEstimate;
PrrtIncompleteBlock *incompleteBlocks; PrrtIncompleteBlock *incompleteBlocks;
} PrrtPacketFeedbackPayload; } PrrtPacketFeedbackPayload;
#define PRRT_PACKET_FEEDBACK_HEADER_SIZE (sizeof(PrrtPacketFeedbackPayload) - sizeof(PrrtIncompleteBlock*)) #define PRRT_PACKET_FEEDBACK_HEADER_SIZE (sizeof(PrrtPacketFeedbackPayload) - sizeof(PrrtIncompleteBlock*))
...@@ -87,12 +83,11 @@ PrrtPacket *PrrtPacket_create_data_packet(uint8_t priority, const void *payloadP ...@@ -87,12 +83,11 @@ PrrtPacket *PrrtPacket_create_data_packet(uint8_t priority, const void *payloadP
prrtTimedelta_t targetDelay); prrtTimedelta_t targetDelay);
PrrtPacket* PrrtPacket_reconstruct_data_packet(PrrtPacketDataPayload* payload, prrtIndex_t index, prrtSequenceNumber_t sequenceNumber); PrrtPacket* PrrtPacket_reconstruct_data_packet(PrrtPacketDataPayload* payload, prrtIndex_t index, prrtSequenceNumber_t sequenceNumber);
PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, prrtSequenceNumber_t sequenceNumber, PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, prrtSequenceNumber_t sequenceNumber, prrtTimedelta_t groupRTT,
prrtTimedelta_t groupRTT, prrtSequenceNumber_t gapLength, prrtSequenceNumber_t gapLength, prrtSequenceNumber_t gapCount,
prrtSequenceNumber_t gapCount, prrtSequenceNumber_t burstLength, prrtSequenceNumber_t burstLength, prrtSequenceNumber_t burstCount,
prrtSequenceNumber_t burstCount, uint32_t bandwidth, prrtTimestamp_t forwardTripTime, prrtSequenceNumber_t erasureCount,
uint32_t receiverAddr, prrtTimestamp_t forwardTripTime, prrtSequenceNumber_t packetCount);
prrtSequenceNumber_t erasureCount, prrtSequenceNumber_t packetCount);
PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadPointer, PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadPointer,
prrtPacketLength_t payloadLength, prrtPacketLength_t payloadLength,
......
...@@ -50,7 +50,7 @@ static void decode_block(PrrtSocket *sock_ptr, PrrtBlock *block) { ...@@ -50,7 +50,7 @@ static void decode_block(PrrtSocket *sock_ptr, PrrtBlock *block) {
PERROR("Decoding failed.%s", "") PERROR("Decoding failed.%s", "")
} }
static bool send_feedback(const PrrtSocket *sock_ptr, struct sockaddr_in remote) { static bool send_feedback(PrrtSocket *sock_ptr, struct sockaddr_in remote) {
uint16_t remote_port = ntohs(remote.sin_port); uint16_t remote_port = ntohs(remote.sin_port);
char *remote_host = inet_ntoa(remote.sin_addr); char *remote_host = inet_ntoa(remote.sin_addr);
...@@ -68,9 +68,11 @@ static bool send_feedback(const PrrtSocket *sock_ptr, struct sockaddr_in remote) ...@@ -68,9 +68,11 @@ static bool send_feedback(const PrrtSocket *sock_ptr, struct sockaddr_in remote)
PrrtLossStatistics stats = sock_ptr->lossStatistics; PrrtLossStatistics stats = sock_ptr->lossStatistics;
PrrtPacket *feedback_pkt_ptr = PrrtPacket_create_feedback_packet(0, 19, 4715, 0, 4, 6, 8, 9, 5, int group_RTT = 0; // TODO: To be determined.
sock_ptr->address->sin_addr.s_addr, PrrtPacket *feedback_pkt_ptr = PrrtPacket_create_feedback_packet(0, sock_ptr->sequenceNumberFeedback++, group_RTT,
forwardTripTime, stats.erasureCount, stats.packetCount); stats.gapLength, stats.gapCount, stats.burstLength,
stats.burstCount, forwardTripTime,
stats.erasureCount, stats.packetCount);
prrtPacketLength_t length = PrrtPacket_size(feedback_pkt_ptr); prrtPacketLength_t length = PrrtPacket_size(feedback_pkt_ptr);
void *buf = calloc(1, length); void *buf = calloc(1, length);
check_mem(buf); check_mem(buf);
......
...@@ -71,6 +71,7 @@ PrrtSocket *PrrtSocket_create(const bool is_sender, prrtTimedelta_t target_delay ...@@ -71,6 +71,7 @@ PrrtSocket *PrrtSocket_create(const bool is_sender, prrtTimedelta_t target_delay
s->sequenceNumberSource = 1; s->sequenceNumberSource = 1;
s->sequenceNumberRedundancy = 1; s->sequenceNumberRedundancy = 1;
s->sequenceNumberFeedback = 1;
check(target_delay_us < HALF_TIMESTAMP, "Specify target delay between 0 and %i", HALF_TIMESTAMP-1) check(target_delay_us < HALF_TIMESTAMP, "Specify target delay between 0 and %i", HALF_TIMESTAMP-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