receiver.h 1.73 KB
Newer Older
1
2
3
4
5
#ifndef PRRT_RECEIVER_H
#define PRRT_RECEIVER_H

#include <stdbool.h>
#include <stdint.h>
6
7
8
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
9
#include "channelStateInformation.h"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "stores/inFlightPacketStore.h"

typedef struct prrtRateSample {
    prrtByteCount_t prior_delivered;
    prrtTimestamp_t prior_time;
    prrtTimedelta_t send_elapsed;
    prrtTimedelta_t ack_elapsed;

    prrtTimedelta_t interval;
    prrtByteCount_t delivered;
    bool is_app_limited;

    prrtDeliveryRate_t delivery_rate; // Bps
} PrrtRateSample;

typedef struct packetTracking {
26
    prrtByteCount_t pipe;
27
28
29
    prrtByteCount_t delivered;
    prrtTimestamp_t delivered_time;
    prrtTimestamp_t first_sent_time;
30
    prrtSequenceNumber_t app_limited;
31
} PrrtPacketTracking;
32
33

typedef struct prrtReceiver {
34
    const char *host_name;
35
    uint16_t port;
36
37
38
39
40
41
42
43
44
45
46
    struct addrinfo *ai;
    PrrtChannelStateInformation *csi;
    pthread_cond_t pipeNotFullCv;
    pthread_cond_t recordNotFoundCv;
    pthread_mutex_t lock;

    PrrtInFlightPacketStore *dataPacketStates;
    PrrtInFlightPacketStore *redundancyPacketStates;

    PrrtRateSample *rateSample;
    PrrtPacketTracking *packetTracking;
47
48
} PrrtReceiver;

49
50
51
52
53
54
55
PrrtReceiver *PrrtReceiver_create(const char *host, uint16_t port);

void PrrtReceiver_updateAndGenerateRateSample(PrrtReceiver *recv, prrtSequenceNumber_t seqnum, uint8_t packetType,
                                              prrtTimestamp_t receiveTime);

void PrrtReceiver_add_outstanding_packet_state(PrrtReceiver *recv, PrrtPacket *packet, prrtTimestamp_t sentTime);

56
57
void PrrtReceiver_on_application_write(PrrtReceiver* receiver);

58
59
60
void PrrtReceiver_interrupt(PrrtReceiver *recv);

bool PrrtReceiver_destroy(PrrtReceiver *receiver);
61
62

#endif //PRRT_RECEIVER_H