From: Matthew Mondor Date: Wed, 9 Sep 2015 23:15:55 +0000 (+0000) Subject: Commit some forgotten changes X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=7e65216c3603eee181c466dee02e13609f0d035d;p=mmondor.git Commit some forgotten changes --- diff --git a/mmsoftware/util/tty-udp.c b/mmsoftware/util/tty-udp.c index de6a78d..73204b9 100644 --- a/mmsoftware/util/tty-udp.c +++ b/mmsoftware/util/tty-udp.c @@ -1,4 +1,4 @@ -/* $Id: tty-udp.c,v 1.8 2012/06/22 16:43:27 mmondor Exp $ */ +/* $Id: tty-udp.c,v 1.9 2015/09/09 23:15:55 mmondor Exp $ */ /* * Copyright (c) 2005, 2011, Matthew Mondor @@ -19,7 +19,42 @@ * lcp-echo-failure 2 * persist * - * Exemple usage (setup a throttled link from 192.168.1.13 to 192.168.1.1 to + * NOTES: + * + * Reference header sizes: + * + * IP header: 20-22 bytes + * UDP header: IP header + 8 bytes (28-30 bytes) + * PPP header: 2-8 bytes + * + * The MTU/MRU of the PPP interface should take into account the overhead of + * both per-packet PPP headers and UDP packet headers. To avoid IP + * fragmentation on a standard 1500 MTU ethernet interface, we would have to + * restrict the data payload of our outgoing UDP packets to 1500 - 30 = 1470 + * bytes (this is what our minimum "buffer size" setting should use). These + * packets will however also be encapsulated using PPP, thus an extra 8 bytes + * per packet are reserved. The safe MTU for our PPP interface would + * therefore become 1472 bytes, the maximum which we could safely transit + * without incurring IP fragmentation. + * + * XXX + * + * UDP packets with a payload of Thus, it should be + * safe to use an MTU of 1500 - 38 = 1472 to tunnel via UDP over a standard + * 1500 MTU ethernet interface if we wanted to avoid IP fragmentation. + * + * Make sure to choose the buffer size and interface MTU by taking into + * account the ethernet (64 bytes), IP and PPP overhead. For IPv4, accounting for 188 + * bytes of overhead should be safe. Thus, to avoid IP fragmentation of our + * outgoing UDP packets over a 1500 MTU ethernet interface, we should ensure + * to use a PPP interface of 1500 - 168 (1332) and a buffer size of 1500 - 20 + * (1480). + * + * If we want to avoid IP fragmentation of the UDP packets we send over an + * 1500 MTU ethernet interface, we thus should ensure to use an MTU of + * 1500 - 8 - 20 - 20 for IPv4, + * + * Example usage (setup a throttled link from 192.168.1.13 to 192.168.1.1 to * create a PPP connection from us (10.0.0.13 to the gateway (10.0.0.1)). * Here we avoid IP fragmentation by using an MTU of 1340 bytes. * @@ -45,6 +80,13 @@ * implementation with a 1024 bytes limit, an MTU of 856 bytes and buffer size * of 1024 bytes can be used safely. This will reduce performance as more * context switches are required. + * + * server_pty=$(./tty-udp -b 4188 -f /tmp/tty-udp-server.pid -a 192.168.1.15 \ + * -p 8001 -A 192.168.1.15 -P 8015) + * client_pty=$(./tty-udp -b 4188 -f /tmp/tty-udp-client.pid -a 192.168.1.15 \ + * -p 8015 -A 192.168.1.15 -P 8001) + * pppd $server_pty 10.0.0.1:10.0.0.15 mru 4000 + * pppd $client_pty 10.0.0.15:10.0.0.1 mru 4000 */ /* @@ -323,19 +365,11 @@ fd_nonblock(int fd) err(EXIT_FAILURE, "fcntl()"); } -/* To test -current kernel patch without -current headers */ -#ifdef USE_TIOCSQSIZE_PATCH -#define TIOCGQSIZE _IOR('t', 129, int) /* get queue size */ -#define TIOCSQSIZE _IOW('t', 128, int) /* set queue size */ -#endif - static int pty_open(void) { int fd; -#ifdef USE_TIOCSQSIZE_PATCH int opt; -#endif if ((fd = posix_openpt(O_RDWR)) == -1) err(EXIT_FAILURE, "Couldn't pty(4) device"); @@ -343,7 +377,6 @@ pty_open(void) err(EXIT_FAILURE, "Couldn't grant permissions on tty(4) device"); -#ifdef USE_TIOCSQSIZE_PATCH /* * Note that tty(4)-side should also do this, unless sysctl-set buffer * size is large enough already. @@ -351,8 +384,6 @@ pty_open(void) opt = (int)buffer_size; if (ioctl(fd, TIOCSQSIZE, &opt) == -1) err(EXIT_FAILURE, "Couldn't set pty(4) buffer size"); -#endif - if (unlockpt(fd) == -1) err(EXIT_FAILURE, "unlockpt()");