diff --git a/docker-test/lib/liblwip.so b/docker-test/lib/liblwip.so deleted file mode 100755 index 9c1299598..000000000 Binary files a/docker-test/lib/liblwip.so and /dev/null differ diff --git a/docker-test/throughput-test/Dockerfile b/docker-test/throughput-test/Dockerfile new file mode 100644 index 000000000..b98def3e0 --- /dev/null +++ b/docker-test/throughput-test/Dockerfile @@ -0,0 +1,37 @@ +# ZT Netcon Throughput test +FROM fedora:22 +MAINTAINER https://www.zerotier.com/ + +# Install Apache +RUN yum -y update && yum clean all +RUN yum -y install httpd && yum clean all + +EXPOSE 9993/udp 9992/udp 9991/udp 9990/udp + +# Add ZT files +RUN mkdir -p /var/lib/zerotier-one/networks.d +RUN touch /var/lib/zerotier-one/networks.d/e5cd7a9e1c5311ab.conf +ADD zerotier-one / +ADD zerotier-cli / + +# Install sys-call intercept library +ADD intercept / +ADD libintercept.so.1.0 / +RUN cp libintercept.so.1.0 lib/libintercept.so.1.0 +RUN cp libintercept.so.1.0 /lib/libintercept.so.1.0 +RUN ln -sf /lib/libintercept.so.1.0 /lib/libintercept +RUN /usr/bin/install -c intercept /usr/bin + +# Install test-setup scripts +ADD generate_file.sh /generate_file.sh +RUN chmod -v +x /generate_file.sh +ADD entrypoint.sh /entrypoint.sh +RUN chmod -v +x /entrypoint.sh + +# Install LWIP library used by service +ADD liblwip.so / +RUN mkdir -p ext/bin/lwip +RUN cp liblwip.so ext/bin/lwip/liblwip.so + +# Start ZeroTier-One +CMD ["./entrypoint.sh"] diff --git a/docker-test/throughput-test/build.sh b/docker-test/throughput-test/build.sh new file mode 100755 index 000000000..290053d9b --- /dev/null +++ b/docker-test/throughput-test/build.sh @@ -0,0 +1,15 @@ +cd ../../ +make +cd netcon +make -f make-intercept.mk lib +rm *.o +rm liblwip.so +make -f make-liblwip.mk +cd ../docker-test/throughput-test + +cp ../../zerotier-one zerotier-one +cp ../../zerotier-cli zerotier-cli + +cp ../../netcon/liblwip.so liblwip.so +cp ../../netcon/libintercept.so.1.0 libintercept.so.1.0 + diff --git a/docker-test/throughput-test/entrypoint.sh b/docker-test/throughput-test/entrypoint.sh new file mode 100644 index 000000000..00fdd2be6 --- /dev/null +++ b/docker-test/throughput-test/entrypoint.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/ + +echo '***' +echo '*** ZeroTier Network Containers Test Image' +echo '*** https://www.zerotier.com/' +echo '***' + +./zerotier-one & +./zerotier-cli join e5cd7a9e1c5311ab +./zerotier-cli listnetworks + + diff --git a/docker-test/throughput-test/generate_file.sh b/docker-test/throughput-test/generate_file.sh new file mode 100644 index 000000000..fd84de329 --- /dev/null +++ b/docker-test/throughput-test/generate_file.sh @@ -0,0 +1 @@ +dd if=/dev/urandom of=/var/www/html/bigfile bs=100M count=1 diff --git a/docker-test/throughput-test/intercept b/docker-test/throughput-test/intercept new file mode 100755 index 000000000..3eb27ff7b --- /dev/null +++ b/docker-test/throughput-test/intercept @@ -0,0 +1,54 @@ +#!/bin/sh +# usage: +# /usr/bin/intercept program + +if [ $# = 0 ] ; then + echo "$0: insufficient arguments" + exit +fi + +case "$1" in + on) + if [ -z "$LD_PRELOAD" ] + then + export LD_PRELOAD="/lib/libintercept.so.1.0" + else + echo $LD_PRELOAD | grep -q "/lib/libintercept\.so.1.0" || \ + export LD_PRELOAD="/lib/libintercept.so $LD_PRELOAD" + fi + ;; + off) + export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/lib\/libintercept.so.1.0 \?//'` + if [ -z "$LD_PRELOAD" ] + then + unset LD_PRELOAD + fi + ;; + show|sh) + echo "LD_PRELOAD=\"$LD_PRELOAD\"" + ;; + -h|-?) + echo "" + ;; + *) + if [ -z "$LD_PRELOAD" ] + then + export LD_PRELOAD="/lib/libintercept.so.1.0" + else + echo $LD_PRELOAD | grep -q "/lib/libintercept\.so.1.0" || \ + export LD_PRELOAD="/lib/libintercept.so.1.0 $LD_PRELOAD" + fi + + if [ $# = 0 ] + then + ${SHELL:-/bin/sh} + fi + + if [ $# -gt 0 ] + then + exec "$@" + fi + ;; +esac + +#EOF diff --git a/ext/bin/lwip/liblwip.so b/ext/bin/lwip/liblwip.so index aba90d8e9..722e40f67 100755 Binary files a/ext/bin/lwip/liblwip.so and b/ext/bin/lwip/liblwip.so differ diff --git a/ext/bin/lwip/liblwip.so.bak b/ext/bin/lwip/liblwip.so.bak deleted file mode 100755 index aba90d8e9..000000000 Binary files a/ext/bin/lwip/liblwip.so.bak and /dev/null differ diff --git a/ext/bin/lwip/liblwip.so.debug b/ext/bin/lwip/liblwip.so.debug deleted file mode 100755 index 86c36665e..000000000 Binary files a/ext/bin/lwip/liblwip.so.debug and /dev/null differ diff --git a/ext/bin/lwip/liblwip.so.no-opt b/ext/bin/lwip/liblwip.so.no-opt deleted file mode 100755 index 71859331c..000000000 Binary files a/ext/bin/lwip/liblwip.so.no-opt and /dev/null differ diff --git a/ext/lwipopts.h b/ext/lwipopts.h index 6b95e9b5e..4eb5e1abd 100644 --- a/ext/lwipopts.h +++ b/ext/lwipopts.h @@ -44,9 +44,21 @@ */ #include "lwip/debug.h" +#define TCP_MSS 1400 -//#define TCP_MSS 2048 -//#define TCP_WND 512 +/* +The TCP window size can be adjusted by changing the define TCP_WND. However, +do keep in mind that this should be at least twice the size of TCP_MSS (thus +on ethernet, where TCP_MSS is 1460, it should be set to at least 2920). If +memory allows it, set this as high as possible (16-bit, so 0xFFFF is the highest +value), but keep in mind that for every active connection, the full window may +have to be buffered until it is acknowledged by the remote side (although this +buffer size can still be controlled by TCP_SND_BUF and TCP_SND_QUEUELEN). The +reason for "twice" are both the nagle algorithm and delayed ACK from the +remote peer. +*/ + +#define TCP_WND TCP_MSS*10 // max = 0xffff #define LWIP_NOASSERT 1 #define TCP_LISTEN_BACKLOG 0 @@ -54,7 +66,14 @@ /*------------------------------------------------------------------------------ ---------------------------------- Timers -------------------------------------- ------------------------------------------------------------------------------*/ - +/* +Be careful about setting this too small. lwIP just counts the number +of times its timer is called and uses this to control time sensitive +operations (such as TCP retransmissions), rather than actually +measuring time using something more accurate. If you call the timer +functions very frequently you may see things (such as retransmissions) +happening sooner than they should. +*/ /* these are originally defined in tcp_impl.h */ #ifndef TCP_TMR_INTERVAL /* The TCP timer interval in milliseconds. */ @@ -116,8 +135,9 @@ */ #define MEM_SIZE 1024 * 1024 * 64 #define TCP_SND_BUF 1024 * 63 +//#define TCP_OVERSIZE TCP_MSS -#define TCP_SND_QUEUELEN 1024 +#define TCP_SND_QUEUELEN (2 * TCP_SND_BUF/TCP_MSS) /*------------------------------------------------------------------------------ -------------------------- Internal Memory Pool Sizes -------------------------- ------------------------------------------------------------------------------*/ @@ -209,7 +229,7 @@ /** * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ -#define PBUF_POOL_SIZE 128 /* was 32 */ +#define PBUF_POOL_SIZE 2048 /* was 32 */ /*------------------------------------------------------------------------------ diff --git a/netcon/NetconEthernetTap.cpp b/netcon/NetconEthernetTap.cpp index b6d7e2ce5..a4e2eacd6 100644 --- a/netcon/NetconEthernetTap.cpp +++ b/netcon/NetconEthernetTap.cpp @@ -50,8 +50,8 @@ #include "NetconUtilities.hpp" #define APPLICATION_POLL_FREQ 20 -#define ZT_LWIP_TCP_TIMER_INTERVAL 10 -#define STATUS_TMR_INTERVAL 1000 // How often we check connection statuses +#define ZT_LWIP_TCP_TIMER_INTERVAL 50 +#define STATUS_TMR_INTERVAL 2000 // How often we check connection statuses #define DEBUG_LEVEL 3 namespace ZeroTier { @@ -416,7 +416,7 @@ void NetconEthernetTap::threadMain() uint64_t prev_status_time = 0; uint64_t prev_etharp_time = 0; -/* + fprintf(stderr, "- MEM_SIZE = %dM\n", MEM_SIZE / (1024*1024)); fprintf(stderr, "- TCP_SND_BUF = %dK\n", TCP_SND_BUF / 1024); fprintf(stderr, "- MEMP_NUM_PBUF = %d\n", MEMP_NUM_PBUF); @@ -432,7 +432,7 @@ void NetconEthernetTap::threadMain() fprintf(stderr, "- ARP_TMR_INTERVAL = %d\n", ARP_TMR_INTERVAL); fprintf(stderr, "- TCP_TMR_INTERVAL = %d\n", TCP_TMR_INTERVAL); fprintf(stderr, "- IP_TMR_INTERVAL = %d\n", IP_TMR_INTERVAL); -*/ + // Main timer loop while (_run) { @@ -928,7 +928,7 @@ err_t NetconEthernetTap::nc_sent(void* arg, struct tcp_pcb *tpcb, u16_t len) Larg *l = (Larg*)arg; if(len) { l->conn->acked+=len; - dwr("W = %d, A = %d\n", l->conn->written, l->conn->acked); + //dwr("W = %d, A = %d\n", l->conn->written, l->conn->acked); l->tap->_phy.setNotifyReadable(l->conn->dataSock, true); l->tap->_phy.whack(); } @@ -1397,7 +1397,7 @@ void NetconEthernetTap::handle_write(TcpConnection *conn) memmove(&conn->buf, (conn->buf+r), sz); } conn->idx -= r; - conn->written+=err; + conn->written+=r; return; } } diff --git a/netcon/liblwip.so b/netcon/liblwip.so deleted file mode 100755 index aba90d8e9..000000000 Binary files a/netcon/liblwip.so and /dev/null differ