+#define DIR_READ 1
+#define DIR_WRITE 2
+
+static struct utcp_connection *c;
+static int dir = DIR_READ | DIR_WRITE;
+static long inpktno;
+static long outpktno;
+static long dropfrom;
+static long dropto;
+static double reorder;
+static long reorder_dist = 10;
+static double dropin;
+static double dropout;
+static long total_out;
+static long total_in;
+static FILE *reference;
+static long mtu;
+static long bufsize;
+
+static char *reorder_data;
+static size_t reorder_len;
+static int reorder_countdown;
+
+#if UTCP_DEBUG
+static void debug(const char *format, ...) {
+ struct timespec tv;
+ char buf[1024];
+ int len;
+
+ clock_gettime(CLOCK_REALTIME, &tv);
+ len = snprintf(buf, sizeof(buf), "%ld.%06lu ", (long)tv.tv_sec, tv.tv_nsec / 1000);
+ va_list ap;
+ va_start(ap, format);
+ len += vsnprintf(buf + len, sizeof(buf) - len, format, ap);
+ va_end(ap);
+
+ if(len > 0 && (size_t)len < sizeof(buf)) {
+ fwrite(buf, len, 1, stderr);
+ }
+}
+#else
+#define debug(...) do {} while(0)
+#endif
+
+static ssize_t do_recv(struct utcp_connection *c, const void *data, size_t len) {
+ (void)c;