Commit b98eda49 authored by rna's avatar rna

Rename mtu to maximum_payload_size.

parent 3fc9846d
Pipeline #2530 passed with stages
in 1 minute and 28 seconds
......@@ -5,7 +5,7 @@ host = sys.argv[1]
port = int(sys.argv[2])
localport = int(sys.argv[3])
s = prrt.PrrtSocket(("127.0.1.1", localport), mtu=150)
s = prrt.PrrtSocket(("127.0.1.1", localport), maximum_payload_size=150)
s.connect((host, port))
for i in range(10):
......
......@@ -39,12 +39,12 @@ static inline prrtPacketLength_t deliver_packet(const PrrtSocket *s, void *buffe
return len;
}
PrrtSocket *PrrtSocket_create(prrtByteCount_t mtu, prrtTimedelta_t target_delay_us) {
PrrtSocket *PrrtSocket_create(prrtByteCount_t maximum_payload_size, prrtTimedelta_t target_delay_us) {
assert(sizeof(float) == 4);
PrrtSocket *s = (PrrtSocket *) calloc(1, sizeof(PrrtSocket));
check_mem(s);
s->mtu = mtu;
s->maximum_payload_size = maximum_payload_size;
s->isHardwareTimestamping = false;
s->interfaceName = NULL;
......@@ -208,8 +208,8 @@ int PrrtSocket_connect(PrrtSocket *s, const char *host, const uint16_t port) {
}
int PrrtSocket_send(PrrtSocket *s, const uint8_t *data, const size_t data_len) {
if (data_len > s->mtu) {
PERROR("Data to be sent (%ld bytes) is too long, as MTU is %d.\n", data_len, s->mtu);
if (data_len > s->maximum_payload_size) {
PERROR("Data to be sent (%ld bytes) is too long, as MTU is %d.\n", data_len, s->maximum_payload_size);
return -1;
}
XlapTimestampPlaceholder tsph;
......@@ -417,8 +417,8 @@ int PrrtSocket_close(PrrtSocket *s) {
uint32_t PrrtSocket_get_sock_opt(PrrtSocket *s, const char *name) {
if (strcmp(name, "targetdelay") == 0) {
return PrrtApplicationConstraints_get_target_delay(s->applicationConstraints);
} else if (strcmp(name, "mtu") == 0) {
return s->mtu;
} else if (strcmp(name, "maximum_payload_size") == 0) {
return s->maximum_payload_size;
} else {
PERROR("Unknown property %s\n", name);
return 0;
......
......@@ -78,11 +78,11 @@ typedef struct prrtSocket {
char *interfaceName;
atomic_bool isThreadPinning;
prrtByteCount_t mtu;
prrtByteCount_t maximum_payload_size;
} PrrtSocket;
PrrtSocket *PrrtSocket_create(prrtByteCount_t mtu, prrtTimedelta_t target_delay_us);
PrrtSocket *PrrtSocket_create(prrtByteCount_t maximum_payload_size, prrtTimedelta_t target_delay_us);
bool PrrtSocket_enable_hardware_timestamping(PrrtSocket *s, const char * interface_name);
......
......@@ -130,10 +130,10 @@ cdef class PrrtSocket:
cdef cprrt.PrrtSocket* _c_socket
_epoch = datetime.datetime.utcfromtimestamp(0)
def __cinit__(self, address, mtu = 1500, target_delay = 1, thread_pinning = False):
def __cinit__(self, address, maximum_payload_size = 1400, target_delay = 1, thread_pinning = False):
host, port = address
target_delay_us = target_delay * 1000**2
self._c_socket = cprrt.PrrtSocket_create(mtu, target_delay_us)
self._c_socket = cprrt.PrrtSocket_create(maximum_payload_size, target_delay_us)
if thread_pinning:
cprrt.PrrtSocket_enable_thread_pinning(self._c_socket)
cprrt.PrrtSocket_bind(self._c_socket, host.encode("utf8"), port)
......@@ -160,6 +160,10 @@ cdef class PrrtSocket:
def __get__(self):
return cprrt.PrrtSocket_get_sock_opt(self._c_socket, "targetdelay") * 0.000001
property maximum_payload_size:
def __get__(self):
return cprrt.PrrtSocket_get_sock_opt(self._c_socket, "maximum_payload_size")
# Protocol configuration
property thread_pinning:
......@@ -193,12 +197,12 @@ cdef class PrrtSocket:
cprrt.PrrtSocket_connect(self._c_socket, encodedHost, port)
def send(self, data):
mtu = cprrt.PrrtSocket_get_sock_opt(self._c_socket, "mtu")
maximum_payload_size = cprrt.PrrtSocket_get_sock_opt(self._c_socket, "maximum_payload_size")
data_len = len(data)
if len(data) < mtu:
if len(data) < maximum_payload_size:
cprrt.PrrtSocket_send(self._c_socket, data, data_len)
else:
raise PayloadTooBigException("Sending packet of {} bytes on a socket with MTU of {} bytes failed.".format(data_len, mtu))
raise PayloadTooBigException("Sending packet of {} bytes on a socket with maximum payload size of {} bytes failed.".format(data_len, maximum_payload_size))
# Receiving
......
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