Commit caf62602 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Estimating P_GG, P_BB, mu and rho.

parent feadf321
Pipeline #2246 failed with stages
in 51 seconds
...@@ -148,6 +148,11 @@ cdef extern from "proto/socket.h": ...@@ -148,6 +148,11 @@ cdef extern from "proto/socket.h":
uint32_t PrrtSocket_get_btlbw_fwd(PrrtSocket *s); uint32_t PrrtSocket_get_btlbw_fwd(PrrtSocket *s);
uint32_t PrrtSocket_get_btlbw_back(PrrtSocket *s); uint32_t PrrtSocket_get_btlbw_back(PrrtSocket *s);
double PrrtSocket_get_P_GG(PrrtSocket *s);
double PrrtSocket_get_P_BB(PrrtSocket *s);
double PrrtSocket_get_mu(PrrtSocket *s);
double PrrtSocket_get_rho(PrrtSocket *s);
bint PrrtSocket_get_app_limited(PrrtSocket *socket) bint PrrtSocket_get_app_limited(PrrtSocket *socket)
bint PrrtSocket_enable_thread_pinning(PrrtSocket *socket) bint PrrtSocket_enable_thread_pinning(PrrtSocket *socket)
......
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
#include "../defines.h" #include "../defines.h"
#include "../util/common.h" #include "../util/common.h"
#include "../util/dbg.h" #include "../util/dbg.h"
#include "channelStateInformation.h"
#include "clock.h" #include "clock.h"
#include "receiver.h" #include "receiver.h"
#include "channelStateInformation.h"
PrrtChannelStateInformation * PrrtChannelStateInformation_create() PrrtChannelStateInformation * PrrtChannelStateInformation_create()
{ {
...@@ -44,10 +45,15 @@ void PrrtChannelStateInformation_update_rtprop(PrrtChannelStateInformation *csi, ...@@ -44,10 +45,15 @@ void PrrtChannelStateInformation_update_rtprop(PrrtChannelStateInformation *csi,
pthread_mutex_unlock(&csi->lock); pthread_mutex_unlock(&csi->lock);
} }
void PrrtChannelStateInformation_update_plr(PrrtChannelStateInformation *csi, prrtSequenceNumber_t erasures, void PrrtChannelStateInformation_update_loss_information(PrrtChannelStateInformation *csi, PrrtLossStatistics stats) {
prrtSequenceNumber_t packets) {
pthread_mutex_lock(&csi->lock); pthread_mutex_lock(&csi->lock);
csi->plr = ((float) erasures) / packets; csi->plr = PrrtLossStatistics_get_packet_loss_rate(stats);
float L_B = PrrtLossStatistics_get_avg_burst_length(stats);
csi->P_GG = (isnan(L_B)) ? 0 : 1 - (1.0 / L_B);
float L_G = PrrtLossStatistics_get_avg_gap_length(stats);
csi->P_BB = (isnan(L_G)) ? 0 : 1 - (1.0 / L_G);
csi->mu = (1 - csi->P_BB) / (2 - csi->P_GG - csi->P_BB);
csi->rho = csi->P_GG + csi->P_BB - 1;
pthread_mutex_unlock(&csi->lock); pthread_mutex_unlock(&csi->lock);
} }
...@@ -84,6 +90,22 @@ prrtPacketLossRate_t PrrtChannelStateInformation_get_plr(PrrtChannelStateInforma ...@@ -84,6 +90,22 @@ prrtPacketLossRate_t PrrtChannelStateInformation_get_plr(PrrtChannelStateInforma
return csi->plr; return csi->plr;
} }
double PrrtChannelStateInformation_get_P_GG(PrrtChannelStateInformation *csi) {
return csi->P_GG;
}
double PrrtChannelStateInformation_get_P_BB(PrrtChannelStateInformation *csi) {
return csi->P_BB;
}
double PrrtChannelStateInformation_get_mu(PrrtChannelStateInformation *csi) {
return csi->mu;
}
double PrrtChannelStateInformation_get_rho(PrrtChannelStateInformation *csi) {
return csi->rho;
}
prrtDeliveryRate_t PrrtChannelStateInformation_get_delivery_rate(PrrtChannelStateInformation *csi) { prrtDeliveryRate_t PrrtChannelStateInformation_get_delivery_rate(PrrtChannelStateInformation *csi) {
return csi->deliveryRate; return csi->deliveryRate;
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "types/packet.h" #include "types/packet.h"
#include "types/lossStatistics.h"
typedef struct prrtChannelStateInformation { typedef struct prrtChannelStateInformation {
pthread_mutex_t lock; pthread_mutex_t lock;
...@@ -23,6 +24,10 @@ typedef struct prrtChannelStateInformation { ...@@ -23,6 +24,10 @@ typedef struct prrtChannelStateInformation {
uint8_t btlbw_filter_length; uint8_t btlbw_filter_length;
bool appLimited; bool appLimited;
double P_GG;
double P_BB;
double mu;
double rho;
} PrrtChannelStateInformation; } PrrtChannelStateInformation;
PrrtChannelStateInformation* PrrtChannelStateInformation_create(void); PrrtChannelStateInformation* PrrtChannelStateInformation_create(void);
...@@ -33,11 +38,14 @@ prrtDeliveryRate_t PrrtChannelStateInformation_get_btlbw(PrrtChannelStateInforma ...@@ -33,11 +38,14 @@ prrtDeliveryRate_t PrrtChannelStateInformation_get_btlbw(PrrtChannelStateInforma
bool PrrtChannelStateInformation_get_app_limited(PrrtChannelStateInformation *csi); bool PrrtChannelStateInformation_get_app_limited(PrrtChannelStateInformation *csi);
prrtPacketLossRate_t PrrtChannelStateInformation_get_plr(PrrtChannelStateInformation* csi); prrtPacketLossRate_t PrrtChannelStateInformation_get_plr(PrrtChannelStateInformation* csi);
void PrrtChannelStateInformation_update_plr(PrrtChannelStateInformation *csi, prrtSequenceNumber_t erasures, void PrrtChannelStateInformation_update_loss_information(PrrtChannelStateInformation *csi, PrrtLossStatistics stats);
prrtSequenceNumber_t packets);
void PrrtChannelStateInformation_update_delivery_rate(PrrtChannelStateInformation *csi, PrrtPacket* packet, prrtDeliveryRate_t rate); void PrrtChannelStateInformation_update_delivery_rate(PrrtChannelStateInformation *csi, PrrtPacket* packet, prrtDeliveryRate_t rate);
void PrrtChannelStateInformation_update_app_limited(PrrtChannelStateInformation *csi, bool appLimited); void PrrtChannelStateInformation_update_app_limited(PrrtChannelStateInformation *csi, bool appLimited);
bool PrrtChannelStateInformation_destroy(PrrtChannelStateInformation* csi); bool PrrtChannelStateInformation_destroy(PrrtChannelStateInformation* csi);
double PrrtChannelStateInformation_get_P_GG(PrrtChannelStateInformation *csi);
double PrrtChannelStateInformation_get_P_BB(PrrtChannelStateInformation *csi);
double PrrtChannelStateInformation_get_mu(PrrtChannelStateInformation *csi);
double PrrtChannelStateInformation_get_rho(PrrtChannelStateInformation *csi);
void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi); void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi);
......
...@@ -221,8 +221,16 @@ void handle_feedback_packet(PrrtSocket *prrtSocket, PrrtPacket *prrtPacket, prrt ...@@ -221,8 +221,16 @@ void handle_feedback_packet(PrrtSocket *prrtSocket, PrrtPacket *prrtPacket, prrt
PrrtChannelStateInformation_update_rtprop(prrtSocket->receiver->csi, PrrtChannelStateInformation_update_rtprop(prrtSocket->receiver->csi,
(prrtTimedelta_t) (receiveTime - forwardTripTimestamp)); (prrtTimedelta_t) (receiveTime - forwardTripTimestamp));
debug(DEBUG_DATARECEIVER, "PrrtChannelStateInformation_update_rtprop "); debug(DEBUG_DATARECEIVER, "PrrtChannelStateInformation_update_rtprop ");
PrrtChannelStateInformation_update_plr(prrtSocket->receiver->csi, feedbackPayload->erasureCount, feedbackPayload->packetCount); PrrtLossStatistics stats = {
debug(DEBUG_DATARECEIVER, "PrrtChannelStateInformation_update_plr "); .burstCount = feedbackPayload->burstCount,
.burstLength = feedbackPayload->burstLength,
.erasureCount = feedbackPayload->erasureCount,
.gapCount = feedbackPayload->gapCount,
.gapLength = feedbackPayload->gapLength,
.packetCount = feedbackPayload->packetCount
};
PrrtChannelStateInformation_update_loss_information(prrtSocket->receiver->csi, stats);
debug(DEBUG_DATARECEIVER, "PrrtChannelStateInformation_update_loss_information ");
return; return;
error: error:
......
...@@ -532,6 +532,21 @@ prrtDeliveryRate_t PrrtSocket_get_btlbw_back(PrrtSocket *s) { ...@@ -532,6 +532,21 @@ prrtDeliveryRate_t PrrtSocket_get_btlbw_back(PrrtSocket *s) {
return 0; return 0;
} }
double PrrtSocket_get_P_GG(PrrtSocket *s) {
return PrrtChannelStateInformation_get_P_GG(s->receiver->csi);
}
double PrrtSocket_get_P_BB(PrrtSocket *s) {
return PrrtChannelStateInformation_get_P_BB(s->receiver->csi);
}
double PrrtSocket_get_mu(PrrtSocket *s) {
return PrrtChannelStateInformation_get_mu(s->receiver->csi);
}
double PrrtSocket_get_rho(PrrtSocket *s) {
return PrrtChannelStateInformation_get_rho(s->receiver->csi);
}
bool PrrtSocket_get_app_limited(PrrtSocket *s) { bool PrrtSocket_get_app_limited(PrrtSocket *s) {
return PrrtChannelStateInformation_get_app_limited(s->receiver->csi); return PrrtChannelStateInformation_get_app_limited(s->receiver->csi);
......
...@@ -131,6 +131,10 @@ prrtDeliveryRate_t PrrtSocket_get_delivery_rate_fwd(PrrtSocket *s); ...@@ -131,6 +131,10 @@ prrtDeliveryRate_t PrrtSocket_get_delivery_rate_fwd(PrrtSocket *s);
prrtDeliveryRate_t PrrtSocket_get_btlbw_fwd(PrrtSocket *s); prrtDeliveryRate_t PrrtSocket_get_btlbw_fwd(PrrtSocket *s);
prrtDeliveryRate_t PrrtSocket_get_btlbw_back(PrrtSocket *s); prrtDeliveryRate_t PrrtSocket_get_btlbw_back(PrrtSocket *s);
bool PrrtSocket_get_app_limited(PrrtSocket *s); bool PrrtSocket_get_app_limited(PrrtSocket *s);
double PrrtSocket_get_P_GG(PrrtSocket *s);
double PrrtSocket_get_P_BB(PrrtSocket *s);
double PrrtSocket_get_mu(PrrtSocket *s);
double PrrtSocket_get_rho(PrrtSocket *s);
char *PrrtSocket_inet_ntoa(struct in_addr* in); char *PrrtSocket_inet_ntoa(struct in_addr* in);
uint16_t PrrtSocket_ntohs(uint16_t v); uint16_t PrrtSocket_ntohs(uint16_t v);
......
...@@ -8,7 +8,7 @@ PrrtReceptionTable *PrrtReceptionTable_create(void) { ...@@ -8,7 +8,7 @@ PrrtReceptionTable *PrrtReceptionTable_create(void) {
check_mem(t); check_mem(t);
t->start = 0; t->start = 0;
t->nextNumberAfterWindow = 0; t->nextNumberAfterWindow = 0;
t->windowSize = 1000; t->windowSize = 200;
t->bitmap = Bitmap_create(false, SEQNO_SPACE); t->bitmap = Bitmap_create(false, SEQNO_SPACE);
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
......
...@@ -14,8 +14,8 @@ typedef struct lossStatistics { ...@@ -14,8 +14,8 @@ typedef struct lossStatistics {
PrrtLossStatistics PrrtLossStatistics_add(PrrtLossStatistics a, PrrtLossStatistics b); PrrtLossStatistics PrrtLossStatistics_add(PrrtLossStatistics a, PrrtLossStatistics b);
#define LossStatistics_get_packet_loss_rate(stats) (((float) stats.erasureCount) / stats.packetCount) #define PrrtLossStatistics_get_packet_loss_rate(stats) (((float) stats.erasureCount) / stats.packetCount)
#define LossStatistics_get_avg_gap_length(stats) (((float) stats.gapLength) / stats.gapCount) #define PrrtLossStatistics_get_avg_gap_length(stats) (((float) stats.gapLength) / stats.gapCount)
#define LossStatistics_get_avg_burst_length(stats) (((float) stats.burstLength) / stats.burstCount) #define PrrtLossStatistics_get_avg_burst_length(stats) (((float) stats.burstLength) / stats.burstCount)
#endif //PRRT_LOSS_STATISTICS_H #endif //PRRT_LOSS_STATISTICS_H
\ No newline at end of file
...@@ -253,6 +253,22 @@ cdef class PrrtSocket: ...@@ -253,6 +253,22 @@ cdef class PrrtSocket:
def __get__(self): def __get__(self):
return cprrt.PrrtSocket_get_app_limited(self._c_socket) return cprrt.PrrtSocket_get_app_limited(self._c_socket)
property P_GG:
def __get__(self):
return cprrt.PrrtSocket_get_P_GG(self._c_socket)
property P_BB:
def __get__(self):
return cprrt.PrrtSocket_get_P_BB(self._c_socket)
property mu:
def __get__(self):
return cprrt.PrrtSocket_get_mu(self._c_socket)
property rho:
def __get__(self):
return cprrt.PrrtSocket_get_rho(self._c_socket)
def __dealloc__(self): def __dealloc__(self):
if self._c_socket != NULL: if self._c_socket != NULL:
cprrt.PrrtSocket_close(self._c_socket) cprrt.PrrtSocket_close(self._c_socket)
Supports Markdown
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