Commit 82fa5a5e authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Update size of rtt fields.

parent 8d65f984
......@@ -20,8 +20,8 @@ void PrrtChannelStateInformation_update_rtt(PrrtChannelStateInformation *csi, ui
{
int32_t delta = rtt - csi->rttMean;
// TODO: ensure that there are no arithemtic problems via rounding etc.
csi->rttMean = (uint32_t) (csi->rttMean + RRT_ALPHA * delta);
csi->rttDev = (uint32_t) (csi->rttDev + RRT_ALPHA * (labs(delta) - csi->rttDev));
csi->rttMean = (uint16_t) (csi->rttMean + RRT_ALPHA * delta);
csi->rttDev = (uint16_t) (csi->rttDev + RRT_ALPHA * (labs(delta) - csi->rttDev));
}
void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi)
......
......@@ -4,8 +4,8 @@
#include <stdint.h>
typedef struct prrtChannelStateInformation {
uint32_t rttMean;
uint32_t rttDev;
uint16_t rttMean;
uint16_t rttDev;
} PrrtChannelStateInformation;
void PrrtChannelStateInformation_init(PrrtChannelStateInformation* csi);
......
......@@ -483,9 +483,4 @@ PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, u
error:
return NULL;
}
uint32_t PrrtPacket_get_data_timestamp(PrrtPacket* packet) {
PrrtPacketDataPayload* payload = packet->payload;
return payload->timestamp;
}
\ No newline at end of file
......@@ -82,6 +82,6 @@ int PrrtPacket_destroy(PrrtPacket *packet);
#define PrrtPacket_copy_payload_to_buffer(dst, packet, header_size) memcpy(dst, packet->payload + header_size, packet->payload_len - header_size);
#define PrrtPacket_copy_buffer_to_payload(packet, src, header_size) memcpy(packet->payload + header_size, src, packet->payload_len - header_size);
uint32_t PrrtPacket_get_data_timestamp(PrrtPacket* packet);
#define PrrtPacket_get_data_timestamp(packet) ((PrrtPacketDataPayload*) packet->payload)->timestamp;
#endif //PRRT_FRAME_H
......@@ -103,6 +103,10 @@ void *receive_data_loop(void *ptr)
check_mem(packet);
check(PrrtPacket_decode(buffer, (uint16_t) n, packet), "Decode failed.");
// TODO: make something useful with RTT approximation
PrrtPacketDataPayload* payload = packet->payload;
debug("RTT: %d", payload->group_round_trip_time);
sock_ptr->lastSentTimestamp = PrrtPacket_get_data_timestamp(packet);
check(send_feedback(sock_ptr, remote), "Sending feedback failed.");
......
......@@ -80,6 +80,10 @@ void * send_data_loop(void *ptr) {
packet->seqno = sock_ptr->sequenceNumberSource++;
packet->index = (uint8_t) (packet->seqno - block->baseSequenceNumber);
PrrtPacketDataPayload* payload = packet->payload;
// TODO: should lock here !
payload->group_round_trip_time = (uint16_t) (sock_ptr->csi.rttMean / 1000);
PrrtPacket* packetToSend = PrrtPacket_copy(packet);
send_packet(sock_ptr, packetToSend);
......
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