Commit 973501b7 authored by Andreas Schmidt's avatar Andreas Schmidt

Remove isSender flag.

parent 01b825e1
......@@ -25,7 +25,7 @@ import prrt
port = int(sys.argv[1])
s = prrt.PrrtSocket(port=port, isSender=False)
s = prrt.PrrtSocket(port=port)
while True:
d = s.recv()
......@@ -44,7 +44,7 @@ import prrt
host = sys.argv[1]
port = int(sys.argv[2])
s = prrt.PrrtSocket(port=port, isSender=True)
s = prrt.PrrtSocket(port=port)
s.connect(host, port)
for i in range(10):
......
......@@ -118,7 +118,7 @@ cdef extern from "proto/socket.h":
ctypedef prrtSocket PrrtSocket
cdef PrrtSocket* PrrtSocket_create(bint isSender, const uint32_t target_delay)
cdef PrrtSocket* PrrtSocket_create(const uint32_t target_delay)
bint PrrtSocket_bind(PrrtSocket *sock_ptr, const_char *ipAddress, const uint16_t port)
int PrrtSocket_close(const PrrtSocket *sock_ptr)
int PrrtSocket_connect(PrrtSocket *sock_ptr, const_char *host, const uint16_t port)
......@@ -138,13 +138,15 @@ cdef extern from "proto/socket.h":
bint PrrtSocket_set_coding_parameters(PrrtSocket *s, uint8_t k, uint8_t n, uint8_t c, uint8_t *n_cycle)
PrrtCodingConfiguration *PrrtSocket_get_coding_parameters(PrrtSocket *s)
bint PrrtSocket_uses_thread_pinning(PrrtSocket *socket)
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)
uint32_t PrrtSocket_get_delivery_rate(PrrtSocket *socket)
uint32_t PrrtSocket_get_btlbw(PrrtSocket *socket)
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);
bint PrrtSocket_get_app_limited(PrrtSocket *socket)
bint PrrtSocket_enable_thread_pinning(PrrtSocket *socket)
......
......@@ -149,7 +149,7 @@ void *send_data_loop(void *ptr) {
packet->index = (uint8_t) (packet->sequenceNumber - block->baseSequenceNumber);
PrrtPacketDataPayload *payload = packet->payload;
payload->groupRTprop_us = PrrtSocket_get_rtprop(sock_ptr);
payload->groupRTprop_us = PrrtSocket_get_rtprop_fwd(sock_ptr);
PrrtPacket *packetToSend = PrrtPacket_copy(packet);
send_packet(sock_ptr, packetToSend);
......
This diff is collapsed.
......@@ -57,7 +57,6 @@ typedef struct prrtSocket {
prrtSequenceNumber_t sequenceNumberRepetition;
prrtSequenceNumber_t sequenceNumberRedundancy;
prrtSequenceNumber_t sequenceNumberFeedback;
bool isSender;
prrtTimestamp_t lastSentTimestamp;
prrtTimestamp_t lastReceivedTimestamp;
......@@ -85,7 +84,7 @@ typedef struct prrtSocket {
} PrrtSocket;
PrrtSocket *PrrtSocket_create(bool is_sender, prrtTimedelta_t target_delay_us);
PrrtSocket *PrrtSocket_create(prrtTimedelta_t target_delay_us);
bool PrrtSocket_enable_hardware_timestamping(PrrtSocket *s, const char * interface_name);
......@@ -128,11 +127,12 @@ bool PrrtSocket_closing(PrrtSocket *s);
bool PrrtSocket_uses_thread_pinning(PrrtSocket *s);
uint32_t PrrtSocket_get_rtprop(PrrtSocket *s);
uint32_t PrrtSocket_get_rtprop_fwd(PrrtSocket *s);
prrtPacketLossRate_t PrrtSocket_get_plr(PrrtSocket *s);
prrtDeliveryRate_t PrrtSocket_get_delivery_rate(PrrtSocket *s);
prrtDeliveryRate_t PrrtSocket_get_btlbw(PrrtSocket *s);
prrtPacketLossRate_t PrrtSocket_get_plr_fwd(PrrtSocket *s);
prrtDeliveryRate_t PrrtSocket_get_delivery_rate_fwd(PrrtSocket *s);
prrtDeliveryRate_t PrrtSocket_get_btlbw_fwd(PrrtSocket *s);
prrtDeliveryRate_t PrrtSocket_get_btlbw_back(PrrtSocket *s);
bool PrrtSocket_get_app_limited(PrrtSocket *s);
#endif // PRRT_SOCKET_H
......@@ -114,57 +114,40 @@ class PrrtCodingConfiguration:
cdef class PrrtSocket:
cdef cprrt.PrrtSocket* _c_socket
cdef bint isSender
def __cinit__(self, port, isSender, target_delay = 1, thread_pinning = False):
def __cinit__(self, port, target_delay = 1, thread_pinning = False):
target_delay_us = target_delay * 1000**2
self._c_socket = cprrt.PrrtSocket_create(isSender, target_delay_us)
self._c_socket = cprrt.PrrtSocket_create(target_delay_us)
if thread_pinning:
cprrt.PrrtSocket_enable_thread_pinning(self._c_socket)
cprrt.PrrtSocket_bind(self._c_socket, "0.0.0.0", port)
self.isSender = isSender
property plr:
property plr_fwd:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
return cprrt.PrrtSocket_get_plr(self._c_socket)
return cprrt.PrrtSocket_get_plr_fwd(self._c_socket)
property thread_pinning:
def __get__(self):
return cprrt.PrrtSocket_uses_thread_pinning(self._c_socket)
property target_delay:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
return cprrt.PrrtSocket_get_sock_opt(self._c_socket, "targetdelay") * 0.000001
property app_queue_size:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
return cprrt.PrrtSocket_get_sock_opt(self._c_socket, "app_queue_size")
def __set__(self, value):
if not self.isSender:
raise Exception("Not a sender.")
cprrt.PrrtSocket_set_sock_opt(self._c_socket, "app_queue_size", value)
property rtt:
property rtt_fwd:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
return cprrt.PrrtSocket_get_rtprop(self._c_socket) * 0.000001
return cprrt.PrrtSocket_get_rtprop_fwd(self._c_socket) * 0.000001
property coding_configuration:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
cdef cprrt.PrrtCodingConfiguration *params = cprrt.PrrtSocket_get_coding_parameters(self._c_socket)
return PrrtCodingConfiguration(params.n, params.k, list(<uint8_t[:params.c]> params.n_cycle))
......@@ -176,22 +159,20 @@ cdef class PrrtSocket:
n_cycle[i] = x
cprrt.PrrtSocket_set_coding_parameters(self._c_socket, params.k, params.n, c, n_cycle)
property delivery_rate:
property delivery_rate_fwd:
def __get__(self):
return cprrt.PrrtSocket_get_delivery_rate_fwd(self._c_socket)
property btlbw_fwd:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
return cprrt.PrrtSocket_get_delivery_rate(self._c_socket)
return cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket)
property btlbw:
property btlbw_back:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
return cprrt.PrrtSocket_get_btlbw(self._c_socket)
return cprrt.PrrtSocket_get_btlbw_back(self._c_socket)
property app_limited:
def __get__(self):
if not self.isSender:
raise Exception("Not a sender.")
return cprrt.PrrtSocket_get_app_limited(self._c_socket)
def recv(self):
......
......@@ -97,7 +97,7 @@ int main(int argc, char **argv) {
}
#endif
s = PrrtSocket_create(false, HALF_TIMESTAMP-1);
s = PrrtSocket_create(HALF_TIMESTAMP-1);
check(s != NULL, "Could not create socket.");
if(strcmp(arguments.hardwarestamping_interface, "-") != 0) {
......
......@@ -101,7 +101,7 @@ int main(int argc, char **argv) {
#endif
PrrtSocket *s = PrrtSocket_create(true, 10 * 1000 * 1000);
PrrtSocket *s = PrrtSocket_create(10 * 1000 * 1000);
check(s != NULL, "Socket create failed.");
if(strcmp(arguments.hardwarestamping_interface, "-") != 0) {
......
Markdown is supported
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