Browse Source

Added throughput-test Docker files

Joseph Henry 9 years ago
parent
commit
4b07987210

BIN
docker-test/lib/liblwip.so


+ 37 - 0
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"]

+ 15 - 0
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
+

+ 14 - 0
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
+
+

+ 1 - 0
docker-test/throughput-test/generate_file.sh

@@ -0,0 +1 @@
+dd if=/dev/urandom of=/var/www/html/bigfile  bs=100M  count=1

+ 54 - 0
docker-test/throughput-test/intercept

@@ -0,0 +1,54 @@
+#!/bin/sh
+# usage:
+# /usr/bin/intercept program <args>
+
+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

BIN
ext/bin/lwip/liblwip.so


BIN
ext/bin/lwip/liblwip.so.bak


BIN
ext/bin/lwip/liblwip.so.debug


BIN
ext/bin/lwip/liblwip.so.no-opt


+ 25 - 5
ext/lwipopts.h

@@ -44,9 +44,21 @@
  */
  */
 #include "lwip/debug.h"
 #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 LWIP_NOASSERT 1
 #define TCP_LISTEN_BACKLOG   0
 #define TCP_LISTEN_BACKLOG   0
@@ -54,7 +66,14 @@
 /*------------------------------------------------------------------------------
 /*------------------------------------------------------------------------------
 ---------------------------------- Timers --------------------------------------
 ---------------------------------- 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 */
 /* these are originally defined in tcp_impl.h */
 #ifndef TCP_TMR_INTERVAL
 #ifndef TCP_TMR_INTERVAL
 /* The TCP timer interval in milliseconds. */
 /* The TCP timer interval in milliseconds. */
@@ -116,8 +135,9 @@
  */
  */
 #define MEM_SIZE                        1024 * 1024 * 64
 #define MEM_SIZE                        1024 * 1024 * 64
 #define TCP_SND_BUF                     1024 * 63
 #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 --------------------------
 -------------------------- Internal Memory Pool Sizes --------------------------
 ------------------------------------------------------------------------------*/
 ------------------------------------------------------------------------------*/
@@ -209,7 +229,7 @@
 /**
 /**
  * PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
  * 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 */
 
 
 
 
 /*------------------------------------------------------------------------------
 /*------------------------------------------------------------------------------

+ 6 - 6
netcon/NetconEthernetTap.cpp

@@ -50,8 +50,8 @@
 #include "NetconUtilities.hpp"
 #include "NetconUtilities.hpp"
 
 
 #define APPLICATION_POLL_FREQ 				20
 #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
 #define DEBUG_LEVEL 									3
 
 
 namespace ZeroTier {
 namespace ZeroTier {
@@ -416,7 +416,7 @@ void NetconEthernetTap::threadMain()
 	uint64_t prev_status_time = 0;
 	uint64_t prev_status_time = 0;
 	uint64_t prev_etharp_time = 0;
 	uint64_t prev_etharp_time = 0;
 
 
-/*
+
 	fprintf(stderr, "- MEM_SIZE = %dM\n", MEM_SIZE / (1024*1024));
 	fprintf(stderr, "- MEM_SIZE = %dM\n", MEM_SIZE / (1024*1024));
 	fprintf(stderr, "- TCP_SND_BUF = %dK\n", TCP_SND_BUF / 1024);
 	fprintf(stderr, "- TCP_SND_BUF = %dK\n", TCP_SND_BUF / 1024);
 	fprintf(stderr, "- MEMP_NUM_PBUF = %d\n", MEMP_NUM_PBUF);
 	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, "- ARP_TMR_INTERVAL = %d\n", ARP_TMR_INTERVAL);
 	fprintf(stderr, "- TCP_TMR_INTERVAL = %d\n", TCP_TMR_INTERVAL);
 	fprintf(stderr, "- TCP_TMR_INTERVAL = %d\n", TCP_TMR_INTERVAL);
 	fprintf(stderr, "- IP_TMR_INTERVAL  = %d\n", IP_TMR_INTERVAL);
 	fprintf(stderr, "- IP_TMR_INTERVAL  = %d\n", IP_TMR_INTERVAL);
-*/
+
 
 
 	// Main timer loop
 	// Main timer loop
 	while (_run) {
 	while (_run) {
@@ -928,7 +928,7 @@ err_t NetconEthernetTap::nc_sent(void* arg, struct tcp_pcb *tpcb, u16_t len)
 	Larg *l = (Larg*)arg;
 	Larg *l = (Larg*)arg;
 	if(len) {
 	if(len) {
 		l->conn->acked+=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.setNotifyReadable(l->conn->dataSock, true);
 		l->tap->_phy.whack();
 		l->tap->_phy.whack();
 	}
 	}
@@ -1397,7 +1397,7 @@ void NetconEthernetTap::handle_write(TcpConnection *conn)
 							memmove(&conn->buf, (conn->buf+r), sz);
 							memmove(&conn->buf, (conn->buf+r), sz);
 						}
 						}
 						conn->idx -= r;
 						conn->idx -= r;
-						conn->written+=err;
+						conn->written+=r;
 						return;
 						return;
 					}
 					}
 				}
 				}

BIN
netcon/liblwip.so