lossGatherer.h 1.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#ifndef PRRT_LOSSGATHERER_H
#define PRRT_LOSSGATHERER_H

#include "../../util/bitmap.h"

typedef struct lossGatherer {
    Bitmap* bitmap;
    uint16_t start;
} LossGatherer;

typedef struct lossStatistics {
    uint16_t packetCount;
    uint16_t errorCount;
    uint16_t gapLength;
    uint16_t gapCount;
    uint16_t burstLength;
    uint16_t burstCount;
} LossStatistics;

20
LossGatherer* LossGatherer_create(void);
21 22 23 24 25 26 27 28 29 30
LossStatistics LossGatherer_calculate_statistics(LossGatherer *lossGatherer, uint32_t start, uint16_t length);
bool LossGatherer_mark_loss(LossGatherer* lossGatherer, uint32_t sequenceNumber);
bool LossGatherer_check_loss(LossGatherer *lossGatherer, uint32_t sequenceNumber);
bool LossGatherer_destroy(LossGatherer* lossGatherer);

#define LossStatistics_get_packet_loss_rate(stats) (((float) stats.errorCount) / stats.packetCount)
#define LossStatistics_get_avg_gap_length(stats) (((float) stats.gapLength) / stats.gapCount)
#define LossStatistics_get_avg_burst_length(stats) (((float) stats.burstLength) / stats.burstCount)

#endif //PRRT_LOSSGATHERER_H