Commit b3c8b737 authored by Andreas Schmidt's avatar Andreas Schmidt

Add minRTT. Fix conversion problem.

parent 273d1eb4
......@@ -29,6 +29,8 @@
#define RRT_ALPHA 0.125
#define MIN_RTT 300
// Uncomment the line below if you are compiling on Windows.
// #define WINDOWS
#include <stdio.h>
......
#include <malloc.h>
#include <math.h>
#include "../xlap/xlap.h"
#include "../util/common.h"
#include "../util/dbg.h"
......@@ -122,39 +123,34 @@ void PrrtReceiver_on_application_write(PrrtReceiver* receiver) {
}
void PrrtReceiver_generateRateSample(PrrtRateSample *rateSample, PrrtPacketTracking *packetTracking) {
bool PrrtReceiver_generateRateSample(PrrtRateSample *rateSample, PrrtPacketTracking *packetTracking) {
/* Clear app-limited field */
if (packetTracking->app_limited && packetTracking->delivered > packetTracking->app_limited)
packetTracking->app_limited = 0;
if (rateSample->prior_time == 0) {
//printf("Prior Time is 0, Cancelling Rate sample calculation\n");
return;
return false;
}
prrtTimedelta_t interval = MAX(rateSample->send_elapsed, rateSample->ack_elapsed);
if(interval < MIN_RTT) {
return false;
}
rateSample->interval = MAX(rateSample->send_elapsed, rateSample->ack_elapsed);
rateSample->interval = interval;
rateSample->delivered = packetTracking->delivered - rateSample->prior_delivered;
if (rateSample->interval != 0) {
// delivered: bytes; interval: us; convert to bps
rateSample->delivery_rate =
rateSample->delivered * 1000 * 1000 * 8 / rateSample->interval;
rateSample->delivery_rate = (uint32_t) round(
(((double) rateSample->delivered) * 1000.0 * 1000.0 * 8.0) / ((double) rateSample->interval));
}
debug(DEBUG_FEEDBACK, "RS interval: %u, RS delivered: %u, RS delivery_rate: %u", rateSample->interval,
rateSample->delivered, rateSample->delivery_rate);
/* Normally we expect interval >= MinRTT.
* Note that rate may still be over-estimated when a spuriously
* retransmitted skb was first (s)acked because "interval"
* is under-estimated (up to an RTT). However, continuously
* measuring the delivery rate during loss recovery is crucial
* for connections suffer heavy or prolonged losses.
if (packetStore->rateSample->interval < MinRTT(tp))
packetStore->rateSample->interval = -1;
return false // no reliable sample
*/
debug(DEBUG_FEEDBACK, "RS interval: %u, RS delivered: %u, RS delivery_rate: %u, App Limited: %u", rateSample->interval,
rateSample->delivered, rateSample->delivery_rate, rateSample->is_app_limited);
return true;
}
void PrrtReceiver_updateAndGenerateRateSample(PrrtReceiver *recv, prrtSequenceNumber_t seqnum, uint8_t packetType,
......@@ -195,8 +191,7 @@ void PrrtReceiver_add_outstanding_packet_state(PrrtReceiver *recv, PrrtPacket *p
//printf("Adding Packet #%u to %u\n", packet->sequenceNumber, PrrtPacket_type(packet));
check(pthread_mutex_lock(&recv->lock) == 0, "Lock failed.");
if (PrrtInFlightPacketStore_get_queue_size(recv->dataPacketStates) +
PrrtInFlightPacketStore_get_queue_size(recv->redundancyPacketStates) == 0) {
if (recv->packetTracking->pipe == 0) {
recv->packetTracking->first_sent_time = sentTime;
recv->packetTracking->delivered_time = sentTime;
}
......
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