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

Add packet loss statistics.

parent 349b320d
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -143,10 +143,10 @@ cdef extern from "proto/socket.h":
    uint32_t PrrtSocket_get_rtprop(PrrtSocket *socket)

    bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
    uint32_t PrrtSocket_get_rtt(PrrtSocket *socket)
    float PrrtSocket_get_plr(PrrtSocket *socket)
    bint PrrtSocket_enable_thread_pinning(PrrtSocket *socket)



cdef extern from "proto/stores/packetDeliveryStore.h":
    ctypedef struct PrrtPacketDeliveryStore:
        pass
+3 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ add_library(PRRT ../defines.h
        applicationConstraints.c applicationConstraints.h
        vdmcode/block_code.c vdmcode/block_code.h
        stores/deliveredPacketTable.c stores/deliveredPacketTable.h
        stores/lossGatherer.c stores/lossGatherer.h
        types/lossStatistics.c types/lossStatistics.h
        processes/dataReceiver.c processes/dataReceiver.h
        processes/feedbackReceiver.c processes/feedbackReceiver.h
        processes/dataTransmitter.c processes/dataTransmitter.h
@@ -18,6 +18,7 @@ add_library(PRRT ../defines.h
        stores/packetTimeoutTable.c stores/packetTimeoutTable.h
        stores/dataPacketStore.c stores/dataPacketStore.h
        types/packetTimeout.c types/packetTimeout.h
        stores/packetDeliveryStore.c stores/packetDeliveryStore.h)
        stores/packetDeliveryStore.c stores/packetDeliveryStore.h
        stores/receptionTable.c stores/receptionTable.h)

target_link_libraries(PRRT rt)
+11 −0
Original line number Diff line number Diff line
@@ -33,6 +33,13 @@ void PrrtChannelStateInformation_update_rtprop(PrrtChannelStateInformation *csi,
    pthread_mutex_unlock(&csi->lock);
}

void PrrtChannelStateInformation_update_plr(PrrtChannelStateInformation *csi, prrtSequenceNumber_t erasures,
                                                   prrtSequenceNumber_t packets) {
    pthread_mutex_lock(&csi->lock);
    csi->plr = ((float) erasures) / packets;
    pthread_mutex_unlock(&csi->lock);
}


prrtTimedelta_t PrrtChannelStateInformation_get_rtprop(PrrtChannelStateInformation *csi)
{
@@ -50,3 +57,7 @@ bool PrrtChannelStateInformation_destroy(PrrtChannelStateInformation *csi)
    error:
        return false;
}

prrtPacketLossRate_t PrrtChannelStateInformation_get_plr(PrrtChannelStateInformation *csi) {
    return csi->plr;
}
+4 −0
Original line number Diff line number Diff line
@@ -10,11 +10,15 @@ typedef struct prrtChannelStateInformation {
    prrtTimestamp_t rtprop_stamp;
    prrtTimedelta_t rtprop_filter_length_us;
    bool rtprop_expired;
    prrtPacketLossRate_t plr;
} PrrtChannelStateInformation;

PrrtChannelStateInformation* PrrtChannelStateInformation_create(void);
void PrrtChannelStateInformation_update_rtprop(PrrtChannelStateInformation *csi, prrtTimedelta_t rtprop);
prrtTimedelta_t PrrtChannelStateInformation_get_rtprop(PrrtChannelStateInformation *csi);
prrtPacketLossRate_t PrrtChannelStateInformation_get_plr(PrrtChannelStateInformation* csi);
void PrrtChannelStateInformation_update_plr(PrrtChannelStateInformation *csi, prrtSequenceNumber_t erasures,
                                                   prrtSequenceNumber_t packets);
bool PrrtChannelStateInformation_destroy(PrrtChannelStateInformation* csi);

void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi);
+4 −4
Original line number Diff line number Diff line
@@ -409,7 +409,6 @@ void *decode_data_header(void *dstBuffer, const void *srcBuffer) {
    return dstBuffer;
}


int PrrtPacket_destroy(PrrtPacket *packet) {
    if (packet->payload != NULL) {
        free(packet->payload);
@@ -494,7 +493,8 @@ PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, p
                                              prrtTimedelta_t groupRTT, prrtSequenceNumber_t gapLength,
                                              prrtSequenceNumber_t gapCount, prrtSequenceNumber_t burstLength,
                                              prrtSequenceNumber_t burstCount, uint32_t bandwidth,
                                              uint32_t receiverAddr, prrtTimestamp_t forwardTripTime) {
                                              uint32_t receiverAddr, prrtTimestamp_t forwardTripTime,
                                              prrtSequenceNumber_t erasureCount, prrtSequenceNumber_t packetCount) {
    PrrtPacket *packet = create_header(priority, sequenceNumber, PRRT_PACKET_FEEDBACK_HEADER_SIZE, PACKET_TYPE_FEEDBACK,
                                       index);

@@ -505,8 +505,8 @@ PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, p
    payload->receiverAddress = receiverAddr;
    payload->groupRTT_us = groupRTT;
    payload->forwardTripTimestamp_us = forwardTripTime;
    payload->erasureCount = 0;
    payload->packetCount = 0;
    payload->erasureCount = erasureCount;
    payload->packetCount = packetCount;
    payload->gapLength = gapLength;
    payload->gapCount = gapCount;
    payload->burstLength = burstLength;
Loading