cprrt.pxd 6.53 KB
Newer Older
1
include "posix/time.pxd"
2
include "sockets.pxd"
3

4
from libc.stdint cimport uint32_t, uint16_t, uint8_t, int32_t, uint64_t
Andreas Schmidt's avatar
Andreas Schmidt committed
5
from libc.string cimport const_char
6

7

8 9 10 11 12 13 14 15 16 17
cdef extern from "pthread.h" nogil:
    ctypedef struct pthread_t:
        pass

    ctypedef struct pthread_mutex_t:
        pass

    ctypedef struct pthread_cond_t:
        pass

18
cdef extern from "proto/vdmcode/block_code.h":
19 20 21 22 23
    cdef struct prrtCoder:
        pass

    ctypedef prrtCoder PrrtCoder

24
cdef extern from "proto/channelStateInformation.h":
Andreas Schmidt's avatar
Andreas Schmidt committed
25 26 27 28 29
    cdef struct prrtChannelStateInformation:
        pass

    ctypedef prrtChannelStateInformation PrrtChannelStateInformation

30
cdef extern from "proto/codingParams.h":
31
    ctypedef struct prrtCodingConfiguration:
32 33 34 35 36
        uint8_t k
        uint8_t r
        uint8_t n
        uint8_t c
        uint8_t *n_cycle
37

38 39 40 41
    ctypedef prrtCodingConfiguration PrrtCodingConfiguration
    PrrtCodingConfiguration *PrrtCodingConfiguration_create()
    PrrtCodingConfiguration *PrrtCodingConfiguration_copy(PrrtCodingConfiguration *cpar)
    bint PrrtCodingConfiguration_destroy(PrrtCodingConfiguration *cpar)
42

Andreas Schmidt's avatar
Andreas Schmidt committed
43
cdef extern from "util/list.h":
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    cdef struct list:
        pass

    ctypedef list List

    cdef struct listNode:
        pass

    ctypedef listNode ListNode

    void List_push(List *list, const void *value)
    void *List_pop(const List *list)

    void List_unshift(List *list, const void *value)
    void *List_shift(const List *list)

    void *List_remove(List *list, const ListNode *node)

62
cdef extern from "proto/block.h":
63 64 65
    cdef struct prrtBlock:
        uint32_t data_count
        uint32_t redundancy_count
66
        PrrtCodingConfiguration coding_params
67
        uint32_t largest_data_length
68
        uint16_t baseSequenceNumber
69 70 71 72 73 74
        List* data_blocks
        List* redundancy_blocks
        uint8_t is_coded

    ctypedef prrtBlock PrrtBlock

75
cdef extern from "proto/types/packet.h":
76 77 78
    cdef struct prrtPacket:
        uint8_t type_priority;
        uint8_t index;
79
        uint16_t sequenceNumber;
80
        void* payload;
81
        uint32_t payloadLength;
82 83 84

    ctypedef prrtPacket PrrtPacket

85 86
    ctypedef uint32_t prrtTimedelta_t;

87
cdef extern from "proto/receiver.h":
88 89 90 91
    ctypedef struct PrrtReceiver:
        const char* host_name
        uint16_t port

Andreas Schmidt's avatar
Andreas Schmidt committed
92 93 94 95
    PrrtReceiver* PrrtReceiver_create(const char *host, uint16_t port)
    bint PrrtReceiver_destroy(PrrtReceiver* receiver)


96
cdef extern from "proto/socket.h":
97
    cdef struct prrtSocket:
98
        int socketFd
99

Andreas Schmidt's avatar
Andreas Schmidt committed
100
        pthread_t sendDataThread
101 102
        pthread_mutex_t outQueueFilledMutex
        pthread_cond_t outQueueFilledCv
Andreas Schmidt's avatar
Andreas Schmidt committed
103
        MPSCQueue* sendDataQueue
104 105 106 107

        pthread_t receiveDataThread
        pthread_mutex_t inQueueFilledMutex
        pthread_cond_t inQueueFilledMutexCv
108
        PrrtPacketDeliveryStore *packetDeliveryStore
109 110 111

        BPTreeNode* dataStore

112
        PrrtReceiver* receiver
113

114 115 116 117 118 119 120 121
        uint16_t packetsCount
        uint16_t sequenceNumberSource
        uint16_t sequenceNumberRepetition
        uint16_t sequenceNumberRedundancy
        uint16_t sequenceNumberFeedback

    ctypedef prrtSocket PrrtSocket

122
    cdef PrrtSocket* PrrtSocket_create(const uint32_t maximum_payload_size, const uint32_t target_delay)
Andreas Schmidt's avatar
Andreas Schmidt committed
123
    bint PrrtSocket_bind(PrrtSocket *sock_ptr, const_char *ipAddress, const uint16_t port)
Andreas Schmidt's avatar
Andreas Schmidt committed
124 125
    int PrrtSocket_close(const PrrtSocket *sock_ptr)
    int PrrtSocket_connect(PrrtSocket *sock_ptr, const_char *host, const uint16_t port)
126 127 128
    int PrrtSocket_send_sync(PrrtSocket *sock_ptr, const uint8_t *data, const size_t data_len)
    int PrrtSocket_send_async(PrrtSocket *sock_ptr, const uint8_t *data, const size_t data_len)

129

130 131 132 133
    int32_t PrrtSocket_recv(PrrtSocket *sock_ptr, void *buf_ptr, sockaddr* addr) nogil
    int32_t PrrtSocket_receive_asap(PrrtSocket *s, void *buf_ptr, sockaddr* addr) nogil
    int32_t PrrtSocket_receive_asap_wait(PrrtSocket *s, void *buf_ptr, sockaddr* addr) nogil
    int32_t PrrtSocket_receive_asap_timedwait(PrrtSocket *s, void *buf_ptr, sockaddr* addr, timespec* deadline) nogil
134

135 136 137
    int32_t PrrtSocket_receive_ordered(PrrtSocket *s, void *buf_ptr, sockaddr* addr, prrtTimedelta_t time_window_us) nogil
    int32_t PrrtSocket_receive_ordered_wait(PrrtSocket *s, void *buf_ptr, sockaddr* addr, prrtTimedelta_t time_window_us) nogil
    int32_t PrrtSocket_receive_ordered_timedwait(PrrtSocket *s, void *buf_ptr, sockaddr* addr, prrtTimedelta_t time_window_us, timespec* deadline) nogil
138

Andreas Schmidt's avatar
Andreas Schmidt committed
139
    bint PrrtSocket_set_sock_opt(PrrtSocket *sock_ptr, const_char *name, const uint32_t value)
140
    uint32_t PrrtSocket_get_sock_opt(PrrtSocket *sock_ptr, const_char *name)
rna's avatar
rna committed
141
    bint PrrtSocket_set_coding_parameters(PrrtSocket *s, uint8_t k, uint8_t n, uint8_t c, uint8_t *n_cycle)
142
    PrrtCodingConfiguration *PrrtSocket_get_coding_parameters(PrrtSocket *s)
143
    bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
144

145
    bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
Andreas Schmidt's avatar
Andreas Schmidt committed
146 147 148 149 150 151
    uint32_t PrrtSocket_get_rtprop_fwd(PrrtSocket *socket)
    float PrrtSocket_get_plr_fwd(PrrtSocket *socket)
    uint32_t PrrtSocket_get_delivery_rate_fwd(PrrtSocket *socket)
    uint32_t PrrtSocket_get_btlbw_fwd(PrrtSocket *s);
    uint32_t PrrtSocket_get_btlbw_back(PrrtSocket *s);

152 153 154
    uint32_t PrrtSocket_get_bbr_state(PrrtSocket *s)
    uint64_t PrrtSocket_get_full_bw(PrrtSocket *s)
    bint PrrtSocket_get_filled_pipe(PrrtSocket *s)
Andreas Schmidt's avatar
Andreas Schmidt committed
155 156
    uint32_t PrrtSocket_get_cycle_index(PrrtSocket *s)
    float PrrtSocket_get_pacing_gain(PrrtSocket *s)
Andreas Schmidt's avatar
Andreas Schmidt committed
157 158
    uint32_t PrrtSocket_get_cwnd(PrrtSocket *s)
    uint32_t PrrtSocket_get_inflight(PrrtSocket *s)
159
    uint32_t PrrtSocket_get_pacing_rate(PrrtSocket *s)
Andreas Schmidt's avatar
Andreas Schmidt committed
160
    uint32_t PrrtSocket_get_send_quantum(PrrtSocket *s)
Andreas Schmidt's avatar
Andreas Schmidt committed
161
    uint32_t PrrtSocket_get_pipe(PrrtSocket *s)
Andreas Schmidt's avatar
Andreas Schmidt committed
162
    uint32_t PrrtSocket_get_delivered(PrrtSocket *s)
Andreas Schmidt's avatar
Fixes.  
Andreas Schmidt committed
163
    bint PrrtSocket_get_bbr_round_start(PrrtSocket *s)
164 165
    uint32_t PrrtSocket_get_bbr_app_limited(PrrtSocket *socket)
    bint PrrtSocket_get_bbr_is_app_limited(PrrtSocket *socket)
166 167
    bint PrrtSocket_enable_thread_pinning(PrrtSocket *socket)

168 169
cdef extern from "proto/stores/packetDeliveryStore.h":
    ctypedef struct PrrtPacketDeliveryStore:
170 171
        pass

Andreas Schmidt's avatar
Andreas Schmidt committed
172
cdef extern from "util/bptree.h":
173 174 175 176 177 178 179 180
    ctypedef struct BPTreeNode:
        pass

    BPTreeNode *BPTree_insert(BPTreeNode *root, int key, void *value);
    BPTreeNode *BPTree_delete(BPTreeNode *root, int key);
    BPTreeNode *BPTree_destroy(BPTreeNode *root);
    void *BPTree_get(BPTreeNode *root, int key);
    void BPTree_get_range(BPTreeNode *root, List *list, int key_start, int key_end);
181 182 183 184


cdef extern from "util/pipe.h":
    ctypedef struct Pipe:
185
        pass
Andreas Schmidt's avatar
Andreas Schmidt committed
186 187 188 189

cdef extern from "util/mpsc_queue.h":
    ctypedef struct MPSCQueue:
        pass
190