diff --git a/src/analyze.c b/src/analyze.c
index 26e877d..5ec57af 100644
--- a/src/analyze.c
+++ b/src/analyze.c
@@ -30,8 +30,8 @@
 #include <sys/select.h>
 #include <math.h>
 
-#include "usage.h"
-#include "logging.h"
+#include "./usage.h"
+#include "./logging.h"
 
 #define LOGFILE "web100srv.log"
 #define PROTOLOGFILE "web100srvprotocol.log" /* protocol validation log */
@@ -39,12 +39,13 @@
 #define WEB100_FILE "web100_variables"  /*names of the variables to access*/
 #define BUFFSIZE 512
 
-char buff[BUFFSIZE + 1];int window = 64000;
+char buff[BUFFSIZE + 1];
+int window = 64000;
 int randomize = 0;
 char *rmt_host;
 char *VarFileName = NULL;
 char *LogFileName = NULL;
-char *ProtoLogFileName = NULL; // Log file used to log protocol validation logs
+char *ProtoLogFileName = NULL;  // Log file used to log protocol validation logs
 double avgrtt, loss, loss2, rttsec, bw, bw2, rwin, swin, cwin, speed;
 double rwintime, cwndtime, sendtime, timesec;
 int n, m, one = 1;
@@ -57,14 +58,15 @@ int CongestionOverCount, CongAvoid, SlowStart, MaxRTT, OtherReductions;
 int CurTimeouts, AbruptTimeouts, SendStall, SubsequentTimeouts;
 int autotune, ThruBytesAcked;
 int link = 0, mismatch = 0, bad_cable = 0, half_duplex = 0, congestion = 0,
-		totaltime;
+    totaltime;
 int i, spd, ret;
 double order, idle, cpu_idle1, cpu_idle2;
 char *name, ip_addr[64], ip_addr2[64];
 FILE *fp;
 int indx, links[4][16], max, total;
 float runave[4];
-int c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack;
+int c2s_linkspeed_data, c2s_linkspeed_ack,
+    s2c_linkspeed_data, s2c_linkspeed_ack;
 int j;
 char spds[4][256], buff2[32];
 char *str, tmpstr[32];
@@ -73,868 +75,867 @@ int s2c2spd, c2sspd, s2cspd, iponly;
 int linkcnt, mismatch2, mismatch3;
 
 static struct option long_options[] = { { "debug", 0, 0, 'd' }, { "nodns", 0, 0,
-		'n' }, { "help", 0, 0, 'h' }, { "log", 1, 0, 'l' }, { "version", 0, 0,
-		'v' }, { 0, 0, 0, 0 } };
+  'n' }, { "help", 0, 0, 'h' }, { "log", 1, 0, 'l' }, { "version", 0, 0,
+    'v' }, { 0, 0, 0, 0 } };
 
 int err_sys(char* s) {
-	perror(s);
-	exit(1);
+  perror(s);
+  exit(1);
 }
 
 void calculate() {
-	int tail[4], i, head[4], tmpret;
-	float k;
-	float recvbwd, cwndbwd, sendbwd;
-	char btlneck[64];
-	int congestion2 = 0;
-	I2Addr addr;
-	double acks, aspeed, pureacks;
-	float cong, retrn, increase, touts, fr_ratio = 0;
-	float retransec;
-
-	tail[0] = tail[1] = tail[2] = tail[3] = 0;
-	head[0] = head[1] = head[2] = head[3] = 0;
-	for (i = 0; i < 4; i++) {
-		max = 0;
-		indx = 0;
-		total = 0;
-		for (j = 0; j < linkcnt - 1; j++) {
-			total += links[i][j];
-			if (max < links[i][j]) {
-				max = links[i][j];
-				indx = j;
-			}
-		}
-		for (j = indx + 1; j < 10; j++) {
-			k = (float) links[i][j] / max;
-			if (k > .1)
-				tail[i]++;
-		}
-		for (j = 0; j < indx; j++) {
-			k = (float) links[i][j] / max;
-			if (k > .1)
-				head[i]++;
-		}
-		if (links[i][indx] == -1)
-			indx = -1;
-		if ((total < 20) && (indx != -1))
-			indx = -2;
-		switch (i) {
-		case 0:
-			c2s_linkspeed_data = indx;
-			log_print(1, "Client --> Server data detects link = ");
-			break;
-		case 1:
-			c2s_linkspeed_ack = indx;
-			log_print(1, "Client <-- Server Ack's detect link = ");
-			break;
-		case 2:
-			s2c_linkspeed_data = indx;
-			log_print(1, "Server --> Client data detects link = ");
-			break;
-		case 3:
-			s2c_linkspeed_ack = indx;
-			log_print(1, "Server <-- Client Ack's detect link = ");
-		}
-
-		/*
-		switch (indx) {
-		case -2:
-			log_println(1, "Insufficent Data");
-			break;
-		case -1:
-			log_println(1, "System Fault");
-			break;
-		case 0:
-			log_println(1, "RTT");
-			break;
-		case 1:
-			log_println(1, "Dial-up");
-			break;
-		case 2:
-			log_println(1, "T1");
-			break;
-		case 3:
-			log_println(1, "Ethernet");
-			break;
-		case 4:
-			log_println(1, "T3");
-			break;
-		case 5:
-			log_println(1, "FastEthernet");
-			break;
-		case 6:
-			log_println(1, "OC-12");
-			break;
-		case 7:
-			log_println(1, "Gigabit Ethernet");
-			break;
-		case 8:
-			log_println(1, "OC-48");
-			break;
-		case 9:
-			log_println(1, "10 Gigabit Enet");
-			break;
-		case 10:
-			log_println(1, "Retransmissions");
-			break;
-		}
-		*/
-		log_linkspeed(indx);
-	}
-	switch (c2s_linkspeed_data) {
-	case -2:
-		snprintf(btlneck, sizeof(btlneck), "Insufficent Data");
-		break;
-	case -1:
-		snprintf(btlneck, sizeof(btlneck), "a System Fault");
-		break;
-	case 0:
-		snprintf(btlneck, sizeof(btlneck), "the Round Trip Time");
-		break;
-	case 1:
-		snprintf(btlneck, sizeof(btlneck), "a 'Dial-up modem' connection");
-		break;
-	case 2:
-		if ((c2sspd / s2cspd > .8) && (c2sspd / s2cspd < 1.2)
-				&& (c2sspd > 1000))
-			snprintf(btlneck, sizeof(btlneck), "a 'T1' subnet");
-		else {
-			if ((tail[3] > 1) || (s2c_linkspeed_ack == 3))
-				snprintf(btlneck, sizeof(btlneck), "a 'Cable Modem' connection");
-			else
-				snprintf(btlneck, sizeof(btlneck), "a 'DSL' connection");
-		}
-		break;
-	case 3:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a T1 + subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "an 'Ethernet' subnet");
-		break;
-	case 4:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a IEEE 802.11b Wifi subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "a 'T3/DS-3' subnet");
-		break;
-	case 5:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a Wifi + subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "a 'FastEthernet' subnet");
-		break;
-	case 6:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a Ethernet subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "an 'OC-12' subnet");
-		break;
-	case 7:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a T3/DS3 subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "a 'Gigabit Ethernet' subnet");
-		break;
-	case 8:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a FastEthernet subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "an 'OC-48' subnet");
-		break;
-	case 9:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a OC-12 subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "a '10 Gigabit Enet' subnet");
-		break;
-	case 10:
-		if (linkcnt == 16)
-			snprintf(btlneck, sizeof(btlneck), "a Gigabit Ethernet subnet");
-		else
-			snprintf(btlneck, sizeof(btlneck), "Retransmissions");
-	case 11:
-		snprintf(btlneck, sizeof(btlneck), "an 'OC-48' subnet");
-		break;
-	case 12:
-		snprintf(btlneck, sizeof(btlneck), "a '10 Gigabit Enet' subnet");
-		break;
-	case 13:
-		snprintf(btlneck, sizeof(btlneck), "Retransmissions");
-		break;
-	}
-	/* Calculate some values */
-	avgrtt = (double) SumRTT / CountRTT;
-	rttsec = avgrtt * .001;
-	loss = (double) (PktsRetrans - FastRetran)
-			/ (double) (DataPktsOut - AckPktsOut);
-	loss2 = (double) CongestionSignals / PktsOut;
-	if (loss == 0)
-		loss = .0000000001; /* set to 10^-6 for now */
-	if (loss2 == 0)
-		loss2 = .0000000001; /* set to 10^-6 for now */
-
-	order = (double) DupAcksIn / AckPktsIn;
-	bw = (CurrentMSS / (rttsec * sqrt(loss))) * 8 / 1024 / 1024;
-	bw2 = (CurrentMSS / (rttsec * sqrt(loss2))) * 8 / 1024 / 1024;
-	totaltime = SndLimTimeRwin + SndLimTimeCwnd + SndLimTimeSender;
-	rwintime = (double) SndLimTimeRwin / totaltime;
-	cwndtime = (double) SndLimTimeCwnd / totaltime;
-	sendtime = (double) SndLimTimeSender / totaltime;
-	timesec = totaltime / 1000000;
-	idle = (Timeouts * ((double) CurrentRTO / 1000)) / timesec;
-	retrn = (float) PktsRetrans / PktsOut;
-	increase = (float) CongAvoid / PktsOut;
-
-	recvbwd = ((MaxRwinRcvd * 8) / avgrtt) / 1000;
-	cwndbwd = ((CurrentCwnd * 8) / avgrtt) / 1000;
-	sendbwd = ((Sndbuf * 8) / avgrtt) / 1000;
-
-	spd = ((double) DataBytesOut / (double) totaltime) * 8;
-
-	mismatch2 = 0;
-	mismatch3 = 0;
-	mmorder = (float) (DataPktsOut - PktsRetrans - FastRetran) / DataPktsOut;
-	cong = (float) (CongestionSignals - CongestionOverCount) / PktsOut;
-	touts = (float) Timeouts / PktsOut;
-	if (PktsRetrans > 0)
-		fr_ratio = (float) FastRetran / PktsRetrans;
-	retransec = (float) PktsRetrans / timesec;
-
-	/* new test based on analysis of TCP behavior in duplex mismatch condition. */
-
-	acks = (double) AckPktsIn / (double) DataPktsOut;
-	pureacks = (double) (AckPktsIn - DupAcksIn) / (double) DataPktsOut;
-	if (s2cspd < c2sspd)
-		aspeed = (double) c2sspd / (double) s2cspd;
-	else
-		aspeed = (double) s2cspd / (double) c2sspd;
-	printf(
-			"Acks = %0.4f,  async speed = %0.4f, mismatch3 = %0.4f, CongOver = %d\n",
-			acks, aspeed, cong, CongestionOverCount);
-	printf(
-			"idle = %0.4f, timeout/pkts = %0.4f, %%retranmissions = %0.2f, %%increase = %0.2f\n",
-			idle, touts, retrn * 100, increase * 100);
-	printf(
-			"FastRetrans/Total = %0.4f, Fast/Retrans = %0.4f, Retrans/sec = %0.4f\n",
-			retrn, fr_ratio, retransec);
-	if (((acks > 0.7) || (acks < 0.3)) && (retrn > 0.03)
-			&& (CongAvoid > SlowStart)) {
-		if ((2 * CurrentMSS) == MaxSsthresh) {
-			mismatch2 = 1;
-			mismatch3 = 0;
-		} else if (aspeed > 15) {
-			mismatch2 = 2;
-		}
-	}
-	if ((idle > 0.65) && (touts < 0.4)) {
-		if (MaxSsthresh == (2 * CurrentMSS)) {
-			mismatch2 = 0;
-			mismatch3 = 1;
-		} else {
-			mismatch3 = 2;
-		}
-	}
-
-	/* estimate is less than throughput, something is wrong */
-	if (bw < spd)
-		link = 0;
-
-	if (((loss * 100) / timesec > 15) && (cwndtime / timesec > .6)
-			&& (loss < .01) && (MaxSsthresh > 0))
-		bad_cable = 1;
-
-	/* test for Ethernet link (assume Fast E.) */
-	if ((spd < 9.5) && (spd > 3.0) && (loss < .01) && (order < .035)
-			&& (link > 0))
-		link = 10;
-
-	/* test for DSL/Cable modem link */
-	if ((SndLimTimeSender < 15000) && (spd < 2) && (spd < bw) && (link > 0))
-		link = 2;
-
-	if (((rwintime > .95) && (SndLimTransRwin / timesec > 30)
-			&& (SndLimTransSender / timesec > 30)) || (link <= 10))
-		half_duplex = 1;
-
-	if ((cwndtime > .02) && (mismatch2 == 0) && (cwndbwd < recvbwd))
-		congestion2 = 1;
-
-	if (iponly == 0) {
-		char tmpbuff[200];
-		socklen_t tmpBufLen = 199;
-		if ((addr = I2AddrByNode(get_errhandle(), ip_addr)) == NULL) {
-			printf("Throughput to host [%s] is limited by %s\n", ip_addr,
-					btlneck);
-		} else {
-			struct addrinfo *fai;
-			fai = I2AddrAddrInfo(addr, ip_addr, NULL);
-			if (fai == NULL) {
-				printf("Throughput to host [%s] is limited by %s\n", ip_addr,
-						btlneck);
-			} else {
-				memset(tmpbuff, 0, 200);
-				if ((tmpret = getnameinfo(fai->ai_addr, fai->ai_addrlen,
-						tmpbuff, tmpBufLen, NULL, 0, 0))) {
-					log_println(1, "getnameinfo: %d", tmpret);
-					printf("Throughput to host [%s] is limited by %s\n",
-							ip_addr, btlneck);
-				} else {
-					printf("Throughput to host %s [%s] is limited by %s\n",
-							tmpbuff, ip_addr, btlneck);
-				}
-			}
-		}
-	} else {
-		printf("Throughput to host [%s] is limited by %s\n", ip_addr, btlneck);
-	}
-
-	printf("\tWeb100 says link = %d, speed-chk says link = %d\n", link,
-			c2s_linkspeed_data);
-	printf(
-			"\tSpeed-chk says {%d, %d, %d, %d}, Running average = {%0.1f, %0.1f, %0.1f, %0.1f}\n",
-			c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack, runave[0], runave[1], runave[2],
-			runave[3]);
-	if (c2sspd > 1000)
-		printf(
-				"\tC2Sspeed = %0.2f Mbps, S2Cspeed = %0.2f Mbps, CWND-Limited = %0.2f Mbps, ",
-				(float) c2sspd / 1000, (float) s2cspd / 1000,
-				(float) s2c2spd / 1000);
-	else
-		printf(
-				"\tC2Sspeed = %d kbps, S2Cspeed = %d kbps, CWND-Limited: %d kbps, ",
-				c2sspd, s2cspd, s2c2spd);
-	if (bw > 1)
-		printf("Estimate = %0.2f Mbps (%0.2f Mbps)\n", bw, bw2);
-	else
-		printf("Estimate = %0.2f kbps (%0.2f kbps)\n", bw * 1000, bw2 * 1000);
-
-	if ((bw * 1000) > s2cspd)
-		printf("\tOld estimate is greater than measured; ");
-	else
-		printf("\tOld estimate is less than measured; ");
-
-	if (CongestionSignals == -1)
-		printf("No data collected to calculage new estimate\n");
-	else {
-		if ((bw2 * 1000) > s2cspd)
-			printf("New estimate is greater than measured\n");
-		else
-			printf("New estimate is less than measured\n");
-	}
-
-	printf(
-			"\tLoss = %0.2f%% (%0.2f%%), Out-of-Order = %0.2f%%, Long tail = {%d, %d, %d, %d}\n",
-			loss * 100, loss2 * 100, order * 100, tail[0], tail[1], tail[2],
-			tail[3]);
-	printf(
-			"\tDistribution = {%d, %d, %d, %d}, time spent {r=%0.1f%% c=%0.1f%% s=%0.1f%%}\n",
-			head[0], head[1], head[2], head[3], rwintime * 100, cwndtime * 100,
-			sendtime * 100);
-	printf("\tAve(min) RTT = %0.2f (%d) msec, Buffers = {r=%d, c=%d, s=%d}\n",
-			avgrtt, MinRTT, MaxRwinRcvd, CurrentCwnd, Sndbuf / 2);
-	printf(
-			"\tbw*delay = {r=%0.2f, c=%0.2f, s=%0.2f}, Transitions/sec = {r=%0.1f, c=%0.1f, s=%0.1f}\n",
-			recvbwd, cwndbwd, sendbwd, SndLimTransRwin / timesec,
-			SndLimTransCwnd / timesec, SndLimTransSender / timesec);
-	printf(
-			"\tRetransmissions/sec = %0.1f, Timeouts/sec = %0.1f, SSThreshold = %d\n",
-			(float) PktsRetrans / timesec, (float) Timeouts / timesec,
-			MaxSsthresh);
-	printf("\tMismatch = %d (%d:%d[%0.2f])", mismatch, mismatch2, mismatch3,
-			mmorder);
-	if (mismatch3 == 1)
-		printf(" [H=F, S=H]");
-	if (mismatch2 == 1)
-		printf(" [H=H, S=F]");
-	printf(", Cable fault = %d, Congestion = %d, Duplex = %d\n\n", bad_cable,
-			congestion2, half_duplex);
+  int tail[4], i, head[4], tmpret;
+  float k;
+  float recvbwd, cwndbwd, sendbwd;
+  char btlneck[64];
+  int congestion2 = 0;
+  I2Addr addr;
+  double acks, aspeed, pureacks;
+  float cong, retrn, increase, touts, fr_ratio = 0;
+  float retransec;
+
+  tail[0] = tail[1] = tail[2] = tail[3] = 0;
+  head[0] = head[1] = head[2] = head[3] = 0;
+  for (i = 0; i < 4; i++) {
+    max = 0;
+    indx = 0;
+    total = 0;
+    for (j = 0; j < linkcnt - 1; j++) {
+      total += links[i][j];
+      if (max < links[i][j]) {
+        max = links[i][j];
+        indx = j;
+      }
+    }
+    for (j = indx + 1; j < 10; j++) {
+      k = (float) links[i][j] / max;
+      if (k > .1)
+        tail[i]++;
+    }
+    for (j = 0; j < indx; j++) {
+      k = (float) links[i][j] / max;
+      if (k > .1)
+        head[i]++;
+    }
+    if (links[i][indx] == -1)
+      indx = -1;
+    if ((total < 20) && (indx != -1))
+      indx = -2;
+    switch (i) {
+      case 0:
+        c2s_linkspeed_data = indx;
+        log_print(1, "Client --> Server data detects link = ");
+        break;
+      case 1:
+        c2s_linkspeed_ack = indx;
+        log_print(1, "Client <-- Server Ack's detect link = ");
+        break;
+      case 2:
+        s2c_linkspeed_data = indx;
+        log_print(1, "Server --> Client data detects link = ");
+        break;
+      case 3:
+        s2c_linkspeed_ack = indx;
+        log_print(1, "Server <-- Client Ack's detect link = ");
+    }
+
+    /*
+       switch (indx) {
+       case -2:
+       log_println(1, "Insufficent Data");
+       break;
+       case -1:
+       log_println(1, "System Fault");
+       break;
+       case 0:
+       log_println(1, "RTT");
+       break;
+       case 1:
+       log_println(1, "Dial-up");
+       break;
+       case 2:
+       log_println(1, "T1");
+       break;
+       case 3:
+       log_println(1, "Ethernet");
+       break;
+       case 4:
+       log_println(1, "T3");
+       break;
+       case 5:
+       log_println(1, "FastEthernet");
+       break;
+       case 6:
+       log_println(1, "OC-12");
+       break;
+       case 7:
+       log_println(1, "Gigabit Ethernet");
+       break;
+       case 8:
+       log_println(1, "OC-48");
+       break;
+       case 9:
+       log_println(1, "10 Gigabit Enet");
+       break;
+       case 10:
+       log_println(1, "Retransmissions");
+       break;
+       }
+       */
+    log_linkspeed(indx);
+  }
+  switch (c2s_linkspeed_data) {
+    case -2:
+      snprintf(btlneck, sizeof(btlneck), "Insufficent Data");
+      break;
+    case -1:
+      snprintf(btlneck, sizeof(btlneck), "a System Fault");
+      break;
+    case 0:
+      snprintf(btlneck, sizeof(btlneck), "the Round Trip Time");
+      break;
+    case 1:
+      snprintf(btlneck, sizeof(btlneck), "a 'Dial-up modem' connection");
+      break;
+    case 2:
+      if ((c2sspd / s2cspd > .8) && (c2sspd / s2cspd < 1.2) {
+          && (c2sspd > 1000))
+        snprintf(btlneck, sizeof(btlneck), "a 'T1' subnet");
+      } else {
+        if ((tail[3] > 1) || (s2c_linkspeed_ack == 3))
+          snprintf(btlneck, sizeof(btlneck), "a 'Cable Modem' connection");
+        else
+          snprintf(btlneck, sizeof(btlneck), "a 'DSL' connection");
+      }
+      break;
+    case 3:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a T1 + subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "an 'Ethernet' subnet");
+      break;
+    case 4:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a IEEE 802.11b Wifi subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "a 'T3/DS-3' subnet");
+      break;
+    case 5:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a Wifi + subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "a 'FastEthernet' subnet");
+      break;
+    case 6:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a Ethernet subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "an 'OC-12' subnet");
+      break;
+    case 7:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a T3/DS3 subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "a 'Gigabit Ethernet' subnet");
+      break;
+    case 8:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a FastEthernet subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "an 'OC-48' subnet");
+      break;
+    case 9:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a OC-12 subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "a '10 Gigabit Enet' subnet");
+      break;
+    case 10:
+      if (linkcnt == 16)
+        snprintf(btlneck, sizeof(btlneck), "a Gigabit Ethernet subnet");
+      else
+        snprintf(btlneck, sizeof(btlneck), "Retransmissions");
+    case 11:
+      snprintf(btlneck, sizeof(btlneck), "an 'OC-48' subnet");
+      break;
+    case 12:
+      snprintf(btlneck, sizeof(btlneck), "a '10 Gigabit Enet' subnet");
+      break;
+    case 13:
+      snprintf(btlneck, sizeof(btlneck), "Retransmissions");
+      break;
+  }
+  /* Calculate some values */
+  avgrtt = (double) SumRTT / CountRTT;
+  rttsec = avgrtt * .001;
+  loss = (double) (PktsRetrans - FastRetran)
+      / (double) (DataPktsOut - AckPktsOut);
+  loss2 = (double) CongestionSignals / PktsOut;
+  if (loss == 0)
+    loss = .0000000001; /* set to 10^-6 for now */
+  if (loss2 == 0)
+    loss2 = .0000000001; /* set to 10^-6 for now */
+
+  order = (double) DupAcksIn / AckPktsIn;
+  bw = (CurrentMSS / (rttsec * sqrt(loss))) * 8 / 1024 / 1024;
+  bw2 = (CurrentMSS / (rttsec * sqrt(loss2))) * 8 / 1024 / 1024;
+  totaltime = SndLimTimeRwin + SndLimTimeCwnd + SndLimTimeSender;
+  rwintime = (double) SndLimTimeRwin / totaltime;
+  cwndtime = (double) SndLimTimeCwnd / totaltime;
+  sendtime = (double) SndLimTimeSender / totaltime;
+  timesec = totaltime / 1000000;
+  idle = (Timeouts * ((double) CurrentRTO / 1000)) / timesec;
+  retrn = (float) PktsRetrans / PktsOut;
+  increase = (float) CongAvoid / PktsOut;
+
+  recvbwd = ((MaxRwinRcvd * 8) / avgrtt) / 1000;
+  cwndbwd = ((CurrentCwnd * 8) / avgrtt) / 1000;
+  sendbwd = ((Sndbuf * 8) / avgrtt) / 1000;
+
+  spd = ((double) DataBytesOut / (double) totaltime) * 8;
+
+  mismatch2 = 0;
+  mismatch3 = 0;
+  mmorder = (float) (DataPktsOut - PktsRetrans - FastRetran) / DataPktsOut;
+  cong = (float) (CongestionSignals - CongestionOverCount) / PktsOut;
+  touts = (float) Timeouts / PktsOut;
+  if (PktsRetrans > 0)
+    fr_ratio = (float) FastRetran / PktsRetrans;
+  retransec = (float) PktsRetrans / timesec;
+
+  /* new test based on analysis of TCP behavior in duplex mismatch condition. */
+
+  acks = (double) AckPktsIn / (double) DataPktsOut;
+  pureacks = (double) (AckPktsIn - DupAcksIn) / (double) DataPktsOut;
+  if (s2cspd < c2sspd)
+    aspeed = (double) c2sspd / (double) s2cspd;
+  else
+    aspeed = (double) s2cspd / (double) c2sspd;
+  printf(
+      "Acks = %0.4f,  async speed = %0.4f, mismatch3 = %0.4f, CongOver = %d\n",
+      acks, aspeed, cong, CongestionOverCount);
+  printf(
+      "idle = %0.4f, timeout/pkts = %0.4f, %%retranmissions = %0.2f, "
+      "%%increase = %0.2f\n", idle, touts, retrn * 100, increase * 100);
+  printf(
+      "FastRetrans/Total = %0.4f, Fast/Retrans = %0.4f, Retrans/sec = %0.4f\n",
+      retrn, fr_ratio, retransec);
+  if (((acks > 0.7) || (acks < 0.3)) && (retrn > 0.03)
+      && (CongAvoid > SlowStart)) {
+    if ((2 * CurrentMSS) == MaxSsthresh) {
+      mismatch2 = 1;
+      mismatch3 = 0;
+    } else if (aspeed > 15) {
+      mismatch2 = 2;
+    }
+  }
+  if ((idle > 0.65) && (touts < 0.4)) {
+    if (MaxSsthresh == (2 * CurrentMSS)) {
+      mismatch2 = 0;
+      mismatch3 = 1;
+    } else {
+      mismatch3 = 2;
+    }
+  }
+
+  /* estimate is less than throughput, something is wrong */
+  if (bw < spd)
+    link = 0;
+
+  if (((loss * 100) / timesec > 15) && (cwndtime / timesec > .6)
+      && (loss < .01) && (MaxSsthresh > 0))
+    bad_cable = 1;
+
+  /* test for Ethernet link (assume Fast E.) */
+  if ((spd < 9.5) && (spd > 3.0) && (loss < .01) && (order < .035)
+      && (link > 0))
+    link = 10;
+
+  /* test for DSL/Cable modem link */
+  if ((SndLimTimeSender < 15000) && (spd < 2) && (spd < bw) && (link > 0))
+    link = 2;
+
+  if (((rwintime > .95) && (SndLimTransRwin / timesec > 30)
+       && (SndLimTransSender / timesec > 30)) || (link <= 10))
+    half_duplex = 1;
+
+  if ((cwndtime > .02) && (mismatch2 == 0) && (cwndbwd < recvbwd))
+    congestion2 = 1;
+
+  if (iponly == 0) {
+    char tmpbuff[200];
+    socklen_t tmpBufLen = 199;
+    if ((addr = I2AddrByNode(get_errhandle(), ip_addr)) == NULL) {
+      printf("Throughput to host [%s] is limited by %s\n", ip_addr,
+             btlneck);
+    } else {
+      struct addrinfo *fai;
+      fai = I2AddrAddrInfo(addr, ip_addr, NULL);
+      if (fai == NULL) {
+        printf("Throughput to host [%s] is limited by %s\n", ip_addr,
+               btlneck);
+      } else {
+        memset(tmpbuff, 0, 200);
+        if ((tmpret = getnameinfo(fai->ai_addr, fai->ai_addrlen,
+                                  tmpbuff, tmpBufLen, NULL, 0, 0))) {
+          log_println(1, "getnameinfo: %d", tmpret);
+          printf("Throughput to host [%s] is limited by %s\n",
+                 ip_addr, btlneck);
+        } else {
+          printf("Throughput to host %s [%s] is limited by %s\n",
+                 tmpbuff, ip_addr, btlneck);
+        }
+      }
+    }
+  } else {
+    printf("Throughput to host [%s] is limited by %s\n", ip_addr, btlneck);
+  }
+
+  printf("\tWeb100 says link = %d, speed-chk says link = %d\n", link,
+         c2s_linkspeed_data);
+  printf(
+      "\tSpeed-chk says {%d, %d, %d, %d}, Running average = {"
+      "%0.1f, %0.1f, %0.1f, %0.1f}\n", c2s_linkspeed_data, c2s_linkspeed_ack,
+      s2c_linkspeed_data, s2c_linkspeed_ack, runave[0], runave[1], runave[2],
+      runave[3]);
+  if (c2sspd > 1000) {
+    printf("\tC2Sspeed = %0.2f Mbps, S2Cspeed = %0.2f Mbps, CWND-Limited = "
+           "%0.2f Mbps, ", (float) c2sspd / 1000, (float) s2cspd / 1000,
+           (float) s2c2spd / 1000);
+  } else {
+    printf("\tC2Sspeed = %d kbps, S2Cspeed = %d kbps, CWND-Limited: %d kbps, ",
+           c2sspd, s2cspd, s2c2spd);
+  }
+  if (bw > 1)
+    printf("Estimate = %0.2f Mbps (%0.2f Mbps)\n", bw, bw2);
+  else
+    printf("Estimate = %0.2f kbps (%0.2f kbps)\n", bw * 1000, bw2 * 1000);
+
+  if ((bw * 1000) > s2cspd)
+    printf("\tOld estimate is greater than measured; ");
+  else
+    printf("\tOld estimate is less than measured; ");
+
+  if (CongestionSignals == -1) {
+    printf("No data collected to calculage new estimate\n");
+  } else {
+    if ((bw2 * 1000) > s2cspd)
+      printf("New estimate is greater than measured\n");
+    else
+      printf("New estimate is less than measured\n");
+  }
+
+  printf(
+      "\tLoss = %0.2f%% (%0.2f%%), Out-of-Order = %0.2f%%, "
+      "Long tail = {%d, %d, %d, %d}\n", loss * 100, loss2 * 100, order * 100,
+      tail[0], tail[1], tail[2], tail[3]);
+  printf("\tDistribution = {%d, %d, %d, %d}, "
+         "time spent {r=%0.1f%% c=%0.1f%% s=%0.1f%%}\n",
+         head[0], head[1], head[2], head[3], rwintime * 100, cwndtime * 100,
+         sendtime * 100);
+  printf("\tAve(min) RTT = %0.2f (%d) msec, Buffers = {r=%d, c=%d, s=%d}\n",
+         avgrtt, MinRTT, MaxRwinRcvd, CurrentCwnd, Sndbuf / 2);
+  printf("\tbw*delay = {r=%0.2f, c=%0.2f, s=%0.2f}, Transitions/sec = "
+         "{r=%0.1f, c=%0.1f, s=%0.1f}\n", recvbwd, cwndbwd, sendbwd,
+         SndLimTransRwin / timesec, SndLimTransCwnd / timesec,
+         SndLimTransSender / timesec);
+  printf(
+      "\tRetransmissions/sec = %0.1f, Timeouts/sec = %0.1f, SSThreshold = %d\n",
+      (float) PktsRetrans / timesec, (float) Timeouts / timesec,
+      MaxSsthresh);
+  printf("\tMismatch = %d (%d:%d[%0.2f])", mismatch, mismatch2, mismatch3,
+         mmorder);
+  if (mismatch3 == 1)
+    printf(" [H=F, S=H]");
+  if (mismatch2 == 1)
+    printf(" [H=H, S=F]");
+  printf(", Cable fault = %d, Congestion = %d, Duplex = %d\n\n", bad_cable,
+         congestion2, half_duplex);
 }
 
 int main(int argc, char** argv) {
-	int c;
-	char tmpstr[256];
-	int debug = 0;
-
-	iponly = 0;
-	//while ((c = getopt_long(argc, argv, "dnhl:v", long_options, 0)) != -1) {
-	while ((c = getopt_long(argc, argv, "udnhl:v", long_options, 0)) != -1) {
-		switch (c) {
-		case 'h':
-			analyze_long_usage("ANL/Internet2 NDT version " VERSION " (analyze)");
-			break;
-		case 'v':
-			printf("ANL/Internet2 NDT version %s (analyze)\n", VERSION);
-			exit(0);
-			break;
-		case 'l':
-			LogFileName = optarg;
-			break;
-			/*
-			 case 'u':
-			 ProtoLogFileName = optarg;
-			 break;
-			 */
-		case 'u':
-			printf("Calling set protolog from analyze.c");
-			set_protologdir(optarg);
-			break;
-		case 'n':
-			iponly = 1;
-			break;
-		case 'd':
-			debug++;
-			break;
-		case '?':
-			short_usage(argv[0], "");
-			break;
-		}
-	}
-
-	if (optind < argc) {
-		short_usage(argv[0], "Unrecognized non-option elements");
-	}
-
-	log_init(argv[0], debug);
-
-	if (LogFileName == NULL) {
-		snprintf(tmpstr, sizeof(tmpstr), "%s/%s", BASEDIR, LOGFILE);
-		LogFileName = tmpstr;
-	}
-	log_println(1, "log file = %s", LogFileName);
-
-	//TODO do we need protocol log file in analyze????
-	if (ProtoLogFileName == NULL) {
-		snprintf(tmpstr, 256, "%s/%s", BASEDIR, PROTOLOGFILE);
-		ProtoLogFileName = tmpstr;
-	}
-	log_println(1, "log file = %s", ProtoLogFileName);
-
-	if ((fp = fopen(LogFileName, "r")) == NULL)
-		err_sys("Missing Log file ");
-
-	n = 0;
-	m = 0;
-	while ((fgets(buff, 512, fp)) != NULL) {
-		if (strncmp(buff, "spds", 4) == 0) {
-			str = strchr(buff, 0x27);
-			str++;
-			linkcnt = sscanf(str,
-					"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %f",
-					&links[n][0], &links[n][1], &links[n][2], &links[n][3],
-					&links[n][4], &links[n][5], &links[n][6], &links[n][7],
-					&links[n][8], &links[n][9], &links[n][10], &links[n][11],
-					&links[n][12], &links[n][13], &links[n][14], &runave[n]);
-			if (linkcnt != 16)
-				linkcnt = sscanf(str, "%d %d %d %d %d %d %d %d %d %d %d %d %f",
-						&links[n][0], &links[n][1], &links[n][2], &links[n][3],
-						&links[n][4], &links[n][5], &links[n][6], &links[n][7],
-						&links[n][8], &links[n][9], &links[n][10],
-						&links[n][11], &runave[n]);
-			n++;
-			continue;
-		}
-		if (strncmp(buff, "Running", 6) == 0) {
-			ret = sscanf(buff, "%*s %*s %*s %f %*s", &run_ave[m]);
-			log_println(1, "read %d tokens from buffer", ret);
-			log_println(1, "running average[%d] = %0.2f", m, run_ave[m]);
-			if (runave[m] == 0)
-				runave[m] = run_ave[m];
-			m++;
-			continue;
-		}
-		if ((str = strchr(buff, 'p')) != NULL) {
-			if ((strncmp(buff, "Apr", 3) == 0)
-					|| (strncmp(buff, "Sep", 3) == 0)) {
-				skip2: str++;
-				str = strchr(str, 'p');
-				if (str == NULL)
-					goto skip1;
-			}
-			if (strncmp(str, "port", 4) != 0)
-				goto skip2;
-			sscanf(buff, "%*s %*s %*s %s %*s", (char*) &ip_addr);
-			log_println(1, "Start of New Packet trace -- %s", buff);
-			n = 0;
-			m = 0;
-			run_ave[0] = 0;
-			run_ave[1] = 0;
-			run_ave[2] = 0;
-			run_ave[3] = 0;
-			runave[0] = 0;
-			runave[1] = 0;
-			runave[2] = 0;
-			runave[3] = 0;
-		}
-		skip1: if ((str = strchr(buff, ',')) != NULL) {
-			str++;
-			sscanf(str, "%[^,]s", ip_addr2);
-			if ((str = strchr(str, ',')) == NULL)
-				continue;
-			str++;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			s2c2spd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			s2cspd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			c2sspd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			Timeouts = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			SumRTT = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			CountRTT = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			PktsRetrans = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			FastRetran = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			DataPktsOut = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			AckPktsOut = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			CurrentMSS = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			DupAcksIn = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			AckPktsIn = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			MaxRwinRcvd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			Sndbuf = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			CurrentCwnd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			SndLimTimeRwin = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			SndLimTimeCwnd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			SndLimTimeSender = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			DataBytesOut = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			SndLimTransRwin = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			SndLimTransCwnd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			SndLimTransSender = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			MaxSsthresh = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			CurrentRTO = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			CurrentRwinRcvd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			link = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			mismatch = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			bad_cable = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			half_duplex = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			congestion = atoi(tmpstr);
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				CongestionSignals = -1;
-				goto display;
-			}
-			str += 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			c2s_linkspeed_data = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			c2s_linkspeed_ack = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			s2c_linkspeed_data = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			s2c_linkspeed_ack = atoi(tmpstr);
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				CongestionSignals = -1;
-				goto display;
-			}
-			str += 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			CongestionSignals = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			if (sscanf(str, "%[^,]s", tmpstr) < 1)
-				goto display;
-			PktsOut = atoi(tmpstr);
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				MinRTT = -1;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				MinRTT = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				RcvWinScale = -1;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				RcvWinScale = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				autotune = -1;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				autotune = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				CongAvoid = -1;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				CongAvoid = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				CongestionOverCount = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				CongestionOverCount = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				MaxRTT = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				MaxRTT = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				OtherReductions = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				OtherReductions = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				CurTimeouts = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				CurTimeouts = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				AbruptTimeouts = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				AbruptTimeouts = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				SendStall = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				SendStall = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				SlowStart = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				SlowStart = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				SubsequentTimeouts = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				SubsequentTimeouts = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				ThruBytesAcked = 0;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				ThruBytesAcked = atoi(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				cpu_idle1 = -1;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				cpu_idle1 = atol(tmpstr);
-			}
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				cpu_idle2 = -1;
-				goto display;
-			} else {
-				str += 1;
-				if (sscanf(str, "%[^,]s", tmpstr) < 1)
-					goto display;
-				cpu_idle2 = atol(tmpstr);
-			}
-
-			display: log_println(1, "Web100 variables line received\n");
-			calculate();
-		}
-
-	}
-	return 0;
+  int c;
+  char tmpstr[256];
+  int debug = 0;
+
+  iponly = 0;
+  // while ((c = getopt_long(argc, argv, "dnhl:v", long_options, 0)) != -1) {
+  while ((c = getopt_long(argc, argv, "udnhl:v", long_options, 0)) != -1) {
+    switch (c) {
+      case 'h':
+        analyze_long_usage("ANL/Internet2 NDT version " VERSION " (analyze)");
+        break;
+      case 'v':
+        printf("ANL/Internet2 NDT version %s (analyze)\n", VERSION);
+        exit(0);
+        break;
+      case 'l':
+        LogFileName = optarg;
+        break;
+        /*
+           case 'u':
+           ProtoLogFileName = optarg;
+           break;
+           */
+      case 'u':
+        printf("Calling set protolog from analyze.c");
+        set_protologdir(optarg);
+        break;
+      case 'n':
+        iponly = 1;
+        break;
+      case 'd':
+        debug++;
+        break;
+      case '?':
+        short_usage(argv[0], "");
+        break;
+    }
+  }
+
+  if (optind < argc) {
+    short_usage(argv[0], "Unrecognized non-option elements");
+  }
+
+  log_init(argv[0], debug);
+
+  if (LogFileName == NULL) {
+    snprintf(tmpstr, sizeof(tmpstr), "%s/%s", BASEDIR, LOGFILE);
+    LogFileName = tmpstr;
+  }
+  log_println(1, "log file = %s", LogFileName);
+
+  // TODO do we need protocol log file in analyze????
+  if (ProtoLogFileName == NULL) {
+    snprintf(tmpstr, sizeof(tmpstr), "%s/%s", BASEDIR, PROTOLOGFILE);
+    ProtoLogFileName = tmpstr;
+  }
+  log_println(1, "log file = %s", ProtoLogFileName);
+
+  if ((fp = fopen(LogFileName, "r")) == NULL)
+    err_sys("Missing Log file ");
+
+  n = 0;
+  m = 0;
+  while ((fgets(buff, 512, fp)) != NULL) {
+    if (strncmp(buff, "spds", 4) == 0) {
+      str = strchr(buff, 0x27);
+      str++;
+      linkcnt = sscanf(str,
+                       "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %f",
+                       &links[n][0], &links[n][1], &links[n][2], &links[n][3],
+                       &links[n][4], &links[n][5], &links[n][6], &links[n][7],
+                       &links[n][8], &links[n][9], &links[n][10], &links[n][11],
+                       &links[n][12], &links[n][13], &links[n][14], &runave[n]);
+      if (linkcnt != 16)
+        linkcnt = sscanf(str, "%d %d %d %d %d %d %d %d %d %d %d %d %f",
+                         &links[n][0], &links[n][1], &links[n][2], &links[n][3],
+                         &links[n][4], &links[n][5], &links[n][6], &links[n][7],
+                         &links[n][8], &links[n][9], &links[n][10],
+                         &links[n][11], &runave[n]);
+      n++;
+      continue;
+    }
+    if (strncmp(buff, "Running", 6) == 0) {
+      ret = sscanf(buff, "%*s %*s %*s %f %*s", &run_ave[m]);
+      log_println(1, "read %d tokens from buffer", ret);
+      log_println(1, "running average[%d] = %0.2f", m, run_ave[m]);
+      if (runave[m] == 0)
+        runave[m] = run_ave[m];
+      m++;
+      continue;
+    }
+    if ((str = strchr(buff, 'p')) != NULL) {
+      if ((strncmp(buff, "Apr", 3) == 0)
+          || (strncmp(buff, "Sep", 3) == 0)) {
+skip2: str++;
+       str = strchr(str, 'p');
+       if (str == NULL)
+         goto skip1;
+      }
+      if (strncmp(str, "port", 4) != 0)
+        goto skip2;
+      sscanf(buff, "%*s %*s %*s %s %*s", (char*) &ip_addr);
+      log_println(1, "Start of New Packet trace -- %s", buff);
+      n = 0;
+      m = 0;
+      run_ave[0] = 0;
+      run_ave[1] = 0;
+      run_ave[2] = 0;
+      run_ave[3] = 0;
+      runave[0] = 0;
+      runave[1] = 0;
+      runave[2] = 0;
+      runave[3] = 0;
+    }
+skip1: if ((str = strchr(buff, ',')) != NULL) {
+         str++;
+         sscanf(str, "%[^,]s", ip_addr2);
+         if ((str = strchr(str, ',')) == NULL)
+           continue;
+         str++;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         s2c2spd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         s2cspd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         c2sspd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         Timeouts = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         SumRTT = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         CountRTT = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         PktsRetrans = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         FastRetran = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         DataPktsOut = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         AckPktsOut = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         CurrentMSS = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         DupAcksIn = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         AckPktsIn = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         MaxRwinRcvd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         Sndbuf = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         CurrentCwnd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         SndLimTimeRwin = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         SndLimTimeCwnd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         SndLimTimeSender = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         DataBytesOut = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         SndLimTransRwin = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         SndLimTransCwnd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         SndLimTransSender = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         MaxSsthresh = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         CurrentRTO = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         CurrentRwinRcvd = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         link = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         mismatch = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         bad_cable = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         half_duplex = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         congestion = atoi(tmpstr);
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           CongestionSignals = -1;
+           goto display;
+         }
+         str += 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         c2s_linkspeed_data = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         c2s_linkspeed_ack = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         s2c_linkspeed_data = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         s2c_linkspeed_ack = atoi(tmpstr);
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           CongestionSignals = -1;
+           goto display;
+         }
+         str += 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         CongestionSignals = atoi(tmpstr);
+
+         str = strchr(str, ',') + 1;
+         if (sscanf(str, "%[^,]s", tmpstr) < 1)
+           goto display;
+         PktsOut = atoi(tmpstr);
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           MinRTT = -1;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           MinRTT = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           RcvWinScale = -1;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           RcvWinScale = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           autotune = -1;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           autotune = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           CongAvoid = -1;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           CongAvoid = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           CongestionOverCount = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           CongestionOverCount = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           MaxRTT = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           MaxRTT = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           OtherReductions = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           OtherReductions = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           CurTimeouts = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           CurTimeouts = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           AbruptTimeouts = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           AbruptTimeouts = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           SendStall = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           SendStall = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           SlowStart = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           SlowStart = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           SubsequentTimeouts = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           SubsequentTimeouts = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           ThruBytesAcked = 0;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           ThruBytesAcked = atoi(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           cpu_idle1 = -1;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           cpu_idle1 = atol(tmpstr);
+         }
+
+         str = strchr(str, ',');
+         if (str == NULL) {
+           cpu_idle2 = -1;
+           goto display;
+         } else {
+           str += 1;
+           if (sscanf(str, "%[^,]s", tmpstr) < 1)
+             goto display;
+           cpu_idle2 = atol(tmpstr);
+         }
+
+display: log_println(1, "Web100 variables line received\n");
+         calculate();
+       }
+  }
+  return 0;
 }
diff --git a/src/fakewww.c b/src/fakewww.c
index ecbef7e..93b8202 100644
--- a/src/fakewww.c
+++ b/src/fakewww.c
@@ -21,7 +21,6 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <signal.h>
-#include <unistd.h>
 #include <time.h>
 #include <string.h>
 #include <errno.h>
@@ -29,12 +28,12 @@
 #define SYSLOG_NAMES
 #include  <syslog.h>
 
-#include "usage.h"
-#include "troute.h"
-#include "tr-tree.h"
-#include "network.h"
-#include "logging.h"
-#include "web100-admin.h"
+#include "./usage.h"
+#include "./troute.h"
+#include "./tr-tree.h"
+#include "./network.h"
+#include "./logging.h"
+#include "./web100-admin.h"
 
 #define LISTEN_PORT            "7123"
 #define AC_TIME_FORMAT  "%d/%b/%Y:%H:%M:%S %z"
@@ -50,35 +49,35 @@ char buff[BUFFSIZE];
 char *MsgOK = "HTTP/1.0 200 OK\r\n\r\n";
 char *MsgNope1 = "HTTP/1.0 404 Not found\r\n\r\n";
 char *MsgNope2 = "<HEAD><TITLE>File Not Found</TITLE></HEAD>\n"
-		"<BODY><H1>The requested file could not be found</H1></BODY>\n";
+"<BODY><H1>The requested file could not be found</H1></BODY>\n";
 
 char *MsgRedir1 = "HTTP/1.0 307 Temporary Redirect\r\n";
 char *MsgRedir2 = "Location: ";
 char *MsgRedir3 = "\r\n\r\n";
 char *MsgRedir4 = "<HTML><TITLE>FLM server Redirect Page</TITLE>\n"
-		"  <BODY>\n    <meta http-equiv=\"refresh\" content=\"2; ";
+"  <BODY>\n    <meta http-equiv=\"refresh\" content=\"2; ";
 char *MsgRedir5 =
-		"\">\n\n<h2>FLM server re-direction page</h2>\n"
-				"<p><font size=\"+2\">Your client is being redirected to the 'closest' FLM server "
-				"for configuration testing.\n <a ";
+"\">\n\n<h2>FLM server re-direction page</h2>\n"
+"<p><font size=\"+2\">Your client is being redirected to the 'closest' FLM "
+"server for configuration testing.\n <a ";
 char *MsgRedir6 = ">Click Here  </a> if you are not "
-		"automatically redirected in the next 2 seconds.\n  "
-		"</font></BODY>\n</HTML>";
+"automatically redirected in the next 2 seconds.\n  "
+"</font></BODY>\n</HTML>";
 
 char *Mypagefile = "/tcpbw100.html"; /* we throw the slash away */
 char *okfile[] = { "/tcpbw100.html", "/Tcpbw100.class", "/Tcpbw100$1.class",
-		"/Tcpbw100$clsFrame.class", "/Tcpbw100.jar", "/copyright.html",
-		"/web100variables.html", "/"ADMINFILE, "/Admin.class", "/tr.sh",
-		"/traceroute.pl", "/Tcpbw100$MyTextPane.class",
-		"/Tcpbw100$Protocol.class", "/Tcpbw100$StatusPanel.class",
-		"/Tcpbw100$3.class", "/Tcpbw100$OsfwWorker.class",
-		"/Tcpbw100$Message.class", "/Tcpbw100$StatusPanel$1.class",
-		"/Tcpbw100$clsFrame$1.class", "/Tcpbw100$TestWorker.class",
-		"/crossdomain.xml", 0 };
+  "/Tcpbw100$clsFrame.class", "/Tcpbw100.jar", "/copyright.html",
+  "/web100variables.html", "/"ADMINFILE, "/Admin.class", "/tr.sh",
+  "/traceroute.pl", "/Tcpbw100$MyTextPane.class",
+  "/Tcpbw100$Protocol.class", "/Tcpbw100$StatusPanel.class",
+  "/Tcpbw100$3.class", "/Tcpbw100$OsfwWorker.class",
+  "/Tcpbw100$Message.class", "/Tcpbw100$StatusPanel$1.class",
+  "/Tcpbw100$clsFrame$1.class", "/Tcpbw100$TestWorker.class",
+  "/crossdomain.xml", 0 };
 
 typedef struct allowed {
-	char* filename;
-	struct allowed *next;
+  char* filename;
+  struct allowed *next;
 } Allowed;
 
 Allowed* a_root = NULL;
@@ -97,18 +96,18 @@ char *SysLogFacility = NULL;
 int syslogfacility = LOG_FACILITY;
 char *ProcessName = { "fakewww" };
 
-static struct option long_options[] = { { "debug", 0, 0, 'd' }, { "help", 0, 0,
-		'h' }, { "alog", 1, 0, 'l' }, { "elog", 1, 0, 'e' },
-		{ "port", 1, 0, 'p' }, { "ttl", 1, 0, 't' }, { "federated", 0, 0, 'F' },
-		{ "file", 1, 0, 'f' }, { "basedir", 1, 0, 'b' },
-		{ "syslog", 0, 0, 's' }, { "logfacility", 1, 0, 'S' }, { "version", 0,
-				0, 'v' }, { "dflttree", 1, 0, 301 },
+static struct option long_options[] = {
+  { "debug", 0, 0, 'd' }, { "help", 0, 0, 'h' }, { "alog", 1, 0, 'l' },
+  { "elog", 1, 0, 'e' }, { "port", 1, 0, 'p' }, { "ttl", 1, 0, 't' },
+  { "federated", 0, 0, 'F' }, { "file", 1, 0, 'f' }, { "basedir", 1, 0, 'b' },
+  { "syslog", 0, 0, 's' }, { "logfacility", 1, 0, 'S' },
+  { "version", 0, 0, 'v' }, { "dflttree", 1, 0, 301 },
 #ifdef AF_INET6
-		{	"dflttree6", 1, 0, 302},
-		{	"ipv4", 0, 0, '4'},
-		{	"ipv6", 0, 0, '6'},
+  { "dflttree6", 1, 0, 302},
+  { "ipv4", 0, 0, '4'},
+  { "ipv6", 0, 0, '6'},
 #endif
-		{ 0, 0, 0, 0 } };
+  { 0, 0, 0, 0 } };
 
 void dowww(int, I2Addr, char*, char*, char*, int, int);
 void reap();
@@ -117,27 +116,27 @@ void logErLog(char*, time_t*, char*, char*, ...);
 void logAcLog(char*, time_t*, char*, char*, int, int, char*, char*);
 
 void err_sys(char* s) {
-	perror(s);
-	exit(1);
+  perror(s);
+  exit(1);
 }
 
 int main(int argc, char** argv) {
-	int c;
-	int sockfd, newsockfd;
-	int federated = 0, debug = 0, max_ttl = 10;
-	time_t tt;
-	socklen_t clilen;
-	char* srcname = NULL;
-	char* listenport = LISTEN_PORT;
-	int conn_options = 0;
-
-	char *ErLogFileName = BASEDIR
-	"/"ERLOGFILE;
-	char *AcLogFileName = BASEDIR
-	"/"ACLOGFILE;
-	struct sockaddr_storage cli_addr;
-	I2Addr listenaddr = NULL;
-	Allowed* ptr;
+  int c;
+  int sockfd, newsockfd;
+  int federated = 0, debug = 0, max_ttl = 10;
+  time_t tt;
+  socklen_t clilen;
+  char* srcname = NULL;
+  char* listenport = LISTEN_PORT;
+  int conn_options = 0;
+
+  char *ErLogFileName = BASEDIR
+      "/"ERLOGFILE;
+  char *AcLogFileName = BASEDIR
+      "/"ACLOGFILE;
+  struct sockaddr_storage cli_addr;
+  I2Addr listenaddr = NULL;
+  Allowed* ptr;
 
 #ifdef AF_INET6
 #define GETOPT_LONG_INET6(x) "46"x
@@ -145,190 +144,189 @@ int main(int argc, char** argv) {
 #define GETOPT_LONG_INET6(x) x
 #endif
 
-	while ((c = getopt_long(argc, argv,
-			GETOPT_LONG_INET6("dhl:e:p:t:Ff:b:sS:v"), long_options, 0)) != -1) {
-		switch (c) {
-		case '4':
-			conn_options |= OPT_IPV4_ONLY;
-			break;
-		case '6':
-			conn_options |= OPT_IPV6_ONLY;
-			break;
-		case 'd':
-			debug++;
-			break;
-		case 'h':
-			www_long_usage("ANL/Internet2 NDT version " VERSION " (fakewww)");
-			break;
-		case 'v':
-			printf("ANL/Internet2 NDT version %s (fakewww)\n", VERSION);
-			exit(0);
-			break;
-		case 'l':
-			AcLogFileName = optarg;
-			break;
-		case 'e':
-			ErLogFileName = optarg;
-			break;
-		case 'p':
-			listenport = optarg;
-			break;
-		case 't':
-			max_ttl = atoi(optarg);
-			break;
-		case 'F':
-			federated = 1;
-			break;
-		case 'f':
-			ptr = malloc(sizeof(Allowed));
-			ptr->filename = optarg;
-			ptr->next = a_root;
-			a_root = ptr;
-			break;
-		case 'b':
-			basedir = optarg;
-			break;
-		case 's':
-			usesyslog = 1;
-			break;
-		case 'S':
-			SysLogFacility = optarg;
-			break;
-		case 301:
-			DefaultTree = optarg;
-			break;
+  while ((c = getopt_long(argc, argv, GETOPT_LONG_INET6("dhl:e:p:t:Ff:b:sS:v"),
+                          long_options, 0)) != -1) {
+    switch (c) {
+      case '4':
+        conn_options |= OPT_IPV4_ONLY;
+        break;
+      case '6':
+        conn_options |= OPT_IPV6_ONLY;
+        break;
+      case 'd':
+        debug++;
+        break;
+      case 'h':
+        www_long_usage("ANL/Internet2 NDT version " VERSION " (fakewww)");
+        break;
+      case 'v':
+        printf("ANL/Internet2 NDT version %s (fakewww)\n", VERSION);
+        exit(0);
+        break;
+      case 'l':
+        AcLogFileName = optarg;
+        break;
+      case 'e':
+        ErLogFileName = optarg;
+        break;
+      case 'p':
+        listenport = optarg;
+        break;
+      case 't':
+        max_ttl = atoi(optarg);
+        break;
+      case 'F':
+        federated = 1;
+        break;
+      case 'f':
+        ptr = malloc(sizeof(Allowed));
+        ptr->filename = optarg;
+        ptr->next = a_root;
+        a_root = ptr;
+        break;
+      case 'b':
+        basedir = optarg;
+        break;
+      case 's':
+        usesyslog = 1;
+        break;
+      case 'S':
+        SysLogFacility = optarg;
+        break;
+      case 301:
+        DefaultTree = optarg;
+        break;
 #ifdef AF_INET6
-			case 302:
-			DefaultTree6 = optarg;
-			break;
+      case 302:
+        DefaultTree6 = optarg;
+        break;
 #endif
-		case '?':
-			short_usage(argv[0], "");
-			break;
-		}
-	}
-
-	if (optind < argc) {
-		short_usage(argv[0], "Unrecognized non-option elements");
-	}
-
-	log_init(argv[0], debug);
-
-	if (SysLogFacility != NULL) {
-		int i = 0;
-		while (facilitynames[i].c_name) {
-			if (strcmp(facilitynames[i].c_name, SysLogFacility) == 0) {
-				syslogfacility = facilitynames[i].c_val;
-				break;
-			}
-			++i;
-		}
-		if (facilitynames[i].c_name == NULL) {
-			log_println(
-					0,
-					"Warning: Unknown syslog facility [%s] --> using default (%d)",
-					SysLogFacility, syslogfacility);
-			SysLogFacility = NULL;
-		}
-	}
-
-	if (DefaultTree == NULL) {
-		snprintf(dtfn, sizeof(dtfn), "%s/%s", BASEDIR, DFLT_TREE);
-		DefaultTree = dtfn;
-	}
+      case '?':
+        short_usage(argv[0], "");
+        break;
+    }
+  }
+
+  if (optind < argc) {
+    short_usage(argv[0], "Unrecognized non-option elements");
+  }
+
+  log_init(argv[0], debug);
+
+  if (SysLogFacility != NULL) {
+    int i = 0;
+    while (facilitynames[i].c_name) {
+      if (strcmp(facilitynames[i].c_name, SysLogFacility) == 0) {
+        syslogfacility = facilitynames[i].c_val;
+        break;
+      }
+      ++i;
+    }
+    if (facilitynames[i].c_name == NULL) {
+      log_println(
+          0,
+          "Warning: Unknown syslog facility [%s] --> using default (%d)",
+          SysLogFacility, syslogfacility);
+      SysLogFacility = NULL;
+    }
+  }
+
+  if (DefaultTree == NULL) {
+    snprintf(dtfn, sizeof(dtfn), "%s/%s", BASEDIR, DFLT_TREE);
+    DefaultTree = dtfn;
+  }
 
 #ifdef AF_INET6
-	if (DefaultTree6 == NULL) {
-		snprintf(dt6fn, sizeof(dtfn), "%s/%s", BASEDIR, DFLT_TREE6);
-		DefaultTree6 = dt6fn;
-	}
+  if (DefaultTree6 == NULL) {
+    snprintf(dt6fn, sizeof(dtfn), "%s/%s", BASEDIR, DFLT_TREE6);
+    DefaultTree6 = dt6fn;
+  }
 #endif
 
-	/*
-	 * Bind our local address so that the client can send to us.
-	 */
-	if (srcname && !(listenaddr = I2AddrByNode(get_errhandle(), srcname))) {
-		err_sys("server: Invalid source address specified");
-	}
-	if ((listenaddr = CreateListenSocket(listenaddr, listenport, conn_options,
-			0)) == NULL) {
-		err_sys("server: CreateListenSocket failed");
-	}
-	sockfd = I2AddrFD(listenaddr);
-
-	tt = time(0);
-	log_println(1, "%15.15s fakewww server started (NDT version %s)",
-			ctime(&tt) + 4, VERSION);
-	log_println(1, "\tport = %d", I2AddrPort(listenaddr));
-	log_println(1, "\tfederated mode = %s", (federated == 1) ? "on" : "off");
-	log_println(1, "\taccess log = %s\n\terror log = %s", AcLogFileName,
-			ErLogFileName);
-	log_println(1, "\tbasedir = %s", basedir);
-	if (usesyslog) {
-		log_println(1, "\tsyslog facility = %s (%d)",
-				SysLogFacility ? SysLogFacility : "default", syslogfacility);
-	}
-	log_println(1, "\tdebug level set to %d", debug);
-
-	logErLog(ErLogFileName, &tt, "notice",
-			"fakewww server started (NDT version %s)", VERSION);
-	logErLog(ErLogFileName, &tt, "notice", "\tport = %d",
-			I2AddrPort(listenaddr));
-	logErLog(ErLogFileName, &tt, "notice", "\tfederated mode = %s",
-			(federated == 1) ? "on" : "off");
-	logErLog(ErLogFileName, &tt, "notice", "\taccess log = %s", AcLogFileName);
-	logErLog(ErLogFileName, &tt, "notice", "\terror log = %s", ErLogFileName);
-	logErLog(ErLogFileName, &tt, "notice", "\tbasedir = %s", basedir);
-	if (usesyslog) {
-		logErLog(ErLogFileName, &tt, "notice", "\tsyslog facility = %s (%d)",
-				SysLogFacility ? SysLogFacility : "default", syslogfacility);
-	}
-	logErLog(ErLogFileName, &tt, "notice", "\tdebug level set to %d", debug);
-
-	if (usesyslog == 1)
-		syslog(LOG_FACILITY | LOG_INFO, "Fakewww (ver %s) process started",
-				VERSION);
-	signal(SIGCHLD, reap); /* get rid of zombies */
-
-	/*
-	 * Wait for a connection from a client process.
-	 * This is an example of a concurrent server.
-	 */
-
-	for (;;) {
-		clilen = sizeof(cli_addr);
-		newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
-		if (newsockfd < 0) {
-			if (errno == EINTR)
-				continue; /*sig child */
-			err_sys("Fakewww server: accept error");
-		}
-
-		if (fork() == 0) { /* child */
-			I2Addr caddr = I2AddrBySAddr(get_errhandle(),
-					(struct sockaddr *) &cli_addr, clilen, 0, 0);
-			alarm(300); /* kill child off after 5 minutes, should never happen */
-			close(sockfd);
-			dowww(newsockfd, caddr, listenport, AcLogFileName, ErLogFileName,
-					federated, max_ttl);
-			exit(0);
-		}
-		close(newsockfd);
-	}
-
+  /*
+   * Bind our local address so that the client can send to us.
+   */
+  if (srcname && !(listenaddr = I2AddrByNode(get_errhandle(), srcname))) {
+    err_sys("server: Invalid source address specified");
+  }
+  if ((listenaddr = CreateListenSocket(listenaddr, listenport, conn_options,
+                                       0)) == NULL) {
+    err_sys("server: CreateListenSocket failed");
+  }
+  sockfd = I2AddrFD(listenaddr);
+
+  tt = time(0);
+  log_println(1, "%15.15s fakewww server started (NDT version %s)",
+              ctime(&tt) + 4, VERSION);
+  log_println(1, "\tport = %d", I2AddrPort(listenaddr));
+  log_println(1, "\tfederated mode = %s", (federated == 1) ? "on" : "off");
+  log_println(1, "\taccess log = %s\n\terror log = %s", AcLogFileName,
+              ErLogFileName);
+  log_println(1, "\tbasedir = %s", basedir);
+  if (usesyslog) {
+    log_println(1, "\tsyslog facility = %s (%d)",
+                SysLogFacility ? SysLogFacility : "default", syslogfacility);
+  }
+  log_println(1, "\tdebug level set to %d", debug);
+
+  logErLog(ErLogFileName, &tt, "notice",
+           "fakewww server started (NDT version %s)", VERSION);
+  logErLog(ErLogFileName, &tt, "notice", "\tport = %d",
+           I2AddrPort(listenaddr));
+  logErLog(ErLogFileName, &tt, "notice", "\tfederated mode = %s",
+           (federated == 1) ? "on" : "off");
+  logErLog(ErLogFileName, &tt, "notice", "\taccess log = %s", AcLogFileName);
+  logErLog(ErLogFileName, &tt, "notice", "\terror log = %s", ErLogFileName);
+  logErLog(ErLogFileName, &tt, "notice", "\tbasedir = %s", basedir);
+  if (usesyslog) {
+    logErLog(ErLogFileName, &tt, "notice", "\tsyslog facility = %s (%d)",
+             SysLogFacility ? SysLogFacility : "default", syslogfacility);
+  }
+  logErLog(ErLogFileName, &tt, "notice", "\tdebug level set to %d", debug);
+
+  if (usesyslog == 1)
+    syslog(LOG_FACILITY | LOG_INFO, "Fakewww (ver %s) process started",
+           VERSION);
+  signal(SIGCHLD, reap); /* get rid of zombies */
+
+  /*
+   * Wait for a connection from a client process.
+   * This is an example of a concurrent server.
+   */
+
+  for (;;) {
+    clilen = sizeof(cli_addr);
+    newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
+    if (newsockfd < 0) {
+      if (errno == EINTR)
+        continue; /*sig child */
+      err_sys("Fakewww server: accept error");
+    }
+
+    if (fork() == 0) { /* child */
+      I2Addr caddr = I2AddrBySAddr(get_errhandle(),
+                                   (struct sockaddr *) &cli_addr, clilen, 0, 0);
+      alarm(300); /* kill child off after 5 minutes, should never happen */
+      close(sockfd);
+      dowww(newsockfd, caddr, listenport, AcLogFileName, ErLogFileName,
+            federated, max_ttl);
+      exit(0);
+    }
+    close(newsockfd);
+  }
 }
 
 #include        <sys/wait.h>
 void reap(int signo) {
-	/*
-	 * avoid zombies, since we run forever
-	 * Use the wait3() system call with the WNOHANG option.
-	 */
-	int pid;
-	union wait status;
-
-	while ((pid = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0)
-		;
+  /*
+   * avoid zombies, since we run forever
+   * Use the wait3() system call with the WNOHANG option.
+   */
+  int pid;
+  union wait status;
+
+  while ((pid = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) {
+  }
 }
 
 /*
@@ -340,405 +338,423 @@ void reap(int signo) {
  */
 
 int readline(fd, ptr, maxlen)
-	register int fd;register char *ptr;register int maxlen; {
-	int n, rc;
-	char c;
-
-	for (n = 1; n < maxlen; n++) {
-		if ((rc = read(fd, &c, 1)) == 1) {
-			*ptr++ = c;
-			if (c == '\n')
-				break;
-		} else if (rc == 0) {
-			if (n == 1)
-				return (0); /* EOF, no data read */
-			else
-				break; /* EOF, some data was read */
-		} else
-			return (-1); /* error */
-	}
-
-	*ptr = 0;
-	return (n);
-}
+  register int fd;
+  register char *ptr;
+  register int maxlen; {
+    int n, rc;
+    char c;
+
+    for (n = 1; n < maxlen; n++) {
+      if ((rc = read(fd, &c, 1)) == 1) {
+        *ptr++ = c;
+        if (c == '\n')
+          break;
+      } else if (rc == 0) {
+        if (n == 1)
+          return (0); /* EOF, no data read */
+        else
+          break; /* EOF, some data was read */
+      } else {
+        return (-1); /* error */
+      }
+    }
+
+    *ptr = 0;
+    return (n);
+  }
 
 void trim(char* ptr) {
-	while (*ptr) {
-		if ((*ptr == '\r') || (*ptr == '\n')) {
-			*ptr = 0;
-			break;
-		}
-		ptr++;
-	}
+  while (*ptr) {
+    if ((*ptr == '\r') || (*ptr == '\n')) {
+      *ptr = 0;
+      break;
+    }
+    ptr++;
+  }
 }
 
 void dowww(int sd, I2Addr addr, char* port, char* AcLogFileName,
-		char* ErLogFileName, int fed_mode, int max_ttl) {
-	/* process web request */
-	int fd, n, i, ok;
-	char *p, filename[256], line[256], *ctime();
-	char htmlfile[256];
-	u_int32_t IPlist[64], srv_addr;
+           char* ErLogFileName, int fed_mode, int max_ttl) {
+  /* process web request */
+  int fd, n, i, ok;
+  char *p, filename[256], line[256], *ctime();
+  char htmlfile[256];
+  u_int32_t IPlist[64], srv_addr;
 #ifdef AF_INET6
-	u_int32_t IP6list[64][4];
-	u_int32_t srv_addr6[4];
+  u_int32_t IP6list[64][4];
+  u_int32_t srv_addr6[4];
 #endif
-	I2Addr serv_addr = NULL;
-	I2Addr loc_addr = NULL;
-	time_t tt;
-	char nodename[200];
-	char onenodename[200];
-	size_t nlen = 199;
-	Allowed* ptr;
-	char lineBuf[100];
-	char useragentBuf[100];
-	char refererBuf[100];
-	int answerSize;
-
-	memset(nodename, 0, 200);
-	I2AddrNodeName(addr, nodename, &nlen);
-
-	while ((n = readline(sd, buff, sizeof(buff))) > 0) {
-		if (n < 3)
-			break; /* end of html input */
-		p = (char *) strstr(buff, "GET");
-		if (p == NULL)
-			continue;
-		memset(lineBuf, 0, 100);
-		memset(useragentBuf, 0, 100);
-		memset(refererBuf, 0, 100);
-		strncpy(lineBuf, buff, 99);
-		trim(lineBuf);
-		sscanf(p + 4, "%s", filename);
-		while ((n = readline(sd, buff, sizeof(buff))) > 0) {
-			if ((p = (char *) strstr(buff, "User-Agent"))) {
-				strncpy(useragentBuf, p + 12, 99);
-				trim(useragentBuf);
-			}
-			if ((p = (char *) strstr(buff, "Referer"))) {
-				strncpy(refererBuf, p + 9, 99);
-				trim(refererBuf);
-			}
-			if (n < 3)
-				break; /* end of html input */
-		}
-		if (strcmp(filename, "/") == 0) {
-			/* feed em the default page */
-			/* strcpy(filename, Mypagefile); */
-			/* By default we now send out the redirect page */
-
-			log_println(4, "Received connection from [%s]", nodename);
-
-			if (fed_mode == 1) {
-				struct sockaddr* csaddr;
-				csaddr = I2AddrSAddr(addr, NULL);
-				if (csaddr->sa_family == AF_INET) { /* make the IPv4 find */
-					char ip_str[16];
-					struct sockaddr_in* cli_addr = (struct sockaddr_in*) csaddr;
-					find_route(cli_addr->sin_addr.s_addr, IPlist, max_ttl);
-					for (i = 0; IPlist[i] != cli_addr->sin_addr.s_addr; i++) {
-						snprintf(ip_str, sizeof(ip_str), "%u.%u.%u.%u",
-							 IPlist[i] & 0xff,
-							 (IPlist[i] >> 8) & 0xff,
-							 (IPlist[i] >> 16) & 0xff,
-							 (IPlist[i] >> 24) & 0xff);
-						log_println(4, "loop IPlist[%d] = %s", i, ip_str);
-						if (i == max_ttl) {
-							log_println(4, "Oops, destination not found!");
-							break;
-						}
-					}
-					/* print out last item on list */
-					snprintf(ip_str, sizeof(ip_str), "%u.%u.%u.%u",
-						 IPlist[i] & 0xff,
-						 (IPlist[i] >> 8) & 0xff,
-						 (IPlist[i] >> 16) & 0xff,
-						 (IPlist[i] >> 24) & 0xff);
-					log_println(4, "IPlist[%d] = %s", i, ip_str);
-
-					srv_addr = find_compare(IPlist, i);
-
-					/* the find_compare() routine returns the IP address of the 'closest'
-					 * NDT server.  It does this by comparing the clients address to a
-					 * map of routes between all servers.  If this comparison fails, the
-					 * routine returns 0.  In that case, simply use this server.
-					 */
-					if (srv_addr == 0) {
-						serv_addr = I2AddrByLocalSockFD(get_errhandle(), sd,
-								False);
-						memset(onenodename, 0, 200);
-						nlen = 199;
-						I2AddrNodeName(serv_addr, onenodename, &nlen);
-						log_println(4,
-								"find_compare() returned 0, reset to [%s]",
-								onenodename);
-						srv_addr = ((struct sockaddr_in*) I2AddrSAddr(serv_addr,
-								NULL))->sin_addr.s_addr;
-					}
-
-					log_println(
-							4,
-							"Client host [%s] should be redirected to FLM server [%u.%u.%u.%u]",
-							inet_ntoa(cli_addr->sin_addr), srv_addr & 0xff,
-							(srv_addr >> 8) & 0xff, (srv_addr >> 16) & 0xff,
-							(srv_addr >> 24) & 0xff);
-
-					/* At this point, the srv_addr variable contains the IP address of the
-					 * server we want to re-direct the connect to.  So we should generate a
-					 * new html page, and sent that back to the client.  This new page will
-					 * use the HTML refresh option with a short (2 second) timer to cause the
-					 * client's browser to just to the new server.
-					 * 
-					 * RAC 3/9/04
-					 */
-
-					writen(sd, MsgRedir1, strlen(MsgRedir1));
-					writen(sd, MsgRedir2, strlen(MsgRedir2));
-					snprintf(line, sizeof(line), "http://%u.%u.%u.%u:%s/tcpbw100.html",
-							srv_addr & 0xff, (srv_addr >> 8) & 0xff,
-							(srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
-							port);
-					writen(sd, line, strlen(line));
-					writen(sd, MsgRedir3, strlen(MsgRedir3));
-					writen(sd, MsgRedir4, strlen(MsgRedir4));
-					answerSize = strlen(MsgRedir4);
-					snprintf(line, sizeof(line), "url=http://%u.%u.%u.%u:%s/tcpbw100.html",
-							srv_addr & 0xff, (srv_addr >> 8) & 0xff,
-							(srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
-							port);
-					writen(sd, line, strlen(line));
-					answerSize += strlen(line);
-					writen(sd, MsgRedir5, strlen(MsgRedir5));
-					answerSize += strlen(MsgRedir5);
-					snprintf(line, sizeof(line), "href=\"http://%u.%u.%u.%u:%s/tcpbw100.html\"",
-							srv_addr & 0xff, (srv_addr >> 8) & 0xff,
-							(srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
-							port);
-					writen(sd, line, strlen(line));
-					answerSize += strlen(line);
-					writen(sd, MsgRedir6, strlen(MsgRedir6));
-					answerSize += strlen(MsgRedir6);
-					log_println(3,
-							"%s redirected to remote server [%u.%u.%u.%u:%s]",
-							inet_ntoa(cli_addr->sin_addr), srv_addr & 0xff,
-							(srv_addr >> 8) & 0xff, (srv_addr >> 16) & 0xff,
-							(srv_addr >> 24) & 0xff, port);
-					tt = time(0);
-					logErLog(ErLogFileName, &tt, "notice",
-							"[%s] redirected to remote server [%u.%u.%u.%u:%s]",
-							inet_ntoa(cli_addr->sin_addr), srv_addr & 0xff,
-							(srv_addr >> 8) & 0xff, (srv_addr >> 16) & 0xff,
-							(srv_addr >> 24) & 0xff, port);
-					logAcLog(AcLogFileName, &tt, inet_ntoa(cli_addr->sin_addr),
-							lineBuf, 307, answerSize, useragentBuf, refererBuf);
-					break;
-				}
+  I2Addr serv_addr = NULL;
+  I2Addr loc_addr = NULL;
+  time_t tt;
+  char nodename[200];
+  char onenodename[200];
+  size_t nlen = 199;
+  Allowed* ptr;
+  char lineBuf[100];
+  char useragentBuf[100];
+  char refererBuf[100];
+  int answerSize;
+
+  memset(nodename, 0, 200);
+  I2AddrNodeName(addr, nodename, &nlen);
+
+  while ((n = readline(sd, buff, sizeof(buff))) > 0) {
+    if (n < 3)
+      break; /* end of html input */
+    p = (char *) strstr(buff, "GET");
+    if (p == NULL)
+      continue;
+    memset(lineBuf, 0, 100);
+    memset(useragentBuf, 0, 100);
+    memset(refererBuf, 0, 100);
+    strncpy(lineBuf, buff, 99);
+    trim(lineBuf);
+    sscanf(p + 4, "%s", filename);
+    while ((n = readline(sd, buff, sizeof(buff))) > 0) {
+      if ((p = (char *) strstr(buff, "User-Agent"))) {
+        strncpy(useragentBuf, p + 12, 99);
+        trim(useragentBuf);
+      }
+      if ((p = (char *) strstr(buff, "Referer"))) {
+        strncpy(refererBuf, p + 9, 99);
+        trim(refererBuf);
+      }
+      if (n < 3)
+        break; /* end of html input */
+    }
+    if (strcmp(filename, "/") == 0) {
+      /* feed em the default page */
+      /* strcpy(filename, Mypagefile); */
+      /* By default we now send out the redirect page */
+
+      log_println(4, "Received connection from [%s]", nodename);
+
+      if (fed_mode == 1) {
+        struct sockaddr* csaddr;
+        csaddr = I2AddrSAddr(addr, NULL);
+        if (csaddr->sa_family == AF_INET) { /* make the IPv4 find */
+          char ip_str[16];
+          struct sockaddr_in* cli_addr = (struct sockaddr_in*) csaddr;
+          find_route(cli_addr->sin_addr.s_addr, IPlist, max_ttl);
+          for (i = 0; IPlist[i] != cli_addr->sin_addr.s_addr; i++) {
+            snprintf(ip_str, sizeof(ip_str), "%u.%u.%u.%u",
+                     IPlist[i] & 0xff,
+                     (IPlist[i] >> 8) & 0xff,
+                     (IPlist[i] >> 16) & 0xff,
+                     (IPlist[i] >> 24) & 0xff);
+            log_println(4, "loop IPlist[%d] = %s", i, ip_str);
+            if (i == max_ttl) {
+              log_println(4, "Oops, destination not found!");
+              break;
+            }
+          }
+          /* print out last item on list */
+          snprintf(ip_str, sizeof(ip_str), "%u.%u.%u.%u",
+                   IPlist[i] & 0xff,
+                   (IPlist[i] >> 8) & 0xff,
+                   (IPlist[i] >> 16) & 0xff,
+                   (IPlist[i] >> 24) & 0xff);
+          log_println(4, "IPlist[%d] = %s", i, ip_str);
+
+          srv_addr = find_compare(IPlist, i);
+
+          /* the find_compare() routine returns the IP address of the 'closest'
+           * NDT server.  It does this by comparing the clients address to a
+           * map of routes between all servers.  If this comparison fails, the
+           * routine returns 0.  In that case, simply use this server.
+           */
+          if (srv_addr == 0) {
+            serv_addr = I2AddrByLocalSockFD(get_errhandle(), sd,
+                                            False);
+            memset(onenodename, 0, 200);
+            nlen = 199;
+            I2AddrNodeName(serv_addr, onenodename, &nlen);
+            log_println(4,
+                        "find_compare() returned 0, reset to [%s]",
+                        onenodename);
+            srv_addr =
+                ((struct sockaddr_in*) I2AddrSAddr(serv_addr, NULL))->
+                    sin_addr.s_addr;
+          }
+
+          log_println(4,
+                      "Client host [%s] should be redirected to FLM server "
+                      "[%u.%u.%u.%u]", inet_ntoa(cli_addr->sin_addr),
+                      srv_addr & 0xff, (srv_addr >> 8) & 0xff,
+                      (srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff);
+
+          /* At this point, the srv_addr variable contains the IP address of the
+           * server we want to re-direct the connect to.  So we should generate a
+           * new html page, and sent that back to the client.  This new page will
+           * use the HTML refresh option with a short (2 second) timer to cause the
+           * client's browser to just to the new server.
+           * 
+           * RAC 3/9/04
+           */
+
+          writen(sd, MsgRedir1, strlen(MsgRedir1));
+          writen(sd, MsgRedir2, strlen(MsgRedir2));
+          snprintf(line, sizeof(line), "http://%u.%u.%u.%u:%s/tcpbw100.html",
+                   srv_addr & 0xff, (srv_addr >> 8) & 0xff,
+                   (srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
+                   port);
+          writen(sd, line, strlen(line));
+          writen(sd, MsgRedir3, strlen(MsgRedir3));
+          writen(sd, MsgRedir4, strlen(MsgRedir4));
+          answerSize = strlen(MsgRedir4);
+          snprintf(line, sizeof(line),
+                   "url=http://%u.%u.%u.%u:%s/tcpbw100.html",
+                   srv_addr & 0xff, (srv_addr >> 8) & 0xff,
+                   (srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
+                   port);
+          writen(sd, line, strlen(line));
+          answerSize += strlen(line);
+          writen(sd, MsgRedir5, strlen(MsgRedir5));
+          answerSize += strlen(MsgRedir5);
+          snprintf(line, sizeof(line),
+                   "href=\"http://%u.%u.%u.%u:%s/tcpbw100.html\"",
+                   srv_addr & 0xff, (srv_addr >> 8) & 0xff,
+                   (srv_addr >> 16) & 0xff, (srv_addr >> 24) & 0xff,
+                   port);
+          writen(sd, line, strlen(line));
+          answerSize += strlen(line);
+          writen(sd, MsgRedir6, strlen(MsgRedir6));
+          answerSize += strlen(MsgRedir6);
+          log_println(3,
+                      "%s redirected to remote server [%u.%u.%u.%u:%s]",
+                      inet_ntoa(cli_addr->sin_addr), srv_addr & 0xff,
+                      (srv_addr >> 8) & 0xff, (srv_addr >> 16) & 0xff,
+                      (srv_addr >> 24) & 0xff, port);
+          tt = time(0);
+          logErLog(ErLogFileName, &tt, "notice",
+                   "[%s] redirected to remote server [%u.%u.%u.%u:%s]",
+                   inet_ntoa(cli_addr->sin_addr), srv_addr & 0xff,
+                   (srv_addr >> 8) & 0xff, (srv_addr >> 16) & 0xff,
+                   (srv_addr >> 24) & 0xff, port);
+          logAcLog(AcLogFileName, &tt, inet_ntoa(cli_addr->sin_addr),
+                   lineBuf, 307, answerSize, useragentBuf, refererBuf);
+          break;
+        }
 #ifdef AF_INET6
-				else if (csaddr->sa_family == AF_INET6) {
-					struct sockaddr_in6* cli_addr = (struct sockaddr_in6*) csaddr;
-					socklen_t onenode_len;
-					find_route6(nodename, IP6list, max_ttl);
-					for (i = 0; memcmp(IP6list[i], &cli_addr->sin6_addr, sizeof(cli_addr->sin6_addr)); i++) {
-						memset(onenodename, 0, 200);
-						onenode_len = 199;
-						inet_ntop(AF_INET6, (void *) IP6list[i], onenodename, onenode_len);
-						log_println(4, "loop IP6list[%d], = %s", i, onenodename);
-						if (i == max_ttl) {
-							log_println(4, "Oops, destination not found!");
-							break;
-						}
-					}
-					/* print out last item on list */
-
-					if (get_debuglvl() > 3) {
-						memset(onenodename, 0, 200);
-						onenode_len = 199;
-						inet_ntop(AF_INET6, (void *) IP6list[i], onenodename, onenode_len);
-						log_println(4, "IP6list[%d] = %s", i, onenodename);
-					}
-
-					srv_addr = find_compare6(srv_addr6, IP6list, i);
-					if (srv_addr == 0) {
-						serv_addr = I2AddrByLocalSockFD(get_errhandle(), sd, False);
-						memset(onenodename, 0, 200);
-						nlen = 199;
-						I2AddrNodeName(serv_addr, onenodename, &nlen);
-						log_println(4, "find_compare6() returned 0, reset to [%s]", onenodename);
-						memcpy(srv_addr6, &((struct sockaddr_in6*)I2AddrSAddr(serv_addr, NULL))->sin6_addr, 16);
-					}
-
-					nlen = 199;
-					memset(onenodename, 0, 200);
-					inet_ntop(AF_INET6, (void *) srv_addr6, onenodename, nlen);
-
-					log_println(4, "Client host [%s] should be redirected to FLM server [%s]",
-							nodename, onenodename);
-
-					writen(sd, MsgRedir1, strlen(MsgRedir1));
-					writen(sd, MsgRedir2, strlen(MsgRedir2));
-					snprintf(line, sizeof(line), "http://[%s]:%s/tcpbw100.html", onenodename, port);
-					writen(sd, line, strlen(line));
-					writen(sd, MsgRedir3, strlen(MsgRedir3));
-					writen(sd, MsgRedir4, strlen(MsgRedir4));
-					answerSize = strlen(MsgRedir4);
-					snprintf(line, sizeof(line), "url=http://[%s]:%s/tcpbw100.html", onenodename, port);
-					writen(sd, line, strlen(line));
-					answerSize += strlen(line);
-					writen(sd, MsgRedir5, strlen(MsgRedir5));
-					answerSize += strlen(MsgRedir5);
-					snprintf(line, sizeof(line), "href=\"http://[%s]:%s/tcpbw100.html\"", onenodename, port);
-					writen(sd, line, strlen(line));
-					answerSize += strlen(line);
-					writen(sd, MsgRedir6, strlen(MsgRedir6));
-					answerSize += strlen(MsgRedir6);
-					log_println(3, "%s redirected to remote server [[%s]:%s]", nodename, onenodename, port);
-					tt = time(0);
-					logErLog(ErLogFileName, &tt, "notice", "[%s] redirected to remote server [[%s]:%s]",
-							nodename, onenodename, port);
-					logAcLog(AcLogFileName, &tt, nodename, lineBuf, 307, answerSize,
-							useragentBuf, refererBuf);
-					break;
-				}
+        else if (csaddr->sa_family == AF_INET6) {
+          struct sockaddr_in6* cli_addr = (struct sockaddr_in6*) csaddr;
+          socklen_t onenode_len;
+          find_route6(nodename, IP6list, max_ttl);
+          for (i = 0;
+               memcmp(IP6list[i], &cli_addr->sin6_addr,
+                      sizeof(cli_addr->sin6_addr));
+               i++) {
+            memset(onenodename, 0, 200);
+            onenode_len = 199;
+            inet_ntop(AF_INET6, (void *) IP6list[i], onenodename, onenode_len);
+            log_println(4, "loop IP6list[%d], = %s", i, onenodename);
+            if (i == max_ttl) {
+              log_println(4, "Oops, destination not found!");
+              break;
+            }
+          }
+          /* print out last item on list */
+
+          if (get_debuglvl() > 3) {
+            memset(onenodename, 0, 200);
+            onenode_len = 199;
+            inet_ntop(AF_INET6, (void *) IP6list[i], onenodename, onenode_len);
+            log_println(4, "IP6list[%d] = %s", i, onenodename);
+          }
+
+          srv_addr = find_compare6(srv_addr6, IP6list, i);
+          if (srv_addr == 0) {
+            serv_addr = I2AddrByLocalSockFD(get_errhandle(), sd, False);
+            memset(onenodename, 0, 200);
+            nlen = 199;
+            I2AddrNodeName(serv_addr, onenodename, &nlen);
+            log_println(4, "find_compare6() returned 0, reset to [%s]",
+                        onenodename);
+            memcpy(srv_addr6,
+                   ((struct sockaddr_in6*)(&I2AddrSAddr(serv_addr, NULL)))->
+                       sin6_addr,
+                   16);
+          }
+
+          nlen = 199;
+          memset(onenodename, 0, 200);
+          inet_ntop(AF_INET6, (void *) srv_addr6, onenodename, nlen);
+
+          log_println(4, "Client host [%s] should be redirected to FLM server "
+                      "[%s]", nodename, onenodename);
+
+          writen(sd, MsgRedir1, strlen(MsgRedir1));
+          writen(sd, MsgRedir2, strlen(MsgRedir2));
+          snprintf(line, sizeof(line), "http://[%s]:%s/tcpbw100.html",
+                   onenodename, port);
+          writen(sd, line, strlen(line));
+          writen(sd, MsgRedir3, strlen(MsgRedir3));
+          writen(sd, MsgRedir4, strlen(MsgRedir4));
+          answerSize = strlen(MsgRedir4);
+          snprintf(line, sizeof(line), "url=http://[%s]:%s/tcpbw100.html",
+                   onenodename, port);
+          writen(sd, line, strlen(line));
+          answerSize += strlen(line);
+          writen(sd, MsgRedir5, strlen(MsgRedir5));
+          answerSize += strlen(MsgRedir5);
+          snprintf(line, sizeof(line), "href=\"http://[%s]:%s/tcpbw100.html\"",
+                   onenodename, port);
+          writen(sd, line, strlen(line));
+          answerSize += strlen(line);
+          writen(sd, MsgRedir6, strlen(MsgRedir6));
+          answerSize += strlen(MsgRedir6);
+          log_println(3, "%s redirected to remote server [[%s]:%s]", nodename,
+                      onenodename, port);
+          tt = time(0);
+          logErLog(ErLogFileName, &tt, "notice",
+                   "[%s] redirected to remote server [[%s]:%s]",
+                   nodename, onenodename, port);
+          logAcLog(AcLogFileName, &tt, nodename, lineBuf, 307, answerSize,
+                   useragentBuf, refererBuf);
+          break;
+        }
 #endif
-			}
-		}
-
-		/* try to open and give em what they want */
-		tt = time(0);
-		ok = 0;
-		if (strcmp(filename, "/") == 0)
-			strncpy(filename, "/tcpbw100.html", 15);
-		for (i = 0; okfile[i]; i++) {
-			/* restrict file access */
-			if (strcmp(okfile[i], filename) == 0) {
-				ok = 1;
-				break;
-			}
-		}
-		if (ok == 0) {
-			ptr = a_root;
-			while (ptr != NULL) {
-				if (strcmp(ptr->filename, filename) == 0) {
-					ok = 2;
-					break;
-				}
-				ptr = ptr->next;
-			}
-		}
-		log_print(3, "%15.15s [%s] requested file '%s' - ", ctime(&tt) + 4,
-				nodename, filename);
-		if (ok == 0) {
-			writen(sd, MsgNope1, strlen(MsgNope1));
-			writen(sd, MsgNope2, strlen(MsgNope2));
-			answerSize = strlen(MsgNope2);
-			log_println(3, "access denied");
-			logAcLog(AcLogFileName, &tt, nodename, lineBuf, 403, answerSize,
-					useragentBuf, refererBuf);
-			logErLog(ErLogFileName, &tt, "error",
-					"[client %s] Permission denied: path not allowed: %s",
-					nodename, filename);
-			if (usesyslog == 1)
-				syslog(LOG_FACILITY | LOG_WARNING,
-						"[client %s] Permission denied: path not allowed: %s",
-						nodename, filename);
-			break;
-		}
-		snprintf(htmlfile, sizeof(htmlfile), "%s/%s", basedir, filename + 1);
-		fd = open(htmlfile, 0); /* open file for read */
-		if (fd < 0) {
-			close(fd);
-			writen(sd, MsgNope1, strlen(MsgNope1));
-			writen(sd, MsgNope2, strlen(MsgNope2));
-			answerSize = strlen(MsgNope2);
-			log_println(3, " not found");
-			logAcLog(AcLogFileName, &tt, nodename, lineBuf, 404, answerSize,
-					useragentBuf, refererBuf);
-			logErLog(ErLogFileName, &tt, "error",
-					"[client %s] File does not exist: %s", nodename, filename);
-			if (usesyslog == 1)
-				syslog(LOG_FACILITY | LOG_WARNING,
-						"[client %s] File does not exist: %s", nodename,
-						filename);
-			break;
-		}
-		if (ok == 1) {
-			log_println(3, "sent to client");
-		} else {
-			log_println(3, "sent to client [A]");
-		}
-
-		/* reply: */
-
-		/* RAC
-		 * run Les Cottrell's traceroute program
-		 */
-		if (strncmp(htmlfile, "/usr/local/ndt/traceroute.pl", 28) == 0) {
-			loc_addr = I2AddrByLocalSockFD(get_errhandle(), sd, False);
-			memset(onenodename, 0, 200);
-			nlen = 199;
-			I2AddrNodeName(loc_addr, onenodename, &nlen);
-
-			setenv("QUERY_STRING", nodename, 1);
-			setenv("SERVER_NAME", onenodename, 1);
-			setenv("REMOTE_HOST", nodename, 1);
-			setenv("REMOTE_ADDR", "207.75.164.153", 1);
-			system("/usr/bin/perl /usr/local/ndt/traceroute.pl > /tmp/rac-traceroute.pl");
-			close(fd);
-			fd = open("/tmp/rac-traceroute.pl", 0);
-		}
-
-		writen(sd, MsgOK, strlen(MsgOK));
-		answerSize = 0;
-		while ((n = read(fd, buff, sizeof(buff))) > 0) {
-			writen(sd, buff, n);
-			answerSize += n;
-		}
-		logAcLog(AcLogFileName, &tt, nodename, lineBuf, 200, answerSize,
-				useragentBuf, refererBuf);
-		close(fd);
-		break;
-	}
-	close(sd);
+      }
+    }
+
+    /* try to open and give em what they want */
+    tt = time(0);
+    ok = 0;
+    if (strcmp(filename, "/") == 0)
+      strncpy(filename, "/tcpbw100.html", 15);
+    for (i = 0; okfile[i]; i++) {
+      /* restrict file access */
+      if (strcmp(okfile[i], filename) == 0) {
+        ok = 1;
+        break;
+      }
+    }
+    if (ok == 0) {
+      ptr = a_root;
+      while (ptr != NULL) {
+        if (strcmp(ptr->filename, filename) == 0) {
+          ok = 2;
+          break;
+        }
+        ptr = ptr->next;
+      }
+    }
+    log_print(3, "%15.15s [%s] requested file '%s' - ", ctime(&tt) + 4,
+              nodename, filename);
+    if (ok == 0) {
+      writen(sd, MsgNope1, strlen(MsgNope1));
+      writen(sd, MsgNope2, strlen(MsgNope2));
+      answerSize = strlen(MsgNope2);
+      log_println(3, "access denied");
+      logAcLog(AcLogFileName, &tt, nodename, lineBuf, 403, answerSize,
+               useragentBuf, refererBuf);
+      logErLog(ErLogFileName, &tt, "error",
+               "[client %s] Permission denied: path not allowed: %s",
+               nodename, filename);
+      if (usesyslog == 1)
+        syslog(LOG_FACILITY | LOG_WARNING,
+               "[client %s] Permission denied: path not allowed: %s",
+               nodename, filename);
+      break;
+    }
+    snprintf(htmlfile, sizeof(htmlfile), "%s/%s", basedir, filename + 1);
+    fd = open(htmlfile, 0); /* open file for read */
+    if (fd < 0) {
+      close(fd);
+      writen(sd, MsgNope1, strlen(MsgNope1));
+      writen(sd, MsgNope2, strlen(MsgNope2));
+      answerSize = strlen(MsgNope2);
+      log_println(3, " not found");
+      logAcLog(AcLogFileName, &tt, nodename, lineBuf, 404, answerSize,
+               useragentBuf, refererBuf);
+      logErLog(ErLogFileName, &tt, "error",
+               "[client %s] File does not exist: %s", nodename, filename);
+      if (usesyslog == 1)
+        syslog(LOG_FACILITY | LOG_WARNING,
+               "[client %s] File does not exist: %s", nodename,
+               filename);
+      break;
+    }
+    if (ok == 1) {
+      log_println(3, "sent to client");
+    } else {
+      log_println(3, "sent to client [A]");
+    }
+
+    /* reply: */
+
+    /* RAC
+     * run Les Cottrell's traceroute program
+     */
+    if (strncmp(htmlfile, "/usr/local/ndt/traceroute.pl", 28) == 0) {
+      loc_addr = I2AddrByLocalSockFD(get_errhandle(), sd, False);
+      memset(onenodename, 0, 200);
+      nlen = 199;
+      I2AddrNodeName(loc_addr, onenodename, &nlen);
+
+      setenv("QUERY_STRING", nodename, 1);
+      setenv("SERVER_NAME", onenodename, 1);
+      setenv("REMOTE_HOST", nodename, 1);
+      setenv("REMOTE_ADDR", "207.75.164.153", 1);
+      system("/usr/bin/perl /usr/local/ndt/traceroute.pl > "
+             "/tmp/rac-traceroute.pl");
+      close(fd);
+      fd = open("/tmp/rac-traceroute.pl", 0);
+    }
+
+    writen(sd, MsgOK, strlen(MsgOK));
+    answerSize = 0;
+    while ((n = read(fd, buff, sizeof(buff))) > 0) {
+      writen(sd, buff, n);
+      answerSize += n;
+    }
+    logAcLog(AcLogFileName, &tt, nodename, lineBuf, 200, answerSize,
+             useragentBuf, refererBuf);
+    close(fd);
+    break;
+  }
+  close(sd);
 }
 
 char*
 getTime(time_t* tt, char* format) {
-	static char timeBuf[100];
+  static char timeBuf[100];
 
-	if (strftime(timeBuf, 99, format, localtime(tt))) {
-		return timeBuf;
-	} else {
-		return (ctime(tt) + 4);
-	}
+  if (strftime(timeBuf, 99, format, localtime(tt))) {
+    return timeBuf;
+  } else {
+    return (ctime(tt) + 4);
+  }
 }
 
-void logErLog(char* LogFileName, time_t* tt, char* severity, char* format, ...)
-{
-	FILE *fp;
-	va_list ap;
-	if (LogFileName != NULL) {
-		fp = fopen(LogFileName, "a");
-		if (fp != NULL) {
-			fprintf(fp, "[%s] [%s] ", getTime(tt, er_time_format), severity);
-			va_start(ap, format);
-			vfprintf(fp, format, ap);
-			va_end(ap);
-			fprintf(fp, "\n");
-			fclose(fp);
-		}
-	}
+void logErLog(char* LogFileName, time_t* tt, char* severity,
+              char* format, ...) {
+  FILE *fp;
+  va_list ap;
+  if (LogFileName != NULL) {
+    fp = fopen(LogFileName, "a");
+    if (fp != NULL) {
+      fprintf(fp, "[%s] [%s] ", getTime(tt, er_time_format), severity);
+      va_start(ap, format);
+      vfprintf(fp, format, ap);
+      va_end(ap);
+      fprintf(fp, "\n");
+      fclose(fp);
+    }
+  }
 }
 
 void logAcLog(char* LogFileName, time_t* tt, char* host, char* line, int res,
-		int size, char* agent, char* referer) {
-	FILE * fp;
-	if (LogFileName != NULL) {
-		fp = fopen(LogFileName, "a");
-		if (fp != NULL) {
-			fprintf(fp, "%s - - [%s] \"%s\" %d %d \"%s\" \"%s\"\n", host,
-					getTime(tt, ac_time_format), line, res, size, agent,
-					referer);
-			fclose(fp);
-		}
-	}
+              int size, char* agent, char* referer) {
+  FILE * fp;
+  if (LogFileName != NULL) {
+    fp = fopen(LogFileName, "a");
+    if (fp != NULL) {
+      fprintf(fp, "%s - - [%s] \"%s\" %d %d \"%s\" \"%s\"\n", host,
+              getTime(tt, ac_time_format), line, res, size, agent,
+              referer);
+      fclose(fp);
+    }
+  }
 }
diff --git a/src/genplot.c b/src/genplot.c
index 20ce782..36983bc 100644
--- a/src/genplot.c
+++ b/src/genplot.c
@@ -32,652 +32,641 @@
 #include  <web100.h>
 #endif
 
-#include "usage.h"
+#include "./usage.h"
 
 char *color[16] = { "green", "blue", "orange", "red", "yellow", "magenta",
-		"pink", "white", "black" };
+  "pink", "white", "black" };
 
 static struct option long_options[] = { { "both", 0, 0, 'b' }, { "multi", 1, 0,
-		'm' }, { "text", 0, 0, 't' }, { "CurCwnd", 0, 0, 'C' }, { "CurRwinRcvd",
-		0, 0, 'R' }, { "throughput", 0, 0, 'S' }, { "cwndtime", 0, 0, 'c' }, {
-		"help", 0, 0, 'h' }, { "version", 0, 0, 'v' }, { 0, 0, 0, 0 } };
+  'm' }, { "text", 0, 0, 't' }, { "CurCwnd", 0, 0, 'C' }, { "CurRwinRcvd",
+    0, 0, 'R' }, { "throughput", 0, 0, 'S' }, { "cwndtime", 0, 0, 'c' }, {
+      "help", 0, 0, 'h' }, { "version", 0, 0, 'v' }, { 0, 0, 0, 0 } };
 
 int checkmz(int x) {
-	if (x == 2147483647) {
-		return -1;
-	}
-	return x;
+  if (x == 2147483647) {
+    return -1;
+  }
+  return x;
 }
 
 void get_title(web100_snapshot* snap, web100_log* log, web100_agent* agent,
-		web100_group* group, char* title, char* remport) {
-
-	web100_var* var;
-	char buf[128];
-
-	if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
-		web100_perror("web100_log_open_read");
-		return;
-	}
-
-	if ((web100_agent_find_var_and_group(agent, "LocalAddress", &group, &var))
-			!= WEB100_ERR_SUCCESS) {
-		web100_perror("web100_agent_find_var_and_group");
-		exit(EXIT_FAILURE);
-	}
-	if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-		web100_perror("web100_snap_read");
-		exit(EXIT_FAILURE);
-	}
-	strcpy(title, web100_value_to_text(web100_get_var_type(var), buf));
-	strncat(title, ":", 1);
-	if ((web100_agent_find_var_and_group(agent, "LocalPort", &group, &var))
-			!= WEB100_ERR_SUCCESS) {
-		web100_perror("web100_agent_find_var_and_group");
-		exit(EXIT_FAILURE);
-	}
-	if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-		web100_perror("web100_snap_read");
-		exit(EXIT_FAILURE);
-	}
-	strcat(title, web100_value_to_text(web100_get_var_type(var), buf));
-	strncat(title, " --> ", 5);
-	if ((web100_agent_find_var_and_group(agent, "RemAddress", &group, &var))
-			!= WEB100_ERR_SUCCESS) {
-		web100_perror("web100_agent_find_var_and_group");
-		exit(EXIT_FAILURE);
-	}
-	if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-		web100_perror("web100_snap_read");
-		exit(EXIT_FAILURE);
-	}
-	strcat(title, web100_value_to_text(web100_get_var_type(var), buf));
-	if ((web100_agent_find_var_and_group(agent, "RemPort", &group, &var))
-			!= WEB100_ERR_SUCCESS) {
-		web100_perror("web100_agent_find_var_and_group");
-		exit(EXIT_FAILURE);
-	}
-	if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-		web100_perror("web100_snap_read");
-		exit(EXIT_FAILURE);
-	}
-	strcpy(remport, web100_value_to_text(web100_get_var_type(var), buf));
-	/* printf("%s:%s\n", title, remport); */
+               web100_group* group, char* title, char* remport) {
+  web100_var* var;
+  char buf[128];
+
+  if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_log_open_read");
+    return;
+  }
+
+  if ((web100_agent_find_var_and_group(agent, "LocalAddress", &group, &var))
+      != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_agent_find_var_and_group");
+    exit(EXIT_FAILURE);
+  }
+  if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_snap_read");
+    exit(EXIT_FAILURE);
+  }
+  strcpy(title, web100_value_to_text(web100_get_var_type(var), buf));
+  strncat(title, ":", 1);
+  if ((web100_agent_find_var_and_group(agent, "LocalPort", &group, &var))
+      != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_agent_find_var_and_group");
+    exit(EXIT_FAILURE);
+  }
+  if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_snap_read");
+    exit(EXIT_FAILURE);
+  }
+  strcat(title, web100_value_to_text(web100_get_var_type(var), buf));
+  strncat(title, " --> ", 5);
+  if ((web100_agent_find_var_and_group(agent, "RemAddress", &group, &var))
+      != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_agent_find_var_and_group");
+    exit(EXIT_FAILURE);
+  }
+  if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_snap_read");
+    exit(EXIT_FAILURE);
+  }
+  strcat(title, web100_value_to_text(web100_get_var_type(var), buf));
+  if ((web100_agent_find_var_and_group(agent, "RemPort", &group, &var))
+      != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_agent_find_var_and_group");
+    exit(EXIT_FAILURE);
+  }
+  if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+    web100_perror("web100_snap_read");
+    exit(EXIT_FAILURE);
+  }
+  strcpy(remport, web100_value_to_text(web100_get_var_type(var), buf));
+  /* printf("%s:%s\n", title, remport); */
 }
 
 void plot_var(char *list, int cnt, char *name, web100_snapshot* snap,
-		web100_log* log, web100_agent* agent, web100_group* group,
-		int(*func)(const int arg, const int value)) {
-
-	char *varg;
-	char buf[256];
-	web100_var* var;
-	char varlist[256], lname[256], remport[8];
-	char title[256];
-	int i, first = 0;
-	float x1, x2, y1[32], y2[32];
-	FILE *fn;
-
-	/* Write a xplot file out to the requested file.
-	 * Start by extracting the connection info for the 
-	 * page title.  Then its a series of line statements
-	 * with the x1 y1 x2 y2 coordinates.
-	 */
-
-	memset(lname, 0, 256);
-
-	get_title(snap, log, agent, group, title, remport);
-
-	if (name == NULL) {
-		fn = stdout;
-		strncpy(name, "Unknown", 7);
-	} else {
-		strncpy(lname, name, strlen(name));
-		strcat(lname, ".");
-		strcat(lname, remport);
-		strcat(lname, ".xpl");
-		fn = fopen(lname, "w");
-	}
-
-	fprintf(fn, "double double\ntitle\n");
-	fprintf(fn, "%s:%s (%s)\n", title, remport, name);
-	if ((strncmp(name, "Throughput", 10)) == 0)
-		fprintf(fn, "xlabel\nTime\nylabel\nMbits/sec\n");
-	else
-		fprintf(fn, "xlabel\nTime\nylabel\nKilo Bytes\n");
-
-	x1 = x2 = 0;
-	for (i = 0; i < 32; i++) {
-		y1[i] = 0;
-		y2[i] = 0;
-	}
-	first = 0;
-
-	for (;;) {
-		if (first != 0) {
-			if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
-				/* web100_perror("web100_log_open_read"); */
-				fprintf(fn, "go\n");
-				return;
-			}
-		}
-		strncpy(varlist, list, strlen(list) + 1);
-		varg = strtok(varlist, ",");
-		for (i = 0; i < cnt; i++) {
-			if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
-					!= WEB100_ERR_SUCCESS) {
-				web100_perror("web100_agent_find_var_and_group");
-				exit(EXIT_FAILURE);
-			}
-
-			if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-				web100_perror("web100_snap_read");
-				exit(EXIT_FAILURE);
-			}
-
-			if (i == 0) {
-				if (first == 0) {
-					if (func) {
-						x1 = func(
-								i,
-								checkmz(
-										atoi(
-												web100_value_to_text(
-														web100_get_var_type(
-																var), buf))));
-					} else {
-						x1 = checkmz(
-								atoi(
-										web100_value_to_text(
-												web100_get_var_type(var),
-												buf)));
-					}
-				} else {
-					x1 = x2;
-				}
-			} else {
-				if (first == 0) {
-					if (func) {
-						y1[i - 1] = func(
-								i,
-								checkmz(
-										atoi(
-												web100_value_to_text(
-														web100_get_var_type(
-																var), buf))));
-					} else {
-						y1[i - 1] = checkmz(
-								atoi(
-										web100_value_to_text(
-												web100_get_var_type(var),
-												buf)));
-					}
-				} else {
-					y1[i - 1] = y2[i - 1];
-				}
-			}
-			varg = strtok(NULL, ",");
-		}
-
-		first++;
-		strncpy(varlist, list, strlen(list) + 1);
-		varg = strtok(varlist, ",");
-		for (i = 0; i < cnt; i++) {
-			if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
-					!= WEB100_ERR_SUCCESS) {
-				web100_perror("web100_agent_find_var_and_group");
-				exit(EXIT_FAILURE);
-			}
-
-			if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-				web100_perror("web100_snap_read");
-				exit(EXIT_FAILURE);
-			}
-
-			if (i == 0) {
-				if (func) {
-					x2 = func(
-							i,
-							checkmz(
-									atoi(
-											web100_value_to_text(
-													web100_get_var_type(var),
-													buf))));
-				} else {
-					x2 = checkmz(
-							atoi(
-									web100_value_to_text(
-											web100_get_var_type(var), buf)));
-				}
-			} else {
-				if (func) {
-					y2[i - 1] = func(
-							i,
-							checkmz(
-									atoi(
-											web100_value_to_text(
-													web100_get_var_type(var),
-													buf))));
-				} else {
-					y2[i - 1] = checkmz(
-							atoi(
-									web100_value_to_text(
-											web100_get_var_type(var), buf)));
-				}
-				fprintf(fn, "%s\nline %0.4f %0.4f %0.4f %0.4f\n", color[i - 1],
-						x1 / 1000000, y1[i - 1] / 1024, x2 / 1000000,
-						y2[i - 1] / 1024);
-			}
-			varg = strtok(NULL, ",");
-		}
-	}
-	fprintf(fn, "go\n");
-
+              web100_log* log, web100_agent* agent, web100_group* group,
+              int(*func)(const int arg, const int value)) {
+  char *varg;
+  char buf[256];
+  web100_var* var;
+  char varlist[256], lname[256], remport[8];
+  char title[256];
+  int i, first = 0;
+  float x1, x2, y1[32], y2[32];
+  FILE *fn;
+
+  /* Write a xplot file out to the requested file.
+   * Start by extracting the connection info for the 
+   * page title.  Then its a series of line statements
+   * with the x1 y1 x2 y2 coordinates.
+   */
+
+  memset(lname, 0, 256);
+
+  get_title(snap, log, agent, group, title, remport);
+
+  if (name == NULL) {
+    fn = stdout;
+    strncpy(name, "Unknown", 7);
+  } else {
+    snprintf(lname, sizeof(lname), "%s.%s.xpl", name, remport);
+    fn = fopen(lname, "w");
+  }
+
+  fprintf(fn, "double double\ntitle\n");
+  fprintf(fn, "%s:%s (%s)\n", title, remport, name);
+  if ((strncmp(name, "Throughput", 10)) == 0)
+    fprintf(fn, "xlabel\nTime\nylabel\nMbits/sec\n");
+  else
+    fprintf(fn, "xlabel\nTime\nylabel\nKilo Bytes\n");
+
+  x1 = x2 = 0;
+  for (i = 0; i < 32; i++) {
+    y1[i] = 0;
+    y2[i] = 0;
+  }
+  first = 0;
+
+  for (;;) {
+    if (first != 0) {
+      if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+        /* web100_perror("web100_log_open_read"); */
+        fprintf(fn, "go\n");
+        return;
+      }
+    }
+    strncpy(varlist, list, strlen(list) + 1);
+    varg = strtok(varlist, ",");
+    for (i = 0; i < cnt; i++) {
+      if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
+          != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_agent_find_var_and_group");
+        exit(EXIT_FAILURE);
+      }
+
+      if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_snap_read");
+        exit(EXIT_FAILURE);
+      }
+
+      if (i == 0) {
+        if (first == 0) {
+          if (func) {
+            x1 = func(
+                i,
+                checkmz(
+                    atoi(
+                        web100_value_to_text(
+                            web100_get_var_type(
+                                var), buf))));
+          } else {
+            x1 = checkmz(
+                atoi(
+                    web100_value_to_text(
+                        web100_get_var_type(var),
+                        buf)));
+          }
+        } else {
+          x1 = x2;
+        }
+      } else {
+        if (first == 0) {
+          if (func) {
+            y1[i - 1] = func(
+                i,
+                checkmz(
+                    atoi(
+                        web100_value_to_text(
+                            web100_get_var_type(
+                                var), buf))));
+          } else {
+            y1[i - 1] = checkmz(
+                atoi(
+                    web100_value_to_text(
+                        web100_get_var_type(var),
+                        buf)));
+          }
+        } else {
+          y1[i - 1] = y2[i - 1];
+        }
+      }
+      varg = strtok(NULL, ",");
+    }
+
+    first++;
+    strncpy(varlist, list, strlen(list) + 1);
+    varg = strtok(varlist, ",");
+    for (i = 0; i < cnt; i++) {
+      if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
+          != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_agent_find_var_and_group");
+        exit(EXIT_FAILURE);
+      }
+
+      if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_snap_read");
+        exit(EXIT_FAILURE);
+      }
+
+      if (i == 0) {
+        if (func) {
+          x2 = func(
+              i,
+              checkmz(
+                  atoi(
+                      web100_value_to_text(
+                          web100_get_var_type(var),
+                          buf))));
+        } else {
+          x2 = checkmz(
+              atoi(
+                  web100_value_to_text(
+                      web100_get_var_type(var), buf)));
+        }
+      } else {
+        if (func) {
+          y2[i - 1] = func(
+              i,
+              checkmz(
+                  atoi(
+                      web100_value_to_text(
+                          web100_get_var_type(var),
+                          buf))));
+        } else {
+          y2[i - 1] = checkmz(
+              atoi(
+                  web100_value_to_text(
+                      web100_get_var_type(var), buf)));
+        }
+        fprintf(fn, "%s\nline %0.4f %0.4f %0.4f %0.4f\n", color[i - 1],
+                x1 / 1000000, y1[i - 1] / 1024, x2 / 1000000,
+                y2[i - 1] / 1024);
+      }
+      varg = strtok(NULL, ",");
+    }
+  }
+  fprintf(fn, "go\n");
 }
 
 void plot_cwndtime(char *name, web100_snapshot* snap, web100_log* log,
-		web100_agent* agent, web100_group* group) {
-	double SndLimTimeRwin = 0, SndLimTimeSender = 0;
-	char buf[256];
-	web100_var* var;
-	char lname[256], remport[8];
-	char title[256];
-	char* variables[] = { "Duration", "SndLimTimeRwin", "SndLimTimeSender",
-			"SndLimTimeCwnd" };
-	int i, first = 0;
-	double x1, x2, y1, y2;
-	FILE *fn;
-
-	memset(lname, 0, 256);
-
-	get_title(snap, log, agent, group, title, remport);
-
-	if (name == NULL) {
-		fn = stdout;
-		strncpy(name, "Unknown", 7);
-	} else {
-		strncpy(lname, name, strlen(name));
-		strcat(lname, ".");
-		strcat(lname, remport);
-		strcat(lname, ".xpl");
-		fn = fopen(lname, "w");
-	}
-
-	fprintf(fn, "double double\ntitle\n");
-	fprintf(fn, "%s:%s (%s)\n", title, remport, name);
-	fprintf(fn, "xlabel\nTime\nylabel\nPercentage\n");
-
-	x1 = x2 = y1 = y2 = 0;
-	first = 0;
-
-	for (;;) {
-		if (first != 0) {
-			if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
-				fprintf(fn, "go\n");
-				return;
-			}
-		}
-		for (i = 0; i < 4; i++) {
-			if ((web100_agent_find_var_and_group(agent, variables[i], &group,
-					&var)) != WEB100_ERR_SUCCESS) {
-				web100_perror("web100_agent_find_var_and_group");
-				exit(EXIT_FAILURE);
-			}
-
-			if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-				web100_perror("web100_snap_read");
-				exit(EXIT_FAILURE);
-			}
-
-			if (i == 0) {
-				if (first == 0) {
-					x1 = atoi(
-							web100_value_to_text(web100_get_var_type(var),
-									buf));
-				} else {
-					x1 = x2;
-				}
-			} else if (i == 1) {
-				if (first == 0) {
-					SndLimTimeRwin = atoi(
-							web100_value_to_text(web100_get_var_type(var),
-									buf));
-				}
-			} else if (i == 2) {
-				if (first == 0) {
-					SndLimTimeSender = atoi(
-							web100_value_to_text(web100_get_var_type(var),
-									buf));
-				}
-			} else {
-				if (first == 0) {
-					y1 = atoi(
-							web100_value_to_text(web100_get_var_type(var),
-									buf));
-					y1 = y1 / (SndLimTimeRwin + SndLimTimeSender + y1);
-				} else {
-					y1 = y2;
-				}
-			}
-		}
-
-		first++;
-		for (i = 0; i < 4; i++) {
-			if ((web100_agent_find_var_and_group(agent, variables[i], &group,
-					&var)) != WEB100_ERR_SUCCESS) {
-				web100_perror("web100_agent_find_var_and_group");
-				exit(EXIT_FAILURE);
-			}
-
-			if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-				web100_perror("web100_snap_read");
-				exit(EXIT_FAILURE);
-			}
-
-			if (i == 0) {
-				x2 = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-			} else if (i == 1) {
-				SndLimTimeRwin = atoi(
-						web100_value_to_text(web100_get_var_type(var), buf));
-			} else if (i == 2) {
-				SndLimTimeSender = atoi(
-						web100_value_to_text(web100_get_var_type(var), buf));
-			} else {
-				y2 = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-				y2 = y2 / (SndLimTimeRwin + SndLimTimeSender + y2);
-				fprintf(fn, "%s\nline %0.4f %0.4f %0.4f %0.4f\n", color[i - 1],
-						x1 / 1000000, y1, x2 / 1000000, y2);
-			}
-		}
-	}
-	fprintf(fn, "go\n");
-
+                   web100_agent* agent, web100_group* group) {
+  double SndLimTimeRwin = 0, SndLimTimeSender = 0;
+  char buf[256];
+  web100_var* var;
+  char lname[256], remport[8];
+  char title[256];
+  char* variables[] = { "Duration", "SndLimTimeRwin", "SndLimTimeSender",
+    "SndLimTimeCwnd" };
+  int i, first = 0;
+  double x1, x2, y1, y2;
+  FILE *fn;
+
+  memset(lname, 0, 256);
+
+  get_title(snap, log, agent, group, title, remport);
+
+  if (name == NULL) {
+    fn = stdout;
+    strncpy(name, "Unknown", 7);
+  } else {
+    snprintf(lname, sizeof(lname), "%s.%s.xpl", name, remport);
+    fn = fopen(lname, "w");
+  }
+
+  fprintf(fn, "double double\ntitle\n");
+  fprintf(fn, "%s:%s (%s)\n", title, remport, name);
+  fprintf(fn, "xlabel\nTime\nylabel\nPercentage\n");
+
+  x1 = x2 = y1 = y2 = 0;
+  first = 0;
+
+  for (;;) {
+    if (first != 0) {
+      if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+        fprintf(fn, "go\n");
+        return;
+      }
+    }
+    for (i = 0; i < 4; i++) {
+      if ((web100_agent_find_var_and_group(agent, variables[i], &group,
+                                           &var)) != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_agent_find_var_and_group");
+        exit(EXIT_FAILURE);
+      }
+
+      if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_snap_read");
+        exit(EXIT_FAILURE);
+      }
+
+      if (i == 0) {
+        if (first == 0) {
+          x1 = atoi(
+              web100_value_to_text(web100_get_var_type(var),
+                                   buf));
+        } else {
+          x1 = x2;
+        }
+      } else if (i == 1) {
+        if (first == 0) {
+          SndLimTimeRwin = atoi(
+              web100_value_to_text(web100_get_var_type(var),
+                                   buf));
+        }
+      } else if (i == 2) {
+        if (first == 0) {
+          SndLimTimeSender = atoi(
+              web100_value_to_text(web100_get_var_type(var),
+                                   buf));
+        }
+      } else {
+        if (first == 0) {
+          y1 = atoi(
+              web100_value_to_text(web100_get_var_type(var),
+                                   buf));
+          y1 = y1 / (SndLimTimeRwin + SndLimTimeSender + y1);
+        } else {
+          y1 = y2;
+        }
+      }
+    }
+
+    first++;
+    for (i = 0; i < 4; i++) {
+      if ((web100_agent_find_var_and_group(agent, variables[i], &group,
+                                           &var)) != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_agent_find_var_and_group");
+        exit(EXIT_FAILURE);
+      }
+
+      if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_snap_read");
+        exit(EXIT_FAILURE);
+      }
+
+      if (i == 0) {
+        x2 = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+      } else if (i == 1) {
+        SndLimTimeRwin = atoi(
+            web100_value_to_text(web100_get_var_type(var), buf));
+      } else if (i == 2) {
+        SndLimTimeSender = atoi(
+            web100_value_to_text(web100_get_var_type(var), buf));
+      } else {
+        y2 = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+        y2 = y2 / (SndLimTimeRwin + SndLimTimeSender + y2);
+        fprintf(fn, "%s\nline %0.4f %0.4f %0.4f %0.4f\n", color[i - 1],
+                x1 / 1000000, y1, x2 / 1000000, y2);
+      }
+    }
+  }
+  fprintf(fn, "go\n");
 }
 
 void print_var(char *varlist, web100_snapshot* snap, web100_log* log,
-		web100_agent* agent, web100_group* group,
-		void(*func)(const int arg, const int value)) {
-
-	char *varg, savelist[256], *text;
-	char buf[256], title[256], remport[8];
-	int i, j;
-	web100_var* var;
-	FILE* fn;
-
-	fn = stdout;
-	get_title(snap, log, agent, group, title, remport);
-	fprintf(fn, "Extracting Data from %s:%s connection\n\n", title, remport);
-
-	strncpy(savelist, varlist, strlen(varlist) + 1);
-	printf("Index\t");
-	varg = strtok(varlist, ",");
-	for (j = 0;; j++) {
-		if (varg == NULL)
-			break;
-		if (func) {
-			func(-1, j);
-		} else {
-			printf("%10s\t", varg);
-		}
-		varg = strtok(NULL, ",");
-	}
-	printf("\n");
-	for (i = 0;; i++) {
-		if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
-			/* web100_perror("web100_log_open_read"); */
-			printf("-------------- End Of Data  --------------\n\n");
-			return;
-		}
-		printf("%5d\t", i);
-
-		strncpy(varlist, savelist, strlen(savelist) + 1);
-		varg = strtok(varlist, ",");
-		for (j = 0;; j++) {
-			if (varg == NULL)
-				break;
-			if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
-					!= WEB100_ERR_SUCCESS) {
-				web100_perror("web100_agent_find_var_and_group");
-				exit(EXIT_FAILURE);
-			}
-
-			if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-				web100_perror("web100_snap_read");
-				exit(EXIT_FAILURE);
-			}
-			if (func) {
-				func(
-						j,
-						atoi(
-								web100_value_to_text(web100_get_var_type(var),
-										buf)));
-			} else {
-				text = web100_value_to_text(web100_get_var_type(var), buf);
-				if (strcmp(text, "4294966376") == 0) {
-					printf("%10s\t", "-1");
-				} else {
-					printf("%10s\t", text);
-				}
-			}
-			varg = strtok(NULL, ",");
-		}
-		printf("\n");
-	}
-
+               web100_agent* agent, web100_group* group,
+               void(*func)(const int arg, const int value)) {
+  char *varg, savelist[256], *text;
+  char buf[256], title[256], remport[8];
+  int i, j;
+  web100_var* var;
+  FILE* fn;
+
+  fn = stdout;
+  get_title(snap, log, agent, group, title, remport);
+  fprintf(fn, "Extracting Data from %s:%s connection\n\n", title, remport);
+
+  strncpy(savelist, varlist, strlen(varlist) + 1);
+  printf("Index\t");
+  varg = strtok(varlist, ",");
+  for (j = 0;; j++) {
+    if (varg == NULL)
+      break;
+    if (func) {
+      func(-1, j);
+    } else {
+      printf("%10s\t", varg);
+    }
+    varg = strtok(NULL, ",");
+  }
+  printf("\n");
+  for (i = 0;; i++) {
+    if ((web100_snap_from_log(snap, log)) != WEB100_ERR_SUCCESS) {
+      /* web100_perror("web100_log_open_read"); */
+      printf("-------------- End Of Data  --------------\n\n");
+      return;
+    }
+    printf("%5d\t", i);
+
+    strncpy(varlist, savelist, strlen(savelist) + 1);
+    varg = strtok(varlist, ",");
+    for (j = 0;; j++) {
+      if (varg == NULL)
+        break;
+      if ((web100_agent_find_var_and_group(agent, varg, &group, &var))
+          != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_agent_find_var_and_group");
+        exit(EXIT_FAILURE);
+      }
+
+      if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+        web100_perror("web100_snap_read");
+        exit(EXIT_FAILURE);
+      }
+      if (func) {
+        func(
+            j,
+            atoi(
+                web100_value_to_text(web100_get_var_type(var),
+                                     buf)));
+      } else {
+        text = web100_value_to_text(web100_get_var_type(var), buf);
+        if (strcmp(text, "4294966376") == 0) {
+          printf("%10s\t", "-1");
+        } else {
+          printf("%10s\t", text);
+        }
+      }
+      varg = strtok(NULL, ",");
+    }
+    printf("\n");
+  }
 }
 
 /* workers */
 void throughput(const int arg, const int value) {
-	static int duration;
-
-	if (arg == -1) {
-		if (value) {
-			printf("%10s\t", "Throughput (kB/s)");
-		} else {
-			printf("%10s\t", "Duration");
-		}
-		return;
-	}
-
-	if (!arg) { /* duration */
-		duration = value;
-		printf("%10d\t", value);
-	} else { /* DataBytesOut */
-		printf(
-				"%10.2f",
-				((8 * ((double) value)) / ((double) duration)) * 1000000.0
-						/ 1024.0 / 1024.0);
-	}
+  static int duration;
+
+  if (arg == -1) {
+    if (value) {
+      printf("%10s\t", "Throughput (kB/s)");
+    } else {
+      printf("%10s\t", "Duration");
+    }
+    return;
+  }
+
+  if (!arg) { /* duration */
+    duration = value;
+    printf("%10d\t", value);
+  } else { /* DataBytesOut */
+    printf(
+        "%10.2f",
+        ((8 * ((double) value)) / ((double) duration)) * 1000000.0
+        / 1024.0 / 1024.0);
+  }
 }
 
 int throughputPlot(const int arg, const int value) {
-	static int duration;
-
-	if (!arg) { /* duration */
-		duration = value;
-		return value;
-	} else { /* DataBytesOut */
-		return (((double) value) / ((double) duration)) * 1000000.0;
-	}
+  static int duration;
+
+  if (!arg) { /* duration */
+    duration = value;
+    return value;
+  } else { /* DataBytesOut */
+    return (((double) value) / ((double) duration)) * 1000000.0;
+  }
 }
 
 void cwndtime(const int arg, const int value) {
-	static int SndLimTimeRwin, SndLimTimeSender;
-
-	if (arg == -1) {
-		if (value == 0) {
-			printf("%10s\t", "Duration");
-		} else if (value == 3) {
-			printf("%10s\t", "CwndTime (%% of total time)");
-		}
-		return;
-	}
-
-	if (arg == 0) { /* duration */
-		printf("%10d\t", value);
-	} else if (arg == 1) { /* SndLimTimeRwin */
-		SndLimTimeRwin = value;
-	} else if (arg == 2) { /* SndLimTimeSender */
-		SndLimTimeSender = value;
-	} else { /* SndLimTimeCwnd */
-		printf(
-				"%10.2f",
-				((double) value)
-						/ (((double) SndLimTimeRwin)
-								+ ((double) SndLimTimeSender) + ((double) value)));
-	}
+  static int SndLimTimeRwin, SndLimTimeSender;
+
+  if (arg == -1) {
+    if (value == 0) {
+      printf("%10s\t", "Duration");
+    } else if (value == 3) {
+      printf("%10s\t", "CwndTime (%% of total time)");
+    }
+    return;
+  }
+
+  if (arg == 0) { /* duration */
+    printf("%10d\t", value);
+  } else if (arg == 1) { /* SndLimTimeRwin */
+    SndLimTimeRwin = value;
+  } else if (arg == 2) { /* SndLimTimeSender */
+    SndLimTimeSender = value;
+  } else { /* SndLimTimeCwnd */
+    printf(
+        "%10.2f",
+        ((double) value)
+        / (((double) SndLimTimeRwin)
+           + ((double) SndLimTimeSender) + ((double) value)));
+  }
 }
 
 /* --- */
 
 int main(int argc, char** argv) {
-	web100_agent* agent;
-	web100_connection* conn;
-	web100_group* group;
-	web100_log* log;
-	web100_snapshot* snap;
-	char fn[128];
-	char *varlist = NULL, list[1024];
-	char *varg;
-	int j, c, plotspd = 0, plotuser = 0;
-	int plotboth = 0, plotcwnd = 0, plotrwin = 0;
-	int plotcwndtime = 0;
-	int k, txt = 0;
-
-	while ((c = getopt_long(argc, argv, "hCScRbtm:v", long_options, 0)) != -1) {
-		switch (c) {
-		case 'b':
-			plotboth = 1;
-			break;
-		case 'h':
-			genplot_long_usage("ANL/Internet2 NDT version " VERSION " (genplot)", argv[0]);
-			break;
-		case 'v':
-			printf("ANL/Internet2 NDT version %s (genplot)\n", VERSION);
-			exit(0);
-			break;
-		case 't':
-			txt = 1;
-			break;
-		case 'C':
-			plotcwnd = 1;
-			break;
-		case 'R':
-			plotrwin = 1;
-			break;
-		case 'S':
-			plotspd = 1;
-			break;
-		case 'c':
-			plotcwndtime = 1;
-			break;
-		case 'm':
-			varlist = optarg;
-			plotuser = 1;
-			break;
-		}
-	}
-
-	if (optind == argc) {
-		short_usage(argv[0], "Missing snaplog file");
-	}
-
-	if (argc == 1) {
-short_usage	(argv[0], "ANL/Internet2 NDT version " VERSION " (genplot)");
-}
-
-	for (j = optind; j < argc; j++) {
-		snprintf(fn, sizeof(fn), "%s", argv[j]);
-		if ((log = web100_log_open_read(fn)) == NULL) {
-			web100_perror("web100_log_open_read");
-			exit(EXIT_FAILURE);
-		}
-
-		if ((agent = web100_get_log_agent(log)) == NULL) {
-			web100_perror("web100_get_log_agent");
-			exit(EXIT_FAILURE);
-		}
-
-		if ((group = web100_get_log_group(log)) == NULL) {
-			web100_perror("web100_get_log_group");
-			exit(EXIT_FAILURE);
-		}
-
-		if ((conn = web100_get_log_connection(log)) == NULL) {
-			web100_perror("web100_get_log_connection");
-			exit(EXIT_FAILURE);
-		}
-
-		fprintf(stderr, "Extracting data from Snaplog '%s'\n\n", fn);
-
-		if ((snap = web100_snapshot_alloc_from_log(log)) == NULL) {
-			web100_perror("web100_snapshot_alloc_from_log");
-			exit(EXIT_FAILURE);
-		}
-
-		if (plotuser == 1) {
-			memset(list, 0, 1024);
-			strncpy(list, "Duration,", 9);
-			strncat(list, varlist, strlen(varlist));
-			varg = strtok(list, ",");
-			for (k = 1;; k++) {
-				if ((varg = strtok(NULL, ",")) == NULL)
-					break;
-			}
-			memset(list, 0, 1024);
-			strncpy(list, "Duration,", 9);
-			strncat(list, varlist, strlen(varlist));
-			if (txt == 1)
-				print_var(list, snap, log, agent, group, NULL);
-			else
-				plot_var(list, k, "User Defined", snap, log, agent, group,
-						NULL);
-		}
-		if (plotspd == 1) {
-			memset(list, 0, 1024);
-			strncpy(list, "Duration,DataBytesOut", 21);
-			if (txt == 1)
-				print_var(list, snap, log, agent, group, throughput);
-			else
-				plot_var(list, 2, "Throughput", snap, log, agent, group,
-						throughputPlot);
-		}
-		if (plotcwndtime == 1) {
-			memset(list, 0, 1024);
-			strncpy(list,
-					"Duration,SndLimTimeRwin,SndLimTimeSender,SndLimTimeCwnd",
-					55);
-			if (txt == 1)
-				print_var(list, snap, log, agent, group, cwndtime);
-			else
-				plot_cwndtime("Cwnd Time", snap, log, agent, group);
-		}
-		if (plotcwnd == 1) {
-			memset(list, 0, 1024);
-			strncpy(list, "Duration,CurCwnd", 16);
-			if (txt == 1)
-				print_var(list, snap, log, agent, group, NULL);
-			else
-				plot_var(list, 2, "CurCwnd", snap, log, agent, group, NULL);
-		}
-		if (plotrwin == 1) {
-			memset(list, 0, 1024);
-			strncpy(list, "Duration,CurRwinRcvd", 20);
-			if (txt == 1)
-				print_var(list, snap, log, agent, group, NULL);
-			else
-				plot_var(list, 2, "CurRwinRcvd", snap, log, agent, group, NULL);
-		}
-		if (plotboth == 1) {
-			memset(list, 0, 1024);
-			strncpy(list, "Duration,CurCwnd,CurRwinRcvd", 28);
-			if (txt == 1)
-				print_var(list, snap, log, agent, group, NULL);
-			else
-				plot_var(list, 3, "Both", snap, log, agent, group, NULL);
-		}
-		web100_log_close_read(log);
-	}
-
-	exit(0);
+  web100_agent* agent;
+  web100_connection* conn;
+  web100_group* group;
+  web100_log* log;
+  web100_snapshot* snap;
+  char fn[128];
+  char *varlist = NULL, list[1024];
+  char *varg;
+  int j, c, plotspd = 0, plotuser = 0;
+  int plotboth = 0, plotcwnd = 0, plotrwin = 0;
+  int plotcwndtime = 0;
+  int k, txt = 0;
+
+  while ((c = getopt_long(argc, argv, "hCScRbtm:v", long_options, 0)) != -1) {
+    switch (c) {
+      case 'b':
+        plotboth = 1;
+        break;
+      case 'h':
+        genplot_long_usage("ANL/Internet2 NDT version " VERSION " (genplot)",
+                           argv[0]);
+        break;
+      case 'v':
+        printf("ANL/Internet2 NDT version %s (genplot)\n", VERSION);
+        exit(0);
+        break;
+      case 't':
+        txt = 1;
+        break;
+      case 'C':
+        plotcwnd = 1;
+        break;
+      case 'R':
+        plotrwin = 1;
+        break;
+      case 'S':
+        plotspd = 1;
+        break;
+      case 'c':
+        plotcwndtime = 1;
+        break;
+      case 'm':
+        varlist = optarg;
+        plotuser = 1;
+        break;
+    }
+  }
+
+  if (optind == argc) {
+    short_usage(argv[0], "Missing snaplog file");
+  }
+
+  if (argc == 1) {
+    short_usage(argv[0], "ANL/Internet2 NDT version " VERSION " (genplot)");
+  }
+
+  for (j = optind; j < argc; j++) {
+    snprintf(fn, sizeof(fn), "%s", argv[j]);
+    if ((log = web100_log_open_read(fn)) == NULL) {
+      web100_perror("web100_log_open_read");
+      exit(EXIT_FAILURE);
+    }
+
+    if ((agent = web100_get_log_agent(log)) == NULL) {
+      web100_perror("web100_get_log_agent");
+      exit(EXIT_FAILURE);
+    }
+
+    if ((group = web100_get_log_group(log)) == NULL) {
+      web100_perror("web100_get_log_group");
+      exit(EXIT_FAILURE);
+    }
+
+    if ((conn = web100_get_log_connection(log)) == NULL) {
+      web100_perror("web100_get_log_connection");
+      exit(EXIT_FAILURE);
+    }
+
+    fprintf(stderr, "Extracting data from Snaplog '%s'\n\n", fn);
+
+    if ((snap = web100_snapshot_alloc_from_log(log)) == NULL) {
+      web100_perror("web100_snapshot_alloc_from_log");
+      exit(EXIT_FAILURE);
+    }
+
+    if (plotuser == 1) {
+      memset(list, 0, 1024);
+      strncpy(list, "Duration,", 9);
+      strncat(list, varlist, strlen(varlist));
+      varg = strtok(list, ",");
+      for (k = 1;; k++) {
+        if ((varg = strtok(NULL, ",")) == NULL)
+          break;
+      }
+      memset(list, 0, 1024);
+      strncpy(list, "Duration,", 9);
+      strncat(list, varlist, strlen(varlist));
+      if (txt == 1)
+        print_var(list, snap, log, agent, group, NULL);
+      else
+        plot_var(list, k, "User Defined", snap, log, agent, group,
+                 NULL);
+    }
+    if (plotspd == 1) {
+      memset(list, 0, 1024);
+      strncpy(list, "Duration,DataBytesOut", 21);
+      if (txt == 1)
+        print_var(list, snap, log, agent, group, throughput);
+      else
+        plot_var(list, 2, "Throughput", snap, log, agent, group,
+                 throughputPlot);
+    }
+    if (plotcwndtime == 1) {
+      memset(list, 0, 1024);
+      strncpy(list,
+              "Duration,SndLimTimeRwin,SndLimTimeSender,SndLimTimeCwnd",
+              55);
+      if (txt == 1)
+        print_var(list, snap, log, agent, group, cwndtime);
+      else
+        plot_cwndtime("Cwnd Time", snap, log, agent, group);
+    }
+    if (plotcwnd == 1) {
+      memset(list, 0, 1024);
+      strncpy(list, "Duration,CurCwnd", 16);
+      if (txt == 1)
+        print_var(list, snap, log, agent, group, NULL);
+      else
+        plot_var(list, 2, "CurCwnd", snap, log, agent, group, NULL);
+    }
+    if (plotrwin == 1) {
+      memset(list, 0, 1024);
+      strncpy(list, "Duration,CurRwinRcvd", 20);
+      if (txt == 1)
+        print_var(list, snap, log, agent, group, NULL);
+      else
+        plot_var(list, 2, "CurRwinRcvd", snap, log, agent, group, NULL);
+    }
+    if (plotboth == 1) {
+      memset(list, 0, 1024);
+      strncpy(list, "Duration,CurCwnd,CurRwinRcvd", 28);
+      if (txt == 1)
+        print_var(list, snap, log, agent, group, NULL);
+      else
+        plot_var(list, 3, "Both", snap, log, agent, group, NULL);
+    }
+    web100_log_close_read(log);
+  }
+
+  exit(0);
 }
diff --git a/src/heuristics.c b/src/heuristics.c
index 14fef73..7b9192d 100644
--- a/src/heuristics.c
+++ b/src/heuristics.c
@@ -8,9 +8,9 @@
 #include <string.h>
 #include <math.h>
 
-#include "utils.h"
-#include "logging.h"
-#include "heuristics.h"
+#include "./utils.h"
+#include "./logging.h"
+#include "./heuristics.h"
 
 #define log_lvl_heur 2
 /**
@@ -52,79 +52,78 @@
  * @param is_c2stest is this a C->S test?
  *
  * */
-void calc_linkspeed(char spds[4][256], int spd_index, int *c2s_linkspeed_data, int *c2s_linkspeed_ack,
-		int* s2c_linkspeed_data, int *s2c_linkspeed_ack, float runave[4], u_int32_t *dec_cnt,
-		u_int32_t *same_cnt, u_int32_t *inc_cnt, int *timeout, int *dupack,
-		int is_c2stest) {
-
-	int index = 0; // speed array indices
-	int links[16]; // link speed bin values
-	int n = 0, j = 0; // temporary iterator variables
-	int max; // max speed bin counter value
-	int total; // total of the bin counts, used to calculate percentage
-	int ifspeedlocal; // local if-speed indicator
-
-	for (n = 0; n < spd_index; n++) {
-		sscanf(spds[n],
-				"%d %d %d %d %d %d %d %d %d %d %d %d %f %u %u %u %d %d %d",
-				&links[0], &links[1], &links[2], &links[3], &links[4],
-				&links[5], &links[6], &links[7], &links[8], &links[9],
-				&links[10], &links[11], &runave[n], inc_cnt, dec_cnt,
-				same_cnt, timeout, dupack, &ifspeedlocal);
-		log_println(log_lvl_heur, " **First ele: spd=%s, runave=%f", spds[n],
-				runave[n]);
-		max = 0;
-		index = 0;
-		total = 0;
-
-		if ((ifspeedlocal == -1) || (ifspeedlocal == 0) || (ifspeedlocal > 10))
-			ifspeedlocal = 10; // ifspeed was probably not collected in these cases
-
-		// get the ifspeed bin with the biggest counter value.
-		//  NDT determines link speed using this
-		for (j = 0; j <= ifspeedlocal; j++) {
-			total += links[j];
-			if (max < links[j]) {
-				max = links[j];
-				index = j;
-			}
-		}
-
-		// speed data was not collected correctly
-		if (links[index] == -1)
-			index = -1;
-
-		// log
-		log_println(0, "spds[%d] = '%s' max=%d [%0.2f%%]\n", n, spds[n], max,
-					(float) max * 100 / total);
-
-		// Assign values based on whether C2S or S2C test
-		// Note: spd[0] , [1] contains C->S test results
-		// spd[2] , spd [3] contains S->C test results
-		switch (n + (is_c2stest ? 0 : 2)) {
-		case 0:
-			*c2s_linkspeed_data = index;
-			log_print(log_lvl_heur, "Client --> Server data detects link = ");
-			break;
-		case 1:
-			*c2s_linkspeed_ack = index;
-			log_print(log_lvl_heur, "Client <-- Server Ack's detect link = ");
-			break;
-		case 2:
-			*s2c_linkspeed_data = index;
-			log_print(log_lvl_heur, "Server --> Client data detects link = ");
-			break;
-		case 3:
-			*s2c_linkspeed_ack = index;
-			log_print(1, "Server <-- Client Ack's detect link = ");
-			break;
-		}
-
-		// classify link speed based on the max ifspeed seen
-		log_linkspeed(index);
-	} //end section to determine speed.
-
-} //end method calc_linkspeed
+void calc_linkspeed(char spds[4][256], int spd_index, int *c2s_linkspeed_data,
+                    int *c2s_linkspeed_ack, int* s2c_linkspeed_data,
+                    int *s2c_linkspeed_ack, float runave[4], u_int32_t *dec_cnt,
+                    u_int32_t *same_cnt, u_int32_t *inc_cnt, int *timeout,
+                    int *dupack, int is_c2stest) {
+  int index = 0;  // speed array indices
+  int links[16];  // link speed bin values
+  int n = 0, j = 0;  // temporary iterator variables
+  int max;  // max speed bin counter value
+  int total;  // total of the bin counts, used to calculate percentage
+  int ifspeedlocal;  // local if-speed indicator
+
+  for (n = 0; n < spd_index; n++) {
+    sscanf(spds[n],
+           "%d %d %d %d %d %d %d %d %d %d %d %d %f %u %u %u %d %d %d",
+           &links[0], &links[1], &links[2], &links[3], &links[4],
+           &links[5], &links[6], &links[7], &links[8], &links[9],
+           &links[10], &links[11], &runave[n], inc_cnt, dec_cnt,
+           same_cnt, timeout, dupack, &ifspeedlocal);
+    log_println(log_lvl_heur, " **First ele: spd=%s, runave=%f", spds[n],
+                runave[n]);
+    max = 0;
+    index = 0;
+    total = 0;
+
+    if ((ifspeedlocal == -1) || (ifspeedlocal == 0) || (ifspeedlocal > 10))
+      ifspeedlocal = 10;  // ifspeed was probably not collected in these cases
+
+    // get the ifspeed bin with the biggest counter value.
+    //  NDT determines link speed using this
+    for (j = 0; j <= ifspeedlocal; j++) {
+      total += links[j];
+      if (max < links[j]) {
+        max = links[j];
+        index = j;
+      }
+    }
+
+    // speed data was not collected correctly
+    if (links[index] == -1)
+      index = -1;
+
+    // log
+    log_println(0, "spds[%d] = '%s' max=%d [%0.2f%%]\n", n, spds[n], max,
+                (float) max * 100 / total);
+
+    // Assign values based on whether C2S or S2C test
+    // Note: spd[0] , [1] contains C->S test results
+    // spd[2] , spd [3] contains S->C test results
+    switch (n + (is_c2stest ? 0 : 2)) {
+      case 0:
+        *c2s_linkspeed_data = index;
+        log_print(log_lvl_heur, "Client --> Server data detects link = ");
+        break;
+      case 1:
+        *c2s_linkspeed_ack = index;
+        log_print(log_lvl_heur, "Client <-- Server Ack's detect link = ");
+        break;
+      case 2:
+        *s2c_linkspeed_data = index;
+        log_print(log_lvl_heur, "Server --> Client data detects link = ");
+        break;
+      case 3:
+        *s2c_linkspeed_ack = index;
+        log_print(1, "Server <-- Client Ack's detect link = ");
+        break;
+    }
+
+    // classify link speed based on the max ifspeed seen
+    log_linkspeed(index);
+  }  // end section to determine speed.
+}  // end method calc_linkspeed
 
 /**
  * Calculate average round-trip-time in milliseconds.
@@ -134,11 +133,11 @@ void calc_linkspeed(char spds[4][256], int spd_index, int *c2s_linkspeed_data, i
  * */
 
 double calc_avg_rtt(int sumRTT, int countRTT, double *avgRTT) {
-	*avgRTT = (double) sumRTT / countRTT;
-	log_println(log_lvl_heur,
-			"-- Average round trip time= SumRTT (%d) over countRTT (%d)=%f",
-			sumRTT, countRTT, (*avgRTT) * .001);
-	return ((*avgRTT) * .001);
+  *avgRTT = (double) sumRTT / countRTT;
+  log_println(log_lvl_heur,
+              "-- Average round trip time= SumRTT (%d) over countRTT (%d)=%f",
+              sumRTT, countRTT, (*avgRTT) * .001);
+  return ((*avgRTT) * .001);
 }
 
 /**
@@ -160,16 +159,16 @@ double calc_avg_rtt(int sumRTT, int countRTT, double *avgRTT) {
  * @return packet loss value
  * */
 double calc_packetloss(int congsnsignals, int pktsout, int c2sdatalinkspd) {
-	double packetloss = (double) congsnsignals / pktsout;
-	if (packetloss == 0) {
-		if (c2sdatalinkspd > 5)
-			packetloss = .0000000001; // set to 10^-10 for links faster than FastE
-		else
-			packetloss = .000001; // set to 10^-6 otherwise
-	}
-	log_println(log_lvl_heur, "--packetloss=%d over %d=%f. Link spd=%d",
-			congsnsignals, pktsout, packetloss, c2sdatalinkspd);
-	return packetloss;
+  double packetloss = (double) congsnsignals / pktsout;
+  if (packetloss == 0) {
+    if (c2sdatalinkspd > 5)
+      packetloss = .0000000001;  // set to 10^-10 for links faster than FastE
+    else
+      packetloss = .000001;  // set to 10^-6 otherwise
+  }
+  log_println(log_lvl_heur, "--packetloss=%d over %d=%f. Link spd=%d",
+              congsnsignals, pktsout, packetloss, c2sdatalinkspd);
+  return packetloss;
 }
 
 /**
@@ -181,9 +180,9 @@ double calc_packetloss(int congsnsignals, int pktsout, int c2sdatalinkspd) {
  * 	@return percentage of packets out of order
  * */
 double calc_packets_outoforder(int dupackcount, int actualackcount) {
-	log_println(log_lvl_heur, "--packets out of order: %f",
-			(double) dupackcount / actualackcount);
-	return ((double) dupackcount / actualackcount);
+  log_println(log_lvl_heur, "--packets out of order: %f",
+              (double) dupackcount / actualackcount);
+  return ((double) dupackcount / actualackcount);
 }
 
 /**
@@ -199,13 +198,13 @@ double calc_packets_outoforder(int dupackcount, int actualackcount) {
  * @return maximum theoretical bandwidth
  * */
 double calc_max_theoretical_throughput(int currentMSS, double rttsec,
-		double packetloss) {
-	double maxthruput;
-	maxthruput = (currentMSS / (rttsec * sqrt(packetloss))) * BITS_8 / KILO_BITS
-			/ KILO_BITS;
-	log_println(log_lvl_heur, "--max_theoretical_thruput: %f. From %d,%f,%f",
-			maxthruput, currentMSS, rttsec, packetloss);
-	return maxthruput;
+                                       double packetloss) {
+  double maxthruput;
+  maxthruput = (currentMSS / (rttsec * sqrt(packetloss))) * BITS_8 / KILO_BITS
+      / KILO_BITS;
+  log_println(log_lvl_heur, "--max_theoretical_thruput: %f. From %d,%f,%f",
+              maxthruput, currentMSS, rttsec, packetloss);
+  return maxthruput;
 }
 
 /**
@@ -220,19 +219,21 @@ double calc_max_theoretical_throughput(int currentMSS, double rttsec,
  *
  * */
 void calc_window_sizes(int *SndWinScale, int *RcvWinScale, int SendBuf,
-		int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin, double *cwin) {
-	if ((*SndWinScale > WINDOW_SCALE_THRESH) || (SendBuf < MAX_TCP_PORT))
-		*SndWinScale = 0;
-	if ((*RcvWinScale > WINDOW_SCALE_THRESH) || (MaxRwinRcvd < MAX_TCP_PORT))
-		*RcvWinScale = 0;
-
-	*rwin = (double) MaxRwinRcvd * BITS_8 / KILO_BITS / KILO_BITS;
-	*swin = (double) SendBuf * BITS_8 / KILO_BITS / KILO_BITS;
-	*cwin = (double) MaxCwnd * BITS_8 / KILO_BITS / KILO_BITS;
-	log_println(
-			log_lvl_heur,
-			"--window sizes: SndWinScale= %d, RcvwinScale=%d, MaxRwinRcvd=%d, maxCwnd=%d,rwin=%f, swin=%f, cwin=%f",
-			*SndWinScale, *RcvWinScale, MaxRwinRcvd, MaxCwnd ,*rwin, *swin, *cwin);
+                       int MaxRwinRcvd, int MaxCwnd, double *rwin, double *swin,
+                       double *cwin) {
+  if ((*SndWinScale > WINDOW_SCALE_THRESH) || (SendBuf < MAX_TCP_PORT))
+    *SndWinScale = 0;
+  if ((*RcvWinScale > WINDOW_SCALE_THRESH) || (MaxRwinRcvd < MAX_TCP_PORT))
+    *RcvWinScale = 0;
+
+  *rwin = (double) MaxRwinRcvd * BITS_8 / KILO_BITS / KILO_BITS;
+  *swin = (double) SendBuf * BITS_8 / KILO_BITS / KILO_BITS;
+  *cwin = (double) MaxCwnd * BITS_8 / KILO_BITS / KILO_BITS;
+  log_println(
+      log_lvl_heur,
+      "--window sizes: SndWinScale= %d, RcvwinScale=%d, MaxRwinRcvd=%d, "
+      "maxCwnd=%d,rwin=%f, swin=%f, cwin=%f",
+      *SndWinScale, *RcvWinScale, MaxRwinRcvd, MaxCwnd, *rwin, *swin, *cwin);
 }
 
 /**
@@ -245,10 +246,10 @@ void calc_window_sizes(int *SndWinScale, int *RcvWinScale, int SendBuf,
  * @return idle time fraction
  * */
 double calc_RTOIdle(int timeouts, int currentRTO, double totaltime) {
-	double idlewaitingforpackets = (timeouts * ((double) currentRTO / 1000))
-			/ totaltime;
-	log_println(log_lvl_heur, "--RTOIdle:%f", idlewaitingforpackets);
-	return idlewaitingforpackets;
+  double idlewaitingforpackets = (timeouts * ((double) currentRTO / 1000))
+      / totaltime;
+  log_println(log_lvl_heur, "--RTOIdle:%f", idlewaitingforpackets);
+  return idlewaitingforpackets;
 }
 
 /**
@@ -263,11 +264,11 @@ double calc_RTOIdle(int timeouts, int currentRTO, double totaltime) {
  * @return Total test time
  * */
 int calc_totaltesttime(int SndLimTimeRwin, int SndLimTimeCwnd,
-		int SndLimTimeSender) {
-	int totaltime = SndLimTimeRwin + SndLimTimeCwnd + SndLimTimeSender;
-	log_println(log_lvl_heur, "--Total test time: %d+%d+%d=%d ", SndLimTimeRwin,
-			SndLimTimeCwnd, SndLimTimeSender, totaltime);
-	return (totaltime);
+                       int SndLimTimeSender) {
+  int totaltime = SndLimTimeRwin + SndLimTimeCwnd + SndLimTimeSender;
+  log_println(log_lvl_heur, "--Total test time: %d+%d+%d=%d ", SndLimTimeRwin,
+              SndLimTimeCwnd, SndLimTimeSender, totaltime);
+  return (totaltime);
 }
 
 /**
@@ -278,10 +279,10 @@ int calc_totaltesttime(int SndLimTimeRwin, int SndLimTimeCwnd,
  *
  */
 double calc_sendlimited_sndrfault(int SndLimTimeSender, int totaltime) {
-	double sendlimitedtime = ((double) SndLimTimeSender) / totaltime;
-	log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
-			SndLimTimeSender, totaltime, sendlimitedtime);
-	return sendlimitedtime;
+  double sendlimitedtime = ((double) SndLimTimeSender) / totaltime;
+  log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
+              SndLimTimeSender, totaltime, sendlimitedtime);
+  return sendlimitedtime;
 }
 
 /**
@@ -293,10 +294,10 @@ double calc_sendlimited_sndrfault(int SndLimTimeSender, int totaltime) {
  *
  */
 double calc_sendlimited_rcvrfault(int SndLimTimeRwin, int totaltime) {
-	double sendlimitedtime = ((double) SndLimTimeRwin) / totaltime;
-	log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
-			SndLimTimeRwin, totaltime, sendlimitedtime);
-	return sendlimitedtime;
+  double sendlimitedtime = ((double) SndLimTimeRwin) / totaltime;
+  log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
+              SndLimTimeRwin, totaltime, sendlimitedtime);
+  return sendlimitedtime;
 }
 
 /**
@@ -306,10 +307,10 @@ double calc_sendlimited_rcvrfault(int SndLimTimeRwin, int totaltime) {
  * @return sender limited time ratio
  */
 double calc_sendlimited_cong(int SndLimTimeCwnd, int totaltime) {
-	double sendlimitedtime = ((double) SndLimTimeCwnd) / totaltime;
-	log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
-			SndLimTimeCwnd, totaltime, sendlimitedtime);
-	return sendlimitedtime;
+  double sendlimitedtime = ((double) SndLimTimeCwnd) / totaltime;
+  log_println(log_lvl_heur, "--Send limited time: %d over %d=%f ",
+              SndLimTimeCwnd, totaltime, sendlimitedtime);
+  return sendlimitedtime;
 }
 
 /**
@@ -321,9 +322,9 @@ double calc_sendlimited_cong(int SndLimTimeCwnd, int totaltime) {
  * @return Actual throughput
  */
 double calc_real_throughput(int DataBytesOut, int totaltime) {
-	double realthruput = ((double) DataBytesOut / (double) totaltime) * BITS_8;
-	log_println(log_lvl_heur, "--Actual observed throughput: %f ", realthruput);
-	return realthruput;
+  double realthruput = ((double) DataBytesOut / (double) totaltime) * BITS_8;
+  log_println(log_lvl_heur, "--Actual observed throughput: %f ", realthruput);
+  return realthruput;
 }
 
 /**
@@ -335,9 +336,9 @@ double calc_real_throughput(int DataBytesOut, int totaltime) {
  * @return Actual throughput
  */
 double cal_totalwaittime(int currentRTO, int timeoutcounters) {
-	double waitarrivetime = (double) (currentRTO * timeoutcounters) / KILO;
-	log_println(log_lvl_heur, "--Total wait time: %f ", waitarrivetime);
-	return waitarrivetime;
+  double waitarrivetime = (double) (currentRTO * timeoutcounters) / KILO;
+  log_println(log_lvl_heur, "--Total wait time: %f ", waitarrivetime);
+  return waitarrivetime;
 }
 
 /**
@@ -349,11 +350,10 @@ double cal_totalwaittime(int currentRTO, int timeoutcounters) {
  * @return 1 (true) if midboxs2cspd > s2cspd, else 0.
  */
 int is_limited_cwnd_throughput_better(int midboxs2cspd, int s2cspd) {
-	int thruputmismatch = 0;
-	if (midboxs2cspd > s2cspd)
-		thruputmismatch = 1;
-	return thruputmismatch;
-
+  int thruputmismatch = 0;
+  if (midboxs2cspd > s2cspd)
+    thruputmismatch = 1;
+  return thruputmismatch;
 }
 
 /**
@@ -366,10 +366,10 @@ int is_limited_cwnd_throughput_better(int midboxs2cspd, int s2cspd) {
  * @return 1 (true) if c2stestresult > s2ctestresult, else 0.
  */
 int is_c2s_throughputbetter(int c2stestresult, int s2ctestresult) {
-	int c2sbetter_yes = 0;
-	if (c2stestresult > s2ctestresult)
-		c2sbetter_yes = 1;
-	return c2sbetter_yes;
+  int c2sbetter_yes = 0;
+  if (c2stestresult > s2ctestresult)
+    c2sbetter_yes = 1;
+  return c2sbetter_yes;
 }
 
 /**
@@ -378,8 +378,8 @@ int is_c2s_throughputbetter(int c2stestresult, int s2ctestresult) {
  * @return 1(true) if multiple test mode is on, else 0
  */
 int isNotMultipleTestMode(int multiple) {
-	log_println(log_lvl_heur, "--multiple: %f ", multiple);
-	return (multiple == 0);
+  log_println(log_lvl_heur, "--multiple: %f ", multiple);
+  return (multiple == 0);
 }
 
 /**
@@ -405,24 +405,24 @@ int isNotMultipleTestMode(int multiple) {
  * @return int 1 if duplex mismatch is found, 0 if not.
  * */
 int detect_duplexmismatch(double cwndtime, double bwtheoretcl, int pktsretxed,
-		double timesec, int maxsstartthresh, double idleRTO, int link,
-		int s2cspd, int midboxspd, int multiple) {
-	int duplex_mismatch_yes = 0;
-	if ((cwndtime > .9) // more than 90% time spent being receiver window limited
-	&& (bwtheoretcl > 2) // theoretical max goodput > 2mbps
-	&& (pktsretxed / timesec > 2)
-	// #of segments with pkt-retransmissions> 2
-			&& (maxsstartthresh > 0) // max slow start threshold > 0
-	&& (idleRTO > .01) // cumulative RTO time > 1% test duration
-	&& (link > 2) // not wireless link
-	&& is_limited_cwnd_throughput_better(midboxspd, s2cspd) //S->C throughput calculated
-	// by server < client value
-			&& isNotMultipleTestMode(multiple)) {
-
-		duplex_mismatch_yes = 1;
-	} //end if
-	log_println(log_lvl_heur, "--duplexmismatch?: %d ", duplex_mismatch_yes);
-	return duplex_mismatch_yes;
+                          double timesec, int maxsstartthresh, double idleRTO,
+                          int link, int s2cspd, int midboxspd, int multiple) {
+  int duplex_mismatch_yes = 0;
+  if ((cwndtime > .9)  // more than 90% time spent being receiver window limited
+      && (bwtheoretcl > 2)  // theoretical max goodput > 2mbps
+      && (pktsretxed / timesec > 2)
+      // #of segments with pkt-retransmissions> 2
+      && (maxsstartthresh > 0)  // max slow start threshold > 0
+      && (idleRTO > .01)  // cumulative RTO time > 1% test duration
+      && (link > 2)  // not wireless link
+      // S->C throughput calculated
+      && is_limited_cwnd_throughput_better(midboxspd, s2cspd)
+      // by server < client value
+      && isNotMultipleTestMode(multiple)) {
+    duplex_mismatch_yes = 1;
+  }  // end if
+  log_println(log_lvl_heur, "--duplexmismatch?: %d ", duplex_mismatch_yes);
+  return duplex_mismatch_yes;
 }
 
 /** Check if internal link is duplex mismatched
@@ -433,17 +433,17 @@ int detect_duplexmismatch(double cwndtime, double bwtheoretcl, int pktsretxed,
  * return 1 if internal duplex mismatch is found, else 0
  * */
 int detect_internal_duplexmismatch(double s2cspd, double realthruput,
-		double rwintime, double packetloss) {
-	int duplex_mismatch_yes = 0;
-	if ((s2cspd > 50) // S->C goodput > 50 Mbps
-	&& (realthruput < 5) // actual send throughput < 5 Mbps
-	&& (rwintime > .9) // receive window limited for >90% of the time
-	&& (packetloss < .01)) {
-		duplex_mismatch_yes = 1;
-	}
-	log_println(log_lvl_heur, "--internal duplexmismatch?: %d ",
-			duplex_mismatch_yes);
-	return duplex_mismatch_yes;
+                                   double rwintime, double packetloss) {
+  int duplex_mismatch_yes = 0;
+  if ((s2cspd > 50)  // S->C goodput > 50 Mbps
+      && (realthruput < 5)  // actual send throughput < 5 Mbps
+      && (rwintime > .9)  // receive window limited for >90% of the time
+      && (packetloss < .01)) {
+    duplex_mismatch_yes = 1;
+  }
+  log_println(log_lvl_heur, "--internal duplexmismatch?: %d ",
+              duplex_mismatch_yes);
+  return duplex_mismatch_yes;
 }
 
 /**
@@ -468,15 +468,14 @@ int detect_internal_duplexmismatch(double s2cspd, double realthruput,
  * @return 1 is fault hardware suspected, 0 otherwise
  * */
 int detect_faultyhardwarelink(double packetloss, double cwndtime,
-		double timesec, int maxslowstartthresh) {
-	int faultyhw_found = 0;
-	if (((packetloss * 100) / timesec > 15) && (cwndtime / timesec > .6)
-			&& (packetloss < .01) && (maxslowstartthresh > 0)) {
-		faultyhw_found = 1;
-	}
-	log_println(log_lvl_heur, "--faulty hardware?: %d ", faultyhw_found);
-	return faultyhw_found;
-
+                              double timesec, int maxslowstartthresh) {
+  int faultyhw_found = 0;
+  if (((packetloss * 100) / timesec > 15) && (cwndtime / timesec > .6)
+      && (packetloss < .01) && (maxslowstartthresh > 0)) {
+    faultyhw_found = 1;
+  }
+  log_println(log_lvl_heur, "--faulty hardware?: %d ", faultyhw_found);
+  return faultyhw_found;
 }
 
 /**
@@ -499,14 +498,14 @@ int detect_faultyhardwarelink(double packetloss, double cwndtime,
  * @return 1 if ethernet link, 0 otherwise
  * */
 int detect_ethernetlink(double realthruput, double s2cspd, double packetloss,
-		double oo_order, int link) {
-	int is_ethernet = 0;
-	if ((realthruput < 9.5) && (realthruput > 3.0) && ((s2cspd / 1000) < 9.5)
-			&& (packetloss < .01) && (oo_order < .035) && (link > 0)) {
-		is_ethernet = 1;
-	}
-	log_println(log_lvl_heur, "--Is ethernet?: %d ", is_ethernet);
-	return is_ethernet;
+                        double oo_order, int link) {
+  int is_ethernet = 0;
+  if ((realthruput < 9.5) && (realthruput > 3.0) && ((s2cspd / 1000) < 9.5)
+      && (packetloss < .01) && (oo_order < .035) && (link > 0)) {
+    is_ethernet = 1;
+  }
+  log_println(log_lvl_heur, "--Is ethernet?: %d ", is_ethernet);
+  return is_ethernet;
 }
 
 /**
@@ -533,16 +532,16 @@ int detect_ethernetlink(double realthruput, double s2cspd, double packetloss,
  * @return 1 if wireless link, 0 otherwise
  * */
 int detect_wirelesslink(double sendtime, double realthruput, double bw_theortcl,
-		int sndlimtrans_rwin, int sndlimtrans_cwnd, double rwindowtime,
-		int link) {
-	int is_wireless = 0;
-	if ((sendtime == 0) && (realthruput < 5) && (bw_theortcl > 50)
-			&& ((sndlimtrans_rwin / sndlimtrans_cwnd) == 1)
-			&& (rwindowtime > .90) && (link > 0)) {
-		is_wireless = 1;
-	}
-	log_println(log_lvl_heur, "--Is wireless?: %d ", is_wireless);
-	return is_wireless;
+                        int sndlimtrans_rwin, int sndlimtrans_cwnd,
+                        double rwindowtime, int link) {
+  int is_wireless = 0;
+  if ((sendtime == 0) && (realthruput < 5) && (bw_theortcl > 50)
+      && ((sndlimtrans_rwin / sndlimtrans_cwnd) == 1)
+      && (rwindowtime > .90) && (link > 0)) {
+    is_wireless = 1;
+  }
+  log_println(log_lvl_heur, "--Is wireless?: %d ", is_wireless);
+  return is_wireless;
 }
 
 /**
@@ -565,16 +564,15 @@ int detect_wirelesslink(double sendtime, double realthruput, double bw_theortcl,
  * @return 1 if wireless link, 0 otherwise
  * */
 int detect_DSLCablelink(int sndlim_timesender, int sndlim_transsender,
-		double realthruput, double bw_theoretical, int link) {
-	int is_dslorcable = 0;
-	if ((sndlim_timesender < 600) && (sndlim_transsender == 0)
-			&& (realthruput < 2) && (realthruput < bw_theoretical)
-			&& (link > 0)) {
-		is_dslorcable = 1;
-	}
-	log_println(log_lvl_heur, "--Is DSL/Cable?: %d ", is_dslorcable);
-	return is_dslorcable;
-
+                        double realthruput, double bw_theoretical, int link) {
+  int is_dslorcable = 0;
+  if ((sndlim_timesender < 600) && (sndlim_transsender == 0)
+      && (realthruput < 2) && (realthruput < bw_theoretical)
+      && (link > 0)) {
+    is_dslorcable = 1;
+  }
+  log_println(log_lvl_heur, "--Is DSL/Cable?: %d ", is_dslorcable);
+  return is_dslorcable;
 }
 
 /**
@@ -596,14 +594,14 @@ int detect_DSLCablelink(int sndlim_timesender, int sndlim_transsender,
  * @return 1 if half_duplex link suspected, 0 otherwise
  * */
 int detect_halfduplex(double rwintime, int sndlim_transrwin,
-		int sndlim_transsender, double totaltesttime) {
-	int is_halfduplex = 0;
-	if ((rwintime > .95) && (sndlim_transrwin / totaltesttime > 30)
-			&& (sndlim_transsender / totaltesttime > 30)) {
-		is_halfduplex = 1;
-	}
-	log_println(log_lvl_heur, "--Is Half_duplex detected? %d ", is_halfduplex);
-	return is_halfduplex;
+                      int sndlim_transsender, double totaltesttime) {
+  int is_halfduplex = 0;
+  if ((rwintime > .95) && (sndlim_transrwin / totaltesttime > 30)
+      && (sndlim_transsender / totaltesttime > 30)) {
+    is_halfduplex = 1;
+  }
+  log_println(log_lvl_heur, "--Is Half_duplex detected? %d ", is_halfduplex);
+  return is_halfduplex;
 }
 
 /**
@@ -626,12 +624,12 @@ int detect_halfduplex(double rwintime, int sndlim_transrwin,
  * @return 1 if congestion detected, 0 otherwise
  * */
 int detect_congestionwindow(double cwndtime, int mismatch, double cwin,
-		double rwin, double rttsec) {
-	int is_congested = 0;
-	if ((cwndtime > .02) && (mismatch == 0)
-			&& ((cwin / rttsec) < (rwin / rttsec))) {
-		is_congested = 1;
-	}
-	log_println(log_lvl_heur, "--Is congested? %d ", is_congested);
-	return is_congested;
+                            double rwin, double rttsec) {
+  int is_congested = 0;
+  if ((cwndtime > .02) && (mismatch == 0)
+      && ((cwin / rttsec) < (rwin / rttsec))) {
+    is_congested = 1;
+  }
+  log_println(log_lvl_heur, "--Is congested? %d ", is_congested);
+  return is_congested;
 }
diff --git a/src/logging.c b/src/logging.c
index 03992b5..dd01993 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -19,11 +19,11 @@
 #include <zlib.h>
 /* #endif */
 
-#include "logging.h"
+#include "./logging.h"
 /* #include "testoptions.h" */
-#include "strlutils.h"
-#include "utils.h"
-#include "protocol.h"
+#include "./strlutils.h"
+#include "./utils.h"
+#include "./protocol.h"
 
 static int _debuglevel = 0;
 static char* _programname = "";
@@ -36,7 +36,7 @@ static I2ErrHandle _errorhandler = NULL;
 static I2LogImmediateAttr _immediateattr_nl;
 static I2LogImmediateAttr _immediateattr;
 static time_t timestamp;
-static long int utimestamp;
+static int64_t utimestamp;
 
 /**
  * Compress snaplog, tcpdump, and cputime files to save disk space.
@@ -59,74 +59,73 @@ static long int utimestamp;
  */
 
 int zlib_def(char *src_fn) {
-
-	int ret, flush, level = Z_DEFAULT_COMPRESSION;
-	char dest_fn[256];
-	FILE *dest, *source;
-	unsigned have;
-	z_stream strm;
-	unsigned char in[16384];
-	unsigned char out[16384];
-
-	// allocate deflate state
-	strm.zalloc = Z_NULL;
-	strm.zfree = Z_NULL;
-	strm.opaque = Z_NULL;
-	ret = deflateInit(&strm, level);
-	if (ret != Z_OK) {
-		log_println(6, "zlib deflateInit routine failed with %d", ret);
-		return ret;
-	}
-
-	snprintf(dest_fn, sizeof(dest_fn), "%s.gz", src_fn);
-	if ((source = fopen(src_fn, "r")) == NULL) {
-		log_println(6, "zlib_def(): failed to open src file '%s' for reading",
-				src_fn);
-		return -3;
-	}
-	if ((dest = fopen(dest_fn, "w")) == NULL) {
-		log_println(6, "zlib_def(): failed to open dest file '%s' for writing",
-				dest_fn);
-		return -4;
-	}
-	// compress until end of file
-	do {
-		strm.avail_in = fread(in, 1, 16384, source);
-		if (ferror(source)) {
-			(void) deflateEnd(&strm);
-			return Z_ERRNO;
-		}
-		flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
-		strm.next_in = in;
-
-		// run deflate() on input until output buffer not full, finish
-		//   compression if all of source has been read in
-		do {
-			strm.avail_out = 16384;
-			strm.next_out = out;
-
-			ret = deflate(&strm, flush); /* no bad return value */
-			assert(ret != Z_STREAM_ERROR); /* state not clobbered */
-			have = 16384 - strm.avail_out;
-			if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
-				(void) deflateEnd(&strm);
-				return Z_ERRNO;
-			}
-
-		} while (strm.avail_out == 0);
-		assert(strm.avail_in == 0); /* all input will be used */
-
-		/* done when last data in file processed */
-	} while (flush != Z_FINISH);
-	assert(ret == Z_STREAM_END); /* stream will be complete */
-
-	/* clean up and return */
-	(void) deflateEnd(&strm);
-
-	/* compressed version of file is now created, remove the original uncompressed version */
-	remove(src_fn);
-
-	return Z_OK;
+  int ret, flush, level = Z_DEFAULT_COMPRESSION;
+  char dest_fn[256];
+  FILE *dest, *source;
+  unsigned have;
+  z_stream strm;
+  unsigned char in[16384];
+  unsigned char out[16384];
+
+  // allocate deflate state
+  strm.zalloc = Z_NULL;
+  strm.zfree = Z_NULL;
+  strm.opaque = Z_NULL;
+  ret = deflateInit(&strm, level);
+  if (ret != Z_OK) {
+    log_println(6, "zlib deflateInit routine failed with %d", ret);
+    return ret;
+  }
+
+  snprintf(dest_fn, sizeof(dest_fn), "%s.gz", src_fn);
+  if ((source = fopen(src_fn, "r")) == NULL) {
+    log_println(6, "zlib_def(): failed to open src file '%s' for reading",
+                src_fn);
+    return -3;
+  }
+  if ((dest = fopen(dest_fn, "w")) == NULL) {
+    log_println(6, "zlib_def(): failed to open dest file '%s' for writing",
+                dest_fn);
+    return -4;
+  }
+  // compress until end of file
+  do {
+    strm.avail_in = fread(in, 1, 16384, source);
+    if (ferror(source)) {
+      (void) deflateEnd(&strm);
+      return Z_ERRNO;
+    }
+    flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
+    strm.next_in = in;
+
+    // run deflate() on input until output buffer not full, finish
+    //   compression if all of source has been read in
+    do {
+      strm.avail_out = 16384;
+      strm.next_out = out;
+
+      ret = deflate(&strm, flush); /* no bad return value */
+      assert(ret != Z_STREAM_ERROR); /* state not clobbered */
+      have = 16384 - strm.avail_out;
+      if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
+        (void) deflateEnd(&strm);
+        return Z_ERRNO;
+      }
+    } while (strm.avail_out == 0);
+    assert(strm.avail_in == 0); /* all input will be used */
+
+    /* done when last data in file processed */
+  } while (flush != Z_FINISH);
+  assert(ret == Z_STREAM_END); /* stream will be complete */
+
+  /* clean up and return */
+  (void) deflateEnd(&strm);
+
+  // compressed version of file is now created, remove the original uncompressed
+  // version
+  remove(src_fn);
+
+  return Z_OK;
 }
 /* #endif */
 
@@ -137,28 +136,28 @@ int zlib_def(char *src_fn) {
  */
 
 void log_init(char* progname, int debuglvl) {
-	assert(progname);
+  assert(progname);
 
-	_programname =
-			(_programname = strrchr(progname, '/')) ?
-					_programname + 1 : progname;
+  _programname =
+      (_programname = strrchr(progname, '/')) ?
+      _programname + 1 : progname;
 
-	_immediateattr.fp = _immediateattr_nl.fp = stderr;
-	_immediateattr.line_info = I2MSG | I2NONL;
-	_immediateattr_nl.line_info = I2MSG;
-	_immediateattr.tformat = _immediateattr_nl.tformat = NULL;
+  _immediateattr.fp = _immediateattr_nl.fp = stderr;
+  _immediateattr.line_info = I2MSG | I2NONL;
+  _immediateattr_nl.line_info = I2MSG;
+  _immediateattr.tformat = _immediateattr_nl.tformat = NULL;
 
-	_errorhandler = I2ErrOpen(progname, I2ErrLogImmediate, &_immediateattr,
-			NULL, NULL);
-	_errorhandler_nl = I2ErrOpen(progname, I2ErrLogImmediate,
-			&_immediateattr_nl, NULL, NULL);
+  _errorhandler = I2ErrOpen(progname, I2ErrLogImmediate, &_immediateattr,
+                            NULL, NULL);
+  _errorhandler_nl = I2ErrOpen(progname, I2ErrLogImmediate,
+                               &_immediateattr_nl, NULL, NULL);
 
-	if (!_errorhandler || !_errorhandler_nl) {
-		fprintf(stderr, "%s : Couldn't init error module\n", progname);
-		exit(1);
-	}
+  if (!_errorhandler || !_errorhandler_nl) {
+    fprintf(stderr, "%s : Couldn't init error module\n", progname);
+    exit(1);
+  }
 
-	_debuglevel = debuglvl;
+  _debuglevel = debuglvl;
 }
 
 /**
@@ -168,8 +167,8 @@ void log_init(char* progname, int debuglvl) {
  * Added RAC 10/13/09
  */
 void log_free(void) {
-	free(_errorhandler);
-	free(_errorhandler_nl);
+  free(_errorhandler);
+  free(_errorhandler_nl);
 }
 
 /**
@@ -178,7 +177,7 @@ void log_free(void) {
  */
 
 void set_debuglvl(int debuglvl) {
-	_debuglevel = debuglvl;
+  _debuglevel = debuglvl;
 }
 
 /**
@@ -187,7 +186,7 @@ void set_debuglvl(int debuglvl) {
  */
 
 void set_logfile(char* filename) {
-	LogFileName = filename;
+  LogFileName = filename;
 }
 
 /**
@@ -197,24 +196,22 @@ void set_logfile(char* filename) {
  *
  */
 void set_protologdir(char* dirname) {
-	char localstr[256];
-
-	// Protocol log location being set
-	if (dirname == NULL) {
-		//use default of BASEDIR/LOGDIR
-		log_println(5, "PV: 1: NULL proto location =%s;\n", ProtocolLogDirName);
-		return;
-	} else if (dirname[0] != '/') {
-		snprintf(localstr, sizeof(localstr), "%s/%s/", BASEDIR, dirname);
-		ProtocolLogDirName = localstr;
-		log_println(5, "PV: 2: non-dir proto location. So=%s;\n", dirname);
-	} //end protocol dir name
-	else {
-		snprintf(localstr, sizeof(localstr), "%s", dirname);
-		ProtocolLogDirName = dirname;
-		log_println(5, "PV33: proto location=%s;\n", ProtocolLogDirName);
-	}
-
+  char localstr[256];
+
+  // Protocol log location being set
+  if (dirname == NULL) {
+    // use default of BASEDIR/LOGDIR
+    log_println(5, "PV: 1: NULL proto location =%s;\n", ProtocolLogDirName);
+    return;
+  } else if (dirname[0] != '/') {
+    snprintf(localstr, sizeof(localstr), "%s/%s/", BASEDIR, dirname);
+    ProtocolLogDirName = localstr;
+    log_println(5, "PV: 2: non-dir proto location. So=%s;\n", dirname);
+  } else {  // end protocol dir name
+    snprintf(localstr, sizeof(localstr), "%s", dirname);
+    ProtocolLogDirName = dirname;
+    log_println(5, "PV33: proto location=%s;\n", ProtocolLogDirName);
+  }
 }
 
 /**
@@ -222,8 +219,8 @@ void set_protologdir(char* dirname) {
  * @return directory where protocol logs are placed
  */
 char* get_protologdir() {
-	log_println(5," Protocol file location=%s;\n", ProtocolLogDirName);
-	return ProtocolLogDirName;
+  log_println(5, " Protocol file location=%s;\n", ProtocolLogDirName);
+  return ProtocolLogDirName;
 }
 
 /**             
@@ -231,7 +228,7 @@ char* get_protologdir() {
  * @return is protocol logging enabled? 
  */
 char get_protocolloggingenabled() {
-        return enableprotologging;
+  return enableprotologging;
 }
 
 /** 
@@ -242,14 +239,16 @@ char get_protocolloggingenabled() {
  * @param none
  */
 void create_protolog_dir() {
-	 if ( get_protocolloggingenabled() ) {
-		set_timestamp();
-                snprintf(protocollogfilestore, sizeof(protocollogfilestore), "%s/", get_protologdir());
-                log_println(5,"Creating protocol log directory=%s", protocollogfilestore);
-                create_named_logdir(protocollogfilestore, sizeof(protocollogfilestore), "", get_protocolloggingenabled());
-                set_protologdir(protocollogfilestore);
-		log_println(9,"DataDir remains=%s", DataDirName);
-	}
+  if ( get_protocolloggingenabled() ) {
+    set_timestamp();
+    snprintf(protocollogfilestore, sizeof(protocollogfilestore), "%s/",
+             get_protologdir());
+    log_println(5, "Creating protocol log directory=%s", protocollogfilestore);
+    create_named_logdir(protocollogfilestore, sizeof(protocollogfilestore), "",
+                        get_protocolloggingenabled());
+    set_protologdir(protocollogfilestore);
+    log_println(9, "DataDir remains=%s", DataDirName);
+  }
 }
 
 /**
@@ -259,28 +258,28 @@ void create_protolog_dir() {
  * @param filename The new protocol log filename
  * */
 /*
-void set_protologfile(char* client_ip, char* protologlocalarr) {
-	FILE * fp;
-
-	if (ProtocolLogDirName == NULL) {
-		ProtocolLogDirName = BASEDIR;
-	}
-	sprintf(protologlocalarr, "%s/%s%s%s%s", ProtocolLogDirName, PROTOLOGPREFIX,
-			client_ip, PROTOLOGSUFFIX, "\0");
-	//strlcpy(ProtocolLogFileName, protologlocalarr, sizeof(ProtocolLogFileName));
-	strlcpy(protologlocalarr,ProtocolLogDirName,sizeof(protologlocalarr));
-	strlcat(protologlocalarr,"/",sizeof(protologlocalarr));
-	strlcat(protologlocalarr,PROTOLOGPREFIX,sizeof(protologlocalarr));
-	strlcat(protologlocalarr,client_ip,sizeof(protologlocalarr));
-	strlcat(protologlocalarr,PROTOLOGSUFFIX,sizeof(protologlocalarr));
-
-	strlcpy(ProtocolLogFileName, protologlocalarr, sizeof(ProtocolLogFileName));
-
-	log_println(5, "Protocol filename: %s: %s\n", ProtocolLogFileName,
-			ProtocolLogDirName);
+   void set_protologfile(char* client_ip, char* protologlocalarr) {
+   FILE * fp;
+
+   if (ProtocolLogDirName == NULL) {
+   ProtocolLogDirName = BASEDIR;
+   }
+   sprintf(protologlocalarr, "%s/%s%s%s%s", ProtocolLogDirName, PROTOLOGPREFIX,
+   client_ip, PROTOLOGSUFFIX, "\0");
+//strlcpy(ProtocolLogFileName, protologlocalarr, sizeof(ProtocolLogFileName));
+strlcpy(protologlocalarr,ProtocolLogDirName,sizeof(protologlocalarr));
+strlcat(protologlocalarr,"/",sizeof(protologlocalarr));
+strlcat(protologlocalarr,PROTOLOGPREFIX,sizeof(protologlocalarr));
+strlcat(protologlocalarr,client_ip,sizeof(protologlocalarr));
+strlcat(protologlocalarr,PROTOLOGSUFFIX,sizeof(protologlocalarr));
+
+strlcpy(ProtocolLogFileName, protologlocalarr, sizeof(ProtocolLogFileName));
+
+log_println(5, "Protocol filename: %s: %s\n", ProtocolLogFileName,
+ProtocolLogDirName);
 
 }
- */
+*/
 
 /**
  * Return the protocol validation log filename.
@@ -289,29 +288,31 @@ void set_protologfile(char* client_ip, char* protologlocalarr) {
  * @return The protocol log filename
  */
 
-char* get_protologfile(int socketNum, char *protologfilename, size_t filename_size) {
-	char localAddr[64]="", remoteAddr[64]="";
-	I2Addr tmp_addr = NULL;
-	size_t tmpstrlen = sizeof(localAddr);
-	memset(localAddr, 0, tmpstrlen);
-	memset(remoteAddr, 0, tmpstrlen);
+char* get_protologfile(int socketNum, char *protologfilename,
+                       size_t filename_size) {
+  char localAddr[64]="", remoteAddr[64]="";
+  I2Addr tmp_addr = NULL;
+  size_t tmpstrlen = sizeof(localAddr);
+  memset(localAddr, 0, tmpstrlen);
+  memset(remoteAddr, 0, tmpstrlen);
 
-	// get remote address
-	tmp_addr =
-			I2AddrBySockFD(get_errhandle(), socketNum, False);
-	I2AddrNodeName(tmp_addr, remoteAddr, &tmpstrlen); //client name
+  // get remote address
+  tmp_addr =
+      I2AddrBySockFD(get_errhandle(), socketNum, False);
+  I2AddrNodeName(tmp_addr, remoteAddr, &tmpstrlen);  // client name
 
-	// get local address
-	tmp_addr = I2AddrByLocalSockFD(get_errhandle(), socketNum, False);
+  // get local address
+  tmp_addr = I2AddrByLocalSockFD(get_errhandle(), socketNum, False);
 
-	I2AddrNodeName(tmp_addr, localAddr, &tmpstrlen);
+  I2AddrNodeName(tmp_addr, localAddr, &tmpstrlen);
 
-	// copy address into filename String
-	snprintf(protologfilename, filename_size, "%s/%s%s%s%s%s%s", ProtocolLogDirName, PROTOLOGPREFIX,
-			localAddr, "_",remoteAddr, PROTOLOGSUFFIX, "\0");
-	//log_print(0, "Log file name ---%s---", protologfilename);
+  // copy address into filename String
+  snprintf(protologfilename, filename_size, "%s/%s%s%s%s%s%s",
+           ProtocolLogDirName, PROTOLOGPREFIX, localAddr, "_", remoteAddr,
+           PROTOLOGSUFFIX, "\0");
+  // log_print(0, "Log file name ---%s---", protologfilename);
 
-	return protologfilename;
+  return protologfilename;
 }
 
 /**
@@ -320,7 +321,7 @@ char* get_protologfile(int socketNum, char *protologfilename, size_t filename_si
  */
 
 int get_debuglvl() {
-	return _debuglevel;
+  return _debuglevel;
 }
 
 /**
@@ -330,7 +331,7 @@ int get_debuglvl() {
 
 char*
 get_logfile() {
-	return LogFileName;
+  return LogFileName;
 }
 
 /**
@@ -340,7 +341,7 @@ get_logfile() {
  */
 
 I2ErrHandle get_errhandle() {
-	return _errorhandler_nl;
+  return _errorhandler_nl;
 }
 
 /**
@@ -350,17 +351,16 @@ I2ErrHandle get_errhandle() {
  *            ... - the additional arguments
  */
 
-void log_print(int lvl, const char* format, ...)
-{
-	va_list ap;
+void log_print(int lvl, const char* format, ...) {
+  va_list ap;
 
-	if (lvl > _debuglevel) {
-		return;
-	}
+  if (lvl > _debuglevel) {
+    return;
+  }
 
-	va_start(ap, format);
-	I2ErrLogVT(_errorhandler,-1,0,format,ap);
-	va_end(ap);
+  va_start(ap, format);
+  I2ErrLogVT(_errorhandler, -1, 0, format, ap);
+  va_end(ap);
 }
 
 /**
@@ -371,17 +371,16 @@ void log_print(int lvl, const char* format, ...)
  *            ... - the additional arguments
  */
 
-void log_println(int lvl, const char* format, ...)
-{
-	va_list ap;
+void log_println(int lvl, const char* format, ...) {
+  va_list ap;
 
-	if (lvl > _debuglevel) {
-		return;
-	}
+  if (lvl > _debuglevel) {
+    return;
+  }
 
-	va_start(ap, format);
-	I2ErrLogVT(_errorhandler_nl,-1,0,format,ap);
-	va_end(ap);
+  va_start(ap, format);
+  I2ErrLogVT(_errorhandler_nl, -1, 0, format, ap);
+  va_end(ap);
 }
 
 /**
@@ -395,41 +394,42 @@ void log_println(int lvl, const char* format, ...)
  * @return number or characters written to the output buffer
  * */
 
-int quote_delimiters(const char *line, int line_size, char *output_buf, int output_buf_size) {
-	static char quoted[4][2] = {
-          { '\n', 'n' },
-          { '"', '"' },
-          { '\0', '0' },
-          { '\\', '\\' },
-        };
-	char quote_char = '\\';
-
-	int i, j, k;
-
-	for (i = j = 0; i < line_size && j < output_buf_size - 1; i++) {
-		// find any matching characters among the quoted
-		int match = 0;
-		for (k = 0; k < 4; k++) {
-			if (line[i] == quoted[k][0]) {
-				output_buf[j] = quote_char;
-				output_buf[j + 1] = quoted[k][1];
-				j += 2;
-				match = 1;
-				break;
-			}
-		}
-
-		if (match == 0) {
-			output_buf[j] = line[i];
-			j++;
-		}
-	}
-
-	output_buf[j] = '\0'; // make sure it's null-terminated
-	log_println(8, "****Received=%s; len=%d; dest=%d; MSG=%s", line, line_size,
-			output_buf_size, output_buf);
-
-	return j - 1;
+int quote_delimiters(const char *line, int line_size, char *output_buf,
+                     int output_buf_size) {
+  static char quoted[4][2] = {
+    { '\n', 'n' },
+    { '"', '"' },
+    { '\0', '0' },
+    { '\\', '\\' },
+  };
+  char quote_char = '\\';
+
+  int i, j, k;
+
+  for (i = j = 0; i < line_size && j < output_buf_size - 1; i++) {
+    // find any matching characters among the quoted
+    int match = 0;
+    for (k = 0; k < 4; k++) {
+      if (line[i] == quoted[k][0]) {
+        output_buf[j] = quote_char;
+        output_buf[j + 1] = quoted[k][1];
+        j += 2;
+        match = 1;
+        break;
+      }
+    }
+
+    if (match == 0) {
+      output_buf[j] = line[i];
+      j++;
+    }
+  }
+
+  output_buf[j] = '\0';  // make sure it's null-terminated
+  log_println(8, "****Received=%s; len=%d; dest=%d; MSG=%s", line, line_size,
+              output_buf_size, output_buf);
+
+  return j - 1;
 }
 
 /**
@@ -442,31 +442,31 @@ int quote_delimiters(const char *line, int line_size, char *output_buf, int outp
  * @param socketnum Socket fd
  */
 void protolog_printgeneric(const char* key, const char* value, int socketnum) {
-	FILE * fp;
-	char isotime[64];
-
-	char logmessage[4096]; /* 4096 is just a random default buffer size for the protocol message
-	 Ideally, twice the messsage size will suffice */
-	char tmplogname[FILENAME_SIZE];
-
-	if (!enableprotologging) {
-		log_println(5, "Protocol logging is not enabled");
-		return;
-	}
-
-	// make delimiters in message payload explicit
-	quote_delimiters(value, strlen(value), logmessage, sizeof(logmessage));
-
-	fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");
-	if (fp == NULL) {
-		log_println(5,
-				"--Unable to open proto file while trying to record msg: %s \n",
-				key, value);
-	} else {
-		fprintf(fp, " event=\"%s\", name=\"%s\", time=\"%s\"\n", key, value,
-				get_currenttime(isotime, sizeof(isotime)));
-		fclose(fp);
-	}
+  FILE * fp;
+  char isotime[64];
+  // 4096 is just a random default buffer size for the protocol message.
+  // Ideally, twice the messsage size will suffice
+  char logmessage[4096];
+  char tmplogname[FILENAME_SIZE];
+
+  if (!enableprotologging) {
+    log_println(5, "Protocol logging is not enabled");
+    return;
+  }
+
+  // make delimiters in message payload explicit
+  quote_delimiters(value, strlen(value), logmessage, sizeof(logmessage));
+
+  fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");
+  if (fp == NULL) {
+    log_println(5,
+                "--Unable to open proto file while trying to record msg: %s \n",
+                key, value);
+  } else {
+    fprintf(fp, " event=\"%s\", name=\"%s\", time=\"%s\"\n", key, value,
+            get_currenttime(isotime, sizeof(isotime)));
+    fclose(fp);
+  }
 }
 
 /**
@@ -480,40 +480,40 @@ void protolog_printgeneric(const char* key, const char* value, int socketnum) {
  *
  */
 void protolog_status(int pid, enum TEST_ID testid,
-		enum TEST_STATUS_INT teststatus, int socketnum) {
-	FILE * fp;
-	//va_list ap;
-	char protomessage[256];
-	char currenttestarr[TEST_NAME_DESC_SIZE];
-	char currentstatusarr[TEST_STATUS_DESC_SIZE];
-	char isotime[64];
-	char *currenttestname = "";
-	char *teststatusdesc = "";
-	char tmplogname[FILENAME_SIZE]="";
-
-	//get descriptive strings for test name and status
-	currenttestname = get_testnamedesc(testid, currenttestarr);
-	teststatusdesc = get_teststatusdesc(teststatus, currentstatusarr);
-
-	if (!enableprotologging) {
-		log_println(5, "Protocol logging is not enabled");
-		return;
-	}
-
-	fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");
-	if (fp == NULL) {
-		log_println(
-				5,
-				"--Unable to open protocol log file while trying to record test status message: %s for the %s test \n",
-				teststatusdesc, currenttestname);
-	} else {
-		snprintf(protomessage, sizeof(protomessage),
-				" event=\"%s\", name=\"%s\", pid=\"%d\", time=\"%s\"\n",
-				teststatusdesc, currenttestname, pid,
-				get_currenttime(isotime, sizeof(isotime)));
-		fprintf(fp, "%s", protomessage);
-		fclose(fp);
-	}
+                     enum TEST_STATUS_INT teststatus, int socketnum) {
+  FILE * fp;
+  // va_list ap;
+  char protomessage[256];
+  char currenttestarr[TEST_NAME_DESC_SIZE];
+  char currentstatusarr[TEST_STATUS_DESC_SIZE];
+  char isotime[64];
+  char *currenttestname = "";
+  char *teststatusdesc = "";
+  char tmplogname[FILENAME_SIZE]="";
+
+  // get descriptive strings for test name and status
+  currenttestname = get_testnamedesc(testid, currenttestarr);
+  teststatusdesc = get_teststatusdesc(teststatus, currentstatusarr);
+
+  if (!enableprotologging) {
+    log_println(5, "Protocol logging is not enabled");
+    return;
+  }
+
+  fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");
+  if (fp == NULL) {
+    log_println(5,
+                "--Unable to open protocol log file while trying to record "
+                "test status message: %s for the %s test \n", teststatusdesc,
+                currenttestname);
+  } else {
+    snprintf(protomessage, sizeof(protomessage),
+             " event=\"%s\", name=\"%s\", pid=\"%d\", time=\"%s\"\n",
+             teststatusdesc, currenttestname, pid,
+             get_currenttime(isotime, sizeof(isotime)));
+    fprintf(fp, "%s", protomessage);
+    fclose(fp);
+  }
 }
 
 /**
@@ -527,53 +527,56 @@ void protolog_status(int pid, enum TEST_ID testid,
  * @param socketnum Socket fd
  */
 void protolog_procstatus(int pid, enum TEST_ID testidarg,
-		enum PROCESS_TYPE_INT procidarg, enum PROCESS_STATUS_INT teststatusarg, int socketnum) {
-	FILE * fp;
-	char protomessage[256];
-	char isotime[64];
-	char currentprocarr[TEST_NAME_DESC_SIZE]; // size suffices to describe process name name too
-	char currentstatusarr[PROCESS_STATUS_DESC_SIZE];
-	char currenttestarr[TEST_NAME_DESC_SIZE];
-
-	char *currentprocname = "";
-	char *procstatusdesc = "";
-	char *currenttestname = "";
-
-	char tmplogname[FILENAME_SIZE];
-
-	//get descriptive strings for test name and status
-	currenttestname = get_testnamedesc(testidarg, currenttestarr);
-	currentprocname = get_processtypedesc(procidarg, currentprocarr);
-	procstatusdesc = get_procstatusdesc(teststatusarg, currentstatusarr);
-
-	if (!enableprotologging) {
-		log_println(5, "Protocol logging is not enabled");
-		return;
-	}
-
-	fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");
-
-	if (fp == NULL) {
-		log_println(
-				5,
-				"--Unable to open protocol log file while trying to record process status message: %s for the %s test \n",
-				procstatusdesc, currentprocname);
-	} else {
-		log_println(8, " a0\n %s, %s, %s,%d", procstatusdesc,currentprocname,currenttestname,pid);
-		snprintf(protomessage, sizeof(protomessage),
-				" event=\"%s\", name=\"%s\", test=\"%s\", pid=\"%d\", time=\"%s\"\n",
-				procstatusdesc, currentprocname, currenttestname, pid,
-				get_currenttime(isotime, sizeof(isotime)));
-		fprintf(fp, "%s", protomessage);
-		fclose(fp);
-	}
+                         enum PROCESS_TYPE_INT procidarg,
+                         enum PROCESS_STATUS_INT teststatusarg, int socketnum) {
+  FILE * fp;
+  char protomessage[256];
+  char isotime[64];
+  // size suffices to describe process name name too
+  char currentprocarr[TEST_NAME_DESC_SIZE];
+  char currentstatusarr[PROCESS_STATUS_DESC_SIZE];
+  char currenttestarr[TEST_NAME_DESC_SIZE];
+
+  char *currentprocname = "";
+  char *procstatusdesc = "";
+  char *currenttestname = "";
+
+  char tmplogname[FILENAME_SIZE];
+
+  // get descriptive strings for test name and status
+  currenttestname = get_testnamedesc(testidarg, currenttestarr);
+  currentprocname = get_processtypedesc(procidarg, currentprocarr);
+  procstatusdesc = get_procstatusdesc(teststatusarg, currentstatusarr);
+
+  if (!enableprotologging) {
+    log_println(5, "Protocol logging is not enabled");
+    return;
+  }
+
+  fp = fopen(get_protologfile(socketnum, tmplogname, sizeof(tmplogname)), "a");
+
+  if (fp == NULL) {
+    log_println(5,
+                "--Unable to open protocol log file while trying to record "
+                "process status message: %s for the %s test \n", procstatusdesc,
+                currentprocname);
+  } else {
+    log_println(8, " a0\n %s, %s, %s,%d", procstatusdesc, currentprocname,
+                currenttestname, pid);
+    snprintf(protomessage, sizeof(protomessage), " event=\"%s\", name=\"%s\", "
+             "test=\"%s\", pid=\"%d\", time=\"%s\"\n", procstatusdesc,
+             currentprocname, currenttestname, pid,
+             get_currenttime(isotime, sizeof(isotime)));
+    fprintf(fp, "%s", protomessage);
+    fclose(fp);
+  }
 }
 
 /**
  * Enable protocol logging
  */
 void enableprotocollogging() {
-	enableprotologging = 1;
+  enableprotologging = 1;
 }
 
 /**
@@ -582,22 +585,24 @@ void enableprotocollogging() {
  * @param charbinary 8 digit character that contains binary information
  * @param binout_arr output array containing binary bits
  */
-void printbinary(char *charbinary, int inarray_size, char *binout_arr, int outarr_size) {
-	int j = 7, i = 0;
-
-	if ( outarr_size < 8 ) {
-		log_println(8, "Invalid array sizes while formatting protocol binary data. Quitting");
-		return;
-	}
-
-	for (j = 7 ; j >= 0 && i < BITS_8; j--) {
-		if ((*charbinary & (1 << j)))
-			binout_arr[i] = '1';
-		else
-			binout_arr[i] = '0';
-		i++;
-	}
-	binout_arr[i] = '\0';
+void printbinary(char *charbinary, int inarray_size, char *binout_arr,
+                 int outarr_size) {
+  int j = 7, i = 0;
+
+  if ( outarr_size < 8 ) {
+    log_println(8, "Invalid array sizes while formatting protocol binary data. "
+                "Quitting");
+    return;
+  }
+
+  for (j = 7 ; j >= 0 && i < BITS_8; j--) {
+    if ((*charbinary & (1 << j)))
+      binout_arr[i] = '1';
+    else
+      binout_arr[i] = '0';
+    i++;
+  }
+  binout_arr[i] = '\0';
 }
 
 
@@ -617,25 +622,27 @@ void printbinary(char *charbinary, int inarray_size, char *binout_arr, int outar
  * @param sizemsgbits Output buffer size
  * @return isbitfield
  */
-int getMessageBodyFormat(int type, int len, char* msgbodytype, char* msgpayload, char* msgbits, int sizemsgbits) {
-	int isbitfielddata = 0;
-	enum MSG_BODY_TYPE msgbodyformat = NOT_KNOWN;
-
-	if (type == MSG_LOGIN && len ==1 ) {
-		msgbodyformat = BITFIELD;
-		strlcpy(msgbodytype, (char *)getmessageformattype(msgbodyformat,msgbodytype), MSG_BODY_FMT_SIZE );
-		printbinary (msgpayload, len, msgbits, sizemsgbits);
-		isbitfielddata = 1;
-	}
-	else {
-		msgbodyformat = STRING;
-		strlcpy(msgbodytype , (char *)getmessageformattype(msgbodyformat,msgbodytype), MSG_BODY_FMT_SIZE);
-		// make delimiters in message payload explicit
-		quote_delimiters(msgpayload, len, msgbits, sizemsgbits);
-
-	}
-	return isbitfielddata;
-
+int getMessageBodyFormat(int type, int len, char* msgbodytype,
+                         char* msgpayload, char* msgbits, int sizemsgbits) {
+  int isbitfielddata = 0;
+  enum MSG_BODY_TYPE msgbodyformat = NOT_KNOWN;
+
+  if (type == MSG_LOGIN && len ==1) {
+    msgbodyformat = BITFIELD;
+    strlcpy(msgbodytype,
+            (char *)getmessageformattype(msgbodyformat, msgbodytype),
+            MSG_BODY_FMT_SIZE);
+    printbinary(msgpayload, len, msgbits, sizemsgbits);
+    isbitfielddata = 1;
+  } else {
+    msgbodyformat = STRING;
+    strlcpy(msgbodytype,
+            (char *)getmessageformattype(msgbodyformat, msgbodytype),
+            MSG_BODY_FMT_SIZE);
+    // make delimiters in message payload explicit
+    quote_delimiters(msgpayload, len, msgbits, sizemsgbits);
+  }
+  return isbitfielddata;
 }
 
 /** Log all send/receive protocol messages.
@@ -650,36 +657,39 @@ int getMessageBodyFormat(int type, int len, char* msgbodytype, char* msgpayload,
  * @param ctlSocket socket over which message has been exchanged
  * */
 void protolog_println(char *msgdirection, const int type, void* msg,
-		const int len, const int processid, const int ctlSocket) {
-	FILE * fp;
-
-	char msgtypedescarr[MSG_TYPE_DESC_SIZE];
-	char *currenttestname, *currentmsgtype;
-	char isotime[64];
-	char logmessage[4096]; // message after replacing delimiter characters
-	char protologfile[FILENAME_SIZE];
-	char msgbodytype[MSG_BODY_FMT_SIZE];
-
-	// get descriptive strings for test name and direction
-	currenttestname = get_currenttestdesc();
-	currentmsgtype = get_msgtypedesc(type, msgtypedescarr);
-
-	getMessageBodyFormat(type, len, msgbodytype, (char *) msg, logmessage, sizeof(logmessage));
-
-	fp = fopen(get_protologfile(ctlSocket, protologfile, sizeof(protologfile)), "a");
-	if (fp == NULL) {
-		log_println(
-				5,
-				"Unable to open protocol log file '%s', continuing on without logging",
-				protologfile);
-	} else {
-		fprintf(
-				fp,
-				" event=\"message\", direction=\"%s\", test=\"%s\", type=\"%s\", len=\"%d\", msg_body_format=\"%s\", msg=\"%s\", pid=\"%d\", socket=\"%d\", time=\"%s\"\n",
-				msgdirection, currenttestname, currentmsgtype, len, msgbodytype, logmessage,
-				processid, ctlSocket, get_currenttime(isotime, sizeof(isotime)));
-		fclose(fp);
-	}
+                      const int len, const int processid, const int ctlSocket) {
+  FILE * fp;
+
+  char msgtypedescarr[MSG_TYPE_DESC_SIZE];
+  char *currenttestname, *currentmsgtype;
+  char isotime[64];
+  char logmessage[4096];  // message after replacing delimiter characters
+  char protologfile[FILENAME_SIZE];
+  char msgbodytype[MSG_BODY_FMT_SIZE];
+
+  // get descriptive strings for test name and direction
+  currenttestname = get_currenttestdesc();
+  currentmsgtype = get_msgtypedesc(type, msgtypedescarr);
+
+  getMessageBodyFormat(type, len, msgbodytype, (char *) msg, logmessage,
+                       sizeof(logmessage));
+
+  fp = fopen(get_protologfile(ctlSocket, protologfile, sizeof(protologfile)),
+             "a");
+  if (fp == NULL) {
+    log_println(
+        5,
+        "Unable to open protocol log file '%s', continuing on without logging",
+        protologfile);
+  } else {
+    fprintf(fp,
+            " event=\"message\", direction=\"%s\", test=\"%s\", type=\"%s\", "
+            "len=\"%d\", msg_body_format=\"%s\", msg=\"%s\", pid=\"%d\", "
+            "socket=\"%d\", time=\"%s\"\n", msgdirection, currenttestname,
+            currentmsgtype, len, msgbodytype, logmessage, processid, ctlSocket,
+            get_currenttime(isotime, sizeof(isotime)));
+    fclose(fp);
+  }
 }
 
 /** Log "sent" protocol messages.
@@ -692,16 +702,16 @@ void protolog_println(char *msgdirection, const int type, void* msg,
  * @param ctlSocket socket over which message has been exchanged
  * */
 void protolog_sendprintln(const int type, void* msg, const int len,
-		const int processid, const int ctlSocket) {
-	char *currentDir;
+                          const int processid, const int ctlSocket) {
+  char *currentDir;
 
-	if (!enableprotologging) {
-		log_println(5, "Protocol logging is not enabled");
-		return;
-	}
-	currentDir = get_currentdirndesc();
+  if (!enableprotologging) {
+    log_println(5, "Protocol logging is not enabled");
+    return;
+  }
+  currentDir = get_currentdirndesc();
 
-	protolog_println(currentDir, type, msg, len, processid, ctlSocket);
+  protolog_println(currentDir, type, msg, len, processid, ctlSocket);
 }
 
 /**
@@ -715,31 +725,30 @@ void protolog_sendprintln(const int type, void* msg, const int len,
  * @param ctlSocket socket over which message has been exchanged
  * */
 void protolog_rcvprintln(const int type, void* msg, const int len,
-		const int processid, const int ctlSocket) {
-	char *otherDir;
-	if (!enableprotologging) {
-		log_println(5, "Protocol logging is not enabled");
-		return;
-	}
-	otherDir = get_otherdirndesc();
-	protolog_println(otherDir, type, msg, len, processid, ctlSocket);
+                         const int processid, const int ctlSocket) {
+  char *otherDir;
+  if (!enableprotologging) {
+    log_println(5, "Protocol logging is not enabled");
+    return;
+  }
+  otherDir = get_otherdirndesc();
+  protolog_println(otherDir, type, msg, len, processid, ctlSocket);
 }
 
 /**
  * Set the timestamp to actual time.
  */
 void set_timestamp() {
-	struct timeval tv;
-
-	gettimeofday(&tv, NULL);
-	timestamp = tv.tv_sec;
-	utimestamp = tv.tv_usec;
+  struct timeval tv;
 
-	/*  Changed function to use gettimeofday() need usec value for ISO8601 file names
-	 *  RAC 5/6/09
-	 *  timestamp = time(NULL);
-	 */
+  gettimeofday(&tv, NULL);
+  timestamp = tv.tv_sec;
+  utimestamp = tv.tv_usec;
 
+  /*  Changed function to use gettimeofday() need usec value for ISO8601 file names
+   *  RAC 5/6/09
+   *  timestamp = time(NULL);
+   */
 }
 
 /**
@@ -747,15 +756,15 @@ void set_timestamp() {
  * @return  timestamp
  */
 time_t get_timestamp() {
-	return timestamp;
+  return timestamp;
 }
 
 /**
  * Return the previously recorded utimestamp.
  * @return The utimestamp
  */
-long int get_utimestamp() {
-	return utimestamp;
+int64_t get_utimestamp() {
+  return utimestamp;
 }
 
 /**
@@ -765,15 +774,14 @@ long int get_utimestamp() {
  */
 
 void get_YYYY(char *year, size_t year_strlen) {
+  struct tm *result;
+  time_t now;
 
-	struct tm *result;
-	time_t now;
+  setenv("TZ", "UTC", 0);
+  now = get_timestamp();
+  result = gmtime(&now);
 
-	setenv("TZ", "UTC", 0);
-	now = get_timestamp();
-	result = gmtime(&now);
-
-	snprintf(year, year_strlen, "%d", 1900 + result->tm_year);
+  snprintf(year, year_strlen, "%d", 1900 + result->tm_year);
 }
 
 /**
@@ -783,19 +791,18 @@ void get_YYYY(char *year, size_t year_strlen) {
  */
 
 void get_MM(char *month, size_t month_strlen) {
-
-	struct tm *result;
-	time_t now;
-
-	/* setenv("TZ", NULL, 0); */
-	setenv("TZ", "UTC", 0);
-	now = get_timestamp();
-	result = gmtime(&now);
-
-	if (1 + result->tm_mon < 10)
-		snprintf(month, month_strlen, "0%d", 1 + result->tm_mon);
-	else
-		snprintf(month, month_strlen, "%d", 1 + result->tm_mon);
+  struct tm *result;
+  time_t now;
+
+  /* setenv("TZ", NULL, 0); */
+  setenv("TZ", "UTC", 0);
+  now = get_timestamp();
+  result = gmtime(&now);
+
+  if (1 + result->tm_mon < 10)
+    snprintf(month, month_strlen, "0%d", 1 + result->tm_mon);
+  else
+    snprintf(month, month_strlen, "%d", 1 + result->tm_mon);
 }
 
 /**
@@ -805,17 +812,16 @@ void get_MM(char *month, size_t month_strlen) {
  */
 
 void get_DD(char *day, size_t day_strlen) {
-
-	struct tm *result;
-	time_t now;
-	setenv("TZ", "UTC", 0);
-	now = get_timestamp();
-	result = gmtime(&now);
-
-	if (result->tm_mday < 10)
-		snprintf(day, day_strlen, "0%d", result->tm_mday);
-	else
-		snprintf(day, day_strlen, "%d", result->tm_mday);
+  struct tm *result;
+  time_t now;
+  setenv("TZ", "UTC", 0);
+  now = get_timestamp();
+  result = gmtime(&now);
+
+  if (result->tm_mday < 10)
+    snprintf(day, day_strlen, "0%d", result->tm_mday);
+  else
+    snprintf(day, day_strlen, "%d", result->tm_mday);
 }
 
 
@@ -828,48 +834,48 @@ void get_DD(char *day, size_t day_strlen) {
  */
 
 char *fill_ISOtime(struct tm *result, char *isoTime, int isotimearrsize) {
-	char tmpstr[16];
+  char tmpstr[16];
 
-	snprintf(isoTime, isotimearrsize, "%d", 1900 + result->tm_year);
-	if (1 + result->tm_mon < 10)
-		snprintf(tmpstr, sizeof(tmpstr), "0%d", 1 + result->tm_mon);
-	else
-		snprintf(tmpstr, sizeof(tmpstr), "%d", 1 + result->tm_mon);
+  snprintf(isoTime, isotimearrsize, "%d", 1900 + result->tm_year);
+  if (1 + result->tm_mon < 10)
+    snprintf(tmpstr, sizeof(tmpstr), "0%d", 1 + result->tm_mon);
+  else
+    snprintf(tmpstr, sizeof(tmpstr), "%d", 1 + result->tm_mon);
 
-	strlcat(isoTime, tmpstr, isotimearrsize);
+  strlcat(isoTime, tmpstr, isotimearrsize);
 
-	if (result->tm_mday < 10)
-		snprintf(tmpstr, sizeof(tmpstr), "0%d", result->tm_mday);
-	else
-		snprintf(tmpstr, sizeof(tmpstr), "%d", result->tm_mday);
+  if (result->tm_mday < 10)
+    snprintf(tmpstr, sizeof(tmpstr), "0%d", result->tm_mday);
+  else
+    snprintf(tmpstr, sizeof(tmpstr), "%d", result->tm_mday);
 
-	strlcat(isoTime, tmpstr, isotimearrsize);
+  strlcat(isoTime, tmpstr, isotimearrsize);
 
-	if (result->tm_hour < 10)
-		snprintf(tmpstr, sizeof(tmpstr), "T0%d", result->tm_hour);
-	else
-		snprintf(tmpstr, sizeof(tmpstr), "T%d", result->tm_hour);
+  if (result->tm_hour < 10)
+    snprintf(tmpstr, sizeof(tmpstr), "T0%d", result->tm_hour);
+  else
+    snprintf(tmpstr, sizeof(tmpstr), "T%d", result->tm_hour);
 
-	strlcat(isoTime, tmpstr, isotimearrsize);
+  strlcat(isoTime, tmpstr, isotimearrsize);
 
-	if (result->tm_min < 10)
-		snprintf(tmpstr, sizeof(tmpstr), ":0%d", result->tm_min);
-	else
-		snprintf(tmpstr, sizeof(tmpstr), ":%d", result->tm_min);
+  if (result->tm_min < 10)
+    snprintf(tmpstr, sizeof(tmpstr), ":0%d", result->tm_min);
+  else
+    snprintf(tmpstr, sizeof(tmpstr), ":%d", result->tm_min);
 
-	strlcat(isoTime, tmpstr, isotimearrsize);
+  strlcat(isoTime, tmpstr, isotimearrsize);
 
-	if (result->tm_sec < 10)
-		snprintf(tmpstr, sizeof(tmpstr), ":0%d", result->tm_sec);
-	else
-		snprintf(tmpstr, sizeof(tmpstr), ":%d", result->tm_sec);
+  if (result->tm_sec < 10)
+    snprintf(tmpstr, sizeof(tmpstr), ":0%d", result->tm_sec);
+  else
+    snprintf(tmpstr, sizeof(tmpstr), ":%d", result->tm_sec);
 
-	strlcat(isoTime, tmpstr, isotimearrsize);
+  strlcat(isoTime, tmpstr, isotimearrsize);
 
-	snprintf(tmpstr, sizeof(tmpstr), ".%ldZ", get_utimestamp() * 1000);
+  snprintf(tmpstr, sizeof(tmpstr), ".%ldZ", get_utimestamp() * 1000);
 
-	strlcat(isoTime, tmpstr, isotimearrsize);
-	return isoTime;
+  strlcat(isoTime, tmpstr, isotimearrsize);
+  return isoTime;
 }
 
 /**
@@ -879,15 +885,15 @@ char *fill_ISOtime(struct tm *result, char *isoTime, int isotimearrsize) {
  * @return current time string
  */
 char *get_currenttime(char *isoTime, int isotimearrsize) {
-	time_t rawtime;
-	struct tm *result;
-	time_t rc;
-	rc = time(&rawtime);
-	if(rc!=-1) {
-		result = gmtime(&rawtime);
-		return (fill_ISOtime(result, isoTime, isotimearrsize));
-	}
-	return NULL;
+  time_t rawtime;
+  struct tm *result;
+  time_t rc;
+  rc = time(&rawtime);
+  if (rc != -1) {
+    result = gmtime(&rawtime);
+    return (fill_ISOtime(result, isoTime, isotimearrsize));
+  }
+  return NULL;
 }
 
 
@@ -898,17 +904,15 @@ char *get_currenttime(char *isoTime, int isotimearrsize) {
  * @param Pointer to the string indicating ISO time
  * @param character string with ISO time string.
  */
-char *
-get_ISOtime(char *isoTime, int isotimearrsize) {
+char * get_ISOtime(char *isoTime, int isotimearrsize) {
+  struct tm *result;
+  time_t now;
 
-	struct tm *result;
-	time_t now;
+  setenv("TZ", "UTC", 0);
+  now = get_timestamp();
+  result = gmtime(&now);
 
-	setenv("TZ", "UTC", 0);
-	now = get_timestamp();
-	result = gmtime(&now);
-
-	return (fill_ISOtime(result, isoTime, isotimearrsize));
+  return (fill_ISOtime(result, isoTime, isotimearrsize));
 }
 /**
  * Write meta data out to log file.  This file contains details and
@@ -923,157 +927,160 @@ get_ISOtime(char *isoTime, int isotimearrsize) {
  */
 
 void writeMeta(int compress, int cputime, int snaplog, int tcpdump) {
-	FILE * fp;
-	char tmpstr[256];
-	//char dir[128];
-	char dirpathstr[256]="";
-	char *tempptr;
-	int ptrdiff=0;
-
-	//char isoTime[64];
-	char filename[256];
-	size_t tmpstrlen = sizeof(tmpstr);
-	socklen_t len;
-	//DIR *dp;
-	char metafilesuffix[256] = "meta";
-
-	/* Get the clients domain name and same in metadata file
-	 * changed to use getnameinfo 7/24/09
-	 * RAC 7/7/09
-	 */
-
-	// get socketaddr size based on whether IPv6/IPV4 address was used
+  FILE * fp;
+  char tmpstr[256];
+  // char dir[128];
+  char dirpathstr[256]="";
+  char *tempptr;
+  int ptrdiff = 0;
+
+  // char isoTime[64];
+  char filename[256];
+  size_t tmpstrlen = sizeof(tmpstr);
+  socklen_t len;
+  // DIR *dp;
+  char metafilesuffix[256] = "meta";
+
+  /* Get the clients domain name and same in metadata file
+   * changed to use getnameinfo 7/24/09
+   * RAC 7/7/09
+   */
+
+  // get socketaddr size based on whether IPv6/IPV4 address was used
 #ifdef AF_INET6
-	if (meta.family == AF_INET6)
-		len = sizeof(struct sockaddr_in6);
+  if (meta.family == AF_INET6)
+    len = sizeof(struct sockaddr_in6);
 #endif
-	if (meta.family == AF_INET)
-		len = sizeof(struct sockaddr_in);
-
-	// Look up the host name and service name information for given struct sockaddress and length
-	if (getnameinfo((struct sockaddr *) &meta.c_addr, len, tmpstr, tmpstrlen,
-			NULL, 0, NI_NAMEREQD)) {
-		// No fully qualified domain name
-		memcpy(meta.client_name, "No FQDN name", 12);
-	} else {
-		// copy client's hostname into meta structure
-		log_println(2, "extracting hostname %s", tmpstr);
-		memcpy(meta.client_name, tmpstr, strlen(tmpstr));
-	}
-
-	// reset tmpstr
-	memset(tmpstr, 0, tmpstrlen);
-
-	// Create metadata file
-	create_client_logdir((struct sockaddr *) &meta.c_addr, len, tmpstr,
-			sizeof(tmpstr), metafilesuffix, sizeof(metafilesuffix));
-
-	log_println(6, "Should compress snaplog and tcpdump files compress=%d",
-			compress);
-	/* #ifdef HAVE_ZLIB_H */
-
-	// If compression is enabled, compress files in the "log" directory
-	if (compress == 1) {
-		// Get directory/path
-		tempptr = strstr(tmpstr, metafilesuffix);
-		if (tempptr != NULL) {
-			ptrdiff = tempptr - tmpstr;
-			strlcpy(dirpathstr, tmpstr, ptrdiff);
-		} //obtained directory in "dirpathstr"
-		log_println(5,
-				"Compression is enabled, compress all files in '%s' basedir",
-				dirpathstr);
-		if (snaplog) { // if snaplog is enabled, compress those into .gz formats
-
-			// Try compressing C->S test snaplogs
-			memset(filename, 0, sizeof(filename));
-			snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.c2s_snaplog);
-			if (zlib_def(filename) != 0)
-				log_println(0, "compression failed for file:%s: %s.", filename,
-						dirpathstr);
-			else
-				strlcat(meta.c2s_snaplog, ".gz", sizeof(meta.c2s_snaplog));
-
-			// Try compressing S->C test snaplogs
-			memset(filename, 0, sizeof(filename));
-			snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.s2c_snaplog);
-			if (zlib_def(filename) != 0)
-				log_println(0, "compression failed for file :%s", filename);
-			else
-				strlcat(meta.s2c_snaplog, ".gz", sizeof(meta.s2c_snaplog));
-		}
-
-		// If tcpdump file writing is enabled, compress those
-		if (tcpdump) {
-
-			// Try compressing C->S test tcpdump.
-			// The tcpdump file extension is as specified in the "meta" data-structure
-			memset(filename, 0, sizeof(filename));
-			snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.c2s_ndttrace);
-			if (zlib_def(filename) != 0)
-				log_println(0, "compression failed for tcpdump file %s =%s",
-						filename, meta.c2s_ndttrace);
-			else
-				strlcat(meta.c2s_ndttrace, ".gz", sizeof(meta.c2s_ndttrace));
-
-			// Try compressing S->C test tcpdumps
-			memset(filename, 0, sizeof(filename));
-			snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.s2c_ndttrace);
-			if (zlib_def(filename) != 0)
-				log_println(0, "compression failed for tcpdump file %s =%s",
-						filename, meta.s2c_ndttrace);
-			else
-				strlcat(meta.s2c_ndttrace, ".gz", sizeof(meta.s2c_ndttrace));
-		}
-
-		// If writing "cputime" file is enabled, compress those log files too
-		if (cputime) {
-			memset(filename, 0, sizeof(filename));
-			snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.CPU_time);
-			if (zlib_def(filename) != 0)
-				log_println(0, "compression failed");
-			else
-				strlcat(meta.CPU_time, ".gz", sizeof(meta.CPU_time));
-		} else
-			log_println(
-					5,
-					"Zlib compression disabled, log files will not be compressed in %s", tmpstr);
-	}
-	/* #endif */
-
-	// Try logging metadata into the metadata logfile
-	fp = fopen(tmpstr, "w");
-	if (fp == NULL) { // error, unable to open file in write mode
-		log_println(
-				1,
-				"Unable to open metadata log file, continuing on without logging");
-	} else {
-		log_println(5, "Opened '%s' metadata log file", tmpstr);
-		fprintf(fp, "Date/Time: %s\n", meta.date);
-		fprintf(fp, "c2s_snaplog file: %s\n", meta.c2s_snaplog);
-		fprintf(fp, "c2s_ndttrace file: %s\n", meta.c2s_ndttrace);
-		fprintf(fp, "s2c_snaplog file: %s\n", meta.s2c_snaplog);
-		fprintf(fp, "s2c_ndttrace file: %s\n", meta.s2c_ndttrace);
-		fprintf(fp, "cputime file: %s\n", meta.CPU_time);
-		fprintf(fp, "server IP address: %s\n", meta.server_ip);
-		fprintf(fp, "server hostname: %s\n", meta.server_name);
-		fprintf(fp, "server kernel version: %s\n", meta.server_os);
-		fprintf(fp, "client IP address: %s\n", meta.client_ip);
-		fprintf(fp, "client hostname: %s\n", meta.client_name);
-		fprintf(fp, "client OS name: %s\n", meta.client_os);
-		fprintf(fp, "client_browser name: %s\n", meta.client_browser);
-                fprintf(fp, "client_application name: %s\n", meta.client_application);
-		fprintf(fp, "Summary data: %s\n", meta.summary);
-		if (meta.additional) {
-			fprintf(fp, " * Additional data:\n");
-			struct metaentry* entry = meta.additional;
-			while (entry) {
-				fprintf(fp, "%s: %s\n", entry->key, entry->value);
-				entry = entry->next;
-			}
-		}
-		fclose(fp);
-	}
+  if (meta.family == AF_INET)
+    len = sizeof(struct sockaddr_in);
+
+  // Look up the host name and service name information for given struct
+  // sockaddress and length
+  if (getnameinfo((struct sockaddr *) &meta.c_addr, len, tmpstr, tmpstrlen,
+                  NULL, 0, NI_NAMEREQD)) {
+    // No fully qualified domain name
+    memcpy(meta.client_name, "No FQDN name", 12);
+  } else {
+    // copy client's hostname into meta structure
+    log_println(2, "extracting hostname %s", tmpstr);
+    memcpy(meta.client_name, tmpstr, strlen(tmpstr));
+  }
+
+  // reset tmpstr
+  memset(tmpstr, 0, tmpstrlen);
+
+  // Create metadata file
+  create_client_logdir((struct sockaddr *) &meta.c_addr, len, tmpstr,
+                       sizeof(tmpstr), metafilesuffix, sizeof(metafilesuffix));
+
+  log_println(6, "Should compress snaplog and tcpdump files compress=%d",
+              compress);
+  /* #ifdef HAVE_ZLIB_H */
+
+  // If compression is enabled, compress files in the "log" directory
+  if (compress == 1) {
+    // Get directory/path
+    tempptr = strstr(tmpstr, metafilesuffix);
+    if (tempptr != NULL) {
+      ptrdiff = tempptr - tmpstr;
+      strlcpy(dirpathstr, tmpstr, ptrdiff);
+    }  // obtained directory in "dirpathstr"
+    log_println(5,
+                "Compression is enabled, compress all files in '%s' basedir",
+                dirpathstr);
+    if (snaplog) {  // if snaplog is enabled, compress those into .gz formats
+      // Try compressing C->S test snaplogs
+      memset(filename, 0, sizeof(filename));
+      snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+               meta.c2s_snaplog);
+      if (zlib_def(filename) != 0)
+        log_println(0, "compression failed for file:%s: %s.", filename,
+                    dirpathstr);
+      else
+        strlcat(meta.c2s_snaplog, ".gz", sizeof(meta.c2s_snaplog));
+
+      // Try compressing S->C test snaplogs
+      memset(filename, 0, sizeof(filename));
+      snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+               meta.s2c_snaplog);
+      if (zlib_def(filename) != 0)
+        log_println(0, "compression failed for file :%s", filename);
+      else
+        strlcat(meta.s2c_snaplog, ".gz", sizeof(meta.s2c_snaplog));
+    }
+
+    // If tcpdump file writing is enabled, compress those
+    if (tcpdump) {
+      // Try compressing C->S test tcpdump.
+      // The tcpdump file extension is as specified in the "meta" data-structure
+      memset(filename, 0, sizeof(filename));
+      snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+               meta.c2s_ndttrace);
+      if (zlib_def(filename) != 0)
+        log_println(0, "compression failed for tcpdump file %s =%s",
+                    filename, meta.c2s_ndttrace);
+      else
+        strlcat(meta.c2s_ndttrace, ".gz", sizeof(meta.c2s_ndttrace));
+
+      // Try compressing S->C test tcpdumps
+      memset(filename, 0, sizeof(filename));
+      snprintf(filename, sizeof(filename), "%s/%s", dirpathstr,
+               meta.s2c_ndttrace);
+      if (zlib_def(filename) != 0)
+        log_println(0, "compression failed for tcpdump file %s =%s",
+                    filename, meta.s2c_ndttrace);
+      else
+        strlcat(meta.s2c_ndttrace, ".gz", sizeof(meta.s2c_ndttrace));
+    }
+
+    // If writing "cputime" file is enabled, compress those log files too
+    if (cputime) {
+      memset(filename, 0, sizeof(filename));
+      snprintf(filename, sizeof(filename), "%s/%s", dirpathstr, meta.CPU_time);
+      if (zlib_def(filename) != 0)
+        log_println(0, "compression failed");
+      else
+        strlcat(meta.CPU_time, ".gz", sizeof(meta.CPU_time));
+    } else {
+      log_println(5, "Zlib compression disabled, log files will not be "
+                  "compressed in %s", tmpstr);
+    }
+  }
+  /* #endif */
+
+  // Try logging metadata into the metadata logfile
+  fp = fopen(tmpstr, "w");
+  if (fp == NULL) {  // error, unable to open file in write mode
+    log_println(
+        1,
+        "Unable to open metadata log file, continuing on without logging");
+  } else {
+    log_println(5, "Opened '%s' metadata log file", tmpstr);
+    fprintf(fp, "Date/Time: %s\n", meta.date);
+    fprintf(fp, "c2s_snaplog file: %s\n", meta.c2s_snaplog);
+    fprintf(fp, "c2s_ndttrace file: %s\n", meta.c2s_ndttrace);
+    fprintf(fp, "s2c_snaplog file: %s\n", meta.s2c_snaplog);
+    fprintf(fp, "s2c_ndttrace file: %s\n", meta.s2c_ndttrace);
+    fprintf(fp, "cputime file: %s\n", meta.CPU_time);
+    fprintf(fp, "server IP address: %s\n", meta.server_ip);
+    fprintf(fp, "server hostname: %s\n", meta.server_name);
+    fprintf(fp, "server kernel version: %s\n", meta.server_os);
+    fprintf(fp, "client IP address: %s\n", meta.client_ip);
+    fprintf(fp, "client hostname: %s\n", meta.client_name);
+    fprintf(fp, "client OS name: %s\n", meta.client_os);
+    fprintf(fp, "client_browser name: %s\n", meta.client_browser);
+    fprintf(fp, "client_application name: %s\n", meta.client_application);
+    fprintf(fp, "Summary data: %s\n", meta.summary);
+    if (meta.additional) {
+      fprintf(fp, " * Additional data:\n");
+      struct metaentry* entry = meta.additional;
+      while (entry) {
+        fprintf(fp, "%s: %s\n", entry->key, entry->value);
+        entry = entry->next;
+      }
+    }
+    fclose(fp);
+  }
 }
 
 /** Create directories for snap/tcp trace log files, and meta files.
@@ -1092,47 +1099,46 @@ void writeMeta(int compress, int cputime, int snaplog, int tcpdump) {
  *
  */
 void create_named_logdir(char *dirnamedestarg, int destnamearrsize,
-		char *finalsuffix, char isProtoLog) {
-
-	//char namebuf[256];
-	//size_t namebuflen = 255;
-	char dir[128];
-	DIR *dp;
-	if ( !isProtoLog ) {
-		strlcpy(dirnamedestarg, DataDirName, destnamearrsize);
-		strlcat(dirnamedestarg, "/", destnamearrsize);
-		log_println(5, "DirNAME=%s", DataDirName);
-	}
-	if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
-		mkdir(dirnamedestarg, 0755);
-	closedir(dp);
-	get_YYYY(dir, sizeof(dir));
-
-	strlcat(dirnamedestarg, dir, destnamearrsize);
-	if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
-		mkdir(dirnamedestarg, 0755);
-	closedir(dp);
-
-	strlcat(dirnamedestarg, "/", destnamearrsize);
-	get_MM(dir, sizeof(dir));
-
-	strlcat(dirnamedestarg, dir, destnamearrsize);
-	if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
-		mkdir(dirnamedestarg, 0755);
-	closedir(dp);
-
-	strlcat(dirnamedestarg, "/", destnamearrsize);
-	get_DD(dir, sizeof(dir));
-
-	strlcat(dirnamedestarg, dir, destnamearrsize);
-	if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
-		mkdir(dirnamedestarg, 0755);
-	closedir(dp);
-
-	strlcat(dirnamedestarg, "/", destnamearrsize);
-	snprintf(dir, sizeof(dir), "%s", finalsuffix);
-	strlcat(dirnamedestarg, dir, destnamearrsize);
-	log_println(5, "end named_log_create %s", dirnamedestarg);
+                         char *finalsuffix, char isProtoLog) {
+  // char namebuf[256];
+  // size_t namebuflen = 255;
+  char dir[128];
+  DIR *dp;
+  if ( !isProtoLog ) {
+    strlcpy(dirnamedestarg, DataDirName, destnamearrsize);
+    strlcat(dirnamedestarg, "/", destnamearrsize);
+    log_println(5, "DirNAME=%s", DataDirName);
+  }
+  if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
+    mkdir(dirnamedestarg, 0755);
+  closedir(dp);
+  get_YYYY(dir, sizeof(dir));
+
+  strlcat(dirnamedestarg, dir, destnamearrsize);
+  if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
+    mkdir(dirnamedestarg, 0755);
+  closedir(dp);
+
+  strlcat(dirnamedestarg, "/", destnamearrsize);
+  get_MM(dir, sizeof(dir));
+
+  strlcat(dirnamedestarg, dir, destnamearrsize);
+  if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
+    mkdir(dirnamedestarg, 0755);
+  closedir(dp);
+
+  strlcat(dirnamedestarg, "/", destnamearrsize);
+  get_DD(dir, sizeof(dir));
+
+  strlcat(dirnamedestarg, dir, destnamearrsize);
+  if ((dp = opendir(dirnamedestarg)) == NULL && errno == ENOENT)
+    mkdir(dirnamedestarg, 0755);
+  closedir(dp);
+
+  strlcat(dirnamedestarg, "/", destnamearrsize);
+  snprintf(dir, sizeof(dir), "%s", finalsuffix);
+  strlcat(dirnamedestarg, dir, destnamearrsize);
+  log_println(5, "end named_log_create %s", dirnamedestarg);
 }
 
 /** Create directories for snap/tcp trace log files, and meta files.
@@ -1147,28 +1153,28 @@ void create_named_logdir(char *dirnamedestarg, int destnamearrsize,
  * @param finalsuffixsize        string constant suffix indicating C2S/S2c etc
  */
 void create_client_logdir(struct sockaddr *cliaddrarg, socklen_t clilenarg,
-		char *dirnamedestarg, int destnamearrsize, char *finalsuffix,
-		int finalsuffixsize) {
-	char namebuf[256];
-	size_t namebuflen = 255;
-	char dir[128];
-	char isoTime[64];
-	int socketaddrport;
-
-	I2Addr sockAddr = I2AddrBySAddr(get_errhandle(), cliaddrarg, clilenarg, 0,
-			0);
-	memset(namebuf, 0, 256);
-	I2AddrNodeName(sockAddr, namebuf, &namebuflen);
-	socketaddrport = I2AddrPort(sockAddr);
-
-	snprintf(dir, sizeof(dir), "%s_%s:%d.%s", get_ISOtime(isoTime, sizeof(isoTime)), namebuf,
-			socketaddrport, finalsuffix);
-	strlcpy(finalsuffix, dir, finalsuffixsize);
-
-	create_named_logdir(dirnamedestarg, destnamearrsize, finalsuffix, 0);
-
-	I2AddrFree(sockAddr);
-
+                          char *dirnamedestarg, int destnamearrsize,
+                          char *finalsuffix, int finalsuffixsize) {
+  char namebuf[256];
+  size_t namebuflen = 255;
+  char dir[128];
+  char isoTime[64];
+  int socketaddrport;
+
+  I2Addr sockAddr = I2AddrBySAddr(get_errhandle(), cliaddrarg, clilenarg, 0,
+                                  0);
+  memset(namebuf, 0, 256);
+  I2AddrNodeName(sockAddr, namebuf, &namebuflen);
+  socketaddrport = I2AddrPort(sockAddr);
+
+  snprintf(dir, sizeof(dir), "%s_%s:%d.%s",
+           get_ISOtime(isoTime, sizeof(isoTime)), namebuf,
+           socketaddrport, finalsuffix);
+  strlcpy(finalsuffix, dir, finalsuffixsize);
+
+  create_named_logdir(dirnamedestarg, destnamearrsize, finalsuffix, 0);
+
+  I2AddrFree(sockAddr);
 }
 
 /**
@@ -1178,42 +1184,42 @@ void create_client_logdir(struct sockaddr *cliaddrarg, socklen_t clilenarg,
  *
  */
 void log_linkspeed(int index) {
-	switch (index) {
-	case DATA_RATE_SYSTEM_FAULT:
-		log_println(1, "System Fault");
-		break;
-	case DATA_RATE_RTT:
-		log_println(1, "RTT");
-		break;
-	case DATA_RATE_DIAL_UP:
-		log_println(1, "Dial-up");
-		break;
-	case DATA_RATE_T1:
-		log_println(1, "T1");
-		break;
-	case DATA_RATE_ETHERNET:
-		log_println(1, "Ethernet");
-		break;
-	case DATA_RATE_T3:
-		log_println(1, "T3");
-		break;
-	case DATA_RATE_FAST_ETHERNET:
-		log_println(1, "FastEthernet");
-		break;
-	case DATA_RATE_OC_12:
-		log_println(1, "OC-12");
-		break;
-	case DATA_RATE_GIGABIT_ETHERNET:
-		log_println(1, "Gigabit Ethernet");
-		break;
-	case DATA_RATE_OC_48:
-		log_println(1, "OC-48");
-		break;
-	case DATA_RATE_10G_ETHERNET:
-		log_println(1, "10 Gigabit Enet");
-		break;
-	case DATA_RATE_RETRANSMISSIONS:
-		log_println(1, "Retransmissions");
-		break;
-	}
+  switch (index) {
+    case DATA_RATE_SYSTEM_FAULT:
+      log_println(1, "System Fault");
+      break;
+    case DATA_RATE_RTT:
+      log_println(1, "RTT");
+      break;
+    case DATA_RATE_DIAL_UP:
+      log_println(1, "Dial-up");
+      break;
+    case DATA_RATE_T1:
+      log_println(1, "T1");
+      break;
+    case DATA_RATE_ETHERNET:
+      log_println(1, "Ethernet");
+      break;
+    case DATA_RATE_T3:
+      log_println(1, "T3");
+      break;
+    case DATA_RATE_FAST_ETHERNET:
+      log_println(1, "FastEthernet");
+      break;
+    case DATA_RATE_OC_12:
+      log_println(1, "OC-12");
+      break;
+    case DATA_RATE_GIGABIT_ETHERNET:
+      log_println(1, "Gigabit Ethernet");
+      break;
+    case DATA_RATE_OC_48:
+      log_println(1, "OC-48");
+      break;
+    case DATA_RATE_10G_ETHERNET:
+      log_println(1, "10 Gigabit Enet");
+      break;
+    case DATA_RATE_RETRANSMISSIONS:
+      log_println(1, "Retransmissions");
+      break;
+  }
 }
diff --git a/src/mrange.c b/src/mrange.c
index 7446c79..e2673c3 100644
--- a/src/mrange.c
+++ b/src/mrange.c
@@ -10,14 +10,14 @@
 #include <assert.h>
 #include <string.h>
 
-#include "utils.h"
-#include "logging.h"
-#include "strlutils.h"
+#include "./utils.h"
+#include "./logging.h"
+#include "./strlutils.h"
 
 typedef struct range {
-	int min; /**< lower end of the range */
-	int max; /**< upper end of the range */
-	struct range *next; /**< pointer to the next range member */
+  int min; /**< lower end of the range */
+  int max; /**< upper end of the range */
+  struct range *next; /**< pointer to the next range member */
 } Range;
 
 static Range* mrange_root;
@@ -32,61 +32,61 @@ static Range* mrange_root;
  */
 
 int mrange_parse(char* text) {
-	char tmp[300];
-	char* ptr, *sptr;
-	Range* mr_ptr = NULL;
+  char tmp[300];
+  char* ptr, *sptr;
+  Range* mr_ptr = NULL;
 
-	assert(text);
+  assert(text);
 
-	memset(tmp, 0, 300);
-	if (strlen(text) > 299) {
-		return 1;
-	}
-	//strcpy(tmp, text);
-	strlcpy(tmp, text, sizeof(tmp));
-	// tokenize based on a "," character.
-	// An example of the string : 2003:3000,4000:5000
-	ptr = strtok(tmp, ",");
-	while (ptr != NULL) { // tokens found
-		if ((sptr = strchr(ptr, ':')) != NULL) { // also found a ":" character,
-												 // with sptr pointing to its location
-			*sptr++ = 0;
-			if (strchr(sptr, ':') != NULL) { // should not find any more range
-				return 1;
-			}
-		} else {
-			sptr = ptr;
-		}
-		if ((mr_ptr = malloc(sizeof(Range))) == NULL) {
-			log_println(0, "FATAL: cannot allocate memory");
-			return 1;
-		}
-		if (*ptr == 0) {
-			ptr = "1";
-		}
-		// Check if the input string is within range and store
-		// result as "minimum"
-		// For ex: Is 2003 in a string like "2003:4000" within integer range ?
-		// If not, free the memory allocated to store the range and return
-		if (check_rint(ptr, &mr_ptr->min, 1, MAX_TCP_PORT)) {
-			free(mr_ptr);
-			return 1;
-		}
-		if (*sptr == 0) {
-			sptr = MAX_TCP_PORT_STR;
-		}
-		// now validate if "maximum" is within range  and store
-		// result as "maximum"
-		if (check_rint(sptr, &mr_ptr->max, 1, MAX_TCP_PORT)) {
-			free(mr_ptr);
-			return 1; // if invalid range, free allocated memory and return
-		}
-		mr_ptr->next = mrange_root;
-		mrange_root = mr_ptr; // ready to point to next member
-		ptr = strtok(NULL, ",");
-	}
-	free(mr_ptr);
-	return 0;
+  memset(tmp, 0, 300);
+  if (strlen(text) > 299) {
+    return 1;
+  }
+  // strcpy(tmp, text);
+  strlcpy(tmp, text, sizeof(tmp));
+  // tokenize based on a "," character.
+  // An example of the string : 2003:3000,4000:5000
+  ptr = strtok(tmp, ",");
+  while (ptr != NULL) {  // tokens found
+    if ((sptr = strchr(ptr, ':')) != NULL) {  // also found a ":" character,
+      // with sptr pointing to its location
+      *sptr++ = 0;
+      if (strchr(sptr, ':') != NULL) {  // should not find any more range
+        return 1;
+      }
+    } else {
+      sptr = ptr;
+    }
+    if ((mr_ptr = malloc(sizeof(Range))) == NULL) {
+      log_println(0, "FATAL: cannot allocate memory");
+      return 1;
+    }
+    if (*ptr == 0) {
+      ptr = "1";
+    }
+    // Check if the input string is within range and store
+    // result as "minimum"
+    // For ex: Is 2003 in a string like "2003:4000" within integer range ?
+    // If not, free the memory allocated to store the range and return
+    if (check_rint(ptr, &mr_ptr->min, 1, MAX_TCP_PORT)) {
+      free(mr_ptr);
+      return 1;
+    }
+    if (*sptr == 0) {
+      sptr = MAX_TCP_PORT_STR;
+    }
+    // now validate if "maximum" is within range  and store
+    // result as "maximum"
+    if (check_rint(sptr, &mr_ptr->max, 1, MAX_TCP_PORT)) {
+      free(mr_ptr);
+      return 1;  // if invalid range, free allocated memory and return
+    }
+    mr_ptr->next = mrange_root;
+    mrange_root = mr_ptr;  // ready to point to next member
+    ptr = strtok(NULL, ",");
+  }
+  free(mr_ptr);
+  return 0;
 }
 
 /**
@@ -102,29 +102,29 @@ int mrange_parse(char* text) {
 
 char*
 mrange_next(char* port, size_t port_strlen) {
-	int val;
-	Range* ptr;
+  int val;
+  Range* ptr;
 
-	assert(port);
+  assert(port);
 
-	if (check_rint(port, &val, 0, MAX_TCP_PORT)) { // check if valid
-		log_println(0, "WARNING: invalid port number");
-		snprintf(port, port_strlen, RESERVED_PORT);
-		return port;
-	}
-	val++;
-	while (val <= MAX_TCP_PORT) { // Maximum port number not exceeded
-		ptr = mrange_root;
-		while (ptr != NULL) { // While there is some data
-			if ((val >= ptr->min) && (val <= ptr->max)) { // check range
-														  // and return port if valid
-				snprintf(port, port_strlen, "%d", val);
-				return port;
-			}
-			ptr = ptr->next;
-		}
-		val++;
-	}
-	snprintf(port, port_strlen, RESERVED_PORT);
-	return port;
+  if (check_rint(port, &val, 0, MAX_TCP_PORT)) {  // check if valid
+    log_println(0, "WARNING: invalid port number");
+    snprintf(port, port_strlen, RESERVED_PORT);
+    return port;
+  }
+  val++;
+  while (val <= MAX_TCP_PORT) {  // Maximum port number not exceeded
+    ptr = mrange_root;
+    while (ptr != NULL) {  // While there is some data
+      if ((val >= ptr->min) && (val <= ptr->max)) {  // check range
+        // and return port if valid
+        snprintf(port, port_strlen, "%d", val);
+        return port;
+      }
+      ptr = ptr->next;
+    }
+    val++;
+  }
+  snprintf(port, port_strlen, RESERVED_PORT);
+  return port;
 }
diff --git a/src/ndt_odbc.c b/src/ndt_odbc.c
index 773da40..ad61d3b 100644
--- a/src/ndt_odbc.c
+++ b/src/ndt_odbc.c
@@ -14,9 +14,9 @@
 #include <sqlext.h>
 #endif
 
-#include "ndt_odbc.h"
-#include "logging.h"
-#include "strlutils.h"
+#include "./ndt_odbc.h"
+#include "./logging.h"
+#include "./strlutils.h"
 
 #if defined(HAVE_ODBC) && defined(DATABASE_ENABLED) && defined(HAVE_SQL_H)
 SQLHENV env;
@@ -102,27 +102,25 @@ char createTableStmt[2048];
  * @param type SQLHandle type
  * */
 
-static void
-extract_error(char *fn, SQLHANDLE handle, SQLSMALLINT type)
-{
-	SQLINTEGER i = 0;
-	SQLINTEGER native;
-	SQLCHAR state[ 7 ];
-	SQLCHAR text[256];
-	SQLSMALLINT len;
-	SQLRETURN ret;
+static void extract_error(char *fn, SQLHANDLE handle, SQLSMALLINT type) {
+  SQLINTEGER i = 0;
+  SQLINTEGER native;
+  SQLCHAR state[ 7 ];
+  SQLCHAR text[256];
+  SQLSMALLINT len;
+  SQLRETURN ret;
 
-	log_println(2, "\nThe driver reported the following diagnostics whilst running %s:\n", fn);
-	do
-	{
-		// get current values of multiple fields(error, warning, and status) of diagnostic record
-		// and see if return value indicated success
-		ret = SQLGetDiagRec(type, handle, ++i, state, &native, text,
-				sizeof(text), &len );
-		if (SQL_SUCCEEDED(ret))
-		log_println(2, "%s:%ld:%ld:%s", state, i, native, text);
-	}
-	while( ret == SQL_SUCCESS );
+  log_println(2, "\nThe driver reported the following diagnostics whilst "
+              "running %s:\n", fn);
+  do {
+    // get current values of multiple fields(error, warning, and status) of
+    // diagnostic record and see if return value indicated success
+    ret = SQLGetDiagRec(type, handle, ++i, state, &native, text, sizeof(text),
+                        &len);
+    if (SQL_SUCCEEDED(ret))
+      log_println(2, "%s:%ld:%ld:%s", state, i, native, text);
+  }
+  while (ret == SQL_SUCCESS);
 }
 #endif
 
@@ -136,110 +134,119 @@ extract_error(char *fn, SQLHANDLE handle, SQLSMALLINT type)
  * */
 int initialize_db(int options, char* dsn, char* uid, char* pwd) {
 #if defined(HAVE_ODBC) && defined(DATABASE_ENABLED) && defined(HAVE_SQL_H)
-	if (options) {
-		SQLRETURN ret; /* ODBC API return status */
-		SQLSMALLINT columns; /* number of columns in result-set */
-		SQLCHAR outstr[1024];
-		SQLSMALLINT outstrlen;
-		char loginstring[1024];
+  if (options) {
+    SQLRETURN ret; /* ODBC API return status */
+    SQLSMALLINT columns; /* number of columns in result-set */
+    SQLCHAR outstr[1024];
+    SQLSMALLINT outstrlen;
+    char loginstring[1024];
 
-		log_println(1, "Initializing DB with DSN='%s', UID='%s', PWD=%s", dsn, uid, pwd ? "yes" : "no");
-		snprintf(createTableStmt, sizeof(createTableStmt), "%s%s%s%s", ctStmt_1, ctStmt_2, ctStmt_3, ctStmt_4);
+    log_println(1, "Initializing DB with DSN='%s', UID='%s', PWD=%s", dsn, uid,
+                pwd ? "yes" : "no");
+    snprintf(createTableStmt, sizeof(createTableStmt), "%s%s%s%s", ctStmt_1,
+             ctStmt_2, ctStmt_3, ctStmt_4);
 
-		// Allocate an environment handle
-		SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
-		// We want ODBC 3 support
-		SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
-		// Allocate a connection handle
-		SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
-		// Connect to the DSN after creating summarizing login data
-		// into "loginstring"
-		memset(loginstring, 0, 1024);
-		snprintf(loginstring, 256, "DSN=%s;", dsn);
-		if (uid) {
-			//strcat(loginstring, "UID=");
-			// strncat(loginstring, uid, 256);
-			// strcat(loginstring, ";");
-			strlcat(loginstring, "UID=", sizeof(loginstring));
-			strlcat(loginstring, uid, sizeof(loginstring));
-			strlcat(loginstring, ";", sizeof(loginstring));
-		}
-		if (pwd) {
-			//strcat(loginstring, "PWD=");
-			strlcat(loginstring, "PWD=", sizeof(loginstring));
-			//strncat(loginstring, pwd, 256);
-			strlcat(loginstring, pwd, sizeof(loginstring));
-		}
-		ret = SQLDriverConnect(dbc, NULL, (unsigned char*) loginstring, SQL_NTS,
-				outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_NOPROMPT);
-		if (SQL_SUCCEEDED(ret)) {
-			log_println(2, "  Connected");
-			log_println(2, "  Returned connection string was:\n\t%s", outstr);
-			if (ret == SQL_SUCCESS_WITH_INFO) {
-				log_println(2, "Driver reported the following diagnostics");
-				extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
-			}
-		} else {
-			log_println(0, "  Failed to connect to the DSN\n Continuing without DB logging");
-			extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
-			return 1;
-		}
-		// Allocate a statement handle
-		ret = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
-		if (!SQL_SUCCEEDED(ret)) {
-			log_println(0, "  Failed to alloc statement handle\n Continuing without DB logging");
-			extract_error("SQLAllocHandle", dbc, SQL_HANDLE_DBC);
-			return 1;
-		}
-		// Retrieve a list of tables
-		ret = SQLTables(stmt, NULL, 0, NULL, 0, NULL, 0, (unsigned char*) "TABLE", SQL_NTS);
-		if (!SQL_SUCCEEDED(ret)) {
-			log_println(0, "  Failed to fetch table info\n Continuing without DB logging");
-			extract_error("SQLTables", dbc, SQL_HANDLE_DBC);
-			return 1;
-		}
-		// How many columns are there?
-		SQLNumResultCols(stmt, &columns);
-		log_println(3,"Fetched SQLNumResults:%d", columns);
-		// Loop through the rows in the result-set
-		while (SQL_SUCCEEDED(ret = SQLFetch(stmt))) {
-			SQLUSMALLINT i;
-			// Loop through the columns
-			for (i = 2; i <= columns; i++) {
-				SQLINTEGER indicator;
-				char buf[512];
-				// retrieve column data as a string
-				ret = SQLGetData(stmt, i, SQL_C_CHAR,
-						buf, sizeof(buf), &indicator);
-				if (SQL_SUCCEEDED(ret)) {
-					// Handle null columns
-					if (indicator == SQL_NULL_DATA)
-					//strcpy(buf, "NULL");
-					strlcpy(buf, "NULL", sizeof(buf));
-					if (strcmp(buf, "ndt_test_results") == 0) {
-						// the table exists - do nothing
-						SQLFreeStmt(stmt, SQL_CLOSE);
-						return 0;
-					}
-				}
-			}
-		}
+    // Allocate an environment handle
+    SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
+    // We want ODBC 3 support
+    SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
+    // Allocate a connection handle
+    SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
+    // Connect to the DSN after creating summarizing login data
+    // into "loginstring"
+    memset(loginstring, 0, 1024);
+    snprintf(loginstring, sizeof(loginstring), "DSN=%s;", dsn);
+    if (uid) {
+      // strcat(loginstring, "UID=");
+      // strncat(loginstring, uid, 256);
+      // strcat(loginstring, ";");
+      strlcat(loginstring, "UID=", sizeof(loginstring));
+      strlcat(loginstring, uid, sizeof(loginstring));
+      strlcat(loginstring, ";", sizeof(loginstring));
+    }
+    if (pwd) {
+      // strcat(loginstring, "PWD=");
+      strlcat(loginstring, "PWD=", sizeof(loginstring));
+      // strncat(loginstring, pwd, 256);
+      strlcat(loginstring, pwd, sizeof(loginstring));
+    }
+    ret = SQLDriverConnect(dbc, NULL, (unsigned char*) loginstring, SQL_NTS,
+                           outstr, sizeof(outstr), &outstrlen,
+                           SQL_DRIVER_NOPROMPT);
+    if (SQL_SUCCEEDED(ret)) {
+      log_println(2, "  Connected");
+      log_println(2, "  Returned connection string was:\n\t%s", outstr);
+      if (ret == SQL_SUCCESS_WITH_INFO) {
+        log_println(2, "Driver reported the following diagnostics");
+        extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
+      }
+    } else {
+      log_println(0, "  Failed to connect to the DSN\n Continuing without DB "
+                  "logging");
+      extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
+      return 1;
+    }
+    // Allocate a statement handle
+    ret = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
+    if (!SQL_SUCCEEDED(ret)) {
+      log_println(0, "  Failed to alloc statement handle\n Continuing without "
+                  "DB logging");
+      extract_error("SQLAllocHandle", dbc, SQL_HANDLE_DBC);
+      return 1;
+    }
+    // Retrieve a list of tables
+    ret = SQLTables(stmt, NULL, 0, NULL, 0, NULL, 0, (unsigned char*) "TABLE",
+                    SQL_NTS);
+    if (!SQL_SUCCEEDED(ret)) {
+      log_println(0, "  Failed to fetch table info\n Continuing without DB "
+                  "logging");
+      extract_error("SQLTables", dbc, SQL_HANDLE_DBC);
+      return 1;
+    }
+    // How many columns are there?
+    SQLNumResultCols(stmt, &columns);
+    log_println(3, "Fetched SQLNumResults:%d", columns);
+    // Loop through the rows in the result-set
+    while (SQL_SUCCEEDED(ret = SQLFetch(stmt))) {
+      SQLUSMALLINT i;
+      // Loop through the columns
+      for (i = 2; i <= columns; i++) {
+        SQLINTEGER indicator;
+        char buf[512];
+        // retrieve column data as a string
+        ret = SQLGetData(stmt, i, SQL_C_CHAR,
+                         buf, sizeof(buf), &indicator);
+        if (SQL_SUCCEEDED(ret)) {
+          // Handle null columns
+          if (indicator == SQL_NULL_DATA)
+            // strcpy(buf, "NULL");
+            strlcpy(buf, "NULL", sizeof(buf));
+          if (strcmp(buf, "ndt_test_results") == 0) {
+            // the table exists - do nothing
+            SQLFreeStmt(stmt, SQL_CLOSE);
+            return 0;
+          }
+        }
+      }
+    }
 
-		// the table doesn't exist - create it
-		SQLFreeStmt(stmt, SQL_CLOSE);
-		log_print(1, "The table 'ndt_test_results' doesn't exist, creating...");
-		ret = SQLExecDirect(stmt, (unsigned char*) createTableStmt, strlen(createTableStmt));
-		if (!SQL_SUCCEEDED(ret)) {
-			log_println(0, "  Failed to create table\n Continuing without DB logging");
-			extract_error("SQLExecDirect", dbc, SQL_HANDLE_DBC);
-			stmt = NULL;
-			return 1;
-		}
-		log_println(1, " SUCCESS!");
-	}
-	return 0;
+    // the table doesn't exist - create it
+    SQLFreeStmt(stmt, SQL_CLOSE);
+    log_print(1, "The table 'ndt_test_results' doesn't exist, creating...");
+    ret = SQLExecDirect(stmt, (unsigned char*) createTableStmt,
+                        strlen(createTableStmt));
+    if (!SQL_SUCCEEDED(ret)) {
+      log_println(0, "  Failed to create table\n Continuing without DB "
+                  "logging");
+      extract_error("SQLExecDirect", dbc, SQL_HANDLE_DBC);
+      stmt = NULL;
+      return 1;
+    }
+    log_println(1, " SUCCESS!");
+  }
+  return 0;
 #else
-	return 1;
+  return 1;
 #endif
 }
 
@@ -249,87 +256,90 @@ int initialize_db(int options, char* dsn, char* uid, char* pwd) {
  * @return integer 0 if success, 1 if failure
  * */
 int db_insert(char spds[4][256], float runave[], char* cputimelog,
-		char* snaplog, char* c2s_snaplog, char* hostName, int testPort,
-		char* date, char* rmt_host, int s2c2spd, int s2cspd, int c2sspd,
-		int Timeouts, int SumRTT, int CountRTT, int PktsRetrans, int FastRetran,
-		int DataPktsOut, int AckPktsOut, int CurrentMSS, int DupAcksIn,
-		int AckPktsIn, int MaxRwinRcvd, int Sndbuf, int MaxCwnd,
-		int SndLimTimeRwin, int SndLimTimeCwnd, int SndLimTimeSender,
-		int DataBytesOut, int SndLimTransRwin, int SndLimTransCwnd,
-		int SndLimTransSender, int MaxSsthresh, int CurrentRTO,
-		int CurrentRwinRcvd, int link, int mismatch, int bad_cable,
-		int half_duplex, int congestion, int c2s_linkspeed_data, int c2s_linkspeed_ack, int s2c_linkspeed_data,
-		int s2c_linkspeed_ack, int CongestionSignals, int PktsOut, int MinRTT,
-		int RcvWinScale, int autotune, int CongAvoid, int CongestionOverCount,
-		int MaxRTT, int OtherReductions, int CurTimeoutCount,
-		int AbruptTimeouts, int SendStall, int SlowStart,
-		int SubsequentTimeouts, int ThruBytesAcked, int minPeak, int maxPeak,
-		int peaks) {
+              char* snaplog, char* c2s_snaplog, char* hostName, int testPort,
+              char* date, char* rmt_host, int s2c2spd, int s2cspd, int c2sspd,
+              int Timeouts, int SumRTT, int CountRTT, int PktsRetrans,
+              int FastRetran, int DataPktsOut, int AckPktsOut, int CurrentMSS,
+              int DupAcksIn, int AckPktsIn, int MaxRwinRcvd, int Sndbuf,
+              int MaxCwnd, int SndLimTimeRwin, int SndLimTimeCwnd,
+              int SndLimTimeSender, int DataBytesOut, int SndLimTransRwin,
+              int SndLimTransCwnd, int SndLimTransSender, int MaxSsthresh,
+              int CurrentRTO, int CurrentRwinRcvd, int link, int mismatch,
+              int bad_cable, int half_duplex, int congestion,
+              int c2s_linkspeed_data, int c2s_linkspeed_ack,
+              int s2c_linkspeed_data, int s2c_linkspeed_ack,
+              int CongestionSignals, int PktsOut, int MinRTT, int RcvWinScale,
+              int autotune, int CongAvoid, int CongestionOverCount, int MaxRTT,
+              int OtherReductions, int CurTimeoutCount, int AbruptTimeouts,
+              int SendStall, int SlowStart, int SubsequentTimeouts,
+              int ThruBytesAcked, int minPeak, int maxPeak, int peaks) {
 #if defined(HAVE_ODBC) && defined(DATABASE_ENABLED) && defined(HAVE_SQL_H)
-	SQLRETURN ret;
-	char insertStmt[2048];
-	int i_iter = 0, arr_len = 4; // 4 runspeed-averages are obtained
-	if (!stmt) {
-		return 1;
-	}
-	// Check if any of the run averages are nan numbers 
-	for (i_iter = 0; i_iter < arr_len; i_iter++) {
-		log_println(3,"Odbc:Padding %f?", runave[i_iter]);
-		pad_NaN(&runave[i_iter]);
-		log_println(3,"Odbc:After Padding %f", runave[i_iter]);
-	}
-	snprintf(insertStmt, 2040, "INSERT INTO ndt_test_results VALUES ("
-			"'%s','%s','%s','%s',%f,%f,%f,%f,"
-			"'%s','%s','%s','%s',%d,"
-			"'%s','%s',%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d,"
-			"%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d,"
-			"%d,%d,%d,%d,"
-			"%d,%d,%d,%d,%d"
-			");",
-			spds[0], spds[1], spds[2], spds[3], runave[0], runave[1], runave[2], runave[3],
-			cputimelog, snaplog, c2s_snaplog, hostName, testPort,
-			date, rmt_host, s2c2spd, s2cspd, c2sspd, Timeouts,
-			SumRTT, CountRTT, PktsRetrans, FastRetran, DataPktsOut,
-			AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn, MaxRwinRcvd,
-			Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
-			DataBytesOut, SndLimTransRwin, SndLimTransCwnd, SndLimTransSender,
-			MaxSsthresh, CurrentRTO, CurrentRwinRcvd, link, mismatch,
-			bad_cable, half_duplex, congestion, c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data,
-			s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale,
-			autotune, CongAvoid, CongestionOverCount, MaxRTT, OtherReductions,
-			CurTimeoutCount, AbruptTimeouts, SendStall, SlowStart,
-			SubsequentTimeouts, ThruBytesAcked, minPeak, maxPeak, peaks
-	);
-	ret = SQLExecDirect(stmt, (unsigned char*) insertStmt, strlen(insertStmt));
-	log_println(3, "Trying to insert data using the statement:%s", insertStmt); 
-	if (!SQL_SUCCEEDED(ret)) {
-		log_println(0, "  Failed to insert test results into the table\n Continuing without DB logging");
-		extract_error("SQLExecDirect", dbc, SQL_HANDLE_DBC);
-		stmt = NULL;
-		return 1;
-	}
+  SQLRETURN ret;
+  char insertStmt[2048];
+  int i_iter = 0, arr_len = 4;  // 4 runspeed-averages are obtained
+  if (!stmt) {
+    return 1;
+  }
+  // Check if any of the run averages are nan numbers
+  for (i_iter = 0; i_iter < arr_len; i_iter++) {
+    log_println(3, "Odbc:Padding %f?", runave[i_iter]);
+    pad_NaN(&runave[i_iter]);
+    log_println(3, "Odbc:After Padding %f", runave[i_iter]);
+  }
+  snprintf(insertStmt, sizeof(insertStmt),
+           "INSERT INTO ndt_test_results VALUES ("
+           "'%s','%s','%s','%s',%f,%f,%f,%f,"
+           "'%s','%s','%s','%s',%d,"
+           "'%s','%s',%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d,"
+           "%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d,"
+           "%d,%d,%d,%d,"
+           "%d,%d,%d,%d,%d"
+           ");",
+           spds[0], spds[1], spds[2], spds[3], runave[0], runave[1], runave[2],
+           runave[3], cputimelog, snaplog, c2s_snaplog, hostName, testPort,
+           date, rmt_host, s2c2spd, s2cspd, c2sspd, Timeouts,
+           SumRTT, CountRTT, PktsRetrans, FastRetran, DataPktsOut,
+           AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn, MaxRwinRcvd,
+           Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
+           DataBytesOut, SndLimTransRwin, SndLimTransCwnd, SndLimTransSender,
+           MaxSsthresh, CurrentRTO, CurrentRwinRcvd, link, mismatch,
+           bad_cable, half_duplex, congestion, c2s_linkspeed_data,
+           c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack,
+           CongestionSignals, PktsOut, MinRTT, RcvWinScale, autotune, CongAvoid,
+           CongestionOverCount, MaxRTT, OtherReductions, CurTimeoutCount,
+           AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
+           ThruBytesAcked, minPeak, maxPeak, peaks);
+  ret = SQLExecDirect(stmt, (unsigned char*) insertStmt, strlen(insertStmt));
+  log_println(3, "Trying to insert data using the statement:%s", insertStmt);
+  if (!SQL_SUCCEEDED(ret)) {
+    log_println(0, "  Failed to insert test results into the table\n "
+                "Continuing without DB logging");
+    extract_error("SQLExecDirect", dbc, SQL_HANDLE_DBC);
+    stmt = NULL;
+    return 1;
+  }
 
-	return 0;
+  return 0;
 #else
-	return 1;
+  return 1;
 #endif
 }
 
 /***
-* Check if the value is a NaN by comparing it with itself.
-* @args float_val value of the float variable which has to be checked for Nan
-* 
-**/
+ * Check if the value is a NaN by comparing it with itself.
+ * @args float_val value of the float variable which has to be checked for Nan
+ * 
+ **/
 void pad_NaN(float *float_val) {
-        if (*float_val != *float_val) {
-                *float_val = -1;
-                log_println(0," A float value you tried to insert into the DB was NaN");
-        }
+  if (*float_val != *float_val) {
+    *float_val = -1;
+    log_println(0, " A float value you tried to insert into the DB was NaN");
+  }
 }
diff --git a/src/ndtptestconstants.c b/src/ndtptestconstants.c
index 4a327be..292be74 100644
--- a/src/ndtptestconstants.c
+++ b/src/ndtptestconstants.c
@@ -8,25 +8,25 @@
  */
 
 #include <string.h>
-#include "ndtptestconstants.h"
+#include "./ndtptestconstants.h"
 
 // The arrays below rely on the ordering of corresponding enum in the .h file.
 // test names
 static char *_teststatusdescarray[] = { "test_not_started", "test_started",
-		"test_in_progress", "test_incomplete", "test_complete" };
+  "test_in_progress", "test_incomplete", "test_complete" };
 
 // names of tests.
 static char *_testnamesarray[] = { "None", "Middlebox", "SFW", "C2S", "S2C",
-		"Meta" };
+  "Meta" };
 
 // names of test messages to log in descriptive names instead of numbers
 static char * _testmsgtypesarray[] = { "COMM_FAILURE", "SRV_QUEUE", "MSG_LOGIN",
-		"TEST_PREPARE", "TEST_START", "TEST_MSG", "TEST_FINALIZE", "MSG_ERROR",
-		"MSG_RESULTS", "MSG_LOGOUT", "MSG_WAITING", };
+  "TEST_PREPARE", "TEST_START", "TEST_MSG", "TEST_FINALIZE", "MSG_ERROR",
+  "MSG_RESULTS", "MSG_LOGOUT", "MSG_WAITING", };
 
 // names of protocol message transmission directions
 static char *_txdirectionsarray[] = { "none", "client_to_server",
-		"server_to_client" };
+  "server_to_client" };
 
 static char *_msgbodyformattype[] = { "bitfield", "string", "none" };
 
@@ -37,9 +37,9 @@ static char *_msgbodyformattype[] = { "bitfield", "string", "none" };
  * @return char*  Descriptive string for test name
  * */
 char *get_testnamedesc(enum TEST_ID testid, char *snamearg) {
-	snamearg = _testnamesarray[testid];
-	//printf ("--current test name = %s for %d\n", snamearg ,testid);
-	return snamearg;
+  snamearg = _testnamesarray[testid];
+  // printf ("--current test name = %s for %d\n", snamearg ,testid);
+  return snamearg;
 }
 
 /**
@@ -49,9 +49,9 @@ char *get_testnamedesc(enum TEST_ID testid, char *snamearg) {
  * @return char*  Descriptive string for test status
  * */
 char *get_teststatusdesc(enum TEST_STATUS_INT teststatus, char *sstatusarg) {
-	sstatusarg = _teststatusdescarray[teststatus];
-	//printf ("--current test status = %s, for %d \n", sstatusarg, teststatus);
-	return sstatusarg;
+  sstatusarg = _teststatusdescarray[teststatus];
+  // printf ("--current test status = %s, for %d \n", sstatusarg, teststatus);
+  return sstatusarg;
 }
 
 /**
@@ -62,9 +62,10 @@ char *get_teststatusdesc(enum TEST_STATUS_INT teststatus, char *sstatusarg) {
  * @return char*  Descriptive string fr Test direction
  * */
 char *get_testdirectiondesc(enum Tx_DIRECTION testdirection, char *sdirnarg) {
-	sdirnarg = _txdirectionsarray[testdirection];
-	//printf ("--current test direction = %s , for %d\n", sdirnarg, testdirection);
-	return sdirnarg;
+  sdirnarg = _txdirectionsarray[testdirection];
+  // printf ("--current test direction = %s , for %d\n", sdirnarg,
+  // testdirection);
+  return sdirnarg;
 }
 
 /**
@@ -75,9 +76,9 @@ char *get_testdirectiondesc(enum Tx_DIRECTION testdirection, char *sdirnarg) {
  * @return char* Descriptive string for Message type
  * */
 char *get_msgtypedesc(int msgtype, char *smsgtypearg) {
-	smsgtypearg = _testmsgtypesarray[msgtype];
-	//printf ("--current test type = %s , for %d\n", smsgtypearg, msgtype);
-	return smsgtypearg;
+  smsgtypearg = _testmsgtypesarray[msgtype];
+  // printf ("--current test type = %s , for %d\n", smsgtypearg, msgtype);
+  return smsgtypearg;
 }
 
 /**
@@ -86,7 +87,8 @@ char *get_msgtypedesc(int msgtype, char *smsgtypearg) {
  * @param smsgformattypearg descriptive string for message body format type
  * @return
  */
-char * getmessageformattype(enum MSG_BODY_TYPE bodymsgformat, char *smsgformattypearg)  {
-	smsgformattypearg = _msgbodyformattype[bodymsgformat];
-	return smsgformattypearg;
+char * getmessageformattype(enum MSG_BODY_TYPE bodymsgformat,
+                            char *smsgformattypearg) {
+  smsgformattypearg = _msgbodyformattype[bodymsgformat];
+  return smsgformattypearg;
 }
diff --git a/src/network.c b/src/network.c
index 8e63576..286bafb 100644
--- a/src/network.c
+++ b/src/network.c
@@ -11,8 +11,8 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "network.h"
-#include "logging.h"
+#include "./network.h"
+#include "./logging.h"
 
 /**
  * Create and bind socket.
@@ -26,112 +26,112 @@
  */
 
 static int OpenSocket(I2Addr addr, char* serv, int options) {
-	struct addrinfo *fai;
-	struct addrinfo *ai;
-	int on;
-	socklen_t onSize;
-	int fd = -1;
-
-	if (!(fai = I2AddrAddrInfo(addr, NULL, serv))) {
-		return -2;
-	}
-
-	for (ai = fai; ai; ai = ai->ai_next) {
-		// options provided by user indicate V6
+  struct addrinfo *fai;
+  struct addrinfo *ai;
+  int on;
+  socklen_t onSize;
+  int fd = -1;
+
+  if (!(fai = I2AddrAddrInfo(addr, NULL, serv))) {
+    return -2;
+  }
+
+  for (ai = fai; ai; ai = ai->ai_next) {
+    // options provided by user indicate V6
 #ifdef AF_INET6
-		if (options & OPT_IPV6_ONLY) { // If not an INET6 address, move on
-			if(ai->ai_family != AF_INET6)
-			continue;
-		}
+    if (options & OPT_IPV6_ONLY) {  // If not an INET6 address, move on
+      if (ai->ai_family != AF_INET6)
+        continue;
+    }
 #endif
 
-		if (options & OPT_IPV4_ONLY) { // options provided by user indicate V4
-			if (ai->ai_family != AF_INET) // Not valid Inet address family. move on
-				continue;
-		}
+    if (options & OPT_IPV4_ONLY) {  // options provided by user indicate V4
+      if (ai->ai_family != AF_INET)  // Not valid Inet address family. move on
+        continue;
+    }
 
-		// create socket with obtained address domain, socket type and protocol
-		fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+    // create socket with obtained address domain, socket type and protocol
+    fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
 
-		// socket create failed. Abandon further activities using this socket
-		if (fd < 0) {
-			continue;
-		}
+    // socket create failed. Abandon further activities using this socket
+    if (fd < 0) {
+      continue;
+    }
 
-		// allow sockets to reuse local address while binding unless there
-		// is an active listener. If unable to set this option, indicate failure
+    // allow sockets to reuse local address while binding unless there
+    // is an active listener. If unable to set this option, indicate failure
 
-		on = 1;
-		if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) {
-			goto failsock;
-		}
+    on = 1;
+    if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) {
+      goto failsock;
+    }
 
-		// the IPv6 version socket option setup
+    // the IPv6 version socket option setup
 #if defined(AF_INET6) && defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
-		if ((ai->ai_family == AF_INET6) && (options & OPT_IPV6_ONLY) &&
-				setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,&on,sizeof(on)) != 0) {
-			goto failsock;
-		}
+    if ((ai->ai_family == AF_INET6) && (options & OPT_IPV6_ONLY) &&
+        setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) != 0) {
+      goto failsock;
+    }
 #endif
-		// end trying to set socket option to reuse local address
-
-		// try to bind to address
-		if (bind(fd, ai->ai_addr, ai->ai_addrlen) == 0) { // successful
-
-			// set values in "addr" structure
-			if (!I2AddrSetSAddr(addr, ai->ai_addr, ai->ai_addrlen)
-					|| !I2AddrSetProtocol(addr, ai->ai_protocol)
-					|| !I2AddrSetSocktype(addr, ai->ai_socktype)) {
-				log_println(1, "OpenSocket: Unable to set saddr in address record");
-				return -1;
-			}
-			// set port if not already done, else return -1
-			if (!I2AddrPort(addr)) {
-				struct sockaddr_storage tmp_addr;
-				socklen_t tmp_addr_len = sizeof(tmp_addr);
-				I2Addr tmpAddr;
-				if (getsockname(fd, (struct sockaddr*) &tmp_addr,
-						&tmp_addr_len)) {
-					return -1;
-				}
-				tmpAddr = I2AddrBySAddr(get_errhandle(),
-						(struct sockaddr*) &tmp_addr, tmp_addr_len, 0, 0);
-				I2AddrSetPort(addr, I2AddrPort(tmpAddr));
-				I2AddrFree(tmpAddr);
-			}
-			// save socket file descriptor
-			if (!I2AddrSetFD(addr, fd, True)) {
-				log_println(1, "OpenSocket: Unable to set file descriptor in address record");
-				return -1;
-			}
-			// end setting values in "addr" structure
-
-			break;
-		}
-
-		// Address is indicated as being in use. Display actual socket options to user and return
-		if (errno == EADDRINUSE) {
-			/* RAC debug statemement 10/11/06 */
-			onSize = sizeof(on);
-			getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, &onSize);
-			log_println(1,
-                                    "bind(%d) failed: Address already in use given as the reason, getsockopt() returned %d",
-                                    fd, on);
-			return -2;
-		}
-
-		// If setting socket option failed, print error, and try to close socket file-descriptor
-		failsock:
-		/* RAC debug statemement 10/11/06 */
-		log_println(1, "failsock: Unable to set socket options for fd=%d", fd);
-		while ((close(fd) < 0) && (errno == EINTR))
-			;
-	}
-
-	// set meta test's address domain family to the one used to create socket
-	if (meta.family == 0)
-		meta.family = ai->ai_family;
-	return fd;
+    // end trying to set socket option to reuse local address
+
+    // try to bind to address
+    if (bind(fd, ai->ai_addr, ai->ai_addrlen) == 0) {  // successful
+      // set values in "addr" structure
+      if (!I2AddrSetSAddr(addr, ai->ai_addr, ai->ai_addrlen)
+          || !I2AddrSetProtocol(addr, ai->ai_protocol)
+          || !I2AddrSetSocktype(addr, ai->ai_socktype)) {
+        log_println(1, "OpenSocket: Unable to set saddr in address record");
+        return -1;
+      }
+      // set port if not already done, else return -1
+      if (!I2AddrPort(addr)) {
+        struct sockaddr_storage tmp_addr;
+        socklen_t tmp_addr_len = sizeof(tmp_addr);
+        I2Addr tmpAddr;
+        if (getsockname(fd, (struct sockaddr*) &tmp_addr,
+                        &tmp_addr_len)) {
+          return -1;
+        }
+        tmpAddr = I2AddrBySAddr(
+            get_errhandle(), (struct sockaddr*) &tmp_addr, tmp_addr_len, 0, 0);
+        I2AddrSetPort(addr, I2AddrPort(tmpAddr));
+        I2AddrFree(tmpAddr);
+      }
+      // save socket file descriptor
+      if (!I2AddrSetFD(addr, fd, True)) {
+        log_println(1, "OpenSocket: Unable to set file descriptor in address "
+                    "record");
+        return -1;
+      }
+      // end setting values in "addr" structure
+
+      break;
+    }
+
+    // Address is indicated as being in use. Display actual socket options to
+    // user and return
+    if (errno == EADDRINUSE) {
+      /* RAC debug statemement 10/11/06 */
+      onSize = sizeof(on);
+      getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, &onSize);
+      log_println(1, "bind(%d) failed: Address already in use given as the "
+                  "reason, getsockopt() returned %d", fd, on);
+      return -2;
+    }
+
+    // If setting socket option failed, print error, and try to close socket
+    // file-descriptor
+ failsock:
+    /* RAC debug statemement 10/11/06 */
+    log_println(1, "failsock: Unable to set socket options for fd=%d", fd);
+    while ((close(fd) < 0) && (errno == EINTR)) { }
+  }
+
+  // set meta test's address domain family to the one used to create socket
+  if (meta.family == 0)
+    meta.family = ai->ai_family;
+  return fd;
 }
 
 /**
@@ -146,71 +146,72 @@ static int OpenSocket(I2Addr addr, char* serv, int options) {
  */
 
 I2Addr CreateListenSocket(I2Addr addr, char* serv, int options, int buf_size) {
-	int fd = -1;
-	socklen_t optlen;
-	int set_size;
-
-	if (addr && (I2AddrFD(addr) > -1)) {
-		log_println(1, "Invalid I2Addr record - fd already specified.");
-		goto error;
-	}
-
-	if ((!addr) && !(addr = I2AddrByWildcard(get_errhandle(), SOCK_STREAM, serv))) {
-		log_println(1, "Unable to create I2Addr record by wildcard.");
-		goto error;
-	}
-
-	if (!I2AddrSetPassive(addr, True)) {
-		log_println(1, "Unable to set passive mode in I2Addr record.");
-		goto error;
-	}
-
-	// create and bind socket using arguments
-	fd = OpenSocket(addr, serv, options);
-
-	if (fd < 0) {
-		log_println(1, "Unable to open socket.");
-		goto error;
-	}
-
-	/* Set sock opt code from Marion Nakanson <hakansom@ohsu.edu
-	 *  OHSU Advanced Computing Center
-	 * email on 2/19/09 correctly notes that setsockops must be made before open()
-	 * or listen() calls are made
-	 */
-
-	optlen = sizeof(set_size);
-	// get send buffer size
-	getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
-	log_print(5, "\nSend buffer initialized to %d, ", set_size);
-
-	// get receive buffer size
-	getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
-	log_println(5, "Receive buffer initialized to %d", set_size);
-
-	// now assign buffer sizes passed as arguments
-	if (buf_size > 0) {
-		setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size)); // send buffer
-		setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size)); // receive buffer
-		// print values set to help user verify
-		getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
-		log_print(5, "Changed buffer sizes: Send buffer set to %d(%d), ",
-				set_size, buf_size);
-		getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
-		log_println(5, "Receive buffer set to %d(%d)", set_size, buf_size);
-	}
-
-	// now listen on socket for connections, with backlog queue length = NDT_BACKLOG
-	if (listen(fd, NDT_BACKLOG) < 0) { // if listen returns value <0, then error
-		log_println(1, "listen(%d,%d):%s", fd, NDT_BACKLOG, strerror(errno));
-		goto error;
-	}
-
-	return addr;
-
-// If error, try freeing memory
-	error: I2AddrFree(addr);
-	return NULL;
+  int fd = -1;
+  socklen_t optlen;
+  int set_size;
+
+  if (addr && (I2AddrFD(addr) > -1)) {
+    log_println(1, "Invalid I2Addr record - fd already specified.");
+    goto error;
+  }
+
+  if ((!addr) &&
+      !(addr = I2AddrByWildcard(get_errhandle(), SOCK_STREAM, serv))) {
+    log_println(1, "Unable to create I2Addr record by wildcard.");
+    goto error;
+  }
+
+  if (!I2AddrSetPassive(addr, True)) {
+    log_println(1, "Unable to set passive mode in I2Addr record.");
+    goto error;
+  }
+
+  // create and bind socket using arguments
+  fd = OpenSocket(addr, serv, options);
+
+  if (fd < 0) {
+    log_println(1, "Unable to open socket.");
+    goto error;
+  }
+
+  /* Set sock opt code from Marion Nakanson <hakansom@ohsu.edu
+   *  OHSU Advanced Computing Center
+   * email on 2/19/09 correctly notes that setsockops must be made before open()
+   * or listen() calls are made
+   */
+
+  optlen = sizeof(set_size);
+  // get send buffer size
+  getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
+  log_print(5, "\nSend buffer initialized to %d, ", set_size);
+
+  // get receive buffer size
+  getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
+  log_println(5, "Receive buffer initialized to %d", set_size);
+
+  // now assign buffer sizes passed as arguments
+  if (buf_size > 0) {
+    setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buf_size, sizeof(buf_size));
+    setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buf_size, sizeof(buf_size));
+    // print values set to help user verify
+    getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
+    log_print(5, "Changed buffer sizes: Send buffer set to %d(%d), ",
+              set_size, buf_size);
+    getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
+    log_println(5, "Receive buffer set to %d(%d)", set_size, buf_size);
+  }
+
+  // listen on socket for connections, with backlog queue length = NDT_BACKLOG
+  if (listen(fd, NDT_BACKLOG) < 0) {  // if listen returns value <0, then error
+    log_println(1, "listen(%d,%d):%s", fd, NDT_BACKLOG, strerror(errno));
+    goto error;
+  }
+
+  return addr;
+
+  // If error, try freeing memory
+error: I2AddrFree(addr);
+       return NULL;
 }
 
 /**
@@ -228,135 +229,133 @@ I2Addr CreateListenSocket(I2Addr addr, char* serv, int options, int buf_size) {
  */
 
 int CreateConnectSocket(int* sockfd, I2Addr local_addr, I2Addr server_addr,
-		int options, int buf_size) {
-	struct addrinfo *fai = NULL;
-	struct addrinfo *ai = NULL;
-	struct addrinfo *lfai = NULL;
-	struct addrinfo *lai = NULL;
-	socklen_t optlen;
-	int set_size;
-
-	assert(sockfd);
-	assert(server_addr);
-
-	if (!server_addr) {
-		goto error;
-	}
-
-	// already connected and bound
-	if ((*sockfd = I2AddrFD(server_addr)) > -1) {
-		return 0;
-	}
-
-	if (!(fai = I2AddrAddrInfo(server_addr, NULL, NULL))) {
-		goto error;
-	}
-
-	for (ai = fai; ai; ai = ai->ai_next) {
-
-		// options provided by user indicate V6
+                        int options, int buf_size) {
+  struct addrinfo *fai = NULL;
+  struct addrinfo *ai = NULL;
+  struct addrinfo *lfai = NULL;
+  struct addrinfo *lai = NULL;
+  socklen_t optlen;
+  int set_size;
+
+  assert(sockfd);
+  assert(server_addr);
+
+  if (!server_addr) {
+    goto error;
+  }
+
+  // already connected and bound
+  if ((*sockfd = I2AddrFD(server_addr)) > -1) {
+    return 0;
+  }
+
+  if (!(fai = I2AddrAddrInfo(server_addr, NULL, NULL))) {
+    goto error;
+  }
+
+  for (ai = fai; ai; ai = ai->ai_next) {
+    // options provided by user indicate V6
 #ifdef AF_INET6
-		if (options & OPT_IPV6_ONLY) { // If not an INET6 address, move on
-			if(ai->ai_family != AF_INET6)
-			continue;
-		}
+    if (options & OPT_IPV6_ONLY) {  // If not an INET6 address, move on
+      if (ai->ai_family != AF_INET6)
+        continue;
+    }
 #endif
 
-		// options provided by user indicate V4
-		if (options & OPT_IPV4_ONLY) {
-			if (ai->ai_family != AF_INET) // NOT valid inet address family. Move on.
-				continue;
-		}
-
-		// create socket with obtained address domain, socket type and protocol
-		*sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
-		if (*sockfd < 0) { // socket create failed. Abandon further activities using this socket
-			continue;
-		}
-
-		// local address has been specified. Get details and bind to this adderess
-		if (local_addr) {
-			int bindFailed = 1;
-			if (!(lfai = I2AddrAddrInfo(local_addr, NULL, NULL))) {
-				continue;
-			}
-
-			// Validate INET address family
-			for (lai = lfai; lai; lai = lai->ai_next) {
+    // options provided by user indicate V4
+    if (options & OPT_IPV4_ONLY) {
+      if (ai->ai_family != AF_INET)  // NOT valid inet address family. Move on.
+        continue;
+    }
+
+    // create socket with obtained address domain, socket type and protocol
+    *sockfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+    if (*sockfd < 0) {
+      // socket create failed. Abandon further activities using this socket
+      continue;
+    }
+
+    // local address has been specified. Get details and bind to this adderess
+    if (local_addr) {
+      int bindFailed = 1;
+      if (!(lfai = I2AddrAddrInfo(local_addr, NULL, NULL))) {
+        continue;
+      }
+
+      // Validate INET address family
+      for (lai = lfai; lai; lai = lai->ai_next) {
 #ifdef AF_INET6
-				if (options & OPT_IPV6_ONLY) {
-					if(lai->ai_family != AF_INET6)
-					continue;
-				}
+        if (options & OPT_IPV6_ONLY) {
+          if (lai->ai_family != AF_INET6)
+            continue;
+        }
 #endif
 
-				if (options & OPT_IPV4_ONLY) {
-					if (lai->ai_family != AF_INET)
-						continue;
-				}
-
-				// bind to local address
-				if (bind((*sockfd), lai->ai_addr, lai->ai_addrlen) == 0) {
-					bindFailed = 0; // bind successful
-					break; /* success */
-				}
-			}
-
-			// Failed to bind. Close socket file-descriptor and move on
-			if (bindFailed == 1) {
-				close((*sockfd)); /* ignore this one */
-				continue;
-			}
-		} // end local address
-
-		/* Set sock opt code from Marion Nakanson <hakansom@ohsu.edu
-		 *  OHSU Advanced Computing Center
-		 * email on 2/19/09 correctly notes that setsockops must be made before open()
-		 * or listen() calls are made
-		 */
-
-		optlen = sizeof(set_size);
-		// get send buffer size for logs
-		getsockopt(*sockfd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
-		log_print(5, "\nSend buffer initialized to %d, ", set_size);
-		// get receive buffer size for logs
-		getsockopt(*sockfd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
-		log_println(5, "Receive buffer initialized to %d", set_size);
-
-		// now assign buffer sizes passed as arguments
-		if (buf_size > 0) {
-			setsockopt(*sockfd, SOL_SOCKET, SO_SNDBUF, &buf_size,
-					sizeof(buf_size));
-			setsockopt(*sockfd, SOL_SOCKET, SO_RCVBUF, &buf_size,
-					sizeof(buf_size));
-			// log values for reference
-			getsockopt(*sockfd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
-			log_print(5, "Changed buffer sizes: Send buffer set to %d(%d), ",
-					set_size, buf_size);
-			getsockopt(*sockfd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
-			log_println(5, "Receive buffer set to %d(%d)", set_size, buf_size);
-		}
-
-		// Connect to target socket
-		if (connect(*sockfd, ai->ai_addr, ai->ai_addrlen) == 0) {
-
-			// save server address values
-			if (I2AddrSetSAddr(server_addr, ai->ai_addr, ai->ai_addrlen)
-					&& I2AddrSetSocktype(server_addr, ai->ai_socktype)
-					&& I2AddrSetProtocol(server_addr, ai->ai_protocol)
-					&& I2AddrSetFD(server_addr, *sockfd, True)) {
-				return 0;
-			}
-			// unable to save
-			log_println(1, "I2Addr functions failed after successful connection");
-			while ((close(*sockfd) < 0) && (errno == EINTR))
-				;
-			return 1;
-		}
-	}
-
-	error: log_println(1, "Unable to create connect socket.");
-	return -1;
+        if (options & OPT_IPV4_ONLY) {
+          if (lai->ai_family != AF_INET)
+            continue;
+        }
+
+        // bind to local address
+        if (bind((*sockfd), lai->ai_addr, lai->ai_addrlen) == 0) {
+          bindFailed = 0;  // bind successful
+          break; /* success */
+        }
+      }
+
+      // Failed to bind. Close socket file-descriptor and move on
+      if (bindFailed == 1) {
+        close((*sockfd)); /* ignore this one */
+        continue;
+      }
+    }  // end local address
+
+    /* Set sock opt code from Marion Nakanson <hakansom@ohsu.edu
+     *  OHSU Advanced Computing Center
+     * email on 2/19/09 correctly notes that setsockops must be made before open()
+     * or listen() calls are made
+     */
+
+    optlen = sizeof(set_size);
+    // get send buffer size for logs
+    getsockopt(*sockfd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
+    log_print(5, "\nSend buffer initialized to %d, ", set_size);
+    // get receive buffer size for logs
+    getsockopt(*sockfd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
+    log_println(5, "Receive buffer initialized to %d", set_size);
+
+    // now assign buffer sizes passed as arguments
+    if (buf_size > 0) {
+      setsockopt(*sockfd, SOL_SOCKET, SO_SNDBUF, &buf_size,
+                 sizeof(buf_size));
+      setsockopt(*sockfd, SOL_SOCKET, SO_RCVBUF, &buf_size,
+                 sizeof(buf_size));
+      // log values for reference
+      getsockopt(*sockfd, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
+      log_print(5, "Changed buffer sizes: Send buffer set to %d(%d), ",
+                set_size, buf_size);
+      getsockopt(*sockfd, SOL_SOCKET, SO_RCVBUF, &set_size, &optlen);
+      log_println(5, "Receive buffer set to %d(%d)", set_size, buf_size);
+    }
+
+    // Connect to target socket
+    if (connect(*sockfd, ai->ai_addr, ai->ai_addrlen) == 0) {
+      // save server address values
+      if (I2AddrSetSAddr(server_addr, ai->ai_addr, ai->ai_addrlen)
+          && I2AddrSetSocktype(server_addr, ai->ai_socktype)
+          && I2AddrSetProtocol(server_addr, ai->ai_protocol)
+          && I2AddrSetFD(server_addr, *sockfd, True)) {
+        return 0;
+      }
+      // unable to save
+      log_println(1, "I2Addr functions failed after successful connection");
+      while ((close(*sockfd) < 0) && (errno == EINTR)) { }
+      return 1;
+    }
+  }
+
+error: log_println(1, "Unable to create connect socket.");
+       return -1;
 }
 
 /**
@@ -374,54 +373,54 @@ int CreateConnectSocket(int* sockfd, I2Addr local_addr, I2Addr server_addr,
  */
 
 int send_msg(int ctlSocket, int type, void* msg, int len) {
-	unsigned char buff[3];
-	int rc, i;
-
-	assert(msg);
-	assert(len >= 0);
-
-	/*  memset(0, buff, 3); */
-	// set message type and length into message itself
-	buff[0] = type;
-	buff[1] = len >> 8;
-	buff[2] = len;
-
-	// retry sending data 5 times
-	for (i = 0; i < 5; i++) {
-		// Write initial data about length and type to socket
-		rc = writen(ctlSocket, buff, 3);
-		if (rc == 3) // write completed
-			break;
-		if (rc == 0) // nothing written yet,
-			continue;
-		if (rc == -1) // error writing to socket..cannot continue
-			return -1;
-	}
-
-	// Exceeded retries, return as "failed trying to write"
-	if (i == 5)
-		return -3;
-
-	// Now write the actual message
-	for (i = 0; i < 5; i++) {
-		rc = writen(ctlSocket, msg, len);
-		// all the data has been written successfully
-		if (rc == len)
-			break;
-		// data writing not complete, continue
-		if (rc == 0)
-			continue;
-		if (rc == -1) //error writing to socket, cannot continue writing data
-			return -2;
-	}
-	if (i == 5)
-		return -3;
-	log_println(8, ">>> send_msg: type=%d, len=%d, msg=%s, pid=%d", type, len,
-			msg, getpid());
-
-	protolog_sendprintln(type, msg, len, getpid(), ctlSocket);
-
-	return 0;
+  unsigned char buff[3];
+  int rc, i;
+
+  assert(msg);
+  assert(len >= 0);
+
+  /*  memset(0, buff, 3); */
+  // set message type and length into message itself
+  buff[0] = type;
+  buff[1] = len >> 8;
+  buff[2] = len;
+
+  // retry sending data 5 times
+  for (i = 0; i < 5; i++) {
+    // Write initial data about length and type to socket
+    rc = writen(ctlSocket, buff, 3);
+    if (rc == 3)  // write completed
+      break;
+    if (rc == 0)  // nothing written yet,
+      continue;
+    if (rc == -1)  // error writing to socket..cannot continue
+      return -1;
+  }
+
+  // Exceeded retries, return as "failed trying to write"
+  if (i == 5)
+    return -3;
+
+  // Now write the actual message
+  for (i = 0; i < 5; i++) {
+    rc = writen(ctlSocket, msg, len);
+    // all the data has been written successfully
+    if (rc == len)
+      break;
+    // data writing not complete, continue
+    if (rc == 0)
+      continue;
+    if (rc == -1)  // error writing to socket, cannot continue writing data
+      return -2;
+  }
+  if (i == 5)
+    return -3;
+  log_println(8, ">>> send_msg: type=%d, len=%d, msg=%s, pid=%d", type, len,
+              msg, getpid());
+
+  protolog_sendprintln(type, msg, len, getpid(), ctlSocket);
+
+  return 0;
 }
 
 /**
@@ -438,40 +437,40 @@ int send_msg(int ctlSocket, int type, void* msg, int len) {
  */
 
 int recv_msg(int ctlSocket, int* type, void* msg, int* len) {
-	unsigned char buff[3];
-	int length;
-
-	char *msgtemp = (char*) msg;
-
-	assert(type);
-	assert(msg);
-	assert(len);
-
-	// if 3 bytes are not explicitly read, signal error
-	if (readn(ctlSocket, buff, 3) != 3) {
-		return -1;
-	}
-
-	// get msg type, and calculate length as sum of the next 2 bytes
-	*type = buff[0];
-	length = buff[1];
-	length = (length << 8) + buff[2];
-
-	// if received buffer size < length as conveyed by buffer contents, then error
-	assert(length <= (*len));
-	if (length > (*len)) {
-		log_println(3, "recv_msg: length [%d] > *len [%d]", length, *len);
-		return -2;
-	}
-	*len = length;
-	if (readn(ctlSocket, msg, length) != length) {
-		return -3;
-	}
-	log_println(8, "<<< recv_msg: type=%d, len=%d", *type, *len);
-
-	protolog_rcvprintln(*type, msgtemp, *len, getpid(), ctlSocket);
-
-	return 0;
+  unsigned char buff[3];
+  int length;
+
+  char *msgtemp = (char*) msg;
+
+  assert(type);
+  assert(msg);
+  assert(len);
+
+  // if 3 bytes are not explicitly read, signal error
+  if (readn(ctlSocket, buff, 3) != 3) {
+    return -1;
+  }
+
+  // get msg type, and calculate length as sum of the next 2 bytes
+  *type = buff[0];
+  length = buff[1];
+  length = (length << 8) + buff[2];
+
+  // if received buffer size < length as conveyed by buffer contents, then error
+  assert(length <= (*len));
+  if (length > (*len)) {
+    log_println(3, "recv_msg: length [%d] > *len [%d]", length, *len);
+    return -2;
+  }
+  *len = length;
+  if (readn(ctlSocket, msg, length) != length) {
+    return -3;
+  }
+  log_println(8, "<<< recv_msg: type=%d, len=%d", *type, *len);
+
+  protolog_rcvprintln(*type, msgtemp, *len, getpid(), ctlSocket);
+
+  return 0;
 }
 
 /**
@@ -483,28 +482,28 @@ int recv_msg(int ctlSocket, int* type, void* msg, int* len) {
  */
 
 int writen(int fd, void* buf, int amount) {
-	int sent, n;
-	char* ptr = buf;
-	sent = 0;
-	assert(amount >= 0);
-	while (sent < amount) {
-		n = write(fd, ptr + sent, amount - sent);
-		if (n == -1) {
-			if (errno == EINTR) // interrupted, retry writing again
-				continue;
-			if (errno != EAGAIN) { // some genuine socket write error
-				log_println(6,
-                                            "writen() Error! write(%d) failed with err='%s(%d) pic=%d'",
-                                            fd, strerror(errno), errno, getpid());
-				return -1;
-			}
-		}
-		assert(n != 0);
-		if (n != -1) { // success writing "n" bytes. Increment total bytes written
-			sent += n;
-		}
-	}
-	return sent;
+  int sent, n;
+  char* ptr = buf;
+  sent = 0;
+  assert(amount >= 0);
+  while (sent < amount) {
+    n = write(fd, ptr + sent, amount - sent);
+    if (n == -1) {
+      if (errno == EINTR)  // interrupted, retry writing again
+        continue;
+      if (errno != EAGAIN) {  // some genuine socket write error
+        log_println(6,
+                    "writen() Error! write(%d) failed with err='%s(%d) pic=%d'",
+                    fd, strerror(errno), errno, getpid());
+        return -1;
+      }
+    }
+    assert(n != 0);
+    if (n != -1) {  // success writing "n" bytes. Increment total bytes written
+      sent += n;
+    }
+  }
+  return sent;
 }
 
 /**
@@ -516,46 +515,47 @@ int writen(int fd, void* buf, int amount) {
  */
 
 int readn(int fd, void* buf, int amount) {
-	int received = 0, n, rc;
-	char* ptr = buf;
-	struct timeval sel_tv;
-	fd_set rfd;
-
-	assert(amount >= 0);
-
-	FD_ZERO(&rfd); // initialize with zeroes
-	FD_SET(fd, &rfd); //
-	sel_tv.tv_sec = 600;
-	sel_tv.tv_usec = 0;
-
-	/* modified readn() routine 11/26/09 - RAC
-	 * addedd in select() call, to timeout if no read occurs after 10 seconds of waiting.
-	 * This should fix a bug where the server hangs at it looks like it's in this read
-	 * state.  The select() should check to see if there is anything to read on this socket.
-	 * if not, and the 3 second timer goes off, exit out and clean up.
-	 */
-	while (received < amount) {
-
-		// check if fd+1 socket is ready to be read
-		rc = select(fd + 1, &rfd, NULL, NULL, &sel_tv);
-		if (rc == 0) { /* A timeout occurred, nothing to read from socket after 3 seconds */
-			log_println(6, "readn() routine timeout occurred, return error signal and kill off child");
-			return received;
-		}
-		if ((rc == -1) && (errno == EINTR)) /* a signal was processed, ignore it */
-			continue;
-		n = read(fd, ptr + received, amount - received);
-		if (n == -1) { // error
-			if (errno == EINTR) // interrupted , try reading again
-				continue;
-			if (errno != EAGAIN) // genuine socket read error, return
-				return -errno;
-		}
-		if (n != -1) { // if no errors reading, increment data byte count
-			received += n;
-		}
-		if (n == 0)
-			return 0;
-	}
-	return received;
+  int received = 0, n, rc;
+  char* ptr = buf;
+  struct timeval sel_tv;
+  fd_set rfd;
+
+  assert(amount >= 0);
+
+  FD_ZERO(&rfd);  // initialize with zeroes
+  FD_SET(fd, &rfd);
+  sel_tv.tv_sec = 600;
+  sel_tv.tv_usec = 0;
+
+  /* modified readn() routine 11/26/09 - RAC
+   * addedd in select() call, to timeout if no read occurs after 10 seconds of waiting.
+   * This should fix a bug where the server hangs at it looks like it's in this read
+   * state.  The select() should check to see if there is anything to read on this socket.
+   * if not, and the 3 second timer goes off, exit out and clean up.
+   */
+  while (received < amount) {
+    // check if fd+1 socket is ready to be read
+    rc = select(fd + 1, &rfd, NULL, NULL, &sel_tv);
+    if (rc == 0) {
+      /* A timeout occurred, nothing to read from socket after 3 seconds */
+      log_println(6, "readn() routine timeout occurred, return error signal "
+                  "and kill off child");
+      return received;
+    }
+    if ((rc == -1) && (errno == EINTR)) /* a signal was processed, ignore it */
+      continue;
+    n = read(fd, ptr + received, amount - received);
+    if (n == -1) {  // error
+      if (errno == EINTR)  // interrupted , try reading again
+        continue;
+      if (errno != EAGAIN)  // genuine socket read error, return
+        return -errno;
+    }
+    if (n != -1) {  // if no errors reading, increment data byte count
+      received += n;
+    }
+    if (n == 0)
+      return 0;
+  }
+  return received;
 }
diff --git a/src/protocol.c b/src/protocol.c
index 6a336fc..f76fa95 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -5,8 +5,8 @@
  * jeremian@poczta.fm
  */
 
-#include "protocol.h"
-#include "logging.h"
+#include "./protocol.h"
+#include "./logging.h"
 
 /**
  * Check if the received msg type is compatible
@@ -21,23 +21,23 @@
  */
 
 int check_msg_type(char* prefix, int expected, int received, char* buff,
-		int len) {
-	// check if expected and received messages are the same
-	if (expected != received) {
-		if (prefix) { // Add prefix to log message
-			log_print(0, "%s: ", prefix);
-		}
-		if (received == MSG_ERROR) { // if Error message was actually received,
-									 // then its not an unexpected message exchange
-			buff[len] = 0; // terminate string
-			log_println(0, "ERROR MSG: %s", buff);
-		} else {
-			// certainly an unexpected message
-			log_println(0, "ERROR: received message type %d (expected %d)",
-					received, expected);
-		}
-		return 1;
-	}
-	// everything is well, return 0
-	return 0;
+                   int len) {
+  // check if expected and received messages are the same
+  if (expected != received) {
+    if (prefix) {  // Add prefix to log message
+      log_print(0, "%s: ", prefix);
+    }
+    if (received == MSG_ERROR) {  // if Error message was actually received,
+      // then its not an unexpected message exchange
+      buff[len] = 0;  // terminate string
+      log_println(0, "ERROR MSG: %s", buff);
+    } else {
+      // certainly an unexpected message
+      log_println(0, "ERROR: received message type %d (expected %d)",
+                  received, expected);
+    }
+    return 1;
+  }
+  // everything is well, return 0
+  return 0;
 }
diff --git a/src/protocol.h b/src/protocol.h
index c309ead..8b65e56 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -6,11 +6,11 @@
  * jeremian@poczta.fm
  */
 
-#ifndef _JS_PROTOCOL_H
-#define _JS_PROTOCOL_H
+#ifndef SRC_PROTOCOL_H_
+#define SRC_PROTOCOL_H_
 
-//new addition after separating out ndtptests header
-#include "ndtptestconstants.h" //protocol validation
+// new addition after separating out ndtptests header
+#include "./ndtptestconstants.h"  // protocol validation
 // Todo could be made into enumeration
 #define COMM_FAILURE 0
 #define SRV_QUEUE 1
@@ -49,6 +49,6 @@
 #define VIEW_DIFF 0.1
 
 int check_msg_type(char* prefix, int expected, int received, char* buff,
-		int len);
+                   int len);
 
-#endif
+#endif  // SRC_PROTOCOL_H_
diff --git a/src/runningtest.c b/src/runningtest.c
index 4814ece..f5a502c 100644
--- a/src/runningtest.c
+++ b/src/runningtest.c
@@ -5,8 +5,8 @@
  *  Created on: Sep 28, 2011
  *      Author: kkumar
  */
-#include "ndtptestconstants.h"
-#include "runningtest.h"
+#include "./ndtptestconstants.h"
+#include "./runningtest.h"
 
 static int currentTest = TEST_NONE;
 static enum Tx_DIRECTION currentDirection = NONE;
@@ -28,7 +28,7 @@ static char *_proctypesarray[] = { "process", "connect" };
  * @return integer current running test Id
  * */
 int getCurrentTest() {
-	return currentTest;
+  return currentTest;
 }
 
 /** Set the id of the currently running test.
@@ -36,7 +36,7 @@ int getCurrentTest() {
  */
 
 void setCurrentTest(int testId) {
-	currentTest = testId;
+  currentTest = testId;
 }
 
 /**
@@ -44,7 +44,7 @@ void setCurrentTest(int testId) {
  * @return integer direction corresponding to an enumerator
  * */
 int getCurrentDirn() {
-	return currentDirection;
+  return currentDirection;
 }
 
 /** Set the test directions for the current process.
@@ -60,25 +60,24 @@ int getCurrentDirn() {
  */
 
 void setCurrentDirn(enum Tx_DIRECTION directionarg) {
-	char currenttestdirn[TEST_DIRN_DESC_SIZE];
-	char othertestdirn[TEST_DIRN_DESC_SIZE];
-	currentDirection = directionarg;
-	switch (currentDirection) {
-	case S_C:
-		senddirnstr = get_testdirectiondesc(currentDirection, currenttestdirn);
-		recvdirnstr = get_testdirectiondesc(C_S, othertestdirn);
-		break;
-	case C_S:
-		senddirnstr = get_testdirectiondesc(currentDirection, currenttestdirn);
-		recvdirnstr = get_testdirectiondesc(S_C, othertestdirn);
-		break;
-	case NO_DIR:
-	default:
-		senddirnstr = get_testdirectiondesc(NO_DIR, currenttestdirn);
-		recvdirnstr = get_testdirectiondesc(NO_DIR, othertestdirn);
-		;
-		break;
-	}
+  char currenttestdirn[TEST_DIRN_DESC_SIZE];
+  char othertestdirn[TEST_DIRN_DESC_SIZE];
+  currentDirection = directionarg;
+  switch (currentDirection) {
+    case S_C:
+      senddirnstr = get_testdirectiondesc(currentDirection, currenttestdirn);
+      recvdirnstr = get_testdirectiondesc(C_S, othertestdirn);
+      break;
+    case C_S:
+      senddirnstr = get_testdirectiondesc(currentDirection, currenttestdirn);
+      recvdirnstr = get_testdirectiondesc(S_C, othertestdirn);
+      break;
+    case NO_DIR:
+    default:
+      senddirnstr = get_testdirectiondesc(NO_DIR, currenttestdirn);
+      recvdirnstr = get_testdirectiondesc(NO_DIR, othertestdirn);
+      break;
+  }
 }
 
 /**
@@ -86,30 +85,30 @@ void setCurrentDirn(enum Tx_DIRECTION directionarg) {
  * @return descriptive name for the currently running test
  */
 char *get_currenttestdesc() {
-	enum TEST_ID currenttestId = NONE;
-	char currenttestdesc[TEST_NAME_DESC_SIZE];
-	switch (getCurrentTest()) {
-	case TEST_MID:
-		currenttestId = MIDDLEBOX;
-		break;
-	case TEST_C2S:
-		currenttestId = C2S;
-		break;
-	case TEST_S2C:
-		currenttestId = S2C;
-		break;
-	case TEST_SFW:
-		currenttestId = SFW;
-		break;
-	case TEST_META:
-		currenttestId = META;
-		break;
-	case TEST_NONE:
-	default:
-		currenttestId = NONE;
-		break;
-	}
-	return get_testnamedesc(currenttestId, currenttestdesc);
+  enum TEST_ID currenttestId = NONE;
+  char currenttestdesc[TEST_NAME_DESC_SIZE];
+  switch (getCurrentTest()) {
+    case TEST_MID:
+      currenttestId = MIDDLEBOX;
+      break;
+    case TEST_C2S:
+      currenttestId = C2S;
+      break;
+    case TEST_S2C:
+      currenttestId = S2C;
+      break;
+    case TEST_SFW:
+      currenttestId = SFW;
+      break;
+    case TEST_META:
+      currenttestId = META;
+      break;
+    case TEST_NONE:
+    default:
+      currenttestId = NONE;
+      break;
+  }
+  return get_testnamedesc(currenttestId, currenttestdesc);
 }
 
 /**
@@ -118,7 +117,7 @@ char *get_currenttestdesc() {
  *  @return char* descriptive text of the current local direction
  *  */
 char *get_currentdirndesc() {
-	return senddirnstr;
+  return senddirnstr;
 }
 
 /**
@@ -127,17 +126,19 @@ char *get_currentdirndesc() {
  *  @return char* descriptive text of the current reverse direction
  *  */
 char *get_otherdirndesc() {
-	return recvdirnstr;
+  return recvdirnstr;
 }
 
 /**
  * get descriptive test for status of process
  *  @return char* descriptive text of the process status
  *  */
-char *get_procstatusdesc(enum PROCESS_STATUS_INT procstatusarg, char *sprocarg) {
-	sprocarg = _procstatusarray[procstatusarg];
-	//log_println(7,"--current process status = %s for %d\n", sprocarg, procstatusarg);
-	return sprocarg;
+char *get_procstatusdesc(enum PROCESS_STATUS_INT procstatusarg,
+                         char *sprocarg) {
+  sprocarg = _procstatusarray[procstatusarg];
+  // log_println(7,"--current process status = %s for %d\n", sprocarg,
+  //  procstatusarg);
+  return sprocarg;
 }
 
 /**
@@ -147,8 +148,7 @@ char *get_procstatusdesc(enum PROCESS_STATUS_INT procstatusarg, char *sprocarg)
  * @return char*  Descriptive string for process (process, connect )
  * */
 char *get_processtypedesc(enum PROCESS_TYPE_INT procidarg, char *snamearg) {
-	snamearg = _proctypesarray[procidarg];
-	//log_println(7,"--current process name = %s for %d\n", snamearg, procidarg);
-	return snamearg;
+  snamearg = _proctypesarray[procidarg];
+  // log_println(7,"--current process name = %s for %d\n", snamearg, procidarg);
+  return snamearg;
 }
-
diff --git a/src/strlutils.c b/src/strlutils.c
index 1db4227..01e0710 100644
--- a/src/strlutils.c
+++ b/src/strlutils.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $	*/
+/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
 
 /*
  * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -25,27 +25,26 @@
  * Returns strlen(src); if retval >= siz, truncation occurred.
  */
 size_t strlcpy(char *dst, const char *src, size_t siz) {
-	char *d = dst;
-	const char *s = src;
-	size_t n = siz;
+  char *d = dst;
+  const char *s = src;
+  size_t n = siz;
 
-	/* Copy as many bytes as will fit */
-	if (n != 0) {
-		while (--n != 0) {
-			if ((*d++ = *s++) == '\0')
-				break;
-		}
-	}
+  /* Copy as many bytes as will fit */
+  if (n != 0) {
+    while (--n != 0) {
+      if ((*d++ = *s++) == '\0')
+        break;
+    }
+  }
 
-	/* Not enough room in dst, add NUL and traverse rest of src */
-	if (n == 0) {
-		if (siz != 0)
-			*d = '\0'; /* NUL-terminate dst */
-		while (*s++)
-			;
-	}
+  /* Not enough room in dst, add NUL and traverse rest of src */
+  if (n == 0) {
+    if (siz != 0)
+      *d = '\0'; /* NUL-terminate dst */
+    while (*s++) { }
+  }
 
-	return (s - src - 1); /* count does not include NUL */
+  return (s - src - 1); /* count does not include NUL */
 }
 
 /*
@@ -56,29 +55,30 @@ size_t strlcpy(char *dst, const char *src, size_t siz) {
  * If retval >= siz, truncation occurred.
  */
 size_t strlcat(dst, src, siz)
-	char *dst;const char *src;size_t siz; {
-	register char *d = dst;
-	register const char *s = src;
-	register size_t n = siz;
-	size_t dlen;
+  char *dst;
+  const char *src;
+  size_t siz; {
+    register char *d = dst;
+    register const char *s = src;
+    register size_t n = siz;
+    size_t dlen;
 
-	/* Find the end of dst and adjust bytes left but don't go past end */
-	while (n-- != 0 && *d != '\0')
-		d++;
-	dlen = d - dst;
-	n = siz - dlen;
+    /* Find the end of dst and adjust bytes left but don't go past end */
+    while (n-- != 0 && *d != '\0')
+      d++;
+    dlen = d - dst;
+    n = siz - dlen;
 
-	if (n == 0)
-		return (dlen + strlen(s));
-	while (*s != '\0') {
-		if (n != 1) {
-			*d++ = *s;
-			n--;
-		}
-		s++;
-	}
-	*d = '\0';
-
-	return (dlen + (s - src)); /* count does not include NUL */
-}
+    if (n == 0)
+      return (dlen + strlen(s));
+    while (*s != '\0') {
+      if (n != 1) {
+        *d++ = *s;
+        n--;
+      }
+      s++;
+    }
+    *d = '\0';
 
+    return (dlen + (s - src)); /* count does not include NUL */
+  }
diff --git a/src/test_c2s_clt.c b/src/test_c2s_clt.c
index 9b89eaf..e4cb10d 100644
--- a/src/test_c2s_clt.c
+++ b/src/test_c2s_clt.c
@@ -42,169 +42,169 @@ double spdout, c2sspd;
  *
  */
 int test_c2s_clt(int ctlSocket, char tests, char* host, int conn_options,
-		int buf_size) {
-	/* char buff[BUFFSIZE+1]; */
-	char buff[64 * KILO_BITS]; // message payload.
-		// note that there is a size variation between server and CLT - do not
-	    // know why this was changed from BUFFZISE, though
-	    // no specific problem is seen due to this
-
-	int msgLen, msgType; // message related data
-	int c2sport = atoi(PORT2); // default C2S port
-	I2Addr sec_addr = NULL;	// server address
-	int retcode;		// return code
-	int one=1;			// socket option store
-	int i, k;			// temporary iterator
-	int outSocket;		// socket descriptor for the outgoing connection
-	double t, stop_time;// test-time indicators
-	// variables used for protocol validation logs
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-	enum TEST_ID testids = C2S;
-
-
-	if (tests & TEST_C2S) {	// C2S test has to be performed
-		struct sigaction new, old;
-		log_println(1, " <-- C2S throughput test -->");
-		setCurrentTest(TEST_C2S);
-		//protocol logs
-		teststatuses = TEST_STARTED;
-		protolog_status(getpid(), testids, teststatuses, ctlSocket);
-
-		msgLen = sizeof(buff);
-
-		// Initially, the server sends a TEST_PREPARE message. Any other message
-		// type, or a message with payload length <0 is unexpected and
-		// indicative of an error
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed prepare message!");
-			return 1;
-		}
-		if (check_msg_type("C2S throughput test", TEST_PREPARE, msgType, buff, msgLen)) {
-			return 2;
-		}
-		if (msgLen <= 0) {
-			log_println(0, "Improper message");
-			return 3;
-		}
-
-		// Server sends port number to bind to in the TEST_PREPARE. Check if this
-		// message body (string) is a valid integral port number.
-		buff[msgLen] = 0;
-		if (check_int(buff, &c2sport)) {
-			log_println(0, "Invalid port number");
-			return 4;
-		}
-		log_println(1, "  -- port: %d", c2sport);
-
-		// make struct of "address details" of the server using the host name
-		if ((sec_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
-			log_println(0, "Unable to resolve server address: %s", strerror(errno));
-			return -3;
-		}
-		I2AddrSetPort(sec_addr, c2sport); //set port value
-
-		// connect to server  and set socket options
-		if ((retcode = CreateConnectSocket(&outSocket, NULL, sec_addr, conn_options, buf_size))) {
-			log_println(0, "Connect() for client to server failed", strerror(errno));
-			return -11;
-		}
-
-		setsockopt(outSocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
-
-		// Expect a TEST_START message from server now. Any other message
-		// type is an error
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed start message!");
-			return 1;
-		}
-		if (check_msg_type("C2S throughput test", TEST_START, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// Prepare for running a C->S throughput test
-		printf("running 10s outbound test (client to server) . . . . . ");
-		fflush(stdout);
-
-		// ....Fill buffer upto NDTConstants.PREDEFNED_BUFFER_SIZE packets
-		pkts = 0;
-		k = 0;
-		for (i=0; i<(64*KILO_BITS); i++) { // again buffer sizes differ. Since the actual
-									// transmitted byte count is timed, it does'nt appear that it is
-									// causing specific problems.
-			while (!isprint(k&0x7f))
-				k++;
-			buff[i] = (k++ % 0x7f);
-		}
-
-		// set the test time to 10 seconds
-		t = secs();
-		stop_time = t + 10;
-		/* ignore the pipe signal */
-		memset(&new, 0, sizeof(new));
-		new.sa_handler = SIG_IGN;
-		sigaction(SIGPIPE, &new, &old);
-
-		// While the 10 s timer ticks, stream data to server. Record the byte count
-		do {
-			write(outSocket, buff, lth);
-			pkts++;
-		}while (secs() < stop_time);
-		sigaction(SIGPIPE, &old, NULL);
-		sndqueue = sndq_len(outSocket); //get send-queue length
-
-		// get actual duration for which data was sent to the server
-		t = secs() - t;
-		I2AddrFree(sec_addr);
-
-		// Calculate C2S throughput in kbps
-		spdout = ((BITS_8_FLOAT * pkts * lth) / KILO) / t;
-		//log_println(6," ---C->S CLT speed=%0.0f, pkts= %d, lth=%d, time=%d", spdout, pkts, lth, t);
-
-
-		// The client has stopped streaming data, and the server is now
-		// expected to send a TEST_MSG message with the throughput it calculated.
-		// So, its time now to receive this throughput (c2sspd).
-
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed text message!");
-			return 1;
-		}
-		if (check_msg_type("C2S throughput test", TEST_MSG, msgType, buff, msgLen)) {
-			// other message types at this juncture indicate error
-			return 2;
-		}
-		if (msgLen <= 0) {	// message payload size cannot be negative! Error.
-			log_println(0, "Improper message");
-			return 3;
-		}
-		buff[msgLen] = 0;
-
-		// get C->S test speed as calculated by server
-		c2sspd = atoi(buff);
-
-		// Print results in the most convenient units (kbps or Mbps)
-		if (c2sspd < KILO)
-			printf(" %0.2f kb/s\n", c2sspd);
-		else
-			printf(" %0.2f Mb/s\n", c2sspd/KILO);
-
-		// Server should close test session with an empty TEST_FINALIZE message.
-		// Any other type of message is an error.
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed finalize message!");
-			return 1;
-		}
-		if (check_msg_type("C2S throughput test", TEST_FINALIZE, msgType, buff, msgLen)) {
-			return 2;
-		}
-		log_println(1, " <------------------------->");
-		//log protocol validation logs
-		teststatuses = TEST_ENDED;
-		protolog_status(getpid(), testids, teststatuses,ctlSocket);
-		setCurrentTest(TEST_NONE);
-	}
-	return 0;
+                 int buf_size) {
+  /* char buff[BUFFSIZE+1]; */
+  char buff[64 * KILO_BITS]; // message payload.
+  // note that there is a size variation between server and CLT - do not
+  // know why this was changed from BUFFZISE, though
+  // no specific problem is seen due to this
+
+  int msgLen, msgType; // message related data
+  int c2sport = atoi(PORT2); // default C2S port
+  I2Addr sec_addr = NULL;	// server address
+  int retcode;		// return code
+  int one=1;			// socket option store
+  int i, k;			// temporary iterator
+  int outSocket;		// socket descriptor for the outgoing connection
+  double t, stop_time;// test-time indicators
+  // variables used for protocol validation logs
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+  enum TEST_ID testids = C2S;
+
+
+  if (tests & TEST_C2S) {	// C2S test has to be performed
+    struct sigaction new, old;
+    log_println(1, " <-- C2S throughput test -->");
+    setCurrentTest(TEST_C2S);
+    //protocol logs
+    teststatuses = TEST_STARTED;
+    protolog_status(getpid(), testids, teststatuses, ctlSocket);
+
+    msgLen = sizeof(buff);
+
+    // Initially, the server sends a TEST_PREPARE message. Any other message
+    // type, or a message with payload length <0 is unexpected and
+    // indicative of an error
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed prepare message!");
+      return 1;
+    }
+    if (check_msg_type("C2S throughput test", TEST_PREPARE, msgType, buff, msgLen)) {
+      return 2;
+    }
+    if (msgLen <= 0) {
+      log_println(0, "Improper message");
+      return 3;
+    }
+
+    // Server sends port number to bind to in the TEST_PREPARE. Check if this
+    // message body (string) is a valid integral port number.
+    buff[msgLen] = 0;
+    if (check_int(buff, &c2sport)) {
+      log_println(0, "Invalid port number");
+      return 4;
+    }
+    log_println(1, "  -- port: %d", c2sport);
+
+    // make struct of "address details" of the server using the host name
+    if ((sec_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
+      log_println(0, "Unable to resolve server address: %s", strerror(errno));
+      return -3;
+    }
+    I2AddrSetPort(sec_addr, c2sport); //set port value
+
+    // connect to server  and set socket options
+    if ((retcode = CreateConnectSocket(&outSocket, NULL, sec_addr, conn_options, buf_size))) {
+      log_println(0, "Connect() for client to server failed", strerror(errno));
+      return -11;
+    }
+
+    setsockopt(outSocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+
+    // Expect a TEST_START message from server now. Any other message
+    // type is an error
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed start message!");
+      return 1;
+    }
+    if (check_msg_type("C2S throughput test", TEST_START, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // Prepare for running a C->S throughput test
+    printf("running 10s outbound test (client to server) . . . . . ");
+    fflush(stdout);
+
+    // ....Fill buffer upto NDTConstants.PREDEFNED_BUFFER_SIZE packets
+    pkts = 0;
+    k = 0;
+    for (i=0; i<(64*KILO_BITS); i++) { // again buffer sizes differ. Since the actual
+      // transmitted byte count is timed, it does'nt appear that it is
+      // causing specific problems.
+      while (!isprint(k&0x7f))
+        k++;
+      buff[i] = (k++ % 0x7f);
+    }
+
+    // set the test time to 10 seconds
+    t = secs();
+    stop_time = t + 10;
+    /* ignore the pipe signal */
+    memset(&new, 0, sizeof(new));
+    new.sa_handler = SIG_IGN;
+    sigaction(SIGPIPE, &new, &old);
+
+    // While the 10 s timer ticks, stream data to server. Record the byte count
+    do {
+      write(outSocket, buff, lth);
+      pkts++;
+    }while (secs() < stop_time);
+    sigaction(SIGPIPE, &old, NULL);
+    sndqueue = sndq_len(outSocket); //get send-queue length
+
+    // get actual duration for which data was sent to the server
+    t = secs() - t;
+    I2AddrFree(sec_addr);
+
+    // Calculate C2S throughput in kbps
+    spdout = ((BITS_8_FLOAT * pkts * lth) / KILO) / t;
+    //log_println(6," ---C->S CLT speed=%0.0f, pkts= %d, lth=%d, time=%d", spdout, pkts, lth, t);
+
+
+    // The client has stopped streaming data, and the server is now
+    // expected to send a TEST_MSG message with the throughput it calculated.
+    // So, its time now to receive this throughput (c2sspd).
+
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed text message!");
+      return 1;
+    }
+    if (check_msg_type("C2S throughput test", TEST_MSG, msgType, buff, msgLen)) {
+      // other message types at this juncture indicate error
+      return 2;
+    }
+    if (msgLen <= 0) {	// message payload size cannot be negative! Error.
+      log_println(0, "Improper message");
+      return 3;
+    }
+    buff[msgLen] = 0;
+
+    // get C->S test speed as calculated by server
+    c2sspd = atoi(buff);
+
+    // Print results in the most convenient units (kbps or Mbps)
+    if (c2sspd < KILO)
+      printf(" %0.2f kb/s\n", c2sspd);
+    else
+      printf(" %0.2f Mb/s\n", c2sspd/KILO);
+
+    // Server should close test session with an empty TEST_FINALIZE message.
+    // Any other type of message is an error.
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed finalize message!");
+      return 1;
+    }
+    if (check_msg_type("C2S throughput test", TEST_FINALIZE, msgType, buff, msgLen)) {
+      return 2;
+    }
+    log_println(1, " <------------------------->");
+    //log protocol validation logs
+    teststatuses = TEST_ENDED;
+    protolog_status(getpid(), testids, teststatuses,ctlSocket);
+    setCurrentTest(TEST_NONE);
+  }
+  return 0;
 }
diff --git a/src/test_c2s_srv.c b/src/test_c2s_srv.c
index 38b85c9..0340d0b 100644
--- a/src/test_c2s_srv.c
+++ b/src/test_c2s_srv.c
@@ -61,383 +61,383 @@ int mon_pipe1[2]; // used to store file descriptors of pipes created for ndttrac
  *
  */
 int test_c2s(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
-		int conn_options, double* c2sspd, int set_buff, int window,
-		int autotune, char* device, Options* options, int record_reverse,
-		int count_vars, char spds[4][256], int* spd_index) {
-	int recvsfd; // receiver socket file descriptor
-	pid_t c2s_childpid = 0; // child process pids
-	int msgretvalue, tmpbytecount; // used during the "read"/"write" process
-	int i, j; // used as loop iterators
-
-	struct sockaddr_storage cli_addr;
-
-	socklen_t clilen;
-	char tmpstr[256]; // string array used for all sorts of temp storage purposes
-	double tmptime; // time indicator
-	double bytes_read = 0; // number of bytes read during the throughput tests
-	struct timeval sel_tv; // time
-	fd_set rfd; // receive file descriptor
-	char buff[BUFFSIZE + 1]; // message "payload" buffer
-	PortPair 	pair; // socket ports
-	I2Addr c2ssrv_addr = NULL; // c2s test's server address
-	//I2Addr src_addr=NULL;			// c2s test source address
-	char listenc2sport[10]; // listening port
-	pthread_t workerThreadId;
-
-	// web_100 related variables
-	web100_group* group = NULL;
-	web100_connection* conn = NULL;
-
-	// snap related variables
-	SnapArgs snapArgs;
-	snapArgs.snap = NULL;
-	snapArgs.log = NULL;
-	snapArgs.delay = options->snapDelay;
-	wait_sig = 0;
-
-	// Test ID and status descriptors
-	enum TEST_ID testids = C2S;
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-	enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
-	enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
-	char namesuffix[256] = "c2s_snaplog";
-
-	if (testOptions->c2sopt) {
-		setCurrentTest(TEST_C2S);
-		log_println(1, " <-- %d - C2S throughput test -->",
-				testOptions->child0);
-		strlcpy(listenc2sport, PORT2, sizeof(listenc2sport));
-
-		//log protocol validation logs
-		teststatuses = TEST_STARTED;
-		protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);
-
-		// Determine port to be used. Compute based on options set earlier
-		// by reading from config file, or use default port2 (3002).
-		if (testOptions->c2ssockport) {
-			snprintf(listenc2sport, sizeof(listenc2sport), "%d", testOptions->c2ssockport);
-		} else if (testOptions->mainport) {
-			snprintf(listenc2sport, sizeof(listenc2sport), "%d", testOptions->mainport + 1);
-		}
-
-		if (testOptions->multiple) {
-			strlcpy(listenc2sport, "0", sizeof(listenc2sport));
-		}
-
-		// attempt to bind to a new port and obtain address structure with details of listening port
-		while (c2ssrv_addr == NULL) {
-			c2ssrv_addr = CreateListenSocket(
-				NULL,
-				(testOptions->multiple ?
-				 	mrange_next(listenc2sport, sizeof(listenc2sport)) : listenc2sport),
-				conn_options, 0)
-							;
-			if (strcmp(listenc2sport, "0") == 0) {
-				log_println(0, "WARNING: ephemeral port number was bound");
-				break;
-			}
-			if (testOptions->multiple == 0) {
-				break;
-			}
-		}
-		if (c2ssrv_addr == NULL) {
-			log_println(
-					0,
-					"Server (C2S throughput test): CreateListenSocket failed: %s",
-					strerror(errno));
-			snprintf(buff,
-				sizeof(buff),
-				"Server (C2S throughput test): CreateListenSocket failed: %s",
-				strerror(errno));
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return -1;
-		}
-
-		// get socket FD and the ephemeral port number that client will connect to run tests
-		testOptions->c2ssockfd = I2AddrFD(c2ssrv_addr);
-		testOptions->c2ssockport = I2AddrPort(c2ssrv_addr);
-		log_println(1, "  -- port: %d", testOptions->c2ssockport);
-		pair.port1 = testOptions->c2ssockport;
-		pair.port2 = -1;
-
-		log_println(
-				1,
-				"listening for Inet connection on testOptions->c2ssockfd, fd=%d",
-				testOptions->c2ssockfd);
-
-		log_println(
-				1,
-				"Sending 'GO' signal, to tell client %d to head for the next test",
-				testOptions->child0);
-		snprintf(buff, sizeof(buff), "%d", testOptions->c2ssockport);
-
-		// send TEST_PREPARE message with ephemeral port detail, indicating start of tests
-		if ((msgretvalue = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff))) < 0)
-			return msgretvalue;
-
-		// Wait on listening socket and read data once ready.
-		// Retry 5 times,  waiting for activity on the socket
-		clilen = sizeof(cli_addr);
-		log_println(6, "child %d - sent c2s prepare to client",
-				testOptions->child0);
-		FD_ZERO(&rfd);
-		FD_SET(testOptions->c2ssockfd, &rfd);
-		sel_tv.tv_sec = 5;
-		sel_tv.tv_usec = 0;
-
-		for (j = 0; j < RETRY_COUNT; j++) {
-			msgretvalue = select((testOptions->c2ssockfd) + 1, &rfd, NULL, NULL,
-					&sel_tv);
-			if ((msgretvalue == -1) && (errno == EINTR)) // socket interrupted. continue waiting for activity on socket
-				continue;
-			if (msgretvalue == 0) // timeout
-				return -SOCKET_CONNECT_TIMEOUT;
-			if (msgretvalue < 0) // other socket errors. exit
-				return -errno;
-			if (j == (RETRY_COUNT - 1)) // retry exceeded. exit
-				return -RETRY_EXCEEDED_WAITING_CONNECT;
-			recfd:
-
-			// If a valid connection request is received, client has connected. Proceed.
-			// Note the new socket fd - recvsfd- used in the throughput test
-			recvsfd = accept(testOptions->c2ssockfd,
-					(struct sockaddr *) &cli_addr, &clilen);
-			if (recvsfd > 0) {
-				log_println(6, "accept() for %d completed",
-						testOptions->child0);
-
-				// log protocol validation indicating client accept
-				procstatusenum = PROCESS_STARTED;
-				proctypeenum = CONNECT_TYPE;
-				protolog_procstatus(testOptions->child0, testids, proctypeenum,
-						procstatusenum, recvsfd);
-				break;
-			}
-			if ((recvsfd == -1) && (errno == EINTR)) { // socket interrupted, wait some more
-				log_println(
-						6,
-						"Child %d interrupted while waiting for accept() to complete",
-						testOptions->child0);
-				goto recfd;
-			}
-			log_println(
-					6,
-					"-------     C2S connection setup for %d returned because (%d)",
-					testOptions->child0, errno);
-			if (recvsfd < 0) { // other socket errors, 	quit
-				return -errno;
-			}
-			if (j == (RETRY_COUNT - 1)) { // retry exceeded, quit
-				log_println(
-						6,
-						"c2s child %d, uable to open connection, return from test",
-						testOptions->child0);
-				return RETRY_EXCEEDED_WAITING_DATA;
-			}
-		}
-
-		// Get address associated with the throughput test. Used for packet tracing
-		log_println(6, "child %d - c2s ready for test with fd=%d",
-				testOptions->child0, recvsfd);
-
-		// commenting out below to move to init_pkttrace function
-		I2Addr src_addr = I2AddrByLocalSockFD(get_errhandle(), recvsfd, 0);
-
-		// Get web100 connection. Used to collect web100 variable statistics
-		conn = web100_connection_from_socket(agent, recvsfd);
-
-		// set up packet tracing. Collected data is used for bottleneck link calculations
-		if (getuid() == 0) {
-			/*
-			pipe(mon_pipe1);
-			log_println(0, "%s test calling pkt_trace_start() with pd=%d for device %s, addr %s",
-					currenttestdesc, clilen, device , src_addr);
-
-			start_packet_trace(recvsfd, testOptions->c2ssockfd, &c2s_childpid,
-								mon_pipe1, (struct sockaddr *) &cli_addr, clilen, device,
-								&pair, currenttestdesc, options->compress, meta.c2s_ndttrace);
-			*/
-
-			pipe(mon_pipe1);
-			if ((c2s_childpid = fork()) == 0) {
-				/* close(ctlsockfd); */
-				close(testOptions->c2ssockfd);
-				close(recvsfd);
-				log_println(
-						5,
-						"C2S test Child %d thinks pipe() returned fd0=%d, fd1=%d",
-						testOptions->child0, mon_pipe1[0], mon_pipe1[1]);
-			    log_println(2, "C2S test calling init_pkttrace() with pd=%p", &cli_addr);
-				init_pkttrace(src_addr, (struct sockaddr *) &cli_addr, clilen,
-						mon_pipe1, device, &pair, "c2s", options->compress);
-				exit(0); /* Packet trace finished, terminate gracefully */
-			}
-
-			// Get data collected from packet tracing into the C2S "ndttrace" file
-			memset(tmpstr, 0, 256);
-			for (i = 0; i < 5; i++) {
-				msgretvalue = read(mon_pipe1[0], tmpstr, 128);
-				if ((msgretvalue == -1) && (errno == EINTR))
-					continue;
-				break;
-			}
-			if (strlen(tmpstr) > 5)
-				memcpy(meta.c2s_ndttrace, tmpstr, strlen(tmpstr));
-			//name of nettrace file passed back from pcap child
-
-			log_println(3, "--tracefile after packet_trace %s",
-					meta.c2s_ndttrace);
-		}
-
-		log_println(5, "C2S test Parent thinks pipe() returned fd0=%d, fd1=%d",
-				mon_pipe1[0], mon_pipe1[1]);
-
-		// experimental code, delete when finished
-		setCwndlimit(conn, group, agent, options);
-
-		// Create C->S snaplog directories, and perform some initialization based on options
-
-		create_client_logdir((struct sockaddr *) &cli_addr, clilen,
-				options->c2s_logname, sizeof(options->c2s_logname), namesuffix,
-				sizeof(namesuffix));
-		sleep(2);
-
-		// send empty TEST_START indicating start of the test
-		send_msg(ctlsockfd, TEST_START, "", 0);
-		/* alarm(30); *//* reset alarm() again, this 10 sec test should finish before this signal
-		 * is generated.  */
-
-		// If snaplog recording is enabled, update meta file to indicate the same
-		//  and proceed to get snapshot and log it. 
-		// This block is needed here since the meta file stores names without the full directory
-		// but fopen needs full path. Else, it could have gone into the "start_snap_worker" method 
-		if (options->snaplog) {
-			memcpy(meta.c2s_snaplog, namesuffix, strlen(namesuffix));
-			/*start_snap_worker(&snapArgs, agent, options->snaplog, &workerLoop,
-					&workerThreadId, meta.c2s_snaplog, options->c2s_logname,
-					conn, group); */
-		}
-		start_snap_worker(&snapArgs, agent, NULL, options->snaplog, &workerThreadId,
-					meta.c2s_snaplog, options->c2s_logname,	conn, group); 
-		// Wait on listening socket and read data once ready.
-		tmptime = secs();
-		sel_tv.tv_sec = 11; // time out after 11 seconds
-		sel_tv.tv_usec = 0;
-		FD_ZERO(&rfd);
-		FD_SET(recvsfd, &rfd);
-		for (;;) {
-			msgretvalue = select(recvsfd + 1, &rfd, NULL, NULL, &sel_tv);
-			if ((msgretvalue == -1) && (errno == EINTR)) {
-				// socket interrupted. Continue waiting for activity on socket
-				continue;
-			}
-			if (msgretvalue > 0) { // read from socket
-				tmpbytecount = read(recvsfd, buff, sizeof(buff));
-				if ((tmpbytecount == -1) && (errno == EINTR)) // read interrupted,continue waiting
-					continue;
-				if (tmpbytecount == 0) // all data has been read
-					break;
-				bytes_read += tmpbytecount; // data byte count has to be increased
-				continue;
-			}
-			break;
-		}
-
-		tmptime = secs() - tmptime;
-		//  throughput in kilo bits per sec = (transmitted_byte_count * 8) / (time_duration)*(1000)
-		*c2sspd = (8.e-3 * bytes_read) / tmptime;
-
-		// c->s throuput value calculated and assigned ! Release resources, conclude snap writing.
-		stop_snap_worker(&workerThreadId, options->snaplog, &snapArgs);
-
-		// send the server calculated value of C->S throughput as result to client
-		snprintf(buff, sizeof(buff), "%6.0f kbps outbound for child %d", *c2sspd,
-				testOptions->child0);
-		log_println(1, "%s", buff);
-		snprintf(buff, sizeof(buff), "%0.0f", *c2sspd);
-		send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-
-		// get receiver side Web100 stats and write them to the log file. close sockets
-		if (record_reverse == 1)
-			web100_get_data_recv(recvsfd, agent, conn, count_vars);
-
-		close(recvsfd);
-		close(testOptions->c2ssockfd);
-
-		// Next, send speed-chk a flag to retrieve the data it collected.
-		// Skip this step if speed-chk isn't running.
-
-		if (getuid() == 0) {
-			log_println(1, "Signal USR1(%d) sent to child [%d]", SIGUSR1,
-					c2s_childpid);
-			testOptions->child1 = c2s_childpid;
-			kill(c2s_childpid, SIGUSR1);
-			FD_ZERO(&rfd);
-			FD_SET(mon_pipe1[0], &rfd);
-			sel_tv.tv_sec = 1;
-			sel_tv.tv_usec = 100000;
-			i = 0;
-
-			for (;;) {
-				msgretvalue = select(mon_pipe1[0] + 1, &rfd, NULL, NULL,
-						&sel_tv);
-				if ((msgretvalue == -1) && (errno == EINTR))
-					continue;
-				if (((msgretvalue == -1) && (errno != EINTR))
-						|| (msgretvalue == 0)) {
-					log_println(4,
-						"Failed to read pkt-pair data from C2S flow, retcode=%d, reason=%d",
-						msgretvalue, errno);
-					snprintf(spds[(*spd_index)++],
-						sizeof(spds[*spd_index]),
-						" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
-					snprintf(spds[(*spd_index)++],
-						sizeof(spds[*spd_index]),
-						" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
-					break;
-				}
-				/* There is something to read, so get it from the pktpair child.  If an interrupt occurs,
-				 * just skip the read and go on
-				 * RAC 2/8/10
-				 */
-				if (msgretvalue > 0) {
-					if ((msgretvalue = read(mon_pipe1[0], spds[*spd_index], sizeof(spds[*spd_index])))
-							< 0)
-						snprintf(
-								spds[*spd_index],
-								sizeof(spds[*spd_index]),
-								" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
-					log_println(1, "%d bytes read '%s' from C2S monitor pipe",
-							msgretvalue, spds[*spd_index]);
-					(*spd_index)++;
-					if (i++ == 1)
-						break;
-					sel_tv.tv_sec = 1;
-					sel_tv.tv_usec = 100000;
-					continue;
-				}
-
-			}
-		}
-
-		// An empty TEST_FINALIZE message is sent to conclude the test
-		send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
-
-		//  Close opened resources for packet capture
-		if (getuid() == 0) {
-			stop_packet_trace(mon_pipe1);
-		}
-
-		// log end of C->S test
-		log_println(1, " <----------- %d -------------->", testOptions->child0);
-		//protocol logs
-		teststatuses = TEST_ENDED;
-		protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);
-
-		//set current test status and free address
-		setCurrentTest(TEST_NONE);
-
-	}
-
-	return 0;
+             int conn_options, double* c2sspd, int set_buff, int window,
+             int autotune, char* device, Options* options, int record_reverse,
+             int count_vars, char spds[4][256], int* spd_index) {
+  int recvsfd; // receiver socket file descriptor
+  pid_t c2s_childpid = 0; // child process pids
+  int msgretvalue, tmpbytecount; // used during the "read"/"write" process
+  int i, j; // used as loop iterators
+
+  struct sockaddr_storage cli_addr;
+
+  socklen_t clilen;
+  char tmpstr[256]; // string array used for all sorts of temp storage purposes
+  double tmptime; // time indicator
+  double bytes_read = 0; // number of bytes read during the throughput tests
+  struct timeval sel_tv; // time
+  fd_set rfd; // receive file descriptor
+  char buff[BUFFSIZE + 1]; // message "payload" buffer
+  PortPair 	pair; // socket ports
+  I2Addr c2ssrv_addr = NULL; // c2s test's server address
+  //I2Addr src_addr=NULL;			// c2s test source address
+  char listenc2sport[10]; // listening port
+  pthread_t workerThreadId;
+
+  // web_100 related variables
+  web100_group* group = NULL;
+  web100_connection* conn = NULL;
+
+  // snap related variables
+  SnapArgs snapArgs;
+  snapArgs.snap = NULL;
+  snapArgs.log = NULL;
+  snapArgs.delay = options->snapDelay;
+  wait_sig = 0;
+
+  // Test ID and status descriptors
+  enum TEST_ID testids = C2S;
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+  enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
+  enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
+  char namesuffix[256] = "c2s_snaplog";
+
+  if (testOptions->c2sopt) {
+    setCurrentTest(TEST_C2S);
+    log_println(1, " <-- %d - C2S throughput test -->",
+                testOptions->child0);
+    strlcpy(listenc2sport, PORT2, sizeof(listenc2sport));
+
+    //log protocol validation logs
+    teststatuses = TEST_STARTED;
+    protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);
+
+    // Determine port to be used. Compute based on options set earlier
+    // by reading from config file, or use default port2 (3002).
+    if (testOptions->c2ssockport) {
+      snprintf(listenc2sport, sizeof(listenc2sport), "%d", testOptions->c2ssockport);
+    } else if (testOptions->mainport) {
+      snprintf(listenc2sport, sizeof(listenc2sport), "%d", testOptions->mainport + 1);
+    }
+
+    if (testOptions->multiple) {
+      strlcpy(listenc2sport, "0", sizeof(listenc2sport));
+    }
+
+    // attempt to bind to a new port and obtain address structure with details of listening port
+    while (c2ssrv_addr == NULL) {
+      c2ssrv_addr = CreateListenSocket(
+          NULL,
+          (testOptions->multiple ?
+           mrange_next(listenc2sport, sizeof(listenc2sport)) : listenc2sport),
+          conn_options, 0)
+          ;
+      if (strcmp(listenc2sport, "0") == 0) {
+        log_println(0, "WARNING: ephemeral port number was bound");
+        break;
+      }
+      if (testOptions->multiple == 0) {
+        break;
+      }
+    }
+    if (c2ssrv_addr == NULL) {
+      log_println(
+          0,
+          "Server (C2S throughput test): CreateListenSocket failed: %s",
+          strerror(errno));
+      snprintf(buff,
+               sizeof(buff),
+               "Server (C2S throughput test): CreateListenSocket failed: %s",
+               strerror(errno));
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return -1;
+    }
+
+    // get socket FD and the ephemeral port number that client will connect to run tests
+    testOptions->c2ssockfd = I2AddrFD(c2ssrv_addr);
+    testOptions->c2ssockport = I2AddrPort(c2ssrv_addr);
+    log_println(1, "  -- port: %d", testOptions->c2ssockport);
+    pair.port1 = testOptions->c2ssockport;
+    pair.port2 = -1;
+
+    log_println(
+        1,
+        "listening for Inet connection on testOptions->c2ssockfd, fd=%d",
+        testOptions->c2ssockfd);
+
+    log_println(
+        1,
+        "Sending 'GO' signal, to tell client %d to head for the next test",
+        testOptions->child0);
+    snprintf(buff, sizeof(buff), "%d", testOptions->c2ssockport);
+
+    // send TEST_PREPARE message with ephemeral port detail, indicating start of tests
+    if ((msgretvalue = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff))) < 0)
+      return msgretvalue;
+
+    // Wait on listening socket and read data once ready.
+    // Retry 5 times,  waiting for activity on the socket
+    clilen = sizeof(cli_addr);
+    log_println(6, "child %d - sent c2s prepare to client",
+                testOptions->child0);
+    FD_ZERO(&rfd);
+    FD_SET(testOptions->c2ssockfd, &rfd);
+    sel_tv.tv_sec = 5;
+    sel_tv.tv_usec = 0;
+
+    for (j = 0; j < RETRY_COUNT; j++) {
+      msgretvalue = select((testOptions->c2ssockfd) + 1, &rfd, NULL, NULL,
+                           &sel_tv);
+      if ((msgretvalue == -1) && (errno == EINTR)) // socket interrupted. continue waiting for activity on socket
+        continue;
+      if (msgretvalue == 0) // timeout
+        return -SOCKET_CONNECT_TIMEOUT;
+      if (msgretvalue < 0) // other socket errors. exit
+        return -errno;
+      if (j == (RETRY_COUNT - 1)) // retry exceeded. exit
+        return -RETRY_EXCEEDED_WAITING_CONNECT;
+recfd:
+
+      // If a valid connection request is received, client has connected. Proceed.
+      // Note the new socket fd - recvsfd- used in the throughput test
+      recvsfd = accept(testOptions->c2ssockfd,
+                       (struct sockaddr *) &cli_addr, &clilen);
+      if (recvsfd > 0) {
+        log_println(6, "accept() for %d completed",
+                    testOptions->child0);
+
+        // log protocol validation indicating client accept
+        procstatusenum = PROCESS_STARTED;
+        proctypeenum = CONNECT_TYPE;
+        protolog_procstatus(testOptions->child0, testids, proctypeenum,
+                            procstatusenum, recvsfd);
+        break;
+      }
+      if ((recvsfd == -1) && (errno == EINTR)) { // socket interrupted, wait some more
+        log_println(
+            6,
+            "Child %d interrupted while waiting for accept() to complete",
+            testOptions->child0);
+        goto recfd;
+      }
+      log_println(
+          6,
+          "-------     C2S connection setup for %d returned because (%d)",
+          testOptions->child0, errno);
+      if (recvsfd < 0) { // other socket errors, 	quit
+        return -errno;
+      }
+      if (j == (RETRY_COUNT - 1)) { // retry exceeded, quit
+        log_println(
+            6,
+            "c2s child %d, uable to open connection, return from test",
+            testOptions->child0);
+        return RETRY_EXCEEDED_WAITING_DATA;
+      }
+    }
+
+    // Get address associated with the throughput test. Used for packet tracing
+    log_println(6, "child %d - c2s ready for test with fd=%d",
+                testOptions->child0, recvsfd);
+
+    // commenting out below to move to init_pkttrace function
+    I2Addr src_addr = I2AddrByLocalSockFD(get_errhandle(), recvsfd, 0);
+
+    // Get web100 connection. Used to collect web100 variable statistics
+    conn = web100_connection_from_socket(agent, recvsfd);
+
+    // set up packet tracing. Collected data is used for bottleneck link calculations
+    if (getuid() == 0) {
+      /*
+         pipe(mon_pipe1);
+         log_println(0, "%s test calling pkt_trace_start() with pd=%d for device %s, addr %s",
+         currenttestdesc, clilen, device , src_addr);
+
+         start_packet_trace(recvsfd, testOptions->c2ssockfd, &c2s_childpid,
+         mon_pipe1, (struct sockaddr *) &cli_addr, clilen, device,
+         &pair, currenttestdesc, options->compress, meta.c2s_ndttrace);
+         */
+
+      pipe(mon_pipe1);
+      if ((c2s_childpid = fork()) == 0) {
+        /* close(ctlsockfd); */
+        close(testOptions->c2ssockfd);
+        close(recvsfd);
+        log_println(
+            5,
+            "C2S test Child %d thinks pipe() returned fd0=%d, fd1=%d",
+            testOptions->child0, mon_pipe1[0], mon_pipe1[1]);
+        log_println(2, "C2S test calling init_pkttrace() with pd=%p", &cli_addr);
+        init_pkttrace(src_addr, (struct sockaddr *) &cli_addr, clilen,
+                      mon_pipe1, device, &pair, "c2s", options->compress);
+        exit(0); /* Packet trace finished, terminate gracefully */
+      }
+
+      // Get data collected from packet tracing into the C2S "ndttrace" file
+      memset(tmpstr, 0, 256);
+      for (i = 0; i < 5; i++) {
+        msgretvalue = read(mon_pipe1[0], tmpstr, 128);
+        if ((msgretvalue == -1) && (errno == EINTR))
+          continue;
+        break;
+      }
+      if (strlen(tmpstr) > 5)
+        memcpy(meta.c2s_ndttrace, tmpstr, strlen(tmpstr));
+      //name of nettrace file passed back from pcap child
+
+      log_println(3, "--tracefile after packet_trace %s",
+                  meta.c2s_ndttrace);
+    }
+
+    log_println(5, "C2S test Parent thinks pipe() returned fd0=%d, fd1=%d",
+                mon_pipe1[0], mon_pipe1[1]);
+
+    // experimental code, delete when finished
+    setCwndlimit(conn, group, agent, options);
+
+    // Create C->S snaplog directories, and perform some initialization based on options
+
+    create_client_logdir((struct sockaddr *) &cli_addr, clilen,
+                         options->c2s_logname, sizeof(options->c2s_logname), namesuffix,
+                         sizeof(namesuffix));
+    sleep(2);
+
+    // send empty TEST_START indicating start of the test
+    send_msg(ctlsockfd, TEST_START, "", 0);
+    /* alarm(30); *//* reset alarm() again, this 10 sec test should finish before this signal
+     * is generated.  */
+
+    // If snaplog recording is enabled, update meta file to indicate the same
+    //  and proceed to get snapshot and log it. 
+    // This block is needed here since the meta file stores names without the full directory
+    // but fopen needs full path. Else, it could have gone into the "start_snap_worker" method 
+    if (options->snaplog) {
+      memcpy(meta.c2s_snaplog, namesuffix, strlen(namesuffix));
+      /*start_snap_worker(&snapArgs, agent, options->snaplog, &workerLoop,
+        &workerThreadId, meta.c2s_snaplog, options->c2s_logname,
+        conn, group); */
+    }
+    start_snap_worker(&snapArgs, agent, NULL, options->snaplog, &workerThreadId,
+                      meta.c2s_snaplog, options->c2s_logname,	conn, group); 
+    // Wait on listening socket and read data once ready.
+    tmptime = secs();
+    sel_tv.tv_sec = 11; // time out after 11 seconds
+    sel_tv.tv_usec = 0;
+    FD_ZERO(&rfd);
+    FD_SET(recvsfd, &rfd);
+    for (;;) {
+      msgretvalue = select(recvsfd + 1, &rfd, NULL, NULL, &sel_tv);
+      if ((msgretvalue == -1) && (errno == EINTR)) {
+        // socket interrupted. Continue waiting for activity on socket
+        continue;
+      }
+      if (msgretvalue > 0) { // read from socket
+        tmpbytecount = read(recvsfd, buff, sizeof(buff));
+        if ((tmpbytecount == -1) && (errno == EINTR)) // read interrupted,continue waiting
+          continue;
+        if (tmpbytecount == 0) // all data has been read
+          break;
+        bytes_read += tmpbytecount; // data byte count has to be increased
+        continue;
+      }
+      break;
+    }
+
+    tmptime = secs() - tmptime;
+    //  throughput in kilo bits per sec = (transmitted_byte_count * 8) / (time_duration)*(1000)
+    *c2sspd = (8.e-3 * bytes_read) / tmptime;
+
+    // c->s throuput value calculated and assigned ! Release resources, conclude snap writing.
+    stop_snap_worker(&workerThreadId, options->snaplog, &snapArgs);
+
+    // send the server calculated value of C->S throughput as result to client
+    snprintf(buff, sizeof(buff), "%6.0f kbps outbound for child %d", *c2sspd,
+             testOptions->child0);
+    log_println(1, "%s", buff);
+    snprintf(buff, sizeof(buff), "%0.0f", *c2sspd);
+    send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+
+    // get receiver side Web100 stats and write them to the log file. close sockets
+    if (record_reverse == 1)
+      web100_get_data_recv(recvsfd, agent, conn, count_vars);
+
+    close(recvsfd);
+    close(testOptions->c2ssockfd);
+
+    // Next, send speed-chk a flag to retrieve the data it collected.
+    // Skip this step if speed-chk isn't running.
+
+    if (getuid() == 0) {
+      log_println(1, "Signal USR1(%d) sent to child [%d]", SIGUSR1,
+                  c2s_childpid);
+      testOptions->child1 = c2s_childpid;
+      kill(c2s_childpid, SIGUSR1);
+      FD_ZERO(&rfd);
+      FD_SET(mon_pipe1[0], &rfd);
+      sel_tv.tv_sec = 1;
+      sel_tv.tv_usec = 100000;
+      i = 0;
+
+      for (;;) {
+        msgretvalue = select(mon_pipe1[0] + 1, &rfd, NULL, NULL,
+                             &sel_tv);
+        if ((msgretvalue == -1) && (errno == EINTR))
+          continue;
+        if (((msgretvalue == -1) && (errno != EINTR))
+            || (msgretvalue == 0)) {
+          log_println(4,
+                      "Failed to read pkt-pair data from C2S flow, retcode=%d, reason=%d",
+                      msgretvalue, errno);
+          snprintf(spds[(*spd_index)++],
+                   sizeof(spds[*spd_index]),
+                   " -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
+          snprintf(spds[(*spd_index)++],
+                   sizeof(spds[*spd_index]),
+                   " -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
+          break;
+        }
+        /* There is something to read, so get it from the pktpair child.  If an interrupt occurs,
+         * just skip the read and go on
+         * RAC 2/8/10
+         */
+        if (msgretvalue > 0) {
+          if ((msgretvalue = read(mon_pipe1[0], spds[*spd_index], sizeof(spds[*spd_index])))
+              < 0)
+            snprintf(
+                spds[*spd_index],
+                sizeof(spds[*spd_index]),
+                " -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
+          log_println(1, "%d bytes read '%s' from C2S monitor pipe",
+                      msgretvalue, spds[*spd_index]);
+          (*spd_index)++;
+          if (i++ == 1)
+            break;
+          sel_tv.tv_sec = 1;
+          sel_tv.tv_usec = 100000;
+          continue;
+        }
+
+      }
+    }
+
+    // An empty TEST_FINALIZE message is sent to conclude the test
+    send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
+
+    //  Close opened resources for packet capture
+    if (getuid() == 0) {
+      stop_packet_trace(mon_pipe1);
+    }
+
+    // log end of C->S test
+    log_println(1, " <----------- %d -------------->", testOptions->child0);
+    //protocol logs
+    teststatuses = TEST_ENDED;
+    protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);
+
+    //set current test status and free address
+    setCurrentTest(TEST_NONE);
+
+  }
+
+  return 0;
 }
diff --git a/src/test_meta_clt.c b/src/test_meta_clt.c
index 7a5443b..96aaee1 100644
--- a/src/test_meta_clt.c
+++ b/src/test_meta_clt.c
@@ -38,101 +38,101 @@ double spdout, c2sspd;
  * 			2: Wrong message type received
  */
 int test_meta_clt(int ctlSocket, char tests, char* host, int conn_options) {
-	char buff[1024], tmpBuff[512];
-	int msgLen, msgType;
-	FILE * fp;
-
-	//Protocol validation variables
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-	enum TEST_ID testids = META;
-
-	if (tests & TEST_META) { // perform META tests
-		log_println(1, " <-- META test -->");
-		setCurrentTest(TEST_META);
-		//protocol logs
-		teststatuses = TEST_STARTED;
-		protolog_status(getpid(), testids, teststatuses, ctlSocket);
-		msgLen = sizeof(buff);
-		// Server starts with a TEST_PREPARE message. Any other
-		// .. type of message at this juncture is unexpected !
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed prepare message!");
-			return 1;
-		}
-		if (check_msg_type(META_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// Server now sends a TEST_START message. Any other message type is
-		// .. indicative of errors
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed start message!");
-			return 1;
-		}
-		if (check_msg_type(META_TEST_LOG, TEST_START, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// As a response to the Server's TEST_START message, client responds
-		// ..with TEST_MSG. These messages may be used, as below, to send configuration data
-		// ...name-value pairs. Note that there are length constraints to keys- values: 64/256
-		// ....characters respectively
-
-		printf("sending meta information to server . . . . . ");
-		fflush(stdout);
-
-		snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_APPLICATION, "cli");
-		send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
-		// send client os name details
-		if ((fp = fopen("/proc/sys/kernel/ostype", "r")) == NULL) {
-			log_println(0, "Unable to determine client os type.");
-		} else {
-			fscanf(fp, "%s", tmpBuff);
-			fclose(fp);
-			snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_OS, tmpBuff);
-			send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
-		}
-
-		// send client browser name
-		snprintf(buff, sizeof(buff), "%s:%s", META_BROWSER_OS, "- (web100clt)");
-		send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
-
-		// send client kernel version
-		if ((fp = fopen("/proc/sys/kernel/osrelease", "r")) == NULL) {
-			log_println(0, "Unable to determine client kernel version.");
-		} else {
-			fscanf(fp, "%s", tmpBuff);
-			fclose(fp);
-			snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_KERNEL_VERSION, tmpBuff);
-			send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
-		}
-
-		// send NDT client version
-		snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_VERSION, VERSION);
-		send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
-
-		// Client can send any number of such meta data in a TEST_MSG
-		// .. format, and signal the end of the transmission using an empty TEST_MSG
-		send_msg(ctlSocket, TEST_MSG, "", 0);
-
-		printf("Done\n");
-
-		// All data has been sent. Expect server to close this META test session
-		// ... by sending an empty TEST_FINALIZE message
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed finalize message!");
-			return 1;
-		}
-		if (check_msg_type(META_TEST_LOG, TEST_FINALIZE, msgType, buff, msgLen)) {
-			return 2;
-		}
-		log_println(1, " <------------------------->");
-		// log protocol validation logs
-		teststatuses = TEST_ENDED;
-		protolog_status(getpid(), testids, teststatuses,ctlSocket);
-		setCurrentTest(TEST_NONE);
-	}
-	return 0;
+  char buff[1024], tmpBuff[512];
+  int msgLen, msgType;
+  FILE * fp;
+
+  //Protocol validation variables
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+  enum TEST_ID testids = META;
+
+  if (tests & TEST_META) { // perform META tests
+    log_println(1, " <-- META test -->");
+    setCurrentTest(TEST_META);
+    //protocol logs
+    teststatuses = TEST_STARTED;
+    protolog_status(getpid(), testids, teststatuses, ctlSocket);
+    msgLen = sizeof(buff);
+    // Server starts with a TEST_PREPARE message. Any other
+    // .. type of message at this juncture is unexpected !
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed prepare message!");
+      return 1;
+    }
+    if (check_msg_type(META_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // Server now sends a TEST_START message. Any other message type is
+    // .. indicative of errors
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed start message!");
+      return 1;
+    }
+    if (check_msg_type(META_TEST_LOG, TEST_START, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // As a response to the Server's TEST_START message, client responds
+    // ..with TEST_MSG. These messages may be used, as below, to send configuration data
+    // ...name-value pairs. Note that there are length constraints to keys- values: 64/256
+    // ....characters respectively
+
+    printf("sending meta information to server . . . . . ");
+    fflush(stdout);
+
+    snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_APPLICATION, "cli");
+    send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
+    // send client os name details
+    if ((fp = fopen("/proc/sys/kernel/ostype", "r")) == NULL) {
+      log_println(0, "Unable to determine client os type.");
+    } else {
+      fscanf(fp, "%s", tmpBuff);
+      fclose(fp);
+      snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_OS, tmpBuff);
+      send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
+    }
+
+    // send client browser name
+    snprintf(buff, sizeof(buff), "%s:%s", META_BROWSER_OS, "- (web100clt)");
+    send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
+
+    // send client kernel version
+    if ((fp = fopen("/proc/sys/kernel/osrelease", "r")) == NULL) {
+      log_println(0, "Unable to determine client kernel version.");
+    } else {
+      fscanf(fp, "%s", tmpBuff);
+      fclose(fp);
+      snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_KERNEL_VERSION, tmpBuff);
+      send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
+    }
+
+    // send NDT client version
+    snprintf(buff, sizeof(buff), "%s:%s", META_CLIENT_VERSION, VERSION);
+    send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
+
+    // Client can send any number of such meta data in a TEST_MSG
+    // .. format, and signal the end of the transmission using an empty TEST_MSG
+    send_msg(ctlSocket, TEST_MSG, "", 0);
+
+    printf("Done\n");
+
+    // All data has been sent. Expect server to close this META test session
+    // ... by sending an empty TEST_FINALIZE message
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed finalize message!");
+      return 1;
+    }
+    if (check_msg_type(META_TEST_LOG, TEST_FINALIZE, msgType, buff, msgLen)) {
+      return 2;
+    }
+    log_println(1, " <------------------------->");
+    // log protocol validation logs
+    teststatuses = TEST_ENDED;
+    protolog_status(getpid(), testids, teststatuses,ctlSocket);
+    setCurrentTest(TEST_NONE);
+  }
+  return 0;
 }
diff --git a/src/test_meta_srv.c b/src/test_meta_srv.c
index ca9be3b..05887cf 100644
--- a/src/test_meta_srv.c
+++ b/src/test_meta_srv.c
@@ -39,125 +39,125 @@
  */
 
 int test_meta_srv(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
-		int conn_options) {
-	int j;
-	int msgLen, msgType;
-	char buff[BUFFSIZE + 1];
-	struct metaentry *new_entry = NULL;
-	char* value;
-
-	// protocol validation logs
-	enum TEST_ID testids = META;
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-
-	if (testOptions->metaopt) {
-		setCurrentTest(TEST_META);
-		log_println(1, " <-- META test -->");
-
-		// log protocol validation details
-		teststatuses = TEST_STARTED;
-		protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
-
-		// first message exchanged is am empty TEST_PREPARE message
-		j = send_msg(ctlsockfd, TEST_PREPARE, "", 0);
-		if (j == -1 || j == -2) { // Cannot write message headers/data
-			log_println(6, "META Error!, Test start message not sent!");
-			return j;
-		}
-
-		// Now, transmit an empty TEST_START message
-		if (send_msg(ctlsockfd, TEST_START, "", 0) < 0) {
-			log_println(6, "META test - Test-start message failed");
-		}
-
-		while (1) {
-			msgLen = sizeof(buff);
-			// Now read the meta data sent by client.
-
-			if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
-				// message reading error
-				log_println(0, "Protocol error!");
-				snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
-				send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-				return 1;
-			}
-			if (check_msg_type("META test", TEST_MSG, msgType, buff, msgLen)) {
-				// expected a TEST_MSG only
-				log_println(0, "Fault, unexpected message received!");
-				snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
-				send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-				return 2;
-			}
-			if (msgLen < 0) {
-				//  meta data should be present at this stage
-				log_println(0, "Improper message");
-				snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
-				send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-				return 3;
-			}
-
-			// Received empty TEST_MSG. All meta_data has been received, and test
-			//  can be finalized.
-			if (msgLen == 0) {
-				break;
-			}
-
-			buff[msgLen] = 0;
-			value = index(buff, ':');
-			if (value == NULL) { // key-value separates by ":"
-				log_println(0, "Improper message");
-				snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
-				send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-				return 4;
-			}
-			*value = 0;
-			value++;
-
-			// get the recommended set of data expected: client os name , client browser name,
-			//why not if else-if for the whole set? TODO
-			if (strcmp(META_CLIENT_OS, buff) == 0) {
-				snprintf(meta.client_os, sizeof(meta.client_os), "%s", value);
-				/*continue;*/
-			}
-			
-			if (strcmp(META_CLIENT_APPLICATION, buff) == 0) {
-				snprintf(meta.client_application, sizeof(meta.client_application), "%s", value);
-				/*continue;*/
-			}
-
-			if (strcmp(META_BROWSER_OS, buff) == 0) {
-				snprintf(meta.client_browser, sizeof(meta.client_browser), "%s",
-						value);
-				/*continue;*/
-			}
-
-			// now get all the key-value tuples
-			if (new_entry) {
-				new_entry->next = (struct metaentry *) malloc(
-						sizeof(struct metaentry));
-				new_entry = new_entry->next;
-			} else {
-				new_entry = (struct metaentry *) malloc(
-						sizeof(struct metaentry));
-				meta.additional = new_entry;
-			}
-			snprintf(new_entry->key, sizeof(new_entry->key), "%s", buff);
-			snprintf(new_entry->value, sizeof(new_entry->value), "%s", value);
-		}
-		new_entry->next = NULL; // ensure meta list ends here 
-
-		// Finalize test by sending appropriate message, and setting status
-		if (send_msg(ctlsockfd, TEST_FINALIZE, "", 0) < 0) {
-			log_println(6, "META test - failed to send finalize message");
-		}
-
-		//log end of test and conclude
-		log_println(1, " <-------------------------->");
-
-		teststatuses = TEST_ENDED; // protocol log section
-		protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
-
-		setCurrentTest(TEST_NONE);
-	}
-	return 0;
+                  int conn_options) {
+  int j;
+  int msgLen, msgType;
+  char buff[BUFFSIZE + 1];
+  struct metaentry *new_entry = NULL;
+  char* value;
+
+  // protocol validation logs
+  enum TEST_ID testids = META;
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+
+  if (testOptions->metaopt) {
+    setCurrentTest(TEST_META);
+    log_println(1, " <-- META test -->");
+
+    // log protocol validation details
+    teststatuses = TEST_STARTED;
+    protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
+
+    // first message exchanged is am empty TEST_PREPARE message
+    j = send_msg(ctlsockfd, TEST_PREPARE, "", 0);
+    if (j == -1 || j == -2) { // Cannot write message headers/data
+      log_println(6, "META Error!, Test start message not sent!");
+      return j;
+    }
+
+    // Now, transmit an empty TEST_START message
+    if (send_msg(ctlsockfd, TEST_START, "", 0) < 0) {
+      log_println(6, "META test - Test-start message failed");
+    }
+
+    while (1) {
+      msgLen = sizeof(buff);
+      // Now read the meta data sent by client.
+
+      if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
+        // message reading error
+        log_println(0, "Protocol error!");
+        snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+        send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+        return 1;
+      }
+      if (check_msg_type("META test", TEST_MSG, msgType, buff, msgLen)) {
+        // expected a TEST_MSG only
+        log_println(0, "Fault, unexpected message received!");
+        snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+        send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+        return 2;
+      }
+      if (msgLen < 0) {
+        //  meta data should be present at this stage
+        log_println(0, "Improper message");
+        snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+        send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+        return 3;
+      }
+
+      // Received empty TEST_MSG. All meta_data has been received, and test
+      //  can be finalized.
+      if (msgLen == 0) {
+        break;
+      }
+
+      buff[msgLen] = 0;
+      value = index(buff, ':');
+      if (value == NULL) { // key-value separates by ":"
+        log_println(0, "Improper message");
+        snprintf(buff, sizeof(buff), "Server (META test): Invalid meta data received");
+        send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+        return 4;
+      }
+      *value = 0;
+      value++;
+
+      // get the recommended set of data expected: client os name , client browser name,
+      //why not if else-if for the whole set? TODO
+      if (strcmp(META_CLIENT_OS, buff) == 0) {
+        snprintf(meta.client_os, sizeof(meta.client_os), "%s", value);
+        /*continue;*/
+      }
+
+      if (strcmp(META_CLIENT_APPLICATION, buff) == 0) {
+        snprintf(meta.client_application, sizeof(meta.client_application), "%s", value);
+        /*continue;*/
+      }
+
+      if (strcmp(META_BROWSER_OS, buff) == 0) {
+        snprintf(meta.client_browser, sizeof(meta.client_browser), "%s",
+                 value);
+        /*continue;*/
+      }
+
+      // now get all the key-value tuples
+      if (new_entry) {
+        new_entry->next = (struct metaentry *) malloc(
+            sizeof(struct metaentry));
+        new_entry = new_entry->next;
+      } else {
+        new_entry = (struct metaentry *) malloc(
+            sizeof(struct metaentry));
+        meta.additional = new_entry;
+      }
+      snprintf(new_entry->key, sizeof(new_entry->key), "%s", buff);
+      snprintf(new_entry->value, sizeof(new_entry->value), "%s", value);
+    }
+    new_entry->next = NULL; // ensure meta list ends here 
+
+    // Finalize test by sending appropriate message, and setting status
+    if (send_msg(ctlsockfd, TEST_FINALIZE, "", 0) < 0) {
+      log_println(6, "META test - failed to send finalize message");
+    }
+
+    //log end of test and conclude
+    log_println(1, " <-------------------------->");
+
+    teststatuses = TEST_ENDED; // protocol log section
+    protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
+
+    setCurrentTest(TEST_NONE);
+  }
+  return 0;
 }
diff --git a/src/test_mid_clt.c b/src/test_mid_clt.c
index 978c21e..c2970ff 100644
--- a/src/test_mid_clt.c
+++ b/src/test_mid_clt.c
@@ -46,150 +46,150 @@
  *
  */
 int test_mid_clt(int ctlSocket, char tests, char* host, int conn_options,
-		int buf_size, char* testresult_str) {
-	char buff[BUFFSIZE + 1];
-	int msgLen, msgType;
-	int midport = atoi(PORT3);
-	I2Addr sec_addr = NULL;
-	int retcode, inlth;
-	int in2Socket;
-	double t, spdin;
-	uint32_t bytes;
-	struct timeval sel_tv;
-	fd_set rfd;
-
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-	enum TEST_ID testids = MIDDLEBOX;
-
-	if (tests & TEST_MID) { // middlebox test has to be performed
-		log_println(1, " <-- Middlebox test -->");
-		setCurrentTest(TEST_MID);
-		//protocol logs
-		teststatuses = TEST_STARTED;
-		protolog_status(getpid(), testids, teststatuses, ctlSocket);
-
-
-		//  Initially, expecting a TEST_PREPARE message. Any other message
-		// ..type is unexpected at this stage.
-
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed prepare message!");
-			return 1;
-		}
-		if (check_msg_type(MIDBOX_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// The server is expected to send a message with a valid payload that contains
-		// .. the port number that server wants client to bind to for this test
-		if (msgLen <= 0) {
-			log_println(0, "Improper message");
-			return 3;
-		}
-		buff[msgLen] = 0;
-		if (check_int(buff, &midport)) {  // obtained message does not contain integer port#
-			log_println(0, "Invalid port number");
-			return 4;
-		}
-
-		// get server address and set port
-		log_println(1, "  -- port: %d", midport);
-		if ((sec_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
-			log_println(0, "Unable to resolve server address: %s", strerror(errno));
-			return -3;
-		}
-		I2AddrSetPort(sec_addr, midport);
-
-		if (get_debuglvl() > 4) { //debug to check if correct port was set in addr struct
-			char tmpbuff[200];
-			size_t tmpBufLen = 199;
-			memset(tmpbuff, 0, 200);
-			I2AddrNodeName(sec_addr, tmpbuff, &tmpBufLen);
-			log_println(5, "connecting to %s:%d", tmpbuff, I2AddrPort(sec_addr));
-		}
-
-		// connect to server using port obtained above
-		if ((retcode = CreateConnectSocket(&in2Socket, NULL, sec_addr, conn_options, buf_size))) {
-			log_println(0, "Connect() for middlebox failed: %s", strerror(errno));
-			return -10;
-		}
-
-		// start reading throughput test data from server using the connection created above
-		printf("Checking for Middleboxes . . . . . . . . . . . . . . . . . .  ");
-		fflush(stdout);
-		testresult_str[0] = '\0';
-		bytes = 0;
-		t = secs() + 5.0;  // set timer for 5 seconds, and read for 5 seconds
-		sel_tv.tv_sec = 6; // Time out the socket after 6.5 seconds
-		sel_tv.tv_usec = 5; // 500?
-		FD_ZERO(&rfd);
-		FD_SET(in2Socket, &rfd);
-		for (;;) {
-			if (secs() > t)
-				break;
-			retcode = select(in2Socket+1, &rfd, NULL, NULL, &sel_tv);
-			if (retcode > 0) {
-				inlth = read(in2Socket, buff, sizeof(buff));
-				if (inlth == 0)
-					break;
-				bytes += inlth;
-				continue;
-			}
-			if (retcode < 0) {
-				printf("nothing to read, exiting read loop\n");
-				break;
-			}
-			if (retcode == 0) {
-				printf("timer expired, exiting read loop\n");
-				break;
-			}
-		}
-		// get actual time for which test was run
-		t = secs() - t + 5.0;
-
-		// calculate throughput in Kbps
-		spdin = ((BITS_8_FLOAT * bytes) / KILO) / t;
-
-		// Test is complete. Now, get results from server (includes CurrentMSS, WinScaleSent, WinScaleRcvd..).
-		// The results are sent from server in the form of a TEST_MSG object
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed text message!");
-			return 1;
-		}
-		if (check_msg_type(MIDBOX_TEST_LOG " results", TEST_MSG, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		strlcat(testresult_str, buff, MIDBOX_TEST_RES_SIZE);
-
-		memset(buff, 0, sizeof(buff));
-		// this should work since the throughput results from the server should
-							 //  ...fit well within BUFFSIZE
-		snprintf(buff, sizeof(buff), "%0.0f", spdin);
-		log_println(4, "CWND limited speed = %0.2f kbps", spdin);
-
-		// client now sends throughput it calculated above to server, as a TEST_MSG
-		send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
-		printf("Done\n");
-
-		I2AddrFree(sec_addr);
-
-		// Expect an empty TEST_FINALIZE message from server
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed finalize message!");
-			return 1;
-		}
-		if (check_msg_type(MIDBOX_TEST_LOG, TEST_FINALIZE, msgType, buff, msgLen)) {
-			return 2;
-		}
-		log_println(1, " <-------------------->");
-		// log protocol test ending
-		teststatuses = TEST_ENDED;
-		protolog_status(getpid(), testids, teststatuses,ctlSocket);
-		setCurrentTest(TEST_NONE);
-	}
-	return 0;
+                 int buf_size, char* testresult_str) {
+  char buff[BUFFSIZE + 1];
+  int msgLen, msgType;
+  int midport = atoi(PORT3);
+  I2Addr sec_addr = NULL;
+  int retcode, inlth;
+  int in2Socket;
+  double t, spdin;
+  uint32_t bytes;
+  struct timeval sel_tv;
+  fd_set rfd;
+
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+  enum TEST_ID testids = MIDDLEBOX;
+
+  if (tests & TEST_MID) { // middlebox test has to be performed
+    log_println(1, " <-- Middlebox test -->");
+    setCurrentTest(TEST_MID);
+    //protocol logs
+    teststatuses = TEST_STARTED;
+    protolog_status(getpid(), testids, teststatuses, ctlSocket);
+
+
+    //  Initially, expecting a TEST_PREPARE message. Any other message
+    // ..type is unexpected at this stage.
+
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed prepare message!");
+      return 1;
+    }
+    if (check_msg_type(MIDBOX_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // The server is expected to send a message with a valid payload that contains
+    // .. the port number that server wants client to bind to for this test
+    if (msgLen <= 0) {
+      log_println(0, "Improper message");
+      return 3;
+    }
+    buff[msgLen] = 0;
+    if (check_int(buff, &midport)) {  // obtained message does not contain integer port#
+      log_println(0, "Invalid port number");
+      return 4;
+    }
+
+    // get server address and set port
+    log_println(1, "  -- port: %d", midport);
+    if ((sec_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
+      log_println(0, "Unable to resolve server address: %s", strerror(errno));
+      return -3;
+    }
+    I2AddrSetPort(sec_addr, midport);
+
+    if (get_debuglvl() > 4) { //debug to check if correct port was set in addr struct
+      char tmpbuff[200];
+      size_t tmpBufLen = 199;
+      memset(tmpbuff, 0, 200);
+      I2AddrNodeName(sec_addr, tmpbuff, &tmpBufLen);
+      log_println(5, "connecting to %s:%d", tmpbuff, I2AddrPort(sec_addr));
+    }
+
+    // connect to server using port obtained above
+    if ((retcode = CreateConnectSocket(&in2Socket, NULL, sec_addr, conn_options, buf_size))) {
+      log_println(0, "Connect() for middlebox failed: %s", strerror(errno));
+      return -10;
+    }
+
+    // start reading throughput test data from server using the connection created above
+    printf("Checking for Middleboxes . . . . . . . . . . . . . . . . . .  ");
+    fflush(stdout);
+    testresult_str[0] = '\0';
+    bytes = 0;
+    t = secs() + 5.0;  // set timer for 5 seconds, and read for 5 seconds
+    sel_tv.tv_sec = 6; // Time out the socket after 6.5 seconds
+    sel_tv.tv_usec = 5; // 500?
+    FD_ZERO(&rfd);
+    FD_SET(in2Socket, &rfd);
+    for (;;) {
+      if (secs() > t)
+        break;
+      retcode = select(in2Socket+1, &rfd, NULL, NULL, &sel_tv);
+      if (retcode > 0) {
+        inlth = read(in2Socket, buff, sizeof(buff));
+        if (inlth == 0)
+          break;
+        bytes += inlth;
+        continue;
+      }
+      if (retcode < 0) {
+        printf("nothing to read, exiting read loop\n");
+        break;
+      }
+      if (retcode == 0) {
+        printf("timer expired, exiting read loop\n");
+        break;
+      }
+    }
+    // get actual time for which test was run
+    t = secs() - t + 5.0;
+
+    // calculate throughput in Kbps
+    spdin = ((BITS_8_FLOAT * bytes) / KILO) / t;
+
+    // Test is complete. Now, get results from server (includes CurrentMSS, WinScaleSent, WinScaleRcvd..).
+    // The results are sent from server in the form of a TEST_MSG object
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed text message!");
+      return 1;
+    }
+    if (check_msg_type(MIDBOX_TEST_LOG " results", TEST_MSG, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    strlcat(testresult_str, buff, MIDBOX_TEST_RES_SIZE);
+
+    memset(buff, 0, sizeof(buff));
+    // this should work since the throughput results from the server should
+    //  ...fit well within BUFFSIZE
+    snprintf(buff, sizeof(buff), "%0.0f", spdin);
+    log_println(4, "CWND limited speed = %0.2f kbps", spdin);
+
+    // client now sends throughput it calculated above to server, as a TEST_MSG
+    send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
+    printf("Done\n");
+
+    I2AddrFree(sec_addr);
+
+    // Expect an empty TEST_FINALIZE message from server
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed finalize message!");
+      return 1;
+    }
+    if (check_msg_type(MIDBOX_TEST_LOG, TEST_FINALIZE, msgType, buff, msgLen)) {
+      return 2;
+    }
+    log_println(1, " <-------------------->");
+    // log protocol test ending
+    teststatuses = TEST_ENDED;
+    protolog_status(getpid(), testids, teststatuses,ctlSocket);
+    setCurrentTest(TEST_NONE);
+  }
+  return 0;
 }
diff --git a/src/test_mid_srv.c b/src/test_mid_srv.c
index ef0d319..07a0771 100644
--- a/src/test_mid_srv.c
+++ b/src/test_mid_srv.c
@@ -50,252 +50,252 @@
  */
 
 int test_mid(int ctlsockfd, web100_agent* agent, TestOptions* options,
-		int conn_options, double* s2c_throughput_mid) {
-	int maxseg = ETHERNET_MTU_SIZE;
-	/* int maxseg=1456, largewin=16*1024*1024; */
-	/* int seg_size, win_size; */
-	int midsfd; // socket file-descriptor, used in mid-box throughput test from S->C
-	int j; // temporary integer store
-	int msgretvalue; // return value from socket read/writes
-	struct sockaddr_storage cli_addr;
-	/* socklen_t optlen, clilen; */
-	socklen_t clilen;
-	char buff[BUFFSIZE + 1]; // buf used for message payload
-	I2Addr 	midsrv_addr = NULL; // server address
-	char listenmidport[10]; // listener socket for middlebox tests
-	int msgType;
-	int msgLen;
-	web100_connection* conn;
-	char tmpstr[256]; // temporary string storage
-	struct timeval sel_tv; // time
-	fd_set rfd; // receiver file descriptor
-
-	// variables used for protocol validation logging
-	enum TEST_ID thistestId = NONE;
-	enum TEST_STATUS_INT teststatusnow = TEST_NOT_STARTED;
-	enum PROCESS_STATUS_INT procstatusenum = PROCESS_STARTED;
-	enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
-
-	assert(ctlsockfd != -1);
-	assert(agent);
-	assert(options);
-	assert(s2c_throughput_mid);
-
-	if (options->midopt) { // middlebox tests need to be run.
-
-		// Start with readying up (initializing)
-		setCurrentTest(TEST_MID);
-		log_println(1, " <-- %d - Middlebox test -->", options->child0);
-
-		// protocol validation logs indicating start of tests
-		thistestId = MIDDLEBOX;
-		teststatusnow = TEST_STARTED;
-		protolog_status(options->child0, thistestId, teststatusnow, ctlsockfd);
-
-		// determine port to be used. Compute based on options set earlier
-		// by reading from config file, or use default port3 (3003),
-		//strcpy(listenmidport, PORT3);
-		strlcpy(listenmidport, PORT3, sizeof(listenmidport));
-
-		if (options->midsockport) {
-			snprintf(listenmidport, sizeof(listenmidport), "%d", options->midsockport);
-		} else if (options->mainport) {
-			snprintf(listenmidport, sizeof(listenmidport), "%d", options->mainport + 2);
-		}
-
-		if (options->multiple) {
-			//strcpy(listenmidport, "0");
-			strlcpy(listenmidport, "0", sizeof(listenmidport));
-		}
-
-		/*  RAC debug  */
-		/*
-		 if (KillHung() == 0)
-		 log_println(5, "KillHung() returned 0, should have tried to kill off some LastAck process");
-		 else
-		 log_println(5, "KillHung(): returned non-0 response, nothing to kill or kill failed");
-		 */
-
-		while (midsrv_addr == NULL) {
-
-			// attempt to bind to a new port and obtain address structure with details of listening port
-
-			midsrv_addr =
-					CreateListenSocket(
-							NULL,
-							(options->multiple ?
-									mrange_next(listenmidport, sizeof(listenmidport)) : listenmidport), conn_options, 0)
-							;
-			if (midsrv_addr == NULL) {
-				/*
-				 log_println(5, " Calling KillHung() because midsrv_address failed to bind");
-				 if (KillHung() == 0)
-				 continue;
-				 */
-			}
-			if (strcmp(listenmidport, "0") == 0) {
-				log_println(0, "WARNING: ephemeral port number was bound");
-				break;
-			}
-			if (options->multiple == 0) { // simultaneous tests from multiple clients not allowed, quit now
-				break;
-			}
-		}
-
-		if (midsrv_addr == NULL) {
-			log_println(0,
-					"Server (Middlebox test): CreateListenSocket failed: %s",
-					strerror(errno));
-			snprintf(buff, sizeof(buff),
-					"Server (Middlebox test): CreateListenSocket failed: %s",
-					strerror(errno));
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return -1;
-		}
-
-		// get socket FD and the ephemeral port number that client will connect to
-		options->midsockfd = I2AddrFD(midsrv_addr);
-		options->midsockport = I2AddrPort(midsrv_addr);
-		log_println(1, "  -- port: %d", options->midsockport);
-
-		// send this port number to client
-		snprintf(buff, sizeof(buff), "%d", options->midsockport);
-		if ((msgretvalue = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff)))
-				< 0)
-			return msgretvalue;
-
-		/* set mss to 1456 (strange value), and large snd/rcv buffers
-		 * should check to see if server supports window scale ?
-		 */
-		setsockopt(options->midsockfd, SOL_TCP, TCP_MAXSEG, &maxseg,
-				sizeof(maxseg));
-
-		/* Post a listen on port 3003.  Client will connect here to run the
-		 * middlebox test.  At this time it really only checks the MSS value
-		 * and does NAT detection.  More analysis functions (window scale)
-		 * will be done in the future.
-		 */
-		clilen = sizeof(cli_addr);
-
-		// Wait on listening socket and read data once ready.
-		// Choose a retry count of "5" to wait for activity on the socket
-		FD_ZERO(&rfd);
-		FD_SET(options->midsockfd, &rfd);
-		sel_tv.tv_sec = 5;
-		sel_tv.tv_usec = 0;
-		for (j = 0; j < RETRY_COUNT; j++) {
-			msgretvalue = select((options->midsockfd) + 1, &rfd, NULL, NULL,
-					&sel_tv);
-			if ((msgretvalue == -1) && (errno == EINTR)) // socket interruption. continue waiting for activity on socket
-				continue;
-			if (msgretvalue == 0) // timeout
-				return SOCKET_CONNECT_TIMEOUT;
-			if (msgretvalue < 0) // other socket errors, exit
-				return -errno;
-			if (j == 4) // retry exceeded. Quit
-				return RETRY_EXCEEDED_WAITING_CONNECT;
-
-			midfd:
-			// if a valid connection request is received, client has connected. Proceed.
-			// Note the new socket fd used in the throughput test is this (midsfd)
-			if ((midsfd = accept(options->midsockfd,
-					(struct sockaddr *) &cli_addr, &clilen)) > 0) {
-				// log protocol validation indicating client connection
-				procstatusenum = PROCESS_STARTED;
-				proctypeenum = CONNECT_TYPE;
-				protolog_procstatus(options->child0, thistestId, proctypeenum,
-						procstatusenum, midsfd);
-				break;
-			}
-
-			if ((midsfd == -1) && (errno == EINTR)) // socket interrupted, wait some more
-				goto midfd;
-
-			snprintf(tmpstr,
-				sizeof(tmpstr),
-				"-------     middlebox connection setup returned because (%d)",
-				errno);
-			if (get_debuglvl() > 1)
-				perror(tmpstr);
-			if (midsfd < 0)
-				return -errno;
-			if (j == 4)
-				return RETRY_EXCEEDED_WAITING_DATA;
-		}
-
-		// get meta test details copied into results
-		memcpy(&meta.c_addr, &cli_addr, clilen);
-		/* meta.c_addr = cli_addr; */
-		meta.family = ((struct sockaddr *) &cli_addr)->sa_family;
-
-		buff[0] = '\0';
-		// get web100 connection data
-		if ((conn = web100_connection_from_socket(agent, midsfd)) == NULL) {
-			log_println(
-					0,
-					"!!!!!!!!!!!  test_mid() failed to get web100 connection data, rc=%d",
-					errno);
-			/* exit(-1); */
-			return -3;
-		}
-
-		// Perform S->C throughput test. Obtained results in "buff"
-		web100_middlebox(midsfd, agent, conn, buff, sizeof(buff));
-
-		// Transmit results in the form of a TEST_MSG message
-		send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-
-		// Expect client to send throughput as calculated at its end
-
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) { // message reception error
-			log_println(0, "Protocol error!");
-			snprintf(
-					buff,
-					sizeof(buff),
-					"Server (Middlebox test): Invalid CWND limited throughput received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return 1;
-		}
-		if (check_msg_type("Middlebox test", TEST_MSG, msgType, buff, msgLen)) { // only TEST_MSG type valid
-			snprintf(
-					buff,
-					sizeof(buff),
-					"Server (Middlebox test): Invalid CWND limited throughput received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return 2;
-		}
-		if (msgLen <= 0) { // received message's length has to be a valid one
-			log_println(0, "Improper message");
-			snprintf(
-					buff,
-					sizeof(buff),
-					"Server (Middlebox test): Invalid CWND limited throughput received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return 3;
-		}
-
-		// message payload from client == midbox S->c throughput
-		buff[msgLen] = 0;
-		*s2c_throughput_mid = atof(buff);
-		log_println(4, "CWND limited throughput = %0.0f kbps (%s)",
-				*s2c_throughput_mid, buff);
-
-		// finalize the midbox test ; disabling socket used for throughput test and closing out both sockets
-		shutdown(midsfd, SHUT_WR);
-		close(midsfd);
-		close(options->midsockfd);
-		send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
-		log_println(1, " <--------- %d ----------->", options->child0);
-
-		// log end of test into protocol doc, just to delimit.
-		teststatusnow = TEST_ENDED;
-		//protolog_status(1, options->child0, thistestId, teststatusnow);
-		protolog_status(options->child0, thistestId, teststatusnow,ctlsockfd);
-
-		setCurrentTest(TEST_NONE);
-		/* I2AddrFree(midsrv_addr); */
-	}
-	/* I2AddrFree(midsrv_addr); */
-	return 0;
+             int conn_options, double* s2c_throughput_mid) {
+  int maxseg = ETHERNET_MTU_SIZE;
+  /* int maxseg=1456, largewin=16*1024*1024; */
+  /* int seg_size, win_size; */
+  int midsfd; // socket file-descriptor, used in mid-box throughput test from S->C
+  int j; // temporary integer store
+  int msgretvalue; // return value from socket read/writes
+  struct sockaddr_storage cli_addr;
+  /* socklen_t optlen, clilen; */
+  socklen_t clilen;
+  char buff[BUFFSIZE + 1]; // buf used for message payload
+  I2Addr 	midsrv_addr = NULL; // server address
+  char listenmidport[10]; // listener socket for middlebox tests
+  int msgType;
+  int msgLen;
+  web100_connection* conn;
+  char tmpstr[256]; // temporary string storage
+  struct timeval sel_tv; // time
+  fd_set rfd; // receiver file descriptor
+
+  // variables used for protocol validation logging
+  enum TEST_ID thistestId = NONE;
+  enum TEST_STATUS_INT teststatusnow = TEST_NOT_STARTED;
+  enum PROCESS_STATUS_INT procstatusenum = PROCESS_STARTED;
+  enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
+
+  assert(ctlsockfd != -1);
+  assert(agent);
+  assert(options);
+  assert(s2c_throughput_mid);
+
+  if (options->midopt) { // middlebox tests need to be run.
+
+    // Start with readying up (initializing)
+    setCurrentTest(TEST_MID);
+    log_println(1, " <-- %d - Middlebox test -->", options->child0);
+
+    // protocol validation logs indicating start of tests
+    thistestId = MIDDLEBOX;
+    teststatusnow = TEST_STARTED;
+    protolog_status(options->child0, thistestId, teststatusnow, ctlsockfd);
+
+    // determine port to be used. Compute based on options set earlier
+    // by reading from config file, or use default port3 (3003),
+    //strcpy(listenmidport, PORT3);
+    strlcpy(listenmidport, PORT3, sizeof(listenmidport));
+
+    if (options->midsockport) {
+      snprintf(listenmidport, sizeof(listenmidport), "%d", options->midsockport);
+    } else if (options->mainport) {
+      snprintf(listenmidport, sizeof(listenmidport), "%d", options->mainport + 2);
+    }
+
+    if (options->multiple) {
+      //strcpy(listenmidport, "0");
+      strlcpy(listenmidport, "0", sizeof(listenmidport));
+    }
+
+    /*  RAC debug  */
+    /*
+       if (KillHung() == 0)
+       log_println(5, "KillHung() returned 0, should have tried to kill off some LastAck process");
+       else
+       log_println(5, "KillHung(): returned non-0 response, nothing to kill or kill failed");
+       */
+
+    while (midsrv_addr == NULL) {
+
+      // attempt to bind to a new port and obtain address structure with details of listening port
+
+      midsrv_addr =
+          CreateListenSocket(
+              NULL,
+              (options->multiple ?
+               mrange_next(listenmidport, sizeof(listenmidport)) : listenmidport), conn_options, 0)
+          ;
+      if (midsrv_addr == NULL) {
+        /*
+           log_println(5, " Calling KillHung() because midsrv_address failed to bind");
+           if (KillHung() == 0)
+           continue;
+           */
+      }
+      if (strcmp(listenmidport, "0") == 0) {
+        log_println(0, "WARNING: ephemeral port number was bound");
+        break;
+      }
+      if (options->multiple == 0) { // simultaneous tests from multiple clients not allowed, quit now
+        break;
+      }
+    }
+
+    if (midsrv_addr == NULL) {
+      log_println(0,
+                  "Server (Middlebox test): CreateListenSocket failed: %s",
+                  strerror(errno));
+      snprintf(buff, sizeof(buff),
+               "Server (Middlebox test): CreateListenSocket failed: %s",
+               strerror(errno));
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return -1;
+    }
+
+    // get socket FD and the ephemeral port number that client will connect to
+    options->midsockfd = I2AddrFD(midsrv_addr);
+    options->midsockport = I2AddrPort(midsrv_addr);
+    log_println(1, "  -- port: %d", options->midsockport);
+
+    // send this port number to client
+    snprintf(buff, sizeof(buff), "%d", options->midsockport);
+    if ((msgretvalue = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff)))
+        < 0)
+      return msgretvalue;
+
+    /* set mss to 1456 (strange value), and large snd/rcv buffers
+     * should check to see if server supports window scale ?
+     */
+    setsockopt(options->midsockfd, SOL_TCP, TCP_MAXSEG, &maxseg,
+               sizeof(maxseg));
+
+    /* Post a listen on port 3003.  Client will connect here to run the
+     * middlebox test.  At this time it really only checks the MSS value
+     * and does NAT detection.  More analysis functions (window scale)
+     * will be done in the future.
+     */
+    clilen = sizeof(cli_addr);
+
+    // Wait on listening socket and read data once ready.
+    // Choose a retry count of "5" to wait for activity on the socket
+    FD_ZERO(&rfd);
+    FD_SET(options->midsockfd, &rfd);
+    sel_tv.tv_sec = 5;
+    sel_tv.tv_usec = 0;
+    for (j = 0; j < RETRY_COUNT; j++) {
+      msgretvalue = select((options->midsockfd) + 1, &rfd, NULL, NULL,
+                           &sel_tv);
+      if ((msgretvalue == -1) && (errno == EINTR)) // socket interruption. continue waiting for activity on socket
+        continue;
+      if (msgretvalue == 0) // timeout
+        return SOCKET_CONNECT_TIMEOUT;
+      if (msgretvalue < 0) // other socket errors, exit
+        return -errno;
+      if (j == 4) // retry exceeded. Quit
+        return RETRY_EXCEEDED_WAITING_CONNECT;
+
+midfd:
+      // if a valid connection request is received, client has connected. Proceed.
+      // Note the new socket fd used in the throughput test is this (midsfd)
+      if ((midsfd = accept(options->midsockfd,
+                           (struct sockaddr *) &cli_addr, &clilen)) > 0) {
+        // log protocol validation indicating client connection
+        procstatusenum = PROCESS_STARTED;
+        proctypeenum = CONNECT_TYPE;
+        protolog_procstatus(options->child0, thistestId, proctypeenum,
+                            procstatusenum, midsfd);
+        break;
+      }
+
+      if ((midsfd == -1) && (errno == EINTR)) // socket interrupted, wait some more
+        goto midfd;
+
+      snprintf(tmpstr,
+               sizeof(tmpstr),
+               "-------     middlebox connection setup returned because (%d)",
+               errno);
+      if (get_debuglvl() > 1)
+        perror(tmpstr);
+      if (midsfd < 0)
+        return -errno;
+      if (j == 4)
+        return RETRY_EXCEEDED_WAITING_DATA;
+    }
+
+    // get meta test details copied into results
+    memcpy(&meta.c_addr, &cli_addr, clilen);
+    /* meta.c_addr = cli_addr; */
+    meta.family = ((struct sockaddr *) &cli_addr)->sa_family;
+
+    buff[0] = '\0';
+    // get web100 connection data
+    if ((conn = web100_connection_from_socket(agent, midsfd)) == NULL) {
+      log_println(
+          0,
+          "!!!!!!!!!!!  test_mid() failed to get web100 connection data, rc=%d",
+          errno);
+      /* exit(-1); */
+      return -3;
+    }
+
+    // Perform S->C throughput test. Obtained results in "buff"
+    web100_middlebox(midsfd, agent, conn, buff, sizeof(buff));
+
+    // Transmit results in the form of a TEST_MSG message
+    send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+
+    // Expect client to send throughput as calculated at its end
+
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) { // message reception error
+      log_println(0, "Protocol error!");
+      snprintf(
+          buff,
+          sizeof(buff),
+          "Server (Middlebox test): Invalid CWND limited throughput received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return 1;
+    }
+    if (check_msg_type("Middlebox test", TEST_MSG, msgType, buff, msgLen)) { // only TEST_MSG type valid
+      snprintf(
+          buff,
+          sizeof(buff),
+          "Server (Middlebox test): Invalid CWND limited throughput received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return 2;
+    }
+    if (msgLen <= 0) { // received message's length has to be a valid one
+      log_println(0, "Improper message");
+      snprintf(
+          buff,
+          sizeof(buff),
+          "Server (Middlebox test): Invalid CWND limited throughput received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return 3;
+    }
+
+    // message payload from client == midbox S->c throughput
+    buff[msgLen] = 0;
+    *s2c_throughput_mid = atof(buff);
+    log_println(4, "CWND limited throughput = %0.0f kbps (%s)",
+                *s2c_throughput_mid, buff);
+
+    // finalize the midbox test ; disabling socket used for throughput test and closing out both sockets
+    shutdown(midsfd, SHUT_WR);
+    close(midsfd);
+    close(options->midsockfd);
+    send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
+    log_println(1, " <--------- %d ----------->", options->child0);
+
+    // log end of test into protocol doc, just to delimit.
+    teststatusnow = TEST_ENDED;
+    //protolog_status(1, options->child0, thistestId, teststatusnow);
+    protolog_status(options->child0, thistestId, teststatusnow,ctlsockfd);
+
+    setCurrentTest(TEST_NONE);
+    /* I2AddrFree(midsrv_addr); */
+  }
+  /* I2AddrFree(midsrv_addr); */
+  return 0;
 }
diff --git a/src/test_results_clt.c b/src/test_results_clt.c
index b9a0ccc..153b535 100644
--- a/src/test_results_clt.c
+++ b/src/test_results_clt.c
@@ -24,53 +24,53 @@
  * @return Current link's speed
  */
 double get_linkspeed(int c2s_linkspeed_ind, int half_duplex_ind) {
-	double mylinkspeed = 0;
-	if (c2s_linkspeed_ind < DATA_RATE_ETHERNET) {
-		if (c2s_linkspeed_ind < DATA_RATE_RTT) {
-			printf("Server unable to determine bottleneck link type.\n");
-		} else {
-			printf("Your host is connected to a ");
-
-			if (c2s_linkspeed_ind == DATA_RATE_DIAL_UP) {
-				printf("Dial-up Modem\n");
-				mylinkspeed = .064;
-			} else {
-				printf("Cable/DSL modem\n");
-				mylinkspeed = 2;
-			}
-		}
-	} else {
-		printf("The slowest link in the end-to-end path is a ");
-
-		if (c2s_linkspeed_ind == DATA_RATE_ETHERNET) {
-			printf("10 Mbps Ethernet or WiFi 11b subnet\n");
-			mylinkspeed = 10;
-		} else if (c2s_linkspeed_ind == DATA_RATE_T3) {
-			printf("45 Mbps T3/DS3 or WiFi 11 a/g  subnet\n");
-			mylinkspeed = 45;
-		} else if (c2s_linkspeed_ind == DATA_RATE_FAST_ETHERNET) {
-			printf("100 Mbps ");
-			mylinkspeed = 100;
-			if (half_duplex_ind == NO_HALF_DUPLEX) {
-				printf("Full duplex Fast Ethernet subnet\n");
-			} else {
-				printf("Half duplex Fast Ethernet subnet\n");
-			}
-		} else if (c2s_linkspeed_ind == DATA_RATE_OC_12) {
-			printf("a 622 Mbps OC-12 subnet\n");
-			mylinkspeed = 622;
-		} else if (c2s_linkspeed_ind == DATA_RATE_GIGABIT_ETHERNET) {
-			printf("1.0 Gbps Gigabit Ethernet subnet\n");
-			mylinkspeed = 1000;
-		} else if (c2s_linkspeed_ind == DATA_RATE_OC_48) {
-			printf("2.4 Gbps OC-48 subnet\n");
-			mylinkspeed = 2400;
-		} else if (c2s_linkspeed_ind == DATA_RATE_10G_ETHERNET) {
-			printf("10 Gbps 10 Gigabit Ethernet/OC-192 subnet\n");
-			mylinkspeed = 10000;
-		}
-	}
-	return mylinkspeed;
+  double mylinkspeed = 0;
+  if (c2s_linkspeed_ind < DATA_RATE_ETHERNET) {
+    if (c2s_linkspeed_ind < DATA_RATE_RTT) {
+      printf("Server unable to determine bottleneck link type.\n");
+    } else {
+      printf("Your host is connected to a ");
+
+      if (c2s_linkspeed_ind == DATA_RATE_DIAL_UP) {
+        printf("Dial-up Modem\n");
+        mylinkspeed = .064;
+      } else {
+        printf("Cable/DSL modem\n");
+        mylinkspeed = 2;
+      }
+    }
+  } else {
+    printf("The slowest link in the end-to-end path is a ");
+
+    if (c2s_linkspeed_ind == DATA_RATE_ETHERNET) {
+      printf("10 Mbps Ethernet or WiFi 11b subnet\n");
+      mylinkspeed = 10;
+    } else if (c2s_linkspeed_ind == DATA_RATE_T3) {
+      printf("45 Mbps T3/DS3 or WiFi 11 a/g  subnet\n");
+      mylinkspeed = 45;
+    } else if (c2s_linkspeed_ind == DATA_RATE_FAST_ETHERNET) {
+      printf("100 Mbps ");
+      mylinkspeed = 100;
+      if (half_duplex_ind == NO_HALF_DUPLEX) {
+        printf("Full duplex Fast Ethernet subnet\n");
+      } else {
+        printf("Half duplex Fast Ethernet subnet\n");
+      }
+    } else if (c2s_linkspeed_ind == DATA_RATE_OC_12) {
+      printf("a 622 Mbps OC-12 subnet\n");
+      mylinkspeed = 622;
+    } else if (c2s_linkspeed_ind == DATA_RATE_GIGABIT_ETHERNET) {
+      printf("1.0 Gbps Gigabit Ethernet subnet\n");
+      mylinkspeed = 1000;
+    } else if (c2s_linkspeed_ind == DATA_RATE_OC_48) {
+      printf("2.4 Gbps OC-48 subnet\n");
+      mylinkspeed = 2400;
+    } else if (c2s_linkspeed_ind == DATA_RATE_10G_ETHERNET) {
+      printf("10 Gbps 10 Gigabit Ethernet/OC-192 subnet\n");
+      mylinkspeed = 10000;
+    }
+  }
+  return mylinkspeed;
 }
 
 /**
@@ -78,27 +78,27 @@ double get_linkspeed(int c2s_linkspeed_ind, int half_duplex_ind) {
  * @param mismatch Integer indicating results
  */
 void print_results_mismatchcheck(int mismatch) {
-	switch (mismatch) {
-	case DUPLEX_OLD_ALGO_INDICATOR :
-		printf("Warning: Old Duplex-Mismatch condition detected.\n");
-		break;
-
-	case DUPLEX_SWITCH_FULL_HOST_HALF :
-		printf("Alarm: Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
-		break;
-	case DUPLEX_SWITCH_FULL_HOST_HALF_POSS:
-		printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
-		break;
-	case DUPLEX_SWITCH_HALF_HOST_FULL:
-		printf("Alarm: Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
-		break;
-	case DUPLEX_SWITCH_HALF_HOST_FULL_POSS:
-		printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
-		break;
-	case DUPLEX_SWITCH_HALF_HOST_FULL_WARN:
-		printf("Warning: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
-		break;
-	}
+  switch (mismatch) {
+    case DUPLEX_OLD_ALGO_INDICATOR :
+      printf("Warning: Old Duplex-Mismatch condition detected.\n");
+      break;
+
+    case DUPLEX_SWITCH_FULL_HOST_HALF :
+      printf("Alarm: Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
+      break;
+    case DUPLEX_SWITCH_FULL_HOST_HALF_POSS:
+      printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Full and Host=Half\n");
+      break;
+    case DUPLEX_SWITCH_HALF_HOST_FULL:
+      printf("Alarm: Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+      break;
+    case DUPLEX_SWITCH_HALF_HOST_FULL_POSS:
+      printf("Alarm: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+      break;
+    case DUPLEX_SWITCH_HALF_HOST_FULL_WARN:
+      printf("Warning: Possible Duplex Mismatch condition detected. Switch=Half and Host=Full\n");
+      break;
+  }
 }
 
 
@@ -113,19 +113,19 @@ void print_results_mismatchcheck(int mismatch) {
  * @param max_RwinRcvd
  */
 void print_recommend_buffersize(double rwin, double rttsec, double avgrtt,
-		double mylink, int max_RwinRcvd){
-	int j = 0;
-	log_print(3, "Is larger buffer recommended?  rwin*2/rttsec (%0.4f) < mylink (%0.4f) ",
-			((rwin*2)/rttsec), mylink);
-	log_println(3, "AND j (%0.4f) > MaxRwinRcvd (%d)",
-			(float)((mylink * avgrtt)*1000)/8, max_RwinRcvd);
-	if (((rwin*2)/rttsec) < mylink) {
-		j = (float)((mylink * avgrtt)*1000) / 8;
-		if ((int)j > max_RwinRcvd) {
-			printf("Information: The receive buffer should be %0.0f ", j/1024.0f);
-			printf("kbytes to maximize throughput\n");
-		}
-	}
+                                double mylink, int max_RwinRcvd){
+  int j = 0;
+  log_print(3, "Is larger buffer recommended?  rwin*2/rttsec (%0.4f) < mylink (%0.4f) ",
+            ((rwin*2)/rttsec), mylink);
+  log_println(3, "AND j (%0.4f) > MaxRwinRcvd (%d)",
+              (float)((mylink * avgrtt)*1000)/8, max_RwinRcvd);
+  if (((rwin*2)/rttsec) < mylink) {
+    j = (float)((mylink * avgrtt)*1000) / 8;
+    if ((int)j > max_RwinRcvd) {
+      printf("Information: The receive buffer should be %0.0f ", j/1024.0f);
+      printf("kbytes to maximize throughput\n");
+    }
+  }
 }
 
 /**
@@ -133,9 +133,9 @@ void print_recommend_buffersize(double rwin, double rttsec, double avgrtt,
  * @param is_badcable
  * */
 void check_badcable(int is_bad_cable) {
-	if (is_bad_cable == POSSIBLE_BAD_CABLE) {
-		printf("Alarm: Excessive errors, check network cable(s).\n");
-	}
+  if (is_bad_cable == POSSIBLE_BAD_CABLE) {
+    printf("Alarm: Excessive errors, check network cable(s).\n");
+  }
 }
 
 /**
@@ -143,9 +143,9 @@ void check_badcable(int is_bad_cable) {
  * @param is_congested
  * */
 void check_congestion(int is_congested) {
-	if (is_congested == POSSIBLE_CONGESTION) {
-                printf("Information: Other network traffic is congesting the link\n");
-	}
+  if (is_congested == POSSIBLE_CONGESTION) {
+    printf("Information: Other network traffic is congesting the link\n");
+  }
 }
 
 /**
@@ -155,15 +155,15 @@ void check_congestion(int is_congested) {
  * @param sndqueue length of send queue of the C->S throughput test
  */
 void check_C2Spacketqueuing(double c2sthruput, double spdout, int sndqueue, int pktcount, int buflength) {
-	if (c2sthruput < (spdout * (1.0 - VIEW_DIFF))) {
-		printf("Information [C2S]: Packet queuing detected: %0.2f%% ",
-				100 * (spdout - c2sthruput) / spdout);
-		if (sndqueue > (0.8 * pktcount * buflength * (spdout - c2sthruput) / spdout)) {
-			printf("(local buffers)\n");
-		} else {
-			printf("(remote buffers)\n");
-		}
-	}
+  if (c2sthruput < (spdout * (1.0 - VIEW_DIFF))) {
+    printf("Information [C2S]: Packet queuing detected: %0.2f%% ",
+           100 * (spdout - c2sthruput) / spdout);
+    if (sndqueue > (0.8 * pktcount * buflength * (spdout - c2sthruput) / spdout)) {
+      printf("(local buffers)\n");
+    } else {
+      printf("(remote buffers)\n");
+    }
+  }
 }
 
 
@@ -176,15 +176,15 @@ void check_C2Spacketqueuing(double c2sthruput, double spdout, int sndqueue, int
  * @param sbytecount total-sent-byte-count in the S->C throughput test
  */
 void check_S2Cpacketqueuing(double s2cthroughput, double spdin, int srvsndqueue, int sbytecount) {
-	if (spdin < (s2cthroughput * (1.0 - VIEW_DIFF))) {
-		printf("Information [S2C]: Packet queuing detected: %0.2f%% ",
-				100 * (s2cthroughput - spdin) / s2cthroughput);
-		if (srvsndqueue > (0.8 * sbytecount * (s2cthroughput - spdin) / s2cthroughput)) {
-			printf("(local buffers)\n");
-		} else {
-			printf("(remote buffers)\n");
-		}
-	}
+  if (spdin < (s2cthroughput * (1.0 - VIEW_DIFF))) {
+    printf("Information [S2C]: Packet queuing detected: %0.2f%% ",
+           100 * (s2cthroughput - spdin) / s2cthroughput);
+    if (srvsndqueue > (0.8 * sbytecount * (s2cthroughput - spdin) / s2cthroughput)) {
+      printf("(local buffers)\n");
+    } else {
+      printf("(remote buffers)\n");
+    }
+  }
 }
 
 /**
@@ -208,31 +208,31 @@ void check_S2Cpacketqueuing(double s2cthroughput, double spdin, int srvsndqueue,
  * @param totaltesttime     Total test time
  */
 void print_packetloss_statistics(int PktsRetrans, int DupAcksIn, int SACKsRcvd,
-		double ooorder, int Timeouts, double waitsec , double totaltesttime) {
-
-	if (PktsRetrans > 0) {
-		printf("There were %d packets retransmitted", PktsRetrans);
-		printf(", %d duplicate acks received", DupAcksIn);
-		printf(", and %d SACK blocks received\n", SACKsRcvd);
-		if (ooorder > 0)
-			printf("Packets arrived out-of-order %0.2f%% of the time.\n",
-					ooorder * 100);
-		if (Timeouts > 0)
-			printf("The connection stalled %d times due to packet loss.\n",
-					Timeouts);
-		if (waitsec > 0)
-			printf("The connection was idle %0.2f seconds (%0.2f%%) of the time.\n",
-					waitsec, (100 * waitsec / totaltesttime));
-	} else if (DupAcksIn > 0) {
-		printf("No packet loss - ");
-		if (ooorder > 0)
-			printf("but packets arrived out-of-order %0.2f%% of the time.\n",
-					ooorder * 100);
-		else
-			printf("\n");
-	} else {
-		printf("No packet loss was observed.\n");
-	}
+                                 double ooorder, int Timeouts, double waitsec , double totaltesttime) {
+
+  if (PktsRetrans > 0) {
+    printf("There were %d packets retransmitted", PktsRetrans);
+    printf(", %d duplicate acks received", DupAcksIn);
+    printf(", and %d SACK blocks received\n", SACKsRcvd);
+    if (ooorder > 0)
+      printf("Packets arrived out-of-order %0.2f%% of the time.\n",
+             ooorder * 100);
+    if (Timeouts > 0)
+      printf("The connection stalled %d times due to packet loss.\n",
+             Timeouts);
+    if (waitsec > 0)
+      printf("The connection was idle %0.2f seconds (%0.2f%%) of the time.\n",
+             waitsec, (100 * waitsec / totaltesttime));
+  } else if (DupAcksIn > 0) {
+    printf("No packet loss - ");
+    if (ooorder > 0)
+      printf("but packets arrived out-of-order %0.2f%% of the time.\n",
+             ooorder * 100);
+    else
+      printf("\n");
+  } else {
+    printf("No packet loss was observed.\n");
+  }
 
 }
 
@@ -252,26 +252,26 @@ void print_packetloss_statistics(int PktsRetrans, int DupAcksIn, int SACKsRcvd,
  */
 
 void print_limitedtime_ratio(double rwintime, double rwin, double sendtime, double swin, double cwndtime,
-		double rttsec, double mylinkspeed, int sndbuf, int max_rwinrcvd) {
-
-	if (rwintime > .015) {
-		printf("This connection is receiver limited %0.2f%% of the time.\n",
-				rwintime * 100);
-		if ((2 * (rwin / rttsec)) < mylinkspeed)
-			printf("  Increasing the current receive buffer (%0.2f KB) will improve performance\n",
-					(float) max_rwinrcvd / KILO_BITS);
-	}
-	if (sendtime > .015) {
-		printf("This connection is sender limited %0.2f%% of the time.\n",
-				sendtime * 100);
-		if ((2 * (swin / rttsec)) < mylinkspeed)
-			printf("  Increasing the current send buffer (%0.2f KB) will improve performance\n",
-					(float) sndbuf / KILO_BITS);
-	}
-	if (cwndtime > .005) {
-		printf("This connection is network limited %0.2f%% of the time.\n",
-				cwndtime * 100);
-	}
+                             double rttsec, double mylinkspeed, int sndbuf, int max_rwinrcvd) {
+
+  if (rwintime > .015) {
+    printf("This connection is receiver limited %0.2f%% of the time.\n",
+           rwintime * 100);
+    if ((2 * (rwin / rttsec)) < mylinkspeed)
+      printf("  Increasing the current receive buffer (%0.2f KB) will improve performance\n",
+             (float) max_rwinrcvd / KILO_BITS);
+  }
+  if (sendtime > .015) {
+    printf("This connection is sender limited %0.2f%% of the time.\n",
+           sendtime * 100);
+    if ((2 * (swin / rttsec)) < mylinkspeed)
+      printf("  Increasing the current send buffer (%0.2f KB) will improve performance\n",
+             (float) sndbuf / KILO_BITS);
+  }
+  if (cwndtime > .005) {
+    printf("This connection is network limited %0.2f%% of the time.\n",
+           cwndtime * 100);
+  }
 
 }
 
@@ -281,10 +281,10 @@ void print_limitedtime_ratio(double rwintime, double rwin, double sendtime, doub
  * @param loss packet loss
  */
 void print_packetloss_excess(double spd, double loss) {
-	if ((spd < 4) && (loss > .01)) {
-		printf("Excessive packet loss is impacting your performance, check the ");
-		printf("auto-negotiate function on your local PC and network switch\n");
-	}
+  if ((spd < 4) && (loss > .01)) {
+    printf("Excessive packet loss is impacting your performance, check the ");
+    printf("auto-negotiate function on your local PC and network switch\n");
+  }
 }
 
 /**
@@ -293,11 +293,11 @@ void print_packetloss_excess(double spd, double loss) {
  * @param SACKEnabled
  */
 void print_SAck_RFC2018(int SACKEnabled) {
-	printf("RFC 2018 Selective Acknowledgment: ");
-	if (SACKEnabled == 0)
-		printf("OFF\n");
-	else
-		printf("ON\n");
+  printf("RFC 2018 Selective Acknowledgment: ");
+  if (SACKEnabled == 0)
+    printf("OFF\n");
+  else
+    printf("ON\n");
 }
 
 /**
@@ -307,11 +307,11 @@ void print_SAck_RFC2018(int SACKEnabled) {
 
 void print_Nagle_RFC896(int is_nagleenabled)
 {
-	printf("RFC 896 Nagle Algorithm: ");
-	if (is_nagleenabled == 0)
-		printf("OFF\n");
-	else
-		printf("ON\n");
+  printf("RFC 896 Nagle Algorithm: ");
+  if (is_nagleenabled == 0)
+    printf("OFF\n");
+  else
+    printf("ON\n");
 }
 
 /**
@@ -320,11 +320,11 @@ void print_Nagle_RFC896(int is_nagleenabled)
  */
 void print_congestion_RFC3168(int is_ECNenabled)
 {
-	printf("RFC 3168 Explicit Congestion Notification: ");
-				if (is_ECNenabled == 0)
-					printf("OFF\n");
-				else
-					printf("ON\n");
+  printf("RFC 3168 Explicit Congestion Notification: ");
+  if (is_ECNenabled == 0)
+    printf("OFF\n");
+  else
+    printf("ON\n");
 
 }
 
@@ -335,11 +335,11 @@ void print_congestion_RFC3168(int is_ECNenabled)
  */
 void print_timestamping_RFC1323(int is_timestampenabled)
 {
-	printf("RFC 1323 Time Stamping: ");
-	if (is_timestampenabled == 0)
-		printf("OFF\n");
-	else
-		printf("ON\n");
+  printf("RFC 1323 Time Stamping: ");
+  if (is_timestampenabled == 0)
+    printf("OFF\n");
+  else
+    printf("ON\n");
 }
 
 /**
@@ -349,15 +349,15 @@ void print_timestamping_RFC1323(int is_timestampenabled)
  * @param winscale_sent value of the transmitted window scale option
  */
 void print_windowscaling(int max_rwinrcvd, int winscale_rcvd, int winscale_sent) {
-	printf("RFC 1323 Window Scaling: ");
-	if (max_rwinrcvd < 65535)
-		winscale_rcvd = 0;
-
-	if ((winscale_rcvd == 0) || (winscale_rcvd > 20))
-		printf("OFF\n");
-	else
-		printf("ON; Scaling Factors - Server=%d, Client=%d\n",
-				winscale_rcvd, winscale_sent);
+  printf("RFC 1323 Window Scaling: ");
+  if (max_rwinrcvd < 65535)
+    winscale_rcvd = 0;
+
+  if ((winscale_rcvd == 0) || (winscale_rcvd > 20))
+    printf("OFF\n");
+  else
+    printf("ON; Scaling Factors - Server=%d, Client=%d\n",
+           winscale_rcvd, winscale_sent);
 }
 
 /**
@@ -373,21 +373,21 @@ void print_windowscaling(int max_rwinrcvd, int winscale_rcvd, int winscale_sent)
  * @param estimate Estimated theoretical throughput
  */
 void print_throughputlimits(int max_rwinrcvd, int rcvwinscale, int *sndbuf,
-		double s_win, double r_win, double c_win, double rttsec, double estimate) {
-	int tempsendbuf = *sndbuf;
-	if ((rcvwinscale == 0) && (tempsendbuf > 65535))
-		tempsendbuf = 65535;
+                            double s_win, double r_win, double c_win, double rttsec, double estimate) {
+  int tempsendbuf = *sndbuf;
+  if ((rcvwinscale == 0) && (tempsendbuf > 65535))
+    tempsendbuf = 65535;
 
-	printf("The theoretical network limit is %0.2f Mbps\n", estimate);
+  printf("The theoretical network limit is %0.2f Mbps\n", estimate);
 
-	printf("The NDT server has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
-			(float) tempsendbuf / KILO_BITS, (float) s_win / rttsec);
+  printf("The NDT server has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
+         (float) tempsendbuf / KILO_BITS, (float) s_win / rttsec);
 
-	printf("Your PC/Workstation has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
-			(float) max_rwinrcvd / KILO_BITS, (float) r_win / rttsec);
+  printf("Your PC/Workstation has a %0.0f KByte buffer which limits the throughput to %0.2f Mbps\n",
+         (float) max_rwinrcvd / KILO_BITS, (float) r_win / rttsec);
 
-	printf("The network based flow control limits the throughput to %0.2f Mbps\n",
-			(float) c_win / rttsec);
+  printf("The network based flow control limits the throughput to %0.2f Mbps\n",
+         (float) c_win / rttsec);
 
 }
 
@@ -402,13 +402,13 @@ void print_throughputlimits(int max_rwinrcvd, int rcvwinscale, int *sndbuf,
  * @param s2c_linkspeed_ack Data link speed as detected by client acknowledgments
  */
 void print_linkspeed_dataacks(int isC2S_enabled, int c2s_linkspeed_data,
-		int c2s_linkspeed_ack, int s2c_linkspeed_data, int s2c_linkspeed_ack) {
-	if (isC2S_enabled) {
-		printf("\nClient Data reports link is '%3d', Client Acks report link is '%3d'\n",
-				c2s_linkspeed_data, c2s_linkspeed_ack);
-	}
-	printf("Server Data reports link is '%3d', Server Acks report link is '%3d'\n",
-			s2c_linkspeed_data, s2c_linkspeed_ack);
+                              int c2s_linkspeed_ack, int s2c_linkspeed_data, int s2c_linkspeed_ack) {
+  if (isC2S_enabled) {
+    printf("\nClient Data reports link is '%3d', Client Acks report link is '%3d'\n",
+           c2s_linkspeed_data, c2s_linkspeed_ack);
+  }
+  printf("Server Data reports link is '%3d', Server Acks report link is '%3d'\n",
+         s2c_linkspeed_data, s2c_linkspeed_ack);
 
 }
 
@@ -422,25 +422,25 @@ void print_linkspeed_dataacks(int isC2S_enabled, int c2s_linkspeed_data,
  */
 void check_NAT(char *ssip, char *csip, char *scip, char *ccip) {
 
-	// If server and client both see similar server IP addresses,
-	// no NAT happening
-	if (strcmp(ssip, csip) == 0)
-		printf("Server IP addresses are preserved End-to-End\n");
-	else {
-		printf("Information: Network Address Translation (NAT) box is ");
-		printf("modifying the Server's IP address\n");
-		printf("\tServer says [%s] but Client says [ %s]\n", ssip, csip);
-	}
-
-	// If server and client both see similar client IP addresses,
-	// no NAT happening
-	if (strcmp(scip, ccip) == 0)
-		printf("Client IP addresses are preserved End-to-End\n");
-	else {
-		printf("Information: Network Address Translation (NAT) box is ");
-		printf("modifying the Client's IP address\n");
-		printf("\tServer says [%s] but Client says [ %s]\n", scip, ccip);
-	}
+  // If server and client both see similar server IP addresses,
+  // no NAT happening
+  if (strcmp(ssip, csip) == 0)
+    printf("Server IP addresses are preserved End-to-End\n");
+  else {
+    printf("Information: Network Address Translation (NAT) box is ");
+    printf("modifying the Server's IP address\n");
+    printf("\tServer says [%s] but Client says [ %s]\n", ssip, csip);
+  }
+
+  // If server and client both see similar client IP addresses,
+  // no NAT happening
+  if (strcmp(scip, ccip) == 0)
+    printf("Client IP addresses are preserved End-to-End\n");
+  else {
+    printf("Information: Network Address Translation (NAT) box is ");
+    printf("modifying the Client's IP address\n");
+    printf("\tServer says [%s] but Client says [ %s]\n", scip, ccip);
+  }
 
 }
 
@@ -455,12 +455,12 @@ void check_NAT(char *ssip, char *csip, char *scip, char *ccip) {
  * @param mssvalue
  */
 void check_MSS_modification(int is_timestampenabled, int *mssvalue) {
-	if (is_timestampenabled == 1)
-		*mssvalue += 12;
-		if (*mssvalue == 1456)
-			printf("Packet size is preserved End-to-End\n");
-		else
-			printf("Information: Network Middlebox is modifying MSS variable (changed to %d)\n",
-					*mssvalue);
+  if (is_timestampenabled == 1)
+    *mssvalue += 12;
+  if (*mssvalue == 1456)
+    printf("Packet size is preserved End-to-End\n");
+  else
+    printf("Information: Network Middlebox is modifying MSS variable (changed to %d)\n",
+           *mssvalue);
 
 }
diff --git a/src/test_s2c_clt.c b/src/test_s2c_clt.c
index a3771da..04797d0 100644
--- a/src/test_s2c_clt.c
+++ b/src/test_s2c_clt.c
@@ -40,216 +40,216 @@ double spdin, s2cspd;
  */
 
 int test_s2c_clt(int ctlSocket, char tests, char* host, int conn_options,
-		int buf_size, char* result_srv) {
-	char buff[BUFFSIZE + 1];
-	int msgLen, msgType;
-	int s2cport = atoi(PORT3);
-	I2Addr sec_addr = NULL;
-	int inlth, retcode, one=1, set_size;
-	int inSocket;
-	socklen_t optlen;
-	uint32_t bytes;
-	double t;
-	struct timeval sel_tv;
-	fd_set rfd;
-	char* ptr;
-
-	// variables used for protocol validation logs
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-	enum TEST_ID testids = S2C;
-
-	if (tests & TEST_S2C) {
-		setCurrentTest(TEST_S2C);
-		//protocol logs
-		teststatuses = TEST_STARTED;
-		protolog_status(getpid(), testids, teststatuses, ctlSocket);
-
-        // First message expected from the server is a TEST_PREPARE. Any other message
-		// ...type is unexpected at this point.
-		log_println(1, " <-- S2C throughput test -->");
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed prepare message!");
-			return 1;
-		}
-		if (check_msg_type(S2C_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
-			return 2;
-		}
-		// This TEST_PREPARE message is expected to have the port number as message body.
-		// Check if this is a valid integral port.
-		if (msgLen <= 0) {
-			log_println(0, "Improper message");
-			return 3;
-		}
-		buff[msgLen] = 0;
-		if (check_int(buff, &s2cport)) {
-			log_println(0, "Invalid port number");
-			return 4;
-		}
-		log_println(1, "  -- port: %d", s2cport);
-
-		/* Cygwin seems to want/need this extra getsockopt() function
-		 * call.  It certainly doesn't do anything, but the S2C test fails
-		 * at the connect() call if it's not there.  4/14/05 RAC
-		 */
-		optlen = sizeof(set_size);
-		getsockopt(ctlSocket, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
-
-		// get "address details" of the server using the host name
-		if ((sec_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
-			log_println(0, "Unable to resolve server address: %s", strerror(errno));
-			return -3;
-		}
-		I2AddrSetPort(sec_addr, s2cport); //set port to value obtained from server
-
-		// Connect to the server; set socket options
-		if ((retcode = CreateConnectSocket(&inSocket, NULL, sec_addr, conn_options, buf_size))) {
-			log_println(0, "Connect() for Server to Client failed", strerror(errno));
-			return -15;
-		}
-
-		setsockopt(inSocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
-
-		/* Linux updates the sel_tv time values everytime select returns.  This
-		 * means that eventually the timer will reach 0 seconds and select will
-		 * exit with a timeout signal.  Other OS's don't do that so they need
-		 * another method for detecting a long-running process.  The check below
-		 * will cause the loop to terminate if select says there is something
-		 * to read and the loop has been active for over 14 seconds.  This usually
-		 * happens when there is a problem (duplex mismatch) and there is data
-		 * queued up on the server.
-		 */
-
-		// Expect a TEST_START message from server now. Any other message
-		// type is an error
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed start message!");
-			return 1;
-		}
-		if (check_msg_type(S2C_TEST_LOG, TEST_START, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// server performs the S->C throughput test now. Get data sent by server.
-
-		printf("running 10s inbound test (server to client) . . . . . . ");
-		fflush(stdout);
-
-		// Set socket timeout to 15 seconds
-		bytes = 0;
-		t = secs() + 15.0;
-		sel_tv.tv_sec = 15;
-		sel_tv.tv_usec = 5;
-		FD_ZERO(&rfd);
-		FD_SET(inSocket, &rfd);
-		// Read data sent by server as soon as it is available. Stop listening if
-		// ...timeout has been exceeded.
-		for (;;) {
-			retcode = select(inSocket+1, &rfd, NULL, NULL, &sel_tv);
-			if (secs() > t) {
-				log_println(5, "Receive test running long, break out of read loop");
-				break;
-			}
-			if (retcode > 0) {
-				inlth = read(inSocket, buff, sizeof(buff));
-				if (inlth == 0)
-				break;
-				bytes += inlth;
-				continue;
-			}
-			if (get_debuglvl() > 5) {
-				log_println(0, "s2c read loop exiting:", strerror(errno));
-			}
-			break;
-		}
-
-		// get actual time for which data was received, and calculate throughput based on it.
-		t = secs() - t + 15.0;
-		spdin = ((BITS_8_FLOAT * bytes) / KILO) / t; //kbps
-
-		//log_println(0,"S->C: Received %d bytes in %0.2f secs: Spdin= %f", bytes, t, spdin);
-
-		// Server sends calculated throughput value, unsent data amount in the socket queue
-		// and overall number of sent bytes in a TEST_MSG
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed text message!");
-			return 1;
-		}
-		if (check_msg_type(S2C_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
-			return 2; // no other message type expected
-		}
-		// Is message of valid length, and does it have all the data expected?
-		if (msgLen <= 0) {
-			log_println(0, "Improper message");
-			return 3;
-		}
-		buff[msgLen] = 0;
-		ptr = strtok(buff, " ");
-		if (ptr == NULL) {
-			log_println(0, "S2C: Improper message");
-			return 4;
-		}
-		s2cspd = atoi(ptr);  // get S->C throughput first
-		ptr = strtok(NULL, " ");
-		if (ptr == NULL) {
-			log_println(0, "S2C: Improper message");
-			return 4;
-		}
-		ssndqueue = atoi(ptr); // get amount of unsent data in queue
-		ptr = strtok(NULL, " ");
-		if (ptr == NULL) {
-			log_println(0, "S2C: Improper message");
-			return 4;
-		}
-		sbytes = atoi(ptr);	// finally get total-sent-byte-count
-		//log_println(0,"S->C received throughput: %f",s2cspd);
-		// log results in a convenient units format
-		if (spdin < 1000)
-		printf("%0.2f kb/s\n", spdin);
-		else
-		printf("%0.2f Mb/s\n", spdin/1000);
-
-		I2AddrFree(sec_addr);
-
-		// send TEST_MSG to server with the client-calculated throughput
-		snprintf(buff, sizeof(buff), "%0.0f", spdin);
-		send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
-
-		// client now expected to receive web100 variables collected by server
-
-		result_srv[0] = '\0';
-		for (;;) {
-			msgLen = sizeof(buff);
-			memset(buff,0,msgLen); // reset buff and msgLen
-
-			// get web100 variables
-			if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-				log_println(0, "Protocol error - missed text/finalize message!");
-				return 1;
-			}
-
-			// TEST_FINALIZE msg from server indicates end of web100 var transmission
-			if (msgType == TEST_FINALIZE) {
-				break;
-			}
-
-			// if neither TEST_FINALIZE, nor TEST_MSG, signal error!
-			if (check_msg_type(S2C_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
-				return 2;
-			}
-
-			strlcat(result_srv, buff, 2 * BUFFSIZE); // hardcoded size of array from main tests
-		}
-		log_println(6, "result_srv = '%s', of len %d", result_srv, msgLen);
-		log_println(1, " <------------------------->");
-
-		//log protocol validation logs
-		teststatuses = TEST_ENDED;
-		protolog_status(getpid(), testids, teststatuses,ctlSocket);
-		setCurrentTest(TEST_NONE);
-	}
-
-	return 0;
+                 int buf_size, char* result_srv) {
+  char buff[BUFFSIZE + 1];
+  int msgLen, msgType;
+  int s2cport = atoi(PORT3);
+  I2Addr sec_addr = NULL;
+  int inlth, retcode, one=1, set_size;
+  int inSocket;
+  socklen_t optlen;
+  uint32_t bytes;
+  double t;
+  struct timeval sel_tv;
+  fd_set rfd;
+  char* ptr;
+
+  // variables used for protocol validation logs
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+  enum TEST_ID testids = S2C;
+
+  if (tests & TEST_S2C) {
+    setCurrentTest(TEST_S2C);
+    //protocol logs
+    teststatuses = TEST_STARTED;
+    protolog_status(getpid(), testids, teststatuses, ctlSocket);
+
+    // First message expected from the server is a TEST_PREPARE. Any other message
+    // ...type is unexpected at this point.
+    log_println(1, " <-- S2C throughput test -->");
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed prepare message!");
+      return 1;
+    }
+    if (check_msg_type(S2C_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
+      return 2;
+    }
+    // This TEST_PREPARE message is expected to have the port number as message body.
+    // Check if this is a valid integral port.
+    if (msgLen <= 0) {
+      log_println(0, "Improper message");
+      return 3;
+    }
+    buff[msgLen] = 0;
+    if (check_int(buff, &s2cport)) {
+      log_println(0, "Invalid port number");
+      return 4;
+    }
+    log_println(1, "  -- port: %d", s2cport);
+
+    /* Cygwin seems to want/need this extra getsockopt() function
+     * call.  It certainly doesn't do anything, but the S2C test fails
+     * at the connect() call if it's not there.  4/14/05 RAC
+     */
+    optlen = sizeof(set_size);
+    getsockopt(ctlSocket, SOL_SOCKET, SO_SNDBUF, &set_size, &optlen);
+
+    // get "address details" of the server using the host name
+    if ((sec_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
+      log_println(0, "Unable to resolve server address: %s", strerror(errno));
+      return -3;
+    }
+    I2AddrSetPort(sec_addr, s2cport); //set port to value obtained from server
+
+    // Connect to the server; set socket options
+    if ((retcode = CreateConnectSocket(&inSocket, NULL, sec_addr, conn_options, buf_size))) {
+      log_println(0, "Connect() for Server to Client failed", strerror(errno));
+      return -15;
+    }
+
+    setsockopt(inSocket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+
+    /* Linux updates the sel_tv time values everytime select returns.  This
+     * means that eventually the timer will reach 0 seconds and select will
+     * exit with a timeout signal.  Other OS's don't do that so they need
+     * another method for detecting a long-running process.  The check below
+     * will cause the loop to terminate if select says there is something
+     * to read and the loop has been active for over 14 seconds.  This usually
+     * happens when there is a problem (duplex mismatch) and there is data
+     * queued up on the server.
+     */
+
+    // Expect a TEST_START message from server now. Any other message
+    // type is an error
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed start message!");
+      return 1;
+    }
+    if (check_msg_type(S2C_TEST_LOG, TEST_START, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // server performs the S->C throughput test now. Get data sent by server.
+
+    printf("running 10s inbound test (server to client) . . . . . . ");
+    fflush(stdout);
+
+    // Set socket timeout to 15 seconds
+    bytes = 0;
+    t = secs() + 15.0;
+    sel_tv.tv_sec = 15;
+    sel_tv.tv_usec = 5;
+    FD_ZERO(&rfd);
+    FD_SET(inSocket, &rfd);
+    // Read data sent by server as soon as it is available. Stop listening if
+    // ...timeout has been exceeded.
+    for (;;) {
+      retcode = select(inSocket+1, &rfd, NULL, NULL, &sel_tv);
+      if (secs() > t) {
+        log_println(5, "Receive test running long, break out of read loop");
+        break;
+      }
+      if (retcode > 0) {
+        inlth = read(inSocket, buff, sizeof(buff));
+        if (inlth == 0)
+          break;
+        bytes += inlth;
+        continue;
+      }
+      if (get_debuglvl() > 5) {
+        log_println(0, "s2c read loop exiting:", strerror(errno));
+      }
+      break;
+    }
+
+    // get actual time for which data was received, and calculate throughput based on it.
+    t = secs() - t + 15.0;
+    spdin = ((BITS_8_FLOAT * bytes) / KILO) / t; //kbps
+
+    //log_println(0,"S->C: Received %d bytes in %0.2f secs: Spdin= %f", bytes, t, spdin);
+
+    // Server sends calculated throughput value, unsent data amount in the socket queue
+    // and overall number of sent bytes in a TEST_MSG
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed text message!");
+      return 1;
+    }
+    if (check_msg_type(S2C_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
+      return 2; // no other message type expected
+    }
+    // Is message of valid length, and does it have all the data expected?
+    if (msgLen <= 0) {
+      log_println(0, "Improper message");
+      return 3;
+    }
+    buff[msgLen] = 0;
+    ptr = strtok(buff, " ");
+    if (ptr == NULL) {
+      log_println(0, "S2C: Improper message");
+      return 4;
+    }
+    s2cspd = atoi(ptr);  // get S->C throughput first
+    ptr = strtok(NULL, " ");
+    if (ptr == NULL) {
+      log_println(0, "S2C: Improper message");
+      return 4;
+    }
+    ssndqueue = atoi(ptr); // get amount of unsent data in queue
+    ptr = strtok(NULL, " ");
+    if (ptr == NULL) {
+      log_println(0, "S2C: Improper message");
+      return 4;
+    }
+    sbytes = atoi(ptr);	// finally get total-sent-byte-count
+    //log_println(0,"S->C received throughput: %f",s2cspd);
+    // log results in a convenient units format
+    if (spdin < 1000)
+      printf("%0.2f kb/s\n", spdin);
+    else
+      printf("%0.2f Mb/s\n", spdin/1000);
+
+    I2AddrFree(sec_addr);
+
+    // send TEST_MSG to server with the client-calculated throughput
+    snprintf(buff, sizeof(buff), "%0.0f", spdin);
+    send_msg(ctlSocket, TEST_MSG, buff, strlen(buff));
+
+    // client now expected to receive web100 variables collected by server
+
+    result_srv[0] = '\0';
+    for (;;) {
+      msgLen = sizeof(buff);
+      memset(buff,0,msgLen); // reset buff and msgLen
+
+      // get web100 variables
+      if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+        log_println(0, "Protocol error - missed text/finalize message!");
+        return 1;
+      }
+
+      // TEST_FINALIZE msg from server indicates end of web100 var transmission
+      if (msgType == TEST_FINALIZE) {
+        break;
+      }
+
+      // if neither TEST_FINALIZE, nor TEST_MSG, signal error!
+      if (check_msg_type(S2C_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
+        return 2;
+      }
+
+      strlcat(result_srv, buff, 2 * BUFFSIZE); // hardcoded size of array from main tests
+    }
+    log_println(6, "result_srv = '%s', of len %d", result_srv, msgLen);
+    log_println(1, " <------------------------->");
+
+    //log protocol validation logs
+    teststatuses = TEST_ENDED;
+    protolog_status(getpid(), testids, teststatuses,ctlSocket);
+    setCurrentTest(TEST_NONE);
+  }
+
+  return 0;
 }
diff --git a/src/test_s2c_srv.c b/src/test_s2c_srv.c
index f150b52..d8f7299 100644
--- a/src/test_s2c_srv.c
+++ b/src/test_s2c_srv.c
@@ -70,526 +70,526 @@ int mon_pipe2[2]; // used to store file descriptors of pipes created for ndttrac
  *  			-errno - Other specific socket error numbers
  */
 int test_s2c(int ctlsockfd, web100_agent* agent, TestOptions* testOptions,
-		int conn_options, double* s2cspd, int set_buff, int window,
-		int autotune, char* device, Options* options, char spds[4][256],
-		int* spd_index, int count_vars, CwndPeaks* peaks) {
-
-	int ret; // ctrl protocol read/write return status
-	int j, k, n;
-	int xmitsfd; // transmit (i.e server) socket fd
-	pid_t s2c_childpid = 0; // s2c_childpid
-
-	char tmpstr[256]; // string array used for temp storage of many char*
-	struct sockaddr_storage cli_addr;
-
-	socklen_t clilen;
-	double bytes_written; // bytes written in the throughput test
-	double tx_duration; // total time for which data was txed
-	double tmptime; // temporary time store
-	double x2cspd; // s->c test throughput
-	struct timeval sel_tv; // time
-	fd_set rfd; // receive file descriptor
-	char buff[BUFFSIZE + 1]; // message payload buffer
-	int bufctrlattempts = 0; // number of buffer control attempts
-	int i; // temporary var used for iterators etc
-	PortPair pair; // socket ports
-	I2Addr s2csrv_addr = NULL;
-	I2Addr src_addr = NULL;
-	char listens2cport[10];
-	int msgType;
-	int msgLen;
-	int sndqueue;
-	struct sigaction new, old;
-
-	/* experimental code to capture and log multiple copies of the
-	 * web100 variables using the web100_snap() & log() functions.
-	 */
-	web100_snapshot* tsnap = NULL;
-	web100_snapshot* rsnap = NULL;
-	web100_group* group;
-	web100_group* tgroup;
-	web100_group* rgroup;
-	web100_connection* conn;
-	web100_var* var;
-	pthread_t workerThreadId;
-	int nextseqtosend = 0, lastunackedseq = 0;
-	int drainingqueuecount = 0, bufctlrnewdata = 0; // sent data attempt queue, Draining Queue.
-
-	// variables used for protocol validation logs
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-	enum TEST_ID testids = S2C;
-	enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
-	enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
-	char snaplogsuffix[256] = "s2c_snaplog";
-
-	SnapArgs snapArgs;
-	snapArgs.snap = NULL;
-	snapArgs.log = NULL;
-	snapArgs.delay = options->snapDelay;
-	wait_sig = 0;
-
-	// Determine port to be used. Compute based on options set earlier
-	// by reading from config file, or use default port2 (3003)
-	if (testOptions->s2copt) {
-		setCurrentTest(TEST_S2C);
-		log_println(1, " <-- %d - S2C throughput test -->",
-				testOptions->child0);
-
-		//protocol logs
-		teststatuses = TEST_STARTED;
-		protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);
-
-		strlcpy(listens2cport, PORT4, sizeof(listens2cport));
-
-		if (testOptions->s2csockport) {
-			snprintf(listens2cport, sizeof(listens2cport), "%d", testOptions->s2csockport);
-		} else if (testOptions->mainport) {
-			snprintf(listens2cport, sizeof(listens2cport), "%d", testOptions->mainport + 2);
-		}
-
-		if (testOptions->multiple) {
-			strlcpy(listens2cport, "0", sizeof(listens2cport));
-		}
-
-		// attempt to bind to a new port and obtain address structure with details of listening port
-		while (s2csrv_addr == NULL) {
-			s2csrv_addr = CreateListenSocket(NULL,
-							(testOptions->multiple ?
-								mrange_next(listens2cport, sizeof(listens2cport)) :
-								listens2cport),
-							conn_options, 0);
-			if (s2csrv_addr == NULL) {
-				/*
-				 log_println(1, " Calling KillHung() because s2csrv_address failed to bind");
-				 if (KillHung() == 0)
-				 continue;
-				 */
-			}
-			if (strcmp(listens2cport, "0") == 0) {
-				log_println(0, "WARNING: ephemeral port number was bound");
-				break;
-			}
-			if (testOptions->multiple == 0) {
-				break;
-			}
-		}
-		if (s2csrv_addr == NULL) {
-			log_println(
-					0,
-					"Server (S2C throughput test): CreateListenSocket failed: %s",
-					strerror(errno));
-			snprintf(
-					buff,
-					sizeof(buff),
-					"Server (S2C throughput test): CreateListenSocket failed: %s",
-					strerror(errno));
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return -1;
-		}
-
-		// get socket FD and the ephemeral port number that client will connect to run tests
-		testOptions->s2csockfd = I2AddrFD(s2csrv_addr);
-		testOptions->s2csockport = I2AddrPort(s2csrv_addr);
-		log_println(1, "  -- s2c %d port: %d", testOptions->child0,
-				testOptions->s2csockport);
-		pair.port1 = -1;
-		pair.port2 = testOptions->s2csockport;
-
-		// Data received from speed-chk. Send TEST_PREPARE "GO" signal with port number
-		snprintf(buff, sizeof(buff), "%d", testOptions->s2csockport);
-		j = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff));
-		if (j == -1) {
-			log_println(6, "S2C %d Error!, Test start message not sent!",
-					testOptions->child0);
-			return j;
-		}
-		if (j == -2) { // could not write message data
-			log_println(6, "S2C %d Error!, server port [%s] not sent!",
-					testOptions->child0, buff);
-			return j;
-		}
-
-		// ok, await for connect on 3rd port
-		// This is the second throughput test, with data streaming from
-		// the server back to the client.  Again stream data for 10 seconds.
-
-		log_println(1, "%d waiting for data on testOptions->s2csockfd",
-				testOptions->child0);
-
-		clilen = sizeof(cli_addr);
-		FD_ZERO(&rfd);
-		FD_SET(testOptions->c2ssockfd, &rfd);
-		sel_tv.tv_sec = 5; // wait for 5 secs
-		sel_tv.tv_usec = 0;
-		for (j = 0; j < RETRY_COUNT; j++) {
-			ret = select((testOptions->s2csockfd) + 1, &rfd, NULL, NULL,
-					&sel_tv);
-			if ((ret == -1) && (errno == EINTR))
-				continue;
-			if (ret == 0)
-				return SOCKET_CONNECT_TIMEOUT; // timeout
-			if (ret < 0)
-				return -errno; // other socket errors. exit
-			if (j == 4)
-				return RETRY_EXCEEDED_WAITING_CONNECT; // retry exceeded. exit
-
-			// If a valid connection request is received, client has connected. Proceed.
-			// Note the new socket fd - xmitfd - used in the throughput test
-			ximfd: xmitsfd = accept(testOptions->s2csockfd,
-					(struct sockaddr *) &cli_addr, &clilen);
-			if (xmitsfd > 0) {
-				log_println(6, "accept() for %d completed",
-						testOptions->child0);
-				procstatusenum = PROCESS_STARTED;
-				proctypeenum = CONNECT_TYPE;
-				protolog_procstatus(testOptions->child0, testids, proctypeenum,
-						procstatusenum, xmitsfd);
-				break;
-			}
-			if ((xmitsfd == -1) && (errno == EINTR)) { // socket interrupted, wait some more
-				log_println(
-						6,
-						"Child %d interrupted while waiting for accept() to complete",
-						testOptions->child0);
-				goto ximfd;
-			}
-			log_println(
-					6,
-					"-------     S2C connection setup for %d returned because (%d)",
-					testOptions->child0, errno);
-			if (xmitsfd < 0) // other socket errors, quit
-				return -errno;
-			if (++j == 4) { // retry exceeded, quit
-				log_println(
-						6,
-						"s2c child %d, unable to open connection, return from test",
-						testOptions->child0);
-				return -102;
-			}
-		}
-		src_addr = I2AddrByLocalSockFD(get_errhandle(), xmitsfd, 0);
-		conn = web100_connection_from_socket(agent, xmitsfd);
-
-		// set up packet capture. The data collected is used for bottleneck link calculations
-		if (xmitsfd > 0) {
-			log_println(6, "S2C child %d, ready to fork()",
-					testOptions->child0);
-			if (getuid() == 0) {
-				/*
-				pipe(mon_pipe2);
-				start_packet_trace(xmitsfd, testOptions->s2csockfd,
-						&s2c_childpid, mon_pipe2, (struct sockaddr *) &cli_addr,
-						clilen, device, &pair, "s2c", options->compress,
-						meta.s2c_ndttrace);
-				*/
-				pipe(mon_pipe2);
-				if ((s2c_childpid = fork()) == 0) {
-					/* close(ctlsockfd); */
-					close(testOptions->s2csockfd);
-					close(xmitsfd);
-					log_println(
-							5,
-							"S2C test Child thinks pipe() returned fd0=%d, fd1=%d",
-							mon_pipe2[0], mon_pipe2[1]);
-					/* log_println(2, "S2C test calling init_pkttrace() with pd=0x%x", (int) &cli_addr); */
-					init_pkttrace(src_addr, (struct sockaddr *) &cli_addr,
-							clilen, mon_pipe2, device, &pair, "s2c",
-							options->compress);
-					log_println(6,
-							"S2C test ended, why is timer still running?");
-					exit(0); /* Packet trace finished, terminate gracefully */
-				}
-				memset(tmpstr, 0, 256);
-				for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
-					ret = read(mon_pipe2[0], tmpstr, 128);
-					if ((ret == -1) && (errno == EINTR)) // socket interrupted, try reading again
-						continue;
-					break;
-				}
-
-				if (strlen(tmpstr) > 5)
-					memcpy(meta.s2c_ndttrace, tmpstr, strlen(tmpstr));
-				// name of nettrace file passed back from pcap child copied into meta structure
-
-			}
-
-			/* experimental code, delete when finished */
-			setCwndlimit(conn, group, agent, options);
-			/* End of test code */
-
-			// create directory to write web100 snaplog trace
-			create_client_logdir((struct sockaddr *) &cli_addr, clilen,
-					options->s2c_logname, sizeof(options->s2c_logname),
-					snaplogsuffix, sizeof(snaplogsuffix));
-
-			/* Kludge way of nuking Linux route cache.  This should be done
-			 * using the sysctl interface.
-			 */
-			if (getuid() == 0) {
-				// system("/sbin/sysctl -w net.ipv4.route.flush=1");
-				system("echo 1 > /proc/sys/net/ipv4/route/flush");
-			}
-			rgroup = web100_group_find(agent, "read");
-			rsnap = web100_snapshot_alloc(rgroup, conn);
-			tgroup = web100_group_find(agent, "tune");
-			tsnap = web100_snapshot_alloc(tgroup, conn);
-
-			// fill send buffer with random printable data for throughput test
-			bytes_written = 0;
-			k = 0;
-			for (j = 0; j <= BUFFSIZE; j++) {
-				while (!isprint(k & 0x7f))
-					k++;
-				buff[j] = (k++ & 0x7f);
-			}
-
-			// Send message to client indicating TEST_START
-			if (send_msg(ctlsockfd, TEST_START, "", 0) < 0)
-				log_println(6,
-						"S2C test - Test-start message failed for pid=%d",
-						s2c_childpid);
-			// ignore the alarm signal
-			memset(&new, 0, sizeof(new));
-			new.sa_handler = catch_s2c_alrm;
-			sigaction(SIGALRM, &new, &old);
-
-			// capture current values (i.e take snap shot) of web_100 variables
-			// Write snap logs if option is enabled. update meta log to point to this snaplog
-
-			// If snaplog option is enabled, save snaplog details in meta file
-			if (options->snaplog) {
-				memcpy(meta.s2c_snaplog, snaplogsuffix, strlen(snaplogsuffix));
-			}
-			// get web100 snapshot and also log it based on options
-			/*start_snap_worker(&snapArgs, agent, options->snaplog, &workerLoop,
-			 &workerThreadId, meta.s2c_snaplog, options->s2c_logname,
-			 conn, group);*///new file changes
-			start_snap_worker(&snapArgs, agent, peaks, options->snaplog,
-					&workerThreadId, meta.s2c_snaplog, options->s2c_logname,
-					conn, group);
-
-			/* alarm(20); */
-			tmptime = secs(); // current time
-			tx_duration = tmptime + 10.0; // set timeout to 10 s in future
-
-			log_println(6, "S2C child %d beginning test", testOptions->child0);
-
-			while (secs() < tx_duration) {
-				bufctrlattempts++; // Increment total attempts at sending-> buffer control
-				if (options->avoidSndBlockUp) { // Do not block send buffers
-					pthread_mutex_lock(&mainmutex);
-
-					// get details of next sequence # to be sent and fetch value from snap file
-					web100_agent_find_var_and_group(agent, "SndNxt", &group,
-							&var);
-					web100_snap_read(var, snapArgs.snap, tmpstr);
-					nextseqtosend = atoi(
-							web100_value_to_text(web100_get_var_type(var),
-									tmpstr));
-					// get oldest un-acked sequence number
-					web100_agent_find_var_and_group(agent, "SndUna", &group,
-							&var);
-					web100_snap_read(var, snapArgs.snap, tmpstr);
-					lastunackedseq = atoi(
-							web100_value_to_text(web100_get_var_type(var),
-									tmpstr));
-					pthread_mutex_unlock(&mainmutex);
-
-					// Temporarily stop sending data if you sense that the buffer is overwhelmed
-					// This is calculated by checking if (8192 * 4) <
-					//        ((Next Sequence Number To Be Sent) - (Oldest Unacknowledged Sequence Number) - 1)
-					// Increment draining queue value
-					if (is_buffer_clogged(nextseqtosend, lastunackedseq)) {
-						drainingqueuecount++;
-						continue;
-					}
-				}
-
-				// attempt to write random data into the client socket
-				n = write(xmitsfd, buff, RECLTH);
-				if ((n == -1) && (errno == EINTR)) // socket interrupted, continue attempting to write
-					continue;
-				if (n < 0)
-					break; // all data written. Exit
-				bytes_written += n;
-
-				if (options->avoidSndBlockUp) {
-					bufctlrnewdata++; // increment "sent data" queue
-				}
-			} // Completed end of trying to transmit data for the goodput test
-			/* alarm(10); */
-			sigaction(SIGALRM, &old, NULL);
-			sndqueue = sndq_len(xmitsfd);
-
-			// finalize the midbox test ; disabling socket used for throughput test
-			log_println(6, "S2C child %d finished test", testOptions->child0);
-			shutdown(xmitsfd, SHUT_WR); /* end of write's */
-
-			// get actual time duration during which data was transmitted
-			tx_duration = secs() - tmptime;
-
-			// Throughput in kbps = (no of bits sent * 8) / (1000 * time data was sent)
-			x2cspd = (8.e-3 * bytes_written) / tx_duration;
-
-			// Release semaphore, and close snaplog file.  finalize other data
-			stop_snap_worker(&workerThreadId, options->snaplog, &snapArgs);
-
-			// send the x2cspd to the client
-			memset(buff, 0, sizeof(buff));
-
-			// Send throughput, unsent byte count, total sent byte count to client
-			snprintf(buff, sizeof(buff), "%0.0f %d %0.0f", x2cspd, sndqueue, bytes_written);
-			if (send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff)) < 0)
-				log_println(6,
-						"S2C test - failed to send test message to pid=%d",
-						s2c_childpid);
-
-			web100_snap(rsnap);
-			web100_snap(tsnap);
-
-			log_println(1, "sent %d bytes to client in %0.2f seconds",
-					(int) bytes_written, tx_duration);
-			log_println(
-					1,
-					"Buffer control counters Total = %d, new data = %d, Draining Queue = %d",
-					bufctrlattempts, bufctlrnewdata, drainingqueuecount);
-
-			/* Next send speed-chk a flag to retrieve the data it collected.
-			 * Skip this step if speed-chk isn't running.
-			 */
-
-			if (getuid() == 0) {
-				log_println(1, "Signal USR2(%d) sent to child [%d]", SIGUSR2,
-						s2c_childpid);
-				testOptions->child2 = s2c_childpid;
-				kill(s2c_childpid, SIGUSR2);
-				FD_ZERO(&rfd);
-				FD_SET(mon_pipe2[0], &rfd);
-				sel_tv.tv_sec = 1;
-				sel_tv.tv_usec = 100000;
-				i = 0;
-
-				for (;;) {
-					ret = select(mon_pipe2[0] + 1, &rfd, NULL, NULL, &sel_tv);
-					if ((ret == -1) && (errno == EINTR)) {
-						log_println(
-								6,
-								"Interrupt received while waiting for s2c select90 to finish, continuing");
-						continue;
-					}
-					if (((ret == -1) && (errno != EINTR)) || (ret == 0)) {
-						log_println(
-								4,
-								"Failed to read pkt-pair data from S2C flow, retcode=%d, reason=%d, EINTR=%d",
-								ret, errno, EINTR);
-						snprintf(
-								spds[(*spd_index)++],
-								sizeof(spds[*spd_index]),
-								" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
-						snprintf(
-								spds[(*spd_index)++],
-								sizeof(spds[*spd_index]),
-								" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
-						break;
-					}
-					/* There is something to read, so get it from the pktpair child.  If an interrupt occurs,
-					 * just skip the read and go on
-					 * RAC 2/8/10
-					 */
-					if (ret > 0) {
-						if ((ret = read(mon_pipe2[0], spds[*spd_index], 128))
-								< 0)
-							snprintf(
-									spds[*spd_index],
-									sizeof(spds[*spd_index]),
-									" -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
-						log_println(1,
-								"%d bytes read '%s' from S2C monitor pipe", ret,
-								spds[*spd_index]);
-						(*spd_index)++;
-						if (i++ == 1)
-							break;
-						sel_tv.tv_sec = 1;
-						sel_tv.tv_usec = 100000;
-						continue;
-					}
-				}
-			}
-
-			log_println(1, "%6.0f kbps inbound pid-%d", x2cspd, s2c_childpid);
-		}
-
-		/* alarm(30); *//* reset alarm() again, this 10 sec test should finish before this signal
-		 * is generated.  */
-		// Get web100 variables from snapshot taken earlier and send to client
-		log_println(6, "S2C-Send web100 data vars to client pid=%d",
-				s2c_childpid);
-		ret = web100_get_data(tsnap, ctlsockfd, agent, count_vars); //send web100 data to client
-		web100_snapshot_free(tsnap);
-		ret = web100_get_data(rsnap, ctlsockfd, agent, count_vars); //send tuning-related web100 data collected to client
-		web100_snapshot_free(rsnap);
-
-		// If sending web100 variables above failed, indicate to client
-		if (ret < 0) {
-			log_println(6, "S2C - No web100 data received for pid=%d",
-					s2c_childpid);
-			snprintf(buff, sizeof(buff), "No Data Collected: 000000");
-			send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-		}
-
-		// Wait for message from client. Client sends its calculated throughput value
-		log_println(6,"S2CSPD reception starts");
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error!");
-			snprintf(
-					buff,
-					sizeof(buff),
-					"Server (S2C throughput test): Invalid S2C throughput received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return -1;
-		}
-		if (check_msg_type("S2C throughput test", TEST_MSG, msgType, buff,
-				msgLen)) {
-			snprintf(
-					buff,
-					sizeof(buff),
-					"Server (S2C throughput test): Invalid S2C throughput received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return -2;
-		}
-		if (msgLen <= 0) {
-			log_println(0, "Improper message");
-			snprintf(
-					buff,
-					sizeof(buff),
-					"Server (S2C throughput test): Invalid S2C throughput received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return -3;
-		}
-		buff[msgLen] = 0;
-		*s2cspd = atoi(buff); // save Throughput value as seen by client
-		log_println(6, "S2CSPD from client %f", *s2cspd);
-		// Final activities of ending tests. Close sockets, file descriptors,
-		//    send finalise message to client
-		close(xmitsfd);
-		if (send_msg(ctlsockfd, TEST_FINALIZE, "", 0) < 0)
-			log_println(6,
-					"S2C test - failed to send finalize message to pid=%d",
-					s2c_childpid);
-
-		if (getuid() == 0) {
-			stop_packet_trace(mon_pipe2);
-		}
-
-		// log end of test (generic and protocol logs)
-		log_println(0, " <------------ %d ------------->", testOptions->child0);
-		//log protocol validation logs
-		teststatuses = TEST_ENDED;
-		protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
-
-		setCurrentTest(TEST_NONE);
-
-	}
-	return 0;
+             int conn_options, double* s2cspd, int set_buff, int window,
+             int autotune, char* device, Options* options, char spds[4][256],
+             int* spd_index, int count_vars, CwndPeaks* peaks) {
+
+  int ret; // ctrl protocol read/write return status
+  int j, k, n;
+  int xmitsfd; // transmit (i.e server) socket fd
+  pid_t s2c_childpid = 0; // s2c_childpid
+
+  char tmpstr[256]; // string array used for temp storage of many char*
+  struct sockaddr_storage cli_addr;
+
+  socklen_t clilen;
+  double bytes_written; // bytes written in the throughput test
+  double tx_duration; // total time for which data was txed
+  double tmptime; // temporary time store
+  double x2cspd; // s->c test throughput
+  struct timeval sel_tv; // time
+  fd_set rfd; // receive file descriptor
+  char buff[BUFFSIZE + 1]; // message payload buffer
+  int bufctrlattempts = 0; // number of buffer control attempts
+  int i; // temporary var used for iterators etc
+  PortPair pair; // socket ports
+  I2Addr s2csrv_addr = NULL;
+  I2Addr src_addr = NULL;
+  char listens2cport[10];
+  int msgType;
+  int msgLen;
+  int sndqueue;
+  struct sigaction new, old;
+
+  /* experimental code to capture and log multiple copies of the
+   * web100 variables using the web100_snap() & log() functions.
+   */
+  web100_snapshot* tsnap = NULL;
+  web100_snapshot* rsnap = NULL;
+  web100_group* group;
+  web100_group* tgroup;
+  web100_group* rgroup;
+  web100_connection* conn;
+  web100_var* var;
+  pthread_t workerThreadId;
+  int nextseqtosend = 0, lastunackedseq = 0;
+  int drainingqueuecount = 0, bufctlrnewdata = 0; // sent data attempt queue, Draining Queue.
+
+  // variables used for protocol validation logs
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+  enum TEST_ID testids = S2C;
+  enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
+  enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
+  char snaplogsuffix[256] = "s2c_snaplog";
+
+  SnapArgs snapArgs;
+  snapArgs.snap = NULL;
+  snapArgs.log = NULL;
+  snapArgs.delay = options->snapDelay;
+  wait_sig = 0;
+
+  // Determine port to be used. Compute based on options set earlier
+  // by reading from config file, or use default port2 (3003)
+  if (testOptions->s2copt) {
+    setCurrentTest(TEST_S2C);
+    log_println(1, " <-- %d - S2C throughput test -->",
+                testOptions->child0);
+
+    //protocol logs
+    teststatuses = TEST_STARTED;
+    protolog_status(testOptions->child0, testids, teststatuses, ctlsockfd);
+
+    strlcpy(listens2cport, PORT4, sizeof(listens2cport));
+
+    if (testOptions->s2csockport) {
+      snprintf(listens2cport, sizeof(listens2cport), "%d", testOptions->s2csockport);
+    } else if (testOptions->mainport) {
+      snprintf(listens2cport, sizeof(listens2cport), "%d", testOptions->mainport + 2);
+    }
+
+    if (testOptions->multiple) {
+      strlcpy(listens2cport, "0", sizeof(listens2cport));
+    }
+
+    // attempt to bind to a new port and obtain address structure with details of listening port
+    while (s2csrv_addr == NULL) {
+      s2csrv_addr = CreateListenSocket(NULL,
+                                       (testOptions->multiple ?
+                                        mrange_next(listens2cport, sizeof(listens2cport)) :
+                                        listens2cport),
+                                       conn_options, 0);
+      if (s2csrv_addr == NULL) {
+        /*
+           log_println(1, " Calling KillHung() because s2csrv_address failed to bind");
+           if (KillHung() == 0)
+           continue;
+           */
+      }
+      if (strcmp(listens2cport, "0") == 0) {
+        log_println(0, "WARNING: ephemeral port number was bound");
+        break;
+      }
+      if (testOptions->multiple == 0) {
+        break;
+      }
+    }
+    if (s2csrv_addr == NULL) {
+      log_println(
+          0,
+          "Server (S2C throughput test): CreateListenSocket failed: %s",
+          strerror(errno));
+      snprintf(
+          buff,
+          sizeof(buff),
+          "Server (S2C throughput test): CreateListenSocket failed: %s",
+          strerror(errno));
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return -1;
+    }
+
+    // get socket FD and the ephemeral port number that client will connect to run tests
+    testOptions->s2csockfd = I2AddrFD(s2csrv_addr);
+    testOptions->s2csockport = I2AddrPort(s2csrv_addr);
+    log_println(1, "  -- s2c %d port: %d", testOptions->child0,
+                testOptions->s2csockport);
+    pair.port1 = -1;
+    pair.port2 = testOptions->s2csockport;
+
+    // Data received from speed-chk. Send TEST_PREPARE "GO" signal with port number
+    snprintf(buff, sizeof(buff), "%d", testOptions->s2csockport);
+    j = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff));
+    if (j == -1) {
+      log_println(6, "S2C %d Error!, Test start message not sent!",
+                  testOptions->child0);
+      return j;
+    }
+    if (j == -2) { // could not write message data
+      log_println(6, "S2C %d Error!, server port [%s] not sent!",
+                  testOptions->child0, buff);
+      return j;
+    }
+
+    // ok, await for connect on 3rd port
+    // This is the second throughput test, with data streaming from
+    // the server back to the client.  Again stream data for 10 seconds.
+
+    log_println(1, "%d waiting for data on testOptions->s2csockfd",
+                testOptions->child0);
+
+    clilen = sizeof(cli_addr);
+    FD_ZERO(&rfd);
+    FD_SET(testOptions->c2ssockfd, &rfd);
+    sel_tv.tv_sec = 5; // wait for 5 secs
+    sel_tv.tv_usec = 0;
+    for (j = 0; j < RETRY_COUNT; j++) {
+      ret = select((testOptions->s2csockfd) + 1, &rfd, NULL, NULL,
+                   &sel_tv);
+      if ((ret == -1) && (errno == EINTR))
+        continue;
+      if (ret == 0)
+        return SOCKET_CONNECT_TIMEOUT; // timeout
+      if (ret < 0)
+        return -errno; // other socket errors. exit
+      if (j == 4)
+        return RETRY_EXCEEDED_WAITING_CONNECT; // retry exceeded. exit
+
+      // If a valid connection request is received, client has connected. Proceed.
+      // Note the new socket fd - xmitfd - used in the throughput test
+ximfd: xmitsfd = accept(testOptions->s2csockfd,
+                        (struct sockaddr *) &cli_addr, &clilen);
+       if (xmitsfd > 0) {
+         log_println(6, "accept() for %d completed",
+                     testOptions->child0);
+         procstatusenum = PROCESS_STARTED;
+         proctypeenum = CONNECT_TYPE;
+         protolog_procstatus(testOptions->child0, testids, proctypeenum,
+                             procstatusenum, xmitsfd);
+         break;
+       }
+       if ((xmitsfd == -1) && (errno == EINTR)) { // socket interrupted, wait some more
+         log_println(
+             6,
+             "Child %d interrupted while waiting for accept() to complete",
+             testOptions->child0);
+         goto ximfd;
+       }
+       log_println(
+           6,
+           "-------     S2C connection setup for %d returned because (%d)",
+           testOptions->child0, errno);
+       if (xmitsfd < 0) // other socket errors, quit
+         return -errno;
+       if (++j == 4) { // retry exceeded, quit
+         log_println(
+             6,
+             "s2c child %d, unable to open connection, return from test",
+             testOptions->child0);
+         return -102;
+       }
+    }
+    src_addr = I2AddrByLocalSockFD(get_errhandle(), xmitsfd, 0);
+    conn = web100_connection_from_socket(agent, xmitsfd);
+
+    // set up packet capture. The data collected is used for bottleneck link calculations
+    if (xmitsfd > 0) {
+      log_println(6, "S2C child %d, ready to fork()",
+                  testOptions->child0);
+      if (getuid() == 0) {
+        /*
+           pipe(mon_pipe2);
+           start_packet_trace(xmitsfd, testOptions->s2csockfd,
+           &s2c_childpid, mon_pipe2, (struct sockaddr *) &cli_addr,
+           clilen, device, &pair, "s2c", options->compress,
+           meta.s2c_ndttrace);
+           */
+        pipe(mon_pipe2);
+        if ((s2c_childpid = fork()) == 0) {
+          /* close(ctlsockfd); */
+          close(testOptions->s2csockfd);
+          close(xmitsfd);
+          log_println(
+              5,
+              "S2C test Child thinks pipe() returned fd0=%d, fd1=%d",
+              mon_pipe2[0], mon_pipe2[1]);
+          /* log_println(2, "S2C test calling init_pkttrace() with pd=0x%x", (int) &cli_addr); */
+          init_pkttrace(src_addr, (struct sockaddr *) &cli_addr,
+                        clilen, mon_pipe2, device, &pair, "s2c",
+                        options->compress);
+          log_println(6,
+                      "S2C test ended, why is timer still running?");
+          exit(0); /* Packet trace finished, terminate gracefully */
+        }
+        memset(tmpstr, 0, 256);
+        for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
+          ret = read(mon_pipe2[0], tmpstr, 128);
+          if ((ret == -1) && (errno == EINTR)) // socket interrupted, try reading again
+            continue;
+          break;
+        }
+
+        if (strlen(tmpstr) > 5)
+          memcpy(meta.s2c_ndttrace, tmpstr, strlen(tmpstr));
+        // name of nettrace file passed back from pcap child copied into meta structure
+
+      }
+
+      /* experimental code, delete when finished */
+      setCwndlimit(conn, group, agent, options);
+      /* End of test code */
+
+      // create directory to write web100 snaplog trace
+      create_client_logdir((struct sockaddr *) &cli_addr, clilen,
+                           options->s2c_logname, sizeof(options->s2c_logname),
+                           snaplogsuffix, sizeof(snaplogsuffix));
+
+      /* Kludge way of nuking Linux route cache.  This should be done
+       * using the sysctl interface.
+       */
+      if (getuid() == 0) {
+        // system("/sbin/sysctl -w net.ipv4.route.flush=1");
+        system("echo 1 > /proc/sys/net/ipv4/route/flush");
+      }
+      rgroup = web100_group_find(agent, "read");
+      rsnap = web100_snapshot_alloc(rgroup, conn);
+      tgroup = web100_group_find(agent, "tune");
+      tsnap = web100_snapshot_alloc(tgroup, conn);
+
+      // fill send buffer with random printable data for throughput test
+      bytes_written = 0;
+      k = 0;
+      for (j = 0; j <= BUFFSIZE; j++) {
+        while (!isprint(k & 0x7f))
+          k++;
+        buff[j] = (k++ & 0x7f);
+      }
+
+      // Send message to client indicating TEST_START
+      if (send_msg(ctlsockfd, TEST_START, "", 0) < 0)
+        log_println(6,
+                    "S2C test - Test-start message failed for pid=%d",
+                    s2c_childpid);
+      // ignore the alarm signal
+      memset(&new, 0, sizeof(new));
+      new.sa_handler = catch_s2c_alrm;
+      sigaction(SIGALRM, &new, &old);
+
+      // capture current values (i.e take snap shot) of web_100 variables
+      // Write snap logs if option is enabled. update meta log to point to this snaplog
+
+      // If snaplog option is enabled, save snaplog details in meta file
+      if (options->snaplog) {
+        memcpy(meta.s2c_snaplog, snaplogsuffix, strlen(snaplogsuffix));
+      }
+      // get web100 snapshot and also log it based on options
+      /*start_snap_worker(&snapArgs, agent, options->snaplog, &workerLoop,
+        &workerThreadId, meta.s2c_snaplog, options->s2c_logname,
+        conn, group);*///new file changes
+      start_snap_worker(&snapArgs, agent, peaks, options->snaplog,
+                        &workerThreadId, meta.s2c_snaplog, options->s2c_logname,
+                        conn, group);
+
+      /* alarm(20); */
+      tmptime = secs(); // current time
+      tx_duration = tmptime + 10.0; // set timeout to 10 s in future
+
+      log_println(6, "S2C child %d beginning test", testOptions->child0);
+
+      while (secs() < tx_duration) {
+        bufctrlattempts++; // Increment total attempts at sending-> buffer control
+        if (options->avoidSndBlockUp) { // Do not block send buffers
+          pthread_mutex_lock(&mainmutex);
+
+          // get details of next sequence # to be sent and fetch value from snap file
+          web100_agent_find_var_and_group(agent, "SndNxt", &group,
+                                          &var);
+          web100_snap_read(var, snapArgs.snap, tmpstr);
+          nextseqtosend = atoi(
+              web100_value_to_text(web100_get_var_type(var),
+                                   tmpstr));
+          // get oldest un-acked sequence number
+          web100_agent_find_var_and_group(agent, "SndUna", &group,
+                                          &var);
+          web100_snap_read(var, snapArgs.snap, tmpstr);
+          lastunackedseq = atoi(
+              web100_value_to_text(web100_get_var_type(var),
+                                   tmpstr));
+          pthread_mutex_unlock(&mainmutex);
+
+          // Temporarily stop sending data if you sense that the buffer is overwhelmed
+          // This is calculated by checking if (8192 * 4) <
+          //        ((Next Sequence Number To Be Sent) - (Oldest Unacknowledged Sequence Number) - 1)
+          // Increment draining queue value
+          if (is_buffer_clogged(nextseqtosend, lastunackedseq)) {
+            drainingqueuecount++;
+            continue;
+          }
+        }
+
+        // attempt to write random data into the client socket
+        n = write(xmitsfd, buff, RECLTH);
+        if ((n == -1) && (errno == EINTR)) // socket interrupted, continue attempting to write
+          continue;
+        if (n < 0)
+          break; // all data written. Exit
+        bytes_written += n;
+
+        if (options->avoidSndBlockUp) {
+          bufctlrnewdata++; // increment "sent data" queue
+        }
+      } // Completed end of trying to transmit data for the goodput test
+      /* alarm(10); */
+      sigaction(SIGALRM, &old, NULL);
+      sndqueue = sndq_len(xmitsfd);
+
+      // finalize the midbox test ; disabling socket used for throughput test
+      log_println(6, "S2C child %d finished test", testOptions->child0);
+      shutdown(xmitsfd, SHUT_WR); /* end of write's */
+
+      // get actual time duration during which data was transmitted
+      tx_duration = secs() - tmptime;
+
+      // Throughput in kbps = (no of bits sent * 8) / (1000 * time data was sent)
+      x2cspd = (8.e-3 * bytes_written) / tx_duration;
+
+      // Release semaphore, and close snaplog file.  finalize other data
+      stop_snap_worker(&workerThreadId, options->snaplog, &snapArgs);
+
+      // send the x2cspd to the client
+      memset(buff, 0, sizeof(buff));
+
+      // Send throughput, unsent byte count, total sent byte count to client
+      snprintf(buff, sizeof(buff), "%0.0f %d %0.0f", x2cspd, sndqueue, bytes_written);
+      if (send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff)) < 0)
+        log_println(6,
+                    "S2C test - failed to send test message to pid=%d",
+                    s2c_childpid);
+
+      web100_snap(rsnap);
+      web100_snap(tsnap);
+
+      log_println(1, "sent %d bytes to client in %0.2f seconds",
+                  (int) bytes_written, tx_duration);
+      log_println(
+          1,
+          "Buffer control counters Total = %d, new data = %d, Draining Queue = %d",
+          bufctrlattempts, bufctlrnewdata, drainingqueuecount);
+
+      /* Next send speed-chk a flag to retrieve the data it collected.
+       * Skip this step if speed-chk isn't running.
+       */
+
+      if (getuid() == 0) {
+        log_println(1, "Signal USR2(%d) sent to child [%d]", SIGUSR2,
+                    s2c_childpid);
+        testOptions->child2 = s2c_childpid;
+        kill(s2c_childpid, SIGUSR2);
+        FD_ZERO(&rfd);
+        FD_SET(mon_pipe2[0], &rfd);
+        sel_tv.tv_sec = 1;
+        sel_tv.tv_usec = 100000;
+        i = 0;
+
+        for (;;) {
+          ret = select(mon_pipe2[0] + 1, &rfd, NULL, NULL, &sel_tv);
+          if ((ret == -1) && (errno == EINTR)) {
+            log_println(
+                6,
+                "Interrupt received while waiting for s2c select90 to finish, continuing");
+            continue;
+          }
+          if (((ret == -1) && (errno != EINTR)) || (ret == 0)) {
+            log_println(
+                4,
+                "Failed to read pkt-pair data from S2C flow, retcode=%d, reason=%d, EINTR=%d",
+                ret, errno, EINTR);
+            snprintf(
+                spds[(*spd_index)++],
+                sizeof(spds[*spd_index]),
+                " -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
+            snprintf(
+                spds[(*spd_index)++],
+                sizeof(spds[*spd_index]),
+                " -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
+            break;
+          }
+          /* There is something to read, so get it from the pktpair child.  If an interrupt occurs,
+           * just skip the read and go on
+           * RAC 2/8/10
+           */
+          if (ret > 0) {
+            if ((ret = read(mon_pipe2[0], spds[*spd_index], 128))
+                < 0)
+              snprintf(
+                  spds[*spd_index],
+                  sizeof(spds[*spd_index]),
+                  " -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0.0 0 0 0 0 0 -1");
+            log_println(1,
+                        "%d bytes read '%s' from S2C monitor pipe", ret,
+                        spds[*spd_index]);
+            (*spd_index)++;
+            if (i++ == 1)
+              break;
+            sel_tv.tv_sec = 1;
+            sel_tv.tv_usec = 100000;
+            continue;
+          }
+        }
+      }
+
+      log_println(1, "%6.0f kbps inbound pid-%d", x2cspd, s2c_childpid);
+    }
+
+    /* alarm(30); *//* reset alarm() again, this 10 sec test should finish before this signal
+     * is generated.  */
+    // Get web100 variables from snapshot taken earlier and send to client
+    log_println(6, "S2C-Send web100 data vars to client pid=%d",
+                s2c_childpid);
+    ret = web100_get_data(tsnap, ctlsockfd, agent, count_vars); //send web100 data to client
+    web100_snapshot_free(tsnap);
+    ret = web100_get_data(rsnap, ctlsockfd, agent, count_vars); //send tuning-related web100 data collected to client
+    web100_snapshot_free(rsnap);
+
+    // If sending web100 variables above failed, indicate to client
+    if (ret < 0) {
+      log_println(6, "S2C - No web100 data received for pid=%d",
+                  s2c_childpid);
+      snprintf(buff, sizeof(buff), "No Data Collected: 000000");
+      send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+    }
+
+    // Wait for message from client. Client sends its calculated throughput value
+    log_println(6,"S2CSPD reception starts");
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error!");
+      snprintf(
+          buff,
+          sizeof(buff),
+          "Server (S2C throughput test): Invalid S2C throughput received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return -1;
+    }
+    if (check_msg_type("S2C throughput test", TEST_MSG, msgType, buff,
+                       msgLen)) {
+      snprintf(
+          buff,
+          sizeof(buff),
+          "Server (S2C throughput test): Invalid S2C throughput received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return -2;
+    }
+    if (msgLen <= 0) {
+      log_println(0, "Improper message");
+      snprintf(
+          buff,
+          sizeof(buff),
+          "Server (S2C throughput test): Invalid S2C throughput received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return -3;
+    }
+    buff[msgLen] = 0;
+    *s2cspd = atoi(buff); // save Throughput value as seen by client
+    log_println(6, "S2CSPD from client %f", *s2cspd);
+    // Final activities of ending tests. Close sockets, file descriptors,
+    //    send finalise message to client
+    close(xmitsfd);
+    if (send_msg(ctlsockfd, TEST_FINALIZE, "", 0) < 0)
+      log_println(6,
+                  "S2C test - failed to send finalize message to pid=%d",
+                  s2c_childpid);
+
+    if (getuid() == 0) {
+      stop_packet_trace(mon_pipe2);
+    }
+
+    // log end of test (generic and protocol logs)
+    log_println(0, " <------------ %d ------------->", testOptions->child0);
+    //log protocol validation logs
+    teststatuses = TEST_ENDED;
+    protolog_status(testOptions->child0, testids, teststatuses,ctlsockfd);
+
+    setCurrentTest(TEST_NONE);
+
+  }
+  return 0;
 }
diff --git a/src/test_sfw_clt.c b/src/test_sfw_clt.c
index a4b601d..957b485 100644
--- a/src/test_sfw_clt.c
+++ b/src/test_sfw_clt.c
@@ -31,11 +31,11 @@ static I2Addr sfwcli_addr = NULL;
  * @param signo signal number (shuld be SIGALRM)
  */
 void catch_alrm(int signo) {
-	if (signo == SIGALRM) {
-		log_println(1, "SIGALRM was caught");
-		return;
-	}
-	log_println(0, "Unknown (%d) signal was caught", signo);
+  if (signo == SIGALRM) {
+    log_println(1, "SIGALRM was caught");
+    return;
+  }
+  log_println(0, "Unknown (%d) signal was caught", signo);
 }
 
 /**
@@ -51,96 +51,96 @@ void catch_alrm(int signo) {
 
 void*
 test_osfw_clt(void* vptr) {
-	char buff[BUFFSIZE + 1];
-	int sockfd;
-	fd_set fds;
-	struct timeval sel_tv;
-	int msgLen, msgType;
-	struct sockaddr_storage srv_addr;
-	socklen_t srvlen;
-
-	// protocol logging
-	enum PROCESS_TYPE_INT proctypeenum = PROCESS_TYPE;
-	enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
-	enum TEST_ID testids = SFW;
-
-	// listen for a message from server for a preset time, testTime
-	FD_ZERO(&fds);
-	FD_SET(sfwsockfd, &fds);
-	sel_tv.tv_sec = testTime;
-	sel_tv.tv_usec = 0;
-	switch (select(sfwsockfd+1, &fds, NULL, NULL, &sel_tv)) {
-		case -1: // If Socket error, status of firewall is unknown
-		log_println(0, "Simple firewall test: select exited with error");
-		I2AddrFree(sfwcli_addr);
-		return NULL;
-		case 0: // timeout, indicates that firewall is a possibility
-		log_println(1, "Simple firewall test: CLT: no connection for %d seconds", testTime);
-		s2c_result = SFW_POSSIBLE;
-		I2AddrFree(sfwcli_addr);
-		return NULL;
-	}
-
-	// Get message sent by server. If message reception is erroneous, firewall status
-	// .. cannot be determined
-	srvlen = sizeof(srv_addr);
-	sockfd = accept(sfwsockfd, (struct sockaddr *) &srv_addr, &srvlen);
-
-	// log protocol for connection accept
-	if (sockfd > 0) {
-		procstatusenum = PROCESS_STARTED;
-		proctypeenum = CONNECT_TYPE;
-		protolog_procstatus(getpid(), testids , proctypeenum,
-			procstatusenum, sockfd );
-	}
-
-	msgLen = sizeof(buff);
-	if (recv_msg(sockfd, &msgType, buff, &msgLen)) {
-		log_println(0, "Simple firewall test: unrecognized message");
-		s2c_result = SFW_UNKNOWN;
-		close(sockfd);
-		I2AddrFree(sfwcli_addr);
-		return NULL;
-	}
-
-	// The server is expected to send a TEST_MSG type of packet. Any other message
-	// .. type is unexpected at this point and leaves firewall status indeterminate.
-	if (check_msg_type(SFW_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
-		s2c_result = SFW_UNKNOWN;
-		close(sockfd);
-		I2AddrFree(sfwcli_addr);
-		return NULL;
-	}
-
-	// The server is expected to send a 20 char message that
-	// says "Simple firewall test" . Every other message string
-	// indicates an unknown firewall status
-
-	if (msgLen != SFW_TEST_DEFAULT_LEN) {
-		log_println(0, "Simple firewall test: Improper message");
-		s2c_result = SFW_UNKNOWN;
-		close(sockfd);
-		I2AddrFree(sfwcli_addr);
-		return NULL;
-	}
-	buff[msgLen] = 0;
-	if (strcmp(buff, SFW_PREDEFINED_TEST_MSG) != 0) {
-		log_println(0, "Simple firewall test: Improper message");
-		s2c_result = SFW_UNKNOWN;
-		close(sockfd);
-		I2AddrFree(sfwcli_addr);
-		return NULL;
-	}
-
-	// If none of the above conditions were met, then, the server
-	// message has been received correctly, and there seems to be no
-	// firewall. Perform clean-up activities.
-
-	s2c_result = SFW_NOFIREWALL;
-	close(sockfd);
-	I2AddrFree(sfwcli_addr);
-
-	return NULL;
+  char buff[BUFFSIZE + 1];
+  int sockfd;
+  fd_set fds;
+  struct timeval sel_tv;
+  int msgLen, msgType;
+  struct sockaddr_storage srv_addr;
+  socklen_t srvlen;
+
+  // protocol logging
+  enum PROCESS_TYPE_INT proctypeenum = PROCESS_TYPE;
+  enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
+  enum TEST_ID testids = SFW;
+
+  // listen for a message from server for a preset time, testTime
+  FD_ZERO(&fds);
+  FD_SET(sfwsockfd, &fds);
+  sel_tv.tv_sec = testTime;
+  sel_tv.tv_usec = 0;
+  switch (select(sfwsockfd+1, &fds, NULL, NULL, &sel_tv)) {
+    case -1: // If Socket error, status of firewall is unknown
+      log_println(0, "Simple firewall test: select exited with error");
+      I2AddrFree(sfwcli_addr);
+      return NULL;
+    case 0: // timeout, indicates that firewall is a possibility
+      log_println(1, "Simple firewall test: CLT: no connection for %d seconds", testTime);
+      s2c_result = SFW_POSSIBLE;
+      I2AddrFree(sfwcli_addr);
+      return NULL;
+  }
+
+  // Get message sent by server. If message reception is erroneous, firewall status
+  // .. cannot be determined
+  srvlen = sizeof(srv_addr);
+  sockfd = accept(sfwsockfd, (struct sockaddr *) &srv_addr, &srvlen);
+
+  // log protocol for connection accept
+  if (sockfd > 0) {
+    procstatusenum = PROCESS_STARTED;
+    proctypeenum = CONNECT_TYPE;
+    protolog_procstatus(getpid(), testids , proctypeenum,
+                        procstatusenum, sockfd );
+  }
+
+  msgLen = sizeof(buff);
+  if (recv_msg(sockfd, &msgType, buff, &msgLen)) {
+    log_println(0, "Simple firewall test: unrecognized message");
+    s2c_result = SFW_UNKNOWN;
+    close(sockfd);
+    I2AddrFree(sfwcli_addr);
+    return NULL;
+  }
+
+  // The server is expected to send a TEST_MSG type of packet. Any other message
+  // .. type is unexpected at this point and leaves firewall status indeterminate.
+  if (check_msg_type(SFW_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
+    s2c_result = SFW_UNKNOWN;
+    close(sockfd);
+    I2AddrFree(sfwcli_addr);
+    return NULL;
+  }
+
+  // The server is expected to send a 20 char message that
+  // says "Simple firewall test" . Every other message string
+  // indicates an unknown firewall status
+
+  if (msgLen != SFW_TEST_DEFAULT_LEN) {
+    log_println(0, "Simple firewall test: Improper message");
+    s2c_result = SFW_UNKNOWN;
+    close(sockfd);
+    I2AddrFree(sfwcli_addr);
+    return NULL;
+  }
+  buff[msgLen] = 0;
+  if (strcmp(buff, SFW_PREDEFINED_TEST_MSG) != 0) {
+    log_println(0, "Simple firewall test: Improper message");
+    s2c_result = SFW_UNKNOWN;
+    close(sockfd);
+    I2AddrFree(sfwcli_addr);
+    return NULL;
+  }
+
+  // If none of the above conditions were met, then, the server
+  // message has been received correctly, and there seems to be no
+  // firewall. Perform clean-up activities.
+
+  s2c_result = SFW_NOFIREWALL;
+  close(sockfd);
+  I2AddrFree(sfwcli_addr);
+
+  return NULL;
 }
 
 /**
@@ -166,161 +166,161 @@ test_osfw_clt(void* vptr) {
  *
  */
 int test_sfw_clt(int ctlsockfd, char tests, char* host, int conn_options) {
-	char buff[BUFFSIZE + 1];int msgLen, msgType;
-	int sfwport, sfwsock, sfwsockport;
-	I2Addr sfwsrv_addr = NULL;
-	struct sigaction new, old;
-	char* ptr;
-	pthread_t threadId;
-
-	// variables used for protocol validation logs
-	enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
-	enum TEST_ID testids = SFW;
-
-	if (tests & TEST_SFW) { // SFW test is to be performed
-		log_println(1, " <-- Simple firewall test -->");
-		setCurrentTest(TEST_SFW);
-		//protocol logs
-		teststatuses = TEST_STARTED;
-		protolog_status(getpid(), testids, teststatuses, ctlsockfd);
-
-
-		printf("checking for firewalls . . . . . . . . . . . . . . . . . . .  ");
-		fflush(stdout);
-		msgLen = sizeof(buff);
-
-		// The first message expected from the server is a TEST_PREPARE message.
-		// Any other type of message is unexpected at this time.
-		if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed prepare message!");
-			return 1;
-		}
-		if (check_msg_type(SFW_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// This message is expected to be of valid length, and have a message
-		// .. payload containing the integral ephemeral port number and testTime
-		// ... separated by a single space
-		if (msgLen <= 0) {
-			log_println(0, "Improper message");
-			return 3;
-		}
-		buff[msgLen] = 0;
-		ptr = strtok(buff, " ");
-		if (ptr == NULL) {
-			log_println(0, "SFW: Improper message");
-			return 5;
-		}
-		if (check_int(ptr, &sfwport)) {  // get ephemeral port#
-			log_println(0, "Invalid port number");
-			return 4;
-		}
-		ptr = strtok(NULL, " ");
-		if (ptr == NULL) {
-			log_println(0, "SFW: Improper message");
-			return 5;
-		}
-		if (check_int(ptr, &testTime)) { // get test time
-			log_println(0, "Invalid waiting time");
-			return 4;
-		}
-		log_println(1, "\n  -- port: %d", sfwport);
-		log_println(1, "  -- time: %d", testTime);
-		if ((sfwsrv_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
-			log_println(0, "Unable to resolve server address: %s", strerror(errno));
-			return -3;
-		}
-		I2AddrSetPort(sfwsrv_addr, sfwport);
-
-		// create a listening socket, and if successful, send this socket number to server
-		sfwcli_addr = CreateListenSocket(NULL, "0", conn_options, 0);
-		if (sfwcli_addr == NULL) {
-			log_println(0, "Client (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
-			return -1;
-		}
-		sfwsockfd = I2AddrFD(sfwcli_addr);
-		sfwsockport = I2AddrPort(sfwcli_addr);
-		log_println(1, "  -- oport: %d", sfwsockport);
-
-		// Send a TEST_MSG to server with the client's port number
-		snprintf(buff, sizeof(buff), "%d", sfwsockport);
-		send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-
-		// The server responds to the TEST_MSG messages with a TEST_START message.
-		// Any other type of message is an error here.
-		if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed start message!");
-			return 1;
-		}
-		if (check_msg_type(SFW_TEST_LOG, TEST_START, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// Now listen for server sending out a test for the S->C direction , and
-        // update test results
-		pthread_create(&threadId, NULL, &test_osfw_clt, NULL);
-
-		// ignore the alarm signal
-		memset(&new, 0, sizeof(new));
-		new.sa_handler = catch_alrm;
-		sigaction(SIGALRM, &new, &old);
-		alarm(testTime + 1);
-
-		// Now, run Test from client for the C->S direction SFW test
-        // ..trying to connect to ephemeral port number sent by server
-
-		if (CreateConnectSocket(&sfwsock, NULL, sfwsrv_addr, conn_options, 0) == 0) {
-			send_msg(sfwsock, TEST_MSG, SFW_PREDEFINED_TEST_MSG, 20);
-		}
-		alarm(0);
-		sigaction(SIGALRM, &old, NULL);
-
-		// Expect a TES_MSG from server with results. Other types of messages are
-		// ..unexpected at this point.
-
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed text message!");
-			return 1;
-		}
-		if (check_msg_type(SFW_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
-			return 2;
-		}
-
-		// The test results are sent as a numeric encoding the test results.
-
-		if (msgLen <= 0) { // test results have valid length
-			log_println(0, "Improper message");
-			return 3;
-		}
-		buff[msgLen] = 0;
-		if (check_int(buff, &c2s_result)) { // test result has to be a valid integer
-			log_println(0, "Invalid test result");
-			return 4;
-		}
-
-		// wait for the S->C listener thread to finish
-		pthread_join(threadId, NULL);
-
-		printf("Done\n");
-
-		// The last message expected from the server is an empty TEST_FINALIZE message.
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - missed finalize message!");
-			return 1;
-		}
-		if (check_msg_type(SFW_TEST_LOG, TEST_FINALIZE, msgType, buff, msgLen)) {
-			return 2;
-		}
-		log_println(1, " <-------------------------->");
-		// log protocol validation test ending
-		teststatuses = TEST_ENDED;
-		protolog_status(getpid(), testids, teststatuses,ctlsockfd);
-		setCurrentTest(TEST_NONE);
-	}
-	return 0;
+  char buff[BUFFSIZE + 1];int msgLen, msgType;
+  int sfwport, sfwsock, sfwsockport;
+  I2Addr sfwsrv_addr = NULL;
+  struct sigaction new, old;
+  char* ptr;
+  pthread_t threadId;
+
+  // variables used for protocol validation logs
+  enum TEST_STATUS_INT teststatuses = TEST_NOT_STARTED;
+  enum TEST_ID testids = SFW;
+
+  if (tests & TEST_SFW) { // SFW test is to be performed
+    log_println(1, " <-- Simple firewall test -->");
+    setCurrentTest(TEST_SFW);
+    //protocol logs
+    teststatuses = TEST_STARTED;
+    protolog_status(getpid(), testids, teststatuses, ctlsockfd);
+
+
+    printf("checking for firewalls . . . . . . . . . . . . . . . . . . .  ");
+    fflush(stdout);
+    msgLen = sizeof(buff);
+
+    // The first message expected from the server is a TEST_PREPARE message.
+    // Any other type of message is unexpected at this time.
+    if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed prepare message!");
+      return 1;
+    }
+    if (check_msg_type(SFW_TEST_LOG, TEST_PREPARE, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // This message is expected to be of valid length, and have a message
+    // .. payload containing the integral ephemeral port number and testTime
+    // ... separated by a single space
+    if (msgLen <= 0) {
+      log_println(0, "Improper message");
+      return 3;
+    }
+    buff[msgLen] = 0;
+    ptr = strtok(buff, " ");
+    if (ptr == NULL) {
+      log_println(0, "SFW: Improper message");
+      return 5;
+    }
+    if (check_int(ptr, &sfwport)) {  // get ephemeral port#
+      log_println(0, "Invalid port number");
+      return 4;
+    }
+    ptr = strtok(NULL, " ");
+    if (ptr == NULL) {
+      log_println(0, "SFW: Improper message");
+      return 5;
+    }
+    if (check_int(ptr, &testTime)) { // get test time
+      log_println(0, "Invalid waiting time");
+      return 4;
+    }
+    log_println(1, "\n  -- port: %d", sfwport);
+    log_println(1, "  -- time: %d", testTime);
+    if ((sfwsrv_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
+      log_println(0, "Unable to resolve server address: %s", strerror(errno));
+      return -3;
+    }
+    I2AddrSetPort(sfwsrv_addr, sfwport);
+
+    // create a listening socket, and if successful, send this socket number to server
+    sfwcli_addr = CreateListenSocket(NULL, "0", conn_options, 0);
+    if (sfwcli_addr == NULL) {
+      log_println(0, "Client (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
+      return -1;
+    }
+    sfwsockfd = I2AddrFD(sfwcli_addr);
+    sfwsockport = I2AddrPort(sfwcli_addr);
+    log_println(1, "  -- oport: %d", sfwsockport);
+
+    // Send a TEST_MSG to server with the client's port number
+    snprintf(buff, sizeof(buff), "%d", sfwsockport);
+    send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+
+    // The server responds to the TEST_MSG messages with a TEST_START message.
+    // Any other type of message is an error here.
+    if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed start message!");
+      return 1;
+    }
+    if (check_msg_type(SFW_TEST_LOG, TEST_START, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // Now listen for server sending out a test for the S->C direction , and
+    // update test results
+    pthread_create(&threadId, NULL, &test_osfw_clt, NULL);
+
+    // ignore the alarm signal
+    memset(&new, 0, sizeof(new));
+    new.sa_handler = catch_alrm;
+    sigaction(SIGALRM, &new, &old);
+    alarm(testTime + 1);
+
+    // Now, run Test from client for the C->S direction SFW test
+    // ..trying to connect to ephemeral port number sent by server
+
+    if (CreateConnectSocket(&sfwsock, NULL, sfwsrv_addr, conn_options, 0) == 0) {
+      send_msg(sfwsock, TEST_MSG, SFW_PREDEFINED_TEST_MSG, 20);
+    }
+    alarm(0);
+    sigaction(SIGALRM, &old, NULL);
+
+    // Expect a TES_MSG from server with results. Other types of messages are
+    // ..unexpected at this point.
+
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed text message!");
+      return 1;
+    }
+    if (check_msg_type(SFW_TEST_LOG, TEST_MSG, msgType, buff, msgLen)) {
+      return 2;
+    }
+
+    // The test results are sent as a numeric encoding the test results.
+
+    if (msgLen <= 0) { // test results have valid length
+      log_println(0, "Improper message");
+      return 3;
+    }
+    buff[msgLen] = 0;
+    if (check_int(buff, &c2s_result)) { // test result has to be a valid integer
+      log_println(0, "Invalid test result");
+      return 4;
+    }
+
+    // wait for the S->C listener thread to finish
+    pthread_join(threadId, NULL);
+
+    printf("Done\n");
+
+    // The last message expected from the server is an empty TEST_FINALIZE message.
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - missed finalize message!");
+      return 1;
+    }
+    if (check_msg_type(SFW_TEST_LOG, TEST_FINALIZE, msgType, buff, msgLen)) {
+      return 2;
+    }
+    log_println(1, " <-------------------------->");
+    // log protocol validation test ending
+    teststatuses = TEST_ENDED;
+    protolog_status(getpid(), testids, teststatuses,ctlsockfd);
+    setCurrentTest(TEST_NONE);
+  }
+  return 0;
 }
 
 /**
@@ -331,41 +331,41 @@ int test_sfw_clt(int ctlsockfd, char tests, char* host, int conn_options) {
  */
 
 int results_sfw(char tests, char* host) {
-	if (tests & TEST_SFW) { // SFW test has been selected to be run
-		// Print C->S direction's results
-		switch (c2s_result) {
-		case SFW_NOFIREWALL:
-			printf(
-					"Server '%s' is not behind a firewall."
-					" [Connection to the ephemeral port was successful]\n",
-					host);
-			break;
-		case SFW_POSSIBLE:
-			printf(
-					"Server '%s' is probably behind a firewall."
-					" [Connection to the ephemeral port failed]\n",
-					host);
-			break;
-		case SFW_UNKNOWN:
-		case SFW_NOTTESTED:
-			break;
-		}
-		// Print S->C directions results
-		switch (s2c_result) {
-		case SFW_NOFIREWALL:
-			printf(
-					"Client is not behind a firewall."
-					" [Connection to the ephemeral port was successful]\n");
-			break;
-		case SFW_POSSIBLE:
-			printf(
-					"Client is probably behind a firewall."
-					" [Connection to the ephemeral port failed]\n");
-			break;
-		case SFW_UNKNOWN:
-		case SFW_NOTTESTED:
-			break;
-		}
-	}
-	return 0;
+  if (tests & TEST_SFW) { // SFW test has been selected to be run
+    // Print C->S direction's results
+    switch (c2s_result) {
+      case SFW_NOFIREWALL:
+        printf(
+            "Server '%s' is not behind a firewall."
+            " [Connection to the ephemeral port was successful]\n",
+            host);
+        break;
+      case SFW_POSSIBLE:
+        printf(
+            "Server '%s' is probably behind a firewall."
+            " [Connection to the ephemeral port failed]\n",
+            host);
+        break;
+      case SFW_UNKNOWN:
+      case SFW_NOTTESTED:
+        break;
+    }
+    // Print S->C directions results
+    switch (s2c_result) {
+      case SFW_NOFIREWALL:
+        printf(
+            "Client is not behind a firewall."
+            " [Connection to the ephemeral port was successful]\n");
+        break;
+      case SFW_POSSIBLE:
+        printf(
+            "Client is probably behind a firewall."
+            " [Connection to the ephemeral port failed]\n");
+        break;
+      case SFW_UNKNOWN:
+      case SFW_NOTTESTED:
+        break;
+    }
+  }
+  return 0;
 }
diff --git a/src/test_sfw_srv.c b/src/test_sfw_srv.c
index 75562c7..64e9204 100644
--- a/src/test_sfw_srv.c
+++ b/src/test_sfw_srv.c
@@ -31,15 +31,15 @@ static pthread_t threadId = -1;
  */
 
 void catch_alrm(int signo) {
-	if (signo == SIGALRM) {
-		log_println(1, "SFW - SIGALRM was caught");
-		if (threadId != -1) { /* we forward the signal to the osfw thread */
-			pthread_kill(threadId, SIGALRM);
-			threadId = -1;
-		}
-		return;
-	}
-	log_println(0, "Unknown (%d) signal was caught", signo);
+  if (signo == SIGALRM) {
+    log_println(1, "SFW - SIGALRM was caught");
+    if (threadId != -1) { /* we forward the signal to the osfw thread */
+      pthread_kill(threadId, SIGALRM);
+      threadId = -1;
+    }
+    return;
+  }
+  log_println(0, "Unknown (%d) signal was caught", signo);
 }
 
 /**
@@ -52,30 +52,30 @@ void catch_alrm(int signo) {
 
 void*
 test_osfw_srv(void* vptr) {
-	int sfwsock;
-	struct sigaction new, old;
-
-	// ignore the alarm signal
-	memset(&new, 0, sizeof(new));
-	new.sa_handler = catch_alrm;
-	sigaction(SIGALRM, &new, &old);
-	alarm(testTime);
-
-	// connect to client and send TEST_MSG message containing a pre-defined string
-	if (CreateConnectSocket(&sfwsock, NULL, sfwcli_addr, 0, 0) == 0) {
-		send_msg(sfwsock, TEST_MSG, "Simple firewall test", 20);
-	}
-
-	alarm(0);
-	sigaction(SIGALRM, &old, NULL);
-
-	// signal sleeping threads to wake up
-	pthread_mutex_lock(&mainmutex);
-	toWait = 0;
-	pthread_cond_broadcast(&maincond);
-	pthread_mutex_unlock(&mainmutex);
-
-	return NULL;
+  int sfwsock;
+  struct sigaction new, old;
+
+  // ignore the alarm signal
+  memset(&new, 0, sizeof(new));
+  new.sa_handler = catch_alrm;
+  sigaction(SIGALRM, &new, &old);
+  alarm(testTime);
+
+  // connect to client and send TEST_MSG message containing a pre-defined string
+  if (CreateConnectSocket(&sfwsock, NULL, sfwcli_addr, 0, 0) == 0) {
+    send_msg(sfwsock, TEST_MSG, "Simple firewall test", 20);
+  }
+
+  alarm(0);
+  sigaction(SIGALRM, &old, NULL);
+
+  // signal sleeping threads to wake up
+  pthread_mutex_lock(&mainmutex);
+  toWait = 0;
+  pthread_cond_broadcast(&maincond);
+  pthread_mutex_unlock(&mainmutex);
+
+  return NULL;
 }
 
 /**
@@ -85,24 +85,24 @@ test_osfw_srv(void* vptr) {
  */
 
 void finalize_sfw(int ctlsockfd) {
-	enum TEST_ID thistestId = SFW;
-	enum TEST_STATUS_INT teststatusnow = NONE;
-	// wait for mutex to be released before attempting to finalize
-	while (toWait) {
-		pthread_mutex_lock(&mainmutex);
-		pthread_cond_wait(&maincond, &mainmutex);
-		pthread_mutex_unlock(&mainmutex);
-	}
-
-	// close the SFW test by sending a nil (0 length) message
-	send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
-
-	// log
-	teststatusnow = TEST_ENDED;
-	protolog_status(getpid(), thistestId, teststatusnow, ctlsockfd);
-	log_println(1, " <-------------------------->");
-	// unset test name
-	setCurrentTest(TEST_NONE);
+  enum TEST_ID thistestId = SFW;
+  enum TEST_STATUS_INT teststatusnow = NONE;
+  // wait for mutex to be released before attempting to finalize
+  while (toWait) {
+    pthread_mutex_lock(&mainmutex);
+    pthread_cond_wait(&maincond, &mainmutex);
+    pthread_mutex_unlock(&mainmutex);
+  }
+
+  // close the SFW test by sending a nil (0 length) message
+  send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
+
+  // log
+  teststatusnow = TEST_ENDED;
+  protolog_status(getpid(), thistestId, teststatusnow, ctlsockfd);
+  log_println(1, " <-------------------------->");
+  // unset test name
+  setCurrentTest(TEST_NONE);
 }
 
 /**
@@ -121,239 +121,239 @@ void finalize_sfw(int ctlsockfd) {
  */
 
 int test_sfw_srv(int ctlsockfd, web100_agent* agent, TestOptions* options,
-		int conn_options) {
-	char buff[BUFFSIZE + 1];I2Addr sfwsrv_addr = NULL;
-	int sfwsockfd, sfwsockport, sockfd, sfwport;
-	struct sockaddr_storage cli_addr;
-	socklen_t clilen;
-	fd_set fds;
-	struct timeval sel_tv;
-	int msgLen, msgType;
-	web100_var* var;
-	web100_connection* cn;
-	web100_group* group;
-	int maxRTT, maxRTO;
-	char hostname[256];
-	int rc;
-
-	// variables used for protocol validation
-	enum TEST_ID thistestId = NONE;
-	enum TEST_STATUS_INT teststatusnow = TEST_NOT_STARTED;
-	enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
-	enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
-
-	assert(ctlsockfd != -1);
-	assert(options);
-
-	if (options->sfwopt) {
-		setCurrentTest(TEST_SFW);
-		log_println(1, " <-- %d - Simple firewall test -->", options->child0);
-		thistestId = SFW;
-		teststatusnow = TEST_STARTED;
-		protolog_status(options->child0, thistestId, teststatusnow,ctlsockfd);
-
-		// bind to a new port and obtain address structure with details of port etc
-		sfwsrv_addr = CreateListenSocket(NULL, "0", conn_options, 0);
-		if (sfwsrv_addr == NULL) {
-			log_println(0, "Server (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
-			snprintf(buff, sizeof(buff), "Server (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			return -1;
-		}
-
-		// get socket FD and the ephemeral port number to be used
-		sfwsockfd = I2AddrFD(sfwsrv_addr);
-		sfwsockport = I2AddrPort(sfwsrv_addr);
-		log_println(1, "  -- port: %d", sfwsockport);
-
-		cn = web100_connection_from_socket(agent, ctlsockfd);
-		if (cn) {
-
-			// Get remote end's address
-			web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
-			web100_raw_read(var, cn, buff);
-			memset(hostname, 0, 256);
-			//strncpy(hostname, web100_value_to_text(web100_get_var_type(var), buff), 255);
-			strlcpy(hostname, web100_value_to_text(web100_get_var_type(var), buff), sizeof(hostname));
-
-			// Determine test time in seconds.
-			// test-time = max(round trip time, timeout) > 3 ? 3 : 1
-
-			web100_agent_find_var_and_group(agent, "MaxRTT", &group, &var);
-			web100_raw_read(var, cn, buff);
-			maxRTT = atoi(web100_value_to_text(web100_get_var_type(var), buff));
-			web100_agent_find_var_and_group(agent, "MaxRTO", &group, &var);
-			web100_raw_read(var, cn, buff);
-			maxRTO = atoi(web100_value_to_text(web100_get_var_type(var), buff));
-			if (maxRTT > maxRTO)
-			maxRTO = maxRTT;
-			if ((((double) maxRTO) / 1000.0) > 3.0)
-			/* `testTime = (((double) maxRTO) / 1000.0) * 4 ; */
-			testTime = 3;
-			else
-			testTime = 1;
-		}
-		else {
-			log_println(0, "Simple firewall test: Cannot find connection");
-			snprintf(buff, sizeof(buff), "Server (Simple firewall test): Cannot find connection");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			I2AddrFree(sfwsrv_addr);
-			return -1;
-		}
-		log_println(1, "  -- SFW time: %d", testTime);
-
-		// try sending TEST_PREPARE msg with ephemeral port number to client.
-		// If unable to, return
-		snprintf(buff, sizeof(buff), "%d %d", sfwsockport, testTime);
-		if ((rc = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff))) < 0)
-		return (rc);
-
-		// Listen for TEST_MSG from client's port number sent as data.
-		// Any other type of message is unexpected at this juncture.
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) { // message reception error
-			log_println(0, "Protocol error!");
-			snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			I2AddrFree(sfwsrv_addr);
-			return 1;
-		}
-		if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff, msgLen)) {
-			log_println(0, "Fault, unexpected message received!");
-			snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			I2AddrFree(sfwsrv_addr);
-			return 2;
-		}
-		if (msgLen <= 0) { // message reception has error
-			log_println(0, "Improper message");
-			snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			I2AddrFree(sfwsrv_addr);
-			return 3;
-		}
-		// Note: The same error message is transmitted to the client
-		// under any error condition, but the log messages  indicate the difference
-
-		buff[msgLen] = 0;
-		if (check_int(buff, &sfwport)) { // message data is not number, thus no port info received
-			log_println(0, "Invalid port number");
-			snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
-			send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-			I2AddrFree(sfwsrv_addr);
-			return 4;
-		}
-
-		// Get node, port(if present) and other details of client end.
-		// If not able to resolve it, the test cannot proceed to the "throughput" stage
-		if ((sfwcli_addr = I2AddrByNode(get_errhandle(), hostname)) == NULL) {
-			log_println(0, "Unable to resolve server address"); //todo, this is the client address we cannot resolve?
-			send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
-
-			// log end
-			teststatusnow = TEST_ENDED;
-			protolog_status(options->child0, thistestId, teststatusnow, ctlsockfd);
-			log_println(1, " <-------------------------->");
-			I2AddrFree(sfwsrv_addr);
-			return 5;
-		}
-		I2AddrSetPort(sfwcli_addr, sfwport);
-		log_println(1, "  -- oport: %d", sfwport);
-
-		// send S->C side TEST_MSG
-		send_msg(ctlsockfd, TEST_START, "", 0);
-
-		// send the S->C default test message in a separate thread to client
-		pthread_create(&threadId, NULL, &test_osfw_srv, NULL);
-
-		FD_ZERO(&fds);
-		FD_SET(sfwsockfd, &fds);
-		sel_tv.tv_sec = testTime;
-		sel_tv.tv_usec = 0;
-
-		// determine status of listening socket - looking for TEST_MSG from client.
-		// The following switch statement checks for cases where this socket status
-		// indicates error , and finalizes the test at this point.
-
-		switch (select(sfwsockfd+1, &fds, NULL, NULL, &sel_tv)) {
-			case -1: // If SOCKET_ERROR - status of firewall unknown
-			log_println(0, "Simple firewall test: select exited with error");
-			snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
-			send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-			finalize_sfw(ctlsockfd);
-			I2AddrFree(sfwsrv_addr);
-			I2AddrFree(sfwcli_addr);
-			return 1;
-			case 0:// Time expiration. SFW possible in C->S side
-			log_println(0, "Simple firewall test: no connection for %d seconds", testTime);
-			snprintf(buff, sizeof(buff), "%d", SFW_POSSIBLE);
-			send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-			finalize_sfw(ctlsockfd);
-			I2AddrFree(sfwsrv_addr);
-			I2AddrFree(sfwcli_addr);
-			return 2;
-		}
-
-		// Now read actual data from the sockets listening for client message.
-		// Based on data, conclude SFW status and send TEST_MSG with result.
-		// In all cases, finalize the test
-		clilen = sizeof(cli_addr);
-		sockfd = accept(sfwsockfd, (struct sockaddr *) &cli_addr, &clilen);
-		// protocol validation log to indicate client tried connecting
-		procstatusenum = PROCESS_STARTED;
-		protolog_procstatus(options->child0, thistestId, proctypeenum, procstatusenum, sockfd);
-
-		msgLen = sizeof(buff);
-		if (recv_msg(sockfd, &msgType, buff, &msgLen)) { // message received in error
-			log_println(0, "Simple firewall test: unrecognized message");
-			snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
-			send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-			close(sockfd);
-			finalize_sfw(ctlsockfd);
-			I2AddrFree(sfwsrv_addr);
-			I2AddrFree(sfwcli_addr);
-			return 1;
-		}
-		if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff, msgLen)) {
-			// unexpected message type received
-			snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
-			send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-			close(sockfd);
-			finalize_sfw(ctlsockfd);
-			I2AddrFree(sfwsrv_addr);
-			I2AddrFree(sfwcli_addr);
-			return 1;
-		}
-		if (msgLen != SFW_TEST_DEFAULT_LEN) { // Expecting default 20 byte long "Simple firewall test" message
-			log_println(0, "Simple firewall test: Improper message");
-			snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
-			send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-			close(sockfd);
-			finalize_sfw(ctlsockfd);
-			I2AddrFree(sfwsrv_addr);
-			I2AddrFree(sfwcli_addr);
-			return 1;
-		}
-		buff[msgLen] = 0;
-		if (strcmp(buff, "Simple firewall test") != 0) {
-			// Message was of correct length, but was not expected content-wise
-			log_println(0, "Simple firewall test: Improper message");
-			snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
-			send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-			close(sockfd);
-			finalize_sfw(ctlsockfd);
-			I2AddrFree(sfwsrv_addr);
-			I2AddrFree(sfwcli_addr);
-			return 1;
-		}
-
-		// All messages were received correctly, hence no firewall
-		snprintf(buff, sizeof(buff), "%d", SFW_NOFIREWALL);
-		send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
-		close(sockfd);
-		finalize_sfw(ctlsockfd);
-		I2AddrFree(sfwsrv_addr);
-		I2AddrFree(sfwcli_addr);
-	}
-	return 0;
+                 int conn_options) {
+  char buff[BUFFSIZE + 1];I2Addr sfwsrv_addr = NULL;
+  int sfwsockfd, sfwsockport, sockfd, sfwport;
+  struct sockaddr_storage cli_addr;
+  socklen_t clilen;
+  fd_set fds;
+  struct timeval sel_tv;
+  int msgLen, msgType;
+  web100_var* var;
+  web100_connection* cn;
+  web100_group* group;
+  int maxRTT, maxRTO;
+  char hostname[256];
+  int rc;
+
+  // variables used for protocol validation
+  enum TEST_ID thistestId = NONE;
+  enum TEST_STATUS_INT teststatusnow = TEST_NOT_STARTED;
+  enum PROCESS_TYPE_INT proctypeenum = CONNECT_TYPE;
+  enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
+
+  assert(ctlsockfd != -1);
+  assert(options);
+
+  if (options->sfwopt) {
+    setCurrentTest(TEST_SFW);
+    log_println(1, " <-- %d - Simple firewall test -->", options->child0);
+    thistestId = SFW;
+    teststatusnow = TEST_STARTED;
+    protolog_status(options->child0, thistestId, teststatusnow,ctlsockfd);
+
+    // bind to a new port and obtain address structure with details of port etc
+    sfwsrv_addr = CreateListenSocket(NULL, "0", conn_options, 0);
+    if (sfwsrv_addr == NULL) {
+      log_println(0, "Server (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
+      snprintf(buff, sizeof(buff), "Server (Simple firewall test): CreateListenSocket failed: %s", strerror(errno));
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      return -1;
+    }
+
+    // get socket FD and the ephemeral port number to be used
+    sfwsockfd = I2AddrFD(sfwsrv_addr);
+    sfwsockport = I2AddrPort(sfwsrv_addr);
+    log_println(1, "  -- port: %d", sfwsockport);
+
+    cn = web100_connection_from_socket(agent, ctlsockfd);
+    if (cn) {
+
+      // Get remote end's address
+      web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
+      web100_raw_read(var, cn, buff);
+      memset(hostname, 0, 256);
+      //strncpy(hostname, web100_value_to_text(web100_get_var_type(var), buff), 255);
+      strlcpy(hostname, web100_value_to_text(web100_get_var_type(var), buff), sizeof(hostname));
+
+      // Determine test time in seconds.
+      // test-time = max(round trip time, timeout) > 3 ? 3 : 1
+
+      web100_agent_find_var_and_group(agent, "MaxRTT", &group, &var);
+      web100_raw_read(var, cn, buff);
+      maxRTT = atoi(web100_value_to_text(web100_get_var_type(var), buff));
+      web100_agent_find_var_and_group(agent, "MaxRTO", &group, &var);
+      web100_raw_read(var, cn, buff);
+      maxRTO = atoi(web100_value_to_text(web100_get_var_type(var), buff));
+      if (maxRTT > maxRTO)
+        maxRTO = maxRTT;
+      if ((((double) maxRTO) / 1000.0) > 3.0)
+        /* `testTime = (((double) maxRTO) / 1000.0) * 4 ; */
+        testTime = 3;
+      else
+        testTime = 1;
+    }
+    else {
+      log_println(0, "Simple firewall test: Cannot find connection");
+      snprintf(buff, sizeof(buff), "Server (Simple firewall test): Cannot find connection");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      I2AddrFree(sfwsrv_addr);
+      return -1;
+    }
+    log_println(1, "  -- SFW time: %d", testTime);
+
+    // try sending TEST_PREPARE msg with ephemeral port number to client.
+    // If unable to, return
+    snprintf(buff, sizeof(buff), "%d %d", sfwsockport, testTime);
+    if ((rc = send_msg(ctlsockfd, TEST_PREPARE, buff, strlen(buff))) < 0)
+      return (rc);
+
+    // Listen for TEST_MSG from client's port number sent as data.
+    // Any other type of message is unexpected at this juncture.
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlsockfd, &msgType, buff, &msgLen)) { // message reception error
+      log_println(0, "Protocol error!");
+      snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      I2AddrFree(sfwsrv_addr);
+      return 1;
+    }
+    if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff, msgLen)) {
+      log_println(0, "Fault, unexpected message received!");
+      snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      I2AddrFree(sfwsrv_addr);
+      return 2;
+    }
+    if (msgLen <= 0) { // message reception has error
+      log_println(0, "Improper message");
+      snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      I2AddrFree(sfwsrv_addr);
+      return 3;
+    }
+    // Note: The same error message is transmitted to the client
+    // under any error condition, but the log messages  indicate the difference
+
+    buff[msgLen] = 0;
+    if (check_int(buff, &sfwport)) { // message data is not number, thus no port info received
+      log_println(0, "Invalid port number");
+      snprintf(buff, sizeof(buff), "Server (Simple firewall test): Invalid port number received");
+      send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+      I2AddrFree(sfwsrv_addr);
+      return 4;
+    }
+
+    // Get node, port(if present) and other details of client end.
+    // If not able to resolve it, the test cannot proceed to the "throughput" stage
+    if ((sfwcli_addr = I2AddrByNode(get_errhandle(), hostname)) == NULL) {
+      log_println(0, "Unable to resolve server address"); //todo, this is the client address we cannot resolve?
+      send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
+
+      // log end
+      teststatusnow = TEST_ENDED;
+      protolog_status(options->child0, thistestId, teststatusnow, ctlsockfd);
+      log_println(1, " <-------------------------->");
+      I2AddrFree(sfwsrv_addr);
+      return 5;
+    }
+    I2AddrSetPort(sfwcli_addr, sfwport);
+    log_println(1, "  -- oport: %d", sfwport);
+
+    // send S->C side TEST_MSG
+    send_msg(ctlsockfd, TEST_START, "", 0);
+
+    // send the S->C default test message in a separate thread to client
+    pthread_create(&threadId, NULL, &test_osfw_srv, NULL);
+
+    FD_ZERO(&fds);
+    FD_SET(sfwsockfd, &fds);
+    sel_tv.tv_sec = testTime;
+    sel_tv.tv_usec = 0;
+
+    // determine status of listening socket - looking for TEST_MSG from client.
+    // The following switch statement checks for cases where this socket status
+    // indicates error , and finalizes the test at this point.
+
+    switch (select(sfwsockfd+1, &fds, NULL, NULL, &sel_tv)) {
+      case -1: // If SOCKET_ERROR - status of firewall unknown
+        log_println(0, "Simple firewall test: select exited with error");
+        snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
+        send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+        finalize_sfw(ctlsockfd);
+        I2AddrFree(sfwsrv_addr);
+        I2AddrFree(sfwcli_addr);
+        return 1;
+      case 0:// Time expiration. SFW possible in C->S side
+        log_println(0, "Simple firewall test: no connection for %d seconds", testTime);
+        snprintf(buff, sizeof(buff), "%d", SFW_POSSIBLE);
+        send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+        finalize_sfw(ctlsockfd);
+        I2AddrFree(sfwsrv_addr);
+        I2AddrFree(sfwcli_addr);
+        return 2;
+    }
+
+    // Now read actual data from the sockets listening for client message.
+    // Based on data, conclude SFW status and send TEST_MSG with result.
+    // In all cases, finalize the test
+    clilen = sizeof(cli_addr);
+    sockfd = accept(sfwsockfd, (struct sockaddr *) &cli_addr, &clilen);
+    // protocol validation log to indicate client tried connecting
+    procstatusenum = PROCESS_STARTED;
+    protolog_procstatus(options->child0, thistestId, proctypeenum, procstatusenum, sockfd);
+
+    msgLen = sizeof(buff);
+    if (recv_msg(sockfd, &msgType, buff, &msgLen)) { // message received in error
+      log_println(0, "Simple firewall test: unrecognized message");
+      snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
+      send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+      close(sockfd);
+      finalize_sfw(ctlsockfd);
+      I2AddrFree(sfwsrv_addr);
+      I2AddrFree(sfwcli_addr);
+      return 1;
+    }
+    if (check_msg_type("Simple firewall test", TEST_MSG, msgType, buff, msgLen)) {
+      // unexpected message type received
+      snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
+      send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+      close(sockfd);
+      finalize_sfw(ctlsockfd);
+      I2AddrFree(sfwsrv_addr);
+      I2AddrFree(sfwcli_addr);
+      return 1;
+    }
+    if (msgLen != SFW_TEST_DEFAULT_LEN) { // Expecting default 20 byte long "Simple firewall test" message
+      log_println(0, "Simple firewall test: Improper message");
+      snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
+      send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+      close(sockfd);
+      finalize_sfw(ctlsockfd);
+      I2AddrFree(sfwsrv_addr);
+      I2AddrFree(sfwcli_addr);
+      return 1;
+    }
+    buff[msgLen] = 0;
+    if (strcmp(buff, "Simple firewall test") != 0) {
+      // Message was of correct length, but was not expected content-wise
+      log_println(0, "Simple firewall test: Improper message");
+      snprintf(buff, sizeof(buff), "%d", SFW_UNKNOWN);
+      send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+      close(sockfd);
+      finalize_sfw(ctlsockfd);
+      I2AddrFree(sfwsrv_addr);
+      I2AddrFree(sfwcli_addr);
+      return 1;
+    }
+
+    // All messages were received correctly, hence no firewall
+    snprintf(buff, sizeof(buff), "%d", SFW_NOFIREWALL);
+    send_msg(ctlsockfd, TEST_MSG, buff, strlen(buff));
+    close(sockfd);
+    finalize_sfw(ctlsockfd);
+    I2AddrFree(sfwsrv_addr);
+    I2AddrFree(sfwcli_addr);
+  }
+  return 0;
 }
diff --git a/src/testoptions.c b/src/testoptions.c
index fe92440..af6b3b3 100644
--- a/src/testoptions.c
+++ b/src/testoptions.c
@@ -23,10 +23,10 @@
 
 // Worker thread characteristics used to record snaplog and Cwnd peaks
 typedef struct workerArgs {
-	SnapArgs* snapArgs; // snapArgs struct pointer
-	web100_agent* agent; // web_100 agent pointer
-	CwndPeaks* peaks; // data indicating Cwnd values
-	int writeSnap; // enable writing snaplog
+  SnapArgs* snapArgs; // snapArgs struct pointer
+  web100_agent* agent; // web_100 agent pointer
+  CwndPeaks* peaks; // data indicating Cwnd values
+  int writeSnap; // enable writing snaplog
 } WorkerArgs;
 
 int workerLoop = 0;
@@ -46,42 +46,42 @@ static int decreasing = 0;
  */
 
 void findCwndPeaks(web100_agent* agent, CwndPeaks* peaks, web100_snapshot* snap) {
-	web100_group* group;
-	web100_var* var;
-	int CurCwnd;
-	char tmpstr[256];
-
-	web100_agent_find_var_and_group(agent, "CurCwnd", &group, &var);
-	web100_snap_read(var, snap, tmpstr);
-	CurCwnd = atoi(web100_value_to_text(web100_get_var_type(var), tmpstr));
-
-	if (slowStart) {
-		if (CurCwnd < prevCWNDval) {
-			slowStart = 0;
-			peaks->max = prevCWNDval;
-			peaks->amount = 1;
-			decreasing = 1;
-		}
-	} else {
-		// current congestion window < previous value, so, decreasing
-		if (CurCwnd < prevCWNDval) {
-			// update values based on actual values
-			if (prevCWNDval > peaks->max) {
-				peaks->max = prevCWNDval;
-			}
-			if (!decreasing) {
-				peaks->amount += 1;
-			}
-			decreasing = 1;
-		} else if (CurCwnd > prevCWNDval) { // current congestion window size > previous value,
-											// not decreasing.
-			if ((peaks->min == -1) || (prevCWNDval < peaks->min)) {
-				peaks->min = prevCWNDval;
-			}
-			decreasing = 0;
-		}
-	}
-	prevCWNDval = CurCwnd;
+  web100_group* group;
+  web100_var* var;
+  int CurCwnd;
+  char tmpstr[256];
+
+  web100_agent_find_var_and_group(agent, "CurCwnd", &group, &var);
+  web100_snap_read(var, snap, tmpstr);
+  CurCwnd = atoi(web100_value_to_text(web100_get_var_type(var), tmpstr));
+
+  if (slowStart) {
+    if (CurCwnd < prevCWNDval) {
+      slowStart = 0;
+      peaks->max = prevCWNDval;
+      peaks->amount = 1;
+      decreasing = 1;
+    }
+  } else {
+    // current congestion window < previous value, so, decreasing
+    if (CurCwnd < prevCWNDval) {
+      // update values based on actual values
+      if (prevCWNDval > peaks->max) {
+        peaks->max = prevCWNDval;
+      }
+      if (!decreasing) {
+        peaks->amount += 1;
+      }
+      decreasing = 1;
+    } else if (CurCwnd > prevCWNDval) { // current congestion window size > previous value,
+      // not decreasing.
+      if ((peaks->min == -1) || (prevCWNDval < peaks->min)) {
+        peaks->min = prevCWNDval;
+      }
+      decreasing = 0;
+    }
+  }
+  prevCWNDval = CurCwnd;
 }
 
 /**
@@ -90,11 +90,11 @@ void findCwndPeaks(web100_agent* agent, CwndPeaks* peaks, web100_snapshot* snap)
  */
 
 void catch_s2c_alrm(int signo) {
-	if (signo == SIGALRM) {
-		log_println(1, "SIGALRM was caught");
-		return;
-	}
-	log_println(0, "Unknown (%d) signal was caught", signo);
+  if (signo == SIGALRM) {
+    log_println(1, "SIGALRM was caught");
+    return;
+  }
+  log_println(0, "Unknown (%d) signal was caught", signo);
 }
 
 /**
@@ -106,46 +106,46 @@ void catch_s2c_alrm(int signo) {
 
 void*
 snapWorker(void* arg) {
-	WorkerArgs *workerArgs = (WorkerArgs*) arg;
-	SnapArgs *snapArgs = workerArgs->snapArgs;
-	web100_agent* agent = workerArgs->agent;
-	CwndPeaks* peaks = workerArgs->peaks;
-	int writeSnap = workerArgs->writeSnap;
-
-	// snap log written into every "delay" milliseconds
-	double delay = ((double) snapArgs->delay) / 1000.0;
-
-	while (1) {
-		pthread_mutex_lock(&mainmutex);
-		if (workerLoop) {
-			pthread_mutex_unlock(&mainmutex);
-			pthread_cond_broadcast(&maincond);
-			break;
-		}
-		pthread_mutex_unlock(&mainmutex);
-		mysleep(0.01);
-	}
-
-	// Find Congestion window peaks from a web_100 snapshot, if enabled
-	// Write snap log , if enabled, all in a synchronous manner.
-	while (1) {
-		pthread_mutex_lock(&mainmutex);
-		if (!workerLoop) {
-			pthread_mutex_unlock(&mainmutex);
-			break;
-		}
-		web100_snap(snapArgs->snap);
-		if (peaks) {
-			findCwndPeaks(agent, peaks, snapArgs->snap);
-		}
-		if (writeSnap) {
-			web100_log_write(snapArgs->log, snapArgs->snap);
-		}
-		pthread_mutex_unlock(&mainmutex);
-		mysleep(delay);
-	}
-
-	return NULL;
+  WorkerArgs *workerArgs = (WorkerArgs*) arg;
+  SnapArgs *snapArgs = workerArgs->snapArgs;
+  web100_agent* agent = workerArgs->agent;
+  CwndPeaks* peaks = workerArgs->peaks;
+  int writeSnap = workerArgs->writeSnap;
+
+  // snap log written into every "delay" milliseconds
+  double delay = ((double) snapArgs->delay) / 1000.0;
+
+  while (1) {
+    pthread_mutex_lock(&mainmutex);
+    if (workerLoop) {
+      pthread_mutex_unlock(&mainmutex);
+      pthread_cond_broadcast(&maincond);
+      break;
+    }
+    pthread_mutex_unlock(&mainmutex);
+    mysleep(0.01);
+  }
+
+  // Find Congestion window peaks from a web_100 snapshot, if enabled
+  // Write snap log , if enabled, all in a synchronous manner.
+  while (1) {
+    pthread_mutex_lock(&mainmutex);
+    if (!workerLoop) {
+      pthread_mutex_unlock(&mainmutex);
+      break;
+    }
+    web100_snap(snapArgs->snap);
+    if (peaks) {
+      findCwndPeaks(agent, peaks, snapArgs->snap);
+    }
+    if (writeSnap) {
+      web100_log_write(snapArgs->log, snapArgs->snap);
+    }
+    pthread_mutex_unlock(&mainmutex);
+    mysleep(delay);
+  }
+
+  return NULL;
 }
 
 /**
@@ -155,15 +155,15 @@ snapWorker(void* arg) {
  * @param test_id id of the test
  */
 void add_test_to_suite(int* first, char * buff, size_t buff_strlen, int test_id) {
-	char tmpbuff[16];
-	if (*first) {
-		*first = 0;
-		snprintf(buff, buff_strlen, "%d", test_id);
-	} else {
-		memset(tmpbuff, 0, sizeof(tmpbuff));
-		snprintf(tmpbuff, sizeof(tmpbuff), " %d", test_id);
-		strlcat(buff, tmpbuff, buff_strlen);
-	}
+  char tmpbuff[16];
+  if (*first) {
+    *first = 0;
+    snprintf(buff, buff_strlen, "%d", test_id);
+  } else {
+    memset(tmpbuff, 0, sizeof(tmpbuff));
+    snprintf(tmpbuff, sizeof(tmpbuff), " %d", test_id);
+    strlcat(buff, tmpbuff, buff_strlen);
+  }
 }
 
 /**
@@ -182,65 +182,65 @@ void add_test_to_suite(int* first, char * buff, size_t buff_strlen, int test_id)
  */
 
 int initialize_tests(int ctlsockfd, TestOptions* options, char * buff, size_t buff_strlen) {
-	unsigned char useropt = 0;
-	int msgType;
-	int msgLen = 1;
-	int first = 1;
-	//char remhostarr[256], protologlocalarr[256];
-	//char *remhost_ptr = get_remotehost();
-
-	assert(ctlsockfd != -1);
-	assert(options);
-
-	// read the test suite request
-	if (recv_msg(ctlsockfd, &msgType, &useropt, &msgLen)) {
-		snprintf(buff, buff_strlen, "Invalid test suite request");
-		send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-		return (-1);
-	}
-	if (msgLen == -1) {
-		snprintf(buff, buff_strlen, "Client timeout");
-		return (-4);
-	}
-	// Expecting a MSG_LOGIN with payload byte indicating tests to be run
-	if ((msgType != MSG_LOGIN) || (msgLen != 1)) {
-		snprintf(buff, buff_strlen, "Invalid test request");
-		send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-		return (-2);
-	}
-	// client connect received correctly. Logging activity
-	// log that client connected, and create log file
-	log_println(0,
-			"Client connect received from :IP %s to some server on socket %d",
-			get_remotehost(), ctlsockfd);
-
-	//set_protologfile(get_remotehost(), protologlocalarr);
-
-	if (!(useropt
-			& (TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW | TEST_STATUS
-					| TEST_META))) {
-		// message received does not indicate a valid test!
-		snprintf(buff, buff_strlen, "Invalid test suite request");
-		send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
-		return (-3);
-	}
-	// construct test suite request based on user options received
-	if (useropt & TEST_MID) {
-		add_test_to_suite(&first, buff, buff_strlen, TEST_MID);
-	}
-	if (useropt & TEST_SFW) {
-		add_test_to_suite(&first, buff, buff_strlen, TEST_SFW);
-	}
-	if (useropt & TEST_C2S) {
-		add_test_to_suite(&first, buff, buff_strlen, TEST_C2S);
-	}
-	if (useropt & TEST_S2C) {
-		add_test_to_suite(&first, buff, buff_strlen, TEST_S2C);
-	}
-	if (useropt & TEST_META) {
-		add_test_to_suite(&first, buff, buff_strlen, TEST_META);
-	}
-	return useropt;
+  unsigned char useropt = 0;
+  int msgType;
+  int msgLen = 1;
+  int first = 1;
+  //char remhostarr[256], protologlocalarr[256];
+  //char *remhost_ptr = get_remotehost();
+
+  assert(ctlsockfd != -1);
+  assert(options);
+
+  // read the test suite request
+  if (recv_msg(ctlsockfd, &msgType, &useropt, &msgLen)) {
+    snprintf(buff, buff_strlen, "Invalid test suite request");
+    send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+    return (-1);
+  }
+  if (msgLen == -1) {
+    snprintf(buff, buff_strlen, "Client timeout");
+    return (-4);
+  }
+  // Expecting a MSG_LOGIN with payload byte indicating tests to be run
+  if ((msgType != MSG_LOGIN) || (msgLen != 1)) {
+    snprintf(buff, buff_strlen, "Invalid test request");
+    send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+    return (-2);
+  }
+  // client connect received correctly. Logging activity
+  // log that client connected, and create log file
+  log_println(0,
+              "Client connect received from :IP %s to some server on socket %d",
+              get_remotehost(), ctlsockfd);
+
+  //set_protologfile(get_remotehost(), protologlocalarr);
+
+  if (!(useropt
+        & (TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW | TEST_STATUS
+           | TEST_META))) {
+    // message received does not indicate a valid test!
+    snprintf(buff, buff_strlen, "Invalid test suite request");
+    send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+    return (-3);
+  }
+  // construct test suite request based on user options received
+  if (useropt & TEST_MID) {
+    add_test_to_suite(&first, buff, buff_strlen, TEST_MID);
+  }
+  if (useropt & TEST_SFW) {
+    add_test_to_suite(&first, buff, buff_strlen, TEST_SFW);
+  }
+  if (useropt & TEST_C2S) {
+    add_test_to_suite(&first, buff, buff_strlen, TEST_C2S);
+  }
+  if (useropt & TEST_S2C) {
+    add_test_to_suite(&first, buff, buff_strlen, TEST_S2C);
+  }
+  if (useropt & TEST_META) {
+    add_test_to_suite(&first, buff, buff_strlen, TEST_META);
+  }
+  return useropt;
 }
 
 /** Method to start snap worker thread that collects snap logs
@@ -255,55 +255,55 @@ int initialize_tests(int ctlsockfd, TestOptions* options, char * buff, size_t bu
  * @param web100_group group web100_group pointer
  */
 void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg, CwndPeaks* peaks,
-		char snaplogenabled,  pthread_t *wrkrthreadidarg,
-		char *metafilevariablename, char *metafilename, web100_connection* conn,
-		web100_group* group) {
-	FILE *fplocal;
-
-	WorkerArgs workerArgs;
-	workerArgs.snapArgs = snaparg;
-	workerArgs.agent = agentarg;
-	workerArgs.peaks = peaks;
-	workerArgs.writeSnap = snaplogenabled;
-
-	group = web100_group_find(agentarg, "read");
-	snaparg->snap = web100_snapshot_alloc(group, conn);
-
-	if (snaplogenabled) {
-
-		//memcpy(metafilevariablename, metafilename, strlen(metafilename));
-		// The above could have been here, except for a caveat: metafile stores
-		// just the file name, but full filename is needed to open the log file
-
-		fplocal = fopen(get_logfile(), "a");
-		snaparg->log = web100_log_open_write(metafilename, conn, group);
-		if (fplocal == NULL) {
-			log_println(
-					0,
-					"Unable to open log file '%s', continuing on without logging",
-					get_logfile());
-		} else {
-			log_println(0, "Snaplog file: %s\n", metafilename);
-			fprintf(fplocal, "Snaplog file: %s\n", metafilename);
-			fclose(fplocal);
-		}
-	}
-
-	if (pthread_create(wrkrthreadidarg, NULL, snapWorker,
-			(void*) &workerArgs)) {
-		log_println(0, "Cannot create worker thread for writing snap log!");
-		*wrkrthreadidarg = 0;
-	}
-
-	pthread_mutex_lock(&mainmutex);
-	workerLoop= 1;
-	// obtain web100 snap into "snaparg.snap"
-	web100_snap(snaparg->snap);
-	if (snaplogenabled) {
-		web100_log_write(snaparg->log, snaparg->snap);
-	}
-	pthread_cond_wait(&maincond, &mainmutex);
-	pthread_mutex_unlock(&mainmutex);
+                       char snaplogenabled,  pthread_t *wrkrthreadidarg,
+                       char *metafilevariablename, char *metafilename, web100_connection* conn,
+                       web100_group* group) {
+  FILE *fplocal;
+
+  WorkerArgs workerArgs;
+  workerArgs.snapArgs = snaparg;
+  workerArgs.agent = agentarg;
+  workerArgs.peaks = peaks;
+  workerArgs.writeSnap = snaplogenabled;
+
+  group = web100_group_find(agentarg, "read");
+  snaparg->snap = web100_snapshot_alloc(group, conn);
+
+  if (snaplogenabled) {
+
+    //memcpy(metafilevariablename, metafilename, strlen(metafilename));
+    // The above could have been here, except for a caveat: metafile stores
+    // just the file name, but full filename is needed to open the log file
+
+    fplocal = fopen(get_logfile(), "a");
+    snaparg->log = web100_log_open_write(metafilename, conn, group);
+    if (fplocal == NULL) {
+      log_println(
+          0,
+          "Unable to open log file '%s', continuing on without logging",
+          get_logfile());
+    } else {
+      log_println(0, "Snaplog file: %s\n", metafilename);
+      fprintf(fplocal, "Snaplog file: %s\n", metafilename);
+      fclose(fplocal);
+    }
+  }
+
+  if (pthread_create(wrkrthreadidarg, NULL, snapWorker,
+                     (void*) &workerArgs)) {
+    log_println(0, "Cannot create worker thread for writing snap log!");
+    *wrkrthreadidarg = 0;
+  }
+
+  pthread_mutex_lock(&mainmutex);
+  workerLoop= 1;
+  // obtain web100 snap into "snaparg.snap"
+  web100_snap(snaparg->snap);
+  if (snaplogenabled) {
+    web100_log_write(snaparg->log, snaparg->snap);
+  }
+  pthread_cond_wait(&maincond, &mainmutex);
+  pthread_mutex_unlock(&mainmutex);
 }
 
 /**
@@ -313,18 +313,18 @@ void start_snap_worker(SnapArgs *snaparg, web100_agent *agentarg, CwndPeaks* pea
  * @param snapArgs_ptr  pointer to a snapArgs object
  * */
 void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled, SnapArgs* snapArgs_ptr) {
-	if (*workerThreadId) {
-		pthread_mutex_lock(&mainmutex);
-		workerLoop = 0;
-		pthread_mutex_unlock(&mainmutex);
-		pthread_join(*workerThreadId, NULL);
-	}
-	// close writing snaplog, if snaplog recording is enabled
-	if (snaplogenabled) {
-		web100_log_close_write(snapArgs_ptr->log);
-	}
-
-	web100_snapshot_free(snapArgs_ptr->snap);
+  if (*workerThreadId) {
+    pthread_mutex_lock(&mainmutex);
+    workerLoop = 0;
+    pthread_mutex_unlock(&mainmutex);
+    pthread_join(*workerThreadId, NULL);
+  }
+  // close writing snaplog, if snaplog recording is enabled
+  if (snaplogenabled) {
+    web100_log_close_write(snapArgs_ptr->log);
+  }
+
+  web100_snapshot_free(snapArgs_ptr->snap);
 
 }
 
@@ -344,43 +344,43 @@ void stop_snap_worker(pthread_t *workerThreadId, char snaplogenabled, SnapArgs*
  * */
 
 void start_packet_trace(int socketfdarg, int socketfdarg2, pid_t *childpid,
-		int *imonarg, struct sockaddr *cliaddrarg, socklen_t clilenarg,
-		char* device, PortPair* pairarg, const char* testindicatorarg,
-		int iscompressionenabled, char *copylocationarg) {
+                        int *imonarg, struct sockaddr *cliaddrarg, socklen_t clilenarg,
+                        char* device, PortPair* pairarg, const char* testindicatorarg,
+                        int iscompressionenabled, char *copylocationarg) {
 
-	char tmpstr[256];
-	int i, readretval;
+  char tmpstr[256];
+  int i, readretval;
 
-	I2Addr src_addr = I2AddrByLocalSockFD(get_errhandle(), socketfdarg, 0);
+  I2Addr src_addr = I2AddrByLocalSockFD(get_errhandle(), socketfdarg, 0);
 
-	if ((*childpid = fork()) == 0) {
+  if ((*childpid = fork()) == 0) {
 
-		close(socketfdarg2);
-		close(socketfdarg);
-		log_println(0, "%s test Child thinks pipe() returned fd0=%d, fd1=%d",
-				testindicatorarg, imonarg[0], imonarg[1]);
+    close(socketfdarg2);
+    close(socketfdarg);
+    log_println(0, "%s test Child thinks pipe() returned fd0=%d, fd1=%d",
+                testindicatorarg, imonarg[0], imonarg[1]);
 
-		init_pkttrace(src_addr, cliaddrarg, clilenarg, imonarg, device,
-			      pairarg, testindicatorarg, iscompressionenabled);
+    init_pkttrace(src_addr, cliaddrarg, clilenarg, imonarg, device,
+                  pairarg, testindicatorarg, iscompressionenabled);
 
-		exit(0); // Packet trace finished, terminate gracefully
-	}
-	memset(tmpstr, 0, 256);
-	for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
-		readretval = read(imonarg[0], tmpstr, 128);
-		if ((readretval == -1) && (errno == EINTR)) // socket interrupted, try reading again
-			continue;
-		break;
-	}
+    exit(0); // Packet trace finished, terminate gracefully
+  }
+  memset(tmpstr, 0, 256);
+  for (i = 0; i < 5; i++) { // read nettrace file name into "tmpstr"
+    readretval = read(imonarg[0], tmpstr, 128);
+    if ((readretval == -1) && (errno == EINTR)) // socket interrupted, try reading again
+      continue;
+    break;
+  }
 
-	// name of nettrace file passed back from pcap child copied into meta structure
-	if (strlen(tmpstr) > 5) {
-		memcpy(copylocationarg, tmpstr, strlen(tmpstr));
-		log_println(8, "**start pkt trace, memcopied dir name %s", tmpstr);
-	}
+  // name of nettrace file passed back from pcap child copied into meta structure
+  if (strlen(tmpstr) > 5) {
+    memcpy(copylocationarg, tmpstr, strlen(tmpstr));
+    log_println(8, "**start pkt trace, memcopied dir name %s", tmpstr);
+  }
 
-	// free this address now.
-	I2AddrFree(src_addr);
+  // free this address now.
+  I2AddrFree(src_addr);
 
 }
 
@@ -390,19 +390,19 @@ void start_packet_trace(int socketfdarg, int socketfdarg2, pid_t *childpid,
  *
  * */
 void stop_packet_trace(int *monpipe_arr) {
-	int retval;
-	int i;
-
-	for (i = 0; i < RETRY_COUNT; i++) {
-		//retval = write(mon_pipe1[1], "c", 1);
-		retval = write(monpipe_arr[1], "c", 1);
-		if (retval == 1)
-			break;
-		if ((retval == -1) && (errno == EINTR))
-			continue;
-	}
-	close(monpipe_arr[0]);
-	close(monpipe_arr[1]);
+  int retval;
+  int i;
+
+  for (i = 0; i < RETRY_COUNT; i++) {
+    //retval = write(mon_pipe1[1], "c", 1);
+    retval = write(monpipe_arr[1], "c", 1);
+    if (retval == 1)
+      break;
+    if ((retval == -1) && (errno == EINTR))
+      continue;
+  }
+  close(monpipe_arr[0]);
+  close(monpipe_arr[1]);
 
 }
 
@@ -413,37 +413,37 @@ void stop_packet_trace(int *monpipe_arr) {
  * @param agentarg web100 agent pointer
  * */
 void setCwndlimit(web100_connection* connarg, web100_group* grouparg,
-		web100_agent* agentarg, Options* optionsarg) {
-
-	web100_var *LimRwin, *yar;
-	u_int32_t limrwin_val;
-	char yuff[32];
-
-	if (optionsarg->limit > 0) {
-		log_print(1, "Setting Cwnd limit - ");
-
-		if (connarg != NULL) {
-			log_println(1,
-					"Got web100 connection pointer for recvsfd socket\n");
-			web100_agent_find_var_and_group(agentarg, "CurMSS", &grouparg,
-					&yar);
-			web100_raw_read(yar, connarg, yuff);
-			log_println(1, "MSS = %s, multiplication factor = %d",
-					web100_value_to_text(web100_get_var_type(yar), yuff),
-					optionsarg->limit);
-			limrwin_val = optionsarg->limit
-					* (atoi(
-							web100_value_to_text(web100_get_var_type(yar),
-									yuff)));
-			web100_agent_find_var_and_group(agentarg, "LimRwin", &grouparg,
-					&LimRwin);
-			log_print(1, "now write %d to limit the Receive window",
-					limrwin_val);
-			web100_raw_write(LimRwin, connarg, &limrwin_val);
-			log_println(1, "  ---  Done");
-		}
-
-	}
+                  web100_agent* agentarg, Options* optionsarg) {
+
+  web100_var *LimRwin, *yar;
+  u_int32_t limrwin_val;
+  char yuff[32];
+
+  if (optionsarg->limit > 0) {
+    log_print(1, "Setting Cwnd limit - ");
+
+    if (connarg != NULL) {
+      log_println(1,
+                  "Got web100 connection pointer for recvsfd socket\n");
+      web100_agent_find_var_and_group(agentarg, "CurMSS", &grouparg,
+                                      &yar);
+      web100_raw_read(yar, connarg, yuff);
+      log_println(1, "MSS = %s, multiplication factor = %d",
+                  web100_value_to_text(web100_get_var_type(yar), yuff),
+                  optionsarg->limit);
+      limrwin_val = optionsarg->limit
+          * (atoi(
+              web100_value_to_text(web100_get_var_type(yar),
+                                   yuff)));
+      web100_agent_find_var_and_group(agentarg, "LimRwin", &grouparg,
+                                      &LimRwin);
+      log_print(1, "now write %d to limit the Receive window",
+                limrwin_val);
+      web100_raw_write(LimRwin, connarg, &limrwin_val);
+      log_println(1, "  ---  Done");
+    }
+
+  }
 }
 
 /**
@@ -454,9 +454,9 @@ void setCwndlimit(web100_connection* connarg, web100_group* grouparg,
  * @return integer indicating whether buffer is clogged
  * */
 int is_buffer_clogged(int nextseqtosend, int lastunackedseq) {
-	int recclog = 0;
-	if ((RECLTH << 2) < (nextseqtosend - lastunackedseq - 1)) {
-		recclog = 1;
-	}
-	return recclog;
+  int recclog = 0;
+  if ((RECLTH << 2) < (nextseqtosend - lastunackedseq - 1)) {
+    recclog = 1;
+  }
+  return recclog;
 }
diff --git a/src/tr-mkmap.c b/src/tr-mkmap.c
index 176b7c0..b541dfd 100644
--- a/src/tr-mkmap.c
+++ b/src/tr-mkmap.c
@@ -53,69 +53,69 @@ static char dt6fn[256];
 #endif
 
 static struct option long_options[] = { { "build", 0, 0, 'b' }, { "compare", 1,
-		0, 'c' }, { "file", 1, 0, 'f' }, { "help", 0, 0, 'h' }, { "print", 0, 0,
-		'p' }, { "debug", 0, 0, 'd' }, { "version", 0, 0, 'v' }, { "dflttree",
-		1, 0, 301 },
+  0, 'c' }, { "file", 1, 0, 'f' }, { "help", 0, 0, 'h' }, { "print", 0, 0,
+    'p' }, { "debug", 0, 0, 'd' }, { "version", 0, 0, 'v' }, { "dflttree",
+      1, 0, 301 },
 #ifdef AF_INET6
-		{	"dflttree6", 1, 0, 302},
-		{	"ipv4", 0, 0, '4'},
-		{	"ipv6", 0, 0, '6'},
+    {	"dflttree6", 1, 0, 302},
+    {	"ipv4", 0, 0, '4'},
+    {	"ipv6", 0, 0, '6'},
 #endif
-		{ 0, 0, 0, 0 } };
+    { 0, 0, 0, 0 } };
 
 /* Recursive sub-routine that walks through the tree.  In
  * build mode (flag = b) add a new node to the tree if
  * a leaf is reached and this new node should go under it.
  */
 void build_tree(struct tr_tree *tmp, struct tr_tree *new) {
-	if (new->ip_addr == tmp->ip_addr)
-		return;
-	if (new->ip_addr < tmp->ip_addr) {
-		if (tmp->left == NULL) {
-			tmp->left = new;
-			return;
-		} else {
-			build_tree(tmp->left, new);
-			return;
-		}
-	}
-	if (new->ip_addr > tmp->ip_addr) {
-		if (tmp->right == NULL) {
-			tmp->right = new;
-			return;
-		} else {
-			build_tree(tmp->right, new);
-			return;
-		}
-	}
+  if (new->ip_addr == tmp->ip_addr)
+    return;
+  if (new->ip_addr < tmp->ip_addr) {
+    if (tmp->left == NULL) {
+      tmp->left = new;
+      return;
+    } else {
+      build_tree(tmp->left, new);
+      return;
+    }
+  }
+  if (new->ip_addr > tmp->ip_addr) {
+    if (tmp->right == NULL) {
+      tmp->right = new;
+      return;
+    } else {
+      build_tree(tmp->right, new);
+      return;
+    }
+  }
 }
 #ifdef AF_INET6
-void
+  void
 build_tree6(struct tr_tree6 *tmp, struct tr_tree6 *new)
 {
-	if (memcmp(new->ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) == 0) {
-		return;
-	}
-	if (memcmp(new->ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) < 0) {
-		if (tmp->left == NULL) {
-			tmp->left = new;
-			return;
-		}
-		else {
-			build_tree6(tmp->left, new);
-			return;
-		}
-	}
-	if (memcmp(new->ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) > 0) {
-		if (tmp->right == NULL) {
-			tmp->right = new;
-			return;
-		}
-		else {
-			build_tree6(tmp->right, new);
-			return;
-		}
-	}
+  if (memcmp(new->ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) == 0) {
+    return;
+  }
+  if (memcmp(new->ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) < 0) {
+    if (tmp->left == NULL) {
+      tmp->left = new;
+      return;
+    }
+    else {
+      build_tree6(tmp->left, new);
+      return;
+    }
+  }
+  if (memcmp(new->ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) > 0) {
+    if (tmp->right == NULL) {
+      tmp->right = new;
+      return;
+    }
+    else {
+      build_tree6(tmp->right, new);
+      return;
+    }
+  }
 }
 #endif
 
@@ -123,102 +123,102 @@ build_tree6(struct tr_tree6 *tmp, struct tr_tree6 *new)
  * lines with *'s too.
  */
 uint32_t get_addr(char *tmpbuff) {
-	char *tmpstr;
-	int i;
-	uint32_t ip_addr;
-	struct sockaddr_in address;
-
-	/* no response from intermediate/destination host found, line should
-	 * just contain * * * sequence.  return -1 (255.255.255.255)
-	 */
-	if ((strchr(tmpbuff, '*') != NULL) && (strchr(tmpbuff, '.') == NULL))
-		return (-1);
-
-	/* No IP address found on this line (can this occur or will the previous
-	 * test catch everything?
-	 */
-	if (strchr(tmpbuff, '.') == NULL)
-		return (-1);
-
-	/* now check to see if '-n' option was used.  Output could be
-	 * line_no. hostname (ip_addr) time1 time2 time3 flag
-	 * OR '-n'
-	 * line_no ip_addr time1 time2 time3
-	 */
-	if (strchr(tmpbuff, '(') != NULL) {
-		tmpstr = strchr(tmpbuff, '(');
-		tmpstr++;
-		tmpbuff = strtok(tmpstr, ")");
-	} else {
-		tmpstr = strchr(tmpbuff, '.');
-		while (tmpstr[0] != ' ') {
-			if (tmpstr == tmpbuff)
-				break;
-			tmpstr--;
-		}
-		tmpbuff = strtok(tmpstr, " ");
-	}
-	if ((i = inet_aton(tmpbuff, &address.sin_addr)) == -1) {
-		printf("Error: Improper format for traceroute compare file\n");
-		exit(-39);
-	}
-	ip_addr = address.sin_addr.s_addr;
-	return (ip_addr);
+  char *tmpstr;
+  int i;
+  uint32_t ip_addr;
+  struct sockaddr_in address;
+
+  /* no response from intermediate/destination host found, line should
+   * just contain * * * sequence.  return -1 (255.255.255.255)
+   */
+  if ((strchr(tmpbuff, '*') != NULL) && (strchr(tmpbuff, '.') == NULL))
+    return (-1);
+
+  /* No IP address found on this line (can this occur or will the previous
+   * test catch everything?
+   */
+  if (strchr(tmpbuff, '.') == NULL)
+    return (-1);
+
+  /* now check to see if '-n' option was used.  Output could be
+   * line_no. hostname (ip_addr) time1 time2 time3 flag
+   * OR '-n'
+   * line_no ip_addr time1 time2 time3
+   */
+  if (strchr(tmpbuff, '(') != NULL) {
+    tmpstr = strchr(tmpbuff, '(');
+    tmpstr++;
+    tmpbuff = strtok(tmpstr, ")");
+  } else {
+    tmpstr = strchr(tmpbuff, '.');
+    while (tmpstr[0] != ' ') {
+      if (tmpstr == tmpbuff)
+        break;
+      tmpstr--;
+    }
+    tmpbuff = strtok(tmpstr, " ");
+  }
+  if ((i = inet_aton(tmpbuff, &address.sin_addr)) == -1) {
+    printf("Error: Improper format for traceroute compare file\n");
+    exit(-39);
+  }
+  ip_addr = address.sin_addr.s_addr;
+  return (ip_addr);
 }
 #ifdef AF_INET6
-int
+  int
 get_addr6(uint32_t dst_addr[4], char *tmpbuff)
 {
-	char *tmpstr;
-	int i;
-	struct sockaddr_in6 address;
-
-	/* no response from intermediate/destination host found, line should
-	 * just contain IP t1 !x t2 !x t3 !x sequence.  Set addr to 16x255, return 0.
-	 */
-	if ((tmpstr = strchr(tmpbuff, '!')) != NULL) {
-		tmpstr++;
-		if ((tmpstr = strchr(tmpstr, '!')) != NULL) {
-			tmpstr++;
-			if (strchr(tmpstr, '!') != NULL) {
-				memset(dst_addr, 255, 16);
-				return 0;
-			}
-		}
-	}
-
-	/* No IP address found on this line. Set addr to 16x255, return 0.
-	 */
-	if (strchr(tmpbuff, ':') == NULL) {
-		memset(dst_addr, 255, 16);
-		return 0;
-	}
-
-	/* now check to see if '-n' option was used.  Output could be
-	 * line_no. hostname (ip_addr) time1 time2 time3 flag
-	 * OR '-n'
-	 * line_no ip_addr time1 time2 time3
-	 */
-	if (strchr(tmpbuff, '(') != NULL) {
-		tmpstr = strchr(tmpbuff, '(');
-		tmpstr++;
-		tmpbuff = strtok(tmpstr, ")");
-	}
-	else {
-		tmpstr = strchr(tmpbuff, ':');
-		while (tmpstr[0] != ' ') {
-			if (tmpstr == tmpbuff)
-			break;
-			tmpstr--;
-		}
-		tmpbuff = strtok(tmpstr, " ");
-	}
-	if ((i = inet_pton(AF_INET6, tmpbuff, &address.sin6_addr)) == -1) {
-		printf("Error: Improper format for traceroute6 compare file\n");
-		exit(-39);
-	}
-	memcpy(dst_addr, &address.sin6_addr, 16);
-	return 1;
+  char *tmpstr;
+  int i;
+  struct sockaddr_in6 address;
+
+  /* no response from intermediate/destination host found, line should
+   * just contain IP t1 !x t2 !x t3 !x sequence.  Set addr to 16x255, return 0.
+   */
+  if ((tmpstr = strchr(tmpbuff, '!')) != NULL) {
+    tmpstr++;
+    if ((tmpstr = strchr(tmpstr, '!')) != NULL) {
+      tmpstr++;
+      if (strchr(tmpstr, '!') != NULL) {
+        memset(dst_addr, 255, 16);
+        return 0;
+      }
+    }
+  }
+
+  /* No IP address found on this line. Set addr to 16x255, return 0.
+  */
+  if (strchr(tmpbuff, ':') == NULL) {
+    memset(dst_addr, 255, 16);
+    return 0;
+  }
+
+  /* now check to see if '-n' option was used.  Output could be
+   * line_no. hostname (ip_addr) time1 time2 time3 flag
+   * OR '-n'
+   * line_no ip_addr time1 time2 time3
+   */
+  if (strchr(tmpbuff, '(') != NULL) {
+    tmpstr = strchr(tmpbuff, '(');
+    tmpstr++;
+    tmpbuff = strtok(tmpstr, ")");
+  }
+  else {
+    tmpstr = strchr(tmpbuff, ':');
+    while (tmpstr[0] != ' ') {
+      if (tmpstr == tmpbuff)
+        break;
+      tmpstr--;
+    }
+    tmpbuff = strtok(tmpstr, " ");
+  }
+  if ((i = inet_pton(AF_INET6, tmpbuff, &address.sin6_addr)) == -1) {
+    printf("Error: Improper format for traceroute6 compare file\n");
+    exit(-39);
+  }
+  memcpy(dst_addr, &address.sin6_addr, 16);
+  return 1;
 }
 #endif
 
@@ -226,41 +226,41 @@ get_addr6(uint32_t dst_addr[4], char *tmpbuff)
  * indicate completion status
  */
 void compare_tree(struct tr_tree *tmp, uint32_t ip_addr) {
-	if (tmp->ip_addr == ip_addr) {
-		found_node = 1;
-		tr_cur = tmp;
-		return;
-	}
-	if ((tmp->left == NULL) && (tmp->right == NULL)) {
-		found_node = 2;
-		tr_cur = tmp;
-		return;
-	}
-	if ((tmp->ip_addr < ip_addr) && (found_node == 0))
-		compare_tree(tmp->left, ip_addr);
-	if ((tmp->ip_addr > ip_addr) && (found_node == 0))
-		compare_tree(tmp->right, ip_addr);
+  if (tmp->ip_addr == ip_addr) {
+    found_node = 1;
+    tr_cur = tmp;
+    return;
+  }
+  if ((tmp->left == NULL) && (tmp->right == NULL)) {
+    found_node = 2;
+    tr_cur = tmp;
+    return;
+  }
+  if ((tmp->ip_addr < ip_addr) && (found_node == 0))
+    compare_tree(tmp->left, ip_addr);
+  if ((tmp->ip_addr > ip_addr) && (found_node == 0))
+    compare_tree(tmp->right, ip_addr);
 }
 #ifdef AF_INET6
-void
+  void
 compare_tree6(struct tr_tree6 *tmp, uint32_t ip_addr[4])
 {
-	if (memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) == 0) {
-		found_node = 1;
-		tr_cur6 = tmp;
-		return;
-	}
-	if ((tmp->left == NULL) && (tmp->right == NULL)) {
-		found_node = 2;
-		tr_cur6 = tmp;
-		return;
-	}
-	if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) > 0) && (found_node == 0)) {
-		compare_tree6(tmp->left, ip_addr);
-	}
-	if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) < 0) && (found_node == 0)) {
-		compare_tree6(tmp->right, ip_addr);
-	}
+  if (memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) == 0) {
+    found_node = 1;
+    tr_cur6 = tmp;
+    return;
+  }
+  if ((tmp->left == NULL) && (tmp->right == NULL)) {
+    found_node = 2;
+    tr_cur6 = tmp;
+    return;
+  }
+  if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) > 0) && (found_node == 0)) {
+    compare_tree6(tmp->left, ip_addr);
+  }
+  if ((memcmp(ip_addr, tmp->ip_addr, sizeof(tmp->ip_addr)) < 0) && (found_node == 0)) {
+    compare_tree6(tmp->right, ip_addr);
+  }
 }
 #endif
 
@@ -270,33 +270,33 @@ compare_tree6(struct tr_tree6 *tmp, uint32_t ip_addr[4])
  */
 
 void save_tree(struct tr_tree *cur, FILE *fp) {
-	int i;
-
-	for (i = 0; i < cur->branches; i++) {
-		if (i == 0)
-			fwrite(cur, sizeof(struct tr_tree), 1, fp);
-		save_tree(&*cur->branch[i], fp);
-	}
-	if (cur->branches == 0) {
-		fwrite(cur, sizeof(struct tr_tree), 1, fp);
-		free(cur);
-	}
+  int i;
+
+  for (i = 0; i < cur->branches; i++) {
+    if (i == 0)
+      fwrite(cur, sizeof(struct tr_tree), 1, fp);
+    save_tree(&*cur->branch[i], fp);
+  }
+  if (cur->branches == 0) {
+    fwrite(cur, sizeof(struct tr_tree), 1, fp);
+    free(cur);
+  }
 }
 #ifdef AF_INET6
-void
+  void
 save_tree6(struct tr_tree6 *cur, FILE *fp)
 {
-	int i;
-
-	for (i=0; i<cur->branches; i++) {
-		if (i == 0)
-		fwrite(cur, sizeof(struct tr_tree6), 1, fp);
-		save_tree6(&*cur->branch[i], fp);
-	}
-	if (cur->branches == 0) {
-		fwrite(cur, sizeof(struct tr_tree6), 1, fp);
-		free(cur);
-	}
+  int i;
+
+  for (i=0; i<cur->branches; i++) {
+    if (i == 0)
+      fwrite(cur, sizeof(struct tr_tree6), 1, fp);
+    save_tree6(&*cur->branch[i], fp);
+  }
+  if (cur->branches == 0) {
+    fwrite(cur, sizeof(struct tr_tree6), 1, fp);
+    free(cur);
+  }
 }
 #endif
 
@@ -304,47 +304,47 @@ save_tree6(struct tr_tree6 *cur, FILE *fp)
  * Once restored, the comparison can take place.
  */
 void restore_tree2(struct tr_tree *tmp, FILE *fp) {
-	struct tr_tree *new;
-	int i, j;
-
-	for (i = 0; i < tmp->branches; i++) {
-		new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
-		memset(&*new, 0, sizeof(struct tr_tree));
-		if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
-			return;
-		else {
-			for (j = 0; j < 25; j++)
-				new->branch[j] = NULL;
-		}
-		tmp->branch[i] = new;
-		if (new->branches == 0) {
-			continue;
-		}
-		restore_tree(&*tmp->branch[i], fp);
-	}
+  struct tr_tree *new;
+  int i, j;
+
+  for (i = 0; i < tmp->branches; i++) {
+    new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
+    memset(&*new, 0, sizeof(struct tr_tree));
+    if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+      return;
+    else {
+      for (j = 0; j < 25; j++)
+        new->branch[j] = NULL;
+    }
+    tmp->branch[i] = new;
+    if (new->branches == 0) {
+      continue;
+    }
+    restore_tree(&*tmp->branch[i], fp);
+  }
 }
 #ifdef AF_INET6
-void
+  void
 restore_tree26(struct tr_tree6 *tmp, FILE *fp)
 {
-	struct tr_tree6 *new;
-	int i, j;
-
-	for (i=0; i<tmp->branches; i++) {
-		new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
-		memset(&*new, 0, sizeof(struct tr_tree6));
-		if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
-		return;
-		else {
-			for (j=0; j<25; j++)
-			new->branch[j] = NULL;
-		}
-		tmp->branch[i] = new;
-		if (new->branches == 0) {
-			continue;
-		}
-		restore_tree6( &*tmp->branch[i], fp);
-	}
+  struct tr_tree6 *new;
+  int i, j;
+
+  for (i=0; i<tmp->branches; i++) {
+    new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
+    memset(&*new, 0, sizeof(struct tr_tree6));
+    if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+      return;
+    else {
+      for (j=0; j<25; j++)
+        new->branch[j] = NULL;
+    }
+    tmp->branch[i] = new;
+    if (new->branches == 0) {
+      continue;
+    }
+    restore_tree6( &*tmp->branch[i], fp);
+  }
 }
 #endif
 
@@ -352,464 +352,464 @@ restore_tree26(struct tr_tree6 *tmp, FILE *fp)
  * standard recursive print algorithm
  */
 void print_tree(struct tr_tree *cur) {
-	static int i;
-	int j;
-
-	if (i == 0)
-		printf(
-				"Root node is [%u.%u.%u.%u]\n",
-				(cur->ip_addr & 0xff), ((cur->ip_addr >> 8) & 0xff),
-				((cur->ip_addr >> 16) & 0xff), (cur->ip_addr >> 24));
-				else {
-					printf("Leaf %d node [%u.%u.%u.%u]\n", i,
-							(cur->ip_addr & 0xff), ((cur->ip_addr >> 8) &0xff),
-        ((cur->ip_addr >> 16) & 0xff),  ((cur->ip_addr >> 24) & 0xff));
-  }
-	for (j = 0; j < cur->branches; j++) {
-		i++;
-		print_tree(&*cur->branch[j]);
-		i--;
-	}
+  static int i;
+  int j;
+
+  if (i == 0)
+    printf(
+        "Root node is [%u.%u.%u.%u]\n",
+        (cur->ip_addr & 0xff), ((cur->ip_addr >> 8) & 0xff),
+        ((cur->ip_addr >> 16) & 0xff), (cur->ip_addr >> 24));
+  else {
+    printf("Leaf %d node [%u.%u.%u.%u]\n", i,
+           (cur->ip_addr & 0xff), ((cur->ip_addr >> 8) &0xff),
+           ((cur->ip_addr >> 16) & 0xff),  ((cur->ip_addr >> 24) & 0xff));
+  }
+  for (j = 0; j < cur->branches; j++) {
+    i++;
+    print_tree(&*cur->branch[j]);
+    i--;
+  }
 }
 #ifdef AF_INET6
-void
+  void
 print_tree6(struct tr_tree6 *cur)
 {
-	static int i;
-	int j;
-	char nodename[200];
-	socklen_t nnlen = 199;
-
-	if (i == 0) {
-		inet_ntop(AF_INET6, cur->ip_addr, nodename, nnlen);
-		printf("Root node is [%s]\n", nodename);
-	}
-	else {
-		inet_ntop(AF_INET6, cur->ip_addr, nodename, nnlen);
-		printf("Leaf %d node [%s]\n", i, nodename);
-	}
-	for (j=0; j<cur->branches; j++) {
-		i++;
-		print_tree6(&*cur->branch[j]);
-		i--;
-	}
+  static int i;
+  int j;
+  char nodename[200];
+  socklen_t nnlen = 199;
+
+  if (i == 0) {
+    inet_ntop(AF_INET6, cur->ip_addr, nodename, nnlen);
+    printf("Root node is [%s]\n", nodename);
+  }
+  else {
+    inet_ntop(AF_INET6, cur->ip_addr, nodename, nnlen);
+    printf("Leaf %d node [%s]\n", i, nodename);
+  }
+  for (j=0; j<cur->branches; j++) {
+    i++;
+    print_tree6(&*cur->branch[j]);
+    i--;
+  }
 }
 #endif
 
 /* Builds the tree from the given file
- */
+*/
 void build(char* inputfile) {
-	struct tr_tree *root, *current, *new;
-	int i;
-	uint32_t ip_addr;
-	char buff[256], *tmpbuff;
-	FILE * fp;
-
-	root = NULL;
-	current = NULL;
-
-	printf("\nBuilding default tree (IPv4)\n\n");
-	if (inputfile == NULL)
-		inputfile = "/tmp/traceroute.data";
-	fp = fopen(inputfile, "r");
-
-	if (fp == NULL) {
-		printf("Error: Default tree input file '%s' missing!\n", inputfile);
-		exit(-5);
-	}
-	while ((fgets(buff, 256, fp)) != NULL) {
-		tmpbuff = strtok(buff, "\n");
-		if (tmpbuff == NULL) {
-			current = root;
-			continue;
-		}
-		ip_addr = get_addr(tmpbuff);
-		new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
-		if (new == NULL) {
-			printf("Error: malloc failed, out of memory\n");
-			exit(-10);
-		}
-		memset(&*new, 0, sizeof(struct tr_tree));
-		new->ip_addr = ip_addr;
-		snprintf(new->hostname, sizeof(new->hostname), "%u.%u.%u.%u",
-				(ip_addr & 0xff), ((ip_addr >> 8) & 0xff),
-				((ip_addr >> 16) & 0xff), (ip_addr >> 24));
-		/* resolve host name and store for later use */
-
-		if (root == NULL) {
-			root = new;
-		} else {
-			if ((current == root) && (current->ip_addr == new->ip_addr)) {
-				free(new);
-				continue;
-			}
-			for (i = 0; i < current->branches; i++) {
-				if (current->branch[i]->ip_addr == new->ip_addr) {
-					current = current->branch[i];
-					free(new);
-					new = NULL;
-					break;
-				}
-			}
-			if (new == NULL) {
-				continue;
-			} else {
-				i = 0;
-				while (current->branch[i] != NULL)
-					i++;
-				current->branch[i] = new;
-				current->branches++;
-			}
-		}
-		current = new;
-	}
-	fp = fopen(DefaultTree, "wb");
-	if (fp == NULL) {
-		printf("Error: Can't write default tree '%s', exiting save_tree()\n",
-				DefaultTree);
-		exit(-15);
-	}
-	print_tree(&*root);
-	printf("Finished printing default tree '%s'\n", DefaultTree);
-	save_tree(&*root, fp);
-	fclose(fp);
+  struct tr_tree *root, *current, *new;
+  int i;
+  uint32_t ip_addr;
+  char buff[256], *tmpbuff;
+  FILE * fp;
+
+  root = NULL;
+  current = NULL;
+
+  printf("\nBuilding default tree (IPv4)\n\n");
+  if (inputfile == NULL)
+    inputfile = "/tmp/traceroute.data";
+  fp = fopen(inputfile, "r");
+
+  if (fp == NULL) {
+    printf("Error: Default tree input file '%s' missing!\n", inputfile);
+    exit(-5);
+  }
+  while ((fgets(buff, 256, fp)) != NULL) {
+    tmpbuff = strtok(buff, "\n");
+    if (tmpbuff == NULL) {
+      current = root;
+      continue;
+    }
+    ip_addr = get_addr(tmpbuff);
+    new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
+    if (new == NULL) {
+      printf("Error: malloc failed, out of memory\n");
+      exit(-10);
+    }
+    memset(&*new, 0, sizeof(struct tr_tree));
+    new->ip_addr = ip_addr;
+    snprintf(new->hostname, sizeof(new->hostname), "%u.%u.%u.%u",
+             (ip_addr & 0xff), ((ip_addr >> 8) & 0xff),
+             ((ip_addr >> 16) & 0xff), (ip_addr >> 24));
+    /* resolve host name and store for later use */
+
+    if (root == NULL) {
+      root = new;
+    } else {
+      if ((current == root) && (current->ip_addr == new->ip_addr)) {
+        free(new);
+        continue;
+      }
+      for (i = 0; i < current->branches; i++) {
+        if (current->branch[i]->ip_addr == new->ip_addr) {
+          current = current->branch[i];
+          free(new);
+          new = NULL;
+          break;
+        }
+      }
+      if (new == NULL) {
+        continue;
+      } else {
+        i = 0;
+        while (current->branch[i] != NULL)
+          i++;
+        current->branch[i] = new;
+        current->branches++;
+      }
+    }
+    current = new;
+  }
+  fp = fopen(DefaultTree, "wb");
+  if (fp == NULL) {
+    printf("Error: Can't write default tree '%s', exiting save_tree()\n",
+           DefaultTree);
+    exit(-15);
+  }
+  print_tree(&*root);
+  printf("Finished printing default tree '%s'\n", DefaultTree);
+  save_tree(&*root, fp);
+  fclose(fp);
 }
 #ifdef AF_INET6
-void
+  void
 build6(char* inputfile)
 {
-	struct tr_tree6 *root, *current, *new;
-	int i;
-	uint32_t ip_addr[4];
-	char buff[256], *tmpbuff;
-	char nodename[200];
-	socklen_t nnlen = 199;
-	FILE *fp;
-
-	root = NULL;
-	current = NULL;
-
-	printf("\nBuilding default tree (IPv6)\n\n");
-	if (inputfile == NULL)
-	inputfile = "/tmp/traceroute6.data";
-	fp = fopen(inputfile, "r");
-
-	if (fp == NULL) {
-		printf("Error: Default tree6 input file '%s' missing!\n", inputfile);
-		exit (-5);
-	}
-	while ((fgets(buff, 256, fp)) != NULL) {
-		tmpbuff = strtok(buff, "\n");
-		if (tmpbuff == NULL) {
-			current = root;
-			continue;
-		}
-		get_addr6(ip_addr, tmpbuff);
-		new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
-		if (new == NULL) {
-			printf("Error: malloc failed, out of memory\n");
-			exit (-10);
-		}
-		memset(&*new, 0, sizeof(struct tr_tree6));
-		memcpy(new->ip_addr, ip_addr, sizeof(new->ip_addr));
-		inet_ntop(AF_INET6, new->ip_addr, nodename, nnlen);
-		snprintf(new->hostname, sizeof(new->hostname), "%s", nodename);
-		/* resolve host name and store for later use */
-
-		if (root == NULL) {
-			root = new;
-		}
-		else {
-			if ((current == root) && (memcmp(current->ip_addr, new->ip_addr, sizeof(new->ip_addr)) == 0)) {
-				free(new);
-				continue;
-			}
-			for (i=0; i<current->branches; i++) {
-				if (memcmp(current->branch[i]->ip_addr, new->ip_addr, sizeof(new->ip_addr)) == 0) {
-					current = current->branch[i];
-					free(new);
-					new = NULL;
-					break;
-				}
-			}
-			if (new == NULL) {
-				continue;
-			} else {
-				i = 0;
-				while (current->branch[i] != NULL)
-				i++;
-				current->branch[i] = new;
-				current->branches++;
-			}
-		}
-		current = new;
-	}
-	fp = fopen(DefaultTree6, "wb");
-	if (fp == NULL) {
-		printf("Error: Can't write default tree6 '%s', exiting save_tree()\n", DefaultTree6);
-		exit (-15);
-	}
-	print_tree6(&*root);
-	printf("Finished printing default tree6 '%s'\n", DefaultTree6);
-	save_tree6(&*root, fp);
-	fclose(fp);
+  struct tr_tree6 *root, *current, *new;
+  int i;
+  uint32_t ip_addr[4];
+  char buff[256], *tmpbuff;
+  char nodename[200];
+  socklen_t nnlen = 199;
+  FILE *fp;
+
+  root = NULL;
+  current = NULL;
+
+  printf("\nBuilding default tree (IPv6)\n\n");
+  if (inputfile == NULL)
+    inputfile = "/tmp/traceroute6.data";
+  fp = fopen(inputfile, "r");
+
+  if (fp == NULL) {
+    printf("Error: Default tree6 input file '%s' missing!\n", inputfile);
+    exit (-5);
+  }
+  while ((fgets(buff, 256, fp)) != NULL) {
+    tmpbuff = strtok(buff, "\n");
+    if (tmpbuff == NULL) {
+      current = root;
+      continue;
+    }
+    get_addr6(ip_addr, tmpbuff);
+    new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
+    if (new == NULL) {
+      printf("Error: malloc failed, out of memory\n");
+      exit (-10);
+    }
+    memset(&*new, 0, sizeof(struct tr_tree6));
+    memcpy(new->ip_addr, ip_addr, sizeof(new->ip_addr));
+    inet_ntop(AF_INET6, new->ip_addr, nodename, nnlen);
+    snprintf(new->hostname, sizeof(new->hostname), "%s", nodename);
+    /* resolve host name and store for later use */
+
+    if (root == NULL) {
+      root = new;
+    }
+    else {
+      if ((current == root) && (memcmp(current->ip_addr, new->ip_addr, sizeof(new->ip_addr)) == 0)) {
+        free(new);
+        continue;
+      }
+      for (i=0; i<current->branches; i++) {
+        if (memcmp(current->branch[i]->ip_addr, new->ip_addr, sizeof(new->ip_addr)) == 0) {
+          current = current->branch[i];
+          free(new);
+          new = NULL;
+          break;
+        }
+      }
+      if (new == NULL) {
+        continue;
+      } else {
+        i = 0;
+        while (current->branch[i] != NULL)
+          i++;
+        current->branch[i] = new;
+        current->branches++;
+      }
+    }
+    current = new;
+  }
+  fp = fopen(DefaultTree6, "wb");
+  if (fp == NULL) {
+    printf("Error: Can't write default tree6 '%s', exiting save_tree()\n", DefaultTree6);
+    exit (-15);
+  }
+  print_tree6(&*root);
+  printf("Finished printing default tree6 '%s'\n", DefaultTree6);
+  save_tree6(&*root, fp);
+  fclose(fp);
 }
 #endif
 
 /* Compares the traceroute to the default tree
- */
+*/
 void compare(char* cmp_ip) {
-	struct tr_tree *root, *current, *new;
-	int i;
-	uint32_t ip_addr, IPlist[64];
-	char h_name[256], c_name[256], buff[256], *tmpbuff;
-	struct hostent *hp;
-	FILE * fp;
-
-	root = NULL;
-	current = NULL;
-
-	printf("\nComparing traceroute (IPv4)\n\n");
-	fp = fopen(DefaultTree, "rb");
-	if (fp == NULL) {
-		printf("Error: Can't read default tree '%s', exiting restore_tree()\n",
-				DefaultTree);
-		exit(-15);
-	}
-	new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
-	memset(&*new, 0, sizeof(struct tr_tree));
-	if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
-		return;
-	else {
-		for (i = 0; i < 25; i++)
-			new->branch[i] = NULL;
-	}
-	if (root == NULL) {
-		root = new;
-	}
-	restore_tree(&*root, fp);
-	fclose(fp);
-	fp = fopen(cmp_ip, "r");
-	if (fp == NULL) {
-		printf("Error: Can't read comparison file '%s', exiting main()\n",
-				cmp_ip);
-		exit(-17);
-	}
-	found_node = 0;
-	current = root;
-	i = 0;
-	while ((fgets(buff, 256, fp)) != NULL) {
-		tmpbuff = strtok(buff, "\n");
-		IPlist[i] = get_addr(tmpbuff);
-		log_println(5, "IPlist[%d] = %u.%u.%u.%u", (i),
-				(IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
-				((IPlist[i] >> 16) & 0xff), (IPlist[i] >> 24));
-		i++;
-
-	}
-
-	ip_addr = find_compare(IPlist, --i);
-
-	hp = gethostbyaddr((char *) &ip_addr, 4, AF_INET);
-	if (hp == NULL)
-		//strncpy(c_name, "Unknown Host", 13);
-		strlcpy(c_name, "Unknown Host", sizeof(c_name));
-	else
-		//strncpy(c_name, hp->h_name, strlen(hp->h_name));
-		strlcpy(c_name, hp->h_name, sizeof(c_name));
-
-	if (found_node == 1) {
-		printf("Host %s [%u.%u.%u.%u] is remote eNDT server!\n", c_name,
-				(ip_addr & 0xff), ((ip_addr >> 8) & 0xff),
-				((ip_addr >> 16) & 0xff), (ip_addr >> 24));
-				return;
-			}
-	printf("Leaf Node found!\n");
-	for (i = 0; i < current->branches; i++) {
-		if (current->branch[i]->branches == 0) {
-			current = current->branch[i];
-			break;
-		}
-	}
-	hp = (struct hostent *) gethostbyaddr((char *) &current->ip_addr, 4,
-			AF_INET);
-	if (hp == NULL)
-		//strncpy(h_name, "Unknown Host", 13);
-		strlcpy(h_name, "Unknown Host", sizeof(h_name));
-	else
-		//strncpy(h_name, hp->h_name, strlen(hp->h_name));
-		strlcpy(h_name, hp->h_name, sizeof(h_name));
-
-	printf(
-			"\tThe eNDT server %s [%u.%u.%u.%u] is closest to host %s [%u.%u.%u.%u]\n",
-			h_name,
-			(current->ip_addr & 0xff), ((current->ip_addr >> 8) & 0xff),
-			((current->ip_addr >> 16) & 0xff), (current->ip_addr >> 24),
-			c_name, (ip_addr & 0xff), ((ip_addr >> 8) & 0xff),
-			((ip_addr >> 16) & 0xff), (ip_addr >> 24));
-		}
+  struct tr_tree *root, *current, *new;
+  int i;
+  uint32_t ip_addr, IPlist[64];
+  char h_name[256], c_name[256], buff[256], *tmpbuff;
+  struct hostent *hp;
+  FILE * fp;
+
+  root = NULL;
+  current = NULL;
+
+  printf("\nComparing traceroute (IPv4)\n\n");
+  fp = fopen(DefaultTree, "rb");
+  if (fp == NULL) {
+    printf("Error: Can't read default tree '%s', exiting restore_tree()\n",
+           DefaultTree);
+    exit(-15);
+  }
+  new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
+  memset(&*new, 0, sizeof(struct tr_tree));
+  if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+    return;
+  else {
+    for (i = 0; i < 25; i++)
+      new->branch[i] = NULL;
+  }
+  if (root == NULL) {
+    root = new;
+  }
+  restore_tree(&*root, fp);
+  fclose(fp);
+  fp = fopen(cmp_ip, "r");
+  if (fp == NULL) {
+    printf("Error: Can't read comparison file '%s', exiting main()\n",
+           cmp_ip);
+    exit(-17);
+  }
+  found_node = 0;
+  current = root;
+  i = 0;
+  while ((fgets(buff, 256, fp)) != NULL) {
+    tmpbuff = strtok(buff, "\n");
+    IPlist[i] = get_addr(tmpbuff);
+    log_println(5, "IPlist[%d] = %u.%u.%u.%u", (i),
+                (IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
+                ((IPlist[i] >> 16) & 0xff), (IPlist[i] >> 24));
+    i++;
+
+  }
+
+  ip_addr = find_compare(IPlist, --i);
+
+  hp = gethostbyaddr((char *) &ip_addr, 4, AF_INET);
+  if (hp == NULL)
+    //strncpy(c_name, "Unknown Host", 13);
+    strlcpy(c_name, "Unknown Host", sizeof(c_name));
+  else
+    //strncpy(c_name, hp->h_name, strlen(hp->h_name));
+    strlcpy(c_name, hp->h_name, sizeof(c_name));
+
+  if (found_node == 1) {
+    printf("Host %s [%u.%u.%u.%u] is remote eNDT server!\n", c_name,
+           (ip_addr & 0xff), ((ip_addr >> 8) & 0xff),
+           ((ip_addr >> 16) & 0xff), (ip_addr >> 24));
+    return;
+  }
+  printf("Leaf Node found!\n");
+  for (i = 0; i < current->branches; i++) {
+    if (current->branch[i]->branches == 0) {
+      current = current->branch[i];
+      break;
+    }
+  }
+  hp = (struct hostent *) gethostbyaddr((char *) &current->ip_addr, 4,
+                                        AF_INET);
+  if (hp == NULL)
+    //strncpy(h_name, "Unknown Host", 13);
+    strlcpy(h_name, "Unknown Host", sizeof(h_name));
+  else
+    //strncpy(h_name, hp->h_name, strlen(hp->h_name));
+    strlcpy(h_name, hp->h_name, sizeof(h_name));
+
+  printf(
+      "\tThe eNDT server %s [%u.%u.%u.%u] is closest to host %s [%u.%u.%u.%u]\n",
+      h_name,
+      (current->ip_addr & 0xff), ((current->ip_addr >> 8) & 0xff),
+      ((current->ip_addr >> 16) & 0xff), (current->ip_addr >> 24),
+      c_name, (ip_addr & 0xff), ((ip_addr >> 8) & 0xff),
+      ((ip_addr >> 16) & 0xff), (ip_addr >> 24));
+}
 #ifdef AF_INET6
-	void
-	compare6(char* cmp_ip)
-	{
-		struct tr_tree6 *root, *current, *new;
-		int i;
-		uint32_t ip_addr[4], IPlist[64][4];
-		char h_name[256], c_name[256], buff[256], *tmpbuff;
-		struct hostent *hp;
-		char nodename[200];
-		socklen_t nnlen = 199;
-		FILE *fp;
-
-		root = NULL;
-		current = NULL;
-
-		printf("\nComparing traceroute (IPv6)\n\n");
-		fp = fopen(DefaultTree6, "rb");
-		if (fp == NULL) {
-			printf("Error: Can't read default tree6 '%s', exiting restore_tree()\n", DefaultTree6);
-			exit (-15);
-		}
-		new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
-		memset(&*new, 0, sizeof(struct tr_tree6));
-		if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
-		return;
-		else {
-			for (i=0; i<25; i++)
-			new->branch[i] = NULL;
-		}
-		if (root == NULL) {
-			root = new;
-		}
-		restore_tree6(&*root, fp);
-		fclose(fp);
-		fp = fopen(cmp_ip, "r");
-		if (fp == NULL) {
-			printf("Error: Can't read comparison file '%s', exiting main()\n", cmp_ip);
-			exit (-17);
-		}
-		found_node = 0;
-		current = root;
-		i = 0;
-		while ((fgets(buff, 256, fp)) != NULL) {
-			tmpbuff = strtok(buff, "\n");
-			get_addr6(IPlist[i], tmpbuff);
-			if (get_debuglvl() > 4) {
-				memset(nodename, 0, 200);
-				inet_ntop(AF_INET6, IPlist[i], nodename, nnlen);
-				log_println(5, "IP6list[%d] = %s", i, nodename);
-			}
-			i++;
-		}
-
-		find_compare6(ip_addr, IPlist, --i);
-
-		hp = gethostbyaddr((char *) ip_addr, 16, AF_INET6);
-		if (hp == NULL)
-		strncpy(c_name, "Unknown Host", 13);
-		else
-		strncpy(c_name, hp->h_name, strlen(hp->h_name));
-
-		if (found_node == 1) {
-			nnlen = 199;
-			memset(nodename, 0, 200);
-			inet_ntop(AF_INET6, ip_addr, nodename, nnlen);
-			printf("Host %s [%s] is remote eNDT server!\n", c_name, nodename);
-			return;
-		}
-		printf("Leaf Node found!\n");
-		for (i=0; i<current->branches; i++) {
-			if (current->branch[i]->branches == 0) {
-				current = current->branch[i];
-				break;
-			}
-		}
-		hp = (struct hostent *)gethostbyaddr((char *) current->ip_addr, 16, AF_INET6);
-		if (hp == NULL)
-		strncpy(h_name, "Unknown Host", 13);
-		else
-		strncpy(h_name, hp->h_name, strlen(hp->h_name));
-
-		nnlen = 199;
-		memset(nodename, 0, 200);
-		inet_ntop(AF_INET6, current->ip_addr, nodename, nnlen);
-		printf("\tThe eNDT server %s [%s]", h_name, nodename);
-		nnlen = 199;
-		memset(nodename, 0, 200);
-		inet_ntop(AF_INET6, ip_addr, nodename, nnlen);
-		printf(" is closest to host %s [%s]\n", c_name, nodename);
-	}
+  void
+compare6(char* cmp_ip)
+{
+  struct tr_tree6 *root, *current, *new;
+  int i;
+  uint32_t ip_addr[4], IPlist[64][4];
+  char h_name[256], c_name[256], buff[256], *tmpbuff;
+  struct hostent *hp;
+  char nodename[200];
+  socklen_t nnlen = 199;
+  FILE *fp;
+
+  root = NULL;
+  current = NULL;
+
+  printf("\nComparing traceroute (IPv6)\n\n");
+  fp = fopen(DefaultTree6, "rb");
+  if (fp == NULL) {
+    printf("Error: Can't read default tree6 '%s', exiting restore_tree()\n", DefaultTree6);
+    exit (-15);
+  }
+  new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
+  memset(&*new, 0, sizeof(struct tr_tree6));
+  if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+    return;
+  else {
+    for (i=0; i<25; i++)
+      new->branch[i] = NULL;
+  }
+  if (root == NULL) {
+    root = new;
+  }
+  restore_tree6(&*root, fp);
+  fclose(fp);
+  fp = fopen(cmp_ip, "r");
+  if (fp == NULL) {
+    printf("Error: Can't read comparison file '%s', exiting main()\n", cmp_ip);
+    exit (-17);
+  }
+  found_node = 0;
+  current = root;
+  i = 0;
+  while ((fgets(buff, 256, fp)) != NULL) {
+    tmpbuff = strtok(buff, "\n");
+    get_addr6(IPlist[i], tmpbuff);
+    if (get_debuglvl() > 4) {
+      memset(nodename, 0, 200);
+      inet_ntop(AF_INET6, IPlist[i], nodename, nnlen);
+      log_println(5, "IP6list[%d] = %s", i, nodename);
+    }
+    i++;
+  }
+
+  find_compare6(ip_addr, IPlist, --i);
+
+  hp = gethostbyaddr((char *) ip_addr, 16, AF_INET6);
+  if (hp == NULL)
+    strncpy(c_name, "Unknown Host", 13);
+  else
+    strncpy(c_name, hp->h_name, strlen(hp->h_name));
+
+  if (found_node == 1) {
+    nnlen = 199;
+    memset(nodename, 0, 200);
+    inet_ntop(AF_INET6, ip_addr, nodename, nnlen);
+    printf("Host %s [%s] is remote eNDT server!\n", c_name, nodename);
+    return;
+  }
+  printf("Leaf Node found!\n");
+  for (i=0; i<current->branches; i++) {
+    if (current->branch[i]->branches == 0) {
+      current = current->branch[i];
+      break;
+    }
+  }
+  hp = (struct hostent *)gethostbyaddr((char *) current->ip_addr, 16, AF_INET6);
+  if (hp == NULL)
+    strncpy(h_name, "Unknown Host", 13);
+  else
+    strncpy(h_name, hp->h_name, strlen(hp->h_name));
+
+  nnlen = 199;
+  memset(nodename, 0, 200);
+  inet_ntop(AF_INET6, current->ip_addr, nodename, nnlen);
+  printf("\tThe eNDT server %s [%s]", h_name, nodename);
+  nnlen = 199;
+  memset(nodename, 0, 200);
+  inet_ntop(AF_INET6, ip_addr, nodename, nnlen);
+  printf(" is closest to host %s [%s]\n", c_name, nodename);
+}
 #endif
 
-	/* Prints the default tree
-	 */
+/* Prints the default tree
+*/
 void print() {
-	struct tr_tree *root = NULL, *new;
-	int i;
-	FILE * fp;
-
-	printf("\nPrinting Default Tree (IPv4)\n\n");
-	fp = fopen(DefaultTree, "rb");
-	if (fp == NULL) {
-		printf("Error: No default tree '%s' found, exiting compare\n",
-				DefaultTree);
-		return;
-	}
-	new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
-	memset(&*new, 0, sizeof(struct tr_tree));
-	if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
-		return;
-	else {
-		for (i = 0; i < 25; i++)
-			new->branch[i] = NULL;
-	}
-	if (root == NULL) {
-		root = new;
-	}
-	restore_tree(&*root, fp);
-	fclose(fp);
-	print_tree(&*root);
+  struct tr_tree *root = NULL, *new;
+  int i;
+  FILE * fp;
+
+  printf("\nPrinting Default Tree (IPv4)\n\n");
+  fp = fopen(DefaultTree, "rb");
+  if (fp == NULL) {
+    printf("Error: No default tree '%s' found, exiting compare\n",
+           DefaultTree);
+    return;
+  }
+  new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
+  memset(&*new, 0, sizeof(struct tr_tree));
+  if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+    return;
+  else {
+    for (i = 0; i < 25; i++)
+      new->branch[i] = NULL;
+  }
+  if (root == NULL) {
+    root = new;
+  }
+  restore_tree(&*root, fp);
+  fclose(fp);
+  print_tree(&*root);
 }
 #ifdef AF_INET6
-void
+  void
 print6()
 {
-	struct tr_tree6 *root = NULL, *new;
-	int i;
-	FILE *fp;
-
-	printf("\nPrinting Default Tree (IPv6)\n\n");
-	fp = fopen(DefaultTree6, "rb");
-	if (fp == NULL) {
-		printf("Error: No default tree6 '%s' found, exiting compare6\n", DefaultTree6);
-		return;
-	}
-	new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
-	memset(&*new, 0, sizeof(struct tr_tree6));
-	if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
-	return;
-	else {
-		for (i=0; i<25; i++)
-		new->branch[i] = NULL;
-	}
-	if (root == NULL) {
-		root = new;
-	}
-	restore_tree6(&*root, fp);
-	fclose(fp);
-	print_tree6(&*root);
+  struct tr_tree6 *root = NULL, *new;
+  int i;
+  FILE *fp;
+
+  printf("\nPrinting Default Tree (IPv6)\n\n");
+  fp = fopen(DefaultTree6, "rb");
+  if (fp == NULL) {
+    printf("Error: No default tree6 '%s' found, exiting compare6\n", DefaultTree6);
+    return;
+  }
+  new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
+  memset(&*new, 0, sizeof(struct tr_tree6));
+  if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+    return;
+  else {
+    for (i=0; i<25; i++)
+      new->branch[i] = NULL;
+  }
+  if (root == NULL) {
+    root = new;
+  }
+  restore_tree6(&*root, fp);
+  fclose(fp);
+  print_tree6(&*root);
 }
 #endif
 
 int main(int argc, char *argv[]) {
-	char *cmp_ip = NULL;
-	char *inputfile = NULL;
-	int c, flag, flag_set = 0;
-	int v4only = 0;
-	int v6only = 0;
-	int debug = 0;
+  char *cmp_ip = NULL;
+  char *inputfile = NULL;
+  int c, flag, flag_set = 0;
+  int v4only = 0;
+  int v6only = 0;
+  int debug = 0;
 
-	flag = 'p';
+  flag = 'p';
 
 #ifdef AF_INET6
 #define GETOPT_LONG_INET6(x) "46"x
@@ -817,105 +817,105 @@ int main(int argc, char *argv[]) {
 #define GETOPT_LONG_INET6(x) x
 #endif
 
-	while ((c = getopt_long(argc, argv, GETOPT_LONG_INET6("bc:f:hpdv"),
-			long_options, 0)) != -1) {
-		switch (c) {
-		case '4':
-			v4only = 1;
-			break;
-		case '6':
-			v6only = 1;
-			break;
-		case 'b':
-			if (flag_set == 0) {
-				flag = 'b';
-				flag_set = 1;
-			}
-			break;
-		case 'c':
-			if (flag_set == 0) {
-				flag = 'c';
-				cmp_ip = optarg;
-				flag_set = 1;
-			}
-			break;
-		case 'f':
-			inputfile = optarg;
-			break;
-		case 'p':
-			flag = 'p';
-			break;
-		case 'd':
-			debug++;
-			break;
-		case 'h':
-			mkmap_long_usage("ANL/Internet2 NDT version " VERSION " (tr-mkmap)");
-			break;
-		case 'v':
-			printf("ANL/Internet2 NDT version %s (tr-mkmap)\n", VERSION);
-			exit(0);
-			break;
-		case 301:
-			DefaultTree = optarg;
-			break;
+  while ((c = getopt_long(argc, argv, GETOPT_LONG_INET6("bc:f:hpdv"),
+                          long_options, 0)) != -1) {
+    switch (c) {
+      case '4':
+        v4only = 1;
+        break;
+      case '6':
+        v6only = 1;
+        break;
+      case 'b':
+        if (flag_set == 0) {
+          flag = 'b';
+          flag_set = 1;
+        }
+        break;
+      case 'c':
+        if (flag_set == 0) {
+          flag = 'c';
+          cmp_ip = optarg;
+          flag_set = 1;
+        }
+        break;
+      case 'f':
+        inputfile = optarg;
+        break;
+      case 'p':
+        flag = 'p';
+        break;
+      case 'd':
+        debug++;
+        break;
+      case 'h':
+        mkmap_long_usage("ANL/Internet2 NDT version " VERSION " (tr-mkmap)");
+        break;
+      case 'v':
+        printf("ANL/Internet2 NDT version %s (tr-mkmap)\n", VERSION);
+        exit(0);
+        break;
+      case 301:
+        DefaultTree = optarg;
+        break;
 #ifdef AF_INET6
-			case 302:
-			DefaultTree6 = optarg;
-			break;
+      case 302:
+        DefaultTree6 = optarg;
+        break;
 #endif
-		case '?':
-			short_usage(argv[0], "");
-			break;
-		}
-	}
+      case '?':
+        short_usage(argv[0], "");
+        break;
+    }
+  }
 
-	if (optind < argc) {
-		short_usage(argv[0], "Unrecognized non-option elements");
-	}
+  if (optind < argc) {
+    short_usage(argv[0], "Unrecognized non-option elements");
+  }
 
-	log_init(argv[0], debug);
+  log_init(argv[0], debug);
 
-	if (DefaultTree == NULL) {
-		snprintf(dtfn, sizeof(dtfn), "%s/%s", BASEDIR, DFLT_TREE);
-		DefaultTree = dtfn;
-	}
+  if (DefaultTree == NULL) {
+    snprintf(dtfn, sizeof(dtfn), "%s/%s", BASEDIR, DFLT_TREE);
+    DefaultTree = dtfn;
+  }
 
 #ifdef AF_INET6
-	if (DefaultTree6 == NULL) {
-		snprintf(dt6fn, sizeof(dt6fn), "%s/%s", BASEDIR, DFLT_TREE6);
-		DefaultTree6 = dt6fn;
-	}
+  if (DefaultTree6 == NULL) {
+    snprintf(dt6fn, sizeof(dt6fn), "%s/%s", BASEDIR, DFLT_TREE6);
+    DefaultTree6 = dt6fn;
+  }
 #endif
 
-	if (flag == 'b') {
+  if (flag == 'b') {
 #ifdef AF_INET6
-		if (v4only == 0) {
-			build6(inputfile);
-		}
+    if (v4only == 0) {
+      build6(inputfile);
+    }
 #endif
-		if (v6only == 0) {
-			build(inputfile);
-		}
-	} else if (flag == 'c') {
+    if (v6only == 0) {
+      build(inputfile);
+    }
+  } else if (flag == 'c') {
 #ifdef AF_INET6
-		if (v4only == 0) {
-			compare6(cmp_ip);
-		}
+    if (v4only == 0) {
+      compare6(cmp_ip);
+    }
 #endif
-		if (v6only == 0) {
-			compare(cmp_ip);
-		}
-	} else if (flag == 'p') {
+    if (v6only == 0) {
+      compare(cmp_ip);
+    }
+  } else if (flag == 'p') {
 #ifdef AF_INET6
-		if (v4only == 0) {
-			print6();
-		}
+    if (v4only == 0) {
+      print6();
+    }
 #endif
-		if (v6only == 0) {
-			print();
-		}
-	} else {
-		printf("Nothing happened, how did I get here?\n");
-	}
-	return 0;
+    if (v6only == 0) {
+      print();
+    }
+  } else {
+    printf("Nothing happened, how did I get here?\n");
+  }
+  return 0;
 }
diff --git a/src/tr-tree.c b/src/tr-tree.c
index 297f8e6..2f8df1b 100644
--- a/src/tr-tree.c
+++ b/src/tr-tree.c
@@ -43,79 +43,79 @@ char* DefaultTree;
  * Once restored, the comparison can take place.
  */
 void restore_tree(struct tr_tree *tmp, FILE *fp) {
-	struct tr_tree *new;
-	int i, j;
-
-	for (i = 0; i < tmp->branches; i++) {
-		new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
-		memset(&*new, 0, sizeof(struct tr_tree));
-		if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
-			return;
-		else {
-			for (j = 0; j < 25; j++)
-				new->branch[j] = NULL;
-		}
-		tmp->branch[i] = new;
-		if (new->branches == 0) {
-			continue;
-		}
-		restore_tree(&*tmp->branch[i], fp);
-	}
+  struct tr_tree *new;
+  int i, j;
+
+  for (i = 0; i < tmp->branches; i++) {
+    new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
+    memset(&*new, 0, sizeof(struct tr_tree));
+    if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+      return;
+    else {
+      for (j = 0; j < 25; j++)
+        new->branch[j] = NULL;
+    }
+    tmp->branch[i] = new;
+    if (new->branches == 0) {
+      continue;
+    }
+    restore_tree(&*tmp->branch[i], fp);
+  }
 }
 
 u_int32_t find_compare(u_int32_t IPlist[], int cnt) {
 
-	struct tr_tree *root, *current, *new;
-	int i, j, k;
-	uint32_t srv_addr;
-	char h_name[256], c_name[256];
-	FILE * fp;
-	struct hostent *hp;
-
-	root = NULL;
-	current = NULL;
-
-	fp = fopen(DefaultTree, "rb");
-	if (fp == NULL) {
-		log_println(5,
-				"Error: Can't read default tree, exiting find_compare()");
-		return 0;
-	}
-	new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
-	memset(&*new, 0, sizeof(struct tr_tree));
-	if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
-		return 0;
-	else {
-		for (i = 0; i < 25; i++)
-			new->branch[i] = NULL;
-	}
-	if (root == NULL) {
-		root = new;
-	}
-	restore_tree(&*root, fp);
-	fclose(fp);
-	found_node = 0;
-	srv_addr = 0;
-	current = root;
-	log_println(6, "route to client contains %d hops", cnt);
-	for (i = 0; i <= cnt; i++) {
-		log_print(6, "New client node [%u.%u.%u.%u] ",
-				(IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
-				((IPlist[i] >> 16) & 0xff), (IPlist[i] >> 24));
-				log_println(6, "to map node [%u.%u.%u.%u]",
-						(current->ip_addr & 0xff), ((current->ip_addr >> 8) & 0xff),
-        ((current->ip_addr >> 16) & 0xff),  (current->ip_addr >> 24));
+  struct tr_tree *root, *current, *new;
+  int i, j, k;
+  uint32_t srv_addr;
+  char h_name[256], c_name[256];
+  FILE * fp;
+  struct hostent *hp;
+
+  root = NULL;
+  current = NULL;
+
+  fp = fopen(DefaultTree, "rb");
+  if (fp == NULL) {
+    log_println(5,
+                "Error: Can't read default tree, exiting find_compare()");
+    return 0;
+  }
+  new = (struct tr_tree *) malloc(sizeof(struct tr_tree));
+  memset(&*new, 0, sizeof(struct tr_tree));
+  if (fread(&*new, sizeof(struct tr_tree), 1, fp) == 0)
+    return 0;
+  else {
+    for (i = 0; i < 25; i++)
+      new->branch[i] = NULL;
+  }
+  if (root == NULL) {
+    root = new;
+  }
+  restore_tree(&*root, fp);
+  fclose(fp);
+  found_node = 0;
+  srv_addr = 0;
+  current = root;
+  log_println(6, "route to client contains %d hops", cnt);
+  for (i = 0; i <= cnt; i++) {
+    log_print(6, "New client node [%u.%u.%u.%u] ",
+              (IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
+              ((IPlist[i] >> 16) & 0xff), (IPlist[i] >> 24));
+    log_println(6, "to map node [%u.%u.%u.%u]",
+                (current->ip_addr & 0xff), ((current->ip_addr >> 8) & 0xff),
+                ((current->ip_addr >> 16) & 0xff),  (current->ip_addr >> 24));
     if (current->ip_addr == IPlist[i])
       continue;
     for (j=0; j<current->branches; j++) {
       log_print(5, "Comparing map node [%u.%u.%u.%u] ",
-          (current->branch[j]->ip_addr & 0xff),
-          ((current->branch[j]->ip_addr >> 8) & 0xff),
-          ((current->branch[j]->ip_addr >> 16) & 0xff), 
-          (current->branch[j]->ip_addr >> 24));
+                (current->branch[j]->ip_addr & 0xff),
+                ((current->branch[j]->ip_addr >> 8) & 0xff),
+                ((current->branch[j]->ip_addr >> 16) & 0xff), 
+                (current->branch[j]->ip_addr >> 24));
       log_println(5, "to client node [%u.%u.%u.%u], cnt = %d",
-          (IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
-          ((IPlist[i] >> 16) & 0xff),  (IPlist[i] >> 24), i);
+                  (IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
+                  ((IPlist[i] >> 16) & 0xff),  (IPlist[i] >> 24), i);
 
       if (current->branch[j]->ip_addr == IPlist[i]) {
         current = current->branch[j];
@@ -124,8 +124,8 @@ u_int32_t find_compare(u_int32_t IPlist[], int cnt) {
           if (current->branch[k]->branches == 0) {
             srv_addr = current->branch[k]->ip_addr;
             log_println(5, "srv_addr set to [%u.%u.%u.%u]",
-                (srv_addr & 0xff), ((srv_addr >> 8) & 0xff),
-                ((srv_addr >> 16) & 0xff), (srv_addr >> 24));
+                        (srv_addr & 0xff), ((srv_addr >> 8) & 0xff),
+                        ((srv_addr >> 16) & 0xff), (srv_addr >> 24));
             found_node = 1;
           }
         }
@@ -137,58 +137,58 @@ u_int32_t find_compare(u_int32_t IPlist[], int cnt) {
       break;
   } 
 
-	if (current->ip_addr == IPlist[cnt]) {
-		srv_addr = IPlist[cnt];
-		found_node = 1;
-	}
-	if (srv_addr != 0)
-		found_node = 1;
-
-	if (found_node == -1) {
-		log_println(6, "Broke out of compare loop, setting current pointer");
-		if (current->branches == 1) {
-			current = current->branch[0];
-			if (current->branches == 0)
-				found_node = 2;
-			else {
-				found_node = 4;
-				current = root;
-			}
-		} else {
-			found_node = 3;
-			current = root;
-		}
-	}
-
-	hp = gethostbyaddr((char *) &IPlist[i], 4, AF_INET);
-	if (hp == NULL)
-		strncpy(c_name, "Unknown Host", 13);
-	else
-		strncpy(c_name, hp->h_name, strlen(hp->h_name));
-
-	if (found_node == 1) {
-		log_println(5,
-				"Router %s [%u.%u.%u.%u] is last common router in the path!",
-				c_name, (IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
-				((IPlist[i] >> 16) & 0xff), (IPlist[i] >> 24));
-				return(srv_addr);
-			}
-	log_println(6, "New Server Node found!  found_node set to %d", found_node);
-	hp = (struct hostent *) gethostbyaddr((char *) &current->ip_addr, 4,
-			AF_INET);
-	if (hp == NULL)
-		strncpy(h_name, "Unknown Host", 13);
-	else
-		strncpy(h_name, hp->h_name, strlen(hp->h_name));
-
-	log_println(
-			6,
-			"\tThe eNDT server %s [%u.%u.%u.%u] is closest to %s [%u.%u.%u.%u]",
-			h_name,
-			(current->ip_addr & 0xff), ((current->ip_addr >> 8) & 0xff),
-			((current->ip_addr >> 16) & 0xff), (current->ip_addr >> 24),
-			c_name, (IPlist[cnt] & 0xff), ((IPlist[cnt] >> 8) & 0xff),
-			((IPlist[cnt] >> 16) & 0xff), (IPlist[cnt] >> 24));
-
-	return (current->ip_addr);
+  if (current->ip_addr == IPlist[cnt]) {
+    srv_addr = IPlist[cnt];
+    found_node = 1;
+  }
+  if (srv_addr != 0)
+    found_node = 1;
+
+  if (found_node == -1) {
+    log_println(6, "Broke out of compare loop, setting current pointer");
+    if (current->branches == 1) {
+      current = current->branch[0];
+      if (current->branches == 0)
+        found_node = 2;
+      else {
+        found_node = 4;
+        current = root;
+      }
+    } else {
+      found_node = 3;
+      current = root;
+    }
+  }
+
+  hp = gethostbyaddr((char *) &IPlist[i], 4, AF_INET);
+  if (hp == NULL)
+    strncpy(c_name, "Unknown Host", 13);
+  else
+    strncpy(c_name, hp->h_name, strlen(hp->h_name));
+
+  if (found_node == 1) {
+    log_println(5,
+                "Router %s [%u.%u.%u.%u] is last common router in the path!",
+                c_name, (IPlist[i] & 0xff), ((IPlist[i] >> 8) & 0xff),
+                ((IPlist[i] >> 16) & 0xff), (IPlist[i] >> 24));
+    return(srv_addr);
+  }
+  log_println(6, "New Server Node found!  found_node set to %d", found_node);
+  hp = (struct hostent *) gethostbyaddr((char *) &current->ip_addr, 4,
+                                        AF_INET);
+  if (hp == NULL)
+    strncpy(h_name, "Unknown Host", 13);
+  else
+    strncpy(h_name, hp->h_name, strlen(hp->h_name));
+
+  log_println(
+      6,
+      "\tThe eNDT server %s [%u.%u.%u.%u] is closest to %s [%u.%u.%u.%u]",
+      h_name,
+      (current->ip_addr & 0xff), ((current->ip_addr >> 8) & 0xff),
+      ((current->ip_addr >> 16) & 0xff), (current->ip_addr >> 24),
+      c_name, (IPlist[cnt] & 0xff), ((IPlist[cnt] >> 8) & 0xff),
+      ((IPlist[cnt] >> 16) & 0xff), (IPlist[cnt] >> 24));
+
+  return (current->ip_addr);
 }
diff --git a/src/tr-tree6.c b/src/tr-tree6.c
index 5dbb05e..f243711 100644
--- a/src/tr-tree6.c
+++ b/src/tr-tree6.c
@@ -47,176 +47,176 @@ char* DefaultTree6;
 /* Restore the default tree, stored by the save tree routine above.
  * Once restored, the comparison can take place.
  */
-void
+  void
 restore_tree6(struct tr_tree6 *tmp, FILE *fp)
 {
-	struct tr_tree6 *new;
-	int i, j;
-
-	for (i=0; i<tmp->branches; i++) {
-		new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
-		memset(&*new, 0, sizeof(struct tr_tree6));
-		if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
-		return;
-		else {
-			for (j=0; j<25; j++)
-			new->branch[j] = NULL;
-		}
-		tmp->branch[i] = new;
-		if (new->branches == 0) {
-			continue;
-		}
-		restore_tree6( &*tmp->branch[i], fp);
-	}
+  struct tr_tree6 *new;
+  int i, j;
+
+  for (i=0; i<tmp->branches; i++) {
+    new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
+    memset(&*new, 0, sizeof(struct tr_tree6));
+    if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+      return;
+    else {
+      for (j=0; j<25; j++)
+        new->branch[j] = NULL;
+    }
+    tmp->branch[i] = new;
+    if (new->branches == 0) {
+      continue;
+    }
+    restore_tree6( &*tmp->branch[i], fp);
+  }
 }
 
-int
+  int
 find_compare6(u_int32_t IPnode[4], u_int32_t IP6list[][4], int cnt)
 {
 
-	struct tr_tree6 *root, *current, *new;
-	int i, j, k, fnode = 0;
-	char h_name[256], c_name[256];
-	char nodename[200];
-	size_t nnlen;
-	FILE *fp;
-	struct hostent *hp;
-
-	root = NULL;
-	current = NULL;
-
-	fp = fopen(DefaultTree6, "rb");
-	if (fp == NULL) {
-		log_println(5, "Error: Can't read default tree, exiting find_compare6()");
-		return 0;
-	}
-	new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
-	memset(&*new, 0, sizeof(struct tr_tree6));
-	if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
-	return 0;
-	else {
-		for (i=0; i<25; i++)
-		new->branch[i] = NULL;
-	}
-	if (root == NULL) {
-		root = new;
-	}
-	restore_tree6(&*root, fp);
-	fclose(fp);
-	found_node = 0;
-	current = root;
-	log_println(6, "route to client contains %d hops", cnt);
-	for (i=0; i<=cnt; i++) {
-		if (get_debuglvl() > 5) {
-			memset(nodename, 0, 200);
-			nnlen = 199;
-			inet_ntop(AF_INET6, (void *) IP6list[i], nodename, nnlen);
-			log_print(6, "New client node [%s] ", nodename);
-			memset(nodename, 0, 200);
-			nnlen = 199;
-			inet_ntop(AF_INET6, (void *) current->ip_addr, nodename, nnlen);
-			log_println(6, "to map node [%s]", nodename);
-		}
-		if (memcmp(IP6list[i], current->ip_addr, sizeof(current->ip_addr)) == 0) {
-			continue;
-		}
-		for (j=0; j<current->branches; j++) {
-			if (get_debuglvl() > 4) {
-				memset(nodename, 0, 200);
-				nnlen = 199;
-				inet_ntop(AF_INET6, (void *) current->branch[j]->ip_addr, nodename, nnlen);
-				log_print(5, "Comparing map node [%s] ", nodename);
-				memset(nodename, 0, 200);
-				nnlen = 199;
-				inet_ntop(AF_INET6, (void *) IP6list[i], nodename, nnlen);
-				log_println(5, "to client node [%s], cnt = %d", nodename, i);
-			}
-
-			if (memcmp(current->branch[j]->ip_addr, IP6list[i], sizeof(IP6list[i])) == 0) {
-				current = current->branch[j];
-				found_node = 0;
-				for (k=0; k<current->branches; k++) {
-					if (current->branch[k]->branches == 0) {
-						memcpy(IPnode, current->branch[k]->ip_addr, 16);
-						if (get_debuglvl() > 4) {
-							memset(nodename, 0, 200);
-							nnlen = 199;
-							inet_ntop(AF_INET6, (void *) IPnode, nodename, nnlen);
-							log_println(5, "srv_addr set to [%s]", nodename);
-						}
-						found_node = 1;
-						fnode = 1;
-					}
-				}
-				break;
-			}
-			found_node = -1;
-		}
-		if (found_node == -1)
-		break;
-	}
-
-	if (memcmp(current->ip_addr, IP6list[cnt], sizeof(IP6list[cnt])) == 0) {
-		memcpy(IPnode, IP6list[cnt], 16);
-		found_node = 1;
-		fnode = 1;
-	}
-	if (fnode) {
-		found_node = 1;
-	}
-
-	if (found_node == -1) {
-		log_println(6, "Broke out of compare loop, setting current pointer");
-		if (current->branches == 1) {
-			current = current->branch[0];
-			if (current->branches == 0)
-			found_node = 2;
-			else {
-				found_node = 4;
-				current = root;
-			}
-		}
-		else {
-			found_node = 3;
-			current = root;
-		}
-	}
-
-	hp = gethostbyaddr((char *) IP6list[i], 16, AF_INET6);
-	if (hp == NULL)
-	strncpy(c_name, "Unknown Host", 13);
-	else
-	strncpy(c_name, hp->h_name, strlen(hp->h_name));
-
-	if (found_node == 1) {
-		if (get_debuglvl() > 4) {
-			memset(nodename, 0, 200);
-			nnlen = 199;
-			inet_ntop(AF_INET6, (void *) IP6list[i], nodename, nnlen);
-			log_println(5, "Router %s [%s] is last common router in the path!", c_name, nodename);
-		}
-		return 1;
-	}
-	log_println(6, "New Server Node found!  found_node set to %d", found_node);
-	hp = (struct hostent *)gethostbyaddr((char *) current->ip_addr, 16, AF_INET6);
-	if (hp == NULL)
-	strncpy(h_name, "Unknown Host", 13);
-	else
-	strncpy(h_name, hp->h_name, strlen(hp->h_name));
-
-	if (get_debuglvl() > 5) {
-		memset(nodename, 0, 200);
-		nnlen = 199;
-		inet_ntop(AF_INET6, (void *) current->ip_addr, nodename, nnlen);
-		log_print(6, "\tThe eNDT server %s [%s]", h_name, nodename);
-		memset(nodename, 0, 200);
-		nnlen = 199;
-		inet_ntop(AF_INET6, (void *) IP6list[cnt], nodename, nnlen);
-		log_println(6, " is closest to %s [%s]", c_name, nodename);
-	}
-
-	memcpy(IPnode, current->ip_addr, 16);
-	return 1;
+  struct tr_tree6 *root, *current, *new;
+  int i, j, k, fnode = 0;
+  char h_name[256], c_name[256];
+  char nodename[200];
+  size_t nnlen;
+  FILE *fp;
+  struct hostent *hp;
+
+  root = NULL;
+  current = NULL;
+
+  fp = fopen(DefaultTree6, "rb");
+  if (fp == NULL) {
+    log_println(5, "Error: Can't read default tree, exiting find_compare6()");
+    return 0;
+  }
+  new = (struct tr_tree6 *) malloc(sizeof(struct tr_tree6));
+  memset(&*new, 0, sizeof(struct tr_tree6));
+  if (fread(&*new, sizeof(struct tr_tree6), 1, fp) == 0)
+    return 0;
+  else {
+    for (i=0; i<25; i++)
+      new->branch[i] = NULL;
+  }
+  if (root == NULL) {
+    root = new;
+  }
+  restore_tree6(&*root, fp);
+  fclose(fp);
+  found_node = 0;
+  current = root;
+  log_println(6, "route to client contains %d hops", cnt);
+  for (i=0; i<=cnt; i++) {
+    if (get_debuglvl() > 5) {
+      memset(nodename, 0, 200);
+      nnlen = 199;
+      inet_ntop(AF_INET6, (void *) IP6list[i], nodename, nnlen);
+      log_print(6, "New client node [%s] ", nodename);
+      memset(nodename, 0, 200);
+      nnlen = 199;
+      inet_ntop(AF_INET6, (void *) current->ip_addr, nodename, nnlen);
+      log_println(6, "to map node [%s]", nodename);
+    }
+    if (memcmp(IP6list[i], current->ip_addr, sizeof(current->ip_addr)) == 0) {
+      continue;
+    }
+    for (j=0; j<current->branches; j++) {
+      if (get_debuglvl() > 4) {
+        memset(nodename, 0, 200);
+        nnlen = 199;
+        inet_ntop(AF_INET6, (void *) current->branch[j]->ip_addr, nodename, nnlen);
+        log_print(5, "Comparing map node [%s] ", nodename);
+        memset(nodename, 0, 200);
+        nnlen = 199;
+        inet_ntop(AF_INET6, (void *) IP6list[i], nodename, nnlen);
+        log_println(5, "to client node [%s], cnt = %d", nodename, i);
+      }
+
+      if (memcmp(current->branch[j]->ip_addr, IP6list[i], sizeof(IP6list[i])) == 0) {
+        current = current->branch[j];
+        found_node = 0;
+        for (k=0; k<current->branches; k++) {
+          if (current->branch[k]->branches == 0) {
+            memcpy(IPnode, current->branch[k]->ip_addr, 16);
+            if (get_debuglvl() > 4) {
+              memset(nodename, 0, 200);
+              nnlen = 199;
+              inet_ntop(AF_INET6, (void *) IPnode, nodename, nnlen);
+              log_println(5, "srv_addr set to [%s]", nodename);
+            }
+            found_node = 1;
+            fnode = 1;
+          }
+        }
+        break;
+      }
+      found_node = -1;
+    }
+    if (found_node == -1)
+      break;
+  }
+
+  if (memcmp(current->ip_addr, IP6list[cnt], sizeof(IP6list[cnt])) == 0) {
+    memcpy(IPnode, IP6list[cnt], 16);
+    found_node = 1;
+    fnode = 1;
+  }
+  if (fnode) {
+    found_node = 1;
+  }
+
+  if (found_node == -1) {
+    log_println(6, "Broke out of compare loop, setting current pointer");
+    if (current->branches == 1) {
+      current = current->branch[0];
+      if (current->branches == 0)
+        found_node = 2;
+      else {
+        found_node = 4;
+        current = root;
+      }
+    }
+    else {
+      found_node = 3;
+      current = root;
+    }
+  }
+
+  hp = gethostbyaddr((char *) IP6list[i], 16, AF_INET6);
+  if (hp == NULL)
+    strncpy(c_name, "Unknown Host", 13);
+  else
+    strncpy(c_name, hp->h_name, strlen(hp->h_name));
+
+  if (found_node == 1) {
+    if (get_debuglvl() > 4) {
+      memset(nodename, 0, 200);
+      nnlen = 199;
+      inet_ntop(AF_INET6, (void *) IP6list[i], nodename, nnlen);
+      log_println(5, "Router %s [%s] is last common router in the path!", c_name, nodename);
+    }
+    return 1;
+  }
+  log_println(6, "New Server Node found!  found_node set to %d", found_node);
+  hp = (struct hostent *)gethostbyaddr((char *) current->ip_addr, 16, AF_INET6);
+  if (hp == NULL)
+    strncpy(h_name, "Unknown Host", 13);
+  else
+    strncpy(h_name, hp->h_name, strlen(hp->h_name));
+
+  if (get_debuglvl() > 5) {
+    memset(nodename, 0, 200);
+    nnlen = 199;
+    inet_ntop(AF_INET6, (void *) current->ip_addr, nodename, nnlen);
+    log_print(6, "\tThe eNDT server %s [%s]", h_name, nodename);
+    memset(nodename, 0, 200);
+    nnlen = 199;
+    inet_ntop(AF_INET6, (void *) IP6list[cnt], nodename, nnlen);
+    log_println(6, " is closest to %s [%s]", c_name, nodename);
+  }
+
+  memcpy(IPnode, current->ip_addr, 16);
+  return 1;
 }
 
 #endif
diff --git a/src/troute.c b/src/troute.c
index 74049c7..f3ceb19 100644
--- a/src/troute.c
+++ b/src/troute.c
@@ -51,7 +51,7 @@
 #ifndef lint
 static char copyright[] =
 "@(#) Copyright (c) 1990, 1993\n\
-  The Regents of the University of California.  All rights reserved.\n";
+        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
@@ -99,11 +99,11 @@ static char sccsid[] = "@(#)troute.c  8.1 (Berkeley) 6/6/93";
  * format of a (udp) probe packet.
  */
 struct opacket {
-	struct ip ip;
-	struct udphdr udp;
-	u_char seq; /* sequence number of this packet */
-	u_char ttl; /* ttl packet left with */
-	struct timeval tv; /* time packet left */
+  struct ip ip;
+  struct udphdr udp;
+  u_char seq; /* sequence number of this packet */
+  u_char ttl; /* ttl packet left with */
+  struct timeval tv; /* time packet left */
 };
 
 u_char packet[512]; /* last inbound (icmp) packet */
@@ -134,275 +134,275 @@ int waittime = 1; /* time to wait for response (in seconds) */
 int nflag; /* print addresses numerically */
 
 void find_route(u_int32_t destIP, u_int32_t IPlist[], int max_ttl) {
-	extern char *optarg;
-	extern int optind;
-	struct protoent *pe;
-	struct sockaddr_in from, *to;
-	int i, on, probe, seq, tos, ttl;
-
-	on = 1;
-	seq = tos = 0;
-	to = (struct sockaddr_in *) &whereto;
-	(void) bzero((char *) &whereto, sizeof(struct sockaddr));
-	to->sin_family = AF_INET;
-	to->sin_addr.s_addr = destIP;
-
-	datalen += sizeof(struct opacket);
-	outpacket = (struct opacket *) malloc((unsigned) datalen);
-	if (!outpacket) {
-		perror("traceroute: malloc");
-		exit(1);
-	}
-	(void) bzero((char *) outpacket, datalen);
-	outpacket->ip.ip_dst = to->sin_addr;
-	outpacket->ip.ip_tos = tos;
-	outpacket->ip.ip_v = IPVERSION;
-	outpacket->ip.ip_id = 0;
-
-	ident = (getpid() & 0xffff) | 0x8000;
-
-	if ((pe = getprotobyname("icmp")) == NULL) {
-		fprintf(stderr, "icmp: unknown protocol\n");
-		exit(10);
-	}
-	if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0) {
-		perror("traceroute: icmp socket");
-		exit(5);
-	}
-
-	if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
-		perror("traceroute: raw socket");
-		exit(5);
-	}
-
-	if (source) {
-		(void) bzero((char *) &from, sizeof(struct sockaddr));
-		from.sin_family = AF_INET;
-		from.sin_addr.s_addr = inet_addr(source);
-		if (from.sin_addr.s_addr == -1) {
-			printf("traceroute: unknown host %s\n", source);
-			exit(1);
-		}
-		outpacket->ip.ip_src = from.sin_addr;
+  extern char *optarg;
+  extern int optind;
+  struct protoent *pe;
+  struct sockaddr_in from, *to;
+  int i, on, probe, seq, tos, ttl;
+
+  on = 1;
+  seq = tos = 0;
+  to = (struct sockaddr_in *) &whereto;
+  (void) bzero((char *) &whereto, sizeof(struct sockaddr));
+  to->sin_family = AF_INET;
+  to->sin_addr.s_addr = destIP;
+
+  datalen += sizeof(struct opacket);
+  outpacket = (struct opacket *) malloc((unsigned) datalen);
+  if (!outpacket) {
+    perror("traceroute: malloc");
+    exit(1);
+  }
+  (void) bzero((char *) outpacket, datalen);
+  outpacket->ip.ip_dst = to->sin_addr;
+  outpacket->ip.ip_tos = tos;
+  outpacket->ip.ip_v = IPVERSION;
+  outpacket->ip.ip_id = 0;
+
+  ident = (getpid() & 0xffff) | 0x8000;
+
+  if ((pe = getprotobyname("icmp")) == NULL) {
+    fprintf(stderr, "icmp: unknown protocol\n");
+    exit(10);
+  }
+  if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0) {
+    perror("traceroute: icmp socket");
+    exit(5);
+  }
+
+  if ((sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
+    perror("traceroute: raw socket");
+    exit(5);
+  }
+
+  if (source) {
+    (void) bzero((char *) &from, sizeof(struct sockaddr));
+    from.sin_family = AF_INET;
+    from.sin_addr.s_addr = inet_addr(source);
+    if (from.sin_addr.s_addr == -1) {
+      printf("traceroute: unknown host %s\n", source);
+      exit(1);
+    }
+    outpacket->ip.ip_src = from.sin_addr;
 #ifndef IP_HDRINCL
-		if (bind(sndsock, (struct sockaddr *) &from, sizeof(from)) < 0) {
-			perror("traceroute: bind:");
-			exit(1);
-		}
+    if (bind(sndsock, (struct sockaddr *) &from, sizeof(from)) < 0) {
+      perror("traceroute: bind:");
+      exit(1);
+    }
 #endif /* IP_HDRINCL */
-	}
-
-	for (ttl = 1; ttl <= max_ttl; ++ttl) {
-		u_long lastaddr = 0;
-		int got_there = 0;
-		int unreachable = 0;
-
-		for (probe = 0; probe < nprobes; ++probe) {
-			int cc;
-			struct timeval t1, t2;
-			struct timezone tz;
-			struct ip *ip;
-
-			(void) gettimeofday(&t1, &tz);
-			send_probe(++seq, ttl);
-			while ((cc = wait_for_reply(s, &from))) {
-				(void) gettimeofday(&t2, &tz);
-				if ((i = packet_ok(packet, cc, &from, seq))) {
-					if (from.sin_addr.s_addr != lastaddr) {
-						IPlist[ttl - 1] = from.sin_addr.s_addr;
-						lastaddr = from.sin_addr.s_addr;
-					}
-					log_println(5, "Probe %d resulted in reply from [%s]",
-							probe, inet_ntoa(from.sin_addr));
-
-					switch (i - 1) {
-					case ICMP_UNREACH_PORT:
+  }
+
+  for (ttl = 1; ttl <= max_ttl; ++ttl) {
+    u_long lastaddr = 0;
+    int got_there = 0;
+    int unreachable = 0;
+
+    for (probe = 0; probe < nprobes; ++probe) {
+      int cc;
+      struct timeval t1, t2;
+      struct timezone tz;
+      struct ip *ip;
+
+      (void) gettimeofday(&t1, &tz);
+      send_probe(++seq, ttl);
+      while ((cc = wait_for_reply(s, &from))) {
+        (void) gettimeofday(&t2, &tz);
+        if ((i = packet_ok(packet, cc, &from, seq))) {
+          if (from.sin_addr.s_addr != lastaddr) {
+            IPlist[ttl - 1] = from.sin_addr.s_addr;
+            lastaddr = from.sin_addr.s_addr;
+          }
+          log_println(5, "Probe %d resulted in reply from [%s]",
+                      probe, inet_ntoa(from.sin_addr));
+
+          switch (i - 1) {
+            case ICMP_UNREACH_PORT:
 #ifndef ARCHAIC
-						ip = (struct ip *) packet;
+              ip = (struct ip *) packet;
 #endif /* ARCHAIC */
-						++got_there;
-						break;
-					case ICMP_UNREACH_NET:
-						++unreachable;
-						break;
-					case ICMP_UNREACH_HOST:
-						++unreachable;
-						break;
-					case ICMP_UNREACH_PROTOCOL:
-						++got_there;
-						break;
-					case ICMP_UNREACH_NEEDFRAG:
-						++unreachable;
-						break;
-					case ICMP_UNREACH_SRCFAIL:
-						++unreachable;
-						break;
-					}
-					break;
-				}
-			}
-		}
-		if (got_there || unreachable >= nprobes - 1) {
-			return;
-		}
-	}
+              ++got_there;
+              break;
+            case ICMP_UNREACH_NET:
+              ++unreachable;
+              break;
+            case ICMP_UNREACH_HOST:
+              ++unreachable;
+              break;
+            case ICMP_UNREACH_PROTOCOL:
+              ++got_there;
+              break;
+            case ICMP_UNREACH_NEEDFRAG:
+              ++unreachable;
+              break;
+            case ICMP_UNREACH_SRCFAIL:
+              ++unreachable;
+              break;
+          }
+          break;
+        }
+      }
+    }
+    if (got_there || unreachable >= nprobes - 1) {
+      return;
+    }
+  }
 }
 
 int wait_for_reply(sock, from)
-	int sock;struct sockaddr_in *from; {
-	fd_set fds;
-	struct timeval wait;
-	int cc = 0;
-	socklen_t fromlen = sizeof(*from);
-
-	FD_ZERO(&fds);
-	FD_SET(sock, &fds);
-	wait.tv_sec = waittime;
-	wait.tv_usec = 0;
-
-	if (select(sock + 1, &fds, (fd_set *) 0, (fd_set *) 0, &wait) > 0)
-		cc = recvfrom(s, (char *) packet, sizeof(packet), 0,
-				(struct sockaddr *) from, &fromlen);
-
-	return (cc);
-}
+  int sock;struct sockaddr_in *from; {
+    fd_set fds;
+    struct timeval wait;
+    int cc = 0;
+    socklen_t fromlen = sizeof(*from);
+
+    FD_ZERO(&fds);
+    FD_SET(sock, &fds);
+    wait.tv_sec = waittime;
+    wait.tv_usec = 0;
+
+    if (select(sock + 1, &fds, (fd_set *) 0, (fd_set *) 0, &wait) > 0)
+      cc = recvfrom(s, (char *) packet, sizeof(packet), 0,
+                    (struct sockaddr *) from, &fromlen);
+
+    return (cc);
+  }
 
 void send_probe(seq, ttl)
-	int seq, ttl; {
-	struct opacket *op = outpacket;
-	struct ip *ip = &op->ip;
-	struct udphdr *up = &op->udp;
-	int i;
-
-	ip->ip_off = 0;
-	ip->ip_hl = sizeof(*ip) >> 2;
-	ip->ip_p = IPPROTO_UDP;
-	ip->ip_len = datalen;
-	ip->ip_ttl = ttl;
-	ip->ip_v = IPVERSION;
-	ip->ip_id = htons(ident + seq);
+  int seq, ttl; {
+    struct opacket *op = outpacket;
+    struct ip *ip = &op->ip;
+    struct udphdr *up = &op->udp;
+    int i;
+
+    ip->ip_off = 0;
+    ip->ip_hl = sizeof(*ip) >> 2;
+    ip->ip_p = IPPROTO_UDP;
+    ip->ip_len = datalen;
+    ip->ip_ttl = ttl;
+    ip->ip_v = IPVERSION;
+    ip->ip_id = htons(ident + seq);
 
 #ifdef __FAVOR_BSD
-	up->uh_sport = htons(ident);
-	up->uh_dport = htons(port+seq);
-	up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
-	up->uh_sum = 0;
+    up->uh_sport = htons(ident);
+    up->uh_dport = htons(port+seq);
+    up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
+    up->uh_sum = 0;
 #else
-	up->source = htons(ident);
-	up->dest = htons(port + seq);
-	up->len = htons((u_short)(datalen - sizeof(struct ip)));
-	up->check = 0;
+    up->source = htons(ident);
+    up->dest = htons(port + seq);
+    up->len = htons((u_short)(datalen - sizeof(struct ip)));
+    up->check = 0;
 #endif
 
-	op->seq = seq;
-	op->ttl = ttl;
-	(void) gettimeofday(&op->tv, &tz);
+    op->seq = seq;
+    op->ttl = ttl;
+    (void) gettimeofday(&op->tv, &tz);
 
-	i = sendto(sndsock, (char *) outpacket, datalen, 0, &whereto,
-			sizeof(struct sockaddr));
-	if (i < 0 || i != datalen) {
-		if (i < 0)
-			perror("sendto");
-	}
-}
+    i = sendto(sndsock, (char *) outpacket, datalen, 0, &whereto,
+               sizeof(struct sockaddr));
+    if (i < 0 || i != datalen) {
+      if (i < 0)
+        perror("sendto");
+    }
+  }
 
 double deltaT(t1p, t2p)
-	struct timeval *t1p, *t2p; {
-	register double dt;
+  struct timeval *t1p, *t2p; {
+    register double dt;
 
-	dt = (double) (t2p->tv_sec - t1p->tv_sec) * 1000.0
-			+ (double) (t2p->tv_usec - t1p->tv_usec) / 1000.0;
-	return (dt);
-}
+    dt = (double) (t2p->tv_sec - t1p->tv_sec) * 1000.0
+        + (double) (t2p->tv_usec - t1p->tv_usec) / 1000.0;
+    return (dt);
+  }
 
 int packet_ok(buf, cc, from, seq)
-	u_char *buf;int cc;struct sockaddr_in *from;int seq; {
-	register struct icmp *icp;
-	u_char type, code;
-	int hlen;
+  u_char *buf;int cc;struct sockaddr_in *from;int seq; {
+    register struct icmp *icp;
+    u_char type, code;
+    int hlen;
 #ifndef ARCHAIC
-	struct ip *ip;
-
-	ip = (struct ip *) buf;
-	hlen = ip->ip_hl << 2;
-	if (cc < hlen + ICMP_MINLEN) {
-		return (0);
-	}
-	cc -= hlen;
-	icp =
-			(struct icmp *) (buf + hlen);
+    struct ip *ip;
+
+    ip = (struct ip *) buf;
+    hlen = ip->ip_hl << 2;
+    if (cc < hlen + ICMP_MINLEN) {
+      return (0);
+    }
+    cc -= hlen;
+    icp =
+        (struct icmp *) (buf + hlen);
 #else
-			icp = (struct icmp *)buf;
+    icp = (struct icmp *)buf;
 #endif /* ARCHAIC */
-			type = icp->icmp_type; code = icp->icmp_code;
-			if ((type == ICMP_TIMXCEED && code == ICMP_TIMXCEED_INTRANS) ||
-					type == ICMP_UNREACH) {
-				struct ip *hip;
-				struct udphdr *up;
-
-				hip = &icp->icmp_ip;
-				hlen = hip->ip_hl << 2;
-				up = (struct udphdr *)((u_char *)hip + hlen);
-				if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
+    type = icp->icmp_type; code = icp->icmp_code;
+    if ((type == ICMP_TIMXCEED && code == ICMP_TIMXCEED_INTRANS) ||
+        type == ICMP_UNREACH) {
+      struct ip *hip;
+      struct udphdr *up;
+
+      hip = &icp->icmp_ip;
+      hlen = hip->ip_hl << 2;
+      up = (struct udphdr *)((u_char *)hip + hlen);
+      if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
 #ifdef __FAVOR_BSD
-			up->uh_sport == htons(ident) &&
-			up->uh_dport == htons(port+seq))
+          up->uh_sport == htons(ident) &&
+          up->uh_dport == htons(port+seq))
 #else
-			up->source == htons(ident) &&
-			up->dest == htons(port+seq))
+        up->source == htons(ident) &&
+            up->dest == htons(port+seq))
 #endif
-			return (type == ICMP_TIMXCEED? -1 : code+1);
-		}
-		return(0)
-;}
+            return (type == ICMP_TIMXCEED? -1 : code+1);
+    }
+    return(0)
+        ;}
 #ifdef notyet
-	/*
-	 * Checksum routine for Internet Protocol family headers (C Version)
-	 */
-	u_short
-	in_cksum(addr, len)
-	u_short *addr;
-	int len;
-	{
-		register int nleft = len;
-		register u_short *w = addr;
-		register u_short answer;
-		register int sum = 0;
-
-		/*
-		 *  Our algorithm is simple, using a 32 bit accumulator (sum),
-		 *  we add sequential 16 bit words to it, and at the end, fold
-		 *  back all the carry bits from the top 16 bits into the lower
-		 *  16 bits.
-		 */
-		while (nleft > 1) {
-			sum += *w++;
-			nleft -= 2;
-		}
-
-		/* mop up an odd byte, if necessary */
-		if (nleft == 1)
-		sum += *(u_char *)w;
-
-		/*
-		 * add back carry outs from top 16 bits to low 16 bits
-		 */
-		sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
-		sum += (sum >> 16); /* add carry */
-		answer = ~sum; /* truncate to 16 bits */
-		return (answer);
-	}
+        /*
+         * Checksum routine for Internet Protocol family headers (C Version)
+         */
+  u_short
+in_cksum(addr, len)
+  u_short *addr;
+  int len;
+{
+  register int nleft = len;
+  register u_short *w = addr;
+  register u_short answer;
+  register int sum = 0;
+
+  /*
+   *  Our algorithm is simple, using a 32 bit accumulator (sum),
+   *  we add sequential 16 bit words to it, and at the end, fold
+   *  back all the carry bits from the top 16 bits into the lower
+   *  16 bits.
+   */
+  while (nleft > 1) {
+    sum += *w++;
+    nleft -= 2;
+  }
+
+  /* mop up an odd byte, if necessary */
+  if (nleft == 1)
+    sum += *(u_char *)w;
+
+  /*
+   * add back carry outs from top 16 bits to low 16 bits
+   */
+  sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
+  sum += (sum >> 16); /* add carry */
+  answer = ~sum; /* truncate to 16 bits */
+  return (answer);
+}
 #endif /* notyet */
 
-	/*
-	 * Subtract 2 timeval structs:  out = out - in.
-	 * Out is assumed to be >= in.
-	 */
+/*
+ * Subtract 2 timeval structs:  out = out - in.
+ * Out is assumed to be >= in.
+ */
 void tvsub (out, in)
-	register struct timeval *out, *in; {
-	if ((out->tv_usec -= in->tv_usec) < 0) {
-		out->tv_sec--;
-		out->tv_usec += 1000000;
-	}
-	out->tv_sec -= in->tv_sec;
-}
+  register struct timeval *out, *in; {
+    if ((out->tv_usec -= in->tv_usec) < 0) {
+      out->tv_sec--;
+      out->tv_usec += 1000000;
+    }
+    out->tv_sec -= in->tv_sec;
+  }
diff --git a/src/troute6.c b/src/troute6.c
index 8f9bea8..4098851 100644
--- a/src/troute6.c
+++ b/src/troute6.c
@@ -69,7 +69,7 @@
 #ifndef lint
 char copyright[] =
 "@(#) Copyright (c) 1990, 1993\n\
-  The Regents of the University of California.  All rights reserved.\n";
+        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 #endif
 
@@ -144,105 +144,105 @@ char copyright[] =
  * either don't send ICMP "time exceeded" messages or send them
  * with a ttl too small to reach us.  14 - 17 are running the
  * MIT C Gateway code that doesn't send "time exceeded"s.  God
- * only knows what's going on with 12.
- *
- * The silent gateway 12 in the above may be the result of a bug in
- * the 4.[23]BSD network code (and its derivatives):  4.x (x <= 3)
- * sends an unreachable message using whatever ttl remains in the
- * original datagram.  Since, for gateways, the remaining ttl is
- * zero, the icmp "time exceeded" is guaranteed to not make it back
- * to us.  The behavior of this bug is slightly more interesting
- * when it appears on the destination system:
- *
- *      1  helios.ee.lbl.gov (128.3.112.1)  0 ms  0 ms  0 ms
- *      2  lilac-dmc.Berkeley.EDU (128.32.216.1)  39 ms  19 ms  39 ms
- *      3  lilac-dmc.Berkeley.EDU (128.32.216.1)  19 ms  39 ms  19 ms
- *      4  ccngw-ner-cc.Berkeley.EDU (128.32.136.23)  39 ms  40 ms  19 ms
- *      5  ccn-nerif35.Berkeley.EDU (128.32.168.35)  39 ms  39 ms  39 ms
- *      6  csgw.Berkeley.EDU (128.32.133.254)  39 ms  59 ms  39 ms
- *      7  * * *
- *      8  * * *
- *      9  * * *
- *     10  * * *
- *     11  * * *
- *     12  * * *
- *     13  rip.Berkeley.EDU (128.32.131.22)  59 ms !  39 ms !  39 ms !
- *
- * Notice that there are 12 "gateways" (13 is the final
- * destination) and exactly the last half of them are "missing".
- * What's really happening is that rip (a Sun-3 running Sun OS3.5)
- * is using the ttl from our arriving datagram as the ttl in its
- * icmp reply.  So, the reply will time out on the return path
- * (with no notice sent to anyone since icmp's aren't sent for
- * icmp's) until we probe with a ttl that's at least twice the path
- * length.  I.e., rip is really only 7 hops away.  A reply that
- * returns with a ttl of 1 is a clue this problem exists.
- * Traceroute prints a "!" after the time if the ttl is <= 1.
- * Since vendors ship a lot of obsolete (DEC's Ultrix, Sun 3.x) or
- * non-standard (HPUX) software, expect to see this problem
- * frequently and/or take care picking the target host of your
- * probes.
- *
- * Other possible annotations after the time are !H, !N, !P (got a host,
- * network or protocol unreachable, respectively), !S or !F (source
- * route failed or fragmentation needed -- neither of these should
- * ever occur and the associated gateway is busted if you see one).  If
- * almost all the probes result in some kind of unreachable, traceroute
- * will give up and exit.
- *
- * Notes
- * -----
- * This program must be run by root or be setuid.  (I suggest that
- * you *don't* make it setuid -- casual use could result in a lot
- * of unnecessary traffic on our poor, congested nets.)
- *
- * This program requires a kernel mod that does not appear in any
- * system available from Berkeley:  A raw ip socket using proto
- * IPPROTO_RAW must interpret the data sent as an ip datagram (as
- * opposed to data to be wrapped in a ip datagram).  See the README
- * file that came with the source to this program for a description
- * of the mods I made to /sys/netinet/raw_ip.c.  Your mileage may
- * vary.  But, again, ANY 4.x (x < 4) BSD KERNEL WILL HAVE TO BE
- * MODIFIED TO RUN THIS PROGRAM.
- *
- * The udp port usage may appear bizarre (well, ok, it is bizarre).
- * The problem is that an icmp message only contains 8 bytes of
- * data from the original datagram.  8 bytes is the size of a udp
- * header so, if we want to associate replies with the original
- * datagram, the necessary information must be encoded into the
- * udp header (the ip id could be used but there's no way to
- * interlock with the kernel's assignment of ip id's and, anyway,
- * it would have taken a lot more kernel hacking to allow this
- * code to set the ip id).  So, to allow two or more users to
- * use traceroute simultaneously, we use this task's pid as the
- * source port (the high bit is set to move the port number out
- * of the "likely" range).  To keep track of which probe is being
- * replied to (so times and/or hop counts don't get confused by a
- * reply that was delayed in transit), we increment the destination
- * port number before each probe.
- *
- * Don't use this as a coding example.  I was trying to find a
- * routing problem and this code sort-of popped out after 48 hours
- * without sleep.  I was amazed it ever compiled, much less ran.
- *
- * I stole the idea for this program from Steve Deering.  Since
- * the first release, I've learned that had I attended the right
- * IETF working group meetings, I also could have stolen it from Guy
- * Almes or Matt Mathis.  I don't know (or care) who came up with
- * the idea first.  I envy the originators' perspicacity and I'm
- * glad they didn't keep the idea a secret.
- *
- * Tim Seaver, Ken Adelman and C. Philip Wood provided bug fixes and/or
- * enhancements to the original distribution.
- *
- * I've hacked up a round-trip-route version of this that works by
- * sending a loose-source-routed udp datagram through the destination
- * back to yourself.  Unfortunately, SO many gateways botch source
- * routing, the thing is almost worthless.  Maybe one day...
- *
- *  -- Van Jacobson (van@helios.ee.lbl.gov)
- *     Tue Dec 20 03:50:13 PST 1988
- */
+* only knows what's going on with 12.
+*
+  * The silent gateway 12 in the above may be the result of a bug in
+* the 4.[23]BSD network code (and its derivatives):  4.x (x <= 3)
+                                                     * sends an unreachable message using whatever ttl remains in the
+                                                     * original datagram.  Since, for gateways, the remaining ttl is
+                                                     * zero, the icmp "time exceeded" is guaranteed to not make it back
+                                                     * to us.  The behavior of this bug is slightly more interesting
+                                                     * when it appears on the destination system:
+                                                     *
+                                                     *      1  helios.ee.lbl.gov (128.3.112.1)  0 ms  0 ms  0 ms
+                                                     *      2  lilac-dmc.Berkeley.EDU (128.32.216.1)  39 ms  19 ms  39 ms
+                                                     *      3  lilac-dmc.Berkeley.EDU (128.32.216.1)  19 ms  39 ms  19 ms
+                                                     *      4  ccngw-ner-cc.Berkeley.EDU (128.32.136.23)  39 ms  40 ms  19 ms
+                                                     *      5  ccn-nerif35.Berkeley.EDU (128.32.168.35)  39 ms  39 ms  39 ms
+                                                     *      6  csgw.Berkeley.EDU (128.32.133.254)  39 ms  59 ms  39 ms
+                                                     *      7  * * *
+                                                     *      8  * * *
+                                                     *      9  * * *
+                                                     *     10  * * *
+                                                     *     11  * * *
+                                                     *     12  * * *
+                                                     *     13  rip.Berkeley.EDU (128.32.131.22)  59 ms !  39 ms !  39 ms !
+                                                     *
+                                                     * Notice that there are 12 "gateways" (13 is the final
+                                                                                            * destination) and exactly the last half of them are "missing".
+                                                     * What's really happening is that rip (a Sun-3 running Sun OS3.5)
+                                                     * is using the ttl from our arriving datagram as the ttl in its
+                                                     * icmp reply.  So, the reply will time out on the return path
+                                                     * (with no notice sent to anyone since icmp's aren't sent for
+                                                        * icmp's) until we probe with a ttl that's at least twice the path
+                                                     * length.  I.e., rip is really only 7 hops away.  A reply that
+                                                     * returns with a ttl of 1 is a clue this problem exists.
+                                                     * Traceroute prints a "!" after the time if the ttl is <= 1.
+                                                     * Since vendors ship a lot of obsolete (DEC's Ultrix, Sun 3.x) or
+                                                     * non-standard (HPUX) software, expect to see this problem
+                                                     * frequently and/or take care picking the target host of your
+                                                     * probes.
+                                                     *
+                                                     * Other possible annotations after the time are !H, !N, !P (got a host,
+                                                                                                                 * network or protocol unreachable, respectively), !S or !F (source
+                                                                                                                                                                             * route failed or fragmentation needed -- neither of these should
+                                                                                                                                                                             * ever occur and the associated gateway is busted if you see one).  If
+                                                     * almost all the probes result in some kind of unreachable, traceroute
+                                                     * will give up and exit.
+                                                     *
+                                                     * Notes
+                                                     * -----
+                                                     * This program must be run by root or be setuid.  (I suggest that
+                                                                                                        * you *don't* make it setuid -- casual use could result in a lot
+                                                                                                        * of unnecessary traffic on our poor, congested nets.)
+                                                     *
+                                                     * This program requires a kernel mod that does not appear in any
+                                                     * system available from Berkeley:  A raw ip socket using proto
+                                                     * IPPROTO_RAW must interpret the data sent as an ip datagram (as
+                                                                                                                   * opposed to data to be wrapped in a ip datagram).  See the README
+                                                     * file that came with the source to this program for a description
+                                                     * of the mods I made to /sys/netinet/raw_ip.c.  Your mileage may
+                                                     * vary.  But, again, ANY 4.x (x < 4) BSD KERNEL WILL HAVE TO BE
+                                                     * MODIFIED TO RUN THIS PROGRAM.
+                                                     *
+                                                     * The udp port usage may appear bizarre (well, ok, it is bizarre).
+                                                     * The problem is that an icmp message only contains 8 bytes of
+                                                     * data from the original datagram.  8 bytes is the size of a udp
+                                                     * header so, if we want to associate replies with the original
+                                                     * datagram, the necessary information must be encoded into the
+                                                     * udp header (the ip id could be used but there's no way to
+                                                                   * interlock with the kernel's assignment of ip id's and, anyway,
+                                                                   * it would have taken a lot more kernel hacking to allow this
+                                                                   * code to set the ip id).  So, to allow two or more users to
+                                                     * use traceroute simultaneously, we use this task's pid as the
+                                                     * source port (the high bit is set to move the port number out
+                                                                    * of the "likely" range).  To keep track of which probe is being
+                                                     * replied to (so times and/or hop counts don't get confused by a
+                                                                   * reply that was delayed in transit), we increment the destination
+                                                     * port number before each probe.
+                                                     *
+                                                     * Don't use this as a coding example.  I was trying to find a
+                                                     * routing problem and this code sort-of popped out after 48 hours
+                                                     * without sleep.  I was amazed it ever compiled, much less ran.
+                                                     *
+                                                     * I stole the idea for this program from Steve Deering.  Since
+                                                     * the first release, I've learned that had I attended the right
+                                                     * IETF working group meetings, I also could have stolen it from Guy
+                                                     * Almes or Matt Mathis.  I don't know (or care) who came up with
+                                                     * the idea first.  I envy the originators' perspicacity and I'm
+                                                     * glad they didn't keep the idea a secret.
+                                                     *
+                                                     * Tim Seaver, Ken Adelman and C. Philip Wood provided bug fixes and/or
+                                                     * enhancements to the original distribution.
+                                                     *
+                                                     * I've hacked up a round-trip-route version of this that works by
+                                                     * sending a loose-source-routed udp datagram through the destination
+                                                     * back to yourself.  Unfortunately, SO many gateways botch source
+                                                     * routing, the thing is almost worthless.  Maybe one day...
+  *
+   *  -- Van Jacobson (van@helios.ee.lbl.gov)
+                                             *     Tue Dec 20 03:50:13 PST 1988
+                                                     */
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -292,34 +292,34 @@ char copyright[] =
 #define Fprintf (void)fprintf
 #define Printf (void)printf
 
-/* taken from linux/ipv6.h */
+                                                     /* taken from linux/ipv6.h */
 
-/*
- *  IPv6 fixed header
- *
- *  BEWARE, it is incorrect. The first 4 bits of flow_lbl
- *  are glued to priority now, forming "class".
- */
+                                                     /*
+                                                      *  IPv6 fixed header
+                                                      *
+                                                      *  BEWARE, it is incorrect. The first 4 bits of flow_lbl
+                                                      *  are glued to priority now, forming "class".
+                                                      */
 
-struct ipv6hdr {
+                                                     struct ipv6hdr {
 #if defined(__LITTLE_ENDIAN_BITFIELD)
-__extension__	__u8 priority:4,
-	version:4;
+                                                       __extension__	__u8 priority:4,
+                                                                        version:4;
 #elif defined(__BIG_ENDIAN_BITFIELD)
-__extension__	__u8 version:4,
-	priority:4;
+                                                       __extension__	__u8 version:4,
+                                                                        priority:4;
 #else
 #error  "Please fix <asm/byteorder.h>"
 #endif
-__extension__	__u8 flow_lbl[3];
+                                                       __extension__	__u8 flow_lbl[3];
 
-__extension__	__u16 payload_len;
-__extension__	__u8 nexthdr;
-__extension__	__u8 hop_limit;
+                                                       __extension__	__u16 payload_len;
+                                                       __extension__	__u8 nexthdr;
+                                                       __extension__	__u8 hop_limit;
 
-	struct in6_addr saddr;
-	struct in6_addr daddr;
-};
+                                                       struct in6_addr saddr;
+                                                       struct in6_addr daddr;
+                                                     };
 
 /* --- */
 
@@ -327,7 +327,7 @@ u_char packet[512]; /* last inbound (icmp) packet */
 
 int wait_for_reply6(int, struct sockaddr_in6 *, int);
 int packet_ok6(u_char *buf, int cc, struct sockaddr_in6 *from, int seq,
-		struct timeval *);
+               struct timeval *);
 void send_probe6(int seq, int ttl);
 double deltaT (struct timeval *, struct timeval *);
 void tvsub (struct timeval *, struct timeval *);
@@ -355,267 +355,267 @@ int nflag; /* print addresses numerically */
 
 struct pkt_format
 {
-	__u32 ident;
-	__u32 seq;
-	struct timeval tv;
+  __u32 ident;
+  __u32 seq;
+  struct timeval tv;
 };
 
 char *sendbuff;
 int datalen = sizeof(struct pkt_format);
 
-void
+  void
 find_route6(char* dst, u_int32_t IPlist[][4], int max_ttl)
 {
-	extern char *optarg;
-	extern int optind;
-	struct hostent *hp;
-	struct sockaddr_in6 from, *to;
-	int i, on, probe, seq, tos, ttl;
-	int socket_errno;
-
-	icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
-	socket_errno = errno;
-
-	setuid(getuid());
-
-	on = 1;
-	seq = tos = 0;
-	to = (struct sockaddr_in6 *)&whereto;
-	(void) bzero((char *)&whereto, sizeof(whereto));
-
-	to->sin6_family = AF_INET6;
-	to->sin6_port = htons(port6);
-
-	if (inet_pton(AF_INET6, dst, &to->sin6_addr) > 0) {
-		hostname = dst;
-	} else {
-		hp = gethostbyname2(dst, AF_INET6);
-		if (hp) {
-			memmove((caddr_t)&to->sin6_addr, hp->h_addr, sizeof(to->sin6_addr));
-			hostname = (char *)hp->h_name;
-		} else {
-			(void)fprintf(stderr,
-					"traceroute: unknown host %s\n", dst);
-			return;
-		}
-	}
-	firsthop = *to;
-
-	ident = (getpid() & 0xffff) | 0x8000;
-
-	sendbuff = malloc(datalen);
-	if (sendbuff == NULL) {
-		fprintf(stderr, "malloc failed\n");
-		return;
-	}
-
-	if (icmp_sock < 0) {
-		errno = socket_errno;
-		perror("traceroute6: icmp socket");
-		return;
-	}
-
-	if (options & SO_DEBUG)
-	setsockopt(icmp_sock, SOL_SOCKET, SO_DEBUG,
-			(char *)&on, sizeof(on));
-	if (options & SO_DONTROUTE)
-	setsockopt(icmp_sock, SOL_SOCKET, SO_DONTROUTE,
-			(char *)&on, sizeof(on));
-	on = 2;
-	if (setsockopt(icmp_sock, SOL_RAW, IPV6_CHECKSUM, &on, sizeof(on)) < 0) {
-		perror("setsockopt(RAW_CHECKSUM)");
-		return;
-	}
-
-	if ((sndsock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
-		perror("traceroute: UDP socket");
-		return;
-	}
+  extern char *optarg;
+  extern int optind;
+  struct hostent *hp;
+  struct sockaddr_in6 from, *to;
+  int i, on, probe, seq, tos, ttl;
+  int socket_errno;
+
+  icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
+  socket_errno = errno;
+
+  setuid(getuid());
+
+  on = 1;
+  seq = tos = 0;
+  to = (struct sockaddr_in6 *)&whereto;
+  (void) bzero((char *)&whereto, sizeof(whereto));
+
+  to->sin6_family = AF_INET6;
+  to->sin6_port = htons(port6);
+
+  if (inet_pton(AF_INET6, dst, &to->sin6_addr) > 0) {
+    hostname = dst;
+  } else {
+    hp = gethostbyname2(dst, AF_INET6);
+    if (hp) {
+      memmove((caddr_t)&to->sin6_addr, hp->h_addr, sizeof(to->sin6_addr));
+      hostname = (char *)hp->h_name;
+    } else {
+      (void)fprintf(stderr,
+                    "traceroute: unknown host %s\n", dst);
+      return;
+    }
+  }
+  firsthop = *to;
+
+  ident = (getpid() & 0xffff) | 0x8000;
+
+  sendbuff = malloc(datalen);
+  if (sendbuff == NULL) {
+    fprintf(stderr, "malloc failed\n");
+    return;
+  }
+
+  if (icmp_sock < 0) {
+    errno = socket_errno;
+    perror("traceroute6: icmp socket");
+    return;
+  }
+
+  if (options & SO_DEBUG)
+    setsockopt(icmp_sock, SOL_SOCKET, SO_DEBUG,
+               (char *)&on, sizeof(on));
+  if (options & SO_DONTROUTE)
+    setsockopt(icmp_sock, SOL_SOCKET, SO_DONTROUTE,
+               (char *)&on, sizeof(on));
+  on = 2;
+  if (setsockopt(icmp_sock, SOL_RAW, IPV6_CHECKSUM, &on, sizeof(on)) < 0) {
+    perror("setsockopt(RAW_CHECKSUM)");
+    return;
+  }
+
+  if ((sndsock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+    perror("traceroute: UDP socket");
+    return;
+  }
 #ifdef SO_SNDBUF
-	if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
-					sizeof(datalen)) < 0) {
-		perror("traceroute: SO_SNDBUF");
-		return;
-	}
+  if (setsockopt(sndsock, SOL_SOCKET, SO_SNDBUF, (char *)&datalen,
+                 sizeof(datalen)) < 0) {
+    perror("traceroute: SO_SNDBUF");
+    return;
+  }
 #endif /* SO_SNDBUF */
 
-	if (options & SO_DEBUG)
-	(void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
-			(char *)&on, sizeof(on));
-	if (options & SO_DONTROUTE)
-	(void) setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE,
-			(char *)&on, sizeof(on));
-
-	if (source6 == NULL) {
-		socklen_t alen;
-		int probe_fd = socket(AF_INET6, SOCK_DGRAM, 0);
-
-		if (probe_fd < 0) {
-			perror("socket");
-			return;
-		}
-		if (device) {
-			if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)+1) == -1)
-			perror("WARNING: interface is ignored");
-		}
-		firsthop.sin6_port = htons(1025);
-		if (connect(probe_fd, (struct sockaddr*)&firsthop, sizeof(firsthop)) == -1) {
-			perror("connect");
-			return;
-		}
-		alen = sizeof(saddr);
-		if (getsockname(probe_fd, (struct sockaddr*)&saddr, &alen) == -1) {
-			perror("getsockname");
-			return;
-		}
-		saddr.sin6_port = 0;
-		close(probe_fd);
-	} else {
-		(void) bzero((char *)&saddr, sizeof(saddr));
-		saddr.sin6_family = AF_INET6;
-		if (inet_pton(AF_INET6, source6, &saddr.sin6_addr) < 0)
-		{
-			Printf("traceroute: unknown addr %s\n", source6);
-			return;
-		}
-	}
-
-	if (bind(sndsock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
-		perror ("traceroute: bind sending socket");
-		return;
-	}
-	if (bind(icmp_sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
-		perror ("traceroute: bind icmp6 socket");
-		return;
-	}
-
-	for (ttl = 1; ttl <= max_ttl; ++ttl) {
-		struct in6_addr lastaddr = { { {0,}}};
-		int got_there = 0;
-		int unreachable = 0;
-
-		/* Printf("%2d ", ttl); */
-		for (probe = 0; probe < nprobes6; ++probe) {
-			int cc, reset_timer;
-			struct timeval t1, t2;
-			struct timezone tz;
-
-			gettimeofday(&t1, &tz);
-			send_probe6(++seq, ttl);
-			reset_timer = 1;
-
-			while ((cc = wait_for_reply6(icmp_sock, &from, reset_timer)) != 0) {
-				gettimeofday(&t2, &tz);
-				if (cc > 0 && (i = packet_ok6(packet, cc, &from, seq, &t1))) {
-					reset_timer = 1;
-					if (memcmp(&from.sin6_addr, &lastaddr, sizeof(from.sin6_addr))) {
-						memcpy(IPlist[ttl-1],
-								&from.sin6_addr,
-								sizeof(IPlist[ttl-1]));
-						memcpy(&lastaddr,
-								&from.sin6_addr,
-								sizeof(lastaddr));
-					}
-					if (get_debuglvl() > 4) {
-						char tmp[MAXHOSTNAMELEN];
-						inet_ntop(AF_INET6, &from.sin6_addr, tmp, sizeof(tmp));
-						log_println(5, "Probe %d resulted in reply from [%s]", probe, tmp);
-					}
-					switch(i - 1) {
-						case ICMPV6_PORT_UNREACH:
-						++got_there;
-						break;
-
-						case ICMPV6_NOROUTE:
-						++unreachable;
-						Printf(" !N");
-						break;
-						case ICMPV6_ADDR_UNREACH:
-						++unreachable;
-						Printf(" !H");
-						break;
-
-						case ICMPV6_ADM_PROHIBITED:
-						++unreachable;
-						Printf(" !S");
-						break;
-					}
-					break;
-				} else
-				reset_timer = 0;
-			}
-			if (cc <= 0)
-			Printf(" *");
-			(void) fflush(stdout);
-		}
-		if (got_there || (unreachable > 0 && unreachable >= nprobes6-1))
-		return;
-	}
+  if (options & SO_DEBUG)
+    (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG,
+                      (char *)&on, sizeof(on));
+  if (options & SO_DONTROUTE)
+    (void) setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE,
+                      (char *)&on, sizeof(on));
+
+  if (source6 == NULL) {
+    socklen_t alen;
+    int probe_fd = socket(AF_INET6, SOCK_DGRAM, 0);
+
+    if (probe_fd < 0) {
+      perror("socket");
+      return;
+    }
+    if (device) {
+      if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)+1) == -1)
+        perror("WARNING: interface is ignored");
+    }
+    firsthop.sin6_port = htons(1025);
+    if (connect(probe_fd, (struct sockaddr*)&firsthop, sizeof(firsthop)) == -1) {
+      perror("connect");
+      return;
+    }
+    alen = sizeof(saddr);
+    if (getsockname(probe_fd, (struct sockaddr*)&saddr, &alen) == -1) {
+      perror("getsockname");
+      return;
+    }
+    saddr.sin6_port = 0;
+    close(probe_fd);
+  } else {
+    (void) bzero((char *)&saddr, sizeof(saddr));
+    saddr.sin6_family = AF_INET6;
+    if (inet_pton(AF_INET6, source6, &saddr.sin6_addr) < 0)
+    {
+      Printf("traceroute: unknown addr %s\n", source6);
+      return;
+    }
+  }
+
+  if (bind(sndsock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+    perror ("traceroute: bind sending socket");
+    return;
+  }
+  if (bind(icmp_sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+    perror ("traceroute: bind icmp6 socket");
+    return;
+  }
+
+  for (ttl = 1; ttl <= max_ttl; ++ttl) {
+    struct in6_addr lastaddr = { { {0,}}};
+    int got_there = 0;
+    int unreachable = 0;
+
+    /* Printf("%2d ", ttl); */
+    for (probe = 0; probe < nprobes6; ++probe) {
+      int cc, reset_timer;
+      struct timeval t1, t2;
+      struct timezone tz;
+
+      gettimeofday(&t1, &tz);
+      send_probe6(++seq, ttl);
+      reset_timer = 1;
+
+      while ((cc = wait_for_reply6(icmp_sock, &from, reset_timer)) != 0) {
+        gettimeofday(&t2, &tz);
+        if (cc > 0 && (i = packet_ok6(packet, cc, &from, seq, &t1))) {
+          reset_timer = 1;
+          if (memcmp(&from.sin6_addr, &lastaddr, sizeof(from.sin6_addr))) {
+            memcpy(IPlist[ttl-1],
+                   &from.sin6_addr,
+                   sizeof(IPlist[ttl-1]));
+            memcpy(&lastaddr,
+                   &from.sin6_addr,
+                   sizeof(lastaddr));
+          }
+          if (get_debuglvl() > 4) {
+            char tmp[MAXHOSTNAMELEN];
+            inet_ntop(AF_INET6, &from.sin6_addr, tmp, sizeof(tmp));
+            log_println(5, "Probe %d resulted in reply from [%s]", probe, tmp);
+          }
+          switch(i - 1) {
+            case ICMPV6_PORT_UNREACH:
+              ++got_there;
+              break;
+
+            case ICMPV6_NOROUTE:
+              ++unreachable;
+              Printf(" !N");
+              break;
+            case ICMPV6_ADDR_UNREACH:
+              ++unreachable;
+              Printf(" !H");
+              break;
+
+            case ICMPV6_ADM_PROHIBITED:
+              ++unreachable;
+              Printf(" !S");
+              break;
+          }
+          break;
+        } else
+          reset_timer = 0;
+      }
+      if (cc <= 0)
+        Printf(" *");
+      (void) fflush(stdout);
+    }
+    if (got_there || (unreachable > 0 && unreachable >= nprobes6-1))
+      return;
+  }
 }
 
-int
+  int
 wait_for_reply6(sock, from, reset_timer)
-int sock;
-struct sockaddr_in6 *from;
-int reset_timer;
+  int sock;
+  struct sockaddr_in6 *from;
+  int reset_timer;
 {
-	fd_set fds;
-	static struct timeval wait;
-	int cc = 0;
-	socklen_t fromlen = sizeof (*from);
-
-	FD_ZERO(&fds);
-	FD_SET(sock, &fds);
-	if (reset_timer) {
-		/*
-		 * traceroute could hang if someone else has a ping
-		 * running and our ICMP reply gets dropped but we don't
-		 * realize it because we keep waking up to handle those
-		 * other ICMP packets that keep coming in.  To fix this,
-		 * "reset_timer" will only be true if the last packet that
-		 * came in was for us or if this is the first time we're
-		 * waiting for a reply since sending out a probe.  Note
-		 * that this takes advantage of the select() feature on
-		 * Linux where the remaining timeout is written to the
-		 * struct timeval area.
-		 */
-		wait.tv_sec = waittime6;
-		wait.tv_usec = 0;
-	}
-
-	if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) {
-		cc=recvfrom(icmp_sock, (char *)packet, sizeof(packet), 0,
-				(struct sockaddr *)from, &fromlen);
-	}
-
-	return(cc);
+  fd_set fds;
+  static struct timeval wait;
+  int cc = 0;
+  socklen_t fromlen = sizeof (*from);
+
+  FD_ZERO(&fds);
+  FD_SET(sock, &fds);
+  if (reset_timer) {
+    /*
+     * traceroute could hang if someone else has a ping
+     * running and our ICMP reply gets dropped but we don't
+     * realize it because we keep waking up to handle those
+     * other ICMP packets that keep coming in.  To fix this,
+     * "reset_timer" will only be true if the last packet that
+     * came in was for us or if this is the first time we're
+     * waiting for a reply since sending out a probe.  Note
+     * that this takes advantage of the select() feature on
+     * Linux where the remaining timeout is written to the
+     * struct timeval area.
+     */
+    wait.tv_sec = waittime6;
+    wait.tv_usec = 0;
+  }
+
+  if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0) {
+    cc=recvfrom(icmp_sock, (char *)packet, sizeof(packet), 0,
+                (struct sockaddr *)from, &fromlen);
+  }
+
+  return(cc);
 }
 
 void send_probe6(int seq, int ttl)
 {
-	struct pkt_format *pkt = (struct pkt_format *) sendbuff;
-	int i;
-
-	pkt->ident = htonl(ident);
-	pkt->seq = htonl(seq);
-	gettimeofday(&pkt->tv, &tz);
-
-	i = setsockopt(sndsock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl));
-	if (i < 0)
-	{
-		perror("setsockopt");
-		return;
-	}
-
-	do {
-		i = sendto(sndsock, sendbuff, datalen, 0,
-				(struct sockaddr *)&whereto, sizeof(whereto));
-	}while (i<0 && errno == ECONNREFUSED);
-
-	if (i < 0 || i != datalen) {
-		if (i<0)
-		perror("sendto");
-	}
+  struct pkt_format *pkt = (struct pkt_format *) sendbuff;
+  int i;
+
+  pkt->ident = htonl(ident);
+  pkt->seq = htonl(seq);
+  gettimeofday(&pkt->tv, &tz);
+
+  i = setsockopt(sndsock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl));
+  if (i < 0)
+  {
+    perror("setsockopt");
+    return;
+  }
+
+  do {
+    i = sendto(sndsock, sendbuff, datalen, 0,
+               (struct sockaddr *)&whereto, sizeof(whereto));
+  }while (i<0 && errno == ECONNREFUSED);
+
+  if (i < 0 || i != datalen) {
+    if (i<0)
+      perror("sendto");
+  }
 }
 
 /*
@@ -623,99 +623,99 @@ void send_probe6(int seq, int ttl)
  */
 char * pr_type(unsigned char t)
 {
-	static char *ttab1[] = {
-		"Error",
-		"Destination Unreachable",
-		"Packet Too Big",
-		"Time Exceeded in Transit",
-		"Parameter Problem"
-	};
-
-	static char *ttab2[] = {
-		"Echo Reply",
-		"Echo Request",
-		"Membership Query",
-		"Membership Report",
-		"Membership Reduction",
-	};
-
-	if (t < 5)
-	{
-		return (ttab1[t]);
-	}
-
-        unsigned char newt = t - 128;
-	if (newt < 5)
-	{
-		return (ttab2[newt]);
-	}
-
-	return("OUT-OF-RANGE");
+  static char *ttab1[] = {
+    "Error",
+    "Destination Unreachable",
+    "Packet Too Big",
+    "Time Exceeded in Transit",
+    "Parameter Problem"
+  };
+
+  static char *ttab2[] = {
+    "Echo Reply",
+    "Echo Request",
+    "Membership Query",
+    "Membership Report",
+    "Membership Reduction",
+  };
+
+  if (t < 5)
+  {
+    return (ttab1[t]);
+  }
+
+  unsigned char newt = t - 128;
+  if (newt < 5)
+  {
+    return (ttab2[newt]);
+  }
+
+  return("OUT-OF-RANGE");
 }
 
 int packet_ok6(u_char *buf, int cc, struct sockaddr_in6 *from, int seq,
-		struct timeval *tv)
+               struct timeval *tv)
 {
-	struct icmp6hdr *icp;
-	u_char type, code;
-
-	icp = (struct icmp6hdr *) buf;
-
-	type = icp->icmp6_type;
-	code = icp->icmp6_code;
-
-	if ((type == ICMPV6_TIME_EXCEED && code == ICMPV6_EXC_HOPLIMIT) ||
-			type == ICMPV6_DEST_UNREACH)
-	{
-		struct ipv6hdr *hip;
-		struct udphdr *up;
-		int nexthdr;
-
-		hip = (struct ipv6hdr *) (icp + 1);
-		up = (struct udphdr *)(hip+1);
-		nexthdr = hip->nexthdr;
-
-		if (nexthdr == 44) {
-			nexthdr = *(unsigned char*)up;
-			up++;
-		}
-		if (nexthdr == IPPROTO_UDP)
-		{
-			struct pkt_format *pkt;
-
-			pkt = (struct pkt_format *) (up + 1);
-
-			if (ntohl(pkt->ident) == ident &&
-					ntohl(pkt->seq) == seq)
-			{
-				*tv = pkt->tv;
-				return (type == ICMPV6_TIME_EXCEED? -1 : code+1);
-			}
-		}
-
-	}
-
-	if (verbose) {
-		struct ipv6hdr *hip;
-		__u32 *lp;
-		char pa1[MAXHOSTNAMELEN];
-		char pa2[MAXHOSTNAMELEN];
-		int i;
-		hip = (struct ipv6hdr *) (icp + 1);
-		lp = (__u32 *) (icp + 1);
-
-		Printf("\n%d bytes from %s to %s", cc,
-				inet_ntop(AF_INET6, &hip->saddr, pa1, sizeof(pa1)),
-				inet_ntop(AF_INET6, &hip->daddr, pa2, sizeof(pa2)));
-
-		Printf(": icmp type %d (%s) code %d\n", type, pr_type(type),
-				icp->icmp6_code);
-
-		for (i = sizeof(struct ipv6hdr); i < cc; i += 4)
-		Printf("%2d: x%8.8x\n", i, *lp++);
-	}
-
-	return(0);
+  struct icmp6hdr *icp;
+  u_char type, code;
+
+  icp = (struct icmp6hdr *) buf;
+
+  type = icp->icmp6_type;
+  code = icp->icmp6_code;
+
+  if ((type == ICMPV6_TIME_EXCEED && code == ICMPV6_EXC_HOPLIMIT) ||
+      type == ICMPV6_DEST_UNREACH)
+  {
+    struct ipv6hdr *hip;
+    struct udphdr *up;
+    int nexthdr;
+
+    hip = (struct ipv6hdr *) (icp + 1);
+    up = (struct udphdr *)(hip+1);
+    nexthdr = hip->nexthdr;
+
+    if (nexthdr == 44) {
+      nexthdr = *(unsigned char*)up;
+      up++;
+    }
+    if (nexthdr == IPPROTO_UDP)
+    {
+      struct pkt_format *pkt;
+
+      pkt = (struct pkt_format *) (up + 1);
+
+      if (ntohl(pkt->ident) == ident &&
+          ntohl(pkt->seq) == seq)
+      {
+        *tv = pkt->tv;
+        return (type == ICMPV6_TIME_EXCEED? -1 : code+1);
+      }
+    }
+
+  }
+
+  if (verbose) {
+    struct ipv6hdr *hip;
+    __u32 *lp;
+    char pa1[MAXHOSTNAMELEN];
+    char pa2[MAXHOSTNAMELEN];
+    int i;
+    hip = (struct ipv6hdr *) (icp + 1);
+    lp = (__u32 *) (icp + 1);
+
+    Printf("\n%d bytes from %s to %s", cc,
+           inet_ntop(AF_INET6, &hip->saddr, pa1, sizeof(pa1)),
+           inet_ntop(AF_INET6, &hip->daddr, pa2, sizeof(pa2)));
+
+    Printf(": icmp type %d (%s) code %d\n", type, pr_type(type),
+           icp->icmp6_code);
+
+    for (i = sizeof(struct ipv6hdr); i < cc; i += 4)
+      Printf("%2d: x%8.8x\n", i, *lp++);
+  }
+
+  return(0);
 }
 
 #endif
diff --git a/src/usage.c b/src/usage.c
index 8ff0431..6d8fb82 100644
--- a/src/usage.c
+++ b/src/usage.c
@@ -19,12 +19,12 @@
  */
 
 void short_usage(char* prog, char* info) {
-	assert(prog != NULL);
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf("Try `%s --help' for more information.\n", prog);
+  assert(prog != NULL);
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf("Try `%s --help' for more information.\n", prog);
 
-	exit(1);
+  exit(1);
 }
 
 /**
@@ -33,90 +33,90 @@ void short_usage(char* prog, char* info) {
  */
 
 void srv_long_usage(char* info) {
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf(" Basic options:\n\n");
-	printf(
-			"  -a, --adminview        - generate administrator view html page\n");
-	printf("  -d, --debug            - print additional diagnostic messages\n");
-	printf(
-			"                           Note: add multiple d's (-ddd) for more details\n");
-	printf("  -h, --help             - print help message (this message)\n");
-	printf("  -m, --multiple         - select single or multi-test mode\n");
-	printf("  -o, --old              - use old Duplex Mismatch heuristic\n");
-	printf(
-			"  -q, --disable-queue    - disable FIFO queuing of client requests\n");
-	printf(
-			"  -r, --record           - record client to server Web100 variables\n");
-	printf(
-			"  -s, --syslog           - use the syslog() to log some information\n");
-	printf("  -t, --tcpdump          - write tcpdump formatted file to disk\n");
-	printf("  -v, --version          - print version number\n");
-	printf(
-			"  -x, --max_clients      - maximum numbers of clients permited in FIFO queue (default=50)\n");
-	printf(
-			"  -z, --gzip	     - disable compression of tcptrace, snaplog, and cputime files\n\n");
-	printf(" Configuration:\n\n");
-	printf(
-			"  -c, --config #filename - specify the name of the file with configuration\n");
-	printf(
-			"  -b, --buffer #size     - set TCP send/recv buffers to user value\n");
-	printf(
-			"  -f, --file variable_FN - specify alternate 'web100_variables' file\n");
-	printf(
-			"  -i, --interface device - specify network interface (libpcap device)\n");
-	printf(
-			"  -l, --log Log_FN       - specify alternate 'web100srv.log' file\n");
-	printf(
-			"  -u, --protolog_dir DIR - specify the base directory for protocol validation logs \n");
-	printf("  --enableprotolog       - enable protocol logging \n");
-	printf(
-			"  -p, --port #port       - specify primary port number (default 3001)\n");
-	printf(
-			"  --midport #port        - specify Middlebox test port number (default 3003)\n");
-	printf(
-			"  --c2sport #port        - specify C2S throughput test port number (default 3002)\n");
-	printf(
-			"  --s2cport #port        - specify S2C throughput test port number (default 3003)\n");
-	printf(
-			"  -T, --refresh #time    - specify the refresh time of the admin page\n");
-	printf(
-			"  --mrange #range        - set the port range used in multi-test mode\n");
-	printf("                           Note: this enables multi-test mode\n");
-	printf(
-			"  -A, --adminfile #FN    - specify alternate filename for Admin web page\n");
-	printf(
-			"                           Note: this doesn't enable 'adminview'\n");
-	printf(
-			"  -L, --log_dir DIR      - specify the base directory for snaplog and tcpdump files\n");
-	printf("                           (default %s/serverdata)\n", BASEDIR);
-	printf("  -S, --logfacility #F   - specify syslog facility name\n");
-	printf("                           Note: this doesn't enable 'syslog'\n\n");
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf(" Basic options:\n\n");
+  printf(
+      "  -a, --adminview        - generate administrator view html page\n");
+  printf("  -d, --debug            - print additional diagnostic messages\n");
+  printf(
+      "                           Note: add multiple d's (-ddd) for more details\n");
+  printf("  -h, --help             - print help message (this message)\n");
+  printf("  -m, --multiple         - select single or multi-test mode\n");
+  printf("  -o, --old              - use old Duplex Mismatch heuristic\n");
+  printf(
+      "  -q, --disable-queue    - disable FIFO queuing of client requests\n");
+  printf(
+      "  -r, --record           - record client to server Web100 variables\n");
+  printf(
+      "  -s, --syslog           - use the syslog() to log some information\n");
+  printf("  -t, --tcpdump          - write tcpdump formatted file to disk\n");
+  printf("  -v, --version          - print version number\n");
+  printf(
+      "  -x, --max_clients      - maximum numbers of clients permited in FIFO queue (default=50)\n");
+  printf(
+      "  -z, --gzip	     - disable compression of tcptrace, snaplog, and cputime files\n\n");
+  printf(" Configuration:\n\n");
+  printf(
+      "  -c, --config #filename - specify the name of the file with configuration\n");
+  printf(
+      "  -b, --buffer #size     - set TCP send/recv buffers to user value\n");
+  printf(
+      "  -f, --file variable_FN - specify alternate 'web100_variables' file\n");
+  printf(
+      "  -i, --interface device - specify network interface (libpcap device)\n");
+  printf(
+      "  -l, --log Log_FN       - specify alternate 'web100srv.log' file\n");
+  printf(
+      "  -u, --protolog_dir DIR - specify the base directory for protocol validation logs \n");
+  printf("  --enableprotolog       - enable protocol logging \n");
+  printf(
+      "  -p, --port #port       - specify primary port number (default 3001)\n");
+  printf(
+      "  --midport #port        - specify Middlebox test port number (default 3003)\n");
+  printf(
+      "  --c2sport #port        - specify C2S throughput test port number (default 3002)\n");
+  printf(
+      "  --s2cport #port        - specify S2C throughput test port number (default 3003)\n");
+  printf(
+      "  -T, --refresh #time    - specify the refresh time of the admin page\n");
+  printf(
+      "  --mrange #range        - set the port range used in multi-test mode\n");
+  printf("                           Note: this enables multi-test mode\n");
+  printf(
+      "  -A, --adminfile #FN    - specify alternate filename for Admin web page\n");
+  printf(
+      "                           Note: this doesn't enable 'adminview'\n");
+  printf(
+      "  -L, --log_dir DIR      - specify the base directory for snaplog and tcpdump files\n");
+  printf("                           (default %s/serverdata)\n", BASEDIR);
+  printf("  -S, --logfacility #F   - specify syslog facility name\n");
+  printf("                           Note: this doesn't enable 'syslog'\n\n");
 #ifdef EXPERIMENTAL_ENABLED
-	printf(" Experimental code:\n\n");
-	printf("  --avoidsndblockup      - enable code to avoid send buffers blocking in the S2C test\n");
-	printf("  --snaplog              - enable the snaplog writing\n");
-	printf("  --snapdelay #msec      - specify the delay in the snaplog thread (default 5 msec)\n");
-	printf("                           Note: this doesn't enable 'snaplog'\n");
-	printf("  --cwnddecrease         - enable analyzing of the cwnd changes during the S2C test\n");
-	printf("                           Note: this automatically enables 'snaplog'\n");
-	printf("  --cputime              - enable the cputime writing\n");
-	printf("  -y, --limit #limit     - enable the throughput limiting code\n\n");
+  printf(" Experimental code:\n\n");
+  printf("  --avoidsndblockup      - enable code to avoid send buffers blocking in the S2C test\n");
+  printf("  --snaplog              - enable the snaplog writing\n");
+  printf("  --snapdelay #msec      - specify the delay in the snaplog thread (default 5 msec)\n");
+  printf("                           Note: this doesn't enable 'snaplog'\n");
+  printf("  --cwnddecrease         - enable analyzing of the cwnd changes during the S2C test\n");
+  printf("                           Note: this automatically enables 'snaplog'\n");
+  printf("  --cputime              - enable the cputime writing\n");
+  printf("  -y, --limit #limit     - enable the throughput limiting code\n\n");
 #endif
 #if defined(HAVE_ODBC) && defined(DATABASE_ENABLED) && defined(HAVE_SQL_H)
-	printf(" Database support:\n\n");
-	printf("  --enableDBlogging      - enable the test results logging to the database\n");
-	printf("  --dbDSN #dsn           - specify the DSN to use (this doesn't enable DBlogging)\n");
-	printf("  --dbUID #uid           - specify the UID to use (this doesn't enable DBlogging)\n");
-	printf("  --dbPWD #pwd           - specify the PWD to use (this doesn't enable DBlogging)\n\n");
+  printf(" Database support:\n\n");
+  printf("  --enableDBlogging      - enable the test results logging to the database\n");
+  printf("  --dbDSN #dsn           - specify the DSN to use (this doesn't enable DBlogging)\n");
+  printf("  --dbUID #uid           - specify the UID to use (this doesn't enable DBlogging)\n");
+  printf("  --dbPWD #pwd           - specify the PWD to use (this doesn't enable DBlogging)\n\n");
 #endif
 #ifdef AF_INET6
-	printf(" IP family:\n\n");
-	printf("  -4, --ipv4             - use IPv4 addresses only\n");
-	printf("  -6, --ipv6             - use IPv6 addresses only\n\n");
+  printf(" IP family:\n\n");
+  printf("  -4, --ipv4             - use IPv4 addresses only\n");
+  printf("  -6, --ipv6             - use IPv6 addresses only\n\n");
 #endif
 
-	exit(0);
+  exit(0);
 }
 
 /**
@@ -125,34 +125,34 @@ void srv_long_usage(char* info) {
  */
 
 void clt_long_usage(char* info) {
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf(" Basic options:\n\n");
-	printf("  -n, --name #name       - specify name of the server\n");
-	printf("  -p, --port #port       - specify port server is listening on\n");
-	printf("  -d, --debug            - Increase debug level details\n");
-	printf(
-			"                           Note: add multiple d's (-ddd) for more details\n");
-	printf("  -h, --help             - print this help message\n");
-	printf("  -l, --msglvl           - increase message level details\n");
-	printf(
-			"  --web100variables      - print the information about each Web100 variable\n");
-	printf("  -v, --version          - print version number\n\n");
-	printf(" Configuration:\n\n");
-	printf("  -b, --buffer #size     - set send/receive buffer to value\n");
-	printf("  --disablemid           - disable the Middlebox test\n");
-	printf("  --disablec2s           - disable the C2S throughput test\n");
-	printf("  --disables2c           - disable the S2C throughput test\n");
-	printf("  --disablesfw           - disable the Simple firewall test\n\n");
-	printf("  -u, --protolog_dir DIR - specify the base directory for protocol validation logs \n");
-	printf("  --enableprotolog        - enable protocol logging \n");
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf(" Basic options:\n\n");
+  printf("  -n, --name #name       - specify name of the server\n");
+  printf("  -p, --port #port       - specify port server is listening on\n");
+  printf("  -d, --debug            - Increase debug level details\n");
+  printf(
+      "                           Note: add multiple d's (-ddd) for more details\n");
+  printf("  -h, --help             - print this help message\n");
+  printf("  -l, --msglvl           - increase message level details\n");
+  printf(
+      "  --web100variables      - print the information about each Web100 variable\n");
+  printf("  -v, --version          - print version number\n\n");
+  printf(" Configuration:\n\n");
+  printf("  -b, --buffer #size     - set send/receive buffer to value\n");
+  printf("  --disablemid           - disable the Middlebox test\n");
+  printf("  --disablec2s           - disable the C2S throughput test\n");
+  printf("  --disables2c           - disable the S2C throughput test\n");
+  printf("  --disablesfw           - disable the Simple firewall test\n\n");
+  printf("  -u, --protolog_dir DIR - specify the base directory for protocol validation logs \n");
+  printf("  --enableprotolog        - enable protocol logging \n");
 #ifdef AF_INET6
-	printf(" IP family:\n\n");
-	printf("  -4, --ipv4             - use IPv4 addresses only\n");
-	printf("  -6, --ipv6             - use IPv6 addresses only\n\n");
+  printf(" IP family:\n\n");
+  printf("  -4, --ipv4             - use IPv4 addresses only\n");
+  printf("  -6, --ipv6             - use IPv6 addresses only\n\n");
 #endif
 
-	exit(0);
+  exit(0);
 }
 
 /**
@@ -161,40 +161,40 @@ void clt_long_usage(char* info) {
  */
 
 void www_long_usage(char* info) {
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf(" Basic options:\n\n");
-	printf("  -d, --debug            - increment debugging mode\n");
-	printf(
-			"                           Note: add multiple d's (-ddd) for more details\n");
-	printf("  -h, --help             - print this help message\n");
-	printf("  -F, --federated        - operate in Federated mode\n");
-	printf("  -f, --file FN          - add the file to the allowed list\n");
-	printf(
-			"  -s, --syslog           - use the syslog() to log some information\n");
-	printf("  -v, --version          - print version number\n\n");
-	printf(" Configuration:\n\n");
-	printf("  -l, --alog alog_FN     - specify the access log filename\n");
-	printf("  -e, --elog elog_FN     - specify the error log filename\n");
-	printf("  -b, --basedir path     - set the basedir for the documents\n");
-	printf("  -S, --logfacility #F   - specify syslog facility name\n");
-	printf("                           Note: this doesn't enable 'syslog'\n");
-	printf(
-			"  -p, --port #port       - specify the port number (default is 7123)\n");
-	printf(
-			"  -t, --ttl #amount      - specify maximum number of hops in path (default is 10)\n");
-	printf(
-			"  --dflttree fn          - specify alternate 'Default.tree' file\n");
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf(" Basic options:\n\n");
+  printf("  -d, --debug            - increment debugging mode\n");
+  printf(
+      "                           Note: add multiple d's (-ddd) for more details\n");
+  printf("  -h, --help             - print this help message\n");
+  printf("  -F, --federated        - operate in Federated mode\n");
+  printf("  -f, --file FN          - add the file to the allowed list\n");
+  printf(
+      "  -s, --syslog           - use the syslog() to log some information\n");
+  printf("  -v, --version          - print version number\n\n");
+  printf(" Configuration:\n\n");
+  printf("  -l, --alog alog_FN     - specify the access log filename\n");
+  printf("  -e, --elog elog_FN     - specify the error log filename\n");
+  printf("  -b, --basedir path     - set the basedir for the documents\n");
+  printf("  -S, --logfacility #F   - specify syslog facility name\n");
+  printf("                           Note: this doesn't enable 'syslog'\n");
+  printf(
+      "  -p, --port #port       - specify the port number (default is 7123)\n");
+  printf(
+      "  -t, --ttl #amount      - specify maximum number of hops in path (default is 10)\n");
+  printf(
+      "  --dflttree fn          - specify alternate 'Default.tree' file\n");
 #ifdef AF_INET6
-	printf("  --dflttree6 fn         - specify alternate 'Default.tree6' file\n\n");
-	printf(" IP family:\n\n");
-	printf("  -4, --ipv4             - use IPv4 addresses only\n");
-	printf("  -6, --ipv6             - use IPv6 addresses only\n\n");
+  printf("  --dflttree6 fn         - specify alternate 'Default.tree6' file\n\n");
+  printf(" IP family:\n\n");
+  printf("  -4, --ipv4             - use IPv4 addresses only\n");
+  printf("  -6, --ipv6             - use IPv6 addresses only\n\n");
 #else
-	printf("\n");
+  printf("\n");
 #endif
 
-	exit(0);
+  exit(0);
 }
 
 /**
@@ -203,18 +203,18 @@ void www_long_usage(char* info) {
  */
 
 void analyze_long_usage(char* info) {
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf(" Basic options:\n\n");
-	printf("  -d, --debug            - increment debugging mode\n");
-	printf(
-			"                           Note: add multiple d's (-ddd) for more details\n");
-	printf("  -n, --nodns            - disable resolving DNS names\n");
-	printf("  -h, --help             - print this help message\n");
-	printf("  -l, --log log_FN       - specify the file with the logs\n");
-	printf("  -v, --version          - print version number\n\n");
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf(" Basic options:\n\n");
+  printf("  -d, --debug            - increment debugging mode\n");
+  printf(
+      "                           Note: add multiple d's (-ddd) for more details\n");
+  printf("  -n, --nodns            - disable resolving DNS names\n");
+  printf("  -h, --help             - print this help message\n");
+  printf("  -l, --log log_FN       - specify the file with the logs\n");
+  printf("  -v, --version          - print version number\n\n");
 
-	exit(0);
+  exit(0);
 }
 
 /**
@@ -223,34 +223,34 @@ void analyze_long_usage(char* info) {
  */
 
 void mkmap_long_usage(char* info) {
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf(" Basic options:\n\n");
-	printf("  -b, --build            - build a new default tree\n");
-	printf("  -c, --compare fn       - compare new traceroute to tree\n");
-	printf(
-			"                           Note: -b and -c are mutually exclusive\n");
-	printf("  -f, --file fn          - specify the name of the input file\n");
-	printf("  -h, --help             - print this help message\n");
-	printf(
-			"  -p, --print            - [default] print out the current traceroute map\n");
-	printf("  -d, --debug            - increment debugging mode\n");
-	printf(
-			"                           Note: add multiple d's (-ddd) for more details\n");
-	printf("  -v, --version          - print version number\n\n");
-	printf(" Configuration:\n\n");
-	printf(
-			"  --dflttree fn          - specify alternate 'Default.tree' file\n");
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf(" Basic options:\n\n");
+  printf("  -b, --build            - build a new default tree\n");
+  printf("  -c, --compare fn       - compare new traceroute to tree\n");
+  printf(
+      "                           Note: -b and -c are mutually exclusive\n");
+  printf("  -f, --file fn          - specify the name of the input file\n");
+  printf("  -h, --help             - print this help message\n");
+  printf(
+      "  -p, --print            - [default] print out the current traceroute map\n");
+  printf("  -d, --debug            - increment debugging mode\n");
+  printf(
+      "                           Note: add multiple d's (-ddd) for more details\n");
+  printf("  -v, --version          - print version number\n\n");
+  printf(" Configuration:\n\n");
+  printf(
+      "  --dflttree fn          - specify alternate 'Default.tree' file\n");
 #ifdef AF_INET6
-	printf("  --dflttree6 fn         - specify alternate 'Default.tree6' file\n\n");
-	printf(" IP family:\n\n");
-	printf("  -4, --ipv4             - use only IPv4 operational mode\n");
-	printf("  -6, --ipv6             - use only IPv6 operational mode\n\n");
+  printf("  --dflttree6 fn         - specify alternate 'Default.tree6' file\n\n");
+  printf(" IP family:\n\n");
+  printf("  -4, --ipv4             - use only IPv4 operational mode\n");
+  printf("  -6, --ipv6             - use only IPv6 operational mode\n\n");
 #else
-	printf("\n");
+  printf("\n");
 #endif
 
-	exit(0);
+  exit(0);
 }
 
 /**
@@ -259,26 +259,26 @@ void mkmap_long_usage(char* info) {
  */
 
 void vt_long_usage(char* info) {
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf(" Basic options:\n\n");
-	printf(
-			"  -c, --count #amount    - specify how many packets will be viewed\n");
-	printf("  -d, --debug            - increment debugging mode\n");
-	printf(
-			"                           Note: add multiple d's (-ddd) for more details\n");
-	printf(
-			"  -f, --file fn          - specify the name of the file to offline trace\n");
-	printf("  -h, --help             - print this help message\n");
-	printf(
-			"  -i, --interface device - specify network interface (libpcap device)\n");
-	printf(
-			"  --c2sport #port        - specify C2S throughput test port number (default 3002)\n");
-	printf(
-			"  --s2cport #port        - specify S2C throughput test port number (default 3003)\n");
-	printf("  -v, --version          - print version number\n\n");
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf(" Basic options:\n\n");
+  printf(
+      "  -c, --count #amount    - specify how many packets will be viewed\n");
+  printf("  -d, --debug            - increment debugging mode\n");
+  printf(
+      "                           Note: add multiple d's (-ddd) for more details\n");
+  printf(
+      "  -f, --file fn          - specify the name of the file to offline trace\n");
+  printf("  -h, --help             - print this help message\n");
+  printf(
+      "  -i, --interface device - specify network interface (libpcap device)\n");
+  printf(
+      "  --c2sport #port        - specify C2S throughput test port number (default 3002)\n");
+  printf(
+      "  --s2cport #port        - specify S2C throughput test port number (default 3003)\n");
+  printf("  -v, --version          - print version number\n\n");
 
-	exit(0);
+  exit(0);
 }
 
 /**
@@ -288,23 +288,23 @@ void vt_long_usage(char* info) {
  */
 
 void genplot_long_usage(char* info, char* argv0) {
-	assert(info != NULL);
-	printf("\n%s\n\n\n", info);
-	printf("Usage: %s [options] filelist\n", argv0);
-	printf("This program generates xplot graphs from Web100 variables\n\n");
-	printf(" Basic options:\n\n");
-	printf(
-			"  -b, --both             - generate plot of both CurCwnd and CurRwinRcvd\n");
-	printf(
-			"  -m, --multi varlist    - a comma separated list of Web100 vars to plot\n");
-	printf(
-			"  -t, --text             - print variable values instead of generating plots\n");
-	printf("  -C, --CurCwnd          - generate CurCwnd plot\n");
-	printf("  -R, --CurRwinRcvd      - generate CurRwinRcvd plot\n");
-	printf("  -S, --throughput       - generate throughput plot\n");
-	printf("  -c, --cwndtime         - generate Cwnd time plot\n");
-	printf("  -h, --help             - print this help message\n");
-	printf("  -v, --version          - print version number\n\n");
+  assert(info != NULL);
+  printf("\n%s\n\n\n", info);
+  printf("Usage: %s [options] filelist\n", argv0);
+  printf("This program generates xplot graphs from Web100 variables\n\n");
+  printf(" Basic options:\n\n");
+  printf(
+      "  -b, --both             - generate plot of both CurCwnd and CurRwinRcvd\n");
+  printf(
+      "  -m, --multi varlist    - a comma separated list of Web100 vars to plot\n");
+  printf(
+      "  -t, --text             - print variable values instead of generating plots\n");
+  printf("  -C, --CurCwnd          - generate CurCwnd plot\n");
+  printf("  -R, --CurRwinRcvd      - generate CurRwinRcvd plot\n");
+  printf("  -S, --throughput       - generate throughput plot\n");
+  printf("  -c, --cwndtime         - generate Cwnd time plot\n");
+  printf("  -h, --help             - print this help message\n");
+  printf("  -v, --version          - print version number\n\n");
 
-	exit(0);
+  exit(0);
 }
diff --git a/src/utils.c b/src/utils.c
index 97a8698..26240c7 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -33,21 +33,21 @@
  */
 
 int check_int(char* text, int* number) {
-	char* znak;
-	long tmp;
-
-	assert(text != NULL);
-	assert(number != NULL);
-
-	if (((tmp = strtol(text, &znak, 10)) >= INT_MAX) || (tmp <= INT_MIN)) {
-		return 1;
-	}
-	if ((*text != '\0') && (*znak == '\0')) {
-		*number = tmp;
-		return 0;
-	} else {
-		return 2;
-	}
+  char* znak;
+  long tmp;
+
+  assert(text != NULL);
+  assert(number != NULL);
+
+  if (((tmp = strtol(text, &znak, 10)) >= INT_MAX) || (tmp <= INT_MIN)) {
+    return 1;
+  }
+  if ((*text != '\0') && (*znak == '\0')) {
+    *number = tmp;
+    return 0;
+  } else {
+    return 2;
+  }
 }
 
 /**
@@ -63,17 +63,17 @@ int check_int(char* text, int* number) {
  */
 
 int check_rint(char* text, int* number, int minVal, int maxVal) {
-	int ret;
+  int ret;
 
-	assert(maxVal >= minVal);
+  assert(maxVal >= minVal);
 
-	if ((ret = check_int(text, number))) {
-		return ret;
-	}
-	if ((*number < minVal) || (*number > maxVal)) {
-		return 1;
-	}
-	return 0;
+  if ((ret = check_int(text, number))) {
+    return ret;
+  }
+  if ((*number < minVal) || (*number > maxVal)) {
+    return 1;
+  }
+  return 0;
 }
 
 /**
@@ -86,20 +86,20 @@ int check_rint(char* text, int* number, int minVal, int maxVal) {
  */
 
 int check_long(char* text, long* number) {
-	char* tmp;
-
-	assert(text != NULL);
-	assert(number != NULL);
-
-	if (((*number = strtol(text, &tmp, 10)) == LONG_MAX)
-			|| (*number == LONG_MIN)) {
-		return 1;
-	}
-	if ((*text != '\0') && (*tmp == '\0')) {
-		return 0;
-	} else {
-		return 2;
-	}
+  char* tmp;
+
+  assert(text != NULL);
+  assert(number != NULL);
+
+  if (((*number = strtol(text, &tmp, 10)) == LONG_MAX)
+      || (*number == LONG_MIN)) {
+    return 1;
+  }
+  if ((*text != '\0') && (*tmp == '\0')) {
+    return 0;
+  } else {
+    return 2;
+  }
 }
 
 /**
@@ -108,9 +108,9 @@ int check_long(char* text, long* number) {
  */
 
 double secs() {
-	struct timeval ru;
-	gettimeofday(&ru, (struct timezone *) 0);
-	return (ru.tv_sec + ((double) ru.tv_usec) / 1000000);
+  struct timeval ru;
+  gettimeofday(&ru, (struct timezone *) 0);
+  return (ru.tv_sec + ((double) ru.tv_usec) / 1000000);
 }
 
 /**
@@ -119,8 +119,8 @@ double secs() {
  */
 
 void err_sys(char* s) {
-	perror(s);
-	/* return -1; */
+  perror(s);
+  /* return -1; */
 }
 
 /**
@@ -132,14 +132,14 @@ void err_sys(char* s) {
 
 int sndq_len(int fd) {
 #ifdef SIOCOUTQ
-	int length = -1;
+  int length = -1;
 
-	if (ioctl(fd, SIOCOUTQ, &length)) {
-		return -1;
-	}
-	return length;
+  if (ioctl(fd, SIOCOUTQ, &length)) {
+    return -1;
+  }
+  return length;
 #else
-	return 0;
+  return 0;
 #endif
 }
 
@@ -149,18 +149,18 @@ int sndq_len(int fd) {
  */
 
 void mysleep(double time) {
-	int rc;
-	struct timeval tv;
-	tv.tv_sec = (int) time;
-	tv.tv_usec = (int) (time * 1000000) % 1000000;
-
-	for (;;) {
-		rc = select(0, NULL, NULL, NULL, &tv);
-		if ((rc == -1) && (errno == EINTR))
-			continue;
-		if (rc == 0)
-			return;
-	}
+  int rc;
+  struct timeval tv;
+  tv.tv_sec = (int) time;
+  tv.tv_usec = (int) (time * 1000000) % 1000000;
+
+  for (;;) {
+    rc = select(0, NULL, NULL, NULL, &tv);
+    if ((rc == -1) && (errno == EINTR))
+      continue;
+    if (rc == 0)
+      return;
+  }
 }
 
 /**
@@ -172,28 +172,27 @@ void mysleep(double time) {
  * @return strlen of output string
  */
 int trim(char *line, int line_size,
-		char * output_buf, int output_buf_size) {
-	static char whitespacearr[4]= {  '\n', ' ', '\t', '\r' };
-
-	int i, j, k;
-
-	for (i = j = 0; i < line_size && j < output_buf_size - 1; i++) {
-		// find any matching characters among the quoted
-		int is_whitespace = 0;
-		for (k = 0; k < 4; k++) {
-			if (line[i] == whitespacearr[k]) {
-				is_whitespace = 1;
-				break;
-			}
-		}
-		if (!is_whitespace) {
-			output_buf[j] = line[i];
-			j++ ;
-		}
-	}
-	output_buf[j] = '\0'; // null terminate
-	//log_println(8,"Received=%s; len=%d; dest=%d; MSG=%s\n", line, line_size,
-	//		strlen(output_buf), output_buf);
-	return j - 1;
+         char * output_buf, int output_buf_size) {
+  static char whitespacearr[4]= {  '\n', ' ', '\t', '\r' };
+
+  int i, j, k;
+
+  for (i = j = 0; i < line_size && j < output_buf_size - 1; i++) {
+    // find any matching characters among the quoted
+    int is_whitespace = 0;
+    for (k = 0; k < 4; k++) {
+      if (line[i] == whitespacearr[k]) {
+        is_whitespace = 1;
+        break;
+      }
+    }
+    if (!is_whitespace) {
+      output_buf[j] = line[i];
+      j++ ;
+    }
+  }
+  output_buf[j] = '\0'; // null terminate
+  //log_println(8,"Received=%s; len=%d; dest=%d; MSG=%s\n", line, line_size,
+  //		strlen(output_buf), output_buf);
+  return j - 1;
 }
-
diff --git a/src/viewtrace.c b/src/viewtrace.c
index 711504b..98fb49c 100644
--- a/src/viewtrace.c
+++ b/src/viewtrace.c
@@ -51,9 +51,9 @@ FILE *fp;
 int c2sport = 3002, s2cport = 3003;
 
 static struct option long_options[] = { { "count", 1, 0, 'c' }, { "debug", 0, 0,
-		'd' }, { "file", 1, 0, 'f' }, { "help", 0, 0, 'h' }, { "interface", 1,
+	'd' }, { "file", 1, 0, 'f' }, { "help", 0, 0, 'h' }, { "interface", 1,
 		0, 'i' }, { "log", 1, 0, 'l' }, { "c2sport", 1, 0, 303 }, { "s2cport",
-		1, 0, 304 }, { "version", 0, 0, 'v' }, { 0, 0, 0, 0 } };
+			1, 0, 304 }, { "version", 0, 0, 'v' }, { 0, 0, 0, 0 } };
 
 /*
  * Copy arg vector into a new buffer, concatenating arguments with spaces.
@@ -160,68 +160,68 @@ void vt_print_bins(struct spdpair *cur) {
 				"%u.%u.%u.%u:%d --> ",
 				(cur->saddr & 0xFF), ((cur->saddr >> 8) & 0xff),
 				((cur->saddr >> 16) & 0xff), (cur->saddr >> 24), cur->sport);
-				fprintf(stderr, "%u.%u.%u.%u:%d  ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
-        ((cur->daddr >> 16) & 0xff),  (cur->daddr >> 24), cur->dport);
+		fprintf(stderr, "%u.%u.%u.%u:%d  ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
+				((cur->daddr >> 16) & 0xff),  (cur->daddr >> 24), cur->dport);
 #endif
-  } else {
+	} else {
 #if defined(AF_INET6)
-			char str[136];
-			memset(str, 0, 136);
-			inet_ntop(AF_INET6, (void *) cur->daddr, str, sizeof(str));
-			fprintf(stderr, "%s.%d --> ", str, cur->dport);
-			memset(str, 0, 136);
-			inet_ntop(AF_INET6, (void *) cur->saddr, str, sizeof(str));
-			fprintf(stderr, "%s.%d  ", str, cur->sport);
+		char str[136];
+		memset(str, 0, 136);
+		inet_ntop(AF_INET6, (void *) cur->daddr, str, sizeof(str));
+		fprintf(stderr, "%s.%d --> ", str, cur->dport);
+		memset(str, 0, 136);
+		inet_ntop(AF_INET6, (void *) cur->saddr, str, sizeof(str));
+		fprintf(stderr, "%s.%d  ", str, cur->sport);
 #else
-			fprintf(stderr, "%u.%u.%u.%u:%d --> ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
-					((cur->daddr >> 16) & 0xff), (cur->daddr >> 24), cur->dport);
-			fprintf(stderr, "%u.%u.%u.%u:%d  ", (cur->saddr & 0xFF), ((cur->saddr >> 8) & 0xff),
-					((cur->saddr >> 16) & 0xff), (cur->saddr >> 24), cur->sport);
+		fprintf(stderr, "%u.%u.%u.%u:%d --> ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
+				((cur->daddr >> 16) & 0xff), (cur->daddr >> 24), cur->dport);
+		fprintf(stderr, "%u.%u.%u.%u:%d  ", (cur->saddr & 0xFF), ((cur->saddr >> 8) & 0xff),
+				((cur->saddr >> 16) & 0xff), (cur->saddr >> 24), cur->sport);
 #endif
-		}
+	}
 	if (max == 0)
 		fprintf(stderr, "\n\tNo packets collected\n");
 
 	switch (index) {
-	case -1:
-		fprintf(stderr, "link=%d (Fault); ", index);
-		break;
-	case 0:
-		fprintf(stderr, "link=%d (RTT); ", index);
-		break;
-	case 1:
-		fprintf(stderr, "link=%d (dial-up); ", index);
-		break;
-	case 2:
-		fprintf(stderr, "link=%d (T1); ", index);
-		break;
-	case 3:
-		fprintf(stderr, "link=%d (Enet); ", index);
-		break;
-	case 4:
-		fprintf(stderr, "link=%d (T3); ", index);
-		break;
-	case 5:
-		fprintf(stderr, "link=%d (FastE); ", index);
-		break;
-	case 6:
-		fprintf(stderr, "link=%d (OC-12); ", index);
-		break;
-	case 7:
-		fprintf(stderr, "link=%d (GigE); ", index);
-		break;
-	case 8:
-		fprintf(stderr, "link=%d (OC-48); ", index);
-		break;
-	case 9:
-		fprintf(stderr, "link=%d (10 GigE); ", index);
-		break;
-	case 10:
-		fprintf(stderr, "retransmission; ");
-		break;
-	case 11:
-		fprintf(stderr, "link=%d (unknown); ", index);
-		break;
+		case -1:
+			fprintf(stderr, "link=%d (Fault); ", index);
+			break;
+		case 0:
+			fprintf(stderr, "link=%d (RTT); ", index);
+			break;
+		case 1:
+			fprintf(stderr, "link=%d (dial-up); ", index);
+			break;
+		case 2:
+			fprintf(stderr, "link=%d (T1); ", index);
+			break;
+		case 3:
+			fprintf(stderr, "link=%d (Enet); ", index);
+			break;
+		case 4:
+			fprintf(stderr, "link=%d (T3); ", index);
+			break;
+		case 5:
+			fprintf(stderr, "link=%d (FastE); ", index);
+			break;
+		case 6:
+			fprintf(stderr, "link=%d (OC-12); ", index);
+			break;
+		case 7:
+			fprintf(stderr, "link=%d (GigE); ", index);
+			break;
+		case 8:
+			fprintf(stderr, "link=%d (OC-48); ", index);
+			break;
+		case 9:
+			fprintf(stderr, "link=%d (10 GigE); ", index);
+			break;
+		case 10:
+			fprintf(stderr, "retransmission; ");
+			break;
+		case 11:
+			fprintf(stderr, "link=%d (unknown); ", index);
+			break;
 	}
 	fprintf(stderr, "packets=%d\n", total);
 	fprintf(stderr, "Running Average = %0.2f Mbps  ", cur->totalspd2);
@@ -313,7 +313,7 @@ void cleanup(int signo) {
  * and calculates the link speed between each packet pair.  It then
  * increments the proper link bin.
  */
-void
+	void
 print_speed(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
 {
 	struct ether_header *enet;
@@ -394,9 +394,9 @@ print_speed(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
 				if (fwd.saddr == current.saddr) {
 #endif
 					if (current.dport == c2sport)
-					vt_calculate_spd(&current, &fwd);
+						vt_calculate_spd(&current, &fwd);
 					else if (current.sport == s2cport)
-					vt_calculate_spd(&current, &fwd);
+						vt_calculate_spd(&current, &fwd);
 				}
 #if defined(AF_INET6)
 				if (rev.saddr[0] == current.saddr[0]) {
@@ -404,9 +404,9 @@ print_speed(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
 					if (rev.saddr == current.saddr) {
 #endif
 						if (current.sport == c2sport)
-						vt_calculate_spd(&current, &rev);
+							vt_calculate_spd(&current, &rev);
 						else if (current.dport == s2cport)
-						vt_calculate_spd(&current, &rev);
+							vt_calculate_spd(&current, &rev);
 					}
 #if defined(AF_INET6)
 				}
@@ -463,157 +463,157 @@ print_speed(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
 							(fwd.saddr[2] == current.saddr[2]) &&
 							(fwd.saddr[3] == current.saddr[3])) {
 						if (current.dport == c2sport)
-						vt_calculate_spd(&current, &fwd);
+							vt_calculate_spd(&current, &fwd);
 						else if (current.sport == s2cport)
-						vt_calculate_spd(&current, &fwd);
+							vt_calculate_spd(&current, &fwd);
 					}
 					if ((rev.saddr[0] == current.saddr[0]) &&
 							(rev.saddr[1] == current.saddr[1]) &&
 							(rev.saddr[2] == current.saddr[2]) &&
 							(rev.saddr[3] == current.saddr[3])) {
 						if (current.sport == c2sport)
-						vt_calculate_spd(&current, &rev);
+							vt_calculate_spd(&current, &rev);
 						else if (current.dport == s2cport)
-						vt_calculate_spd(&current, &rev);
+							vt_calculate_spd(&current, &rev);
 					}
 				}
 #endif
 			}
 #endif
 
-int main(int argc, char **argv) {
+			int main(int argc, char **argv) {
 
-	char *read_file, *cmdbuf, *device;
+				char *read_file, *cmdbuf, *device;
 #ifdef HAVE_LIBPCAP
-	pcap_handler printer;
-	u_char * pcap_userdata = NULL;
-	struct bpf_program fcode;
-	char errbuf[PCAP_ERRBUF_SIZE];
+				pcap_handler printer;
+				u_char * pcap_userdata = NULL;
+				struct bpf_program fcode;
+				char errbuf[PCAP_ERRBUF_SIZE];
 #endif
-	int cnt, pflag = 0, debug = 0, c;
-	struct sigaction new;
-
-	read_file = NULL;
-	device = NULL;
-	cnt = -1; /* read forever, or until end of file */
-	while ((c = getopt_long(argc, argv, "c:df:hi:l:v", long_options, 0)) != -1) {
-		switch (c) {
-		case 'c':
-			cnt = atoi(optarg);
-			break;
-		case 'd':
-			debug++;
-			break;
-		case 'f':
-			read_file = optarg;
-			break;
-		case 'i':
-			device = optarg;
-			break;
-		case 'h':
+				int cnt, pflag = 0, debug = 0, c;
+				struct sigaction new;
+
+				read_file = NULL;
+				device = NULL;
+				cnt = -1; /* read forever, or until end of file */
+				while ((c = getopt_long(argc, argv, "c:df:hi:l:v", long_options, 0)) != -1) {
+					switch (c) {
+						case 'c':
+							cnt = atoi(optarg);
+							break;
+						case 'd':
+							debug++;
+							break;
+						case 'f':
+							read_file = optarg;
+							break;
+						case 'i':
+							device = optarg;
+							break;
+						case 'h':
 #ifdef HAVE_LIBPCAP
-			vt_long_usage("ANL/Internet2 NDT version " VERSION " (viewtrace)");
+							vt_long_usage("ANL/Internet2 NDT version " VERSION " (viewtrace)");
 #else
-			vt_long_usage("ANL/Internet2 NDT version " VERSION " (viewtrace) [missing pcap library]");
+							vt_long_usage("ANL/Internet2 NDT version " VERSION " (viewtrace) [missing pcap library]");
 #endif
-			break;
-		case 'v':
+							break;
+						case 'v':
 #ifdef HAVE_LIBPCAP
-			printf("ANL/Internet2 NDT version %s (viewtrace)\n", VERSION);
+							printf("ANL/Internet2 NDT version %s (viewtrace)\n", VERSION);
 #else
-			printf(
-					"ANL/Internet2 NDT version %s (viewtrace) [missing pcap library]\n",
-					VERSION);
+							printf(
+									"ANL/Internet2 NDT version %s (viewtrace) [missing pcap library]\n",
+									VERSION);
 #endif
-			exit(0);
-			break;
-		case 303:
-			if (check_int(optarg, &c2sport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200,
-						"Invalid C2S throughput test port number: %s", optarg);
-				short_usage(argv[0], tmpText);
-			}
-			break;
-		case 304:
-			if (check_int(optarg, &s2cport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200,
-						"Invalid S2C throughput test port number: %s", optarg);
-				short_usage(argv[0], tmpText);
-			}
-			break;
-		case '?':
-			short_usage(argv[0], "");
-			break;
-		}
-	}
+							exit(0);
+							break;
+						case 303:
+							if (check_int(optarg, &c2sport)) {
+								char tmpText[200];
+								snprintf(tmpText, 200,
+										"Invalid C2S throughput test port number: %s", optarg);
+								short_usage(argv[0], tmpText);
+							}
+							break;
+						case 304:
+							if (check_int(optarg, &s2cport)) {
+								char tmpText[200];
+								snprintf(tmpText, 200,
+										"Invalid S2C throughput test port number: %s", optarg);
+								short_usage(argv[0], tmpText);
+							}
+							break;
+						case '?':
+							short_usage(argv[0], "");
+							break;
+					}
+				}
 
-	if (optind < argc) {
-		short_usage(argv[0], "Unrecognized non-option elements");
-	}
+				if (optind < argc) {
+					short_usage(argv[0], "Unrecognized non-option elements");
+				}
 
-	log_init(argv[0], debug);
+				log_init(argv[0], debug);
 
 #ifdef HAVE_LIBPCAP
-	init_vars(&fwd);
-	init_vars(&rev);
-
-	if (read_file == NULL) {
-		if (device == NULL) {
-			device = pcap_lookupdev(errbuf);
-			if (device == NULL) {
-				fprintf(stderr, "pcap_lookupdev failed: %s\n", errbuf);
-				exit (-1);
-			}
-		}
-		if ((pd = pcap_open_live(device, 68, !pflag, 1000, errbuf)) == NULL) {
-			fprintf(stderr, "pcap_open_live failed: %s\n", errbuf);
-			exit (-9);
-		}
-		memset(&new, 0, sizeof(new));
-		new.sa_handler = cleanup;
-		sigaction(SIGTERM, &new, NULL);
-		sigaction(SIGINT, &new, NULL);
-		sigaction(SIGALRM, &new, NULL);
+				init_vars(&fwd);
+				init_vars(&rev);
+
+				if (read_file == NULL) {
+					if (device == NULL) {
+						device = pcap_lookupdev(errbuf);
+						if (device == NULL) {
+							fprintf(stderr, "pcap_lookupdev failed: %s\n", errbuf);
+							exit (-1);
+						}
+					}
+					if ((pd = pcap_open_live(device, 68, !pflag, 1000, errbuf)) == NULL) {
+						fprintf(stderr, "pcap_open_live failed: %s\n", errbuf);
+						exit (-9);
+					}
+					memset(&new, 0, sizeof(new));
+					new.sa_handler = cleanup;
+					sigaction(SIGTERM, &new, NULL);
+					sigaction(SIGINT, &new, NULL);
+					sigaction(SIGALRM, &new, NULL);
 
-	}
-	else {
-		if ((pd = pcap_open_offline(read_file, errbuf)) == NULL) {
-			fprintf(stderr, "pcap_open_offline failed: %s\n", errbuf);
-			exit (-2);
-		}
-	}
+				}
+				else {
+					if ((pd = pcap_open_offline(read_file, errbuf)) == NULL) {
+						fprintf(stderr, "pcap_open_offline failed: %s\n", errbuf);
+						exit (-2);
+					}
+				}
 
-	cmdbuf = copy_argv(&argv[optind]);
+				cmdbuf = copy_argv(&argv[optind]);
 
-	if (pcap_compile(pd, &fcode, cmdbuf, 0, 0xFFFFFF00) < 0) {
-		fprintf(stderr, "pcap_compile failed %s\n", pcap_geterr(pd));
-		exit(-2);
-	}
+				if (pcap_compile(pd, &fcode, cmdbuf, 0, 0xFFFFFF00) < 0) {
+					fprintf(stderr, "pcap_compile failed %s\n", pcap_geterr(pd));
+					exit(-2);
+				}
 
-	if (pcap_setfilter(pd, &fcode) < 0) {
-		fprintf(stderr, "pcap_setfiler failed %s\n", pcap_geterr(pd));
-		exit (-2);
-	}
+				if (pcap_setfilter(pd, &fcode) < 0) {
+					fprintf(stderr, "pcap_setfiler failed %s\n", pcap_geterr(pd));
+					exit (-2);
+				}
 
-	printer = (pcap_handler) print_speed;
-	if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) {
-		fprintf(stderr, "pcap_loop failed %s\n", pcap_geterr(pd));
-		exit(-2);
-	}
-	if (fwd.sport == s2cport) {
-		vt_print_bins(&rev);
-		vt_print_bins(&fwd);
-	} else {
-		vt_print_bins(&fwd);
-		vt_print_bins(&rev);
-	}
-	pcap_close(pd);
+				printer = (pcap_handler) print_speed;
+				if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) {
+					fprintf(stderr, "pcap_loop failed %s\n", pcap_geterr(pd));
+					exit(-2);
+				}
+				if (fwd.sport == s2cport) {
+					vt_print_bins(&rev);
+					vt_print_bins(&fwd);
+				} else {
+					vt_print_bins(&fwd);
+					vt_print_bins(&rev);
+				}
+				pcap_close(pd);
 #else
-	log_println(
-			0,
-			"\n!!! In order to use viewtrace utility you have to compile it with the pcap library !!!\n");
+				log_println(
+						0,
+						"\n!!! In order to use viewtrace utility you have to compile it with the pcap library !!!\n");
 #endif
-	return 0;
-}
+				return 0;
+			}
diff --git a/src/web100-admin.c b/src/web100-admin.c
index 31e44e7..b44330f 100644
--- a/src/web100-admin.c
+++ b/src/web100-admin.c
@@ -62,272 +62,272 @@ char *AdminFileName;
  * @return count of variable values read
  */
 int calculate(char now[32], int SumRTT, int CountRTT, int CongestionSignals,
-		int PktsOut, int DupAcksIn, int AckPktsIn, int CurrentMSS,
-		int SndLimTimeRwin, int SndLimTimeCwnd, int SndLimTimeSender,
-		int MaxRwinRcvd, int CurrentCwnd, int Sndbuf, int DataBytesOut,
-		int mismatch, int bad_cable, int c2sspd, int s2cspd,
-		int c2s_linkspeed_data, int s2c_linkspeed_ack, int view_flag) {
-
-	int congestion2 = 0, i;
-	static int totalcnt;
-	double rttsec;
-	double rwintime=0, cwndtime=0, sendtime=0;
-	int totaltime=0;
-	char view_string[256], *str, tmpstr[32];
-	FILE * fp;
-
-	if (view_flag == 1) {
-		fp = fopen("/tmp/view.string", "r");
-		fgets(view_string, 256, fp);
-		log_println(3, "View_string=%s", view_string);
-		str = view_string;
-		sscanf(str, "%[^,]s", tmpstr);
-		maxc2sspd = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		minc2sspd = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		maxs2cspd = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		mins2cspd = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		totalcnt = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		totmismatch = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		totbad_cable = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[0] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[1] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[2] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[3] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[4] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[5] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[6] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[7] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[8] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[9] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[10] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[11] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[12] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[13] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[14] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		count[15] = atoi(tmpstr);
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		strlcpy(maxdate, tmpstr, sizeof(maxdate));
-
-		str = strchr(str, ',') + 1;
-		sscanf(str, "%[^,]s", tmpstr);
-		strlcpy(mindate, tmpstr, sizeof(mindate));
-
-		for (i = 0; i < strlen(mindate); i++)
-			if (mindate[i] == '\n')
-				break;
-		mindate[i] = '\0';
-
-		log_println(1, "Updating admin_view variables: Total count = %d",
-				totalcnt);
-
-		fclose(fp);
-	}
-
-	// print details about bottleneck link's speed
-	switch (c2s_linkspeed_data) {
-	case DATA_RATE_INSUFFICIENT_DATA:
-		snprintf(btlneck, sizeof(btlneck), "Insufficent Data");
-		break;
-	case DATA_RATE_SYSTEM_FAULT:
-		snprintf(btlneck, sizeof(btlneck), "System Fault");
-		break;
-	case DATA_RATE_RTT:
-		snprintf(btlneck, sizeof(btlneck), "Round Trip Time");
-		break;
-	case DATA_RATE_DIAL_UP:
-		snprintf(btlneck, sizeof(btlneck), "Dial-up modem");
-		break;
-	case DATA_RATE_T1:
-		if (((float) c2sspd / (float) s2cspd > .8)
-				&& ((float) c2sspd / (float) s2cspd < 1.2) && (c2sspd > 1000))
-			snprintf(btlneck, sizeof(btlneck), "T1 subnet");
-		else {
-			if (s2c_linkspeed_ack == 3)
-				snprintf(btlneck, sizeof(btlneck), "Cable Modem");
-			else
-				snprintf(btlneck, sizeof(btlneck), "DSL");
-		}
-		break;
-	case DATA_RATE_ETHERNET:
-		snprintf(btlneck, sizeof(btlneck), "Ethernet");
-		break;
-	case DATA_RATE_T3:
-		snprintf(btlneck, sizeof(btlneck), "T3/DS-3");
-		break;
-	case DATA_RATE_FAST_ETHERNET:
-		snprintf(btlneck, sizeof(btlneck), "FastEthernet");
-		break;
-	case DATA_RATE_OC_12:
-		snprintf(btlneck, sizeof(btlneck), "OC-12");
-		break;
-	case DATA_RATE_GIGABIT_ETHERNET:
-		snprintf(btlneck, sizeof(btlneck), "Gigabit Ethernet");
-		break;
-	case DATA_RATE_OC_48:
-		snprintf(btlneck, sizeof(btlneck), "OC-48");
-		break;
-	case DATA_RATE_10G_ETHERNET:
-		snprintf(btlneck, sizeof(btlneck), "10 Gigabit Enet");
-		break;
-	case DATA_RATE_RETRANSMISSIONS:
-		snprintf(btlneck, sizeof(btlneck), "Retransmissions");
-	}
-
-	/* Calculate some values */
-	strlcpy(date, now, sizeof(date));
-	// Calculate average round trip time and convert to seconds
-	rttsec = calc_avg_rtt(SumRTT, CountRTT, &avgrtt);
-	loss2 = (double) CongestionSignals / PktsOut;
-	if (loss2 == 0)
-		loss2 = .000001; /* set to 10^-6 for now */
-
-	oo_order = calc_packets_outoforder(DupAcksIn, AckPktsIn);
-
-	bw_theortcl = calc_max_theoretical_throughput(CurrentMSS, rttsec, loss2);
-
-	totaltime = calc_totaltesttime(SndLimTimeRwin, SndLimTimeCwnd,
-			SndLimTimeSender);
-	log_println(3, "totaltime=%d, sndLim %d", totaltime, SndLimTimeRwin);
-	// time spent being send-limited due to client's recv window
-	rwintime = calc_sendlimited_rcvrfault(SndLimTimeRwin, totaltime);
-	log_println(3, "rwintime=%f", rwintime);
-
-	log_println(3, "before calling cwndtime cal. %d,%d", SndLimTimeCwnd, totaltime);
-	// time spent in being send-limited due to congestion window
-	cwndtime = calc_sendlimited_cong(SndLimTimeCwnd, totaltime);
-	log_println(3, "cwndtime=%f", cwndtime);
-	// time spent in being send-limited due to own fault
-	sendtime = calc_sendlimited_sndrfault(SndLimTimeSender, totaltime);
-	timesec = totaltime / MEGA; // total time in microsecs
-
-	// calculate receive buffer delay, send buffer delay and congestion window delays
-	recvbwd = ((MaxRwinRcvd * 8) / avgrtt) / 1000;
-	cwndbwd = ((CurrentCwnd * 8) / avgrtt) / 1000;
-	sendbwd = ((Sndbuf * 8) / avgrtt) / 1000;
-
-	// this is different from congestion window heuristic, but seems unused
-	if ((cwndtime > .02) && (mismatch == 0) && (cwndbwd < recvbwd))
-		congestion2 = 1;
-
-	// if no web100 variables were read from the file, then assign values
-	if (totalcnt == 0) {
-		minc2sspd = c2sspd;
-		mins2cspd = s2cspd;
-		maxc2sspd = c2sspd;
-		maxs2cspd = s2cspd;
-		strlcpy(startdate, date, sizeof(startdate));
-		strlcpy(maxdate, date, sizeof(maxdate));
-		strlcpy(mindate, date, sizeof(mindate));
-	}
-
-	// assign max/min values of speeds based on real read values
-	if (c2sspd > maxc2sspd) {
-		maxc2sspd = c2sspd;
-		strlcpy(maxdate, date, sizeof(maxdate));
-	}
-	if (s2cspd > maxs2cspd) {
-		maxs2cspd = s2cspd;
-		strlcpy(maxdate, date, sizeof(maxdate));
-	}
-	if (c2sspd < minc2sspd) {
-		minc2sspd = c2sspd;
-		strlcpy(mindate, date, sizeof(mindate));
-
-	}
-	if (s2cspd < mins2cspd) {
-		mins2cspd = s2cspd;
-		strlcpy(mindate, date, sizeof(mindate));
-	}
-
-	log_println(
-			1,
-			"Initial counter Values Totalcnt = %d, Total Mismatch = %d, Total Bad Cables = %d",
-			totalcnt, totmismatch, totbad_cable);
-	totalcnt++;
-	count[c2s_linkspeed_data + 1]++;
-	if (mismatch > 0)
-		totmismatch++;
-	if (bad_cable == 1)
-		totbad_cable++;
-	log_println(
-			1,
-			"Updated counter values Totalcnt = %d, Total Mismatch = %d, Total Bad Cables = %d",
-			totalcnt, totmismatch, totbad_cable);
-	log_println(
-			1,
-			"Individual counts = [%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d]",
-			count[0], count[1], count[2], count[3], count[4], count[5],
-			count[6], count[7], count[8], count[9], count[10], count[11],
-			count[12], count[13], count[14], count[15]);
-	return (totalcnt);
+              int PktsOut, int DupAcksIn, int AckPktsIn, int CurrentMSS,
+              int SndLimTimeRwin, int SndLimTimeCwnd, int SndLimTimeSender,
+              int MaxRwinRcvd, int CurrentCwnd, int Sndbuf, int DataBytesOut,
+              int mismatch, int bad_cable, int c2sspd, int s2cspd,
+              int c2s_linkspeed_data, int s2c_linkspeed_ack, int view_flag) {
+
+  int congestion2 = 0, i;
+  static int totalcnt;
+  double rttsec;
+  double rwintime=0, cwndtime=0, sendtime=0;
+  int totaltime=0;
+  char view_string[256], *str, tmpstr[32];
+  FILE * fp;
+
+  if (view_flag == 1) {
+    fp = fopen("/tmp/view.string", "r");
+    fgets(view_string, 256, fp);
+    log_println(3, "View_string=%s", view_string);
+    str = view_string;
+    sscanf(str, "%[^,]s", tmpstr);
+    maxc2sspd = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    minc2sspd = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    maxs2cspd = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    mins2cspd = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    totalcnt = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    totmismatch = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    totbad_cable = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[0] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[1] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[2] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[3] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[4] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[5] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[6] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[7] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[8] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[9] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[10] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[11] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[12] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[13] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[14] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    count[15] = atoi(tmpstr);
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    strlcpy(maxdate, tmpstr, sizeof(maxdate));
+
+    str = strchr(str, ',') + 1;
+    sscanf(str, "%[^,]s", tmpstr);
+    strlcpy(mindate, tmpstr, sizeof(mindate));
+
+    for (i = 0; i < strlen(mindate); i++)
+      if (mindate[i] == '\n')
+        break;
+    mindate[i] = '\0';
+
+    log_println(1, "Updating admin_view variables: Total count = %d",
+                totalcnt);
+
+    fclose(fp);
+  }
+
+  // print details about bottleneck link's speed
+  switch (c2s_linkspeed_data) {
+    case DATA_RATE_INSUFFICIENT_DATA:
+      snprintf(btlneck, sizeof(btlneck), "Insufficent Data");
+      break;
+    case DATA_RATE_SYSTEM_FAULT:
+      snprintf(btlneck, sizeof(btlneck), "System Fault");
+      break;
+    case DATA_RATE_RTT:
+      snprintf(btlneck, sizeof(btlneck), "Round Trip Time");
+      break;
+    case DATA_RATE_DIAL_UP:
+      snprintf(btlneck, sizeof(btlneck), "Dial-up modem");
+      break;
+    case DATA_RATE_T1:
+      if (((float) c2sspd / (float) s2cspd > .8)
+          && ((float) c2sspd / (float) s2cspd < 1.2) && (c2sspd > 1000))
+        snprintf(btlneck, sizeof(btlneck), "T1 subnet");
+      else {
+        if (s2c_linkspeed_ack == 3)
+          snprintf(btlneck, sizeof(btlneck), "Cable Modem");
+        else
+          snprintf(btlneck, sizeof(btlneck), "DSL");
+      }
+      break;
+    case DATA_RATE_ETHERNET:
+      snprintf(btlneck, sizeof(btlneck), "Ethernet");
+      break;
+    case DATA_RATE_T3:
+      snprintf(btlneck, sizeof(btlneck), "T3/DS-3");
+      break;
+    case DATA_RATE_FAST_ETHERNET:
+      snprintf(btlneck, sizeof(btlneck), "FastEthernet");
+      break;
+    case DATA_RATE_OC_12:
+      snprintf(btlneck, sizeof(btlneck), "OC-12");
+      break;
+    case DATA_RATE_GIGABIT_ETHERNET:
+      snprintf(btlneck, sizeof(btlneck), "Gigabit Ethernet");
+      break;
+    case DATA_RATE_OC_48:
+      snprintf(btlneck, sizeof(btlneck), "OC-48");
+      break;
+    case DATA_RATE_10G_ETHERNET:
+      snprintf(btlneck, sizeof(btlneck), "10 Gigabit Enet");
+      break;
+    case DATA_RATE_RETRANSMISSIONS:
+      snprintf(btlneck, sizeof(btlneck), "Retransmissions");
+  }
+
+  /* Calculate some values */
+  strlcpy(date, now, sizeof(date));
+  // Calculate average round trip time and convert to seconds
+  rttsec = calc_avg_rtt(SumRTT, CountRTT, &avgrtt);
+  loss2 = (double) CongestionSignals / PktsOut;
+  if (loss2 == 0)
+    loss2 = .000001; /* set to 10^-6 for now */
+
+  oo_order = calc_packets_outoforder(DupAcksIn, AckPktsIn);
+
+  bw_theortcl = calc_max_theoretical_throughput(CurrentMSS, rttsec, loss2);
+
+  totaltime = calc_totaltesttime(SndLimTimeRwin, SndLimTimeCwnd,
+                                 SndLimTimeSender);
+  log_println(3, "totaltime=%d, sndLim %d", totaltime, SndLimTimeRwin);
+  // time spent being send-limited due to client's recv window
+  rwintime = calc_sendlimited_rcvrfault(SndLimTimeRwin, totaltime);
+  log_println(3, "rwintime=%f", rwintime);
+
+  log_println(3, "before calling cwndtime cal. %d,%d", SndLimTimeCwnd, totaltime);
+  // time spent in being send-limited due to congestion window
+  cwndtime = calc_sendlimited_cong(SndLimTimeCwnd, totaltime);
+  log_println(3, "cwndtime=%f", cwndtime);
+  // time spent in being send-limited due to own fault
+  sendtime = calc_sendlimited_sndrfault(SndLimTimeSender, totaltime);
+  timesec = totaltime / MEGA; // total time in microsecs
+
+  // calculate receive buffer delay, send buffer delay and congestion window delays
+  recvbwd = ((MaxRwinRcvd * 8) / avgrtt) / 1000;
+  cwndbwd = ((CurrentCwnd * 8) / avgrtt) / 1000;
+  sendbwd = ((Sndbuf * 8) / avgrtt) / 1000;
+
+  // this is different from congestion window heuristic, but seems unused
+  if ((cwndtime > .02) && (mismatch == 0) && (cwndbwd < recvbwd))
+    congestion2 = 1;
+
+  // if no web100 variables were read from the file, then assign values
+  if (totalcnt == 0) {
+    minc2sspd = c2sspd;
+    mins2cspd = s2cspd;
+    maxc2sspd = c2sspd;
+    maxs2cspd = s2cspd;
+    strlcpy(startdate, date, sizeof(startdate));
+    strlcpy(maxdate, date, sizeof(maxdate));
+    strlcpy(mindate, date, sizeof(mindate));
+  }
+
+  // assign max/min values of speeds based on real read values
+  if (c2sspd > maxc2sspd) {
+    maxc2sspd = c2sspd;
+    strlcpy(maxdate, date, sizeof(maxdate));
+  }
+  if (s2cspd > maxs2cspd) {
+    maxs2cspd = s2cspd;
+    strlcpy(maxdate, date, sizeof(maxdate));
+  }
+  if (c2sspd < minc2sspd) {
+    minc2sspd = c2sspd;
+    strlcpy(mindate, date, sizeof(mindate));
+
+  }
+  if (s2cspd < mins2cspd) {
+    mins2cspd = s2cspd;
+    strlcpy(mindate, date, sizeof(mindate));
+  }
+
+  log_println(
+      1,
+      "Initial counter Values Totalcnt = %d, Total Mismatch = %d, Total Bad Cables = %d",
+      totalcnt, totmismatch, totbad_cable);
+  totalcnt++;
+  count[c2s_linkspeed_data + 1]++;
+  if (mismatch > 0)
+    totmismatch++;
+  if (bad_cable == 1)
+    totbad_cable++;
+  log_println(
+      1,
+      "Updated counter values Totalcnt = %d, Total Mismatch = %d, Total Bad Cables = %d",
+      totalcnt, totmismatch, totbad_cable);
+  log_println(
+      1,
+      "Individual counts = [%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d]",
+      count[0], count[1], count[2], count[3], count[4], count[5],
+      count[6], count[7], count[8], count[9], count[10], count[11],
+      count[12], count[13], count[14], count[15]);
+  return (totalcnt);
 }
 
 /**
@@ -348,224 +348,224 @@ int calculate(char now[32], int SumRTT, int CountRTT, int CongestionSignals,
  * @param refresh time in seconds after which to refresh page
  */
 void gen_html(int c2sspd, int s2cspd, int MinRTT, int PktsRetrans, int Timeouts,
-		int Sndbuf, int MaxRwinRcvd, int CurrentCwnd, int mismatch,
-		int bad_cable, int totalcnt, int refresh) {
-	FILE * fp;
-	char view_string[256], tmpstr[256];
-	int i;
-	struct flock lock;
-
-	fp = fopen(AdminFileName, "w");
-	if (fp == NULL) {
-		log_println(1, "Cannot open file for the admin web page...");
-		return;
-	}
-	/* generate an HTML page for display.  */
-	fprintf(
-			fp,
-			"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
-	fprintf(fp, "<html> <head> <title>NDT server Admin Page</title>\n");
-	fprintf(fp,
-			"<meta http-equiv=\"refresh\" content=\"%d; url="ADMINFILE"\">\n",
-			refresh);
-	fprintf(fp, "<meta http-equiv=\"Content-Language\" content=\"en\">\n");
-	fprintf(
-			fp,
-			"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n");
-	fprintf(fp, "</head>\n");
-
-	/* First build current results table */
-	fprintf(fp, "<table border>\n  <tr>\n ");
-	fprintf(
-			fp,
-			"    <th colspan=8><font size=\"+1\">NDT Usage Statistics -- Current Test Results\n");
-	fprintf(fp, "    </font></tr>\n");
-	fprintf(
-			fp,
-			"  <tr>\n    <th>Date/Time\n    <th>Total Tests\n    <th rowspan=6>\n");
-	fprintf(
-			fp,
-			"    <th>Bottleneck Link\n    <th>Theoritical Limit\n    <th rowspan=6>\n");
-	fprintf(fp, "    <th>C2S Speed\n    <th>S2C Speed\n  </tr>\n");
-	fprintf(
-			fp,
-			"  <tr>\n    <td align=right>%s\n    <td align=right>%d\n    <td align=right>%s\n",
-			date, totalcnt, btlneck);
-	if (bw_theortcl > 1)
-		fprintf(fp, "    <td align=right>%0.2f Mbps\n", bw_theortcl);
-	else
-		fprintf(fp, "    <td align=right>%0.2f kbps\n", bw_theortcl * 1000);
-	if (c2sspd > 1000)
-		fprintf(
-				fp,
-				"    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
-				(float) c2sspd / 1000, (float) s2cspd / 1000);
-	else
-		fprintf(fp,
-				"    <td align=right>%d kbps\n    <td align=right>%d kbps, ",
-				c2sspd, s2cspd);
-	fprintf(fp, "  </tr>\n  <tr>\n    <th>Packet Loss\n    <th>Average RTT\n");
-	fprintf(fp,
-			"    <th>Mininum RTT\n    <th>Retrans/sec\n    <th>Timeouts/sec\n");
-	fprintf(fp, "    <th>%% Out-of-Order\n  </tr>\n  <tr>\n");
-	if (loss2 == .000001)
-		fprintf(
-				fp,
-				"    <td align=right>None\n    <td align=right>%0.2f msec\n    <td align=right>%d msec\n",
-				avgrtt, MinRTT);
-	else
-		fprintf(
-				fp,
-				"    <td align=right>%0.4f%%\n    <td align=right>%0.2f msec\n    <td align=right>%d msec\n",
-				loss2 * 100, avgrtt, MinRTT);
-	fprintf(
-			fp,
-			"    <td align=right>%0.2f\n    <td align=right>%0.2f\n    <td align=right>%0.2f\n  </tr>\n",
-			(float) PktsRetrans / timesec, (float) Timeouts / timesec,
-			oo_order * 100);
-	fprintf(fp, "  <tr>\n    <th>Send Buffer\n    <th>BW*Delay\n");
-	fprintf(fp, "    <th>Receive Buffer\n    <th>BW*Delay\n");
-	fprintf(fp, "    <th>Congestion Window\n    <th>BW*Delay\n  </tr>\n");
-	fprintf(
-			fp,
-			"  <tr>\n    <td align=right>%d Bytes\n    <td align=right>%0.2f Mbps\n",
-			Sndbuf, sendbwd);
-	fprintf(fp,
-			"    <td align=right>%d Bytes\n    <td align=right>%0.2f Mbps\n",
-			MaxRwinRcvd, recvbwd);
-	fprintf(fp,
-			"    <td align=right>%d Bytes\n    <td align=right>%0.2f Mbps\n",
-			CurrentCwnd, cwndbwd);
-	fprintf(fp, "  </tr>\n</table>\n\n");
-
-	fprintf(fp, "<applet code=Admin.class\n  width=600 height=400>\n");
-	fprintf(fp, "  <PARAM NAME=\"Fault\" VALUE=\"%d\">\n", count[0]);
-	fprintf(fp, "  <PARAM NAME=\"RTT\" VALUE=\"%d\">\n", count[1]);
-	fprintf(fp, "  <PARAM NAME=\"Dial-up\" VALUE=\"%d\">\n", count[2]);
-	fprintf(fp, "  <PARAM NAME=\"T1\" VALUE=\"%d\">\n", count[3]);
-	fprintf(fp, "  <PARAM NAME=\"Enet\" VALUE=\"%d\">\n", count[4]);
-	fprintf(fp, "  <PARAM NAME=\"T3\" VALUE=\"%d\">\n", count[5]);
-	fprintf(fp, "  <PARAM NAME=\"FastE\" VALUE=\"%d\">\n", count[6]);
-	fprintf(fp, "  <PARAM NAME=\"OC-12\" VALUE=\"%d\">\n", count[7]);
-	fprintf(fp, "  <PARAM NAME=\"GigE\" VALUE=\"%d\">\n", count[8]);
-	fprintf(fp, "  <PARAM NAME=\"OC-48\" VALUE=\"%d\">\n", count[9]);
-	fprintf(fp, "  <PARAM NAME=\"tenGE\" VALUE=\"%d\">\n", count[10]);
-	fprintf(fp, "  <PARAM NAME=\"Total\" VALUE=\"%d\">\n", totalcnt);
-	fprintf(fp, "</applet>\n<br>\n");
-
-	/* Next generate summary table */
-	fprintf(fp, "<table border>\n  <tr>\n");
-	fprintf(fp, "    <th>\n    <th>Date/Time\n    <th rowspan=5>\n");
-	fprintf(fp, "    <th colspan=2>Throughput Summary\n    <th rowspan=5>\n");
-	fprintf(fp,
-			"    <th colspan=2>Configuration Fault Summary\n  </tr>\n  <tr>\n");
-	fprintf(
-			fp,
-			"    <td><b>Log Starts</b>\n    <td align=right>%s\n    <th>Client-to-Server\n",
-			startdate);
-	fprintf(fp, "    <th>Server-to-Client\n    <th>Duplex Mismatch\n");
-	fprintf(fp, "    <th>Excessive Errors\n  </tr>\n");
-	fprintf(fp, "  <tr>\n    <td><b>Current</b>\n    <td align=right>%s\n",
-			date);
-	if (c2sspd > 1000)
-		fprintf(
-				fp,
-				"    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
-				(float) c2sspd / 1000, (float) s2cspd / 1000);
-	else
-		fprintf(fp,
-				"    <td align=right>%d kbps\n    <td align=right>%d kbps, ",
-				c2sspd, s2cspd);
-
-	fprintf(fp,
-			"    <td align=right>%s\n    <td align=right>%s\n  </tr>\n  <tr>\n",
-			mismatch == 1 ? "Yes" : "No", bad_cable == 1 ? "Yes" : "No");
-	fprintf(fp, "    <td><b>Maximum</b>\n    <td align=right>%s\n", maxdate);
-	if (maxc2sspd > 1000)
-		fprintf(
-				fp,
-				"    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
-				(float) maxc2sspd / 1000, (float) maxs2cspd / 1000);
-	else
-		fprintf(fp,
-				"    <td align=right>%d kbps\n    <td align=right>%d kbps, ",
-				maxc2sspd, maxs2cspd);
-	fprintf(
-			fp,
-			"    <td align=right>%d found\n    <td align=right>%d found\n  </tr>\n",
-			totmismatch, totbad_cable);
-	fprintf(fp, "  <tr>\n    <td><b>Minimum</b>\n    <td align=right>%s\n",
-			mindate);
-	if (minc2sspd > 1000)
-		fprintf(
-				fp,
-				"    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
-				(float) minc2sspd / 1000, (float) mins2cspd / 1000);
-	else
-		fprintf(fp,
-				"    <td align=right>%d kbps\n    <td align=right>%d kbps\n",
-				minc2sspd, mins2cspd);
-	fprintf(fp, "    <td>\n    <td>\n  </tr>\n</table>\n");
-
-	fprintf(fp, "<br>\n<hr width=\"100%%\" noShade size=4>\n");
-	fprintf(fp, "<table border>\n  <tr>\n");
-	fprintf(fp, "    <th>\n    <th>Filename\n    <th>Size\n  </tr>\n  <tr>\n");
-	fprintf(fp, "    <td><b>Log</b>\n    <td> %s    <td>\n", get_logfile());
-	{
-		struct stat fstats;
-
-		if (stat(get_logfile(), &fstats) == 0) {
-			char* names[] = { "B", "KB", "MB", "GB" };
-			int idname;
-			double size = fstats.st_size;
-			for (idname = 0; idname < 3; ++idname) {
-				if (size < 1024) {
-					break;
-				}
-				size /= 1024.0;
-			}
-			fprintf(fp, "%.2f %s\n", size, names[idname]);
-		} else {
-			fprintf(fp, "???\n");
-		}
-	}
-	fprintf(fp, "  </tr>\n</table>\n");
-
-	/* now pick up the rest of the descriptive text that goes along with this page.
-	 * instead of burying all the text in this program, just include it from an external
-	 * file.  For now, use the system command to append the text to the just created file.
-	 */
-	fclose(fp);
-	snprintf(tmpstr, sizeof(tmpstr), "/bin/cat %s/admin_description.html >> %s", BASEDIR,
-			AdminFileName);
-	system(tmpstr);
-
-	/* Save the current variables into a file for later use.  These
-	 * variables are updated by each child process at the end of every
-	 * test.  This data must be shared between multiple children.  If
-	 * not, then the admin view page doesn't get update after every 
-	 * test.
-	 */
-	fp = fopen("/tmp/view.string", "w");
-	if (fp == NULL) {
-		return;
-	}
-	lock.l_type = F_WRLCK;
-	i = fcntl(fileno(fp), F_SETLKW, lock);
-	log_println(1, "successfully locked '/tmp/view.string' for updating");
-	snprintf(
-			view_string, sizeof(view_string),
-			"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s,%s",
-			maxc2sspd, minc2sspd, maxs2cspd, mins2cspd, totalcnt, totmismatch,
-			totbad_cable, count[0], count[1], count[2], count[3], count[4],
-			count[5], count[6], count[7], count[8], count[9], count[10],
-			count[11], count[12], count[13], count[14], count[15], maxdate,
-			mindate);
-	log_println(1, "sending '%s' to tmp file", view_string);
-	fprintf(fp, "%s\n", view_string);
-	lock.l_type = F_UNLCK;
-	fcntl(fileno(fp), F_SETLK, lock);
-	fclose(fp);
+              int Sndbuf, int MaxRwinRcvd, int CurrentCwnd, int mismatch,
+              int bad_cable, int totalcnt, int refresh) {
+  FILE * fp;
+  char view_string[256], tmpstr[256];
+  int i;
+  struct flock lock;
+
+  fp = fopen(AdminFileName, "w");
+  if (fp == NULL) {
+    log_println(1, "Cannot open file for the admin web page...");
+    return;
+  }
+  /* generate an HTML page for display.  */
+  fprintf(
+      fp,
+      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
+  fprintf(fp, "<html> <head> <title>NDT server Admin Page</title>\n");
+  fprintf(fp,
+          "<meta http-equiv=\"refresh\" content=\"%d; url="ADMINFILE"\">\n",
+          refresh);
+  fprintf(fp, "<meta http-equiv=\"Content-Language\" content=\"en\">\n");
+  fprintf(
+      fp,
+      "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n");
+  fprintf(fp, "</head>\n");
+
+  /* First build current results table */
+  fprintf(fp, "<table border>\n  <tr>\n ");
+  fprintf(
+      fp,
+      "    <th colspan=8><font size=\"+1\">NDT Usage Statistics -- Current Test Results\n");
+  fprintf(fp, "    </font></tr>\n");
+  fprintf(
+      fp,
+      "  <tr>\n    <th>Date/Time\n    <th>Total Tests\n    <th rowspan=6>\n");
+  fprintf(
+      fp,
+      "    <th>Bottleneck Link\n    <th>Theoritical Limit\n    <th rowspan=6>\n");
+  fprintf(fp, "    <th>C2S Speed\n    <th>S2C Speed\n  </tr>\n");
+  fprintf(
+      fp,
+      "  <tr>\n    <td align=right>%s\n    <td align=right>%d\n    <td align=right>%s\n",
+      date, totalcnt, btlneck);
+  if (bw_theortcl > 1)
+    fprintf(fp, "    <td align=right>%0.2f Mbps\n", bw_theortcl);
+  else
+    fprintf(fp, "    <td align=right>%0.2f kbps\n", bw_theortcl * 1000);
+  if (c2sspd > 1000)
+    fprintf(
+        fp,
+        "    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
+        (float) c2sspd / 1000, (float) s2cspd / 1000);
+  else
+    fprintf(fp,
+            "    <td align=right>%d kbps\n    <td align=right>%d kbps, ",
+            c2sspd, s2cspd);
+  fprintf(fp, "  </tr>\n  <tr>\n    <th>Packet Loss\n    <th>Average RTT\n");
+  fprintf(fp,
+          "    <th>Mininum RTT\n    <th>Retrans/sec\n    <th>Timeouts/sec\n");
+  fprintf(fp, "    <th>%% Out-of-Order\n  </tr>\n  <tr>\n");
+  if (loss2 == .000001)
+    fprintf(
+        fp,
+        "    <td align=right>None\n    <td align=right>%0.2f msec\n    <td align=right>%d msec\n",
+        avgrtt, MinRTT);
+  else
+    fprintf(
+        fp,
+        "    <td align=right>%0.4f%%\n    <td align=right>%0.2f msec\n    <td align=right>%d msec\n",
+        loss2 * 100, avgrtt, MinRTT);
+  fprintf(
+      fp,
+      "    <td align=right>%0.2f\n    <td align=right>%0.2f\n    <td align=right>%0.2f\n  </tr>\n",
+      (float) PktsRetrans / timesec, (float) Timeouts / timesec,
+      oo_order * 100);
+  fprintf(fp, "  <tr>\n    <th>Send Buffer\n    <th>BW*Delay\n");
+  fprintf(fp, "    <th>Receive Buffer\n    <th>BW*Delay\n");
+  fprintf(fp, "    <th>Congestion Window\n    <th>BW*Delay\n  </tr>\n");
+  fprintf(
+      fp,
+      "  <tr>\n    <td align=right>%d Bytes\n    <td align=right>%0.2f Mbps\n",
+      Sndbuf, sendbwd);
+  fprintf(fp,
+          "    <td align=right>%d Bytes\n    <td align=right>%0.2f Mbps\n",
+          MaxRwinRcvd, recvbwd);
+  fprintf(fp,
+          "    <td align=right>%d Bytes\n    <td align=right>%0.2f Mbps\n",
+          CurrentCwnd, cwndbwd);
+  fprintf(fp, "  </tr>\n</table>\n\n");
+
+  fprintf(fp, "<applet code=Admin.class\n  width=600 height=400>\n");
+  fprintf(fp, "  <PARAM NAME=\"Fault\" VALUE=\"%d\">\n", count[0]);
+  fprintf(fp, "  <PARAM NAME=\"RTT\" VALUE=\"%d\">\n", count[1]);
+  fprintf(fp, "  <PARAM NAME=\"Dial-up\" VALUE=\"%d\">\n", count[2]);
+  fprintf(fp, "  <PARAM NAME=\"T1\" VALUE=\"%d\">\n", count[3]);
+  fprintf(fp, "  <PARAM NAME=\"Enet\" VALUE=\"%d\">\n", count[4]);
+  fprintf(fp, "  <PARAM NAME=\"T3\" VALUE=\"%d\">\n", count[5]);
+  fprintf(fp, "  <PARAM NAME=\"FastE\" VALUE=\"%d\">\n", count[6]);
+  fprintf(fp, "  <PARAM NAME=\"OC-12\" VALUE=\"%d\">\n", count[7]);
+  fprintf(fp, "  <PARAM NAME=\"GigE\" VALUE=\"%d\">\n", count[8]);
+  fprintf(fp, "  <PARAM NAME=\"OC-48\" VALUE=\"%d\">\n", count[9]);
+  fprintf(fp, "  <PARAM NAME=\"tenGE\" VALUE=\"%d\">\n", count[10]);
+  fprintf(fp, "  <PARAM NAME=\"Total\" VALUE=\"%d\">\n", totalcnt);
+  fprintf(fp, "</applet>\n<br>\n");
+
+  /* Next generate summary table */
+  fprintf(fp, "<table border>\n  <tr>\n");
+  fprintf(fp, "    <th>\n    <th>Date/Time\n    <th rowspan=5>\n");
+  fprintf(fp, "    <th colspan=2>Throughput Summary\n    <th rowspan=5>\n");
+  fprintf(fp,
+          "    <th colspan=2>Configuration Fault Summary\n  </tr>\n  <tr>\n");
+  fprintf(
+      fp,
+      "    <td><b>Log Starts</b>\n    <td align=right>%s\n    <th>Client-to-Server\n",
+      startdate);
+  fprintf(fp, "    <th>Server-to-Client\n    <th>Duplex Mismatch\n");
+  fprintf(fp, "    <th>Excessive Errors\n  </tr>\n");
+  fprintf(fp, "  <tr>\n    <td><b>Current</b>\n    <td align=right>%s\n",
+          date);
+  if (c2sspd > 1000)
+    fprintf(
+        fp,
+        "    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
+        (float) c2sspd / 1000, (float) s2cspd / 1000);
+  else
+    fprintf(fp,
+            "    <td align=right>%d kbps\n    <td align=right>%d kbps, ",
+            c2sspd, s2cspd);
+
+  fprintf(fp,
+          "    <td align=right>%s\n    <td align=right>%s\n  </tr>\n  <tr>\n",
+          mismatch == 1 ? "Yes" : "No", bad_cable == 1 ? "Yes" : "No");
+  fprintf(fp, "    <td><b>Maximum</b>\n    <td align=right>%s\n", maxdate);
+  if (maxc2sspd > 1000)
+    fprintf(
+        fp,
+        "    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
+        (float) maxc2sspd / 1000, (float) maxs2cspd / 1000);
+  else
+    fprintf(fp,
+            "    <td align=right>%d kbps\n    <td align=right>%d kbps, ",
+            maxc2sspd, maxs2cspd);
+  fprintf(
+      fp,
+      "    <td align=right>%d found\n    <td align=right>%d found\n  </tr>\n",
+      totmismatch, totbad_cable);
+  fprintf(fp, "  <tr>\n    <td><b>Minimum</b>\n    <td align=right>%s\n",
+          mindate);
+  if (minc2sspd > 1000)
+    fprintf(
+        fp,
+        "    <td align=right>%0.2f Mbps\n    <td align=right>%0.2f Mbps\n",
+        (float) minc2sspd / 1000, (float) mins2cspd / 1000);
+  else
+    fprintf(fp,
+            "    <td align=right>%d kbps\n    <td align=right>%d kbps\n",
+            minc2sspd, mins2cspd);
+  fprintf(fp, "    <td>\n    <td>\n  </tr>\n</table>\n");
+
+  fprintf(fp, "<br>\n<hr width=\"100%%\" noShade size=4>\n");
+  fprintf(fp, "<table border>\n  <tr>\n");
+  fprintf(fp, "    <th>\n    <th>Filename\n    <th>Size\n  </tr>\n  <tr>\n");
+  fprintf(fp, "    <td><b>Log</b>\n    <td> %s    <td>\n", get_logfile());
+  {
+    struct stat fstats;
+
+    if (stat(get_logfile(), &fstats) == 0) {
+      char* names[] = { "B", "KB", "MB", "GB" };
+      int idname;
+      double size = fstats.st_size;
+      for (idname = 0; idname < 3; ++idname) {
+        if (size < 1024) {
+          break;
+        }
+        size /= 1024.0;
+      }
+      fprintf(fp, "%.2f %s\n", size, names[idname]);
+    } else {
+      fprintf(fp, "???\n");
+    }
+  }
+  fprintf(fp, "  </tr>\n</table>\n");
+
+  /* now pick up the rest of the descriptive text that goes along with this page.
+   * instead of burying all the text in this program, just include it from an external
+   * file.  For now, use the system command to append the text to the just created file.
+   */
+  fclose(fp);
+  snprintf(tmpstr, sizeof(tmpstr), "/bin/cat %s/admin_description.html >> %s", BASEDIR,
+           AdminFileName);
+  system(tmpstr);
+
+  /* Save the current variables into a file for later use.  These
+   * variables are updated by each child process at the end of every
+   * test.  This data must be shared between multiple children.  If
+   * not, then the admin view page doesn't get update after every 
+   * test.
+   */
+  fp = fopen("/tmp/view.string", "w");
+  if (fp == NULL) {
+    return;
+  }
+  lock.l_type = F_WRLCK;
+  i = fcntl(fileno(fp), F_SETLKW, lock);
+  log_println(1, "successfully locked '/tmp/view.string' for updating");
+  snprintf(
+      view_string, sizeof(view_string),
+      "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s,%s",
+      maxc2sspd, minc2sspd, maxs2cspd, mins2cspd, totalcnt, totmismatch,
+      totbad_cable, count[0], count[1], count[2], count[3], count[4],
+      count[5], count[6], count[7], count[8], count[9], count[10],
+      count[11], count[12], count[13], count[14], count[15], maxdate,
+      mindate);
+  log_println(1, "sending '%s' to tmp file", view_string);
+  fprintf(fp, "%s\n", view_string);
+  lock.l_type = F_UNLCK;
+  fcntl(fileno(fp), F_SETLK, lock);
+  fclose(fp);
 }
 
 /**
@@ -574,215 +574,215 @@ void gen_html(int c2sspd, int s2cspd, int MinRTT, int PktsRetrans, int Timeouts,
  * @param refresh time in seconds after which to refresh page
  */
 void view_init(int refresh) {
-	int Timeouts = 0, SumRTT, CountRTT, MinRTT = 0, PktsRetrans = 0, FastRetran,
-			DataPktsOut;
-	int AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn, MaxRwinRcvd = 0, Sndbuf =
-			0;
-	//int CurrentCwnd = 0, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
- 	//			DataBytesOut;
-	// commenting out lines above to assign values
-	int CurrentCwnd = 0, SndLimTimeRwin=0, SndLimTimeCwnd=0, SndLimTimeSender=0,
- 				DataBytesOut=0;
-
-	int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
-	int CurrentRTO, CurrentRwinRcvd, CongestionSignals, PktsOut = 0;
-	FILE * fp;
-	int c2sspd = 0, s2cspd = 0;
-	char ip_addr2[64], buff[512], *str, tmpstr[32];
-	int link = 0, mismatch = 0, bad_cable = 0, half_duplex = 0, congestion = 0;
-	int c2s_linkspeed_data = 0, c2s_linkspeed_ack, s2c_linkspeed_data,
-			s2c_linkspeed_ack = 0;
-	int totalcnt = 0, view_flag = 0;
-
-	if ((fp = fopen(get_logfile(), "r")) == NULL)
-		return;
-
-	while ((fgets(buff, 512, fp)) != NULL) {
-		log_println(3,"Reading line: %s",buff);
-		if ((str = strchr(buff, ',')) != NULL) {
-			sscanf(buff, "%[^,]s", date);
-			str++;
-			sscanf(str, "%[^,]s", ip_addr2);
-			if ((str = strchr(str, ',')) == NULL)
-				continue;
-			/* skip over s2c cwnd-limited speed value */
-			str++;
-			sscanf(str, "%[^,]s", tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			c2sspd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			s2cspd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			Timeouts = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			SumRTT = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			CountRTT = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			PktsRetrans = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			FastRetran = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			DataPktsOut = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			AckPktsOut = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			CurrentMSS = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			DupAcksIn = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			AckPktsIn = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			MaxRwinRcvd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			Sndbuf = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			CurrentCwnd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			SndLimTimeRwin = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			SndLimTimeCwnd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			SndLimTimeSender = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			DataBytesOut = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			SndLimTransRwin = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			SndLimTransCwnd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			SndLimTransSender = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			MaxSsthresh = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			CurrentRTO = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			CurrentRwinRcvd = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			link = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			mismatch = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			bad_cable = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			half_duplex = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			congestion = atoi(tmpstr);
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				CongestionSignals = -1;
-				goto display;
-			}
-			str += 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			c2s_linkspeed_data = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			c2s_linkspeed_ack = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			s2c_linkspeed_data = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			s2c_linkspeed_ack = atoi(tmpstr);
-
-			str = strchr(str, ',');
-			if (str == NULL) {
-				CongestionSignals = -1;
-				goto display;
-			}
-			str += 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			CongestionSignals = atoi(tmpstr);
-
-			str = strchr(str, ',') + 1;
-			sscanf(str, "%[^,]s", tmpstr);
-			PktsOut = atoi(tmpstr);
-
-			str = strchr(str, ',');
-			if (str == NULL)
-				MinRTT = -1;
-			else {
-				str += 1;
-				sscanf(str, "%[^,]s", tmpstr);
-				MinRTT = atoi(tmpstr);
-			}
-
-			display: log_println(4, "Web100 variables line received\n");
-			totalcnt = calculate(date, SumRTT, CountRTT, CongestionSignals,
-					PktsOut, DupAcksIn, AckPktsIn, CurrentMSS, SndLimTimeRwin,
-					SndLimTimeCwnd, SndLimTimeSender, MaxRwinRcvd, CurrentCwnd,
-					Sndbuf, DataBytesOut, mismatch, bad_cable, c2sspd, s2cspd,
-					c2s_linkspeed_data, s2c_linkspeed_ack, view_flag);
-		}
-
-	}
-	fclose(fp);
-	view_flag = 1;
-	gen_html(c2sspd, s2cspd, MinRTT, PktsRetrans, Timeouts, Sndbuf, MaxRwinRcvd,
-			CurrentCwnd, mismatch, bad_cable, totalcnt, refresh);
+  int Timeouts = 0, SumRTT, CountRTT, MinRTT = 0, PktsRetrans = 0, FastRetran,
+      DataPktsOut;
+  int AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn, MaxRwinRcvd = 0, Sndbuf =
+      0;
+  //int CurrentCwnd = 0, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
+  //			DataBytesOut;
+  // commenting out lines above to assign values
+  int CurrentCwnd = 0, SndLimTimeRwin=0, SndLimTimeCwnd=0, SndLimTimeSender=0,
+      DataBytesOut=0;
+
+  int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
+  int CurrentRTO, CurrentRwinRcvd, CongestionSignals, PktsOut = 0;
+  FILE * fp;
+  int c2sspd = 0, s2cspd = 0;
+  char ip_addr2[64], buff[512], *str, tmpstr[32];
+  int link = 0, mismatch = 0, bad_cable = 0, half_duplex = 0, congestion = 0;
+  int c2s_linkspeed_data = 0, c2s_linkspeed_ack, s2c_linkspeed_data,
+      s2c_linkspeed_ack = 0;
+  int totalcnt = 0, view_flag = 0;
+
+  if ((fp = fopen(get_logfile(), "r")) == NULL)
+    return;
+
+  while ((fgets(buff, 512, fp)) != NULL) {
+    log_println(3,"Reading line: %s",buff);
+    if ((str = strchr(buff, ',')) != NULL) {
+      sscanf(buff, "%[^,]s", date);
+      str++;
+      sscanf(str, "%[^,]s", ip_addr2);
+      if ((str = strchr(str, ',')) == NULL)
+        continue;
+      /* skip over s2c cwnd-limited speed value */
+      str++;
+      sscanf(str, "%[^,]s", tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      c2sspd = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      s2cspd = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      Timeouts = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      SumRTT = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      CountRTT = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      PktsRetrans = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      FastRetran = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      DataPktsOut = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      AckPktsOut = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      CurrentMSS = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      DupAcksIn = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      AckPktsIn = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      MaxRwinRcvd = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      Sndbuf = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      CurrentCwnd = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      SndLimTimeRwin = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      SndLimTimeCwnd = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      SndLimTimeSender = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      DataBytesOut = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      SndLimTransRwin = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      SndLimTransCwnd = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      SndLimTransSender = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      MaxSsthresh = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      CurrentRTO = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      CurrentRwinRcvd = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      link = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      mismatch = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      bad_cable = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      half_duplex = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      congestion = atoi(tmpstr);
+
+      str = strchr(str, ',');
+      if (str == NULL) {
+        CongestionSignals = -1;
+        goto display;
+      }
+      str += 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      c2s_linkspeed_data = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      c2s_linkspeed_ack = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      s2c_linkspeed_data = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      s2c_linkspeed_ack = atoi(tmpstr);
+
+      str = strchr(str, ',');
+      if (str == NULL) {
+        CongestionSignals = -1;
+        goto display;
+      }
+      str += 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      CongestionSignals = atoi(tmpstr);
+
+      str = strchr(str, ',') + 1;
+      sscanf(str, "%[^,]s", tmpstr);
+      PktsOut = atoi(tmpstr);
+
+      str = strchr(str, ',');
+      if (str == NULL)
+        MinRTT = -1;
+      else {
+        str += 1;
+        sscanf(str, "%[^,]s", tmpstr);
+        MinRTT = atoi(tmpstr);
+      }
+
+display: log_println(4, "Web100 variables line received\n");
+         totalcnt = calculate(date, SumRTT, CountRTT, CongestionSignals,
+                              PktsOut, DupAcksIn, AckPktsIn, CurrentMSS, SndLimTimeRwin,
+                              SndLimTimeCwnd, SndLimTimeSender, MaxRwinRcvd, CurrentCwnd,
+                              Sndbuf, DataBytesOut, mismatch, bad_cable, c2sspd, s2cspd,
+                              c2s_linkspeed_data, s2c_linkspeed_ack, view_flag);
+    }
+
+  }
+  fclose(fp);
+  view_flag = 1;
+  gen_html(c2sspd, s2cspd, MinRTT, PktsRetrans, Timeouts, Sndbuf, MaxRwinRcvd,
+           CurrentCwnd, mismatch, bad_cable, totalcnt, refresh);
 }
diff --git a/src/web100-pcap.c b/src/web100-pcap.c
index 96d6418..3453682 100644
--- a/src/web100-pcap.c
+++ b/src/web100-pcap.c
@@ -38,55 +38,55 @@ int ifspeed;
  *
  */
 void get_iflist(void) {
-	/* pcap_addr_t *ifaceAddr; */
-	pcap_if_t *alldevs, *dp;
-	struct ethtool_cmd ecmd;
-	int fd, cnt, i, err;
-	struct ifreq ifr;
-	char errbuf[256];
-
-	cnt = 0;
-	if (pcap_findalldevs(&alldevs, errbuf) == 0) {
-		for (dp = alldevs; dp != NULL; dp = dp->next) {
-			memcpy(iflist.name[cnt++], dp->name, strlen(dp->name));
-		}
-	}
-	// Ethernet related speeds alone "specifically" determined.
-	// Note that it appears that NDT assumes its an ethernet link. But, if ifspeed is not assigned,
-	// a value will be assigned to it in the "calc_linkspeed" method which will still
-	// cause all speed-bins to be looked into (i.e correct results expected).
-	for (i = 0; i < cnt; i++) {
-		if (strncmp((char *) iflist.name[i], "eth", 3) != 0)
-			continue;
-		memset(&ifr, 0, sizeof(ifr));
-		memcpy(ifr.ifr_name, (char *) iflist.name[i], strlen(iflist.name[i]));
-		/* strcpy(ifr.ifr_name, iflist.name[i]); */
-		fd = socket(AF_INET, SOCK_DGRAM, 0);
-		ecmd.cmd = ETHTOOL_GSET;
-		ifr.ifr_data = (caddr_t) & ecmd;
-		err = ioctl(fd, SIOCETHTOOL, &ifr);
-		if (err == 0) {
-			switch (ecmd.speed) {
-			case SPEED_10:
-				iflist.speed[i] = DATA_RATE_ETHERNET;
-				break;
-			case SPEED_100:
-				iflist.speed[i] = DATA_RATE_FAST_ETHERNET;
-				break;
-			case SPEED_1000:
-				iflist.speed[i] = DATA_RATE_GIGABIT_ETHERNET;
-				break;
-			case SPEED_10000:
-				iflist.speed[i] = DATA_RATE_10G_ETHERNET;
-				break;
-			default:
-				iflist.speed[i] = DATA_RATE_RTT;
-			}
-		}
-	}
-	// free list allocated by pcap_findalldevs call
-	if (alldevs != NULL)
-		pcap_freealldevs(alldevs);
+  /* pcap_addr_t *ifaceAddr; */
+  pcap_if_t *alldevs, *dp;
+  struct ethtool_cmd ecmd;
+  int fd, cnt, i, err;
+  struct ifreq ifr;
+  char errbuf[256];
+
+  cnt = 0;
+  if (pcap_findalldevs(&alldevs, errbuf) == 0) {
+    for (dp = alldevs; dp != NULL; dp = dp->next) {
+      memcpy(iflist.name[cnt++], dp->name, strlen(dp->name));
+    }
+  }
+  // Ethernet related speeds alone "specifically" determined.
+  // Note that it appears that NDT assumes its an ethernet link. But, if ifspeed is not assigned,
+  // a value will be assigned to it in the "calc_linkspeed" method which will still
+  // cause all speed-bins to be looked into (i.e correct results expected).
+  for (i = 0; i < cnt; i++) {
+    if (strncmp((char *) iflist.name[i], "eth", 3) != 0)
+      continue;
+    memset(&ifr, 0, sizeof(ifr));
+    memcpy(ifr.ifr_name, (char *) iflist.name[i], strlen(iflist.name[i]));
+    /* strcpy(ifr.ifr_name, iflist.name[i]); */
+    fd = socket(AF_INET, SOCK_DGRAM, 0);
+    ecmd.cmd = ETHTOOL_GSET;
+    ifr.ifr_data = (caddr_t) & ecmd;
+    err = ioctl(fd, SIOCETHTOOL, &ifr);
+    if (err == 0) {
+      switch (ecmd.speed) {
+        case SPEED_10:
+          iflist.speed[i] = DATA_RATE_ETHERNET;
+          break;
+        case SPEED_100:
+          iflist.speed[i] = DATA_RATE_FAST_ETHERNET;
+          break;
+        case SPEED_1000:
+          iflist.speed[i] = DATA_RATE_GIGABIT_ETHERNET;
+          break;
+        case SPEED_10000:
+          iflist.speed[i] = DATA_RATE_10G_ETHERNET;
+          break;
+        default:
+          iflist.speed[i] = DATA_RATE_RTT;
+      }
+    }
+  }
+  // free list allocated by pcap_findalldevs call
+  if (alldevs != NULL)
+    pcap_freealldevs(alldevs);
 }
 
 /** Check signal flags and process them accordingly.
@@ -97,99 +97,99 @@ void get_iflist(void) {
  * 		   0 if no relevant signals were actually received
  */
 int check_signal_flags() {
-	if ((sig1 == 1) || (sig2 == 1)) {
-		log_println(
-				5,
-				"Received SIGUSRx signal terminating data collection loop for pid=%d",
-				getpid());
-		if (sig1 == 1) {
-			log_println(4,
-					"Sending pkt-pair data back to parent on pipe %d, %d",
-					mon_pipe1[0], mon_pipe1[1]);
-			if (get_debuglvl() > 3) {
+  if ((sig1 == 1) || (sig2 == 1)) {
+    log_println(
+        5,
+        "Received SIGUSRx signal terminating data collection loop for pid=%d",
+        getpid());
+    if (sig1 == 1) {
+      log_println(4,
+                  "Sending pkt-pair data back to parent on pipe %d, %d",
+                  mon_pipe1[0], mon_pipe1[1]);
+      if (get_debuglvl() > 3) {
 #ifdef AF_INET6
-				if (fwd.family == 4) {
-					fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
-							fwd.saddr[0], fwd.sport, rev.saddr[0], rev.sport);
+        if (fwd.family == 4) {
+          fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
+                  fwd.saddr[0], fwd.sport, rev.saddr[0], rev.sport);
 #else
-				fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
-						fwd.saddr, fwd.sport, rev.saddr, rev.sport);
+          fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
+                  fwd.saddr, fwd.sport, rev.saddr, rev.sport);
 #endif
 #ifdef AF_INET6
-			}
-			else if (fwd.family == 6) {
-				char str[136];
-				memset(str, 0, 136);
-				inet_ntop(AF_INET6, (void *) fwd.saddr, str, sizeof(str));
-				fprintf(stderr, "fwd.saddr = %s:%d", str, fwd.sport);
-				memset(str, 0, 136);
-				inet_ntop(AF_INET6, (void *) rev.saddr, str, sizeof(str));
-				fprintf(stderr, ", rev.saddr = %s:%d\n", str, rev.sport);
-			}
-			else {
-				fprintf(stderr, "check_signal_flags: Unknown IP family (%d)\n", fwd.family);
-			}
+        }
+        else if (fwd.family == 6) {
+          char str[136];
+          memset(str, 0, 136);
+          inet_ntop(AF_INET6, (void *) fwd.saddr, str, sizeof(str));
+          fprintf(stderr, "fwd.saddr = %s:%d", str, fwd.sport);
+          memset(str, 0, 136);
+          inet_ntop(AF_INET6, (void *) rev.saddr, str, sizeof(str));
+          fprintf(stderr, ", rev.saddr = %s:%d\n", str, rev.sport);
+        }
+        else {
+          fprintf(stderr, "check_signal_flags: Unknown IP family (%d)\n", fwd.family);
+        }
 #endif
-			}
-			print_bins(&fwd, mon_pipe1);
-			usleep(30000); /* wait here 30 msec, for parent to read this data */
-			print_bins(&rev, mon_pipe1);
-			usleep(30000); /* wait here 30 msec, for parent to read this data */
-			if (pd != NULL) {
-                                pcap_breakloop(pd);
-			}
-			if (dumptrace == 1)
-				pcap_dump_close(pdump);
-			sig1 = 2;
-		}
-
-		if (sig2 == 1) {
-			log_println(4,
-					"Sending pkt-pair data back to parent on pipe %d, %d",
-					mon_pipe2[0], mon_pipe2[1]);
-			if (get_debuglvl() > 3) {
+      }
+      print_bins(&fwd, mon_pipe1);
+      usleep(30000); /* wait here 30 msec, for parent to read this data */
+      print_bins(&rev, mon_pipe1);
+      usleep(30000); /* wait here 30 msec, for parent to read this data */
+      if (pd != NULL) {
+        pcap_breakloop(pd);
+      }
+      if (dumptrace == 1)
+        pcap_dump_close(pdump);
+      sig1 = 2;
+    }
+
+    if (sig2 == 1) {
+      log_println(4,
+                  "Sending pkt-pair data back to parent on pipe %d, %d",
+                  mon_pipe2[0], mon_pipe2[1]);
+      if (get_debuglvl() > 3) {
 #ifdef AF_INET6
-				if (fwd.family == 4) {
-					fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
-							fwd.saddr[0], fwd.sport, rev.saddr[0], rev.sport);
+        if (fwd.family == 4) {
+          fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
+                  fwd.saddr[0], fwd.sport, rev.saddr[0], rev.sport);
 #else
-				fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
-						fwd.saddr, fwd.sport, rev.saddr, rev.sport);
+          fprintf(stderr, "fwd.saddr = %x:%d, rev.saddr = %x:%d\n",
+                  fwd.saddr, fwd.sport, rev.saddr, rev.sport);
 #endif
 #ifdef AF_INET6
-			}
-			else if (fwd.family == 6) {
-				char str[136];
-				memset(str, 0, 136);
-				inet_ntop(AF_INET6, (void *) fwd.saddr, str, sizeof(str));
-				fprintf(stderr, "fwd.saddr = %s:%d", str, fwd.sport);
-				memset(str, 0, 136);
-				inet_ntop(AF_INET6, (void *) rev.saddr, str, sizeof(str));
-				fprintf(stderr, ", rev.saddr = %s:%d\n", str, rev.sport);
-			}
-			else {
-				fprintf(stderr, "check_signal_flags: Unknown IP family (%d)\n", fwd.family);
-			}
+        }
+        else if (fwd.family == 6) {
+          char str[136];
+          memset(str, 0, 136);
+          inet_ntop(AF_INET6, (void *) fwd.saddr, str, sizeof(str));
+          fprintf(stderr, "fwd.saddr = %s:%d", str, fwd.sport);
+          memset(str, 0, 136);
+          inet_ntop(AF_INET6, (void *) rev.saddr, str, sizeof(str));
+          fprintf(stderr, ", rev.saddr = %s:%d\n", str, rev.sport);
+        }
+        else {
+          fprintf(stderr, "check_signal_flags: Unknown IP family (%d)\n", fwd.family);
+        }
 #endif
-			}
-			print_bins(&fwd, mon_pipe2);
-			usleep(30000); /* wait here 30 msec, for parent to read this data */
-			print_bins(&rev, mon_pipe2);
-			usleep(30000); /* wait here 30 msec, for parent to read this data */
-			if (pd != NULL) {
-                                pcap_breakloop(pd);
-			}
-			if (dumptrace == 1)
-				pcap_dump_close(pdump);
-			sig2 = 2;
-		}
-		log_println(
-				6,
-				"Finished reading pkt-pair data from network, process %d should terminate now",
-				getpid());
-		return 1;
-	}
-	return 0;
+      }
+      print_bins(&fwd, mon_pipe2);
+      usleep(30000); /* wait here 30 msec, for parent to read this data */
+      print_bins(&rev, mon_pipe2);
+      usleep(30000); /* wait here 30 msec, for parent to read this data */
+      if (pd != NULL) {
+        pcap_breakloop(pd);
+      }
+      if (dumptrace == 1)
+        pcap_dump_close(pdump);
+      sig2 = 2;
+    }
+    log_println(
+        6,
+        "Finished reading pkt-pair data from network, process %d should terminate now",
+        getpid());
+    return 1;
+  }
+  return 0;
 }
 
 /**
@@ -198,29 +198,29 @@ int check_signal_flags() {
  * */
 void init_vars(struct spdpair *cur) {
 
-	int i;
+  int i;
 
-	assert(cur);
+  assert(cur);
 
 #if defined(AF_INET6)
-	memset(cur->saddr, 0, 4);
-	memset(cur->daddr, 0, 4);
+  memset(cur->saddr, 0, 4);
+  memset(cur->daddr, 0, 4);
 #else
-	cur->saddr = 0;
-	cur->daddr = 0;
+  cur->saddr = 0;
+  cur->daddr = 0;
 #endif
-	cur->sport = 0;
-	cur->dport = 0;
-	cur->seq = 0;
-	cur->ack = 0;
-	cur->win = 0;
-	cur->sec = 0;
-	cur->usec = 0;
-	cur->time = 0;
-	cur->totalspd = 0;
-	cur->totalcount = 0;
-	for (i = 0; i < 16; i++)
-		cur->links[i] = 0;
+  cur->sport = 0;
+  cur->dport = 0;
+  cur->seq = 0;
+  cur->ack = 0;
+  cur->win = 0;
+  cur->sec = 0;
+  cur->usec = 0;
+  cur->time = 0;
+  cur->totalspd = 0;
+  cur->totalcount = 0;
+  for (i = 0; i < 16; i++)
+    cur->links[i] = 0;
 }
 
 /**
@@ -231,197 +231,197 @@ void init_vars(struct spdpair *cur) {
  *   */
 void print_bins(struct spdpair *cur, int monitor_pipe[2]) {
 
-	int i, total = 0, max = 0, s, index = -1;
-	char buff[256];
-	int tzoffset = 6;
-	FILE * fp;
-	int j;
-
-	assert(cur);
-
-	/* the tzoffset value is fixed for CST (6), use 5 for CDT.  The code needs to find the
-	 * current timezone and use that value here! */
-	s = (cur->st_sec - (tzoffset * 3600)) % 86400;
-	fp = fopen(get_logfile(), "a");
-	log_print(1, "%02d:%02d:%02d.%06u   ", s / 3600, (s % 3600) / 60, s % 60,
-			cur->st_usec);
-
-	// Get the ifspeed bin with the biggest counter value.
-	//  NDT determines link speed using this
-	for (i = 0; i < 16; i++) {
-		total += cur->links[i];
-		if (cur->links[i] > max) {
-			max = cur->links[i];
-		}
-	}
-	if (get_debuglvl() > 2) {
+  int i, total = 0, max = 0, s, index = -1;
+  char buff[256];
+  int tzoffset = 6;
+  FILE * fp;
+  int j;
+
+  assert(cur);
+
+  /* the tzoffset value is fixed for CST (6), use 5 for CDT.  The code needs to find the
+   * current timezone and use that value here! */
+  s = (cur->st_sec - (tzoffset * 3600)) % 86400;
+  fp = fopen(get_logfile(), "a");
+  log_print(1, "%02d:%02d:%02d.%06u   ", s / 3600, (s % 3600) / 60, s % 60,
+            cur->st_usec);
+
+  // Get the ifspeed bin with the biggest counter value.
+  //  NDT determines link speed using this
+  for (i = 0; i < 16; i++) {
+    total += cur->links[i];
+    if (cur->links[i] > max) {
+      max = cur->links[i];
+    }
+  }
+  if (get_debuglvl() > 2) {
 #ifdef AF_INET6
-		if (cur->family == 4) {
-			if (fp) {
-				fprintf(fp, "%u.%u.%u.%u:%d --> ", (cur->saddr[0] & 0xFF), ((cur->saddr[0] >> 8) & 0xff),
-						((cur->saddr[0] >> 16) & 0xff), (cur->saddr[0] >> 24), cur->sport);
-				fprintf(fp, "%u.%u.%u.%u:%d  ", (cur->daddr[0] & 0xFF), ((cur->daddr[0] >> 8) & 0xff),
-						((cur->daddr[0] >> 16) & 0xff), (cur->daddr[0] >> 24), cur->dport);
-			}
-			log_print(3, "%u.%u.%u.%u:%d --> ", (cur->saddr[0] & 0xFF), ((cur->saddr[0] >> 8) & 0xff),
-					((cur->saddr[0] >> 16) & 0xff), (cur->saddr[0] >> 24), cur->sport);
-			log_print(3, "%u.%u.%u.%u:%d ", (cur->daddr[0] & 0xFF), ((cur->daddr[0] >> 8) & 0xff),
-					((cur->daddr[0] >> 16) & 0xff), (cur->daddr[0] >> 24), cur->dport);
-		}
+    if (cur->family == 4) {
+      if (fp) {
+        fprintf(fp, "%u.%u.%u.%u:%d --> ", (cur->saddr[0] & 0xFF), ((cur->saddr[0] >> 8) & 0xff),
+                ((cur->saddr[0] >> 16) & 0xff), (cur->saddr[0] >> 24), cur->sport);
+        fprintf(fp, "%u.%u.%u.%u:%d  ", (cur->daddr[0] & 0xFF), ((cur->daddr[0] >> 8) & 0xff),
+                ((cur->daddr[0] >> 16) & 0xff), (cur->daddr[0] >> 24), cur->dport);
+      }
+      log_print(3, "%u.%u.%u.%u:%d --> ", (cur->saddr[0] & 0xFF), ((cur->saddr[0] >> 8) & 0xff),
+                ((cur->saddr[0] >> 16) & 0xff), (cur->saddr[0] >> 24), cur->sport);
+      log_print(3, "%u.%u.%u.%u:%d ", (cur->daddr[0] & 0xFF), ((cur->daddr[0] >> 8) & 0xff),
+                ((cur->daddr[0] >> 16) & 0xff), (cur->daddr[0] >> 24), cur->dport);
+    }
 #else
-		if (fp) {
-			fprintf(
-					fp,
-					"%u.%u.%u.%u:%d --> ",
-					(cur->saddr & 0xFF), ((cur->saddr >> 8) & 0xff),
-					((cur->saddr >> 16) & 0xff), (cur->saddr >> 24), cur->sport);
-					fprintf(fp, "%u.%u.%u.%u:%d  ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
-          ((cur->daddr >> 16) & 0xff),  (cur->daddr >> 24), cur->dport);
+    if (fp) {
+      fprintf(
+          fp,
+          "%u.%u.%u.%u:%d --> ",
+          (cur->saddr & 0xFF), ((cur->saddr >> 8) & 0xff),
+          ((cur->saddr >> 16) & 0xff), (cur->saddr >> 24), cur->sport);
+      fprintf(fp, "%u.%u.%u.%u:%d  ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
+              ((cur->daddr >> 16) & 0xff),  (cur->daddr >> 24), cur->dport);
     }
-			log_print(3, "%u.%u.%u.%u:%d --> ", (cur->saddr & 0xFF), ((cur->saddr >> 8) & 0xff),
-					((cur->saddr >> 16) & 0xff), (cur->saddr >> 24), cur->sport);
-			log_print(3, "%u.%u.%u.%u:%d ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
-					((cur->daddr >> 16) & 0xff), (cur->daddr >> 24), cur->dport);
+    log_print(3, "%u.%u.%u.%u:%d --> ", (cur->saddr & 0xFF), ((cur->saddr >> 8) & 0xff),
+              ((cur->saddr >> 16) & 0xff), (cur->saddr >> 24), cur->sport);
+    log_print(3, "%u.%u.%u.%u:%d ", (cur->daddr & 0xFF), ((cur->daddr >> 8) & 0xff),
+              ((cur->daddr >> 16) & 0xff), (cur->daddr >> 24), cur->dport);
 #endif
 #ifdef AF_INET6
-			else {
-				char name[200];
-				socklen_t len;
-				memset(name, 0, 200);
-				len = 199;
-				inet_ntop(AF_INET6, cur->saddr, name, len);
-				if (fp) {
-					fprintf(fp, "%s:%d --> ", name, cur->sport);
-				}
-				log_print(3, "%s:%d --> ", name, cur->sport);
-				memset(name, 0, 200);
-				len = 199;
-				inet_ntop(AF_INET6, cur->daddr, name, len);
-				if (fp) {
-					fprintf(fp, "%s:%d  ", name, cur->dport);
-				}
-				log_print(3, "%s:%d  ", name, cur->dport);
-			}
+    else {
+      char name[200];
+      socklen_t len;
+      memset(name, 0, 200);
+      len = 199;
+      inet_ntop(AF_INET6, cur->saddr, name, len);
+      if (fp) {
+        fprintf(fp, "%s:%d --> ", name, cur->sport);
+      }
+      log_print(3, "%s:%d --> ", name, cur->sport);
+      memset(name, 0, 200);
+      len = 199;
+      inet_ntop(AF_INET6, cur->daddr, name, len);
+      if (fp) {
+        fprintf(fp, "%s:%d  ", name, cur->dport);
+      }
+      log_print(3, "%s:%d  ", name, cur->dport);
+    }
 #endif
-		}
-	// If max speed is 0, then indicate that no data has been collected
-	if (max == 0) {
-		log_println(3, "No data Packets collected");
-		if (get_debuglvl() > 2) {
-			if (fp) {
-				fprintf(fp, "\n\tNo packets collected\n");
-			}
-		}
-		for (i = 0; i < 16; i++)
-			cur->links[i] = -1;
-		index = -1;
-	}
-	log_println(3, "Collected pkt-pair data max = %d", max);
-	if (max == cur->links[8]) {
-		max = 0;
-		for (i = 0; i < 10; i++) {
-			if (max < cur->links[i]) {
-				index = i;
-				max = cur->links[i];
-			}
-		}
-	}
-
-	// print details of link speed found
-	if (fp) {
-		if (get_debuglvl() > 2) {
-			switch (index) {
-			case -1:
-				fprintf(fp, "link=System Fault; ");
-				break;
-			case 0:
-				fprintf(fp, "link=RTT; ");
-				break;
-			case 1:
-				fprintf(fp, "link=dial-up; ");
-				break;
-			case 2:
-				fprintf(fp, "link=T1; ");
-				break;
-			case 3:
-				fprintf(fp, "link=Enet; ");
-				break;
-			case 4:
-				fprintf(fp, "link=T3; ");
-				break;
-			case 5:
-				fprintf(fp, "link=FastE; ");
-				break;
-			case 6:
-				fprintf(fp, "link=OC-12; ");
-				break;
-			case 7:
-				fprintf(fp, "link=GigE; ");
-				break;
-			case 8:
-				fprintf(fp, "link=OC-48; ");
-				break;
-			case 9:
-				fprintf(fp, "link=10 GigE; ");
-				break;
-			case 10:
-				fprintf(fp, "retransmission; ");
-				break;
-			case 11:
-				fprintf(fp, "link=unknown; ");
-				break;
-			}
-
-			// now print values of speeds for various bins found
-			fprintf(fp, "packets=%d\n", total);
-			fprintf(fp, "Running Average = %0.2f Mbps  ", cur->totalspd2);
-			fprintf(fp, "Average speed = %0.2f Mbps\n",
-					cur->totalspd / cur->totalcount);
-			fprintf(fp, "\tT1=%d (%0.2f%%); ", cur->links[2],
-					((float) cur->links[2] * 100 / total));
-			fprintf(fp, "Ethernet=%d (%0.2f%%); ", cur->links[3],
-					((float) cur->links[3] * 100 / total));
-			fprintf(fp, "T3=%d (%0.2f%%); ", cur->links[4],
-					((float) cur->links[4] * 100 / total));
-			fprintf(fp, "FastEthernet=%d (%0.2f%%);\n", cur->links[5],
-					((float) cur->links[5] * 100 / total));
-			fprintf(fp, "OC-12=%d (%0.2f%%); ", cur->links[6],
-					((float) cur->links[6] * 100 / total));
-			fprintf(fp, "\tGigabit Ethernet=%d (%0.2f%%); ", cur->links[7],
-					((float) cur->links[7] * 100 / total));
-			fprintf(fp, "OC-48=%d (%0.2f%%); ", cur->links[8],
-					((float) cur->links[8] * 100 / total));
-			fprintf(fp, "10 Gigabit Enet=%d (%0.2f%%);\n", cur->links[9],
-					((float) cur->links[9] * 100 / total));
-			fprintf(fp, "\tRetransmissions=%d (%0.2f%%); ", cur->links[10],
-					((float) cur->links[10] * 100 / total));
-			fprintf(fp, "Unknown=%d (%0.2f%%);\n", cur->links[11],
-					((float) cur->links[11] * 100 / total));
-		}
-		fclose(fp);
-	}
-
-	// make speed bin available to other processes
-	snprintf(buff,
-			sizeof(buff),
-			"  %d %d %d %d %d %d %d %d %d %d %d %d %0.2f %d %d %d %d %d %d",
-			cur->links[0], cur->links[1], cur->links[2], cur->links[3],
-			cur->links[4], cur->links[5], cur->links[6], cur->links[7],
-			cur->links[8], cur->links[9], cur->links[10], cur->links[11],
-			cur->totalspd2, cur->inc_cnt, cur->dec_cnt, cur->same_cnt,
-			cur->timeout, cur->dupack, ifspeed);
-	for (j = 0; j < 5; j++) {
-		i = write(monitor_pipe[1], buff, strlen(buff));
-		if (i == strlen(buff))
-			break;
-		if ((i == -1) && (errno == EINTR))
-			continue;
-	}
-	log_println(6, "wrote %d bytes: link counters are '%s'", i, buff);
-	log_println(
-			6,
-			"#$#$#$#$ pcap routine says window increases = %d, decreases = %d, no change = %d",
-			cur->inc_cnt, cur->dec_cnt, cur->same_cnt);
+  }
+  // If max speed is 0, then indicate that no data has been collected
+  if (max == 0) {
+    log_println(3, "No data Packets collected");
+    if (get_debuglvl() > 2) {
+      if (fp) {
+        fprintf(fp, "\n\tNo packets collected\n");
+      }
+    }
+    for (i = 0; i < 16; i++)
+      cur->links[i] = -1;
+    index = -1;
+  }
+  log_println(3, "Collected pkt-pair data max = %d", max);
+  if (max == cur->links[8]) {
+    max = 0;
+    for (i = 0; i < 10; i++) {
+      if (max < cur->links[i]) {
+        index = i;
+        max = cur->links[i];
+      }
+    }
+  }
+
+  // print details of link speed found
+  if (fp) {
+    if (get_debuglvl() > 2) {
+      switch (index) {
+        case -1:
+          fprintf(fp, "link=System Fault; ");
+          break;
+        case 0:
+          fprintf(fp, "link=RTT; ");
+          break;
+        case 1:
+          fprintf(fp, "link=dial-up; ");
+          break;
+        case 2:
+          fprintf(fp, "link=T1; ");
+          break;
+        case 3:
+          fprintf(fp, "link=Enet; ");
+          break;
+        case 4:
+          fprintf(fp, "link=T3; ");
+          break;
+        case 5:
+          fprintf(fp, "link=FastE; ");
+          break;
+        case 6:
+          fprintf(fp, "link=OC-12; ");
+          break;
+        case 7:
+          fprintf(fp, "link=GigE; ");
+          break;
+        case 8:
+          fprintf(fp, "link=OC-48; ");
+          break;
+        case 9:
+          fprintf(fp, "link=10 GigE; ");
+          break;
+        case 10:
+          fprintf(fp, "retransmission; ");
+          break;
+        case 11:
+          fprintf(fp, "link=unknown; ");
+          break;
+      }
+
+      // now print values of speeds for various bins found
+      fprintf(fp, "packets=%d\n", total);
+      fprintf(fp, "Running Average = %0.2f Mbps  ", cur->totalspd2);
+      fprintf(fp, "Average speed = %0.2f Mbps\n",
+              cur->totalspd / cur->totalcount);
+      fprintf(fp, "\tT1=%d (%0.2f%%); ", cur->links[2],
+              ((float) cur->links[2] * 100 / total));
+      fprintf(fp, "Ethernet=%d (%0.2f%%); ", cur->links[3],
+              ((float) cur->links[3] * 100 / total));
+      fprintf(fp, "T3=%d (%0.2f%%); ", cur->links[4],
+              ((float) cur->links[4] * 100 / total));
+      fprintf(fp, "FastEthernet=%d (%0.2f%%);\n", cur->links[5],
+              ((float) cur->links[5] * 100 / total));
+      fprintf(fp, "OC-12=%d (%0.2f%%); ", cur->links[6],
+              ((float) cur->links[6] * 100 / total));
+      fprintf(fp, "\tGigabit Ethernet=%d (%0.2f%%); ", cur->links[7],
+              ((float) cur->links[7] * 100 / total));
+      fprintf(fp, "OC-48=%d (%0.2f%%); ", cur->links[8],
+              ((float) cur->links[8] * 100 / total));
+      fprintf(fp, "10 Gigabit Enet=%d (%0.2f%%);\n", cur->links[9],
+              ((float) cur->links[9] * 100 / total));
+      fprintf(fp, "\tRetransmissions=%d (%0.2f%%); ", cur->links[10],
+              ((float) cur->links[10] * 100 / total));
+      fprintf(fp, "Unknown=%d (%0.2f%%);\n", cur->links[11],
+              ((float) cur->links[11] * 100 / total));
+    }
+    fclose(fp);
+  }
+
+  // make speed bin available to other processes
+  snprintf(buff,
+           sizeof(buff),
+           "  %d %d %d %d %d %d %d %d %d %d %d %d %0.2f %d %d %d %d %d %d",
+           cur->links[0], cur->links[1], cur->links[2], cur->links[3],
+           cur->links[4], cur->links[5], cur->links[6], cur->links[7],
+           cur->links[8], cur->links[9], cur->links[10], cur->links[11],
+           cur->totalspd2, cur->inc_cnt, cur->dec_cnt, cur->same_cnt,
+           cur->timeout, cur->dupack, ifspeed);
+  for (j = 0; j < 5; j++) {
+    i = write(monitor_pipe[1], buff, strlen(buff));
+    if (i == strlen(buff))
+      break;
+    if ((i == -1) && (errno == EINTR))
+      continue;
+  }
+  log_println(6, "wrote %d bytes: link counters are '%s'", i, buff);
+  log_println(
+      6,
+      "#$#$#$#$ pcap routine says window increases = %d, decreases = %d, no change = %d",
+      cur->inc_cnt, cur->dec_cnt, cur->same_cnt);
 }
 
 /**
@@ -436,87 +436,87 @@ void print_bins(struct spdpair *cur, int monitor_pipe[2]) {
  * @param portB Expected source port
  */
 void calculate_spd(struct spdpair *cur, struct spdpair *cur2, int portA,
-		int portB) {
-
-	float bits = 0, spd = 0, time = 0;
-
-	assert(cur);
-	assert(cur2);
-
-	time = (((cur->sec - cur2->sec) * 1000000) + (cur->usec - cur2->usec));
-	/* time = curt->time - cur2->time; */
-	// if ports are as anticipated, use sequence number to calculate no of bits exchanged
-	if ((cur->dport == portA) || (cur->sport == portB)) {
-		if (cur->seq >= cur2->seq)
-			bits = (cur->seq - cur2->seq) * 8;
-		else
-			bits = 0;
-		if (time > 200000) {
-			cur2->timeout++;
-		}
-	} else { // use acknowledgement details to calculate number of bits exchanged
-		if (cur->ack > cur2->ack)
-			bits = (cur->ack - cur2->ack) * 8;
-		else if (cur->ack == cur2->ack)
-			cur2->dupack++;
-		else
-			bits = 0;
-		if (cur->win > cur2->win)
-			cur2->inc_cnt++;
-		if (cur->win == cur2->win)
-			cur2->same_cnt++;
-		if (cur->win < cur2->win)
-			cur2->dec_cnt++;
-	}
-	// get throughput
-log_println(8, "0BITS=%f, time=%f, SPD=%f", bits, time, spd);
-	spd = (bits / time); /* convert to mbits/sec) */
-log_println(8, "1BITS=%f, time=%f, SPD=%f", bits, time, spd);
-	// increment speed bin based on throughput range
-	if ((spd > 0) && (spd <= 0.01))
-		cur2->links[0]++;
-	if ((spd > 0.01) && (spd <= 0.064))
-		cur2->links[1]++;
-	if ((spd > 0.064) && (spd <= 1.5))
-		cur2->links[2]++;
-	else if ((spd > 1.5) && (spd <= 10))
-		cur2->links[3]++;
-	else if ((spd > 10) && (spd <= 40))
-		cur2->links[4]++;
-	else if ((spd > 40) && (spd <= 100))
-		cur2->links[5]++;
-	else if ((spd > 100) && (spd <= 622))
-		cur2->links[6]++;
-	else if ((spd > 622) && (spd <= 1000))
-		cur2->links[7]++;
-	else if ((spd > 1000) && (spd <= 2400))
-		cur2->links[8]++;
-	else if ((spd > 2400) && (spd <= 10000))
-		cur2->links[9]++;
-	else if (spd == 0)
-		cur2->links[10]++;
-	else
-		cur2->links[11]++;
-	cur2->seq = cur->seq;
-	cur2->ack = cur->ack;
-	cur2->win = cur->win;
-	cur2->time = cur->time;
-	cur2->sec = cur->sec;
-	cur2->usec = cur->usec;
-log_println(8, "BITS=%f, time=%f, SPD=%f", bits, time, spd);
-	if ((time > 10) && (spd > 0)) {
-log_println(8, ">10 : totalcount=%f, spd=%f, cur2->totalcount=%d",  cur2->totalspd2, spd, cur2->totalcount);
-		cur2->totalspd += spd;
-		cur2->totalcount++;
-		cur2->totalspd2 = (cur2->totalspd2 + spd) / 2;
-	}
-	// debug 
-//
-//else {
-//	log_println(0, "ELSE totalspd2=%f, spd=%f, cur2->totalcount=%d",  cur2->totalspd2, spd, cur2->totalcount);
-//} 
-
-log_println(8, "totalspd2 in the end=%f, spd=%f",  cur2->totalspd2,spd);
+                   int portB) {
+
+  float bits = 0, spd = 0, time = 0;
+
+  assert(cur);
+  assert(cur2);
+
+  time = (((cur->sec - cur2->sec) * 1000000) + (cur->usec - cur2->usec));
+  /* time = curt->time - cur2->time; */
+  // if ports are as anticipated, use sequence number to calculate no of bits exchanged
+  if ((cur->dport == portA) || (cur->sport == portB)) {
+    if (cur->seq >= cur2->seq)
+      bits = (cur->seq - cur2->seq) * 8;
+    else
+      bits = 0;
+    if (time > 200000) {
+      cur2->timeout++;
+    }
+  } else { // use acknowledgement details to calculate number of bits exchanged
+    if (cur->ack > cur2->ack)
+      bits = (cur->ack - cur2->ack) * 8;
+    else if (cur->ack == cur2->ack)
+      cur2->dupack++;
+    else
+      bits = 0;
+    if (cur->win > cur2->win)
+      cur2->inc_cnt++;
+    if (cur->win == cur2->win)
+      cur2->same_cnt++;
+    if (cur->win < cur2->win)
+      cur2->dec_cnt++;
+  }
+  // get throughput
+  log_println(8, "0BITS=%f, time=%f, SPD=%f", bits, time, spd);
+  spd = (bits / time); /* convert to mbits/sec) */
+  log_println(8, "1BITS=%f, time=%f, SPD=%f", bits, time, spd);
+  // increment speed bin based on throughput range
+  if ((spd > 0) && (spd <= 0.01))
+    cur2->links[0]++;
+  if ((spd > 0.01) && (spd <= 0.064))
+    cur2->links[1]++;
+  if ((spd > 0.064) && (spd <= 1.5))
+    cur2->links[2]++;
+  else if ((spd > 1.5) && (spd <= 10))
+    cur2->links[3]++;
+  else if ((spd > 10) && (spd <= 40))
+    cur2->links[4]++;
+  else if ((spd > 40) && (spd <= 100))
+    cur2->links[5]++;
+  else if ((spd > 100) && (spd <= 622))
+    cur2->links[6]++;
+  else if ((spd > 622) && (spd <= 1000))
+    cur2->links[7]++;
+  else if ((spd > 1000) && (spd <= 2400))
+    cur2->links[8]++;
+  else if ((spd > 2400) && (spd <= 10000))
+    cur2->links[9]++;
+  else if (spd == 0)
+    cur2->links[10]++;
+  else
+    cur2->links[11]++;
+  cur2->seq = cur->seq;
+  cur2->ack = cur->ack;
+  cur2->win = cur->win;
+  cur2->time = cur->time;
+  cur2->sec = cur->sec;
+  cur2->usec = cur->usec;
+  log_println(8, "BITS=%f, time=%f, SPD=%f", bits, time, spd);
+  if ((time > 10) && (spd > 0)) {
+    log_println(8, ">10 : totalcount=%f, spd=%f, cur2->totalcount=%d",  cur2->totalspd2, spd, cur2->totalcount);
+    cur2->totalspd += spd;
+    cur2->totalcount++;
+    cur2->totalspd2 = (cur2->totalspd2 + spd) / 2;
+  }
+  // debug 
+  //
+  //else {
+  //	log_println(0, "ELSE totalspd2=%f, spd=%f, cur2->totalcount=%d",  cur2->totalspd2, spd, cur2->totalcount);
+  //} 
+
+  log_println(8, "totalspd2 in the end=%f, spd=%f",  cur2->totalspd2,spd);
 }
 
 /**
@@ -532,534 +532,534 @@ log_println(8, "totalspd2 in the end=%f, spd=%f",  cur2->totalspd2,spd);
 
 void print_speed(u_char *user, const struct pcap_pkthdr *h, const u_char *p) {
 
-	struct ether_header *enet;
-	const struct ip *ip = NULL;
-	PortPair* pair = (PortPair*) user;
+  struct ether_header *enet;
+  const struct ip *ip = NULL;
+  PortPair* pair = (PortPair*) user;
 #if defined(AF_INET6)
-	const struct ip6_hdr *ip6;
+  const struct ip6_hdr *ip6;
 #endif
-	const struct tcphdr *tcp;
-	struct spdpair current;
-	int port2 = pair->port1;
-	int port4 = pair->port2;
+  const struct tcphdr *tcp;
+  struct spdpair current;
+  int port2 = pair->port1;
+  int port4 = pair->port2;
 
-	assert(user);
+  assert(user);
 
-	if (dumptrace == 1)
-		pcap_dump((u_char *) pdump, h, p);
+  if (dumptrace == 1)
+    pcap_dump((u_char *) pdump, h, p);
 
-	if (pd == NULL) {
-		fprintf(
-				stderr,
-				"!#!#!#!# Error, trying to process IF data, but pcap fd closed\n");
-		return;
-	}
+  if (pd == NULL) {
+    fprintf(
+        stderr,
+        "!#!#!#!# Error, trying to process IF data, but pcap fd closed\n");
+    return;
+  }
 
-	if (check_signal_flags()) {
-		return;
-	}
+  if (check_signal_flags()) {
+    return;
+  }
 
-	current.sec = h->ts.tv_sec;
-	current.usec = h->ts.tv_usec;
-	current.time = (current.sec * 1000000) + current.usec;
+  current.sec = h->ts.tv_sec;
+  current.usec = h->ts.tv_usec;
+  current.time = (current.sec * 1000000) + current.usec;
 
-	enet = (struct ether_header *) p;
-	p += sizeof(struct ether_header); /* move packet pointer past ethernet fields */
+  enet = (struct ether_header *) p;
+  p += sizeof(struct ether_header); /* move packet pointer past ethernet fields */
 
-	ip = (const struct ip *) p;
+  ip = (const struct ip *) p;
 #if defined(AF_INET6)
-	if (ip->ip_v == 4) {
+  if (ip->ip_v == 4) {
 #endif
 
-	/* This section grabs the IP & TCP header values from an IPv4 packet and loads the various
-	 * variables with the packet's values.  
-	 */
-	p += (ip->ip_hl) * 4;
-	tcp = (const struct tcphdr *) p;
+    /* This section grabs the IP & TCP header values from an IPv4 packet and loads the various
+     * variables with the packet's values.  
+     */
+    p += (ip->ip_hl) * 4;
+    tcp = (const struct tcphdr *) p;
 #if defined(AF_INET6)
-	current.saddr[0] = ip->ip_src.s_addr;
-	current.daddr[0] = ip->ip_dst.s_addr;
+    current.saddr[0] = ip->ip_src.s_addr;
+    current.daddr[0] = ip->ip_dst.s_addr;
 #else
-	current.saddr = ip->ip_src.s_addr;
-	current.daddr = ip->ip_dst.s_addr;
+    current.saddr = ip->ip_src.s_addr;
+    current.daddr = ip->ip_dst.s_addr;
 #endif
 
-	current.sport = ntohs(tcp->source);
-	current.dport = ntohs(tcp->dest);
-	current.seq = ntohl(tcp->seq);
-	current.ack = ntohl(tcp->ack_seq);
-	current.win = ntohs(tcp->window);
-
-	/* the current structure now has copies of the IP/TCP header values, if this is the
-	 * first packet, then there is nothing to compare them to, so just finish the initialization
-	 * step and return.
-	 */
-
-	if (fwd.seq == 0) {
-		log_println(1,
-				"New IPv4 packet trace started -- initializing counters");
-		fwd.seq = current.seq;
-
-		fwd.st_sec = current.sec;
-		fwd.st_usec = current.usec;
-		rev.st_sec = current.sec;
-		rev.st_usec = current.usec;
-		fwd.dec_cnt = 0;
-		fwd.inc_cnt = 0;
-		fwd.same_cnt = 0;
-		fwd.timeout = 0;
-		fwd.dupack = 0;
-		rev.dec_cnt = 0;
-		rev.inc_cnt = 0;
-		rev.same_cnt = 0;
-		rev.timeout = 0;
-		rev.dupack = 0;
-		fwd.family = 4;
-		rev.family = 4;
-		return;
-	}
-
-	/* a new IPv4 packet has been received and it isn't the 1st one, so calculate the bottleneck link
-	 * capacity based on the times between this packet and the previous one.
-	 */
+    current.sport = ntohs(tcp->source);
+    current.dport = ntohs(tcp->dest);
+    current.seq = ntohl(tcp->seq);
+    current.ack = ntohl(tcp->ack_seq);
+    current.win = ntohs(tcp->window);
+
+    /* the current structure now has copies of the IP/TCP header values, if this is the
+     * first packet, then there is nothing to compare them to, so just finish the initialization
+     * step and return.
+     */
+
+    if (fwd.seq == 0) {
+      log_println(1,
+                  "New IPv4 packet trace started -- initializing counters");
+      fwd.seq = current.seq;
+
+      fwd.st_sec = current.sec;
+      fwd.st_usec = current.usec;
+      rev.st_sec = current.sec;
+      rev.st_usec = current.usec;
+      fwd.dec_cnt = 0;
+      fwd.inc_cnt = 0;
+      fwd.same_cnt = 0;
+      fwd.timeout = 0;
+      fwd.dupack = 0;
+      rev.dec_cnt = 0;
+      rev.inc_cnt = 0;
+      rev.same_cnt = 0;
+      rev.timeout = 0;
+      rev.dupack = 0;
+      fwd.family = 4;
+      rev.family = 4;
+      return;
+    }
+
+    /* a new IPv4 packet has been received and it isn't the 1st one, so calculate the bottleneck link
+     * capacity based on the times between this packet and the previous one.
+     */
 
 #if defined(AF_INET6)
-	if (fwd.saddr[0] == current.saddr[0]) {
+    if (fwd.saddr[0] == current.saddr[0]) {
 #else
-	if (fwd.saddr == current.saddr) {
+      if (fwd.saddr == current.saddr) {
 #endif
-		if (current.dport == port2) {
-			calculate_spd(&current, &fwd, port2, port4);
-			return;
-		}
-		if (current.sport == port4) {
-			calculate_spd(&current, &fwd, port2, port4);
-			return;
-		}
-	}
+        if (current.dport == port2) {
+          calculate_spd(&current, &fwd, port2, port4);
+          return;
+        }
+        if (current.sport == port4) {
+          calculate_spd(&current, &fwd, port2, port4);
+          return;
+        }
+      }
 #if defined(AF_INET6)
-	if (rev.saddr[0] == current.saddr[0]) {
+      if (rev.saddr[0] == current.saddr[0]) {
 #else
-	if (rev.saddr == current.saddr) {
+        if (rev.saddr == current.saddr) {
 #endif
-		if (current.sport == port2) {
-			calculate_spd(&current, &rev, port2, port4);
-			return;
-		}
-		if (current.dport == port4) {
-			calculate_spd(&current, &rev, port2, port4);
-			return;
-		}
-	}
+          if (current.sport == port2) {
+            calculate_spd(&current, &rev, port2, port4);
+            return;
+          }
+          if (current.dport == port4) {
+            calculate_spd(&current, &rev, port2, port4);
+            return;
+          }
+        }
 #if defined(AF_INET6)
-}
-else { /*  IP header value is not = 4, so must be IPv6 */
-
-	/* This is an IPv6 packet, grab the IP & TCP header values for further use.
-	 */
-
-	ip6 = (const struct ip6_hdr *)p;
-
-	p += 40;
-	tcp = (const struct tcphdr *)p;
-	memcpy(current.saddr, (void *) &ip6->ip6_src, 16);
-	memcpy(current.daddr, (void *) &ip6->ip6_dst, 16);
-
-	current.sport = ntohs(tcp->source);
-	current.dport = ntohs(tcp->dest);
-	current.seq = ntohl(tcp->seq);
-	current.ack = ntohl(tcp->ack_seq);
-	current.win = ntohs(tcp->window);
-
-	/* The 1st packet has been received, finish the initialization process and return.
-	 */
-
-	/* if ((fwd.saddr[0] == 0) && (fwd.saddr[1] == 0) && (fwd.saddr[2] == 0) && (fwd.saddr[3] == 0)) { */
-	if (fwd.seq == 0) {
-		log_println(1, "New IPv6 packet trace started -- initializing counters");
-		fwd.seq = current.seq;
-		fwd.st_sec = current.sec;
-		fwd.st_usec = current.usec;
-		rev.st_sec = current.sec;
-		rev.st_usec = current.usec;
-		fwd.dec_cnt = 0;
-		fwd.inc_cnt = 0;
-		fwd.same_cnt = 0;
-		fwd.timeout = 0;
-		fwd.dupack = 0;
-		rev.dec_cnt = 0;
-		rev.inc_cnt = 0;
-		rev.same_cnt = 0;
-		rev.timeout = 0;
-		rev.dupack = 0;
-		fwd.family = 6;
-		rev.family = 6;
-		return;
-	}
-
-	/* A new packet has been recieved, and it's not the 1st.  Use it to calculate the
-	 * bottleneck link capacity for this flow.
-	 */
-
-	if ((fwd.saddr[0] == current.saddr[0]) &&
-			(fwd.saddr[1] == current.saddr[1]) &&
-			(fwd.saddr[2] == current.saddr[2]) &&
-			(fwd.saddr[3] == current.saddr[3])) {
-		if (current.dport == port2) {
-			calculate_spd(&current, &fwd, port2, port4);
-			return;
-		}
-		if (current.sport == port4) {
-			calculate_spd(&current, &fwd, port2, port4);
-			return;
-		}
-	}
-	if ((rev.saddr[0] == current.saddr[0]) &&
-			(rev.saddr[1] == current.saddr[1]) &&
-			(rev.saddr[2] == current.saddr[2]) &&
-			(rev.saddr[3] == current.saddr[3])) {
-		if (current.sport == port2) {
-			calculate_spd(&current, &rev, port2, port4);
-			return;
-		}
-		if (current.dport == port4) {
-			calculate_spd(&current, &rev, port2, port4);
-			return;
-		}
-	}
-}
+      }
+      else { /*  IP header value is not = 4, so must be IPv6 */
+
+        /* This is an IPv6 packet, grab the IP & TCP header values for further use.
+        */
+
+        ip6 = (const struct ip6_hdr *)p;
+
+        p += 40;
+        tcp = (const struct tcphdr *)p;
+        memcpy(current.saddr, (void *) &ip6->ip6_src, 16);
+        memcpy(current.daddr, (void *) &ip6->ip6_dst, 16);
+
+        current.sport = ntohs(tcp->source);
+        current.dport = ntohs(tcp->dest);
+        current.seq = ntohl(tcp->seq);
+        current.ack = ntohl(tcp->ack_seq);
+        current.win = ntohs(tcp->window);
+
+        /* The 1st packet has been received, finish the initialization process and return.
+        */
+
+        /* if ((fwd.saddr[0] == 0) && (fwd.saddr[1] == 0) && (fwd.saddr[2] == 0) && (fwd.saddr[3] == 0)) { */
+        if (fwd.seq == 0) {
+          log_println(1, "New IPv6 packet trace started -- initializing counters");
+          fwd.seq = current.seq;
+          fwd.st_sec = current.sec;
+          fwd.st_usec = current.usec;
+          rev.st_sec = current.sec;
+          rev.st_usec = current.usec;
+          fwd.dec_cnt = 0;
+          fwd.inc_cnt = 0;
+          fwd.same_cnt = 0;
+          fwd.timeout = 0;
+          fwd.dupack = 0;
+          rev.dec_cnt = 0;
+          rev.inc_cnt = 0;
+          rev.same_cnt = 0;
+          rev.timeout = 0;
+          rev.dupack = 0;
+          fwd.family = 6;
+          rev.family = 6;
+          return;
+        }
+
+        /* A new packet has been recieved, and it's not the 1st.  Use it to calculate the
+         * bottleneck link capacity for this flow.
+         */
+
+        if ((fwd.saddr[0] == current.saddr[0]) &&
+            (fwd.saddr[1] == current.saddr[1]) &&
+            (fwd.saddr[2] == current.saddr[2]) &&
+            (fwd.saddr[3] == current.saddr[3])) {
+          if (current.dport == port2) {
+            calculate_spd(&current, &fwd, port2, port4);
+            return;
+          }
+          if (current.sport == port4) {
+            calculate_spd(&current, &fwd, port2, port4);
+            return;
+          }
+        }
+        if ((rev.saddr[0] == current.saddr[0]) &&
+            (rev.saddr[1] == current.saddr[1]) &&
+            (rev.saddr[2] == current.saddr[2]) &&
+            (rev.saddr[3] == current.saddr[3])) {
+          if (current.sport == port2) {
+            calculate_spd(&current, &rev, port2, port4);
+            return;
+          }
+          if (current.dport == port4) {
+            calculate_spd(&current, &rev, port2, port4);
+            return;
+          }
+        }
+      }
 #endif
 
-	/* a packet has been received, so it matched the filter, but the src/dst ports are backward for some reason.
-	 * Need to fix this by reversing the values.
-	 */
-
-	if (sigk == 0) {
-		sigk++;
-		log_println(6,
-				"Fault: unknown packet received with src/dst port = %d/%d",
-				current.sport, current.dport);
-	}
-	if (sigj == 0) {
-		log_println(6, "Ports need to be reversed now port1/port2 = %d/%d",
-				pair->port1, pair->port2);
-		int tport = pair->port1;
-		pair->port1 = pair->port2;
-		pair->port2 = tport;
-		;
-		fwd.st_sec = current.sec;
-		fwd.st_usec = current.usec;
-		rev.st_sec = current.sec;
-		rev.st_usec = current.usec;
-		fwd.dec_cnt = 0;
-		fwd.inc_cnt = 0;
-		fwd.same_cnt = 0;
-		fwd.timeout = 0;
-		fwd.dupack = 0;
-		rev.dec_cnt = 0;
-		rev.inc_cnt = 0;
-		rev.same_cnt = 0;
-		rev.timeout = 0;
-		rev.dupack = 0;
-		log_println(6,
-				"Ports should have been reversed now port1/port2 = %d/%d",
-				pair->port1, pair->port2);
-		sigj = 1;
-	}
-}
-
-/**
- * Perform opening and initialization functions needed
- * by the libpcap routines.  The print_speed function above, is passed
- * to the pcap_open_live() function as the pcap_handler.
- * @param srcAddr 	Source address
- * @param sock_addr socket address used to determine client address
- * @param saddrlen  socket address length
- * @param monitor_pipe socket file descriptors used to read/write data (for interprocess communication)
- * @param device devive detail string
- * @param pair PortPair strcuture
- * @param direction string indicating C2S/S2c test
- * @param compress Option indicating whether log files (here, ndttrace) needs to be compressed. Unused here.
- */
-
-void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
-		socklen_t saddrlen, int monitor_pipe[2], char *device, PortPair* pair,
-		char *direction, int compress) {
-	char cmdbuf[256], dir[256];
-	pcap_handler printer;
-	u_char * pcap_userdata = (u_char*) pair;
-	struct bpf_program fcode;
-	char errbuf[PCAP_ERRBUF_SIZE];
-	int cnt, pflag = 0, i;
-	char c;
-	char namebuf[200], isoTime[64];
-	size_t nameBufLen = 199;
-	I2Addr sockAddr = NULL;
-	struct sockaddr *src_addr;
-	pcap_if_t *alldevs, *dp;
-	pcap_addr_t *curAddr;
-	int rc;
-
-	char logdir[256];
-
-	cnt = -1; /* read forever, or until end of file */
-	sig1 = 0;
-	sig2 = 0;
-
-	init_vars(&fwd);
-	init_vars(&rev);
-
-	sockAddr = I2AddrBySAddr(get_errhandle(), sock_addr, saddrlen, 0, 0);
-	sock_addr = I2AddrSAddr(sockAddr, 0);
-	src_addr = I2AddrSAddr(srcAddr, 0);
-
-	/* special check for localhost, set device accordingly */
-	if (I2SockAddrIsLoopback(sock_addr, saddrlen) > 0)
-		strlcpy(device, "lo", 100); //hardcoding device address to 100, as initialised in main()
-	if (device == NULL) {
-		if (pcap_findalldevs(&alldevs, errbuf) == 0) {
-			for (dp = alldevs; dp != NULL; dp = dp->next) {
-				for (curAddr = dp->addresses; curAddr != NULL;
-						curAddr = curAddr->next) {
-					switch (curAddr->addr->sa_family) {
-					case AF_INET:
-						memset(namebuf, 0, 200);
-						inet_ntop(
-								AF_INET,
-								&((struct sockaddr_in *) curAddr->addr)->sin_addr,
-								namebuf, INET_ADDRSTRLEN);
-						log_println(3, "IPv4 interface found address=%s",
-								namebuf);
-						if (((struct sockaddr_in *) curAddr->addr)->sin_addr.s_addr
-								== ((struct sockaddr_in *) src_addr)->sin_addr.s_addr) {
-							log_println(
-									4,
-									"IPv4 address match, setting device to '%s'",
-									dp->name);
-							device = dp->name;
-							ifspeed = -1;
-							for (i = 0; iflist.name[0][i] != '0'; i++) {
-								if (strncmp((char *) iflist.name[i], device, 4)
-										== 0) {
-									ifspeed = iflist.speed[i];
-									break;
-								}
-							}
-
-							if (direction[0] == 's') {
+      /* a packet has been received, so it matched the filter, but the src/dst ports are backward for some reason.
+       * Need to fix this by reversing the values.
+       */
+
+      if (sigk == 0) {
+        sigk++;
+        log_println(6,
+                    "Fault: unknown packet received with src/dst port = %d/%d",
+                    current.sport, current.dport);
+      }
+      if (sigj == 0) {
+        log_println(6, "Ports need to be reversed now port1/port2 = %d/%d",
+                    pair->port1, pair->port2);
+        int tport = pair->port1;
+        pair->port1 = pair->port2;
+        pair->port2 = tport;
+        ;
+        fwd.st_sec = current.sec;
+        fwd.st_usec = current.usec;
+        rev.st_sec = current.sec;
+        rev.st_usec = current.usec;
+        fwd.dec_cnt = 0;
+        fwd.inc_cnt = 0;
+        fwd.same_cnt = 0;
+        fwd.timeout = 0;
+        fwd.dupack = 0;
+        rev.dec_cnt = 0;
+        rev.inc_cnt = 0;
+        rev.same_cnt = 0;
+        rev.timeout = 0;
+        rev.dupack = 0;
+        log_println(6,
+                    "Ports should have been reversed now port1/port2 = %d/%d",
+                    pair->port1, pair->port2);
+        sigj = 1;
+      }
+      }
+
+      /**
+       * Perform opening and initialization functions needed
+       * by the libpcap routines.  The print_speed function above, is passed
+       * to the pcap_open_live() function as the pcap_handler.
+       * @param srcAddr 	Source address
+       * @param sock_addr socket address used to determine client address
+       * @param saddrlen  socket address length
+       * @param monitor_pipe socket file descriptors used to read/write data (for interprocess communication)
+       * @param device devive detail string
+       * @param pair PortPair strcuture
+       * @param direction string indicating C2S/S2c test
+       * @param compress Option indicating whether log files (here, ndttrace) needs to be compressed. Unused here.
+       */
+
+      void init_pkttrace(I2Addr srcAddr, struct sockaddr *sock_addr,
+                         socklen_t saddrlen, int monitor_pipe[2], char *device, PortPair* pair,
+                         char *direction, int compress) {
+        char cmdbuf[256], dir[256];
+        pcap_handler printer;
+        u_char * pcap_userdata = (u_char*) pair;
+        struct bpf_program fcode;
+        char errbuf[PCAP_ERRBUF_SIZE];
+        int cnt, pflag = 0, i;
+        char c;
+        char namebuf[200], isoTime[64];
+        size_t nameBufLen = 199;
+        I2Addr sockAddr = NULL;
+        struct sockaddr *src_addr;
+        pcap_if_t *alldevs, *dp;
+        pcap_addr_t *curAddr;
+        int rc;
+
+        char logdir[256];
+
+        cnt = -1; /* read forever, or until end of file */
+        sig1 = 0;
+        sig2 = 0;
+
+        init_vars(&fwd);
+        init_vars(&rev);
+
+        sockAddr = I2AddrBySAddr(get_errhandle(), sock_addr, saddrlen, 0, 0);
+        sock_addr = I2AddrSAddr(sockAddr, 0);
+        src_addr = I2AddrSAddr(srcAddr, 0);
+
+        /* special check for localhost, set device accordingly */
+        if (I2SockAddrIsLoopback(sock_addr, saddrlen) > 0)
+          strlcpy(device, "lo", 100); //hardcoding device address to 100, as initialised in main()
+        if (device == NULL) {
+          if (pcap_findalldevs(&alldevs, errbuf) == 0) {
+            for (dp = alldevs; dp != NULL; dp = dp->next) {
+              for (curAddr = dp->addresses; curAddr != NULL;
+                   curAddr = curAddr->next) {
+                switch (curAddr->addr->sa_family) {
+                  case AF_INET:
+                    memset(namebuf, 0, 200);
+                    inet_ntop(
+                        AF_INET,
+                        &((struct sockaddr_in *) curAddr->addr)->sin_addr,
+                        namebuf, INET_ADDRSTRLEN);
+                    log_println(3, "IPv4 interface found address=%s",
+                                namebuf);
+                    if (((struct sockaddr_in *) curAddr->addr)->sin_addr.s_addr
+                        == ((struct sockaddr_in *) src_addr)->sin_addr.s_addr) {
+                      log_println(
+                          4,
+                          "IPv4 address match, setting device to '%s'",
+                          dp->name);
+                      device = dp->name;
+                      ifspeed = -1;
+                      for (i = 0; iflist.name[0][i] != '0'; i++) {
+                        if (strncmp((char *) iflist.name[i], device, 4)
+                            == 0) {
+                          ifspeed = iflist.speed[i];
+                          break;
+                        }
+                      }
+
+                      if (direction[0] == 's') {
 #if defined(AF_INET6)
-								fwd.saddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
-								fwd.daddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
-								rev.saddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
-								rev.daddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
+                        fwd.saddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
+                        fwd.daddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
+                        rev.saddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
+                        rev.daddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
 #else
-								fwd.saddr =
-										((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
-								fwd.daddr =
-										((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
-								rev.saddr =
-										((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
-								rev.daddr =
-										((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
+                        fwd.saddr =
+                            ((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
+                        fwd.daddr =
+                            ((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
+                        rev.saddr =
+                            ((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
+                        rev.daddr =
+                            ((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
 #endif
-								fwd.sport =
-										ntohs(
-												((struct sockaddr_in *) src_addr)->sin_port);
-								fwd.dport =
-										ntohs(
-												((struct sockaddr_in *) sock_addr)->sin_port);
-								rev.sport =
-										ntohs(
-												((struct sockaddr_in *) sock_addr)->sin_port);
-								rev.dport =
-										ntohs(
-												((struct sockaddr_in *) src_addr)->sin_port);
-							} else {
+                        fwd.sport =
+                            ntohs(
+                                ((struct sockaddr_in *) src_addr)->sin_port);
+                        fwd.dport =
+                            ntohs(
+                                ((struct sockaddr_in *) sock_addr)->sin_port);
+                        rev.sport =
+                            ntohs(
+                                ((struct sockaddr_in *) sock_addr)->sin_port);
+                        rev.dport =
+                            ntohs(
+                                ((struct sockaddr_in *) src_addr)->sin_port);
+                      } else {
 #if defined(AF_INET6)
-								rev.saddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
-								rev.daddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
-								fwd.saddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
-								fwd.daddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
+                        rev.saddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
+                        rev.daddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
+                        fwd.saddr[0] = ((struct sockaddr_in *)sock_addr)->sin_addr.s_addr;
+                        fwd.daddr[0] = ((struct sockaddr_in *)src_addr)->sin_addr.s_addr;
 #else
-								rev.saddr =
-										((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
-								rev.daddr =
-										((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
-								fwd.saddr =
-										((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
-								fwd.daddr =
-										((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
+                        rev.saddr =
+                            ((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
+                        rev.daddr =
+                            ((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
+                        fwd.saddr =
+                            ((struct sockaddr_in *) sock_addr)->sin_addr.s_addr;
+                        fwd.daddr =
+                            ((struct sockaddr_in *) src_addr)->sin_addr.s_addr;
 #endif
-								rev.sport =
-										ntohs(
-												((struct sockaddr_in *) src_addr)->sin_port);
-								rev.dport =
-										ntohs(
-												((struct sockaddr_in *) sock_addr)->sin_port);
-								fwd.sport =
-										ntohs(
-												((struct sockaddr_in *) sock_addr)->sin_port);
-								fwd.dport =
-										ntohs(
-												((struct sockaddr_in *) src_addr)->sin_port);
-							}
-							goto endLoop;
-						}
-						break;
+                        rev.sport =
+                            ntohs(
+                                ((struct sockaddr_in *) src_addr)->sin_port);
+                        rev.dport =
+                            ntohs(
+                                ((struct sockaddr_in *) sock_addr)->sin_port);
+                        fwd.sport =
+                            ntohs(
+                                ((struct sockaddr_in *) sock_addr)->sin_port);
+                        fwd.dport =
+                            ntohs(
+                                ((struct sockaddr_in *) src_addr)->sin_port);
+                      }
+                      goto endLoop;
+                    }
+                    break;
 #if defined(AF_INET6)
-						case AF_INET6:
-						memset(namebuf, 0, 200);
-						inet_ntop(AF_INET6, &((struct sockaddr_in6 *)curAddr->addr)->sin6_addr,
-								namebuf, INET6_ADDRSTRLEN);
-						/* I2AddrNodeName(srcAddr, namebuf, &nameBufLen); */
-						log_println(3, "IPv6 interface found address=%s", namebuf);
-						if (memcmp(((struct sockaddr_in6 *)curAddr->addr)->sin6_addr.s6_addr,
-										((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr,
-										16) == 0) {
-							log_println(4, "IPv6 address match, setting device to '%s'", dp->name);
-							device = dp->name;
-
-							if (direction[0] == 's') {
-								memcpy(fwd.saddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
-								memcpy(fwd.daddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
-								memcpy(rev.saddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
-								memcpy(rev.daddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
-								fwd.sport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
-								fwd.dport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
-								rev.sport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
-								rev.dport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
-							} else {
-								memcpy(rev.saddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
-								memcpy(rev.daddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
-								memcpy(fwd.saddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
-								memcpy(fwd.daddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
-								rev.sport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
-								rev.dport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
-								fwd.sport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
-								fwd.dport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
-							}
-							goto endLoop;
-						}
-						break;
+                  case AF_INET6:
+                    memset(namebuf, 0, 200);
+                    inet_ntop(AF_INET6, &((struct sockaddr_in6 *)curAddr->addr)->sin6_addr,
+                              namebuf, INET6_ADDRSTRLEN);
+                    /* I2AddrNodeName(srcAddr, namebuf, &nameBufLen); */
+                    log_println(3, "IPv6 interface found address=%s", namebuf);
+                    if (memcmp(((struct sockaddr_in6 *)curAddr->addr)->sin6_addr.s6_addr,
+                               ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr,
+                               16) == 0) {
+                      log_println(4, "IPv6 address match, setting device to '%s'", dp->name);
+                      device = dp->name;
+
+                      if (direction[0] == 's') {
+                        memcpy(fwd.saddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
+                        memcpy(fwd.daddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
+                        memcpy(rev.saddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
+                        memcpy(rev.daddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
+                        fwd.sport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
+                        fwd.dport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
+                        rev.sport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
+                        rev.dport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
+                      } else {
+                        memcpy(rev.saddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
+                        memcpy(rev.daddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
+                        memcpy(fwd.saddr, ((struct sockaddr_in6 *)sock_addr)->sin6_addr.s6_addr, 16);
+                        memcpy(fwd.daddr, ((struct sockaddr_in6 *)src_addr)->sin6_addr.s6_addr, 16);
+                        rev.sport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
+                        rev.dport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
+                        fwd.sport = ntohs(((struct sockaddr_in6 *)sock_addr)->sin6_port);
+                        fwd.dport = ntohs(((struct sockaddr_in6 *)src_addr)->sin6_port);
+                      }
+                      goto endLoop;
+                    }
+                    break;
 #endif
-					default:
-						log_println(4, "Unknown address family=%d found",
-								curAddr->addr->sa_family);
-					}
-				}
-			}
-		}
-	}
-	endLoop:
-
-	/*  device = pcap_lookupdev(errbuf); */
-	if (device == NULL) {
-		fprintf(stderr, "pcap_lookupdev failed: %s\n", errbuf);
-	}
-
-	log_println(1, "Opening network interface '%s' for packet-pair timing",
-			device);
-
-	if ((pd = pcap_open_live(device, 68, !pflag, 1000, errbuf)) == NULL) {
-		fprintf(stderr, "pcap_open_live failed: %s\n", errbuf);
-	}
-
-	log_println(2, "pcap_open_live() returned pointer %p", pd);
-
-	memset(namebuf, 0, 200);
-	I2AddrNodeName(sockAddr, namebuf, &nameBufLen);
-	memset(cmdbuf, 0, sizeof(cmdbuf));
-	snprintf(cmdbuf, sizeof(cmdbuf), "host %s and port %d", namebuf, I2AddrPort(sockAddr));
-
-	log_println(1, "installing pkt filter for '%s'", cmdbuf);
-	log_println(1, "Initial pkt src data = %p", fwd.saddr);
-
-	if (pcap_compile(pd, &fcode, cmdbuf, 0, 0xFFFFFF00) < 0) {
-		fprintf(stderr, "pcap_compile failed %s\n", pcap_geterr(pd));
-		return;
-	}
-
-	if (pcap_setfilter(pd, &fcode) < 0) {
-		fprintf(stderr, "pcap_setfiler failed %s\n", pcap_geterr(pd));
-		return;
-	}
-
-	if (dumptrace == 1) {
-		// Create log file
-		snprintf(dir, sizeof(dir), "%s_%s:%d.%s_ndttrace",
-				get_ISOtime(isoTime, sizeof(isoTime)), namebuf,
-				I2AddrPort(sockAddr), direction);
-		create_named_logdir(logdir, sizeof(logdir), dir, 0);
-		pdump = pcap_dump_open(pd, logdir);
-		fprintf(stderr, "Opening '%s' log fine\n", logdir);
-		if (pdump == NULL) {
-			fprintf(stderr, "Unable to create trace file '%s'\n", logdir);
-			dumptrace = 0;
-		}
-	}
-
-	printer = (pcap_handler) print_speed;
-	if (dumptrace == 0) {
-		for (i = 0; i < 5; i++) {
-			rc = write(monitor_pipe[1], "Ready", 6);
-			if (rc == 6)
-				break;
-			if ((rc == -1) && (errno == EINTR))
-				continue;
-		}
-	} else {
-		for (i = 0; i < 5; i++) {
-			rc = write(monitor_pipe[1], dir, strlen(dir));
-			if (rc == strlen(dir))
-				break;
-			if ((rc == -1) && (errno == EINTR))
-				continue;
-		}
-	}
-
-	/* kill process off if parent doesn't send a signal. */
-	alarm(60);
-
-	if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) {
-		log_println(5, "pcap_loop exited %s", pcap_geterr(pd));
-	}
-
-	pcap_close(pd);
-
-	log_println(
-			5,
-			"Pkt-Pair data collection ended, waiting for signal to terminate process");
-	/*    Temporarily remove these free statements, The memory should be free'd when
-	 *      the child process terminates, so we don't have a leak.  There might be a bug in
-	 *      the pcap lib (on-line reference found from 2003) and on 10/14/09 I was seeing
-	 *      child crashes with a traceback pointing to the freecode() routine inside the pcap-lib
-	 *      as the culprit.  RAC 10/15/09
-	 *
-	 * if (alldevs != NULL)
-	 *    pcap_freealldevs(alldevs);
-	 *  if (&fcode != NULL)
-	 *    pcap_freecode(&fcode);
-	 */
-	free(sockAddr);
-
-	if (sig1 == 2) {
-		while ((read(mon_pipe1[0], &c, 1)) < 0)
-			;
-		close(mon_pipe1[0]);
-		close(mon_pipe1[1]);
-		sig1 = 0;
-	}
-	if (sig2 == 2) {
-		while ((read(mon_pipe2[0], &c, 1)) < 0)
-			;
-		sleep(2);
-		close(mon_pipe2[0]);
-		close(mon_pipe2[1]);
-		sig2 = 0;
-	}
-
-	log_println(
-			8,
-			"Finally Finished reading data from network, process %d should terminate now",
-			getpid());
-}
+                  default:
+                    log_println(4, "Unknown address family=%d found",
+                                curAddr->addr->sa_family);
+                }
+              }
+            }
+          }
+        }
+endLoop:
+
+        /*  device = pcap_lookupdev(errbuf); */
+        if (device == NULL) {
+          fprintf(stderr, "pcap_lookupdev failed: %s\n", errbuf);
+        }
+
+        log_println(1, "Opening network interface '%s' for packet-pair timing",
+                    device);
+
+        if ((pd = pcap_open_live(device, 68, !pflag, 1000, errbuf)) == NULL) {
+          fprintf(stderr, "pcap_open_live failed: %s\n", errbuf);
+        }
+
+        log_println(2, "pcap_open_live() returned pointer %p", pd);
+
+        memset(namebuf, 0, 200);
+        I2AddrNodeName(sockAddr, namebuf, &nameBufLen);
+        memset(cmdbuf, 0, sizeof(cmdbuf));
+        snprintf(cmdbuf, sizeof(cmdbuf), "host %s and port %d", namebuf, I2AddrPort(sockAddr));
+
+        log_println(1, "installing pkt filter for '%s'", cmdbuf);
+        log_println(1, "Initial pkt src data = %p", fwd.saddr);
+
+        if (pcap_compile(pd, &fcode, cmdbuf, 0, 0xFFFFFF00) < 0) {
+          fprintf(stderr, "pcap_compile failed %s\n", pcap_geterr(pd));
+          return;
+        }
+
+        if (pcap_setfilter(pd, &fcode) < 0) {
+          fprintf(stderr, "pcap_setfiler failed %s\n", pcap_geterr(pd));
+          return;
+        }
+
+        if (dumptrace == 1) {
+          // Create log file
+          snprintf(dir, sizeof(dir), "%s_%s:%d.%s_ndttrace",
+                   get_ISOtime(isoTime, sizeof(isoTime)), namebuf,
+                   I2AddrPort(sockAddr), direction);
+          create_named_logdir(logdir, sizeof(logdir), dir, 0);
+          pdump = pcap_dump_open(pd, logdir);
+          fprintf(stderr, "Opening '%s' log fine\n", logdir);
+          if (pdump == NULL) {
+            fprintf(stderr, "Unable to create trace file '%s'\n", logdir);
+            dumptrace = 0;
+          }
+        }
+
+        printer = (pcap_handler) print_speed;
+        if (dumptrace == 0) {
+          for (i = 0; i < 5; i++) {
+            rc = write(monitor_pipe[1], "Ready", 6);
+            if (rc == 6)
+              break;
+            if ((rc == -1) && (errno == EINTR))
+              continue;
+          }
+        } else {
+          for (i = 0; i < 5; i++) {
+            rc = write(monitor_pipe[1], dir, strlen(dir));
+            if (rc == strlen(dir))
+              break;
+            if ((rc == -1) && (errno == EINTR))
+              continue;
+          }
+        }
+
+        /* kill process off if parent doesn't send a signal. */
+        alarm(60);
+
+        if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) {
+          log_println(5, "pcap_loop exited %s", pcap_geterr(pd));
+        }
+
+        pcap_close(pd);
+
+        log_println(
+            5,
+            "Pkt-Pair data collection ended, waiting for signal to terminate process");
+        /*    Temporarily remove these free statements, The memory should be free'd when
+         *      the child process terminates, so we don't have a leak.  There might be a bug in
+         *      the pcap lib (on-line reference found from 2003) and on 10/14/09 I was seeing
+         *      child crashes with a traceback pointing to the freecode() routine inside the pcap-lib
+         *      as the culprit.  RAC 10/15/09
+         *
+         * if (alldevs != NULL)
+         *    pcap_freealldevs(alldevs);
+         *  if (&fcode != NULL)
+         *    pcap_freecode(&fcode);
+         */
+        free(sockAddr);
+
+        if (sig1 == 2) {
+          while ((read(mon_pipe1[0], &c, 1)) < 0)
+            ;
+          close(mon_pipe1[0]);
+          close(mon_pipe1[1]);
+          sig1 = 0;
+        }
+        if (sig2 == 2) {
+          while ((read(mon_pipe2[0], &c, 1)) < 0)
+            ;
+          sleep(2);
+          close(mon_pipe2[0]);
+          close(mon_pipe2[1]);
+          sig2 = 0;
+        }
+
+        log_println(
+            8,
+            "Finally Finished reading data from network, process %d should terminate now",
+            getpid());
+      }
diff --git a/src/web100-util.c b/src/web100-util.c
index 2cd2066..6b5d4e5 100644
--- a/src/web100-util.c
+++ b/src/web100-util.c
@@ -26,33 +26,33 @@
  */
 int web100_init(char *VarFileName) {
 
-	FILE * fp;
-	char line[256], trimmedline[256];
-	int count_vars = 0;
-
-	assert(VarFileName);
-
-	if ((fp = fopen(VarFileName, "r")) == NULL) { // unable to open web100 variable file
-		err_sys(
-				"Required Web100 variables file missing, use -f option to specify file location\n");
-		exit(5);
-	}
-
-	while (fgets(line, 255, fp) != NULL) { // read file linewise
-		if ((line[0] == '#') || (line[0] == '\n')) // if newline or comment, ignore
-			continue;
-		// copy web100 variable into our array and increment count of read variables
-
-		trim(line, strlen(line), trimmedline, sizeof(trimmedline)); // remove unwanted
-				//	chars (right now, trailing/preceding chars from wb100 var names)
-		strlcpy(web_vars[count_vars].name, trimmedline,
-				sizeof(web_vars[count_vars].name));
-		count_vars++;
-	}
-	fclose(fp);
-	log_println(1, "web100_init() read %d variables from file", count_vars);
-
-	return (count_vars);
+  FILE * fp;
+  char line[256], trimmedline[256];
+  int count_vars = 0;
+
+  assert(VarFileName);
+
+  if ((fp = fopen(VarFileName, "r")) == NULL) { // unable to open web100 variable file
+    err_sys(
+        "Required Web100 variables file missing, use -f option to specify file location\n");
+    exit(5);
+  }
+
+  while (fgets(line, 255, fp) != NULL) { // read file linewise
+    if ((line[0] == '#') || (line[0] == '\n')) // if newline or comment, ignore
+      continue;
+    // copy web100 variable into our array and increment count of read variables
+
+    trim(line, strlen(line), trimmedline, sizeof(trimmedline)); // remove unwanted
+    //	chars (right now, trailing/preceding chars from wb100 var names)
+    strlcpy(web_vars[count_vars].name, trimmedline,
+            sizeof(web_vars[count_vars].name));
+    count_vars++;
+  }
+  fclose(fp);
+  log_println(1, "web100_init() read %d variables from file", count_vars);
+
+  return (count_vars);
 }
 
 /**
@@ -74,166 +74,166 @@ int web100_init(char *VarFileName) {
  *
  */
 void web100_middlebox(int sock, web100_agent* agent, web100_connection* cn,
-		char *results, size_t results_strlen) {
-
-	web100_var* var;
-	web100_group* group;
-	web100_snapshot* snap;
-	char buff[8192], line[256];
-	char* sndbuff;
-	int i, j, k, currentMSSval = 0;
-	int SndMax = 0, SndUna = 0;
-	fd_set wfd;
-	struct timeval sel_tv;
-	int ret;
-	char tmpstr[200];
-	size_t tmpstrlen = sizeof(tmpstr);
-	I2Addr addr = NULL;
-	web100_var *LimCwnd;
-	u_int32_t limcwnd_val;
-
-	// middlebox test results
-	static char vars[][255] = { "CurMSS", "WinScaleSent", "WinScaleRecv", };
-
-	assert(results);
-
-	log_println(4, "Looking for Web100 data on socketid %d", sock);
-
-	// get Server address and add to "results"
-
-	// get socket name
-	addr = I2AddrByLocalSockFD(get_errhandle(), sock, False);
-	memset(tmpstr, 0, 200);
-	// copy address into tmpstr String
-	I2AddrNodeName(addr, tmpstr, &tmpstrlen);
-	// now copy tmpstr containing address into "line"
-	snprintf(line, sizeof(line), "%s;", tmpstr);
-	memset(tmpstr, 0, 200);
-	// service name into tmpstr
-	I2AddrServName(addr, tmpstr, &tmpstrlen);
-	log_print(3, "Server: %s%s ", line, tmpstr);
-	// copy servers address into the meta test struct
-	memcpy(meta.server_ip, line, strlen(line));
-	// terminate the IP address string
-	meta.server_ip[(strlen(line) - 1)] = 0;
-	// Add this address to results
-	strlcat(results, line, results_strlen);
-	I2AddrFree(addr); // free memory
-
-	// Now perform the above set of functions for client address/service name
-	// and copy into results
-	tmpstrlen = sizeof(tmpstr);
-	addr = I2AddrBySockFD(get_errhandle(), sock, False);
-	memset(tmpstr, 0, 200);
-	I2AddrNodeName(addr, tmpstr, &tmpstrlen);
-	snprintf(line, sizeof(line), "%s;", tmpstr);
-	I2AddrServName(addr, tmpstr, &tmpstrlen);
-	log_print(3, "Client: %s%s ", line, tmpstr);
-	strlcat(results, line, results_strlen);
-	I2AddrFree(addr);
-
-	// get web100 values for the middlebox test result group
-	for (i = 0; i < 3; i++) {
-		// read web100_group and web100_var of vars[i] into group and var
-		web100_agent_find_var_and_group(agent, vars[i], &group, &var);
-		web100_raw_read(var, cn, buff); // read variable value from web100 connection
-
-		// get current MSS in textual format and append to results
-
-		//get current MSS value and append to "results"
-		if (strcmp(vars[i], "CurMSS") == 0)
-			currentMSSval = atoi(
-					web100_value_to_text(web100_get_var_type(var), buff));
-		snprintf(line, sizeof(line), "%s;",
-				web100_value_to_text(web100_get_var_type(var), buff));
-		if (strcmp(line, "4294967295;") == 0)
-			snprintf(line, sizeof(line), "%d;", -1);
-
-		//strlcat(results, line, sizeof(results));
-		strlcat(results, line, results_strlen);
-		log_print(3, "%s", line);
-	}
-	log_println(3, "");
-	log_println(0, "Sending %d Byte packets over the network, and data=%s", currentMSSval, line);
-
-	/* The initial check has been completed, now stream data to the remote client
-	 * for 5 seconds with very limited buffer space.  The idea is to see if there
-	 * is a difference between this test and the later s2c speed test.  If so, then
-	 * it may be due to a duplex mismatch condition.
-	 * RAC 2/28/06
-	 */
-
-	// get web100_var and web100_group
-	web100_agent_find_var_and_group(agent, "LimCwnd", &group, &LimCwnd);
-
-	// set TCP CWND web100 variable to twice the current MSS Value
-	limcwnd_val = 2 * currentMSSval;
-	web100_raw_write(LimCwnd, cn, &limcwnd_val);
-	log_println(5, "Setting Cwnd Limit to %d octets", limcwnd_val);
-
-	// try to allocate memory of the size of current MSS Value
-	sndbuff = malloc(currentMSSval);
-	if (sndbuff == NULL) { // not possible, use MIDDLEBOX_PREDEFINED_MSS bytes
-		log_println(0,
-				"Failed to allocate memory --> switching to 8192 Byte packets");
-		sndbuff = buff;
-		currentMSSval = MIDDLEBOX_PREDEFINED_MSS;
-	}
-	if (getuid() == 0) {
-		system("echo 1 > /proc/sys/net/ipv4/route/flush");
-	}
-
-	// fill send buffer with random printable data
-
-	k = 0;
-	for (j = 0; j < currentMSSval; j++) {
-		while (!isprint(k & 0x7f)) // Is character printable?
-			k++;
-		sndbuff[j] = (k++ & 0x7f);
-	}
-
-	// get web100 group with name "read"
-	group = web100_group_find(agent, "read");
-	snap = web100_snapshot_alloc(group, cn);
-
-	FD_ZERO(&wfd);
-	FD_SET(sock, &wfd);
-	sel_tv.tv_sec = 5; // 5 seconds maximum for select call below to complete
-	sel_tv.tv_usec = 0; // 5s + 0ms
-	while ((ret = select(sock + 1, NULL, &wfd, NULL, &sel_tv)) > 0) {
-		if ((ret == -1) && (errno == EINTR)) /* a signal arrived, ignore it */
-			continue;
-
-		web100_snap(snap);
-
-		// get next sequence # to be sent
-		web100_agent_find_var_and_group(agent, "SndNxt", &group, &var);
-		web100_snap_read(var, snap, line);
-		SndMax = atoi(web100_value_to_text(web100_get_var_type(var), line));
-		// get oldest un-acked sequence number
-		web100_agent_find_var_and_group(agent, "SndUna", &group, &var);
-		web100_snap_read(var, snap, line);
-		SndUna = atoi(web100_value_to_text(web100_get_var_type(var), line));
-
-		// stop sending data if (buf size * 16) < 
-		//  	[ (Next Sequence # To Be Sent) - (Oldest Unacknowledged Sequence #) - 1 ]
-		if ((currentMSSval << 4) < (SndMax - SndUna - 1)) {
-			continue;
-		}
-
-		// write currentMSSval number of bytes from send-buffer data into socket
-		k = write(sock, sndbuff, currentMSSval);
-		if ((k == -1) && (errno == EINTR)) // error writing into socket due
-										   // to interruption, try again
-			continue;
-		if (k < 0) // general error writing to socket. quit
-			break;
-	}
-	log_println(5,
-			"Finished with web100_middlebox() routine snap-0x%x, sndbuff=%x0x",
-			snap, sndbuff);
-	web100_snapshot_free(snap);
-	/* free(sndbuff); */
+                      char *results, size_t results_strlen) {
+
+  web100_var* var;
+  web100_group* group;
+  web100_snapshot* snap;
+  char buff[8192], line[256];
+  char* sndbuff;
+  int i, j, k, currentMSSval = 0;
+  int SndMax = 0, SndUna = 0;
+  fd_set wfd;
+  struct timeval sel_tv;
+  int ret;
+  char tmpstr[200];
+  size_t tmpstrlen = sizeof(tmpstr);
+  I2Addr addr = NULL;
+  web100_var *LimCwnd;
+  u_int32_t limcwnd_val;
+
+  // middlebox test results
+  static char vars[][255] = { "CurMSS", "WinScaleSent", "WinScaleRecv", };
+
+  assert(results);
+
+  log_println(4, "Looking for Web100 data on socketid %d", sock);
+
+  // get Server address and add to "results"
+
+  // get socket name
+  addr = I2AddrByLocalSockFD(get_errhandle(), sock, False);
+  memset(tmpstr, 0, 200);
+  // copy address into tmpstr String
+  I2AddrNodeName(addr, tmpstr, &tmpstrlen);
+  // now copy tmpstr containing address into "line"
+  snprintf(line, sizeof(line), "%s;", tmpstr);
+  memset(tmpstr, 0, 200);
+  // service name into tmpstr
+  I2AddrServName(addr, tmpstr, &tmpstrlen);
+  log_print(3, "Server: %s%s ", line, tmpstr);
+  // copy servers address into the meta test struct
+  memcpy(meta.server_ip, line, strlen(line));
+  // terminate the IP address string
+  meta.server_ip[(strlen(line) - 1)] = 0;
+  // Add this address to results
+  strlcat(results, line, results_strlen);
+  I2AddrFree(addr); // free memory
+
+  // Now perform the above set of functions for client address/service name
+  // and copy into results
+  tmpstrlen = sizeof(tmpstr);
+  addr = I2AddrBySockFD(get_errhandle(), sock, False);
+  memset(tmpstr, 0, 200);
+  I2AddrNodeName(addr, tmpstr, &tmpstrlen);
+  snprintf(line, sizeof(line), "%s;", tmpstr);
+  I2AddrServName(addr, tmpstr, &tmpstrlen);
+  log_print(3, "Client: %s%s ", line, tmpstr);
+  strlcat(results, line, results_strlen);
+  I2AddrFree(addr);
+
+  // get web100 values for the middlebox test result group
+  for (i = 0; i < 3; i++) {
+    // read web100_group and web100_var of vars[i] into group and var
+    web100_agent_find_var_and_group(agent, vars[i], &group, &var);
+    web100_raw_read(var, cn, buff); // read variable value from web100 connection
+
+    // get current MSS in textual format and append to results
+
+    //get current MSS value and append to "results"
+    if (strcmp(vars[i], "CurMSS") == 0)
+      currentMSSval = atoi(
+          web100_value_to_text(web100_get_var_type(var), buff));
+    snprintf(line, sizeof(line), "%s;",
+             web100_value_to_text(web100_get_var_type(var), buff));
+    if (strcmp(line, "4294967295;") == 0)
+      snprintf(line, sizeof(line), "%d;", -1);
+
+    //strlcat(results, line, sizeof(results));
+    strlcat(results, line, results_strlen);
+    log_print(3, "%s", line);
+  }
+  log_println(3, "");
+  log_println(0, "Sending %d Byte packets over the network, and data=%s", currentMSSval, line);
+
+  /* The initial check has been completed, now stream data to the remote client
+   * for 5 seconds with very limited buffer space.  The idea is to see if there
+   * is a difference between this test and the later s2c speed test.  If so, then
+   * it may be due to a duplex mismatch condition.
+   * RAC 2/28/06
+   */
+
+  // get web100_var and web100_group
+  web100_agent_find_var_and_group(agent, "LimCwnd", &group, &LimCwnd);
+
+  // set TCP CWND web100 variable to twice the current MSS Value
+  limcwnd_val = 2 * currentMSSval;
+  web100_raw_write(LimCwnd, cn, &limcwnd_val);
+  log_println(5, "Setting Cwnd Limit to %d octets", limcwnd_val);
+
+  // try to allocate memory of the size of current MSS Value
+  sndbuff = malloc(currentMSSval);
+  if (sndbuff == NULL) { // not possible, use MIDDLEBOX_PREDEFINED_MSS bytes
+    log_println(0,
+                "Failed to allocate memory --> switching to 8192 Byte packets");
+    sndbuff = buff;
+    currentMSSval = MIDDLEBOX_PREDEFINED_MSS;
+  }
+  if (getuid() == 0) {
+    system("echo 1 > /proc/sys/net/ipv4/route/flush");
+  }
+
+  // fill send buffer with random printable data
+
+  k = 0;
+  for (j = 0; j < currentMSSval; j++) {
+    while (!isprint(k & 0x7f)) // Is character printable?
+      k++;
+    sndbuff[j] = (k++ & 0x7f);
+  }
+
+  // get web100 group with name "read"
+  group = web100_group_find(agent, "read");
+  snap = web100_snapshot_alloc(group, cn);
+
+  FD_ZERO(&wfd);
+  FD_SET(sock, &wfd);
+  sel_tv.tv_sec = 5; // 5 seconds maximum for select call below to complete
+  sel_tv.tv_usec = 0; // 5s + 0ms
+  while ((ret = select(sock + 1, NULL, &wfd, NULL, &sel_tv)) > 0) {
+    if ((ret == -1) && (errno == EINTR)) /* a signal arrived, ignore it */
+      continue;
+
+    web100_snap(snap);
+
+    // get next sequence # to be sent
+    web100_agent_find_var_and_group(agent, "SndNxt", &group, &var);
+    web100_snap_read(var, snap, line);
+    SndMax = atoi(web100_value_to_text(web100_get_var_type(var), line));
+    // get oldest un-acked sequence number
+    web100_agent_find_var_and_group(agent, "SndUna", &group, &var);
+    web100_snap_read(var, snap, line);
+    SndUna = atoi(web100_value_to_text(web100_get_var_type(var), line));
+
+    // stop sending data if (buf size * 16) < 
+    //  	[ (Next Sequence # To Be Sent) - (Oldest Unacknowledged Sequence #) - 1 ]
+    if ((currentMSSval << 4) < (SndMax - SndUna - 1)) {
+      continue;
+    }
+
+    // write currentMSSval number of bytes from send-buffer data into socket
+    k = write(sock, sndbuff, currentMSSval);
+    if ((k == -1) && (errno == EINTR)) // error writing into socket due
+      // to interruption, try again
+      continue;
+    if (k < 0) // general error writing to socket. quit
+      break;
+  }
+  log_println(5,
+              "Finished with web100_middlebox() routine snap-0x%x, sndbuff=%x0x",
+              snap, sndbuff);
+  web100_snapshot_free(snap);
+  /* free(sndbuff); */
 }
 
 /**
@@ -246,68 +246,68 @@ void web100_middlebox(int sock, web100_agent* agent, web100_connection* cn,
  *
  */
 void web100_get_data_recv(int sock, web100_agent* agent, web100_connection* cn,
-		int count_vars) {
-	int i, ok;
-	web100_var* var;
-	char buf[32], line[256], *ctime();
-	web100_group* group;
-	FILE * fp;
-	time_t tt;
-
-	// get current time
-	tt = time(0);
-	// open logfile in append mode and write time into it
-	fp = fopen(get_logfile(), "a");
-	if (fp)
-		fprintf(fp, "%15.15s;", ctime(&tt) + 4);
-	// get values for group, var of IP Address of the Remote host's side of connection
-	web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
-	web100_raw_read(var, cn, buf);
-	snprintf(line, sizeof(line), "%s;", web100_value_to_text(web100_get_var_type(var), buf));
-	// write remote address to log file
-	if (fp)
-		fprintf(fp, "%s", line);
-
-	ok = 1;
-
-	// get values for other web100 variables and write to the log file
-
-	for (i = 0; i < count_vars; i++) {
-		if ((web100_agent_find_var_and_group(agent, web_vars[i].name, &group,
-				&var)) != WEB100_ERR_SUCCESS) {
-			log_println(1, "Variable %d (%s) not found in KIS", i,
-					web_vars[i].name);
-			ok = 0;
-			continue;
-		}
-
-		if (cn == NULL) {
-			fprintf(
-					stderr,
-					"Web100_get_data_recv() failed, return to testing routine\n");
-			return;
-		}
-
-		if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
-			if (get_debuglvl() > 9)
-				web100_perror("web100_raw_read()");
-			continue;
-		}
-		if (ok == 1) {
-			snprintf(web_vars[i].value, sizeof(web_vars[i].value), "%s",
-					web100_value_to_text(web100_get_var_type(var), buf));
-			if (fp)
-				fprintf(fp, "%d;", (int32_t) atoi(web_vars[i].value));
-			log_println(9, "%s: %d", web_vars[i].name, atoi(web_vars[i].value));
-		}
-		ok = 1;
-	}
-
-	// close file pointers after web100 variables have been fetched
-	if (fp) {
-		fprintf(fp, "\n");
-		fclose(fp);
-	}
+                          int count_vars) {
+  int i, ok;
+  web100_var* var;
+  char buf[32], line[256], *ctime();
+  web100_group* group;
+  FILE * fp;
+  time_t tt;
+
+  // get current time
+  tt = time(0);
+  // open logfile in append mode and write time into it
+  fp = fopen(get_logfile(), "a");
+  if (fp)
+    fprintf(fp, "%15.15s;", ctime(&tt) + 4);
+  // get values for group, var of IP Address of the Remote host's side of connection
+  web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
+  web100_raw_read(var, cn, buf);
+  snprintf(line, sizeof(line), "%s;", web100_value_to_text(web100_get_var_type(var), buf));
+  // write remote address to log file
+  if (fp)
+    fprintf(fp, "%s", line);
+
+  ok = 1;
+
+  // get values for other web100 variables and write to the log file
+
+  for (i = 0; i < count_vars; i++) {
+    if ((web100_agent_find_var_and_group(agent, web_vars[i].name, &group,
+                                         &var)) != WEB100_ERR_SUCCESS) {
+      log_println(1, "Variable %d (%s) not found in KIS", i,
+                  web_vars[i].name);
+      ok = 0;
+      continue;
+    }
+
+    if (cn == NULL) {
+      fprintf(
+          stderr,
+          "Web100_get_data_recv() failed, return to testing routine\n");
+      return;
+    }
+
+    if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
+      if (get_debuglvl() > 9)
+        web100_perror("web100_raw_read()");
+      continue;
+    }
+    if (ok == 1) {
+      snprintf(web_vars[i].value, sizeof(web_vars[i].value), "%s",
+               web100_value_to_text(web100_get_var_type(var), buf));
+      if (fp)
+        fprintf(fp, "%d;", (int32_t) atoi(web_vars[i].value));
+      log_println(9, "%s: %d", web_vars[i].name, atoi(web_vars[i].value));
+    }
+    ok = 1;
+  }
+
+  // close file pointers after web100 variables have been fetched
+  if (fp) {
+    fprintf(fp, "\n");
+    fclose(fp);
+  }
 
 }
 
@@ -323,51 +323,51 @@ void web100_get_data_recv(int sock, web100_agent* agent, web100_connection* cn,
  *
  */
 int web100_get_data(web100_snapshot* snap, int ctlsock, web100_agent* agent,
-		int count_vars) {
-
-	int i;
-	web100_var* var;
-	char buf[32], line[256];
-	web100_group* group;
-
-	assert(snap);
-	assert(agent);
-
-	for (i = 0; i < count_vars; i++) {
-		if ((web100_agent_find_var_and_group(agent, web_vars[i].name, &group,
-				&var)) != WEB100_ERR_SUCCESS) {
-			log_println(9, "Variable %d (%s) not found in KIS: ", i,
-					web_vars[i].name);
-			continue;
-		}
-
-		// if no snapshot provided, no way to get values
-		if (snap == NULL) {
-			fprintf(stderr,
-					"Web100_get_data() failed, return to testing routine\n");
-			log_println(6,
-					"Web100_get_data() failed, return to testing routine\n");
-			return (-1);
-		}
-
-		// handle an unsuccessful data retrieval
-		if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
-			if (get_debuglvl() > 9) {
-				log_print(9, "Variable %d (%s): ", i, web_vars[i].name);
-				web100_perror("web100_snap_read()");
-			}
-			continue;
-		}
-
-		// assign values and transmit message with all web100 variables to socket receiver end
-		snprintf(web_vars[i].value, sizeof(web_vars[i].value), "%s",
-				web100_value_to_text(web100_get_var_type(var), buf));
-		snprintf(line, sizeof(line), "%s: %d\n", web_vars[i].name, atoi(web_vars[i].value));
-		send_msg(ctlsock, TEST_MSG, line, strlen(line));
-		log_print(9, "%s", line);
-	}
-	log_println(6, "S2C test - Send web100 data to client pid=%d", getpid());
-	return (0);
+                    int count_vars) {
+
+  int i;
+  web100_var* var;
+  char buf[32], line[256];
+  web100_group* group;
+
+  assert(snap);
+  assert(agent);
+
+  for (i = 0; i < count_vars; i++) {
+    if ((web100_agent_find_var_and_group(agent, web_vars[i].name, &group,
+                                         &var)) != WEB100_ERR_SUCCESS) {
+      log_println(9, "Variable %d (%s) not found in KIS: ", i,
+                  web_vars[i].name);
+      continue;
+    }
+
+    // if no snapshot provided, no way to get values
+    if (snap == NULL) {
+      fprintf(stderr,
+              "Web100_get_data() failed, return to testing routine\n");
+      log_println(6,
+                  "Web100_get_data() failed, return to testing routine\n");
+      return (-1);
+    }
+
+    // handle an unsuccessful data retrieval
+    if ((web100_snap_read(var, snap, buf)) != WEB100_ERR_SUCCESS) {
+      if (get_debuglvl() > 9) {
+        log_print(9, "Variable %d (%s): ", i, web_vars[i].name);
+        web100_perror("web100_snap_read()");
+      }
+      continue;
+    }
+
+    // assign values and transmit message with all web100 variables to socket receiver end
+    snprintf(web_vars[i].value, sizeof(web_vars[i].value), "%s",
+             web100_value_to_text(web100_get_var_type(var), buf));
+    snprintf(line, sizeof(line), "%s: %d\n", web_vars[i].name, atoi(web_vars[i].value));
+    send_msg(ctlsock, TEST_MSG, line, strlen(line));
+    log_print(9, "%s", line);
+  }
+  log_println(6, "S2C test - Send web100 data to client pid=%d", getpid());
+  return (0);
 
 }
 
@@ -390,30 +390,30 @@ int web100_get_data(web100_snapshot* snap, int ctlsock, web100_agent* agent,
  *
  */
 int web100_rtt(int sock, web100_agent* agent, web100_connection* cn) {
-	web100_var* var;
-	char buf[32];
-	web100_group* group;
-	double count, sum;
-
-	if (cn == NULL)
-		return (-10);
-
-	if ((web100_agent_find_var_and_group(agent, "CountRTT", &group, &var))
-			!= WEB100_ERR_SUCCESS)
-		return (-24);
-	if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
-		return (-25);
-	}
-	count = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-
-	if ((web100_agent_find_var_and_group(agent, "SumRTT", &group, &var))
-			!= WEB100_ERR_SUCCESS)
-		return (-24);
-	if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
-		return (-25);
-	}
-	sum = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-	return (sum / count);
+  web100_var* var;
+  char buf[32];
+  web100_group* group;
+  double count, sum;
+
+  if (cn == NULL)
+    return (-10);
+
+  if ((web100_agent_find_var_and_group(agent, "CountRTT", &group, &var))
+      != WEB100_ERR_SUCCESS)
+    return (-24);
+  if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
+    return (-25);
+  }
+  count = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+
+  if ((web100_agent_find_var_and_group(agent, "SumRTT", &group, &var))
+      != WEB100_ERR_SUCCESS)
+    return (-24);
+  if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
+    return (-25);
+  }
+  sum = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+  return (sum / count);
 }
 
 /**
@@ -434,46 +434,46 @@ int web100_rtt(int sock, web100_agent* agent, web100_connection* cn) {
  */
 
 int web100_autotune(int sock, web100_agent* agent, web100_connection* cn) {
-	web100_var* var;
-	char buf[32];
-	web100_group* group;
-	int i, j = 0;
-
-	if (cn == NULL)
-		return (10);
-
-	if ((web100_agent_find_var_and_group(agent, "X_SBufMode", &group, &var))
-			!= WEB100_ERR_SUCCESS)
-		return (22);
-	if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
-		log_println(4, "Web100_raw_read(X_SBufMode) failed with errorno=%d",
-				errno);
-		return (23);
-	}
-	i = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-
-	/* OK, the variable i now holds the value of the sbufmode autotune parm.  If it
-	 * is 0, autotuning is turned off, so we turn it on for this socket.
-	 */
-	if (i == 0)
-		j |= 0x01;
-
-	/* OK, the variable i now holds the value of the rbufmode autotune parm.  If it
-	 * is 0, autotuning is turned off, so we turn it on for this socket.
-	 */
-	if ((web100_agent_find_var_and_group(agent, "X_RBufMode", &group, &var))
-			!= WEB100_ERR_SUCCESS)
-		return (22);
-	if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
-		log_println(4, "Web100_raw_read(X_RBufMode) failed with errorno=%d",
-				errno);
-		return (23);
-	}
-	i = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-
-	if (i == 0)
-		j |= 0x02;
-	return (j);
+  web100_var* var;
+  char buf[32];
+  web100_group* group;
+  int i, j = 0;
+
+  if (cn == NULL)
+    return (10);
+
+  if ((web100_agent_find_var_and_group(agent, "X_SBufMode", &group, &var))
+      != WEB100_ERR_SUCCESS)
+    return (22);
+  if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
+    log_println(4, "Web100_raw_read(X_SBufMode) failed with errorno=%d",
+                errno);
+    return (23);
+  }
+  i = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+
+  /* OK, the variable i now holds the value of the sbufmode autotune parm.  If it
+   * is 0, autotuning is turned off, so we turn it on for this socket.
+   */
+  if (i == 0)
+    j |= 0x01;
+
+  /* OK, the variable i now holds the value of the rbufmode autotune parm.  If it
+   * is 0, autotuning is turned off, so we turn it on for this socket.
+   */
+  if ((web100_agent_find_var_and_group(agent, "X_RBufMode", &group, &var))
+      != WEB100_ERR_SUCCESS)
+    return (22);
+  if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
+    log_println(4, "Web100_raw_read(X_RBufMode) failed with errorno=%d",
+                errno);
+    return (23);
+  }
+  i = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+
+  if (i == 0)
+    j |= 0x02;
+  return (j);
 }
 
 /**
@@ -500,68 +500,68 @@ int web100_autotune(int sock, web100_agent* agent, web100_connection* cn) {
  *
  */
 int web100_setbuff(int sock, web100_agent* agent, web100_connection* cn,
-		int autotune) {
-	web100_var* var;
-	char buf[32];
-	web100_group* group;
-	int buff;
-	int sScale, rScale;
-
-	if (cn == NULL)
-		return (10);
-
-	// get Window scale used by the sender to decode snd.wnd
-	if ((web100_agent_find_var_and_group(agent, "SndWinScale", &group, &var))
-			!= WEB100_ERR_SUCCESS)
-		return (24);
-	if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
-		return (25);
-	}
-	sScale = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-	if (sScale > 15) // define constant for 15
-		sScale = 0;
-
-	// get Window scale used by the sender to decode seg.wnd
-	if ((web100_agent_find_var_and_group(agent, "RcvWinScale", &group, &var))
-			!= WEB100_ERR_SUCCESS)
-		return (34);
-	if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
-		return (35);
-	}
-	rScale = atoi(web100_value_to_text(web100_get_var_type(var), buf));
-	if (rScale > 15)
-		rScale = 0;
-
-	if ((sScale > 0) && (rScale > 0)) {
-		buff = (MAX_TCP_WIN_BYTES * KILO_BITS) << sScale; // 64k( max TCP rcv window)
-		if (autotune & 0x01) { // autotune send buffer is not enabled
-			if ((web100_agent_find_var_and_group(agent, "LimCwnd", &group, &var))
-					!= WEB100_ERR_SUCCESS)
-				return (22);
-			// attempt writing variable value, log failure
-			if ((web100_raw_write(var, cn, &buff)) != WEB100_ERR_SUCCESS) {
-				log_println(4,
-						"Web100_raw_write(LimCwnd) failed with errorno=%d",
-						errno);
-				return (23);
-			}
-		}
-		buff = (MAX_TCP_WIN_BYTES * KILO_BITS) << rScale;
-
-		if (autotune & 0x02) { // autotune receive buffer is not enabled
-			if ((web100_agent_find_var_and_group(agent, "LimRwin", &group, &var))
-					!= WEB100_ERR_SUCCESS)
-				return (22);
-			if ((web100_raw_write(var, cn, &buff)) != WEB100_ERR_SUCCESS) {
-				log_println(4,
-						"Web100_raw_write(LimRwin) failed with errorno=%d",
-						errno);
-				return (23);
-			}
-		}
-	}
-
-	return (0);
+                   int autotune) {
+  web100_var* var;
+  char buf[32];
+  web100_group* group;
+  int buff;
+  int sScale, rScale;
+
+  if (cn == NULL)
+    return (10);
+
+  // get Window scale used by the sender to decode snd.wnd
+  if ((web100_agent_find_var_and_group(agent, "SndWinScale", &group, &var))
+      != WEB100_ERR_SUCCESS)
+    return (24);
+  if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
+    return (25);
+  }
+  sScale = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+  if (sScale > 15) // define constant for 15
+    sScale = 0;
+
+  // get Window scale used by the sender to decode seg.wnd
+  if ((web100_agent_find_var_and_group(agent, "RcvWinScale", &group, &var))
+      != WEB100_ERR_SUCCESS)
+    return (34);
+  if ((web100_raw_read(var, cn, buf)) != WEB100_ERR_SUCCESS) {
+    return (35);
+  }
+  rScale = atoi(web100_value_to_text(web100_get_var_type(var), buf));
+  if (rScale > 15)
+    rScale = 0;
+
+  if ((sScale > 0) && (rScale > 0)) {
+    buff = (MAX_TCP_WIN_BYTES * KILO_BITS) << sScale; // 64k( max TCP rcv window)
+    if (autotune & 0x01) { // autotune send buffer is not enabled
+      if ((web100_agent_find_var_and_group(agent, "LimCwnd", &group, &var))
+          != WEB100_ERR_SUCCESS)
+        return (22);
+      // attempt writing variable value, log failure
+      if ((web100_raw_write(var, cn, &buff)) != WEB100_ERR_SUCCESS) {
+        log_println(4,
+                    "Web100_raw_write(LimCwnd) failed with errorno=%d",
+                    errno);
+        return (23);
+      }
+    }
+    buff = (MAX_TCP_WIN_BYTES * KILO_BITS) << rScale;
+
+    if (autotune & 0x02) { // autotune receive buffer is not enabled
+      if ((web100_agent_find_var_and_group(agent, "LimRwin", &group, &var))
+          != WEB100_ERR_SUCCESS)
+        return (22);
+      if ((web100_raw_write(var, cn, &buff)) != WEB100_ERR_SUCCESS) {
+        log_println(4,
+                    "Web100_raw_write(LimRwin) failed with errorno=%d",
+                    errno);
+        return (23);
+      }
+    }
+  }
+
+  return (0);
 }
 
 /**
@@ -572,101 +572,101 @@ int web100_setbuff(int sock, web100_agent* agent, web100_connection* cn,
  *
  */
 int web100_logvars(int *Timeouts, int *SumRTT, int *CountRTT, int *PktsRetrans,
-		int *FastRetran, int *DataPktsOut, int *AckPktsOut, int *CurrentMSS,
-		int *DupAcksIn, int *AckPktsIn, int *MaxRwinRcvd, int *Sndbuf,
-		int *CurrentCwnd, int *SndLimTimeRwin, int *SndLimTimeCwnd,
-		int *SndLimTimeSender, int *DataBytesOut, int *SndLimTransRwin,
-		int *SndLimTransCwnd, int *SndLimTransSender, int *MaxSsthresh,
-		int *CurrentRTO, int *CurrentRwinRcvd, int *MaxCwnd,
-		int *CongestionSignals, int *PktsOut, int *MinRTT, int count_vars,
-		int *RcvWinScale, int *SndWinScale, int *CongAvoid,
-		int *CongestionOverCount, int *MaxRTT, int *OtherReductions,
-		int *CurTimeoutCount, int *AbruptTimeouts, int *SendStall,
-		int *SlowStart, int *SubsequentTimeouts, int *ThruBytesAcked) {
-	int i;
-
-	for (i = 0; i <= count_vars; i++) {
-		if (strcmp(web_vars[i].name, "Timeouts") == 0)
-			*Timeouts = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SumRTT") == 0)
-			*SumRTT = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CountRTT") == 0)
-			*CountRTT = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "PktsRetrans") == 0)
-			*PktsRetrans = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "FastRetran") == 0)
-			*FastRetran = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "DataPktsOut") == 0)
-			*DataPktsOut = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "AckPktsOut") == 0)
-			*AckPktsOut = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CurMSS") == 0)
-			*CurrentMSS = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "DupAcksIn") == 0)
-			*DupAcksIn = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "AckPktsIn") == 0)
-			*AckPktsIn = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "MaxRwinRcvd") == 0)
-			*MaxRwinRcvd = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "X_Sndbuf") == 0)
-			*Sndbuf = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CurCwnd") == 0)
-			*CurrentCwnd = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "MaxCwnd") == 0)
-			*MaxCwnd = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SndLimTimeRwin") == 0)
-			*SndLimTimeRwin = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SndLimTimeCwnd") == 0)
-			*SndLimTimeCwnd = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SndLimTimeSender") == 0)
-			*SndLimTimeSender = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "DataBytesOut") == 0)
-			*DataBytesOut = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SndLimTransRwin") == 0)
-			*SndLimTransRwin = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SndLimTransCwnd") == 0)
-			*SndLimTransCwnd = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SndLimTransSender") == 0)
-			*SndLimTransSender = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "MaxSsthresh") == 0)
-			*MaxSsthresh = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CurRTO") == 0)
-			*CurrentRTO = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CurRwinRcvd") == 0)
-			*CurrentRwinRcvd = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CongestionSignals") == 0)
-			*CongestionSignals = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "PktsOut") == 0)
-			*PktsOut = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "MinRTT") == 0)
-			*MinRTT = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "RcvWinScale") == 0)
-			*RcvWinScale = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SndWinScale") == 0)
-			*SndWinScale = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CongAvoid") == 0)
-			*CongAvoid = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CongestionOverCount") == 0)
-			*CongestionOverCount = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "MaxRTT") == 0)
-			*MaxRTT = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "OtherReductions") == 0)
-			*OtherReductions = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "CurTimeoutCount") == 0)
-			*CurTimeoutCount = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "AbruptTimeouts") == 0)
-			*AbruptTimeouts = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SendStall") == 0)
-			*SendStall = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SlowStart") == 0)
-			*SlowStart = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "SubsequentTimeouts") == 0)
-			*SubsequentTimeouts = atoi(web_vars[i].value);
-		else if (strcmp(web_vars[i].name, "ThruBytesAcked") == 0)
-			*ThruBytesAcked = atoi(web_vars[i].value);
-	}
-
-	return (0);
+                   int *FastRetran, int *DataPktsOut, int *AckPktsOut, int *CurrentMSS,
+                   int *DupAcksIn, int *AckPktsIn, int *MaxRwinRcvd, int *Sndbuf,
+                   int *CurrentCwnd, int *SndLimTimeRwin, int *SndLimTimeCwnd,
+                   int *SndLimTimeSender, int *DataBytesOut, int *SndLimTransRwin,
+                   int *SndLimTransCwnd, int *SndLimTransSender, int *MaxSsthresh,
+                   int *CurrentRTO, int *CurrentRwinRcvd, int *MaxCwnd,
+                   int *CongestionSignals, int *PktsOut, int *MinRTT, int count_vars,
+                   int *RcvWinScale, int *SndWinScale, int *CongAvoid,
+                   int *CongestionOverCount, int *MaxRTT, int *OtherReductions,
+                   int *CurTimeoutCount, int *AbruptTimeouts, int *SendStall,
+                   int *SlowStart, int *SubsequentTimeouts, int *ThruBytesAcked) {
+  int i;
+
+  for (i = 0; i <= count_vars; i++) {
+    if (strcmp(web_vars[i].name, "Timeouts") == 0)
+      *Timeouts = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SumRTT") == 0)
+      *SumRTT = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CountRTT") == 0)
+      *CountRTT = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "PktsRetrans") == 0)
+      *PktsRetrans = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "FastRetran") == 0)
+      *FastRetran = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "DataPktsOut") == 0)
+      *DataPktsOut = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "AckPktsOut") == 0)
+      *AckPktsOut = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CurMSS") == 0)
+      *CurrentMSS = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "DupAcksIn") == 0)
+      *DupAcksIn = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "AckPktsIn") == 0)
+      *AckPktsIn = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "MaxRwinRcvd") == 0)
+      *MaxRwinRcvd = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "X_Sndbuf") == 0)
+      *Sndbuf = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CurCwnd") == 0)
+      *CurrentCwnd = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "MaxCwnd") == 0)
+      *MaxCwnd = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SndLimTimeRwin") == 0)
+      *SndLimTimeRwin = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SndLimTimeCwnd") == 0)
+      *SndLimTimeCwnd = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SndLimTimeSender") == 0)
+      *SndLimTimeSender = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "DataBytesOut") == 0)
+      *DataBytesOut = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SndLimTransRwin") == 0)
+      *SndLimTransRwin = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SndLimTransCwnd") == 0)
+      *SndLimTransCwnd = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SndLimTransSender") == 0)
+      *SndLimTransSender = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "MaxSsthresh") == 0)
+      *MaxSsthresh = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CurRTO") == 0)
+      *CurrentRTO = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CurRwinRcvd") == 0)
+      *CurrentRwinRcvd = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CongestionSignals") == 0)
+      *CongestionSignals = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "PktsOut") == 0)
+      *PktsOut = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "MinRTT") == 0)
+      *MinRTT = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "RcvWinScale") == 0)
+      *RcvWinScale = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SndWinScale") == 0)
+      *SndWinScale = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CongAvoid") == 0)
+      *CongAvoid = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CongestionOverCount") == 0)
+      *CongestionOverCount = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "MaxRTT") == 0)
+      *MaxRTT = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "OtherReductions") == 0)
+      *OtherReductions = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "CurTimeoutCount") == 0)
+      *CurTimeoutCount = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "AbruptTimeouts") == 0)
+      *AbruptTimeouts = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SendStall") == 0)
+      *SendStall = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SlowStart") == 0)
+      *SlowStart = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "SubsequentTimeouts") == 0)
+      *SubsequentTimeouts = atoi(web_vars[i].value);
+    else if (strcmp(web_vars[i].name, "ThruBytesAcked") == 0)
+      *ThruBytesAcked = atoi(web_vars[i].value);
+  }
+
+  return (0);
 }
 
 /**
@@ -683,67 +683,67 @@ int web100_logvars(int *Timeouts, int *SumRTT, int *CountRTT, int *PktsRetrans,
  */
 
 int CwndDecrease(web100_agent* agent, char* logname, u_int32_t *dec_cnt,
-		u_int32_t *same_cnt, u_int32_t *inc_cnt) {
-
-	web100_var* var;
-	char buff[256];
-	web100_snapshot* snap;
-	int s1, s2, cnt, rt;
-	web100_log* log;
-	web100_group* group;
-	web100_agent* agnt;
-
-	// open snaplog file to read values
-	if ((log = web100_log_open_read(logname)) == NULL)
-		return (0);
-	if ((snap = web100_snapshot_alloc_from_log(log)) == NULL)
-		return (-1);
-	if ((agnt = web100_get_log_agent(log)) == NULL)
-		return (-1);
-	if ((group = web100_get_log_group(log)) == NULL)
-		return (-1);
-
-	// Find current values of the congestion window
-	if (web100_agent_find_var_and_group(agnt, "CurCwnd", &group, &var)
-			!= WEB100_ERR_SUCCESS)
-		return (-1);
-	s2 = 0;
-	cnt = 0;
-
-	// get values and update counts
-	while (web100_snap_from_log(snap, log) == 0) {
-		if (cnt++ == 0)
-			continue;
-		s1 = s2;
-		// Parse snapshot, returning variable values
-		rt = web100_snap_read(var, snap, buff);
-		s2 = atoi(web100_value_to_text(web100_get_var_type(var), buff));
-		if (cnt < 20) {
-			log_println(7, "Reading snaplog %p (%d), var = %s", snap, cnt, (char*) var);
-			log_println(
-					7,
-					"Checking for Cwnd decreases. rt=%d, s1=%d, s2=%d (%s), dec-cnt=%d",
-					rt, s1, s2,
-					web100_value_to_text(web100_get_var_type(var), buff),
-					*dec_cnt);
-		}
-		if (s2 < s1)
-			(*dec_cnt)++;
-		if (s2 == s1)
-			(*same_cnt)++;
-		if (s2 > s1)
-			(*inc_cnt)++;
-
-		if (rt != WEB100_ERR_SUCCESS)
-			break;
-	}
-	web100_snapshot_free(snap);
-	web100_log_close_read(log);
-	log_println(
-			2,
-			"-=-=-=- CWND window report: increases = %d, decreases = %d, no change = %d",
-			*inc_cnt, *dec_cnt, *same_cnt);
-	return (0);
+                 u_int32_t *same_cnt, u_int32_t *inc_cnt) {
+
+  web100_var* var;
+  char buff[256];
+  web100_snapshot* snap;
+  int s1, s2, cnt, rt;
+  web100_log* log;
+  web100_group* group;
+  web100_agent* agnt;
+
+  // open snaplog file to read values
+  if ((log = web100_log_open_read(logname)) == NULL)
+    return (0);
+  if ((snap = web100_snapshot_alloc_from_log(log)) == NULL)
+    return (-1);
+  if ((agnt = web100_get_log_agent(log)) == NULL)
+    return (-1);
+  if ((group = web100_get_log_group(log)) == NULL)
+    return (-1);
+
+  // Find current values of the congestion window
+  if (web100_agent_find_var_and_group(agnt, "CurCwnd", &group, &var)
+      != WEB100_ERR_SUCCESS)
+    return (-1);
+  s2 = 0;
+  cnt = 0;
+
+  // get values and update counts
+  while (web100_snap_from_log(snap, log) == 0) {
+    if (cnt++ == 0)
+      continue;
+    s1 = s2;
+    // Parse snapshot, returning variable values
+    rt = web100_snap_read(var, snap, buff);
+    s2 = atoi(web100_value_to_text(web100_get_var_type(var), buff));
+    if (cnt < 20) {
+      log_println(7, "Reading snaplog %p (%d), var = %s", snap, cnt, (char*) var);
+      log_println(
+          7,
+          "Checking for Cwnd decreases. rt=%d, s1=%d, s2=%d (%s), dec-cnt=%d",
+          rt, s1, s2,
+          web100_value_to_text(web100_get_var_type(var), buff),
+          *dec_cnt);
+    }
+    if (s2 < s1)
+      (*dec_cnt)++;
+    if (s2 == s1)
+      (*same_cnt)++;
+    if (s2 > s1)
+      (*inc_cnt)++;
+
+    if (rt != WEB100_ERR_SUCCESS)
+      break;
+  }
+  web100_snapshot_free(snap);
+  web100_log_close_read(log);
+  log_println(
+      2,
+      "-=-=-=- CWND window report: increases = %d, decreases = %d, no change = %d",
+      *inc_cnt, *dec_cnt, *same_cnt);
+  return (0);
 }
 
 /**
@@ -755,33 +755,33 @@ int CwndDecrease(web100_agent* agent, char* logname, u_int32_t *dec_cnt,
  */
 unsigned short csum(unsigned short *buff, int nwords) {
 
-	/* generate a TCP/IP checksum for our packet */
-
-	register int sum = 0;
-	u_short answer = 0;
-	register u_short *w = buff;
-	register int nleft = nwords;
-
-	// make 16 bit words out of every couple of 8 bit words and
-	// add up
-	while (nleft > 1) {
-		sum += *w++;
-		nleft -= 2;
-	}
-
-	if (nleft == 1) {
-		*(u_char *) (&answer) = *(u_char *) w;
-		sum += answer;
-	}
-
-	// form 16 bit words, add and store
-	sum = (sum >> 16) + (sum & 0xffff);
-	// then add carries to the sume
-	sum += (sum >> 16);
-
-	// 1s complement of the above yields checksum
-	answer = ~sum;
-	return (answer);
+  /* generate a TCP/IP checksum for our packet */
+
+  register int sum = 0;
+  u_short answer = 0;
+  register u_short *w = buff;
+  register int nleft = nwords;
+
+  // make 16 bit words out of every couple of 8 bit words and
+  // add up
+  while (nleft > 1) {
+    sum += *w++;
+    nleft -= 2;
+  }
+
+  if (nleft == 1) {
+    *(u_char *) (&answer) = *(u_char *) w;
+    sum += answer;
+  }
+
+  // form 16 bit words, add and store
+  sum = (sum >> 16) + (sum & 0xffff);
+  // then add carries to the sume
+  sum += (sum >> 16);
+
+  // 1s complement of the above yields checksum
+  answer = ~sum;
+  return (answer);
 }
 
 /**
@@ -795,145 +795,145 @@ unsigned short csum(unsigned short *buff, int nwords) {
 int KillHung(void)
 
 {
-	web100_agent *agent;
-	web100_group *group;
-	web100_var *state, *var;
-	web100_connection *conn;
-	int cid, one = 1, hung = 0;
-	int sd;
-	char *pkt, buff[64];
-	struct in_addr src, dst;
-	struct iphdr *ip = NULL;
-	struct tcphdr *tcp;
-	struct sockaddr_in sin;
-	struct pseudo_hdr *phdr;
-
-	if ((agent = web100_attach(WEB100_AGENT_TYPE_LOCAL, NULL)) == NULL) {
-		web100_perror("web100_attach");
-		return (-1);
-	}
-
-	group = web100_group_head(agent);
-	conn = web100_connection_head(agent);
-
-	while (conn) {
-		cid = web100_get_connection_cid(conn);
-		web100_agent_find_var_and_group(agent, "State", &group, &state);
-		web100_raw_read(state, conn, buff);
-		if (atoi(web100_value_to_text(web100_get_var_type(state), buff)) == 9) {
-			/* Connection is in Last_Ack state, and probably stuck, so generate and
-			 send a FIN packet to the remote client.  This should force the connection
-			 to close
-			 */
-
-			log_println(3, "Connection %d was found in LastAck state", cid);
-			sin.sin_family = AF_INET;
-
-			pkt = malloc(sizeof(struct iphdr) + sizeof(struct tcphdr) + 24);
-			memset(pkt, 0, (24 + sizeof(struct iphdr) + sizeof(struct tcphdr)));
-			sd = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
-			ip = (struct iphdr *) pkt;
-			tcp = (struct tcphdr *) (pkt + sizeof(struct iphdr));
-			phdr = (struct pseudo_hdr *) (pkt + sizeof(struct iphdr)
-					- sizeof(struct pseudo_hdr));
-
-			/* Build the TCP packet first, along with the pseudo header, the later
-			 * the IP header build process will overwrite the pseudo header fields
-			 */
-
-			web100_agent_find_var_and_group(agent, "LocalAddress", &group,
-					&var);
-			web100_raw_read(var, conn, buff);
-			log_println(3, "LocalAddress: '%s'",
-					web100_value_to_text(web100_get_var_type(var), buff));
-			dst.s_addr = inet_addr(
-					web100_value_to_text(web100_get_var_type(var), buff));
-			web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
-			web100_raw_read(var, conn, buff);
-			src.s_addr = inet_addr(
-					web100_value_to_text(web100_get_var_type(var), buff));
-			log_println(3, "RemAddress: '%s'",
-					web100_value_to_text(web100_get_var_type(var), buff));
-
-			phdr->protocol = IPPROTO_TCP;
-			phdr->len = htons(sizeof(struct tcphdr) / 4);
-			phdr->s_addr = src.s_addr;
-			phdr->d_addr = dst.s_addr;
-
-			web100_agent_find_var_and_group(agent, "LocalPort", &group, &var);
-			web100_raw_read(var, conn, buff);
-			tcp->dest = htons(
-					atoi(web100_value_to_text(web100_get_var_type(var), buff)));
-			log_println(3, "LocalPort: '%s'",
-					web100_value_to_text(web100_get_var_type(var), buff));
-			web100_agent_find_var_and_group(agent, "RemPort", &group, &var);
-			web100_raw_read(var, conn, buff);
-			tcp->source = htons(
-					atoi(web100_value_to_text(web100_get_var_type(var), buff)));
-			log_println(3, "RemPort: '%s'",
-					web100_value_to_text(web100_get_var_type(var), buff));
-			sin.sin_port = tcp->dest;
-
-			web100_agent_find_var_and_group(agent, "RcvNxt", &group, &var);
-			web100_raw_read(var, conn, buff);
-			tcp->seq = htonl(
-					atoll(
-							web100_value_to_text(web100_get_var_type(var),
-									buff)));
-			log_println(3, "Seq No. (RcvNxt): '%s'",
-					web100_value_to_text(web100_get_var_type(var), buff));
-			web100_agent_find_var_and_group(agent, "SndUna", &group, &var);
-			web100_raw_read(var, conn, buff);
-			tcp->ack_seq = htonl(
-					atoll(
-							web100_value_to_text(web100_get_var_type(var),
-									buff)));
-			log_println(3, "Ack No. (SndNxt): '%s'",
-					web100_value_to_text(web100_get_var_type(var), buff));
-
-			tcp->window = 0x7fff;
-			tcp->res1 = 0;
-			tcp->doff = sizeof(struct tcphdr) / 4;
-			/* tcp->syn = 1; */
-			tcp->rst = 1;
-			tcp->ack = 1;
-			/* tcp->fin = 1; */
-			tcp->urg_ptr = 0;
-			tcp->check = csum((unsigned short *) phdr,
-					sizeof(struct tcphdr) + sizeof(struct pseudo_hdr));
-
-			bzero(pkt, sizeof(struct iphdr));
-			ip->ihl = 5;
-			ip->version = 4;
-			ip->tos = 0;
-			ip->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
-			ip->id = htons(31890);
-			ip->frag_off = htons(IP_DF);
-			ip->ttl = IPDEFTTL;
-			ip->protocol = IPPROTO_TCP; /* TCP packet */
-			ip->saddr = src.s_addr;
-			ip->daddr = dst.s_addr;
-			sin.sin_addr.s_addr = dst.s_addr;
-
-			ip->check = csum((unsigned short *) pkt, sizeof(struct iphdr));
-
-			if (setsockopt(sd, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one)) < 0)
-				return (-1);
-
-			sendto(sd, (char *) pkt, 40, 0, (struct sockaddr *) &sin,
-					sizeof(sin));
-
-			hung = 1;
-
-		}
-		// returns the next connection in the sequence
-		conn = web100_connection_next(conn);
-	}
-
-	// close and free allocated agent
-	web100_detach(agent);
-	/* free(pkt); */
-	if (hung == 0)
-		return (-1);
-	return (0);
+  web100_agent *agent;
+  web100_group *group;
+  web100_var *state, *var;
+  web100_connection *conn;
+  int cid, one = 1, hung = 0;
+  int sd;
+  char *pkt, buff[64];
+  struct in_addr src, dst;
+  struct iphdr *ip = NULL;
+  struct tcphdr *tcp;
+  struct sockaddr_in sin;
+  struct pseudo_hdr *phdr;
+
+  if ((agent = web100_attach(WEB100_AGENT_TYPE_LOCAL, NULL)) == NULL) {
+    web100_perror("web100_attach");
+    return (-1);
+  }
+
+  group = web100_group_head(agent);
+  conn = web100_connection_head(agent);
+
+  while (conn) {
+    cid = web100_get_connection_cid(conn);
+    web100_agent_find_var_and_group(agent, "State", &group, &state);
+    web100_raw_read(state, conn, buff);
+    if (atoi(web100_value_to_text(web100_get_var_type(state), buff)) == 9) {
+      /* Connection is in Last_Ack state, and probably stuck, so generate and
+         send a FIN packet to the remote client.  This should force the connection
+         to close
+         */
+
+      log_println(3, "Connection %d was found in LastAck state", cid);
+      sin.sin_family = AF_INET;
+
+      pkt = malloc(sizeof(struct iphdr) + sizeof(struct tcphdr) + 24);
+      memset(pkt, 0, (24 + sizeof(struct iphdr) + sizeof(struct tcphdr)));
+      sd = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
+      ip = (struct iphdr *) pkt;
+      tcp = (struct tcphdr *) (pkt + sizeof(struct iphdr));
+      phdr = (struct pseudo_hdr *) (pkt + sizeof(struct iphdr)
+                                    - sizeof(struct pseudo_hdr));
+
+      /* Build the TCP packet first, along with the pseudo header, the later
+       * the IP header build process will overwrite the pseudo header fields
+       */
+
+      web100_agent_find_var_and_group(agent, "LocalAddress", &group,
+                                      &var);
+      web100_raw_read(var, conn, buff);
+      log_println(3, "LocalAddress: '%s'",
+                  web100_value_to_text(web100_get_var_type(var), buff));
+      dst.s_addr = inet_addr(
+          web100_value_to_text(web100_get_var_type(var), buff));
+      web100_agent_find_var_and_group(agent, "RemAddress", &group, &var);
+      web100_raw_read(var, conn, buff);
+      src.s_addr = inet_addr(
+          web100_value_to_text(web100_get_var_type(var), buff));
+      log_println(3, "RemAddress: '%s'",
+                  web100_value_to_text(web100_get_var_type(var), buff));
+
+      phdr->protocol = IPPROTO_TCP;
+      phdr->len = htons(sizeof(struct tcphdr) / 4);
+      phdr->s_addr = src.s_addr;
+      phdr->d_addr = dst.s_addr;
+
+      web100_agent_find_var_and_group(agent, "LocalPort", &group, &var);
+      web100_raw_read(var, conn, buff);
+      tcp->dest = htons(
+          atoi(web100_value_to_text(web100_get_var_type(var), buff)));
+      log_println(3, "LocalPort: '%s'",
+                  web100_value_to_text(web100_get_var_type(var), buff));
+      web100_agent_find_var_and_group(agent, "RemPort", &group, &var);
+      web100_raw_read(var, conn, buff);
+      tcp->source = htons(
+          atoi(web100_value_to_text(web100_get_var_type(var), buff)));
+      log_println(3, "RemPort: '%s'",
+                  web100_value_to_text(web100_get_var_type(var), buff));
+      sin.sin_port = tcp->dest;
+
+      web100_agent_find_var_and_group(agent, "RcvNxt", &group, &var);
+      web100_raw_read(var, conn, buff);
+      tcp->seq = htonl(
+          atoll(
+              web100_value_to_text(web100_get_var_type(var),
+                                   buff)));
+      log_println(3, "Seq No. (RcvNxt): '%s'",
+                  web100_value_to_text(web100_get_var_type(var), buff));
+      web100_agent_find_var_and_group(agent, "SndUna", &group, &var);
+      web100_raw_read(var, conn, buff);
+      tcp->ack_seq = htonl(
+          atoll(
+              web100_value_to_text(web100_get_var_type(var),
+                                   buff)));
+      log_println(3, "Ack No. (SndNxt): '%s'",
+                  web100_value_to_text(web100_get_var_type(var), buff));
+
+      tcp->window = 0x7fff;
+      tcp->res1 = 0;
+      tcp->doff = sizeof(struct tcphdr) / 4;
+      /* tcp->syn = 1; */
+      tcp->rst = 1;
+      tcp->ack = 1;
+      /* tcp->fin = 1; */
+      tcp->urg_ptr = 0;
+      tcp->check = csum((unsigned short *) phdr,
+                        sizeof(struct tcphdr) + sizeof(struct pseudo_hdr));
+
+      bzero(pkt, sizeof(struct iphdr));
+      ip->ihl = 5;
+      ip->version = 4;
+      ip->tos = 0;
+      ip->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
+      ip->id = htons(31890);
+      ip->frag_off = htons(IP_DF);
+      ip->ttl = IPDEFTTL;
+      ip->protocol = IPPROTO_TCP; /* TCP packet */
+      ip->saddr = src.s_addr;
+      ip->daddr = dst.s_addr;
+      sin.sin_addr.s_addr = dst.s_addr;
+
+      ip->check = csum((unsigned short *) pkt, sizeof(struct iphdr));
+
+      if (setsockopt(sd, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one)) < 0)
+        return (-1);
+
+      sendto(sd, (char *) pkt, 40, 0, (struct sockaddr *) &sin,
+             sizeof(sin));
+
+      hung = 1;
+
+    }
+    // returns the next connection in the sequence
+    conn = web100_connection_next(conn);
+  }
+
+  // close and free allocated agent
+  web100_detach(agent);
+  /* free(pkt); */
+  if (hung == 0)
+    return (-1);
+  return (0);
 }
diff --git a/src/web100clt.c b/src/web100clt.c
index 7c0d12b..6608860 100644
--- a/src/web100clt.c
+++ b/src/web100clt.c
@@ -45,17 +45,17 @@ double loss, estimate, avgrtt, spd, waitsec, timesec, rttsec;
 double order, rwintime, sendtime, cwndtime, rwin, swin, cwin;
 double mylink;
 static struct option long_options[] = { { "name", 1, 0, 'n' }, { "port", 1, 0,
-		'p' }, { "debug", 0, 0, 'd' }, { "help", 0, 0, 'h' }, { "msglvl", 0, 0,
-				'l' }, { "web100variables", 0, 0, 301 }, { "buffer", 1, 0, 'b' }, {
-						"disablemid", 0, 0, 302 }, { "disablec2s", 0, 0, 303 }, { "disables2c",
-								0, 0, 304 }, { "disablesfw", 0, 0, 305 },
-								{ "protocol_log", 1, 0, 'u' },
-								{ "enableprotolog", 0, 0, 'e' },
+  'p' }, { "debug", 0, 0, 'd' }, { "help", 0, 0, 'h' }, { "msglvl", 0, 0,
+    'l' }, { "web100variables", 0, 0, 301 }, { "buffer", 1, 0, 'b' }, {
+      "disablemid", 0, 0, 302 }, { "disablec2s", 0, 0, 303 }, { "disables2c",
+        0, 0, 304 }, { "disablesfw", 0, 0, 305 },
+    { "protocol_log", 1, 0, 'u' },
+    { "enableprotolog", 0, 0, 'e' },
 #ifdef AF_INET6
-								{	"ipv4", 0, 0, '4'},
-								{	"ipv6", 0, 0, '6'},
+    {	"ipv4", 0, 0, '4'},
+    {	"ipv6", 0, 0, '6'},
 #endif
-								{ 0, 0, 0, 0 } };
+    { 0, 0, 0, 0 } };
 
 void save_int_values(char *sysvar, int sysval);
 void save_dbl_values(char *sysvar, float *sysval);
@@ -70,24 +70,24 @@ void save_dbl_values(char *sysvar, float *sysval);
  * @param tmpstr Char array containing key-value pairs
  *  */
 void printVariables(char *tmpstr) {
-	int i, j, k;
-	char sysvar[128], sysval[128];
-
-	k = strlen(tmpstr) - 1;
-	i = 0;
-	for (;;) {
-		for (j = 0; tmpstr[i] != ' '; j++)
-			sysvar[j] = tmpstr[i++];
-		sysvar[j] = '\0';
-		i++;
-		for (j = 0; tmpstr[i] != '\n'; j++)
-			sysval[j] = tmpstr[i++];
-		sysval[j] = '\0';
-		i++;
-		printf("%s %s\n", sysvar, sysval);
-		if (i >= k)
-			return;
-	}
+  int i, j, k;
+  char sysvar[128], sysval[128];
+
+  k = strlen(tmpstr) - 1;
+  i = 0;
+  for (;;) {
+    for (j = 0; tmpstr[i] != ' '; j++)
+      sysvar[j] = tmpstr[i++];
+    sysvar[j] = '\0';
+    i++;
+    for (j = 0; tmpstr[i] != '\n'; j++)
+      sysval[j] = tmpstr[i++];
+    sysval[j] = '\0';
+    i++;
+    printf("%s %s\n", sysvar, sysval);
+    if (i >= k)
+      return;
+  }
 }
 
 /**
@@ -99,13 +99,13 @@ void printVariables(char *tmpstr) {
  */
 
 void printWeb100VarInfo() {
-	int i = 0;
-	printf(" --- Detailed description of the Web100 variables ---\n\n");
+  int i = 0;
+  printf(" --- Detailed description of the Web100 variables ---\n\n");
 
-	while (web100vartable[i][0]) {
-		printf("* %s\n    %s\n", web100vartable[i][0], web100vartable[i][1]);
-		++i;
-	}
+  while (web100vartable[i][0]) {
+    printf("* %s\n    %s\n", web100vartable[i][0], web100vartable[i][1]);
+    ++i;
+  }
 }
 
 /**
@@ -118,120 +118,120 @@ void printWeb100VarInfo() {
  * @param host   server host name string
  */
 void testResults(char tests, char *testresult_str, char* host) {
-	int i = 0;
-
-	char *sysvar, *sysval;
-	float j;
-
-	// If the S2C test was not performed, just interpret the C2S and SFW test results
-	if (!(tests & TEST_S2C)) {
-		if (tests & TEST_C2S) { // Was C2S test performed?
-			check_C2Spacketqueuing(c2sspd, spdout, sndqueue, pkts, lth);
-		}
-
-		results_sfw(tests, host);
-		return;
-	}
-
-	sysvar = strtok(testresult_str, " ");
-	sysval = strtok(NULL, "\n");
-	i = atoi(sysval);
-	save_int_values(sysvar, i);
-
-	for (;;) {
-		sysvar = strtok(NULL, " ");
-		if (sysvar == NULL)
-			break;
-		sysval = strtok(NULL, "\n");
-		if (strchr(sysval, '.') == NULL) {
-			i = atoi(sysval);
-			save_int_values(sysvar, i);
-			log_println(7, "Stored %d [%s] in %s", i, sysval, sysvar);
-		} else {
-			j = atof(sysval);
-			save_dbl_values(sysvar, &j);
-			log_println(7, "Stored %0.2f (%s) in %s", j, sysval, sysvar);
-		}
-	}
-
-	//CountRTT = 615596;
-	if (CountRTT > 0) { // The number of round trip time samples is finite
-
-		// Get the link speed as determined during the C2S test. if it was performed
-		if (tests & TEST_C2S) {
-			mylink = get_linkspeed(c2sData, half_duplex);
-		}
-
-		print_results_mismatchcheck(mismatch);
-
-		if (mismatch == 0) {
-			check_congestion(congestion);
-			check_badcable(bad_cable);
-			print_recommend_buffersize(rwin, rttsec, avgrtt, mylink,
-					MaxRwinRcvd);
-		}
-
-		if (tests & TEST_C2S) {
-			check_C2Spacketqueuing(c2sspd,spdout,sndqueue, pkts, lth);
-		}
-		if (tests & TEST_S2C) {
-			check_S2Cpacketqueuing(s2cspd,spdin,ssndqueue, sbytes);
-		}
-
-		results_sfw(tests, host);
-
-		if (msglvl > 0) {
-			printf("\n\t------  Web100 Detailed Analysis  ------\n");
-
-			printf("\nWeb100 reports the Round trip time = %0.2f msec;",
-					avgrtt);
-
-			printf("the Packet size = %d Bytes; and \n", CurrentMSS);
-
-			// print packet loss statistics
-			print_packetloss_statistics (PktsRetrans, DupAcksIn, SACKsRcvd,
-				order,Timeouts,waitsec, timesec);
-
-			// print details of whether connection was send/receive/congestion limited
-			print_limitedtime_ratio( rwintime, rwin, sendtime, swin,  cwndtime,  rttsec,
-					 mylink,  Sndbuf, MaxRwinRcvd);
-
-			// check to see if excessive packet loss was reported
-			print_packetloss_excess(spd, loss);
-
-			// Now print details of optional Performance settings values like the following list:
-			printf(
-					"\n    Web100 reports TCP negotiated the optional Performance Settings to: \n");
-
-			// ..Selective ack options
-			print_SAck_RFC2018(SACKEnabled);
-
-			// ..Nagle algo details
-			print_Nagle_RFC896(NagleEnabled);
-
-			// ..Explicit Congestion Notification
-			print_congestion_RFC3168(ECNEnabled);
-
-			// ..RFC 1323 Time Stamping
-			print_timestamping_RFC1323(TimestampsEnabled);
-
-			// ..RFC 1323 Window Scaling
-			print_windowscaling(MaxRwinRcvd,WinScaleRcvd, WinScaleSent);
-
-			// ..throughput limiting factors details
-			print_throughputlimits(MaxRwinRcvd, RcvWinScale, &Sndbuf, swin, rwin, cwin, rttsec,estimate);
-
-			// client and server's views of link speed
-			print_linkspeed_dataacks((tests & TEST_C2S), c2sData,
-					c2sAck,s2cData, s2cAck) ;
-		}
-	} else {
-		printf(
-				"No Web100 data collected!  Possible Duplex Mismatch condition caused ");
-		printf(
-				"Server to client test to run long.\nCheck for host=Full and switch=Half ");
-		printf("mismatch condition\n");
-	}
+  int i = 0;
+
+  char *sysvar, *sysval;
+  float j;
+
+  // If the S2C test was not performed, just interpret the C2S and SFW test results
+  if (!(tests & TEST_S2C)) {
+    if (tests & TEST_C2S) { // Was C2S test performed?
+      check_C2Spacketqueuing(c2sspd, spdout, sndqueue, pkts, lth);
+    }
+
+    results_sfw(tests, host);
+    return;
+  }
+
+  sysvar = strtok(testresult_str, " ");
+  sysval = strtok(NULL, "\n");
+  i = atoi(sysval);
+  save_int_values(sysvar, i);
+
+  for (;;) {
+    sysvar = strtok(NULL, " ");
+    if (sysvar == NULL)
+      break;
+    sysval = strtok(NULL, "\n");
+    if (strchr(sysval, '.') == NULL) {
+      i = atoi(sysval);
+      save_int_values(sysvar, i);
+      log_println(7, "Stored %d [%s] in %s", i, sysval, sysvar);
+    } else {
+      j = atof(sysval);
+      save_dbl_values(sysvar, &j);
+      log_println(7, "Stored %0.2f (%s) in %s", j, sysval, sysvar);
+    }
+  }
+
+  //CountRTT = 615596;
+  if (CountRTT > 0) { // The number of round trip time samples is finite
+
+    // Get the link speed as determined during the C2S test. if it was performed
+    if (tests & TEST_C2S) {
+      mylink = get_linkspeed(c2sData, half_duplex);
+    }
+
+    print_results_mismatchcheck(mismatch);
+
+    if (mismatch == 0) {
+      check_congestion(congestion);
+      check_badcable(bad_cable);
+      print_recommend_buffersize(rwin, rttsec, avgrtt, mylink,
+                                 MaxRwinRcvd);
+    }
+
+    if (tests & TEST_C2S) {
+      check_C2Spacketqueuing(c2sspd,spdout,sndqueue, pkts, lth);
+    }
+    if (tests & TEST_S2C) {
+      check_S2Cpacketqueuing(s2cspd,spdin,ssndqueue, sbytes);
+    }
+
+    results_sfw(tests, host);
+
+    if (msglvl > 0) {
+      printf("\n\t------  Web100 Detailed Analysis  ------\n");
+
+      printf("\nWeb100 reports the Round trip time = %0.2f msec;",
+             avgrtt);
+
+      printf("the Packet size = %d Bytes; and \n", CurrentMSS);
+
+      // print packet loss statistics
+      print_packetloss_statistics (PktsRetrans, DupAcksIn, SACKsRcvd,
+                                   order,Timeouts,waitsec, timesec);
+
+      // print details of whether connection was send/receive/congestion limited
+      print_limitedtime_ratio( rwintime, rwin, sendtime, swin,  cwndtime,  rttsec,
+                               mylink,  Sndbuf, MaxRwinRcvd);
+
+      // check to see if excessive packet loss was reported
+      print_packetloss_excess(spd, loss);
+
+      // Now print details of optional Performance settings values like the following list:
+      printf(
+          "\n    Web100 reports TCP negotiated the optional Performance Settings to: \n");
+
+      // ..Selective ack options
+      print_SAck_RFC2018(SACKEnabled);
+
+      // ..Nagle algo details
+      print_Nagle_RFC896(NagleEnabled);
+
+      // ..Explicit Congestion Notification
+      print_congestion_RFC3168(ECNEnabled);
+
+      // ..RFC 1323 Time Stamping
+      print_timestamping_RFC1323(TimestampsEnabled);
+
+      // ..RFC 1323 Window Scaling
+      print_windowscaling(MaxRwinRcvd,WinScaleRcvd, WinScaleSent);
+
+      // ..throughput limiting factors details
+      print_throughputlimits(MaxRwinRcvd, RcvWinScale, &Sndbuf, swin, rwin, cwin, rttsec,estimate);
+
+      // client and server's views of link speed
+      print_linkspeed_dataacks((tests & TEST_C2S), c2sData,
+                               c2sAck,s2cData, s2cAck) ;
+    }
+  } else {
+    printf(
+        "No Web100 data collected!  Possible Duplex Mismatch condition caused ");
+    printf(
+        "Server to client test to run long.\nCheck for host=Full and switch=Half ");
+    printf("mismatch condition\n");
+  }
 }
 
 /**
@@ -250,36 +250,36 @@ void testResults(char tests, char *testresult_str, char* host) {
  */
 
 void middleboxResults(char *midresult_str, I2Addr local_addr, I2Addr peer_addr) {
-	char ssip[64], scip[64], *str;
-	char csip[64], ccip[64];
-	int mss;
-	size_t tmpLen;
+  char ssip[64], scip[64], *str;
+  char csip[64], ccip[64];
+  int mss;
+  size_t tmpLen;
 
-	str = strtok(midresult_str, ";");
-	strlcpy(ssip, str, sizeof(ssip));
-	str = strtok(NULL, ";");
+  str = strtok(midresult_str, ";");
+  strlcpy(ssip, str, sizeof(ssip));
+  str = strtok(NULL, ";");
 
-	strlcpy(scip, str, sizeof(scip));
+  strlcpy(scip, str, sizeof(scip));
 
-	str = strtok(NULL, ";");
-	mss = atoi(str);
-	str = strtok(NULL, ";");
-	winssent = atoi(str); // changing order to read winsent before winsrecv for issue 61
-	str = strtok(NULL, ";");
-	winsrecv = atoi(str);
+  str = strtok(NULL, ";");
+  mss = atoi(str);
+  str = strtok(NULL, ";");
+  winssent = atoi(str); // changing order to read winsent before winsrecv for issue 61
+  str = strtok(NULL, ";");
+  winsrecv = atoi(str);
 
-	memset(ccip, 0, 64);
-	tmpLen = 63;
-	I2AddrNodeName(local_addr, ccip, &tmpLen);
-	memset(csip, 0, 64);
-	tmpLen = 63;
-	I2AddrNodeName(peer_addr, csip, &tmpLen);
+  memset(ccip, 0, 64);
+  tmpLen = 63;
+  I2AddrNodeName(local_addr, ccip, &tmpLen);
+  memset(csip, 0, 64);
+  tmpLen = 63;
+  I2AddrNodeName(peer_addr, csip, &tmpLen);
 
-	// Check if MSS modification is happening
-	check_MSS_modification(TimestampsEnabled, &mss);
+  // Check if MSS modification is happening
+  check_MSS_modification(TimestampsEnabled, &mss);
 
-	// detect Network Address translation box
-	check_NAT(ssip, csip, scip, ccip);
+  // detect Network Address translation box
+  check_NAT(ssip, csip, scip, ccip);
 
 }
 
@@ -290,127 +290,127 @@ void middleboxResults(char *midresult_str, I2Addr local_addr, I2Addr peer_addr)
  * @param sysval value of this variable
  */
 void save_int_values(char *sysvar, int sysval) {
-	/*  Values saved for interpretation:
-	 *	SumRTT
-	 *	CountRTT
-	 *	CurrentMSS
-	 *	Timeouts
-	 *	PktsRetrans
-	 *	SACKsRcvd
-	 *	DupAcksIn
-	 *	MaxRwinRcvd
-	 *	MaxRwinSent
-	 *	Sndbuf
-	 *	Rcvbuf
-	 *	DataPktsOut
-	 *	SndLimTimeRwin
-	 *	SndLimTimeCwnd
-	 *	SndLimTimeSender
-	 */
-
-	log_println(6, "save_int_values(%s, %d)", sysvar, sysval);
-
-	if (strcmp("MSSSent:", sysvar) == 0)
-		MSSSent = sysval;
-	else if (strcmp("MSSRcvd:", sysvar) == 0)
-		MSSRcvd = sysval;
-	else if (strcmp("ECNEnabled:", sysvar) == 0)
-		ECNEnabled = sysval;
-	else if (strcmp("NagleEnabled:", sysvar) == 0)
-		NagleEnabled = sysval;
-	else if (strcmp("SACKEnabled:", sysvar) == 0)
-		SACKEnabled = sysval;
-	else if (strcmp("TimestampsEnabled:", sysvar) == 0)
-		TimestampsEnabled = sysval;
-	else if (strcmp("WinScaleRcvd:", sysvar) == 0)
-		WinScaleRcvd = sysval;
-	else if (strcmp("WinScaleSent:", sysvar) == 0)
-		WinScaleSent = sysval;
-	else if (strcmp("SumRTT:", sysvar) == 0)
-		SumRTT = sysval;
-	else if (strcmp("CountRTT:", sysvar) == 0)
-		CountRTT = sysval;
-	else if (strcmp("CurMSS:", sysvar) == 0)
-		CurrentMSS = sysval;
-	else if (strcmp("Timeouts:", sysvar) == 0)
-		Timeouts = sysval;
-	else if (strcmp("PktsRetrans:", sysvar) == 0)
-		PktsRetrans = sysval;
-	else if (strcmp("SACKsRcvd:", sysvar) == 0)
-		SACKsRcvd = sysval;
-	else if (strcmp("DupAcksIn:", sysvar) == 0)
-		DupAcksIn = sysval;
-	else if (strcmp("MaxRwinRcvd:", sysvar) == 0)
-		MaxRwinRcvd = sysval;
-	else if (strcmp("MaxRwinSent:", sysvar) == 0)
-		MaxRwinSent = sysval;
-	else if (strcmp("Sndbuf:", sysvar) == 0)
-		Sndbuf = sysval;
-	else if (strcmp("X_Rcvbuf:", sysvar) == 0)
-		Rcvbuf = sysval;
-	else if (strcmp("DataPktsOut:", sysvar) == 0)
-		DataPktsOut = sysval;
-	else if (strcmp("FastRetran:", sysvar) == 0)
-		FastRetran = sysval;
-	else if (strcmp("AckPktsOut:", sysvar) == 0)
-		AckPktsOut = sysval;
-	else if (strcmp("SmoothedRTT:", sysvar) == 0)
-		SmoothedRTT = sysval;
-	else if (strcmp("CurCwnd:", sysvar) == 0)
-		CurrentCwnd = sysval;
-	else if (strcmp("MaxCwnd:", sysvar) == 0)
-		MaxCwnd = sysval;
-	else if (strcmp("SndLimTimeRwin:", sysvar) == 0)
-		SndLimTimeRwin = sysval;
-	else if (strcmp("SndLimTimeCwnd:", sysvar) == 0)
-		SndLimTimeCwnd = sysval;
-	else if (strcmp("SndLimTimeSender:", sysvar) == 0)
-		SndLimTimeSender = sysval;
-	else if (strcmp("DataBytesOut:", sysvar) == 0)
-		DataBytesOut = sysval;
-	else if (strcmp("AckPktsIn:", sysvar) == 0)
-		AckPktsIn = sysval;
-	else if (strcmp("SndLimTransRwin:", sysvar) == 0)
-		SndLimTransRwin = sysval;
-	else if (strcmp("SndLimTransCwnd:", sysvar) == 0)
-		SndLimTransCwnd = sysval;
-	else if (strcmp("SndLimTransSender:", sysvar) == 0)
-		SndLimTransSender = sysval;
-	else if (strcmp("MaxSsthresh:", sysvar) == 0)
-		MaxSsthresh = sysval;
-	else if (strcmp("CurRTO:", sysvar) == 0)
-		CurrentRTO = sysval;
-	else if (strcmp("c2sData:", sysvar) == 0)
-		c2sData = sysval;
-	else if (strcmp("c2sAck:", sysvar) == 0)
-		c2sAck = sysval;
-	else if (strcmp("s2cData:", sysvar) == 0)
-		s2cData = sysval;
-	else if (strcmp("s2cAck:", sysvar) == 0)
-		s2cAck = sysval;
-	else if (strcmp("PktsOut:", sysvar) == 0)
-		PktsOut = sysval;
-	else if (strcmp("mismatch:", sysvar) == 0)
-		mismatch = sysval;
-	else if (strcmp("bad_cable:", sysvar) == 0)
-		bad_cable = sysval;
-	else if (strcmp("congestion:", sysvar) == 0)
-		congestion = sysval;
-	else if (strcmp("half_duplex:", sysvar) == 0)
-		half_duplex = sysval;
-	else if (strcmp("CongestionSignals:", sysvar) == 0)
-		CongestionSignals = sysval;
-	else if (strcmp("RcvWinScale:", sysvar) == 0) {
-		if (sysval > 15)
-			RcvWinScale = 0;
-		else
-			RcvWinScale = sysval;
-	} else if (strcmp("minCWNDpeak:", sysvar) == 0)
-		minPeak = sysval;
-	else if (strcmp("maxCWNDpeak:", sysvar) == 0)
-		maxPeak = sysval;
-	else if (strcmp("CWNDpeaks:", sysvar) == 0)
-		peaks = sysval;
+  /*  Values saved for interpretation:
+   *	SumRTT
+   *	CountRTT
+   *	CurrentMSS
+   *	Timeouts
+   *	PktsRetrans
+   *	SACKsRcvd
+   *	DupAcksIn
+   *	MaxRwinRcvd
+   *	MaxRwinSent
+   *	Sndbuf
+   *	Rcvbuf
+   *	DataPktsOut
+   *	SndLimTimeRwin
+   *	SndLimTimeCwnd
+   *	SndLimTimeSender
+   */
+
+  log_println(6, "save_int_values(%s, %d)", sysvar, sysval);
+
+  if (strcmp("MSSSent:", sysvar) == 0)
+    MSSSent = sysval;
+  else if (strcmp("MSSRcvd:", sysvar) == 0)
+    MSSRcvd = sysval;
+  else if (strcmp("ECNEnabled:", sysvar) == 0)
+    ECNEnabled = sysval;
+  else if (strcmp("NagleEnabled:", sysvar) == 0)
+    NagleEnabled = sysval;
+  else if (strcmp("SACKEnabled:", sysvar) == 0)
+    SACKEnabled = sysval;
+  else if (strcmp("TimestampsEnabled:", sysvar) == 0)
+    TimestampsEnabled = sysval;
+  else if (strcmp("WinScaleRcvd:", sysvar) == 0)
+    WinScaleRcvd = sysval;
+  else if (strcmp("WinScaleSent:", sysvar) == 0)
+    WinScaleSent = sysval;
+  else if (strcmp("SumRTT:", sysvar) == 0)
+    SumRTT = sysval;
+  else if (strcmp("CountRTT:", sysvar) == 0)
+    CountRTT = sysval;
+  else if (strcmp("CurMSS:", sysvar) == 0)
+    CurrentMSS = sysval;
+  else if (strcmp("Timeouts:", sysvar) == 0)
+    Timeouts = sysval;
+  else if (strcmp("PktsRetrans:", sysvar) == 0)
+    PktsRetrans = sysval;
+  else if (strcmp("SACKsRcvd:", sysvar) == 0)
+    SACKsRcvd = sysval;
+  else if (strcmp("DupAcksIn:", sysvar) == 0)
+    DupAcksIn = sysval;
+  else if (strcmp("MaxRwinRcvd:", sysvar) == 0)
+    MaxRwinRcvd = sysval;
+  else if (strcmp("MaxRwinSent:", sysvar) == 0)
+    MaxRwinSent = sysval;
+  else if (strcmp("Sndbuf:", sysvar) == 0)
+    Sndbuf = sysval;
+  else if (strcmp("X_Rcvbuf:", sysvar) == 0)
+    Rcvbuf = sysval;
+  else if (strcmp("DataPktsOut:", sysvar) == 0)
+    DataPktsOut = sysval;
+  else if (strcmp("FastRetran:", sysvar) == 0)
+    FastRetran = sysval;
+  else if (strcmp("AckPktsOut:", sysvar) == 0)
+    AckPktsOut = sysval;
+  else if (strcmp("SmoothedRTT:", sysvar) == 0)
+    SmoothedRTT = sysval;
+  else if (strcmp("CurCwnd:", sysvar) == 0)
+    CurrentCwnd = sysval;
+  else if (strcmp("MaxCwnd:", sysvar) == 0)
+    MaxCwnd = sysval;
+  else if (strcmp("SndLimTimeRwin:", sysvar) == 0)
+    SndLimTimeRwin = sysval;
+  else if (strcmp("SndLimTimeCwnd:", sysvar) == 0)
+    SndLimTimeCwnd = sysval;
+  else if (strcmp("SndLimTimeSender:", sysvar) == 0)
+    SndLimTimeSender = sysval;
+  else if (strcmp("DataBytesOut:", sysvar) == 0)
+    DataBytesOut = sysval;
+  else if (strcmp("AckPktsIn:", sysvar) == 0)
+    AckPktsIn = sysval;
+  else if (strcmp("SndLimTransRwin:", sysvar) == 0)
+    SndLimTransRwin = sysval;
+  else if (strcmp("SndLimTransCwnd:", sysvar) == 0)
+    SndLimTransCwnd = sysval;
+  else if (strcmp("SndLimTransSender:", sysvar) == 0)
+    SndLimTransSender = sysval;
+  else if (strcmp("MaxSsthresh:", sysvar) == 0)
+    MaxSsthresh = sysval;
+  else if (strcmp("CurRTO:", sysvar) == 0)
+    CurrentRTO = sysval;
+  else if (strcmp("c2sData:", sysvar) == 0)
+    c2sData = sysval;
+  else if (strcmp("c2sAck:", sysvar) == 0)
+    c2sAck = sysval;
+  else if (strcmp("s2cData:", sysvar) == 0)
+    s2cData = sysval;
+  else if (strcmp("s2cAck:", sysvar) == 0)
+    s2cAck = sysval;
+  else if (strcmp("PktsOut:", sysvar) == 0)
+    PktsOut = sysval;
+  else if (strcmp("mismatch:", sysvar) == 0)
+    mismatch = sysval;
+  else if (strcmp("bad_cable:", sysvar) == 0)
+    bad_cable = sysval;
+  else if (strcmp("congestion:", sysvar) == 0)
+    congestion = sysval;
+  else if (strcmp("half_duplex:", sysvar) == 0)
+    half_duplex = sysval;
+  else if (strcmp("CongestionSignals:", sysvar) == 0)
+    CongestionSignals = sysval;
+  else if (strcmp("RcvWinScale:", sysvar) == 0) {
+    if (sysval > 15)
+      RcvWinScale = 0;
+    else
+      RcvWinScale = sysval;
+  } else if (strcmp("minCWNDpeak:", sysvar) == 0)
+    minPeak = sysval;
+  else if (strcmp("maxCWNDpeak:", sysvar) == 0)
+    maxPeak = sysval;
+  else if (strcmp("CWNDpeaks:", sysvar) == 0)
+    peaks = sysval;
 }
 
 /**
@@ -420,36 +420,36 @@ void save_int_values(char *sysvar, int sysval) {
  * @param sysval variable's value
  */
 void save_dbl_values(char *sysvar, float *sysval) {
-	if (strcmp(sysvar, "bw:") == 0)
-		estimate = *sysval;
-	else if (strcmp(sysvar, "loss:") == 0)
-		loss = *sysval;
-	else if (strcmp(sysvar, "avgrtt:") == 0)
-		avgrtt = *sysval;
-	else if (strcmp(sysvar, "waitsec:") == 0)
-		waitsec = *sysval;
-	else if (strcmp(sysvar, "timesec:") == 0)
-		timesec = *sysval;
-	else if (strcmp(sysvar, "order:") == 0)
-		order = *sysval;
-	else if (strcmp(sysvar, "rwintime:") == 0)
-		rwintime = *sysval;
-	else if (strcmp(sysvar, "sendtime:") == 0)
-		sendtime = *sysval;
-	else if (strcmp(sysvar, "cwndtime:") == 0)
-		cwndtime = *sysval;
-	else if (strcmp(sysvar, "rttsec:") == 0)
-		rttsec = *sysval;
-	else if (strcmp(sysvar, "rwin:") == 0)
-		rwin = *sysval;
-	else if (strcmp(sysvar, "swin:") == 0)
-		swin = *sysval;
-	else if (strcmp(sysvar, "cwin:") == 0)
-		cwin = *sysval;
-	else if (strcmp(sysvar, "spd:") == 0)
-		spd = *sysval;
-	else if (strcmp(sysvar, "aspd:") == 0)
-		aspd = *sysval;
+  if (strcmp(sysvar, "bw:") == 0)
+    estimate = *sysval;
+  else if (strcmp(sysvar, "loss:") == 0)
+    loss = *sysval;
+  else if (strcmp(sysvar, "avgrtt:") == 0)
+    avgrtt = *sysval;
+  else if (strcmp(sysvar, "waitsec:") == 0)
+    waitsec = *sysval;
+  else if (strcmp(sysvar, "timesec:") == 0)
+    timesec = *sysval;
+  else if (strcmp(sysvar, "order:") == 0)
+    order = *sysval;
+  else if (strcmp(sysvar, "rwintime:") == 0)
+    rwintime = *sysval;
+  else if (strcmp(sysvar, "sendtime:") == 0)
+    sendtime = *sysval;
+  else if (strcmp(sysvar, "cwndtime:") == 0)
+    cwndtime = *sysval;
+  else if (strcmp(sysvar, "rttsec:") == 0)
+    rttsec = *sysval;
+  else if (strcmp(sysvar, "rwin:") == 0)
+    rwin = *sysval;
+  else if (strcmp(sysvar, "swin:") == 0)
+    swin = *sysval;
+  else if (strcmp(sysvar, "cwin:") == 0)
+    cwin = *sysval;
+  else if (strcmp(sysvar, "spd:") == 0)
+    spd = *sysval;
+  else if (strcmp(sysvar, "aspd:") == 0)
+    aspd = *sysval;
 }
 
 /**
@@ -459,413 +459,413 @@ void save_dbl_values(char *sysvar, float *sysval) {
  * @return > 0 if successful, < 0 if not
  */
 int main(int argc, char *argv[]) {
-	int useroption;				// user options char
-	int swait;					// server wait status
-	char mid_resultstr[MIDBOX_TEST_RES_SIZE];	// MID test results
-	char resultstr[2*BUFFSIZE]; 		// S2C test results, 16384 = 2 * BUFFSIZE
-	char varstr[2*BUFFSIZE]; 		// temporary storage for S2C test results , 16384 = 2 * BUFFSIZE
-	unsigned char tests = TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW
-			| TEST_STATUS | TEST_META; // which tests have been selectedto be performed?
-	int ctlSocket;				// socket fd
-	int ctlport = atoi(PORT);	// default port number
-	int retcode;				// return code from protocol operations, mostly
-	int xwait;					// wait flag
-	char buff[BUFFSIZE];		// buffer used to store protocol message payload
-	char* strtokbuf;			// buffer to store string tokens
-	char *host = NULL;			// server name to connect to
-	int buf_size = 0;			// TCP send/receive window size received from user
-	int msgLen, msgType;		// protocol message related variables
-	int conn_options = 0;		// connection options received from user
-	int debug = 0;				// debug flag
-	int testId;					// test ID received from server
-	// addresses..
-	I2Addr server_addr = NULL;
-	I2Addr local_addr = NULL, remote_addr = NULL;
-	char* ptr;
+  int useroption;				// user options char
+  int swait;					// server wait status
+  char mid_resultstr[MIDBOX_TEST_RES_SIZE];	// MID test results
+  char resultstr[2*BUFFSIZE]; 		// S2C test results, 16384 = 2 * BUFFSIZE
+  char varstr[2*BUFFSIZE]; 		// temporary storage for S2C test results , 16384 = 2 * BUFFSIZE
+  unsigned char tests = TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW
+      | TEST_STATUS | TEST_META; // which tests have been selectedto be performed?
+  int ctlSocket;				// socket fd
+  int ctlport = atoi(PORT);	// default port number
+  int retcode;				// return code from protocol operations, mostly
+  int xwait;					// wait flag
+  char buff[BUFFSIZE];		// buffer used to store protocol message payload
+  char* strtokbuf;			// buffer to store string tokens
+  char *host = NULL;			// server name to connect to
+  int buf_size = 0;			// TCP send/receive window size received from user
+  int msgLen, msgType;		// protocol message related variables
+  int conn_options = 0;		// connection options received from user
+  int debug = 0;				// debug flag
+  int testId;					// test ID received from server
+  // addresses..
+  I2Addr server_addr = NULL;
+  I2Addr local_addr = NULL, remote_addr = NULL;
+  char* ptr;
 #ifdef AF_INET6
 #define GETOPT_LONG_INET6(x) "46"x
 #else
 #define GETOPT_LONG_INET6(x) x
 #endif
-	// Read and record various optional values used for the tests/process
-	while ((useroption = getopt_long(argc, argv, GETOPT_LONG_INET6("n:u:e:p:dhlvb:"),
-			long_options, 0)) != -1) {
-		switch (useroption) {
-		case '4':
-			conn_options |= OPT_IPV4_ONLY;
-			break;
-		case '6':
-			conn_options |= OPT_IPV6_ONLY;
-			break;
-		case 'h':
-			clt_long_usage("ANL/Internet2 NDT version " VERSION " (client)");
-			break;
-		case 'v':
-			printf("ANL/Internet2 NDT version %s (client)\n", VERSION);
-			exit(0);
-			break;
-		case 'b':
-			buf_size = atoi(optarg);
-			break;
-		case 'd':
-			debug++;
-			break;
-		case 'l':
-			msglvl++;
-			break;
-		case 'p':
-			ctlport = atoi(optarg);
-			break;
-		case 'n':
-			host = optarg;
-			break;
-		case 'u':
-			set_protologdir(strdup(optarg));
-			break;
-		case 'e':
-			enableprotocollogging();
-			break;
-		case 301:
-			printWeb100VarInfo();
-			exit(0);
-			break;
-		case 302:
-			tests &= (~TEST_MID);
-			break;
-		case 303:
-			tests &= (~TEST_C2S);
-			break;
-		case 304:
-			tests &= (~TEST_S2C);
-			break;
-		case 305:
-			tests &= (~TEST_SFW);
-			break;
-		case '?':
-			short_usage(argv[0], "");
-			break;
-
-		}
-	}
-
-	if (optind < argc) {
-		short_usage(argv[0], "Unrecognized non-option elements");
-	}
-
-	// If protocol log is enabled, create log dir
-	create_protolog_dir();
-        
-	log_init(argv[0], debug);
-
-	failed = 0;
-
-	// Check if user options do not include any test!
-	if (!(tests & (TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW))) {
-		short_usage(argv[0], "Cannot perform empty test suites");
-	}
-
-	// A server is needed to run the tests against
-	if (host == NULL) {
-		short_usage(argv[0], "Name of the server is required");
-	}
-
-	// Check for initial configuration and performance problems
-	printf(
-			"Testing network path for configuration and performance problems  --  ");
-	fflush(stdout);
-
-	if ((server_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
-		printf("Unable to resolve server address\n");
-		exit(-3);
-	}
-	I2AddrSetPort(server_addr, ctlport);
-
-	if ((retcode = CreateConnectSocket(&ctlSocket, NULL, server_addr, conn_options,
-			0))) {
-		printf("Connect() for control socket failed\n");
-		exit(-4);
-	}
-
-	// check and print Address family being used
-	if (I2AddrSAddr(server_addr, 0)->sa_family == AF_INET) {
-		printf("Using IPv4 address\n");
-	} else {
-		printf("Using IPv6 address\n");
-	}
-
-	// set options for test direction
-	enum Tx_DIRECTION currentDirn = C_S;
-	setCurrentDirn(currentDirn);
-	// end protocol logging
-
-	/* set the TEST_STATUS flag so the server knows this client will respond to status requests.
-	 * this will let the server kill off zombie clients from the queue
-	 * RAC 7/7/09
-	 */
-	if (tests & TEST_STATUS) {
-		log_println(1, "* New Client, implements queuing feedback");
-	}
-
-	log_println(1, "Requesting test suite:");
-	if (tests & TEST_MID) {
-		log_println(1, " > Middlebox test");
-	}
-	if (tests & TEST_SFW) {
-		log_println(1, " > Simple firewall test");
-	}
-	if (tests & TEST_C2S) {
-		log_println(1, " > C2S throughput test");
-	}
-	if (tests & TEST_S2C) {
-		log_println(1, " > S2C throughput test");
-	}
-	if (tests & TEST_META) {
-		log_println(1, " > META test");
-	}
-
-	/* The beginning of the protocol */
-
-	/* write our test suite request by sending a login message */
-	send_msg(ctlSocket, MSG_LOGIN, &tests, 1);
-	/* read the specially crafted data that kicks off the old clients */
-	if (readn(ctlSocket, buff, 13) != 13) {
-		printf(
-				"Information: The server '%s' does not support this command line client\n",
-				host);
-		exit(0);
-	}
-
-	// The server now sends a SRV_QUEUE message to indicate whether/not to wait
-	// SRV_QUEUE messages are only sent to queued clients with a message
-	// body that indicates one of a few statuses, as will be handled individually
-	// below.
-
-	swait = 0;
-	for (;;) {
-		msgLen = sizeof(buff);
-		if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-			log_println(0, "Protocol error - expected hello  message!");
-			exit(1);
-		}
-		if (check_msg_type("Logging to server", SRV_QUEUE, msgType, buff,
-				msgLen)) { // Any other type of message at this stage is incorrect
-			exit(2);
-		}
-		if (msgLen <= 0) {
-			log_println(0, "Improper message");
-			exit(3);
-		}
-		buff[msgLen] = 0;
-		if (check_int(buff, &xwait)) {
-			log_println(0, "Invalid queue indicator");
-			exit(4);
-		}
-		// SRV_QUEUE message received indicating "ready to start tests" .
-		// ...proceed to running tests
-		if (xwait == SRV_QUEUE_TEST_STARTS_NOW) /* signal from ver 3.0.x NDT servers */
-			break;
-
-		if (xwait == SRV_QUEUE_SERVER_FAULT) {
-			fprintf(
-					stderr,
-					"Server Fault: Test terminated for unknown reason, please try again later.\n");
-			exit(0);
-		}
-		if (xwait == SRV_QUEUE_SERVER_BUSY) {
-			if (swait == 0) {
-				 // First message from server, indicating server is busy. Quit
-				fprintf(
-						stderr,
-						"Server Busy: Too many clients waiting in queue, plase try again later.\n");
-			}
-			else { // Server fault, quit
-				fprintf(
-						stderr,
-						"Server Fault: Test terminated for unknown reason, plase try again later.\n");
-			}
-			exit(0);
-		}
-		// server busy, wait 60 s for previous test to finish
-		if (xwait == SRV_QUEUE_SERVER_BUSY_60s) {
-			fprintf(
-					stderr,
-					"Server Busy: Please wait 60 seconds for the current test to finish.\n");
-			exit(0);
-		}
-		// Signal from the server to see if the client is still alive
-		if (xwait == SRV_QUEUE_HEARTBEAT) {
-			send_msg(ctlSocket, MSG_WAITING, &tests, 1);
-			continue;
-		}
-
-
-		/* Each test should take less than 30 s. So convey 45 sec *
-		  number of tests-suites waiting in the queue. Note that server sends a
-		  number equal to the number of clients ==
-		 number of minutes to wait before starting tests. In other words,
-		 wait = num of minutes to wait = number of queued clients */
-
-		xwait = (xwait * 45);
-		log_print(0,
-				"Another client is currently begin served, your test will ");
-		log_println(0, "begin within %d seconds", xwait);
-		swait = 1;
-	}
-
-	/* add alarm() signal to kill off client if the server never finishes the tests
-	 * RAC 7/13/09
-	 */
-	alarm(90);
-
-	// Tests can be started. Read server response again.
-	// The server must send MSG_LOGIN  message to verify version.
-	// Any other type of message is unexpected at this point.
-
-	msgLen = sizeof(buff);
-	if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-		log_println(0, "Protocol error - expected version message!");
-		exit(1);
-	}
-	if (check_msg_type("Negotiating NDT version", MSG_LOGIN, msgType, buff,
-			msgLen)) {
-		exit(2);
-	}
-	if (msgLen <= 0) {
-		log_println(0, "Improper message");
-		exit(3);
-	}
-
-	// Version compatibility between server-client must be verified
-
-	buff[msgLen] = 0;
-	if (buff[0] != 'v') { // payload does'nt start with a version indicator
-		log_println(0, "Incompatible version number");
-		exit(4);
-	}
-	log_println(5, "Server version: %s", &buff[1]);
-	if (strcmp(&buff[1], VERSION)) {
-		log_println(1, "WARNING: NDT server has different version number (%s)",
-				&buff[1]);
-	}
-
-	// Server must send a message to negotiate the test suite, and this is
-    // a MSG_LOGIN type of message which indicates the same set of tests as
-    // requested by the client earlier
-	msgLen = sizeof(buff);
-	if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
-		log_println(0, "Protocol error - expected test suite message!");
-		exit(1);
-	}
-	if (check_msg_type("Negotiating test suite", MSG_LOGIN, msgType, buff,
-			msgLen)) {
-		exit(2);
-	}
-	if (msgLen <= 0) {
-		log_println(0, "Improper message");
-		exit(3);
-	}
-
-	// get ids of tests to be run now
-	buff[msgLen] = 0;
-	log_println(5, "Received tests sequence: '%s'", buff);
-	if ((strtokbuf = malloc(1024)) == NULL) {
-		log_println(0, "Malloc failed!");
-		exit(6);
-	}
-	ptr = strtok_r(buff, " ", &strtokbuf);
-
-	// Run all tests requested, based on the ID.
-	while (ptr) {
-		if (check_int(ptr, &testId)) {
-			log_println(0, "Invalid test ID");
-			exit(4);
-		}
-		switch (testId) {
-		case TEST_MID:
-			if (test_mid_clt(ctlSocket, tests, host, conn_options, buf_size,
-					mid_resultstr)) {
-				log_println(0, "Middlebox test FAILED!");
-				tests &= (~TEST_MID);
-			}
-			break;
-		case TEST_C2S:
-			if (test_c2s_clt(ctlSocket, tests, host, conn_options, buf_size)) {
-				log_println(0, "C2S throughput test FAILED!");
-				tests &= (~TEST_C2S);
-			}
-			break;
-		case TEST_S2C:
-			if (test_s2c_clt(ctlSocket, tests, host, conn_options, buf_size,
-					resultstr)) {
-				log_println(0, "S2C throughput test FAILED!");
-				tests &= (~TEST_S2C);
-			}
-			break;
-		case TEST_SFW:
-			if (test_sfw_clt(ctlSocket, tests, host, conn_options)) {
-				log_println(0, "Simple firewall test FAILED!");
-				tests &= (~TEST_SFW);
-			}
-			break;
-		case TEST_META:
-			if (test_meta_clt(ctlSocket, tests, host, conn_options)) {
-				log_println(0, "META test FAILED!");
-				tests &= (~TEST_META);
-			}
-			break;
-		default:
-			log_println(0, "Unknown test ID");
-			exit(5);
-		}
-		ptr = strtok_r(NULL, " ", &strtokbuf);
-	}
-
-	/* get the final results from server.
-	 *
-	 * The results are encapsulated by the MSG_RESULTS messages. The last
-	 * message is MSG_LOGOUT.
-	 */
-	for (;;) {
-		msgLen = sizeof(buff);
-		memset(buff, 0, msgLen); // reset buff and msgLen
-		if ((retcode = (recv_msg(ctlSocket, &msgType, buff, &msgLen)))) {
-			if (errno == ECONNRESET)
-				log_println(0,
-						"Connection closed by server, No test performed.");
-			else
-				log_println(
-						0,
-						"Protocol error - expected results!  got '%s', msgtype=%d",
-						buff, msgType);
-			exit(1);
-		}
-		if (msgType == MSG_LOGOUT) {
-			break;
-		}
-		if (check_msg_type("Tests results", MSG_RESULTS, msgType, buff,
-				msgLen)) {
-			exit(2);
-		}
-
-		strlcat(resultstr, buff, sizeof(resultstr));
-		log_println(6, "resultstr = '%s'", resultstr);
-	}
-
-	local_addr = I2AddrByLocalSockFD(get_errhandle(), ctlSocket, False);
-	remote_addr = I2AddrBySockFD(get_errhandle(), ctlSocket, False);
-	I2AddrFree(server_addr);
-
-	strlcpy(varstr, resultstr, sizeof(varstr));
-	// print test results
-	testResults(tests, resultstr, host);
-
-	// print middlebox test results
-	if (tests & TEST_MID) {
-		middleboxResults(mid_resultstr, local_addr, remote_addr);
-	}
-
-	// print extra information collected from web100 variables
-	if ((tests & TEST_S2C) && (msglvl > 1))
-		printVariables(varstr);
-	return 0;
+  // Read and record various optional values used for the tests/process
+  while ((useroption = getopt_long(argc, argv, GETOPT_LONG_INET6("n:u:e:p:dhlvb:"),
+                                   long_options, 0)) != -1) {
+    switch (useroption) {
+      case '4':
+        conn_options |= OPT_IPV4_ONLY;
+        break;
+      case '6':
+        conn_options |= OPT_IPV6_ONLY;
+        break;
+      case 'h':
+        clt_long_usage("ANL/Internet2 NDT version " VERSION " (client)");
+        break;
+      case 'v':
+        printf("ANL/Internet2 NDT version %s (client)\n", VERSION);
+        exit(0);
+        break;
+      case 'b':
+        buf_size = atoi(optarg);
+        break;
+      case 'd':
+        debug++;
+        break;
+      case 'l':
+        msglvl++;
+        break;
+      case 'p':
+        ctlport = atoi(optarg);
+        break;
+      case 'n':
+        host = optarg;
+        break;
+      case 'u':
+        set_protologdir(strdup(optarg));
+        break;
+      case 'e':
+        enableprotocollogging();
+        break;
+      case 301:
+        printWeb100VarInfo();
+        exit(0);
+        break;
+      case 302:
+        tests &= (~TEST_MID);
+        break;
+      case 303:
+        tests &= (~TEST_C2S);
+        break;
+      case 304:
+        tests &= (~TEST_S2C);
+        break;
+      case 305:
+        tests &= (~TEST_SFW);
+        break;
+      case '?':
+        short_usage(argv[0], "");
+        break;
+
+    }
+  }
+
+  if (optind < argc) {
+    short_usage(argv[0], "Unrecognized non-option elements");
+  }
+
+  // If protocol log is enabled, create log dir
+  create_protolog_dir();
+
+  log_init(argv[0], debug);
+
+  failed = 0;
+
+  // Check if user options do not include any test!
+  if (!(tests & (TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW))) {
+    short_usage(argv[0], "Cannot perform empty test suites");
+  }
+
+  // A server is needed to run the tests against
+  if (host == NULL) {
+    short_usage(argv[0], "Name of the server is required");
+  }
+
+  // Check for initial configuration and performance problems
+  printf(
+      "Testing network path for configuration and performance problems  --  ");
+  fflush(stdout);
+
+  if ((server_addr = I2AddrByNode(get_errhandle(), host)) == NULL) {
+    printf("Unable to resolve server address\n");
+    exit(-3);
+  }
+  I2AddrSetPort(server_addr, ctlport);
+
+  if ((retcode = CreateConnectSocket(&ctlSocket, NULL, server_addr, conn_options,
+                                     0))) {
+    printf("Connect() for control socket failed\n");
+    exit(-4);
+  }
+
+  // check and print Address family being used
+  if (I2AddrSAddr(server_addr, 0)->sa_family == AF_INET) {
+    printf("Using IPv4 address\n");
+  } else {
+    printf("Using IPv6 address\n");
+  }
+
+  // set options for test direction
+  enum Tx_DIRECTION currentDirn = C_S;
+  setCurrentDirn(currentDirn);
+  // end protocol logging
+
+  /* set the TEST_STATUS flag so the server knows this client will respond to status requests.
+   * this will let the server kill off zombie clients from the queue
+   * RAC 7/7/09
+   */
+  if (tests & TEST_STATUS) {
+    log_println(1, "* New Client, implements queuing feedback");
+  }
+
+  log_println(1, "Requesting test suite:");
+  if (tests & TEST_MID) {
+    log_println(1, " > Middlebox test");
+  }
+  if (tests & TEST_SFW) {
+    log_println(1, " > Simple firewall test");
+  }
+  if (tests & TEST_C2S) {
+    log_println(1, " > C2S throughput test");
+  }
+  if (tests & TEST_S2C) {
+    log_println(1, " > S2C throughput test");
+  }
+  if (tests & TEST_META) {
+    log_println(1, " > META test");
+  }
+
+  /* The beginning of the protocol */
+
+  /* write our test suite request by sending a login message */
+  send_msg(ctlSocket, MSG_LOGIN, &tests, 1);
+  /* read the specially crafted data that kicks off the old clients */
+  if (readn(ctlSocket, buff, 13) != 13) {
+    printf(
+        "Information: The server '%s' does not support this command line client\n",
+        host);
+    exit(0);
+  }
+
+  // The server now sends a SRV_QUEUE message to indicate whether/not to wait
+  // SRV_QUEUE messages are only sent to queued clients with a message
+  // body that indicates one of a few statuses, as will be handled individually
+  // below.
+
+  swait = 0;
+  for (;;) {
+    msgLen = sizeof(buff);
+    if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+      log_println(0, "Protocol error - expected hello  message!");
+      exit(1);
+    }
+    if (check_msg_type("Logging to server", SRV_QUEUE, msgType, buff,
+                       msgLen)) { // Any other type of message at this stage is incorrect
+      exit(2);
+    }
+    if (msgLen <= 0) {
+      log_println(0, "Improper message");
+      exit(3);
+    }
+    buff[msgLen] = 0;
+    if (check_int(buff, &xwait)) {
+      log_println(0, "Invalid queue indicator");
+      exit(4);
+    }
+    // SRV_QUEUE message received indicating "ready to start tests" .
+    // ...proceed to running tests
+    if (xwait == SRV_QUEUE_TEST_STARTS_NOW) /* signal from ver 3.0.x NDT servers */
+      break;
+
+    if (xwait == SRV_QUEUE_SERVER_FAULT) {
+      fprintf(
+          stderr,
+          "Server Fault: Test terminated for unknown reason, please try again later.\n");
+      exit(0);
+    }
+    if (xwait == SRV_QUEUE_SERVER_BUSY) {
+      if (swait == 0) {
+        // First message from server, indicating server is busy. Quit
+        fprintf(
+            stderr,
+            "Server Busy: Too many clients waiting in queue, plase try again later.\n");
+      }
+      else { // Server fault, quit
+        fprintf(
+            stderr,
+            "Server Fault: Test terminated for unknown reason, plase try again later.\n");
+      }
+      exit(0);
+    }
+    // server busy, wait 60 s for previous test to finish
+    if (xwait == SRV_QUEUE_SERVER_BUSY_60s) {
+      fprintf(
+          stderr,
+          "Server Busy: Please wait 60 seconds for the current test to finish.\n");
+      exit(0);
+    }
+    // Signal from the server to see if the client is still alive
+    if (xwait == SRV_QUEUE_HEARTBEAT) {
+      send_msg(ctlSocket, MSG_WAITING, &tests, 1);
+      continue;
+    }
+
+
+    /* Each test should take less than 30 s. So convey 45 sec *
+       number of tests-suites waiting in the queue. Note that server sends a
+       number equal to the number of clients ==
+       number of minutes to wait before starting tests. In other words,
+       wait = num of minutes to wait = number of queued clients */
+
+    xwait = (xwait * 45);
+    log_print(0,
+              "Another client is currently begin served, your test will ");
+    log_println(0, "begin within %d seconds", xwait);
+    swait = 1;
+  }
+
+  /* add alarm() signal to kill off client if the server never finishes the tests
+   * RAC 7/13/09
+   */
+  alarm(90);
+
+  // Tests can be started. Read server response again.
+  // The server must send MSG_LOGIN  message to verify version.
+  // Any other type of message is unexpected at this point.
+
+  msgLen = sizeof(buff);
+  if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+    log_println(0, "Protocol error - expected version message!");
+    exit(1);
+  }
+  if (check_msg_type("Negotiating NDT version", MSG_LOGIN, msgType, buff,
+                     msgLen)) {
+    exit(2);
+  }
+  if (msgLen <= 0) {
+    log_println(0, "Improper message");
+    exit(3);
+  }
+
+  // Version compatibility between server-client must be verified
+
+  buff[msgLen] = 0;
+  if (buff[0] != 'v') { // payload does'nt start with a version indicator
+    log_println(0, "Incompatible version number");
+    exit(4);
+  }
+  log_println(5, "Server version: %s", &buff[1]);
+  if (strcmp(&buff[1], VERSION)) {
+    log_println(1, "WARNING: NDT server has different version number (%s)",
+                &buff[1]);
+  }
+
+  // Server must send a message to negotiate the test suite, and this is
+  // a MSG_LOGIN type of message which indicates the same set of tests as
+  // requested by the client earlier
+  msgLen = sizeof(buff);
+  if (recv_msg(ctlSocket, &msgType, buff, &msgLen)) {
+    log_println(0, "Protocol error - expected test suite message!");
+    exit(1);
+  }
+  if (check_msg_type("Negotiating test suite", MSG_LOGIN, msgType, buff,
+                     msgLen)) {
+    exit(2);
+  }
+  if (msgLen <= 0) {
+    log_println(0, "Improper message");
+    exit(3);
+  }
+
+  // get ids of tests to be run now
+  buff[msgLen] = 0;
+  log_println(5, "Received tests sequence: '%s'", buff);
+  if ((strtokbuf = malloc(1024)) == NULL) {
+    log_println(0, "Malloc failed!");
+    exit(6);
+  }
+  ptr = strtok_r(buff, " ", &strtokbuf);
+
+  // Run all tests requested, based on the ID.
+  while (ptr) {
+    if (check_int(ptr, &testId)) {
+      log_println(0, "Invalid test ID");
+      exit(4);
+    }
+    switch (testId) {
+      case TEST_MID:
+        if (test_mid_clt(ctlSocket, tests, host, conn_options, buf_size,
+                         mid_resultstr)) {
+          log_println(0, "Middlebox test FAILED!");
+          tests &= (~TEST_MID);
+        }
+        break;
+      case TEST_C2S:
+        if (test_c2s_clt(ctlSocket, tests, host, conn_options, buf_size)) {
+          log_println(0, "C2S throughput test FAILED!");
+          tests &= (~TEST_C2S);
+        }
+        break;
+      case TEST_S2C:
+        if (test_s2c_clt(ctlSocket, tests, host, conn_options, buf_size,
+                         resultstr)) {
+          log_println(0, "S2C throughput test FAILED!");
+          tests &= (~TEST_S2C);
+        }
+        break;
+      case TEST_SFW:
+        if (test_sfw_clt(ctlSocket, tests, host, conn_options)) {
+          log_println(0, "Simple firewall test FAILED!");
+          tests &= (~TEST_SFW);
+        }
+        break;
+      case TEST_META:
+        if (test_meta_clt(ctlSocket, tests, host, conn_options)) {
+          log_println(0, "META test FAILED!");
+          tests &= (~TEST_META);
+        }
+        break;
+      default:
+        log_println(0, "Unknown test ID");
+        exit(5);
+    }
+    ptr = strtok_r(NULL, " ", &strtokbuf);
+  }
+
+  /* get the final results from server.
+   *
+   * The results are encapsulated by the MSG_RESULTS messages. The last
+   * message is MSG_LOGOUT.
+   */
+  for (;;) {
+    msgLen = sizeof(buff);
+    memset(buff, 0, msgLen); // reset buff and msgLen
+    if ((retcode = (recv_msg(ctlSocket, &msgType, buff, &msgLen)))) {
+      if (errno == ECONNRESET)
+        log_println(0,
+                    "Connection closed by server, No test performed.");
+      else
+        log_println(
+            0,
+            "Protocol error - expected results!  got '%s', msgtype=%d",
+            buff, msgType);
+      exit(1);
+    }
+    if (msgType == MSG_LOGOUT) {
+      break;
+    }
+    if (check_msg_type("Tests results", MSG_RESULTS, msgType, buff,
+                       msgLen)) {
+      exit(2);
+    }
+
+    strlcat(resultstr, buff, sizeof(resultstr));
+    log_println(6, "resultstr = '%s'", resultstr);
+  }
+
+  local_addr = I2AddrByLocalSockFD(get_errhandle(), ctlSocket, False);
+  remote_addr = I2AddrBySockFD(get_errhandle(), ctlSocket, False);
+  I2AddrFree(server_addr);
+
+  strlcpy(varstr, resultstr, sizeof(varstr));
+  // print test results
+  testResults(tests, resultstr, host);
+
+  // print middlebox test results
+  if (tests & TEST_MID) {
+    middleboxResults(mid_resultstr, local_addr, remote_addr);
+  }
+
+  // print extra information collected from web100 variables
+  if ((tests & TEST_S2C) && (msglvl > 1))
+    printVariables(varstr);
+  return 0;
 }
diff --git a/src/web100srv.c b/src/web100srv.c
index 08f4e88..af97385 100644
--- a/src/web100srv.c
+++ b/src/web100srv.c
@@ -1,64 +1,64 @@
 /*
- Copyright (c) 2003 University of Chicago.  All rights reserved.
- The Web100 Network Diagnostic Tool (NDT) is distributed subject to
- the following license conditions:
- SOFTWARE LICENSE AGREEMENT
- Software: Web100 Network Diagnostic Tool (NDT)
-
- 1. The "Software", below, refers to the Web100 Network Diagnostic Tool (NDT)
- (in either source code, or binary form and accompanying documentation). Each
- licensee is addressed as "you" or "Licensee."
-
- 2. The copyright holder shown above hereby grants Licensee a royalty-free
- nonexclusive license, subject to the limitations stated herein and U.S. Government
- license rights.
-
- 3. You may modify and make a copy or copies of the Software for use within your
- organization, if you meet the following conditions: 
- a. Copies in source code must include the copyright notice and this Software
- License Agreement.
- b. Copies in binary form must include the copyright notice and this Software
- License Agreement in the documentation and/or other materials provided with the copy.
-
- 4. You may make a copy, or modify a copy or copies of the Software or any
- portion of it, thus forming a work based on the Software, and distribute copies
- outside your organization, if you meet all of the following conditions: 
- a. Copies in source code must include the copyright notice and this
- Software License Agreement;
- b. Copies in binary form must include the copyright notice and this
- Software License Agreement in the documentation and/or other materials
- provided with the copy;
- c. Modified copies and works based on the Software must carry prominent
- notices stating that you changed specified portions of the Software.
-
- 5. Portions of the Software resulted from work developed under a U.S. Government
- contract and are subject to the following license: the Government is granted
- for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable
- worldwide license in this computer software to reproduce, prepare derivative
- works, and perform publicly and display publicly.
-
- 6. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY
- OF ANY KIND. THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES
- DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT,
- (2) DO NOT ASSUME ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
- COMPLETENESS, OR USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE
- OF THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT
- THAT THE SOFTWARE WILL FUNCTION UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT
- ANY ERRORS WILL BE CORRECTED.
-
- 7. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDER, THE
- UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, OR THEIR EMPLOYEES:
- BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE
- DAMAGES OF ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS
- OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED
- ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR
- OTHERWISE, EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF
- SUCH LOSS OR DAMAGES.
- The Software was developed at least in part by the University of Chicago,
- as Operator of Argonne National Laboratory (http://miranda.ctd.anl.gov:7123/). 
- */
+   Copyright (c) 2003 University of Chicago.  All rights reserved.
+   The Web100 Network Diagnostic Tool (NDT) is distributed subject to
+   the following license conditions:
+   SOFTWARE LICENSE AGREEMENT
+Software: Web100 Network Diagnostic Tool (NDT)
+
+1. The "Software", below, refers to the Web100 Network Diagnostic Tool (NDT)
+(in either source code, or binary form and accompanying documentation). Each
+licensee is addressed as "you" or "Licensee."
+
+2. The copyright holder shown above hereby grants Licensee a royalty-free
+nonexclusive license, subject to the limitations stated herein and U.S. Government
+license rights.
+
+3. You may modify and make a copy or copies of the Software for use within your
+organization, if you meet the following conditions: 
+a. Copies in source code must include the copyright notice and this Software
+License Agreement.
+b. Copies in binary form must include the copyright notice and this Software
+License Agreement in the documentation and/or other materials provided with the copy.
+
+4. You may make a copy, or modify a copy or copies of the Software or any
+portion of it, thus forming a work based on the Software, and distribute copies
+outside your organization, if you meet all of the following conditions: 
+a. Copies in source code must include the copyright notice and this
+Software License Agreement;
+b. Copies in binary form must include the copyright notice and this
+Software License Agreement in the documentation and/or other materials
+provided with the copy;
+c. Modified copies and works based on the Software must carry prominent
+notices stating that you changed specified portions of the Software.
+
+5. Portions of the Software resulted from work developed under a U.S. Government
+contract and are subject to the following license: the Government is granted
+for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable
+worldwide license in this computer software to reproduce, prepare derivative
+works, and perform publicly and display publicly.
+
+6. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY
+OF ANY KIND. THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES
+DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT,
+(2) DO NOT ASSUME ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
+COMPLETENESS, OR USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE
+OF THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT
+THAT THE SOFTWARE WILL FUNCTION UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT
+ANY ERRORS WILL BE CORRECTED.
+
+7. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDER, THE
+UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, OR THEIR EMPLOYEES:
+BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE
+DAMAGES OF ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS
+OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED
+ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR
+OTHERWISE, EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF
+SUCH LOSS OR DAMAGES.
+The Software was developed at least in part by the University of Chicago,
+as Operator of Argonne National Laboratory (http://miranda.ctd.anl.gov:7123/). 
+*/
 
 #include "../config.h"
 
@@ -157,265 +157,265 @@ char testName[256];
 sem_t ndtq; /* create semaphore to allow only 1 process to modify the wait queue */
 
 static struct option long_options[] = { { "adminview", 0, 0, 'a' }, { "debug",
-		0, 0, 'd' }, { "help", 0, 0, 'h' }, { "multiple", 0, 0, 'm' }, {
-		"max_clients", 1, 0, 'x' }, { "mrange", 1, 0, 301 },
-		{ "old", 0, 0, 'o' }, { "disable-queue", 0, 0, 'q' }, { "record", 0, 0,
-				'r' }, { "syslog", 0, 0, 's' }, { "tcpdump", 0, 0, 't' }, {
-				"version", 0, 0, 'v' }, { "gzip", 0, 0, 'z' }, { "config", 1, 0,
-				'c' },
+  0, 0, 'd' }, { "help", 0, 0, 'h' }, { "multiple", 0, 0, 'm' }, {
+    "max_clients", 1, 0, 'x' }, { "mrange", 1, 0, 301 },
+  { "old", 0, 0, 'o' }, { "disable-queue", 0, 0, 'q' }, { "record", 0, 0,
+                                                          'r' }, { "syslog", 0, 0, 's' }, { "tcpdump", 0, 0, 't' }, {
+                                                            "version", 0, 0, 'v' }, { "gzip", 0, 0, 'z' }, { "config", 1, 0,
+                                                              'c' },
 #ifdef EXPERIMENTAL_ENABLED
-		{	"avoidsndblockup", 0, 0, 306},
-		{	"snaplog", 0, 0, 307},
-		{	"snapdelay", 1, 0, 305},
-		{	"cwnddecrease", 0, 0, 308},
-		{	"cputime", 0, 0, 309},
-		{	"limit", 1, 0, 'y'},
+                                                          {	"avoidsndblockup", 0, 0, 306},
+                                                          {	"snaplog", 0, 0, 307},
+                                                          {	"snapdelay", 1, 0, 305},
+                                                          {	"cwnddecrease", 0, 0, 308},
+                                                          {	"cputime", 0, 0, 309},
+                                                          {	"limit", 1, 0, 'y'},
 #endif
-		{ "buffer", 1, 0, 'b' },
-		{ "file", 1, 0, 'f' },
-		{ "interface", 1, 0, 'i' },
-		{ "log", 1, 0, 'l' },
-		{ "protolog_dir", 1, 0, 'u' },
-		{ "enableprotolog", 0, 0, 'e' },
-		{ "port", 1, 0, 'p' },
-		{ "midport", 1, 0, 302 },
-		{ "c2sport", 1, 0, 303 },
-		{ "s2cport", 1, 0, 304 },
-		{ "refresh", 1, 0, 'T' },
-		{ "adminfile", 1, 0, 'A' },
-		{ "log_dir", 1, 0, 'L' },
-		{ "logfacility", 1, 0, 'S' },
+                                                          { "buffer", 1, 0, 'b' },
+                                                          { "file", 1, 0, 'f' },
+                                                          { "interface", 1, 0, 'i' },
+                                                          { "log", 1, 0, 'l' },
+                                                          { "protolog_dir", 1, 0, 'u' },
+                                                          { "enableprotolog", 0, 0, 'e' },
+                                                          { "port", 1, 0, 'p' },
+                                                          { "midport", 1, 0, 302 },
+                                                          { "c2sport", 1, 0, 303 },
+                                                          { "s2cport", 1, 0, 304 },
+                                                          { "refresh", 1, 0, 'T' },
+                                                          { "adminfile", 1, 0, 'A' },
+                                                          { "log_dir", 1, 0, 'L' },
+                                                          { "logfacility", 1, 0, 'S' },
 #if defined(HAVE_ODBC) && defined(DATABASE_ENABLED) && defined(HAVE_SQL_H)
-		{	"enableDBlogging", 0, 0, 310},
-		{	"dbDSN", 1, 0, 311},
-		{	"dbUID", 1, 0, 312},
-		{	"dbPWD", 1, 0, 313},
+                                                          {	"enableDBlogging", 0, 0, 310},
+                                                          {	"dbDSN", 1, 0, 311},
+                                                          {	"dbUID", 1, 0, 312},
+                                                          {	"dbPWD", 1, 0, 313},
 #endif
 #ifdef AF_INET6
-		{	"ipv4", 0, 0, '4'},
-		{	"ipv6", 0, 0, '6'},
+                                                          {	"ipv4", 0, 0, '4'},
+                                                          {	"ipv6", 0, 0, '6'},
 #endif
-		{ 0, 0, 0, 0 } };
+                                                          { 0, 0, 0, 0 } };
 
 /**
  * Process a SIGCHLD signal.
  * @param pid_t Process id to be processed
  * */
 void child_sig(pid_t chld_pid) {
-	int pid, status, retcode;
-	struct ndtchild *child_proc1, *child_proc2;
-
-	child_proc1 = head_ptr;
-	log_println(
-			2,
-			"Processing SIGCHLD signal for active web100srv process [%d], sig17=%d",
-			chld_pid, sig17);
-
-	/* this routine cleans up after a child process has terminated.  There are 2 types of
-	 * child processes.  The pkt-pair timing children are type 1 and the spawned children to run
-	 * the test are type 0.  For the pkt-pair children, just acknowledge their signal to keep
-	 * them from becoming defunct.  For the type 0 children, use wait3() to figure out which
-	 * child terminated and then clean up the FIFO queue.
-	 * RAC 2/8/10
-	 *
-	 * Added new type (-1) on 2/11/10.  This type indicates a child has terminated due to
-	 * a communications fault.  For some reason the child is stuck in the FIFO queue and
-	 * it needs to be removed.  In this case, the calling function will grab the head pointer's
-	 * PID value, call this function with a -1 to remove the entry from the FIFO, issue a 
-	 * SIGTERM signal and call this function with the childs PID.  This should prevent the
-	 * code from entering into a loop.
-	 * RAC 2/11/10
-	 */
-	if (chld_pid > 0) {
-		while ((pid = wait4(chld_pid, &status, WNOHANG, (struct rusage *) 0))
-				> -1) {
-			log_println(3, "wait4() returned %d for PID=%d", status, pid);
-			if (WIFEXITED(status) != 0) {
-				log_println(3, "wexitstatus = '%d'", WEXITSTATUS(status));
-				break;
-			}
-			if (WIFSIGNALED(status) == 1) {
-				log_println(3, "wtermsig = %d", WTERMSIG(status));
-			}
-			if (WIFSTOPPED(status) == 1) {
-				log_println(3, "wstopsig = %d", WSTOPSIG(status));
-			}
-			if (status != 0) {
-				log_println(
-						4,
-						"child_sig() routine, wait4() non-zero status (%d) returned",
-						status);
-				return;
-			}
-		}
-		return;
-	}
-
-	if (chld_pid == 0) {
-		while ((pid = wait3(&status, WNOHANG, (struct rusage*) 0)) > 0) {
-			log_println(3, "wait3() returned status=%d for PID=%d", status,
-					pid);
-			if (WIFEXITED(status) != 0) {
-				log_println(3, "wexitstatus = '%d'", WEXITSTATUS(status));
-				break;
-			}
-			if (WIFSIGNALED(status) == 1) {
-				log_println(3, "wtermsig = %d", WTERMSIG(status));
-			}
-			if (WIFSTOPPED(status) == 1) {
-				log_println(3, "wstopsig = %d", WSTOPSIG(status));
-			}
-			if (status != 0) {
-				log_println(
-						4,
-						"child_sig() routine, wait3() non-zero status (%d) returned",
-						status);
-				return;
-			}
-		}
-		log_println(6,
-				"child_sig() called pid=%d, wait returned child=%d - status=%d",
-				chld_pid, pid, status);
-		if (pid == 0) {
-			log_println(6, "wait3() failed to return non-zero PID, ignore it");
-			if (sig17 > 0)
-				sig17--;
-			return;
-		}
-	} else { /* chld_pid must be -1, the error condition */
-		pid = head_ptr->pid;
-		log_println(
-				6,
-				"Stuck child at head of queue, set pid=%d and remove it from queue",
-				pid);
-	}
-
-	/* the pid variable now holds the PID of the child that exited.  Find out if this is one
-	 * of the queued children, and if so remove it from the queue and relink everything.  At
-	 * the end of this, update the sig17 counter.
-	 * RAC 2/8/10
-	 */
-
-	if (head_ptr == NULL)
-		return;
-	log_println(5, "checking for pktpair timing children, skip them");
-	child_proc1 = head_ptr;
-	while (child_proc1 != NULL) {
-		log_println(
-				5,
-				"\tLooking for %d, curent queue Child %d, host: %s [%s], next=0x%x",
-				pid, child_proc1->pid, child_proc1->host, child_proc1->addr,
-				(u_int64_t) child_proc1->next);
-		if (child_proc1->pid == pid) {
-			log_println(4, "Main test process %d terminated, remove from queue",
-					pid);
-			break;
-		}
-		child_proc1 = child_proc1->next;
-	}
-	if (child_proc1 == NULL)
-		return;
-
-	reap_child: if (multiple == 1) {
-		log_println(5, "mclient child '%d' (%d) has finished its test",
-				mclients, pid);
-		mclients--;
-		/*     return; */
-	}
-
-	log_println(4, "Attempting to clean up child %d, head pid = %d", pid,
-			head_ptr->pid);
-	if (head_ptr->pid == pid) {
-
-		if (get_debuglvl() > 5) {
-			log_println(5, "Walkingqueue");
-			child_proc1 = head_ptr;
-			while (child_proc1 != NULL) {
-				log_println(5, "\tChild %d, host: %s [%s], next=0x%x",
-						child_proc1->pid, child_proc1->host, child_proc1->addr,
-						(u_int64_t) child_proc1->next);
-				if (child_proc1->next == NULL)
-					break;
-				child_proc1 = child_proc1->next;
-			}
-		}
-
-		while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
-			log_println(6, "Waiting for ndtq semaphore to free - 1");
-			continue;
-		}
-		log_println(
-				5,
-				"Child process %d causing head pointer modification, semaphore locked",
-				pid);
-		if (head_ptr != NULL) {
-			child_proc1 = head_ptr;
-			log_println(6, "modifying queue child_proc1=0x%x, head_ptr=0x%x",
-					child_proc1, head_ptr);
-			head_ptr = head_ptr->next;
-			log_println(6, "free child_proc1=0x%x", child_proc1);
-			free(child_proc1);
-		}
-		if (head_ptr == NULL)
-			testing = 0;
-		if (multiple == 0)
-			testing = 0;
-		waiting--;
-		log_println(3,
-				"Removing Child from head, decremented waiting/mclients %d/%d",
-				waiting, mclients);
-		sem_post(&ndtq);
-		log_println(6, "Free'd ndtq semaphore lock - 3");
-		if (sig17 > 0)
-			sig17--;
-		return;
-	} else {
-		child_proc1 = head_ptr;
-		while (child_proc1->next != NULL) {
-			if (child_proc1->next->pid == pid) {
-				while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
-					log_println(6, "Waiting for ndtq semaphore to free - 2");
-					continue;
-				}
-				log_println(
-						4,
-						"Child process %d causing task list modification, semaphore locked",
-						chld_pid);
-				child_proc2 = child_proc1->next;
-				child_proc1->next = child_proc2->next;
-				log_println(6, "free child_proc2=0x%x", child_proc2);
-				free(child_proc2);
-				/* testing = 0; */
-				waiting--;
-				log_println(
-						3,
-						"Removing Child from list, decremented waiting/mclients %d/%d",
-						waiting, mclients);
-				sem_post(&ndtq);
-				log_println(6, "Free'd ndtq semaphore lock - 4");
-				if (sig17 > 0)
-					sig17--;
-				return;
-			}
-			child_proc1 = child_proc1->next;
-			log_println(6, "Looping through service queue ptr = 0x%x",
-					(u_int64_t) child_proc1);
-		}
-	}
-	if (sig17 > 0)
-		sig17--;
-	log_println(3,
-			"SIGCHLD routine finished!, decremented sig17 counter now =%d",
-			sig17);
-	return;
-	if (pid > 0) {
-		chld_pid = head_ptr->pid;
-		log_println(
-				6,
-				"stuck process or other problem, removing pointer from head of queue");
-		goto reap_child;
-	}
-	log_println(6, "Did we get here???");
+  int pid, status, retcode;
+  struct ndtchild *child_proc1, *child_proc2;
+
+  child_proc1 = head_ptr;
+  log_println(
+      2,
+      "Processing SIGCHLD signal for active web100srv process [%d], sig17=%d",
+      chld_pid, sig17);
+
+  /* this routine cleans up after a child process has terminated.  There are 2 types of
+   * child processes.  The pkt-pair timing children are type 1 and the spawned children to run
+   * the test are type 0.  For the pkt-pair children, just acknowledge their signal to keep
+   * them from becoming defunct.  For the type 0 children, use wait3() to figure out which
+   * child terminated and then clean up the FIFO queue.
+   * RAC 2/8/10
+   *
+   * Added new type (-1) on 2/11/10.  This type indicates a child has terminated due to
+   * a communications fault.  For some reason the child is stuck in the FIFO queue and
+   * it needs to be removed.  In this case, the calling function will grab the head pointer's
+   * PID value, call this function with a -1 to remove the entry from the FIFO, issue a 
+   * SIGTERM signal and call this function with the childs PID.  This should prevent the
+   * code from entering into a loop.
+   * RAC 2/11/10
+   */
+  if (chld_pid > 0) {
+    while ((pid = wait4(chld_pid, &status, WNOHANG, (struct rusage *) 0))
+           > -1) {
+      log_println(3, "wait4() returned %d for PID=%d", status, pid);
+      if (WIFEXITED(status) != 0) {
+        log_println(3, "wexitstatus = '%d'", WEXITSTATUS(status));
+        break;
+      }
+      if (WIFSIGNALED(status) == 1) {
+        log_println(3, "wtermsig = %d", WTERMSIG(status));
+      }
+      if (WIFSTOPPED(status) == 1) {
+        log_println(3, "wstopsig = %d", WSTOPSIG(status));
+      }
+      if (status != 0) {
+        log_println(
+            4,
+            "child_sig() routine, wait4() non-zero status (%d) returned",
+            status);
+        return;
+      }
+    }
+    return;
+  }
+
+  if (chld_pid == 0) {
+    while ((pid = wait3(&status, WNOHANG, (struct rusage*) 0)) > 0) {
+      log_println(3, "wait3() returned status=%d for PID=%d", status,
+                  pid);
+      if (WIFEXITED(status) != 0) {
+        log_println(3, "wexitstatus = '%d'", WEXITSTATUS(status));
+        break;
+      }
+      if (WIFSIGNALED(status) == 1) {
+        log_println(3, "wtermsig = %d", WTERMSIG(status));
+      }
+      if (WIFSTOPPED(status) == 1) {
+        log_println(3, "wstopsig = %d", WSTOPSIG(status));
+      }
+      if (status != 0) {
+        log_println(
+            4,
+            "child_sig() routine, wait3() non-zero status (%d) returned",
+            status);
+        return;
+      }
+    }
+    log_println(6,
+                "child_sig() called pid=%d, wait returned child=%d - status=%d",
+                chld_pid, pid, status);
+    if (pid == 0) {
+      log_println(6, "wait3() failed to return non-zero PID, ignore it");
+      if (sig17 > 0)
+        sig17--;
+      return;
+    }
+  } else { /* chld_pid must be -1, the error condition */
+    pid = head_ptr->pid;
+    log_println(
+        6,
+        "Stuck child at head of queue, set pid=%d and remove it from queue",
+        pid);
+  }
+
+  /* the pid variable now holds the PID of the child that exited.  Find out if this is one
+   * of the queued children, and if so remove it from the queue and relink everything.  At
+   * the end of this, update the sig17 counter.
+   * RAC 2/8/10
+   */
+
+  if (head_ptr == NULL)
+    return;
+  log_println(5, "checking for pktpair timing children, skip them");
+  child_proc1 = head_ptr;
+  while (child_proc1 != NULL) {
+    log_println(
+        5,
+        "\tLooking for %d, curent queue Child %d, host: %s [%s], next=0x%x",
+        pid, child_proc1->pid, child_proc1->host, child_proc1->addr,
+        (u_int64_t) child_proc1->next);
+    if (child_proc1->pid == pid) {
+      log_println(4, "Main test process %d terminated, remove from queue",
+                  pid);
+      break;
+    }
+    child_proc1 = child_proc1->next;
+  }
+  if (child_proc1 == NULL)
+    return;
+
+reap_child: if (multiple == 1) {
+              log_println(5, "mclient child '%d' (%d) has finished its test",
+                          mclients, pid);
+              mclients--;
+              /*     return; */
+            }
+
+            log_println(4, "Attempting to clean up child %d, head pid = %d", pid,
+                        head_ptr->pid);
+            if (head_ptr->pid == pid) {
+
+              if (get_debuglvl() > 5) {
+                log_println(5, "Walkingqueue");
+                child_proc1 = head_ptr;
+                while (child_proc1 != NULL) {
+                  log_println(5, "\tChild %d, host: %s [%s], next=0x%x",
+                              child_proc1->pid, child_proc1->host, child_proc1->addr,
+                              (u_int64_t) child_proc1->next);
+                  if (child_proc1->next == NULL)
+                    break;
+                  child_proc1 = child_proc1->next;
+                }
+              }
+
+              while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
+                log_println(6, "Waiting for ndtq semaphore to free - 1");
+                continue;
+              }
+              log_println(
+                  5,
+                  "Child process %d causing head pointer modification, semaphore locked",
+                  pid);
+              if (head_ptr != NULL) {
+                child_proc1 = head_ptr;
+                log_println(6, "modifying queue child_proc1=0x%x, head_ptr=0x%x",
+                            child_proc1, head_ptr);
+                head_ptr = head_ptr->next;
+                log_println(6, "free child_proc1=0x%x", child_proc1);
+                free(child_proc1);
+              }
+              if (head_ptr == NULL)
+                testing = 0;
+              if (multiple == 0)
+                testing = 0;
+              waiting--;
+              log_println(3,
+                          "Removing Child from head, decremented waiting/mclients %d/%d",
+                          waiting, mclients);
+              sem_post(&ndtq);
+              log_println(6, "Free'd ndtq semaphore lock - 3");
+              if (sig17 > 0)
+                sig17--;
+              return;
+            } else {
+              child_proc1 = head_ptr;
+              while (child_proc1->next != NULL) {
+                if (child_proc1->next->pid == pid) {
+                  while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
+                    log_println(6, "Waiting for ndtq semaphore to free - 2");
+                    continue;
+                  }
+                  log_println(
+                      4,
+                      "Child process %d causing task list modification, semaphore locked",
+                      chld_pid);
+                  child_proc2 = child_proc1->next;
+                  child_proc1->next = child_proc2->next;
+                  log_println(6, "free child_proc2=0x%x", child_proc2);
+                  free(child_proc2);
+                  /* testing = 0; */
+                  waiting--;
+                  log_println(
+                      3,
+                      "Removing Child from list, decremented waiting/mclients %d/%d",
+                      waiting, mclients);
+                  sem_post(&ndtq);
+                  log_println(6, "Free'd ndtq semaphore lock - 4");
+                  if (sig17 > 0)
+                    sig17--;
+                  return;
+                }
+                child_proc1 = child_proc1->next;
+                log_println(6, "Looping through service queue ptr = 0x%x",
+                            (u_int64_t) child_proc1);
+              }
+            }
+            if (sig17 > 0)
+              sig17--;
+            log_println(3,
+                        "SIGCHLD routine finished!, decremented sig17 counter now =%d",
+                        sig17);
+            return;
+            if (pid > 0) {
+              chld_pid = head_ptr->pid;
+              log_println(
+                  6,
+                  "stuck process or other problem, removing pointer from head of queue");
+              goto reap_child;
+            }
+            log_println(6, "Did we get here???");
 }
 
 /**
@@ -423,160 +423,160 @@ void child_sig(pid_t chld_pid) {
  * @param signo Signal number
  * */
 void cleanup(int signo) {
-	FILE * fp;
-
-        if (signo != SIGINT) {
-		log_println(1, "Signal %d received by process %d", signo, getpid());
-		if (get_debuglvl() > 0) {
-			fp = fopen(get_logfile(), "a");
-			if (fp != NULL) {
-				fprintf(fp, "Signal %d received by process %d\n", signo, getpid());
-				fclose(fp);
-			}
-		}
-	}
-	switch (signo) {
-	default:
-		fp = fopen(get_logfile(), "a");
-		if (fp != NULL) {
-			fprintf(
-					fp,
-					"Unexpected signal (%d) received, process (%d) may terminate\n",
-					signo, getpid());
-			fclose(fp);
-		}
-		break;
-	case SIGSEGV:
-		log_println(6,
-				"DEBUG, caught SIGSEGV signal and terminated process (%d)",
-				getpid());
-		if (getpid() != ndtpid)
-			exit(-2);
-		break;
-	case SIGINT:
-		exit(0);
-	case SIGTERM:
-		if (getpid() == ndtpid) {
-			log_println(
-					6,
-					"DEBUG, SIGTERM signal received for parent process (%d), ignore it",
-					ndtpid);
-			break;
-		}
-		exit(0);
-	case SIGUSR1:
-		log_println(6,
-				"DEBUG, caught SIGUSR1, setting sig1 flag to force exit");
-		sig1 = 1;
-		/* check_signal_flags(); */
-		break;
-
-	case SIGUSR2:
-		log_println(6,
-				"DEBUG, caught SIGUSR2, setting sig2 flag to force exit");
-		sig2 = 1;
-		/* check_signal_flags(); */
-		break;
-
-	case SIGALRM:
-		switch (getCurrentTest()) {
-		case TEST_MID:
-			log_println(6, "Received SIGALRM signal [Middlebox test]");
-			break;
-		case TEST_C2S:
-			log_println(6,
-					"Received SIGALRM signal [C2S throughput test] pid=%d",
-					getpid());
-			break;
-		case TEST_S2C:
-			log_println(6,
-					"Received SIGALRM signal [S2C throughput test] pid=%d",
-					getpid());
-			break;
-		case TEST_SFW:
-			log_println(6, "Received SIGALRM signal [Simple firewall test]");
-			break;
-		case TEST_META:
-			log_println(6, "Received SIGALRM signal [META test]");
-			break;
-		}
-		fp = fopen(get_logfile(), "a");
-		if (fp != NULL) {
-			if (get_debuglvl() > 4)
-				fprintf(
-						fp,
-						"Received SIGALRM signal: terminating active web100srv process [%d]",
-						getpid());
-			switch (getCurrentTest()) {
-			case TEST_MID:
-				fprintf(fp, " [Middlebox test]\n");
-				break;
-			case TEST_C2S:
-				fprintf(fp, " [C2S throughput test]\n");
-				/* break; */
-				if (wait_sig == 1)
-					return;
-				break;
-			case TEST_S2C:
-				fprintf(fp, " [S2C throughput test]\n");
-				/* break; */
-				if (wait_sig == 1)
-					return;
-				break;
-			case TEST_SFW:
-				fprintf(fp, " [Simple firewall test]\n");
-				break;
-			case TEST_META:
-				fprintf(fp, " [META test]\n");
-				break;
-			default:
-				fprintf(fp, "\n");
-			}
-			fclose(fp);
-		}
-		exit(0);
-	case SIGPIPE:
-		fp = fopen(get_logfile(), "a");
-		if ((fp != NULL) && (get_debuglvl() > 4)) {
-			fprintf(
-					fp,
-					"Received SIGPIPE signal: terminating active web100srv process [%d]\n",
-					getpid());
-			fclose(fp);
-		}
-		sig13 = 1;
-		break;
-
-	case SIGHUP:
-		/* Initialize Web100 structures */
-		count_vars = web100_init(VarFileName);
-
-		/* The administrator view automatically generates a usage page for the
-		 * NDT server.  This page is then accessable to the general public.
-		 * At this point read the existing log file and generate the necessary
-		 * data.  This data is then updated at the end of each test.
-		 * RAC 3/11/04
-		 */
-		if (admin_view == 1)
-			view_init(refresh);
-		break;
-
-	case SIGCHLD:
-		/* moved actions to child_sig() routine on 3/10/05  RAC
-		 * Now all we do here is set a flag and return the flag
-		 * is checked near the top of the main wait loop, so it
-		 * will only be accessed once and only the testing proces
-		 * will attempt to do something with it.
-		 */
-		/* sig17 = 1; */
-		if (ndtpid != getppid()) {
-			sig17++;
-			log_println(5,
-					"Signal 17 (SIGCHLD) received - completed tests = %d",
-					sig17);
-		}
-		break;
-	}
+  FILE * fp;
+
+  if (signo != SIGINT) {
+    log_println(1, "Signal %d received by process %d", signo, getpid());
+    if (get_debuglvl() > 0) {
+      fp = fopen(get_logfile(), "a");
+      if (fp != NULL) {
+        fprintf(fp, "Signal %d received by process %d\n", signo, getpid());
+        fclose(fp);
+      }
+    }
+  }
+  switch (signo) {
+    default:
+      fp = fopen(get_logfile(), "a");
+      if (fp != NULL) {
+        fprintf(
+            fp,
+            "Unexpected signal (%d) received, process (%d) may terminate\n",
+            signo, getpid());
+        fclose(fp);
+      }
+      break;
+    case SIGSEGV:
+      log_println(6,
+                  "DEBUG, caught SIGSEGV signal and terminated process (%d)",
+                  getpid());
+      if (getpid() != ndtpid)
+        exit(-2);
+      break;
+    case SIGINT:
+      exit(0);
+    case SIGTERM:
+      if (getpid() == ndtpid) {
+        log_println(
+            6,
+            "DEBUG, SIGTERM signal received for parent process (%d), ignore it",
+            ndtpid);
+        break;
+      }
+      exit(0);
+    case SIGUSR1:
+      log_println(6,
+                  "DEBUG, caught SIGUSR1, setting sig1 flag to force exit");
+      sig1 = 1;
+      /* check_signal_flags(); */
+      break;
+
+    case SIGUSR2:
+      log_println(6,
+                  "DEBUG, caught SIGUSR2, setting sig2 flag to force exit");
+      sig2 = 1;
+      /* check_signal_flags(); */
+      break;
+
+    case SIGALRM:
+      switch (getCurrentTest()) {
+        case TEST_MID:
+          log_println(6, "Received SIGALRM signal [Middlebox test]");
+          break;
+        case TEST_C2S:
+          log_println(6,
+                      "Received SIGALRM signal [C2S throughput test] pid=%d",
+                      getpid());
+          break;
+        case TEST_S2C:
+          log_println(6,
+                      "Received SIGALRM signal [S2C throughput test] pid=%d",
+                      getpid());
+          break;
+        case TEST_SFW:
+          log_println(6, "Received SIGALRM signal [Simple firewall test]");
+          break;
+        case TEST_META:
+          log_println(6, "Received SIGALRM signal [META test]");
+          break;
+      }
+      fp = fopen(get_logfile(), "a");
+      if (fp != NULL) {
+        if (get_debuglvl() > 4)
+          fprintf(
+              fp,
+              "Received SIGALRM signal: terminating active web100srv process [%d]",
+              getpid());
+        switch (getCurrentTest()) {
+          case TEST_MID:
+            fprintf(fp, " [Middlebox test]\n");
+            break;
+          case TEST_C2S:
+            fprintf(fp, " [C2S throughput test]\n");
+            /* break; */
+            if (wait_sig == 1)
+              return;
+            break;
+          case TEST_S2C:
+            fprintf(fp, " [S2C throughput test]\n");
+            /* break; */
+            if (wait_sig == 1)
+              return;
+            break;
+          case TEST_SFW:
+            fprintf(fp, " [Simple firewall test]\n");
+            break;
+          case TEST_META:
+            fprintf(fp, " [META test]\n");
+            break;
+          default:
+            fprintf(fp, "\n");
+        }
+        fclose(fp);
+      }
+      exit(0);
+    case SIGPIPE:
+      fp = fopen(get_logfile(), "a");
+      if ((fp != NULL) && (get_debuglvl() > 4)) {
+        fprintf(
+            fp,
+            "Received SIGPIPE signal: terminating active web100srv process [%d]\n",
+            getpid());
+        fclose(fp);
+      }
+      sig13 = 1;
+      break;
+
+    case SIGHUP:
+      /* Initialize Web100 structures */
+      count_vars = web100_init(VarFileName);
+
+      /* The administrator view automatically generates a usage page for the
+       * NDT server.  This page is then accessable to the general public.
+       * At this point read the existing log file and generate the necessary
+       * data.  This data is then updated at the end of each test.
+       * RAC 3/11/04
+       */
+      if (admin_view == 1)
+        view_init(refresh);
+      break;
+
+    case SIGCHLD:
+      /* moved actions to child_sig() routine on 3/10/05  RAC
+       * Now all we do here is set a flag and return the flag
+       * is checked near the top of the main wait loop, so it
+       * will only be accessed once and only the testing proces
+       * will attempt to do something with it.
+       */
+      /* sig17 = 1; */
+      if (ndtpid != getppid()) {
+        sig17++;
+        log_println(5,
+                    "Signal 17 (SIGCHLD) received - completed tests = %d",
+                    sig17);
+      }
+      break;
+  }
 }
 
 /** LoadConfig routine copied from Internet2.
@@ -585,225 +585,225 @@ void cleanup(int signo) {
  * @param *lbuf_max line buffer max - both help keep track of a dynamically grown "line" buffer.*/
 
 static void LoadConfig(char* name, char **lbuf, size_t *lbuf_max) {
-	FILE *conf;
-	char keybuf[256], valbuf[256];
-	char *key = keybuf, *val = valbuf;
-	int retcode = 0;
-
-	if (!(conf = fopen(ConfigFileName, "r")))
-		return;
-
-	log_println(1, " Reading config file %s to obtain options", ConfigFileName);
-
-	// Read the values for various keys and store them in appropriate variables
-	while ((retcode = I2ReadConfVar(conf, retcode, key, val, 256, lbuf,
-			lbuf_max)) > 0) {
-		if (strncasecmp(key, "administrator_view", 5) == 0) {
-			admin_view = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "multiple_clients", 5) == 0) {
-			multiple = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "max_clients", 5) == 0) {
-			max_clients = atoi(val);
-			continue;
-		}
-
-		else if (strncasecmp(key, "record_reverse", 6) == 0) {
-			record_reverse = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "write_trace", 5) == 0) {
-			dumptrace = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "TCP_Buffer_size", 3) == 0) {
-			if (check_int(val, &window)) {
-				char tmpText[200];
-				snprintf(tmpText, 200, "Invalid window size: %s", val);
-				short_usage(name, tmpText);
-			}
-			set_buff = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "debug", 5) == 0) {
-			set_debuglvl(atoi(val));
-			continue;
-		}
-
-		else if (strncasecmp(key, "variable_file", 6) == 0) {
-			snprintf(wvfn, sizeof(wvfn), "%s", val);
-			VarFileName = wvfn;
-			continue;
-		}
-
-		else if (strncasecmp(key, "log_file", 3) == 0) {
-			snprintf(lgfn, sizeof(lgfn), "%s", val);
-			set_logfile(lgfn);
-			snprintf(lgfn, sizeof(lgfn), "%s", val);
-			continue;
-		} else if (strncasecmp(key, "protolog_dir", 12) == 0) {
-			snprintf(lgfn, sizeof(lgfn), "%s", val);
-			set_protologdir(lgfn);
-			continue;
-		} else if (strncasecmp(key, "enableprotolog", 11) == 0) {
-			enableprotocollogging();
-			continue;
-		} else if (strncasecmp(key, "admin_file", 10) == 0) {
-			snprintf(apfn, sizeof(apfn), "%s", val);
-			AdminFileName = apfn;
-			continue;
-		}
-
-		else if (strncasecmp(key, "logfacility", 11) == 0) {
-			snprintf(slfa, sizeof(slfa), "%s", val);
-			SysLogFacility = slfa;
-			continue;
-		}
-
-		else if (strncasecmp(key, "device", 5) == 0) {
-			snprintf(devicebuf, 100, "%s", val);
-			device = devicebuf;
-			continue;
-		}
-
-		else if (strncasecmp(key, "port", 4) == 0) {
-			snprintf(portbuf, 10, "%s", val);
-			port = portbuf;
-			continue;
-		}
-
-		else if (strncasecmp(key, "syslog", 6) == 0) {
-			usesyslog = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "disable_FIFO", 5) == 0) {
-			queue = 0;
-			continue;
-		}
-
-		else if (strncasecmp(key, "old_mismatch", 3) == 0) {
-			old_mismatch = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "cputime", 3) == 0) {
-			cputime = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "enableDBlogging", 8) == 0) {
-			useDB = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "dbDSN", 5) == 0) {
-			snprintf(dbDSNbuf, 255, "%s", val);
-			dbDSN = dbDSNbuf;
-			continue;
-		}
-
-		else if (strncasecmp(key, "dbUID", 5) == 0) {
-			snprintf(dbUIDbuf, 255, "%s", val);
-			dbUID = dbUIDbuf;
-			continue;
-		}
-
-		else if (strncasecmp(key, "dbPWD", 5) == 0) {
-			snprintf(dbPWDbuf, 255, "%s", val);
-			dbPWD = dbPWDbuf;
-			continue;
-		}
-
-		else if (strncasecmp(key, "cwnddecrease", 5) == 0) {
-			options.cwndDecrease = 1;
-			options.snaplog = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "snaplog", 5) == 0) {
-			options.snaplog = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "avoidsndblockup", 5) == 0) {
-			options.avoidSndBlockUp = 1;
-			continue;
-		}
-
-		else if (strncasecmp(key, "snapdelay", 5) == 0) {
-			options.snapDelay = atoi(val);
-			continue;
-		}
-
-		else if (strncasecmp(key, "limit", 5) == 0) {
-			options.limit = atoi(val);
-			continue;
-		}
-
-		else if (strncasecmp(key, "refresh", 5) == 0) {
-			refresh = atoi(val);
-			continue;
-		}
-
-		else if (strncasecmp(key, "mrange", 6) == 0) {
-			if (mrange_parse(val)) {
-				char tmpText[300];
-				snprintf(tmpText, 300, "Invalid range: %s", val);
-				short_usage(name, tmpText);
-			}
-			continue;
-		}
-
-		else if (strncasecmp(key, "midport", 7) == 0) {
-			if (check_int(val, &testopt.midsockport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200, "Invalid Middlebox test port number: %s",
-						val);
-				short_usage(name, tmpText);
-			}
-			continue;
-		}
-
-		else if (strncasecmp(key, "c2sport", 7) == 0) {
-			if (check_int(val, &testopt.c2ssockport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200,
-						"Invalid C2S throughput test port number: %s", val);
-				short_usage(name, tmpText);
-			}
-			continue;
-		}
-
-		else if (strncasecmp(key, "s2cport", 7) == 0) {
-			if (check_int(val, &testopt.s2csockport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200,
-						"Invalid S2C throughput test port number: %s", val);
-				short_usage(name, tmpText);
-			}
-			continue;
-		}
-
-		else {
-			log_println(0, "Unrecognized config option: %s", key);
-			exit(1);
-		}
-	}
-	if (retcode < 0) {
-		log_println(0, "Syntax error in line %d of the config file %s",
-				(-retcode), ConfigFileName);
-		exit(1);
-	}
-	fclose(conf);
+  FILE *conf;
+  char keybuf[256], valbuf[256];
+  char *key = keybuf, *val = valbuf;
+  int retcode = 0;
+
+  if (!(conf = fopen(ConfigFileName, "r")))
+    return;
+
+  log_println(1, " Reading config file %s to obtain options", ConfigFileName);
+
+  // Read the values for various keys and store them in appropriate variables
+  while ((retcode = I2ReadConfVar(conf, retcode, key, val, 256, lbuf,
+                                  lbuf_max)) > 0) {
+    if (strncasecmp(key, "administrator_view", 5) == 0) {
+      admin_view = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "multiple_clients", 5) == 0) {
+      multiple = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "max_clients", 5) == 0) {
+      max_clients = atoi(val);
+      continue;
+    }
+
+    else if (strncasecmp(key, "record_reverse", 6) == 0) {
+      record_reverse = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "write_trace", 5) == 0) {
+      dumptrace = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "TCP_Buffer_size", 3) == 0) {
+      if (check_int(val, &window)) {
+        char tmpText[200];
+        snprintf(tmpText, 200, "Invalid window size: %s", val);
+        short_usage(name, tmpText);
+      }
+      set_buff = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "debug", 5) == 0) {
+      set_debuglvl(atoi(val));
+      continue;
+    }
+
+    else if (strncasecmp(key, "variable_file", 6) == 0) {
+      snprintf(wvfn, sizeof(wvfn), "%s", val);
+      VarFileName = wvfn;
+      continue;
+    }
+
+    else if (strncasecmp(key, "log_file", 3) == 0) {
+      snprintf(lgfn, sizeof(lgfn), "%s", val);
+      set_logfile(lgfn);
+      snprintf(lgfn, sizeof(lgfn), "%s", val);
+      continue;
+    } else if (strncasecmp(key, "protolog_dir", 12) == 0) {
+      snprintf(lgfn, sizeof(lgfn), "%s", val);
+      set_protologdir(lgfn);
+      continue;
+    } else if (strncasecmp(key, "enableprotolog", 11) == 0) {
+      enableprotocollogging();
+      continue;
+    } else if (strncasecmp(key, "admin_file", 10) == 0) {
+      snprintf(apfn, sizeof(apfn), "%s", val);
+      AdminFileName = apfn;
+      continue;
+    }
+
+    else if (strncasecmp(key, "logfacility", 11) == 0) {
+      snprintf(slfa, sizeof(slfa), "%s", val);
+      SysLogFacility = slfa;
+      continue;
+    }
+
+    else if (strncasecmp(key, "device", 5) == 0) {
+      snprintf(devicebuf, 100, "%s", val);
+      device = devicebuf;
+      continue;
+    }
+
+    else if (strncasecmp(key, "port", 4) == 0) {
+      snprintf(portbuf, 10, "%s", val);
+      port = portbuf;
+      continue;
+    }
+
+    else if (strncasecmp(key, "syslog", 6) == 0) {
+      usesyslog = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "disable_FIFO", 5) == 0) {
+      queue = 0;
+      continue;
+    }
+
+    else if (strncasecmp(key, "old_mismatch", 3) == 0) {
+      old_mismatch = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "cputime", 3) == 0) {
+      cputime = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "enableDBlogging", 8) == 0) {
+      useDB = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "dbDSN", 5) == 0) {
+      snprintf(dbDSNbuf, 255, "%s", val);
+      dbDSN = dbDSNbuf;
+      continue;
+    }
+
+    else if (strncasecmp(key, "dbUID", 5) == 0) {
+      snprintf(dbUIDbuf, 255, "%s", val);
+      dbUID = dbUIDbuf;
+      continue;
+    }
+
+    else if (strncasecmp(key, "dbPWD", 5) == 0) {
+      snprintf(dbPWDbuf, 255, "%s", val);
+      dbPWD = dbPWDbuf;
+      continue;
+    }
+
+    else if (strncasecmp(key, "cwnddecrease", 5) == 0) {
+      options.cwndDecrease = 1;
+      options.snaplog = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "snaplog", 5) == 0) {
+      options.snaplog = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "avoidsndblockup", 5) == 0) {
+      options.avoidSndBlockUp = 1;
+      continue;
+    }
+
+    else if (strncasecmp(key, "snapdelay", 5) == 0) {
+      options.snapDelay = atoi(val);
+      continue;
+    }
+
+    else if (strncasecmp(key, "limit", 5) == 0) {
+      options.limit = atoi(val);
+      continue;
+    }
+
+    else if (strncasecmp(key, "refresh", 5) == 0) {
+      refresh = atoi(val);
+      continue;
+    }
+
+    else if (strncasecmp(key, "mrange", 6) == 0) {
+      if (mrange_parse(val)) {
+        char tmpText[300];
+        snprintf(tmpText, 300, "Invalid range: %s", val);
+        short_usage(name, tmpText);
+      }
+      continue;
+    }
+
+    else if (strncasecmp(key, "midport", 7) == 0) {
+      if (check_int(val, &testopt.midsockport)) {
+        char tmpText[200];
+        snprintf(tmpText, 200, "Invalid Middlebox test port number: %s",
+                 val);
+        short_usage(name, tmpText);
+      }
+      continue;
+    }
+
+    else if (strncasecmp(key, "c2sport", 7) == 0) {
+      if (check_int(val, &testopt.c2ssockport)) {
+        char tmpText[200];
+        snprintf(tmpText, 200,
+                 "Invalid C2S throughput test port number: %s", val);
+        short_usage(name, tmpText);
+      }
+      continue;
+    }
+
+    else if (strncasecmp(key, "s2cport", 7) == 0) {
+      if (check_int(val, &testopt.s2csockport)) {
+        char tmpText[200];
+        snprintf(tmpText, 200,
+                 "Invalid S2C throughput test port number: %s", val);
+        short_usage(name, tmpText);
+      }
+      continue;
+    }
+
+    else {
+      log_println(0, "Unrecognized config option: %s", key);
+      exit(1);
+    }
+  }
+  if (retcode < 0) {
+    log_println(0, "Syntax error in line %d of the config file %s",
+                (-retcode), ConfigFileName);
+    exit(1);
+  }
+  fclose(conf);
 }
 
 /**
@@ -816,105 +816,105 @@ static void LoadConfig(char* name, char **lbuf, size_t *lbuf_max) {
 void *
 zombieWorker(void *head_ptr) {
 
-	struct ndtchild *tmp_ptr, *tmp, *pre_ptr = NULL;
-	int i = 0, retcode;
-	struct timeval sel_tv;
-	fd_set rfd;
-	char tmpstr[8], buff[32];
-	int msgType, msgLen = 1;
-
-	tmp_ptr = (struct ndtchild *) head_ptr;
-	/* walk through this chain until the 4th client is reached, this helps
-	 * prevent cases where the current client finishes and the next one begins
-	 * before we are done looking
-	 * RAC 7/8/09
-	 */
-	for (i = 0; i < 4; i++) {
-		log_println(6, "Bumping queue pointer by 1 child=%d", tmp_ptr->pid);
-		if (i == 3)
-			pre_ptr = tmp_ptr;
-		tmp_ptr = tmp_ptr->next;
-	}
-	snprintf(tmpstr, sizeof(tmpstr), "9990");
-	i = 0;
-	while (tmp_ptr != NULL) {
-		if (tmp_ptr->oldclient == 0) {
-			log_println(
-					6,
-					"old client found in queue, can't tell if it's a zombie, child=%d",
-					tmp_ptr->pid);
-			tmp_ptr = tmp_ptr->next;
-			pre_ptr = pre_ptr->next;
-			continue;
-		}
-		log_println(6, "New client found, checking for response, child=%d",
-				tmp_ptr->pid);
-
-		// send "keep-alive" SRV_QUEUE message to client and expect a response
-		retcode = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, tmpstr,
-				strlen(tmpstr));
-		log_println(6,
-				"send_msg() returned %d during zombie check on client %d",
-				retcode, tmp_ptr->pid);
-		FD_ZERO(&rfd);
-		FD_SET(tmp_ptr->ctlsockfd, &rfd);
-		sel_tv.tv_sec = 1;
-		sel_tv.tv_usec = 500000;
-		for (;;) {
-			retcode = select((tmp_ptr->ctlsockfd) + 1, &rfd, NULL, NULL,
-					&sel_tv);
-			switch (retcode) {
-			case 0:
-				//  a timeout occurred, remove zombie client from list
-				log_println(
-						6,
-						"New client didn't respond - must be a zombie, get rid of it, child=%d",
-						tmp_ptr->pid);
-				while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
-					log_println(
-							6,
-							"Waiting for ndtq semaphore to free - adding new client 1");
-					continue;
-				}
-				log_println(6, "removing client from FIFO, semaphore locked");
-				tmp = tmp_ptr;
-				pre_ptr->next = tmp_ptr->next;
-				tmp_ptr = tmp_ptr->next;
-				log_println(6, "timeout free tmp=0x%x", tmp);
-				free(tmp);
-				i++;
-				sem_post(&ndtq);
-				log_println(6, "Free'd semaphore lock - 4");
-				break;
-			default:
-				log_println(6,
-						"%d new client(s) responded, bumping pointers child=%d",
-						retcode, tmp_ptr->pid);
-				recv_msg(tmp_ptr->ctlsockfd, &msgType, buff, &msgLen);
-				tmp_ptr = tmp_ptr->next;
-				pre_ptr = pre_ptr->next;
-				/*
-				 if ((sig1 > 0) || (sig2 > 0))
-				 check_signal_flags();
-				 if (sig17 > 0)
-				 child_sig(0);
-				 */
-				break;
-			case -1: // some error status
-				if (errno == EINTR) {
-					log_println(
-							6,
-							"select() interrupted by signal, continue waiting for action or timeout");
-					continue;
-				}
-				log_println(6, "select returned errno=%d do nothing, child=%d",
-						errno, tmp_ptr->pid);
-				break;
-			}
-		}
-	}
-	zombie_check = i;
-	return NULL;
+  struct ndtchild *tmp_ptr, *tmp, *pre_ptr = NULL;
+  int i = 0, retcode;
+  struct timeval sel_tv;
+  fd_set rfd;
+  char tmpstr[8], buff[32];
+  int msgType, msgLen = 1;
+
+  tmp_ptr = (struct ndtchild *) head_ptr;
+  /* walk through this chain until the 4th client is reached, this helps
+   * prevent cases where the current client finishes and the next one begins
+   * before we are done looking
+   * RAC 7/8/09
+   */
+  for (i = 0; i < 4; i++) {
+    log_println(6, "Bumping queue pointer by 1 child=%d", tmp_ptr->pid);
+    if (i == 3)
+      pre_ptr = tmp_ptr;
+    tmp_ptr = tmp_ptr->next;
+  }
+  snprintf(tmpstr, sizeof(tmpstr), "9990");
+  i = 0;
+  while (tmp_ptr != NULL) {
+    if (tmp_ptr->oldclient == 0) {
+      log_println(
+          6,
+          "old client found in queue, can't tell if it's a zombie, child=%d",
+          tmp_ptr->pid);
+      tmp_ptr = tmp_ptr->next;
+      pre_ptr = pre_ptr->next;
+      continue;
+    }
+    log_println(6, "New client found, checking for response, child=%d",
+                tmp_ptr->pid);
+
+    // send "keep-alive" SRV_QUEUE message to client and expect a response
+    retcode = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, tmpstr,
+                       strlen(tmpstr));
+    log_println(6,
+                "send_msg() returned %d during zombie check on client %d",
+                retcode, tmp_ptr->pid);
+    FD_ZERO(&rfd);
+    FD_SET(tmp_ptr->ctlsockfd, &rfd);
+    sel_tv.tv_sec = 1;
+    sel_tv.tv_usec = 500000;
+    for (;;) {
+      retcode = select((tmp_ptr->ctlsockfd) + 1, &rfd, NULL, NULL,
+                       &sel_tv);
+      switch (retcode) {
+        case 0:
+          //  a timeout occurred, remove zombie client from list
+          log_println(
+              6,
+              "New client didn't respond - must be a zombie, get rid of it, child=%d",
+              tmp_ptr->pid);
+          while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
+            log_println(
+                6,
+                "Waiting for ndtq semaphore to free - adding new client 1");
+            continue;
+          }
+          log_println(6, "removing client from FIFO, semaphore locked");
+          tmp = tmp_ptr;
+          pre_ptr->next = tmp_ptr->next;
+          tmp_ptr = tmp_ptr->next;
+          log_println(6, "timeout free tmp=0x%x", tmp);
+          free(tmp);
+          i++;
+          sem_post(&ndtq);
+          log_println(6, "Free'd semaphore lock - 4");
+          break;
+        default:
+          log_println(6,
+                      "%d new client(s) responded, bumping pointers child=%d",
+                      retcode, tmp_ptr->pid);
+          recv_msg(tmp_ptr->ctlsockfd, &msgType, buff, &msgLen);
+          tmp_ptr = tmp_ptr->next;
+          pre_ptr = pre_ptr->next;
+          /*
+             if ((sig1 > 0) || (sig2 > 0))
+             check_signal_flags();
+             if (sig17 > 0)
+             child_sig(0);
+             */
+          break;
+        case -1: // some error status
+          if (errno == EINTR) {
+            log_println(
+                6,
+                "select() interrupted by signal, continue waiting for action or timeout");
+            continue;
+          }
+          log_println(6, "select returned errno=%d do nothing, child=%d",
+                      errno, tmp_ptr->pid);
+          break;
+      }
+    }
+  }
+  zombie_check = i;
+  return NULL;
 }
 
 /**
@@ -924,28 +924,28 @@ zombieWorker(void *head_ptr) {
  * */
 void*
 cputimeWorker(void* arg) {
-	char *logname = (char*) arg;
-	FILE* file = fopen(logname, "w");
-	struct tms buf;
-	double start = secs();
-
-	if (!file)
-		return NULL;
-
-	while (1) {
-		if (!cputimeworkerLoop) {
-			break;
-		}
-		times(&buf);
-		fprintf(file, "%.2f %ld %ld %ld %ld\n", secs() - start, buf.tms_utime,
-				buf.tms_stime, buf.tms_cutime, buf.tms_cstime);
-		fflush(file);
-		mysleep(0.1);
-	}
-
-	fclose(file);
-
-	return NULL;
+  char *logname = (char*) arg;
+  FILE* file = fopen(logname, "w");
+  struct tms buf;
+  double start = secs();
+
+  if (!file)
+    return NULL;
+
+  while (1) {
+    if (!cputimeworkerLoop) {
+      break;
+    }
+    times(&buf);
+    fprintf(file, "%.2f %ld %ld %ld %ld\n", secs() - start, buf.tms_utime,
+            buf.tms_stime, buf.tms_cutime, buf.tms_cstime);
+    fflush(file);
+    mysleep(0.1);
+  }
+
+  fclose(file);
+
+  return NULL;
 }
 
 /**
@@ -958,517 +958,517 @@ cputimeWorker(void* arg) {
  * */
 
 int run_test(web100_agent* agent, int ctlsockfd, TestOptions* testopt,
-		char *test_suite) {
-
-	char date[32]; // date indicator
-	char spds[4][256]; // speed "bin" array containing counters for speeds
-	char logstr1[4096], logstr2[1024]; // log
-	char tmpstr[256];
-	char isoTime[64];
-
-	//int n; // temporary iterator variable --// commented out -> calc_linkspeed
-	int Timeouts, SumRTT, CountRTT, PktsRetrans, FastRetran, DataPktsOut;
-	int AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn, MaxRwinRcvd, Sndbuf;
-	int CurrentCwnd, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
-			DataBytesOut;
-	int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
-	int CurrentRTO, CurrentRwinRcvd, MaxCwnd, CongestionSignals, PktsOut,
-			MinRTT;
-	int CongAvoid, CongestionOverCount, MaxRTT, OtherReductions,
-			CurTimeoutCount=0;
-	int AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
-			ThruBytesAcked;
-	int RcvWinScale, SndWinScale;
-	int link = CANNOT_DETERMINE_LINK; // local temporary variable indicative of link speed. Transmitted
-	// but unused at client end , which has a similar link speed variable
-	int mismatch = 0, bad_cable = 0;
-	int half_duplex = NO_HALF_DUPLEX;
-	int congestion = 0, totaltime;
-	int ret, spd_index;
-	//int index; // commented out -> calc_linkspeed
-	//int links[16]; // commented out -> calc_linkspeed
-	// int max; // commented out -> calc_linkspeed
-	// int total;// commented out -> calc_linkspeed
-	int c2s_linkspeed_data = 0; // C->S data link speed indicator determined using results
-	int c2s_linkspeed_ack = 0; //
-	int s2c_linkspeed_data = 0; // S->C data link speed indicator determined using results
-	int s2c_linkspeed_ack = 0;
-	//int j;        // commented out -> calc_linkspeed
-	int totalcnt;
-	int autotune;
-	u_int32_t dec_cnt, same_cnt, inc_cnt; // values collected from the speed tests
-        int timeout, dupack;
-	//int ifspeed;
-
-	time_t stime;
-
-	double rttsec; // average round trip time
-	double swin, cwin; //send, congestion window sizes respectively
-	double rwin; // max window size advertisement rcvd
-	double rwintime; // time spent being limited due to rcvr end
-	double cwndtime; // time spent being limited due to congestion
-	double sendtime; // time spent being limited due to sender's own fault
-
-	double oo_order; // out-of-order packet ratio
-	double waitsec;
-	double bw_theortcl; // theoretical bandwidth
-	double avgrtt; // Average round-trip time
-	double timesec; // Total test time in microseconds
-	double packetloss_s2c; // Packet loss as calculated from S->c tests.
-	double RTOidle; // Proportion of idle time spent waiting for packets to arrive
-	double s2cspd; // average throughput as calculated by S->C test
-	double c2sspd; // average throughput as calculated by C->S test
-	double s2c2spd; // average throughput as calculated by midbox test
-	double realthruput; // total send throughput in S->C
-	double acksratio; // ratio of acks over packets sent
-	double aspd = 0;
-	double tmoutsratio; // timeouts fraction
-	double rtranratio, dackratio; // ratio of retransmissions and duplicate acks over packets sent
-	float runave[4];
-
-	FILE * fp;
-
-	web100_connection* conn;
-
-	// start with a clean slate of currently running test and direction
-	setCurrentTest(TEST_NONE);
-	log_println(7,"Remote host= %s", get_remotehost());
-
-	stime = time(0);
-	log_println(4, "Child process %d started", getpid());
-	testopt->child0 = getpid();
-
-	// initialize speeds array
-	for (spd_index = 0; spd_index < 4; spd_index++)
-		for (ret = 0; ret < 256; ret++)
-			spds[spd_index][ret] = 0x00;
-	spd_index = 0;
-
-	// obtain web100 connection and check auto-tune status
-	conn = web100_connection_from_socket(agent, ctlsockfd);
-	autotune = web100_autotune(ctlsockfd, agent, conn);
-
-	// client needs to be version compatible. Send current version
-	snprintf(buff, sizeof(buff), "v%s", VERSION);
-	send_msg(ctlsockfd, MSG_LOGIN, buff, strlen(buff));
-
-	// initiate test with MSG_LOGIN message.
-	log_println(3, "run_test() routine, asking for test_suite = %s",
-			test_suite);
-	send_msg(ctlsockfd, MSG_LOGIN, test_suite, strlen(test_suite));
-	/* if ((n = initialize_tests(ctlsockfd, &testopt, conn_options))) {
-	 log_println(0, "ERROR: Tests initialization failed (%d)", n);
-	 return;
-	 }
-	 */
-
-	log_println(1, "Starting test suite:");
-	if (testopt->midopt) {
-		log_println(1, " > Middlebox test");
-	}
-	if (testopt->sfwopt) {
-		log_println(1, " > Simple firewall test");
-	}
-	if (testopt->c2sopt) {
-		log_println(1, " > C2S throughput test");
-	}
-	if (testopt->s2copt) {
-		log_println(1, " > S2C throughput test");
-	}
-	if (testopt->metaopt) {
-		log_println(1, " > META test");
-	}
-
-	/*  alarm(15); */
-	// Run scheduled test. Log error code if necessary
-	log_println(6, "Starting middlebox test");
-	if ((ret = test_mid(ctlsockfd, agent, &*testopt, conn_options, &s2c2spd))
-			!= 0) {
-		if (ret < 0)
-			log_println(6, "Middlebox test failed with rc=%d", ret);
-		log_println(0, "Middlebox test FAILED!, rc=%d", ret);
-		testopt->midopt = TOPT_DISABLED;
-		return ret;
-	}
-
-	/*  alarm(20); */
-	log_println(6, "Starting simple firewall test");
-	if ((ret = test_sfw_srv(ctlsockfd, agent, &*testopt, conn_options)) != 0) {
-		if (ret < 0)
-			log_println(6, "SFW test failed with rc=%d", ret);
-	}
-
-	/*  alarm(25); */
-	log_println(6, "Starting c2s throughput test");
-	if ((ret = test_c2s(ctlsockfd, agent, &*testopt, conn_options, &c2sspd,
-			set_buff, window, autotune, device, &options, record_reverse,
-			count_vars, spds, &spd_index)) != 0) {
-		if (ret < 0)
-			log_println(6, "C2S test failed with rc=%d", ret);
-		log_println(0, "C2S throughput test FAILED!, rc=%d", ret);
-		testopt->c2sopt = TOPT_DISABLED;
-		return ret;
-	}
-
-	/*  alarm(25); */
-	log_println(6, "Starting s2c throughput test");
-	if ((ret = test_s2c(ctlsockfd, agent, &*testopt, conn_options, &s2cspd,
-			set_buff, window, autotune, device, &options, spds, &spd_index,
-			count_vars, &peaks)) != 0) {
-		if (ret < 0)
-			log_println(6, "S2C test failed with rc=%d", ret);
-		log_println(0, "S2C throughput test FAILED!, rc=%d", ret);
-		testopt->s2copt = TOPT_DISABLED;
-		return ret;
-	}
-
-	log_println(6, "Starting META test");
-	if ((ret = test_meta_srv(ctlsockfd, agent, &*testopt, conn_options)) != 0) {
-		if (ret < 0) {
-			log_println(6, "META test failed with rc=%d", ret);
-		}
-	}
-
-	// Compute variable values from test results and deduce results
-	log_println(4, "Finished testing C2S = %0.2f Mbps, S2C = %0.2f Mbps",
-			c2sspd / 1000, s2cspd / 1000);
-
-	// Determine link speed
-	calc_linkspeed(spds, spd_index, &c2s_linkspeed_data, &c2s_linkspeed_ack, &s2c_linkspeed_data, &s2c_linkspeed_ack,
-			runave, &dec_cnt, &same_cnt, &inc_cnt, &timeout, &dupack,
-			testopt->c2sopt);
-	// Get web100 vars
-
-	// ...determine number of times congestion window has been changed
-	if (options.cwndDecrease) {
-		dec_cnt = inc_cnt = same_cnt = 0;
-		CwndDecrease(agent, options.s2c_logname, &dec_cnt, &same_cnt, &inc_cnt);
-		log_println(2, "####### decreases = %d, increases = %d, no change = %d",
-				dec_cnt, inc_cnt, same_cnt);
-	}
-
-	// ...other variables
-	web100_logvars(&Timeouts, &SumRTT, &CountRTT, &PktsRetrans, &FastRetran,
-			&DataPktsOut, &AckPktsOut, &CurrentMSS, &DupAcksIn, &AckPktsIn,
-			&MaxRwinRcvd, &Sndbuf, &CurrentCwnd, &SndLimTimeRwin,
-			&SndLimTimeCwnd, &SndLimTimeSender, &DataBytesOut, &SndLimTransRwin,
-			&SndLimTransCwnd, &SndLimTransSender, &MaxSsthresh, &CurrentRTO,
-			&CurrentRwinRcvd, &MaxCwnd, &CongestionSignals, &PktsOut, &MinRTT,
-			count_vars, &RcvWinScale, &SndWinScale, &CongAvoid,
-			&CongestionOverCount, &MaxRTT, &OtherReductions, &CurTimeoutCount,
-			&AbruptTimeouts, &SendStall, &SlowStart, &SubsequentTimeouts,
-			&ThruBytesAcked);
-
-	// end getting web100 variable values
-	/* if (rc == 0) { */
-
-	// section to calculate duplex mismatch
-	// Calculate average round trip time and convert to seconds
-	rttsec = calc_avg_rtt(SumRTT, CountRTT, &avgrtt);
-	// Calculate packet loss
-	packetloss_s2c = calc_packetloss(CongestionSignals, PktsOut, c2s_linkspeed_data);
-
-	// Calculate ratio of packets arriving out of order
-	oo_order = calc_packets_outoforder(DupAcksIn, AckPktsIn);
-
-	// calculate theoretical maximum goodput in bits
-	bw_theortcl = calc_max_theoretical_throughput(CurrentMSS, rttsec,
-			packetloss_s2c);
-
-	//get window sizes
-	calc_window_sizes(&SndWinScale, &RcvWinScale, Sndbuf, MaxRwinRcvd,
-			MaxCwnd, &rwin, &swin, &cwin);
-
-	// Total test time
-	totaltime = calc_totaltesttime(SndLimTimeRwin, SndLimTimeCwnd,
-			SndLimTimeSender);
-
-	// time spent being send-limited due to client's recv window
-	rwintime = calc_sendlimited_rcvrfault(SndLimTimeRwin, totaltime);
-
-	// time spent in being send-limited due to congestion window
-	cwndtime = calc_sendlimited_cong(SndLimTimeCwnd, totaltime);
-
-	// time spent in being send-limited due to own fault
-	sendtime = calc_sendlimited_sndrfault(SndLimTimeSender, totaltime);
-
-	timesec = totaltime / MEGA; // total time in microsecs
-
-	// get fraction of total test time waiting for packets to arrive
-	RTOidle = calc_RTOIdle(Timeouts, CurrentRTO, timesec);
-
-	// get timeout, retransmission, acks and dup acks ratios.
-	tmoutsratio = (double) Timeouts / PktsOut;
-	rtranratio = (double) PktsRetrans / PktsOut;
-	acksratio = (double) AckPktsIn / PktsOut;
-	dackratio = (double) DupAcksIn / (double) AckPktsIn;
-
-	// get actual throughput in Mbps (totaltime is in microseconds)
-	realthruput = calc_real_throughput(DataBytesOut, totaltime);
-
-	// total time spent waiting
-	waitsec = cal_totalwaittime(CurrentRTO, Timeouts);
-
-	log_println(2, "CWND limited test = %0.2f while unlimited = %0.2f", s2c2spd,
-			s2cspd);
-
-	// Is thruput measured with limited cwnd(midbox test) > as reported S->C test
-	if (is_limited_cwnd_throughput_better(s2c2spd, s2cspd)
-			&& isNotMultipleTestMode(multiple))
-		log_println(
-				2,
-				"Better throughput when CWND is limited, may be duplex mismatch");
-	else
-		log_println(2,
-				"Better throughput without CWND limits - normal operation");
-
-	/* remove the following line when the new detection code is ready for release */
-	// retaining old comment above
-	// client link duplex mismatch detection heuristic
-	old_mismatch = 1;
-
-	if (old_mismatch == 1) {
-		if (detect_duplexmismatch(cwndtime, bw_theortcl, PktsRetrans, timesec,
-				MaxSsthresh, RTOidle, link, s2cspd, s2c2spd, multiple)) {
-			if (is_c2s_throughputbetter(c2sspd, s2cspd)) { // also, S->C throughput is lesser than C->S throughput
-				mismatch = DUPLEX_OLD_ALGO_INDICATOR;
-				// possible duplex, from Old Duplex-Mismatch logic
-			} else {
-				mismatch = DUPLEX_SWITCH_FULL_HOST_HALF;
-				// switch full, host half
-			}
-			link = LINK_ALGO_FAILED;
-		}
-
-		// test for uplink with duplex mismatch condition
-		if (detect_internal_duplexmismatch(
-				(s2cspd / 1000), realthruput, rwintime, packetloss_s2c )) {
-			mismatch = DUPLEX_SWITCH_FULL_HOST_HALF; // switch full, host half
-			link = LINK_ALGO_FAILED;
-		}
-	} else {
-		/* This section of code is being held up for non-technical reasons.
-		 * Once those issues are resolved a new mismatch detection algorim
-		 * will be placed here.
-		 *  RAC 5-11-06
-		 */
-	}
-
-	// end section calculating duplex mismatch
-
-	// Section to deduce if there is faulty hardware links
-
-	// estimate is less than actual throughput, something is wrong
-	if (bw_theortcl < realthruput)
-		link = LINK_ALGO_FAILED;
-
-	// Faulty hardware link heuristic.
-	if (detect_faultyhardwarelink(packetloss_s2c, cwndtime, timesec,
-			MaxSsthresh))
-		bad_cable = POSSIBLE_BAD_CABLE;
-
-	// test for Ethernet link (assume Fast E.)
-	if (detect_ethernetlink(realthruput, s2cspd, packetloss_s2c, oo_order,
-			link))
-		link = LINK_ETHERNET;
-
-	// test for wireless link
-	if (detect_wirelesslink(sendtime, realthruput, bw_theortcl, SndLimTransRwin,
-			SndLimTransCwnd, rwintime, link))
-		link = LINK_WIRELESS;
-
-	// test for DSL/Cable modem link
-	if (detect_DSLCablelink(SndLimTimeSender, SndLimTransSender, realthruput,
-			bw_theortcl, link))
-		link = LINK_DSLORCABLE;
-
-	// full/half link duplex setting heuristic:
-	// receiver-limited- time > 95%,
-	//  .. number of transitions into the 'Receiver Limited' state is greater than 30 ps
-	//  ...and the number of transitions into the 'Sender Limited' state is greater than 30 per second
-
-	if (detect_halfduplex(rwintime, SndLimTransRwin, SndLimTransSender,
-			timesec))
-		half_duplex = POSSIBLE_HALF_DUPLEX;
-
-	// congestion detection heuristic
-	if (detect_congestionwindow(cwndtime, mismatch, cwin, rwin, rttsec))
-		congestion = POSSIBLE_CONGESTION;
-
-	// Send results and variable values to clients
-	snprintf(buff, sizeof(buff), "c2sData: %d\nc2sAck: %d\ns2cData: %d\ns2cAck: %d\n", c2s_linkspeed_data,
-			c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack);
-	send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
-
-	snprintf(
-			buff,sizeof(buff),
-			"half_duplex: %d\nlink: %d\ncongestion: %d\nbad_cable: %d\nmismatch: %d\nspd: %0.2f\n",
-			half_duplex, link, congestion, bad_cable, mismatch, realthruput);
-	send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
-
-	snprintf(
-			buff,sizeof(buff),
-			"bw: %0.2f\nloss: %0.9f\navgrtt: %0.2f\nwaitsec: %0.2f\ntimesec: %0.2f\norder: %0.4f\n",
-			bw_theortcl, packetloss_s2c, avgrtt, waitsec, timesec, oo_order);
-	send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
-
-	snprintf(
-			buff,sizeof(buff),
-			"rwintime: %0.4f\nsendtime: %0.4f\ncwndtime: %0.4f\nrwin: %0.4f\nswin: %0.4f\n",
-			rwintime, sendtime, cwndtime, rwin, swin);
-	send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
-
-	snprintf(
-			buff,sizeof(buff),
-			"cwin: %0.4f\nrttsec: %0.6f\nSndbuf: %d\naspd: %0.5f\nCWND-Limited: %0.2f\n",
-			cwin, rttsec, Sndbuf, aspd, s2c2spd);
-	send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
-
-	snprintf(buff, sizeof(buff), "minCWNDpeak: %d\nmaxCWNDpeak: %d\nCWNDpeaks: %d\n",
-			peaks.min, peaks.max, peaks.amount);
-	send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
-
-	// Signal end of test results to client
-	send_msg(ctlsockfd, MSG_LOGOUT, "", 0);
-
-	// Copy collected values into the meta data structures. This section
-	// seems most readable, easy to debug here.
-	snprintf(meta.date, sizeof(meta.date), "%s", get_ISOtime(isoTime, sizeof(isoTime)));
-
-	log_println(9, "meta.date=%s, meta.clientip =%s:%s:%d", meta.date,
-			meta.client_ip, rmt_host, strlen(rmt_host));
-	memcpy(meta.client_ip, rmt_host, strlen(rmt_host));
-	log_println(9, "2. meta.clientip =%s:%s:%d", meta.client_ip, rmt_host);
-
-	memset(tmpstr, 0, sizeof(tmpstr));
-	snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", (int) s2c2spd,
-			(int) s2cspd, (int) c2sspd, Timeouts, SumRTT, CountRTT, PktsRetrans,
-			FastRetran, DataPktsOut, AckPktsOut, CurrentMSS, DupAcksIn,
-			AckPktsIn);
-	memcpy(meta.summary, tmpstr, strlen(tmpstr));
-	memset(tmpstr, 0, sizeof(tmpstr));
-	snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", MaxRwinRcvd,
-			Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
-			DataBytesOut, SndLimTransRwin, SndLimTransCwnd, SndLimTransSender,
-			MaxSsthresh, CurrentRTO, CurrentRwinRcvd);
-
-	strlcat(meta.summary, tmpstr, sizeof(meta.summary));
-	memset(tmpstr, 0, sizeof(tmpstr));
-	snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d", link, mismatch, bad_cable, half_duplex,
-			congestion);
-
-	strlcat(meta.summary, tmpstr, sizeof(meta.summary));
-	memset(tmpstr, 0, sizeof(tmpstr));
-	snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d,%d,%d,%d,%d,%d,%d", c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data,
-			s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale, autotune);
-
-	strlcat(meta.summary, tmpstr, sizeof(meta.summary));
-	memset(tmpstr, 0, sizeof(tmpstr));
-	snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", CongAvoid,
-			CongestionOverCount, MaxRTT, OtherReductions, CurTimeoutCount,
-			AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
-			ThruBytesAcked);
-
-	strlcat(meta.summary, tmpstr, sizeof(meta.summary));
-	memset(tmpstr, 0, sizeof(tmpstr));
-	snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d", peaks.min, peaks.max, peaks.amount);
-
-	strlcat(meta.summary, tmpstr, sizeof(meta.summary));
-	writeMeta(options.compress, cputime, options.snaplog, dumptrace);
-
-	// Write into log files, DB
-	fp = fopen(get_logfile(), "a");
-	if (fp == NULL) {
-		log_println(0,
-				"Unable to open log file '%s', continuing on without logging",
-				get_logfile());
-	} else {
-		snprintf(date, sizeof(date), "%15.15s", ctime(&stime) + 4);
-		fprintf(fp, "%s,", date);
-		fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", rmt_host,
-				(int) s2c2spd, (int) s2cspd, (int) c2sspd, Timeouts, SumRTT,
-				CountRTT, PktsRetrans, FastRetran, DataPktsOut, AckPktsOut,
-				CurrentMSS, DupAcksIn, AckPktsIn);
-		fprintf(fp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", MaxRwinRcvd,
-				Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd,
-				SndLimTimeSender, DataBytesOut, SndLimTransRwin,
-				SndLimTransCwnd, SndLimTransSender, MaxSsthresh, CurrentRTO,
-				CurrentRwinRcvd);
-		fprintf(fp, "%d,%d,%d,%d,%d", link, mismatch, bad_cable, half_duplex,
-				congestion);
-		fprintf(fp, ",%d,%d,%d,%d,%d,%d,%d,%d,%d", c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data,
-				s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale,
-				autotune);
-		fprintf(fp, ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", CongAvoid,
-				CongestionOverCount, MaxRTT, OtherReductions, CurTimeoutCount,
-				AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
-				ThruBytesAcked);
-		fprintf(fp, ",%d,%d,%d\n", peaks.min, peaks.max, peaks.amount);
-		fclose(fp);
-	}
-	db_insert(spds, runave, cputimelog, options.s2c_logname,
-			options.c2s_logname, testName, testPort, date, rmt_host, s2c2spd,
-			s2cspd, c2sspd, Timeouts, SumRTT, CountRTT, PktsRetrans, FastRetran,
-			DataPktsOut, AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn,
-			MaxRwinRcvd, Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd,
-			SndLimTimeSender, DataBytesOut, SndLimTransRwin, SndLimTransCwnd,
-			SndLimTransSender, MaxSsthresh, CurrentRTO, CurrentRwinRcvd, link,
-			mismatch, bad_cable, half_duplex, congestion, c2s_linkspeed_data, c2s_linkspeed_ack,
-			s2c_linkspeed_data, s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale,
-			autotune, CongAvoid, CongestionOverCount, MaxRTT, OtherReductions,
-			CurTimeoutCount, AbruptTimeouts, SendStall, SlowStart,
-			SubsequentTimeouts, ThruBytesAcked, peaks.min, peaks.max,
-			peaks.amount);
-	if (usesyslog == 1) {
-		snprintf(
-				logstr1, sizeof(logstr1),
-				"client_IP=%s,c2s_spd=%2.0f,s2c_spd=%2.0f,Timeouts=%d,SumRTT=%d,CountRTT=%d,PktsRetrans=%d,FastRetran=%d,DataPktsOut=%d,AckPktsOut=%d,CurrentMSS=%d,DupAcksIn=%d,AckPktsIn=%d,",
-				rmt_host, c2sspd, s2cspd, Timeouts, SumRTT, CountRTT,
-				PktsRetrans, FastRetran, DataPktsOut, AckPktsOut, CurrentMSS,
-				DupAcksIn, AckPktsIn);
-		snprintf(
-				logstr2, sizeof(logstr2),
-				"MaxRwinRcvd=%d,Sndbuf=%d,MaxCwnd=%d,SndLimTimeRwin=%d,SndLimTimeCwnd=%d,SndLimTimeSender=%d,DataBytesOut=%d,SndLimTransRwin=%d,SndLimTransCwnd=%d,SndLimTransSender=%d,MaxSsthresh=%d,CurrentRTO=%d,CurrentRwinRcvd=%d,",
-				MaxRwinRcvd, Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd,
-				SndLimTimeSender, DataBytesOut, SndLimTransRwin,
-				SndLimTransCwnd, SndLimTransSender, MaxSsthresh, CurrentRTO,
-				CurrentRwinRcvd);
-		strlcat(logstr1, logstr2, sizeof(logstr1));
-		snprintf(
-				logstr2, sizeof(logstr2),
-				"link=%d,mismatch=%d,bad_cable=%d,half_duplex=%d,congestion=%d,c2s_linkspeed_data=%d,c2sack=%d,s2cdata=%d,s2cack=%d,CongestionSignals=%d,PktsOut=%d,MinRTT=%d,RcvWinScale=%d\n",
-				link, mismatch, bad_cable, half_duplex, congestion, c2s_linkspeed_data,
-				c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT,
-				RcvWinScale);
-		strncat(logstr1, logstr2, sizeof(logstr1));
-		syslog(LOG_FACILITY | LOG_INFO, "%s", logstr1);
-		closelog();
-		log_println(4, "%s", logstr1);
-	}
-
-	// close resources
-
-	if (testopt->s2copt) {
-		close(testopt->s2csockfd);
-	}
-
-	/* If the admin view is turned on then the client process is going to update these
-	 * variables.  The need to be shipped back to the parent so the admin page can be
-	 * updated.  Otherwise the changes are lost when the client terminates.
-	 */
-	if (admin_view == 1) {
-		totalcnt = calculate(date, SumRTT, CountRTT, CongestionSignals, PktsOut,
-				DupAcksIn, AckPktsIn, CurrentMSS, SndLimTimeRwin,
-				SndLimTimeCwnd, SndLimTimeSender, MaxRwinRcvd, CurrentCwnd,
-				Sndbuf, DataBytesOut, mismatch, bad_cable, (int) c2sspd,
-				(int) s2cspd, c2s_linkspeed_data, s2c_linkspeed_ack, 1);
-		gen_html((int) c2sspd, (int) s2cspd, MinRTT, PktsRetrans, Timeouts,
-				Sndbuf, MaxRwinRcvd, CurrentCwnd, mismatch, bad_cable, totalcnt,
-				refresh);
-	}
-	shutdown(ctlsockfd, SHUT_WR);
-	/* shutdown(ctlsockfd, SHUT_RDWR); */
-	return (0);
+             char *test_suite) {
+
+  char date[32]; // date indicator
+  char spds[4][256]; // speed "bin" array containing counters for speeds
+  char logstr1[4096], logstr2[1024]; // log
+  char tmpstr[256];
+  char isoTime[64];
+
+  //int n; // temporary iterator variable --// commented out -> calc_linkspeed
+  int Timeouts, SumRTT, CountRTT, PktsRetrans, FastRetran, DataPktsOut;
+  int AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn, MaxRwinRcvd, Sndbuf;
+  int CurrentCwnd, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
+      DataBytesOut;
+  int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
+  int CurrentRTO, CurrentRwinRcvd, MaxCwnd, CongestionSignals, PktsOut,
+      MinRTT;
+  int CongAvoid, CongestionOverCount, MaxRTT, OtherReductions,
+      CurTimeoutCount=0;
+  int AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
+      ThruBytesAcked;
+  int RcvWinScale, SndWinScale;
+  int link = CANNOT_DETERMINE_LINK; // local temporary variable indicative of link speed. Transmitted
+  // but unused at client end , which has a similar link speed variable
+  int mismatch = 0, bad_cable = 0;
+  int half_duplex = NO_HALF_DUPLEX;
+  int congestion = 0, totaltime;
+  int ret, spd_index;
+  //int index; // commented out -> calc_linkspeed
+  //int links[16]; // commented out -> calc_linkspeed
+  // int max; // commented out -> calc_linkspeed
+  // int total;// commented out -> calc_linkspeed
+  int c2s_linkspeed_data = 0; // C->S data link speed indicator determined using results
+  int c2s_linkspeed_ack = 0; //
+  int s2c_linkspeed_data = 0; // S->C data link speed indicator determined using results
+  int s2c_linkspeed_ack = 0;
+  //int j;        // commented out -> calc_linkspeed
+  int totalcnt;
+  int autotune;
+  u_int32_t dec_cnt, same_cnt, inc_cnt; // values collected from the speed tests
+  int timeout, dupack;
+  //int ifspeed;
+
+  time_t stime;
+
+  double rttsec; // average round trip time
+  double swin, cwin; //send, congestion window sizes respectively
+  double rwin; // max window size advertisement rcvd
+  double rwintime; // time spent being limited due to rcvr end
+  double cwndtime; // time spent being limited due to congestion
+  double sendtime; // time spent being limited due to sender's own fault
+
+  double oo_order; // out-of-order packet ratio
+  double waitsec;
+  double bw_theortcl; // theoretical bandwidth
+  double avgrtt; // Average round-trip time
+  double timesec; // Total test time in microseconds
+  double packetloss_s2c; // Packet loss as calculated from S->c tests.
+  double RTOidle; // Proportion of idle time spent waiting for packets to arrive
+  double s2cspd; // average throughput as calculated by S->C test
+  double c2sspd; // average throughput as calculated by C->S test
+  double s2c2spd; // average throughput as calculated by midbox test
+  double realthruput; // total send throughput in S->C
+  double acksratio; // ratio of acks over packets sent
+  double aspd = 0;
+  double tmoutsratio; // timeouts fraction
+  double rtranratio, dackratio; // ratio of retransmissions and duplicate acks over packets sent
+  float runave[4];
+
+  FILE * fp;
+
+  web100_connection* conn;
+
+  // start with a clean slate of currently running test and direction
+  setCurrentTest(TEST_NONE);
+  log_println(7,"Remote host= %s", get_remotehost());
+
+  stime = time(0);
+  log_println(4, "Child process %d started", getpid());
+  testopt->child0 = getpid();
+
+  // initialize speeds array
+  for (spd_index = 0; spd_index < 4; spd_index++)
+    for (ret = 0; ret < 256; ret++)
+      spds[spd_index][ret] = 0x00;
+  spd_index = 0;
+
+  // obtain web100 connection and check auto-tune status
+  conn = web100_connection_from_socket(agent, ctlsockfd);
+  autotune = web100_autotune(ctlsockfd, agent, conn);
+
+  // client needs to be version compatible. Send current version
+  snprintf(buff, sizeof(buff), "v%s", VERSION);
+  send_msg(ctlsockfd, MSG_LOGIN, buff, strlen(buff));
+
+  // initiate test with MSG_LOGIN message.
+  log_println(3, "run_test() routine, asking for test_suite = %s",
+              test_suite);
+  send_msg(ctlsockfd, MSG_LOGIN, test_suite, strlen(test_suite));
+  /* if ((n = initialize_tests(ctlsockfd, &testopt, conn_options))) {
+     log_println(0, "ERROR: Tests initialization failed (%d)", n);
+     return;
+     }
+     */
+
+  log_println(1, "Starting test suite:");
+  if (testopt->midopt) {
+    log_println(1, " > Middlebox test");
+  }
+  if (testopt->sfwopt) {
+    log_println(1, " > Simple firewall test");
+  }
+  if (testopt->c2sopt) {
+    log_println(1, " > C2S throughput test");
+  }
+  if (testopt->s2copt) {
+    log_println(1, " > S2C throughput test");
+  }
+  if (testopt->metaopt) {
+    log_println(1, " > META test");
+  }
+
+  /*  alarm(15); */
+  // Run scheduled test. Log error code if necessary
+  log_println(6, "Starting middlebox test");
+  if ((ret = test_mid(ctlsockfd, agent, &*testopt, conn_options, &s2c2spd))
+      != 0) {
+    if (ret < 0)
+      log_println(6, "Middlebox test failed with rc=%d", ret);
+    log_println(0, "Middlebox test FAILED!, rc=%d", ret);
+    testopt->midopt = TOPT_DISABLED;
+    return ret;
+  }
+
+  /*  alarm(20); */
+  log_println(6, "Starting simple firewall test");
+  if ((ret = test_sfw_srv(ctlsockfd, agent, &*testopt, conn_options)) != 0) {
+    if (ret < 0)
+      log_println(6, "SFW test failed with rc=%d", ret);
+  }
+
+  /*  alarm(25); */
+  log_println(6, "Starting c2s throughput test");
+  if ((ret = test_c2s(ctlsockfd, agent, &*testopt, conn_options, &c2sspd,
+                      set_buff, window, autotune, device, &options, record_reverse,
+                      count_vars, spds, &spd_index)) != 0) {
+    if (ret < 0)
+      log_println(6, "C2S test failed with rc=%d", ret);
+    log_println(0, "C2S throughput test FAILED!, rc=%d", ret);
+    testopt->c2sopt = TOPT_DISABLED;
+    return ret;
+  }
+
+  /*  alarm(25); */
+  log_println(6, "Starting s2c throughput test");
+  if ((ret = test_s2c(ctlsockfd, agent, &*testopt, conn_options, &s2cspd,
+                      set_buff, window, autotune, device, &options, spds, &spd_index,
+                      count_vars, &peaks)) != 0) {
+    if (ret < 0)
+      log_println(6, "S2C test failed with rc=%d", ret);
+    log_println(0, "S2C throughput test FAILED!, rc=%d", ret);
+    testopt->s2copt = TOPT_DISABLED;
+    return ret;
+  }
+
+  log_println(6, "Starting META test");
+  if ((ret = test_meta_srv(ctlsockfd, agent, &*testopt, conn_options)) != 0) {
+    if (ret < 0) {
+      log_println(6, "META test failed with rc=%d", ret);
+    }
+  }
+
+  // Compute variable values from test results and deduce results
+  log_println(4, "Finished testing C2S = %0.2f Mbps, S2C = %0.2f Mbps",
+              c2sspd / 1000, s2cspd / 1000);
+
+  // Determine link speed
+  calc_linkspeed(spds, spd_index, &c2s_linkspeed_data, &c2s_linkspeed_ack, &s2c_linkspeed_data, &s2c_linkspeed_ack,
+                 runave, &dec_cnt, &same_cnt, &inc_cnt, &timeout, &dupack,
+                 testopt->c2sopt);
+  // Get web100 vars
+
+  // ...determine number of times congestion window has been changed
+  if (options.cwndDecrease) {
+    dec_cnt = inc_cnt = same_cnt = 0;
+    CwndDecrease(agent, options.s2c_logname, &dec_cnt, &same_cnt, &inc_cnt);
+    log_println(2, "####### decreases = %d, increases = %d, no change = %d",
+                dec_cnt, inc_cnt, same_cnt);
+  }
+
+  // ...other variables
+  web100_logvars(&Timeouts, &SumRTT, &CountRTT, &PktsRetrans, &FastRetran,
+                 &DataPktsOut, &AckPktsOut, &CurrentMSS, &DupAcksIn, &AckPktsIn,
+                 &MaxRwinRcvd, &Sndbuf, &CurrentCwnd, &SndLimTimeRwin,
+                 &SndLimTimeCwnd, &SndLimTimeSender, &DataBytesOut, &SndLimTransRwin,
+                 &SndLimTransCwnd, &SndLimTransSender, &MaxSsthresh, &CurrentRTO,
+                 &CurrentRwinRcvd, &MaxCwnd, &CongestionSignals, &PktsOut, &MinRTT,
+                 count_vars, &RcvWinScale, &SndWinScale, &CongAvoid,
+                 &CongestionOverCount, &MaxRTT, &OtherReductions, &CurTimeoutCount,
+                 &AbruptTimeouts, &SendStall, &SlowStart, &SubsequentTimeouts,
+                 &ThruBytesAcked);
+
+  // end getting web100 variable values
+  /* if (rc == 0) { */
+
+  // section to calculate duplex mismatch
+  // Calculate average round trip time and convert to seconds
+  rttsec = calc_avg_rtt(SumRTT, CountRTT, &avgrtt);
+  // Calculate packet loss
+  packetloss_s2c = calc_packetloss(CongestionSignals, PktsOut, c2s_linkspeed_data);
+
+  // Calculate ratio of packets arriving out of order
+  oo_order = calc_packets_outoforder(DupAcksIn, AckPktsIn);
+
+  // calculate theoretical maximum goodput in bits
+  bw_theortcl = calc_max_theoretical_throughput(CurrentMSS, rttsec,
+                                                packetloss_s2c);
+
+  //get window sizes
+  calc_window_sizes(&SndWinScale, &RcvWinScale, Sndbuf, MaxRwinRcvd,
+                    MaxCwnd, &rwin, &swin, &cwin);
+
+  // Total test time
+  totaltime = calc_totaltesttime(SndLimTimeRwin, SndLimTimeCwnd,
+                                 SndLimTimeSender);
+
+  // time spent being send-limited due to client's recv window
+  rwintime = calc_sendlimited_rcvrfault(SndLimTimeRwin, totaltime);
+
+  // time spent in being send-limited due to congestion window
+  cwndtime = calc_sendlimited_cong(SndLimTimeCwnd, totaltime);
+
+  // time spent in being send-limited due to own fault
+  sendtime = calc_sendlimited_sndrfault(SndLimTimeSender, totaltime);
+
+  timesec = totaltime / MEGA; // total time in microsecs
+
+  // get fraction of total test time waiting for packets to arrive
+  RTOidle = calc_RTOIdle(Timeouts, CurrentRTO, timesec);
+
+  // get timeout, retransmission, acks and dup acks ratios.
+  tmoutsratio = (double) Timeouts / PktsOut;
+  rtranratio = (double) PktsRetrans / PktsOut;
+  acksratio = (double) AckPktsIn / PktsOut;
+  dackratio = (double) DupAcksIn / (double) AckPktsIn;
+
+  // get actual throughput in Mbps (totaltime is in microseconds)
+  realthruput = calc_real_throughput(DataBytesOut, totaltime);
+
+  // total time spent waiting
+  waitsec = cal_totalwaittime(CurrentRTO, Timeouts);
+
+  log_println(2, "CWND limited test = %0.2f while unlimited = %0.2f", s2c2spd,
+              s2cspd);
+
+  // Is thruput measured with limited cwnd(midbox test) > as reported S->C test
+  if (is_limited_cwnd_throughput_better(s2c2spd, s2cspd)
+      && isNotMultipleTestMode(multiple))
+    log_println(
+        2,
+        "Better throughput when CWND is limited, may be duplex mismatch");
+  else
+    log_println(2,
+                "Better throughput without CWND limits - normal operation");
+
+  /* remove the following line when the new detection code is ready for release */
+  // retaining old comment above
+  // client link duplex mismatch detection heuristic
+  old_mismatch = 1;
+
+  if (old_mismatch == 1) {
+    if (detect_duplexmismatch(cwndtime, bw_theortcl, PktsRetrans, timesec,
+                              MaxSsthresh, RTOidle, link, s2cspd, s2c2spd, multiple)) {
+      if (is_c2s_throughputbetter(c2sspd, s2cspd)) { // also, S->C throughput is lesser than C->S throughput
+        mismatch = DUPLEX_OLD_ALGO_INDICATOR;
+        // possible duplex, from Old Duplex-Mismatch logic
+      } else {
+        mismatch = DUPLEX_SWITCH_FULL_HOST_HALF;
+        // switch full, host half
+      }
+      link = LINK_ALGO_FAILED;
+    }
+
+    // test for uplink with duplex mismatch condition
+    if (detect_internal_duplexmismatch(
+        (s2cspd / 1000), realthruput, rwintime, packetloss_s2c )) {
+      mismatch = DUPLEX_SWITCH_FULL_HOST_HALF; // switch full, host half
+      link = LINK_ALGO_FAILED;
+    }
+  } else {
+    /* This section of code is being held up for non-technical reasons.
+     * Once those issues are resolved a new mismatch detection algorim
+     * will be placed here.
+     *  RAC 5-11-06
+     */
+  }
+
+  // end section calculating duplex mismatch
+
+  // Section to deduce if there is faulty hardware links
+
+  // estimate is less than actual throughput, something is wrong
+  if (bw_theortcl < realthruput)
+    link = LINK_ALGO_FAILED;
+
+  // Faulty hardware link heuristic.
+  if (detect_faultyhardwarelink(packetloss_s2c, cwndtime, timesec,
+                                MaxSsthresh))
+    bad_cable = POSSIBLE_BAD_CABLE;
+
+  // test for Ethernet link (assume Fast E.)
+  if (detect_ethernetlink(realthruput, s2cspd, packetloss_s2c, oo_order,
+                          link))
+    link = LINK_ETHERNET;
+
+  // test for wireless link
+  if (detect_wirelesslink(sendtime, realthruput, bw_theortcl, SndLimTransRwin,
+                          SndLimTransCwnd, rwintime, link))
+    link = LINK_WIRELESS;
+
+  // test for DSL/Cable modem link
+  if (detect_DSLCablelink(SndLimTimeSender, SndLimTransSender, realthruput,
+                          bw_theortcl, link))
+    link = LINK_DSLORCABLE;
+
+  // full/half link duplex setting heuristic:
+  // receiver-limited- time > 95%,
+  //  .. number of transitions into the 'Receiver Limited' state is greater than 30 ps
+  //  ...and the number of transitions into the 'Sender Limited' state is greater than 30 per second
+
+  if (detect_halfduplex(rwintime, SndLimTransRwin, SndLimTransSender,
+                        timesec))
+    half_duplex = POSSIBLE_HALF_DUPLEX;
+
+  // congestion detection heuristic
+  if (detect_congestionwindow(cwndtime, mismatch, cwin, rwin, rttsec))
+    congestion = POSSIBLE_CONGESTION;
+
+  // Send results and variable values to clients
+  snprintf(buff, sizeof(buff), "c2sData: %d\nc2sAck: %d\ns2cData: %d\ns2cAck: %d\n", c2s_linkspeed_data,
+           c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack);
+  send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
+
+  snprintf(
+      buff,sizeof(buff),
+      "half_duplex: %d\nlink: %d\ncongestion: %d\nbad_cable: %d\nmismatch: %d\nspd: %0.2f\n",
+      half_duplex, link, congestion, bad_cable, mismatch, realthruput);
+  send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
+
+  snprintf(
+      buff,sizeof(buff),
+      "bw: %0.2f\nloss: %0.9f\navgrtt: %0.2f\nwaitsec: %0.2f\ntimesec: %0.2f\norder: %0.4f\n",
+      bw_theortcl, packetloss_s2c, avgrtt, waitsec, timesec, oo_order);
+  send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
+
+  snprintf(
+      buff,sizeof(buff),
+      "rwintime: %0.4f\nsendtime: %0.4f\ncwndtime: %0.4f\nrwin: %0.4f\nswin: %0.4f\n",
+      rwintime, sendtime, cwndtime, rwin, swin);
+  send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
+
+  snprintf(
+      buff,sizeof(buff),
+      "cwin: %0.4f\nrttsec: %0.6f\nSndbuf: %d\naspd: %0.5f\nCWND-Limited: %0.2f\n",
+      cwin, rttsec, Sndbuf, aspd, s2c2spd);
+  send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
+
+  snprintf(buff, sizeof(buff), "minCWNDpeak: %d\nmaxCWNDpeak: %d\nCWNDpeaks: %d\n",
+           peaks.min, peaks.max, peaks.amount);
+  send_msg(ctlsockfd, MSG_RESULTS, buff, strlen(buff));
+
+  // Signal end of test results to client
+  send_msg(ctlsockfd, MSG_LOGOUT, "", 0);
+
+  // Copy collected values into the meta data structures. This section
+  // seems most readable, easy to debug here.
+  snprintf(meta.date, sizeof(meta.date), "%s", get_ISOtime(isoTime, sizeof(isoTime)));
+
+  log_println(9, "meta.date=%s, meta.clientip =%s:%s:%d", meta.date,
+              meta.client_ip, rmt_host, strlen(rmt_host));
+  memcpy(meta.client_ip, rmt_host, strlen(rmt_host));
+  log_println(9, "2. meta.clientip =%s:%s:%d", meta.client_ip, rmt_host);
+
+  memset(tmpstr, 0, sizeof(tmpstr));
+  snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", (int) s2c2spd,
+           (int) s2cspd, (int) c2sspd, Timeouts, SumRTT, CountRTT, PktsRetrans,
+           FastRetran, DataPktsOut, AckPktsOut, CurrentMSS, DupAcksIn,
+           AckPktsIn);
+  memcpy(meta.summary, tmpstr, strlen(tmpstr));
+  memset(tmpstr, 0, sizeof(tmpstr));
+  snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", MaxRwinRcvd,
+           Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender,
+           DataBytesOut, SndLimTransRwin, SndLimTransCwnd, SndLimTransSender,
+           MaxSsthresh, CurrentRTO, CurrentRwinRcvd);
+
+  strlcat(meta.summary, tmpstr, sizeof(meta.summary));
+  memset(tmpstr, 0, sizeof(tmpstr));
+  snprintf(tmpstr, sizeof(tmpstr), "%d,%d,%d,%d,%d", link, mismatch, bad_cable, half_duplex,
+           congestion);
+
+  strlcat(meta.summary, tmpstr, sizeof(meta.summary));
+  memset(tmpstr, 0, sizeof(tmpstr));
+  snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d,%d,%d,%d,%d,%d,%d", c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data,
+           s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale, autotune);
+
+  strlcat(meta.summary, tmpstr, sizeof(meta.summary));
+  memset(tmpstr, 0, sizeof(tmpstr));
+  snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", CongAvoid,
+           CongestionOverCount, MaxRTT, OtherReductions, CurTimeoutCount,
+           AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
+           ThruBytesAcked);
+
+  strlcat(meta.summary, tmpstr, sizeof(meta.summary));
+  memset(tmpstr, 0, sizeof(tmpstr));
+  snprintf(tmpstr, sizeof(tmpstr), ",%d,%d,%d", peaks.min, peaks.max, peaks.amount);
+
+  strlcat(meta.summary, tmpstr, sizeof(meta.summary));
+  writeMeta(options.compress, cputime, options.snaplog, dumptrace);
+
+  // Write into log files, DB
+  fp = fopen(get_logfile(), "a");
+  if (fp == NULL) {
+    log_println(0,
+                "Unable to open log file '%s', continuing on without logging",
+                get_logfile());
+  } else {
+    snprintf(date, sizeof(date), "%15.15s", ctime(&stime) + 4);
+    fprintf(fp, "%s,", date);
+    fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", rmt_host,
+            (int) s2c2spd, (int) s2cspd, (int) c2sspd, Timeouts, SumRTT,
+            CountRTT, PktsRetrans, FastRetran, DataPktsOut, AckPktsOut,
+            CurrentMSS, DupAcksIn, AckPktsIn);
+    fprintf(fp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,", MaxRwinRcvd,
+            Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd,
+            SndLimTimeSender, DataBytesOut, SndLimTransRwin,
+            SndLimTransCwnd, SndLimTransSender, MaxSsthresh, CurrentRTO,
+            CurrentRwinRcvd);
+    fprintf(fp, "%d,%d,%d,%d,%d", link, mismatch, bad_cable, half_duplex,
+            congestion);
+    fprintf(fp, ",%d,%d,%d,%d,%d,%d,%d,%d,%d", c2s_linkspeed_data, c2s_linkspeed_ack, s2c_linkspeed_data,
+            s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale,
+            autotune);
+    fprintf(fp, ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", CongAvoid,
+            CongestionOverCount, MaxRTT, OtherReductions, CurTimeoutCount,
+            AbruptTimeouts, SendStall, SlowStart, SubsequentTimeouts,
+            ThruBytesAcked);
+    fprintf(fp, ",%d,%d,%d\n", peaks.min, peaks.max, peaks.amount);
+    fclose(fp);
+  }
+  db_insert(spds, runave, cputimelog, options.s2c_logname,
+            options.c2s_logname, testName, testPort, date, rmt_host, s2c2spd,
+            s2cspd, c2sspd, Timeouts, SumRTT, CountRTT, PktsRetrans, FastRetran,
+            DataPktsOut, AckPktsOut, CurrentMSS, DupAcksIn, AckPktsIn,
+            MaxRwinRcvd, Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd,
+            SndLimTimeSender, DataBytesOut, SndLimTransRwin, SndLimTransCwnd,
+            SndLimTransSender, MaxSsthresh, CurrentRTO, CurrentRwinRcvd, link,
+            mismatch, bad_cable, half_duplex, congestion, c2s_linkspeed_data, c2s_linkspeed_ack,
+            s2c_linkspeed_data, s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT, RcvWinScale,
+            autotune, CongAvoid, CongestionOverCount, MaxRTT, OtherReductions,
+            CurTimeoutCount, AbruptTimeouts, SendStall, SlowStart,
+            SubsequentTimeouts, ThruBytesAcked, peaks.min, peaks.max,
+            peaks.amount);
+  if (usesyslog == 1) {
+    snprintf(
+        logstr1, sizeof(logstr1),
+        "client_IP=%s,c2s_spd=%2.0f,s2c_spd=%2.0f,Timeouts=%d,SumRTT=%d,CountRTT=%d,PktsRetrans=%d,FastRetran=%d,DataPktsOut=%d,AckPktsOut=%d,CurrentMSS=%d,DupAcksIn=%d,AckPktsIn=%d,",
+        rmt_host, c2sspd, s2cspd, Timeouts, SumRTT, CountRTT,
+        PktsRetrans, FastRetran, DataPktsOut, AckPktsOut, CurrentMSS,
+        DupAcksIn, AckPktsIn);
+    snprintf(
+        logstr2, sizeof(logstr2),
+        "MaxRwinRcvd=%d,Sndbuf=%d,MaxCwnd=%d,SndLimTimeRwin=%d,SndLimTimeCwnd=%d,SndLimTimeSender=%d,DataBytesOut=%d,SndLimTransRwin=%d,SndLimTransCwnd=%d,SndLimTransSender=%d,MaxSsthresh=%d,CurrentRTO=%d,CurrentRwinRcvd=%d,",
+        MaxRwinRcvd, Sndbuf, MaxCwnd, SndLimTimeRwin, SndLimTimeCwnd,
+        SndLimTimeSender, DataBytesOut, SndLimTransRwin,
+        SndLimTransCwnd, SndLimTransSender, MaxSsthresh, CurrentRTO,
+        CurrentRwinRcvd);
+    strlcat(logstr1, logstr2, sizeof(logstr1));
+    snprintf(
+        logstr2, sizeof(logstr2),
+        "link=%d,mismatch=%d,bad_cable=%d,half_duplex=%d,congestion=%d,c2s_linkspeed_data=%d,c2sack=%d,s2cdata=%d,s2cack=%d,CongestionSignals=%d,PktsOut=%d,MinRTT=%d,RcvWinScale=%d\n",
+        link, mismatch, bad_cable, half_duplex, congestion, c2s_linkspeed_data,
+        c2s_linkspeed_ack, s2c_linkspeed_data, s2c_linkspeed_ack, CongestionSignals, PktsOut, MinRTT,
+        RcvWinScale);
+    strncat(logstr1, logstr2, sizeof(logstr1));
+    syslog(LOG_FACILITY | LOG_INFO, "%s", logstr1);
+    closelog();
+    log_println(4, "%s", logstr1);
+  }
+
+  // close resources
+
+  if (testopt->s2copt) {
+    close(testopt->s2csockfd);
+  }
+
+  /* If the admin view is turned on then the client process is going to update these
+   * variables.  The need to be shipped back to the parent so the admin page can be
+   * updated.  Otherwise the changes are lost when the client terminates.
+   */
+  if (admin_view == 1) {
+    totalcnt = calculate(date, SumRTT, CountRTT, CongestionSignals, PktsOut,
+                         DupAcksIn, AckPktsIn, CurrentMSS, SndLimTimeRwin,
+                         SndLimTimeCwnd, SndLimTimeSender, MaxRwinRcvd, CurrentCwnd,
+                         Sndbuf, DataBytesOut, mismatch, bad_cable, (int) c2sspd,
+                         (int) s2cspd, c2s_linkspeed_data, s2c_linkspeed_ack, 1);
+    gen_html((int) c2sspd, (int) s2cspd, MinRTT, PktsRetrans, Timeouts,
+             Sndbuf, MaxRwinRcvd, CurrentCwnd, mismatch, bad_cable, totalcnt,
+             refresh);
+  }
+  shutdown(ctlsockfd, SHUT_WR);
+  /* shutdown(ctlsockfd, SHUT_RDWR); */
+  return (0);
 }
 
 /**
@@ -1480,57 +1480,57 @@ int run_test(web100_agent* agent, int ctlsockfd, TestOptions* testopt,
  * @param argv string command line arguments
  * */
 int main(int argc, char** argv) {
-	pid_t chld_pid = -1;
-	int retcode;
-	int tpid, mwaiting = 0;
-	int ctlsockfd = -1;
-	int c, chld_pipe[2];
-	int i, loopcnt, t_opts = 0;
-	struct sockaddr_storage cli_addr;
-	struct sigaction new;
-	web100_agent* agent;
-	char *lbuf = NULL, *ctime();
-	char buff[32], tmpstr[256];
-	char test_suite[16];
-	FILE * fp;
-	size_t lbuf_max = 0;
-	fd_set rfd;
-	struct timeval sel_tv;
-	struct ndtchild *tmp_ptr = NULL, *new_child = NULL, *mchild = NULL;
-	time_t tt;
-	socklen_t clilen;
-
-	I2Addr listenaddr = NULL;
-	int listenfd;
-	char* srcname = NULL;
-	char isoTime[64], dir[256];
-	int debug = 0;
-
-	int j;
-	char *name;
-
-	// variables used for protocol validation logs
-	//char startsrvmsg[256]; // used to log start of server process
-	//char *srvstatusdesc;
-	//enum PROCESS_STATUS_INT srvstatusenum = UNKNOWN;
-	//char statustemparr[PROCESS_STATUS_DESC_SIZE]; // temp storage for process name
-	enum PROCESS_TYPE_INT proctypeenum = PROCESS_TYPE;
-	enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
-
-	options.limit = 0;
-	options.snapDelay = 5;
-	options.avoidSndBlockUp = 0;
-	options.snaplog = 0;
-	options.cwndDecrease = 0;
-	memset(options.s2c_logname, 0, 256);
-	memset(options.c2s_logname, 0, 256);
-	peaks.min = -1;
-	peaks.max = -1;
-	peaks.amount = -1;
-	DataDirName = NULL;
-
-	memset(&testopt, 0, sizeof(testopt));
-	/* sigset_t newmask, oldmask; */
+  pid_t chld_pid = -1;
+  int retcode;
+  int tpid, mwaiting = 0;
+  int ctlsockfd = -1;
+  int c, chld_pipe[2];
+  int i, loopcnt, t_opts = 0;
+  struct sockaddr_storage cli_addr;
+  struct sigaction new;
+  web100_agent* agent;
+  char *lbuf = NULL, *ctime();
+  char buff[32], tmpstr[256];
+  char test_suite[16];
+  FILE * fp;
+  size_t lbuf_max = 0;
+  fd_set rfd;
+  struct timeval sel_tv;
+  struct ndtchild *tmp_ptr = NULL, *new_child = NULL, *mchild = NULL;
+  time_t tt;
+  socklen_t clilen;
+
+  I2Addr listenaddr = NULL;
+  int listenfd;
+  char* srcname = NULL;
+  char isoTime[64], dir[256];
+  int debug = 0;
+
+  int j;
+  char *name;
+
+  // variables used for protocol validation logs
+  //char startsrvmsg[256]; // used to log start of server process
+  //char *srvstatusdesc;
+  //enum PROCESS_STATUS_INT srvstatusenum = UNKNOWN;
+  //char statustemparr[PROCESS_STATUS_DESC_SIZE]; // temp storage for process name
+  enum PROCESS_TYPE_INT proctypeenum = PROCESS_TYPE;
+  enum PROCESS_STATUS_INT procstatusenum = UNKNOWN;
+
+  options.limit = 0;
+  options.snapDelay = 5;
+  options.avoidSndBlockUp = 0;
+  options.snaplog = 0;
+  options.cwndDecrease = 0;
+  memset(options.s2c_logname, 0, 256);
+  memset(options.c2s_logname, 0, 256);
+  peaks.min = -1;
+  peaks.max = -1;
+  peaks.amount = -1;
+  DataDirName = NULL;
+
+  memset(&testopt, 0, sizeof(testopt));
+  /* sigset_t newmask, oldmask; */
 
 #ifdef AF_INET6
 #define GETOPT_LONG_INET6(x) "46"x
@@ -1544,1185 +1544,1185 @@ int main(int argc, char** argv) {
 #define GETOPT_LONG_EXP(x) x
 #endif
 
-	opterr = 0;
-	while ((c =
-			getopt_long(
-					argc,
-					argv,
-					// GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:p:T:A:S:")), long_options, 0)) != -1) {
-					GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:u:e:p:T:A:S:")),
-					long_options, 0)) != -1) {
-		switch (c) {
-		case 'c':
-			ConfigFileName = optarg;
-			break;
-		case 'd':
-			debug++;
-			break;
-		}
-	}
-
-	// Initialize logging system, and then read configuration
-	log_init(argv[0], debug);
-
-	if (ConfigFileName == NULL)
-		ConfigFileName = CONFIGFILE;
-
-	// Load Config file.
-	// lbuf/lbuf_max keep track of a dynamically grown "line" buffer.
-	// (It is grown using realloc.)
-	// This will be used throughout all the config file reading and
-	// should be free'd once all config files have been read.
-
-	opterr = optind = 1;
-	LoadConfig(argv[0], &lbuf, &lbuf_max);
-	debug = 0;
-
-	// set options for test direction
-	enum Tx_DIRECTION currentDirn = S_C;
-	setCurrentDirn(currentDirn);
-	// end protocol logging
-
-	// Get server execution options
-	while ((c =
-			getopt_long(
-					argc,
-					argv,
-					// GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:p:T:A:S:")), long_options, 0)) != -1) {
-					GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:u:e:p:T:A:S:")),
-					long_options, 0)) != -1) {
-		switch (c) {
-		case '4':
-			conn_options |= OPT_IPV4_ONLY;
-			break;
-		case '6':
-			conn_options |= OPT_IPV6_ONLY;
-			break;
-		case 'r':
-			record_reverse = 1;
-			break;
-		case 'h':
-			srv_long_usage("ANL/Internet2 NDT version " VERSION " (server)");
-			break;
-		case 'v':
-			printf("ANL/Internet2 NDT version %s (server)\n", VERSION);
-			exit(0);
-			break;
-		case 'p':
-			port = optarg;
-
-			if (check_int(port, &testopt.mainport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200, "Invalid primary port number: %s",
-						optarg);
-				short_usage(argv[0], tmpText);
-			}
-			break;
-		case 302:
-			if (check_int(optarg, &testopt.midsockport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200, "Invalid Middlebox test port number: %s",
-						optarg);
-				short_usage(argv[0], tmpText);
-			}
-			break;
-		case 303:
-			if (check_int(optarg, &testopt.c2ssockport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200,
-						"Invalid C2S throughput test port number: %s", optarg);
-				short_usage(argv[0], tmpText);
-			}
-			break;
-		case 304:
-			if (check_int(optarg, &testopt.s2csockport)) {
-				char tmpText[200];
-				snprintf(tmpText, 200,
-						"Invalid S2C throughput test port number: %s", optarg);
-				short_usage(argv[0], tmpText);
-			}
-			break;
-		case 'a':
-			admin_view = 1;
-			break;
-		case 'f':
-			VarFileName = optarg;
-			break;
-		case 'i':
-			device = optarg;
-			break;
-		case 'l':
-			set_logfile(optarg);
-			break;
-		case 'u':
-			set_protologdir(optarg);
-			break;
-		case 'e':
-			log_println(7,"Enabling protocol logging");
-			enableprotocollogging();
-			break;
-		case 'o':
-			old_mismatch = 1;
-			break;
-		case 301:
-			if (mrange_parse(optarg)) {
-				char tmpText[300];
-				snprintf(tmpText, 300, "Invalid range: %s", optarg);
-				short_usage(argv[0], tmpText);
-			}
-		case 'z':
-			compress = 0;
-			break;
-		case 'm':
-			multiple = 1;
-			break;
-		case 'x':
-			max_clients = atoi(optarg);
-			break;
-		case 'q':
-			queue = 0;
-			break;
-		case 's':
-			usesyslog = 1;
-			break;
-		case 't':
-			dumptrace = 1;
-			break;
-		case 'b':
-			if (check_int(optarg, &window)) {
-				char tmpText[200];
-				snprintf(tmpText, 200, "Invalid window size: %s", optarg);
-				short_usage(argv[0], tmpText);
-			}
-			set_buff = 1;
-			break;
-		case 'd':
-			debug++;
-			break;
-		case 305:
-			options.snapDelay = atoi(optarg);
-			break;
-		case 'y':
-			options.limit = atoi(optarg);
-			break;
-		case 306:
-			options.avoidSndBlockUp = 1;
-			break;
-		case 308:
-			options.cwndDecrease = 1;
-		case 307:
-			options.snaplog = 1;
-			break;
-		case 309:
-			cputime = 1;
-			break;
-		case 310:
-			useDB = 1;
-			break;
-		case 311:
-			dbDSN = optarg;
-			break;
-		case 312:
-			dbUID = optarg;
-			break;
-		case 313:
-			dbPWD = optarg;
-			break;
-		case 'T':
-			refresh = atoi(optarg);
-			break;
-		case 'A':
-			AdminFileName = optarg;
-			break;
-		case 'L':
-			DataDirName = optarg;
-			break;
-		case 'S':
-			SysLogFacility = optarg;
-			break;
-		case '?':
-			short_usage(argv[0], "");
-			break;
-		}
-	}
-
-	if (optind < argc) {
-		short_usage(argv[0], "Unrecognized non-option elements");
-	}
-
-	if (debug > get_debuglvl()) {
-		set_debuglvl(debug);
-	}
-
-	testopt.multiple = multiple;
-
-	// First check to see if program is running as root.  If not, then warn
-	// the user that link type detection is suspect.  Then downgrade effective
-	// userid to non-root user until needed.
-
-	if (getuid() != 0) {
-		log_print(
-				0,
-				"Warning: This program must be run as root to enable the Link Type");
-		log_println(
-				0,
-				" detection algorithm.\nContinuing execution without this algorithm");
-	}
-
-	if (VarFileName == NULL) {
-		snprintf(wvfn, sizeof(wvfn), "%s/%s", BASEDIR, WEB100_FILE);
-		VarFileName = wvfn;
-	}
-
-	if (AdminFileName == NULL) {
-		snprintf(apfn, sizeof(apfn), "%s/%s", BASEDIR, ADMINFILE);
-		AdminFileName = apfn;
-	}
-
-	if (DataDirName == NULL) {
-		snprintf(logd, sizeof(logd), "%s/%s/", BASEDIR, LOGDIR);
-		DataDirName = logd;
-	} else if (DataDirName[0] != '/') {
-		snprintf(logd, sizeof(logd), "%s/%s/", BASEDIR, DataDirName);
-		DataDirName = logd;
-	}
-
-	create_protolog_dir();
-
-	if (SysLogFacility != NULL) {
-		i = 0;
-		while (facilitynames[i].c_name) {
-			if (strcmp(facilitynames[i].c_name, SysLogFacility) == 0) {
-				syslogfacility = facilitynames[i].c_val;
-				break;
-			}
-			++i;
-		}
-		if (facilitynames[i].c_name == NULL) {
-			log_println(
-					0,
-					"Warning: Unknown syslog facility [%s] --> using default (%d)",
-					SysLogFacility, syslogfacility);
-			SysLogFacility = NULL;
-		}
-	}
-
-	log_println(1, "ANL/Internet2 NDT ver %s", VERSION);
-	log_println(1, "\tVariables file = %s\n\tlog file = %s", VarFileName,
-			get_logfile());
-	if (admin_view) {
-		log_println(1, "\tAdmin file = %s", AdminFileName);
-	}
-	if (usesyslog) {
-		log_println(1, "\tSyslog facility = %s (%d)",
-				SysLogFacility ? SysLogFacility : "default", syslogfacility);
-	}
-	log_println(1, "\tDebug level set to %d", debug);
-
-	initialize_db(useDB, dbDSN, dbUID, dbPWD);
-
-	memset(&new, 0, sizeof(new));
-	new.sa_handler = cleanup;
-
-	// Grab all signals and run them through my cleanup routine.  2/24/05 */
-	// sigemptyset(&newmask);
-	// sigemptyset(&oldmask);
-	for (i = 1; i < 32; i++) {
-		if ((i == SIGKILL) || (i == SIGSTOP))
-			continue; /* these signals can't be caught */
-		sigaction(i, &new, NULL);
-		/* sigaddset(&newmask, i); */
-	}
-
-	// Bind our local address so that the client can send to us.
-
-	if (srcname && !(listenaddr = I2AddrByNode(get_errhandle(), srcname))) {
-		err_sys("server: Invalid source address specified");
-	}
-	if ((listenaddr = CreateListenSocket(listenaddr, port, conn_options,
-			((set_buff > 0) ? window : 0))) == NULL) {
-		err_sys("server: CreateListenSocket failed");
-	}
-	listenfd = I2AddrFD(listenaddr);
-
-	log_println(1, "server ready on port %s", port);
-
-	// Initialize Web100 structures
-	count_vars = web100_init(VarFileName);
-	if (count_vars == -1) {
-		log_println(0, "No web100 variables file found, terminating program");
-		exit(-5);
-	}
-
-	//   The administrator view automatically generates a usage page for the
-	//    NDT server.  This page is then accessible to the general public.
-	//    At this point read the existing log file and generate the necessary
-	//    data.  This data is then updated at the end of each test.
-	//    RAC 11/28/03
-
-	if (admin_view == 1)
-		view_init(refresh);
-
-	// Get the server's metadata info (OS name and kernel version
-	// RAC 7/7/09
-
-	if ((fp = fopen("/proc/sys/kernel/hostname", "r")) == NULL)
-		log_println(0, "Unable to determine server Hostname.");
-	else {
-		fscanf(fp, "%s", meta.server_name);
-		fclose(fp);
-	}
-	if ((fp = fopen("/proc/sys/kernel/osrelease", "r")) == NULL)
-		log_println(0, "Unable to determine server OS Version.");
-	else {
-		fscanf(fp, "%s", meta.server_os);
-		fclose(fp);
-	}
-
-	// create a log file entry every time the web100srv process starts up
-
-	ndtpid = getpid();
-	tt = time(0);
-	log_println(6, "NDT server (v%s) process [%d] started at %15.15s", VERSION,
-			ndtpid, ctime(&tt) + 4);
-	fp = fopen(get_logfile(), "a");
-	if (fp == NULL) {
-		log_println(0,
-				"Unable to open log file '%s', continuing on without logging",
-				get_logfile());
-	} else {
-		fprintf(fp, "Web100srv (ver %s) process (%d) started %15.15s\n",
-				VERSION, ndtpid, ctime(&tt) + 4);
-		fclose(fp);
-	}
-	if (usesyslog == 1)
-		syslog(LOG_FACILITY | LOG_INFO, "Web100srv (ver %s) process started",
-				VERSION);
-
-	// create protocol validation entry every time a process starts up
-	// This whole block is not needed since there are protocol log files per client
-	// and server start is not a protocol process
-	/*
-	sprintf(startsrvmsg, "Web100srv (ver %s)", VERSION);
-	srvstatusenum = PROCESS_STARTED;
-	srvstatusdesc = get_procstatusdesc(srvstatusenum, statustemparr);
-	protolog_printgeneric(srvstatusdesc, startsrvmsg);
-	*/
-
-	// scan through the interface device list and get the names/speeds of each
-	//  if.  The speed data can be used to cap the search for the bottleneck link
-	//  capacity.  The intent is to reduce the impact of interrupt coalescing on
-	//  the bottleneck link detection algorithm
-	//  RAC 7/14/09
-
-	get_iflist();
-
-	for (i = 0; iflist.speed[i] > 0; i++)
-		log_println(4, "Generated iflist with device=%s and if_speed=%d",
-				iflist.name[i], iflist.speed[i]);
-
-	// Wait at accept() for a new connection from a client process.
-
-	// These 2 flags keep track of running processes.  The 'testing' flag
-	//  indicates a test is currently being performed.  The 'waiting' counter
-	//  shows how many tests are pending.
-	//  Rich Carlson 3/11/04
-
-	options.compress = compress;
-	testing = 0;
-	mclients = 0;
-	waiting = 0;
-	loopcnt = 0;
-	head_ptr = NULL;
-	sig13 = 0;
-	sig17 = 0;
-	sig1 = 0;
-	sig2 = 0;
-	sem_init(&ndtq, 0, 1);
-
-	for (;;) {
-
-		mainloop: if (head_ptr == NULL)
-			log_println(3, "nothing in queue");
-		else
-			log_println(
-					3,
-					"Queue pointer=%d, testing=%d, waiting=%d, mclients=%d, zombie_check=%d",
-					head_ptr->pid, testing, waiting, mclients, zombie_check);
-
-		// moved condition from interrupt handler to here
-		/* if ((sig1 > 0) || (sig2 > 0))
-		 * 	check_signal_flags;
-		 */
-
-		if (sig13 == 1) {
-			log_println(5, "todo: Handle SIGPIPE signal, terminate child?");
-			child_sig(0);
-			sig13 = 0;
-		}
-
-		if (sig17 > 0) {
-			log_println(5, "Handle pending SIGCHLD signal, count=%d", sig17);
-			child_sig(0);
-		}
-
-		if ((multiple == 1) && (mclients < max_clients)
-				&& (waiting >= max_clients)) {
-			// This condition means that there are clients waiting and there are open slots
-			//   in the test queue, so dispatch another client.
-			//   RAC 12/11/09
-
-			log_println(5,
-					"Empty slot in test queue, find new client to dispatch");
-			/* tmp_ptr = head_ptr; */
-			mchild = head_ptr;
-			i = 0;
-			while (mchild != NULL) {
-				i++; // Keep count of how many times we go through this loop
-				log_println(
-						2,
-						"walking queue look for non-running client current=%d, running=%d, next=0x%x",
-						mchild->pid, mchild->running, mchild->next);
-				if (mchild->running == 0) {
-					/* mchild = tmp_ptr; */
-					log_println(
-							6,
-							"found non-running client %d, update queue and dispatch this client",
-							mchild->pid);
-					break;
-				}
-				mchild = mchild->next;
-			}
-			if (i > max_clients) {
-				log_println(6,
-						"walked through running client list, no empty slots!");
-				continue;
-			}
-
-			/* if ((mchild->next == NULL) && (mchild->running == 0))
-			 *   mchild = tmp_ptr;
-			 * if (mchild != head_ptr) {
-			 */
-			tmp_ptr = mchild;
-
-			// Update queued clients, send message to client when it moves
-			//  up in the queue enough to get closer to running a test.  This happens
-			//  when the client falls into the next lower maxqueue bin
-			//  RAC 3/21/10
-
-			int rac;
-			if (waiting > (2 * max_clients)) {
-				for (i = max_clients; i <= waiting; i++) {
-					if (tmp_ptr == NULL)
-						break;
-					if (i == (2 * max_clients)) {
-						rac = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, "1", 1);
-						log_println(
-								6,
-								"sent 45 sec update message to client %d on fd=%d, send_msg() returned %d",
-								tmp_ptr->pid, tmp_ptr->ctlsockfd, rac);
-					}
-					if (i == (3 * max_clients)) {
-						rac = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, "2", 1);
-						log_println(
-								6,
-								"sent 90 sec update message to client %d on fd=%d, send_msg() returned %d",
-								tmp_ptr->pid, tmp_ptr->ctlsockfd, rac);
-					}
-					tmp_ptr = tmp_ptr->next;
-				}
-			}
-			goto dispatch_client;
-		}
-
-		if ((waiting < 0) || (mclients < 0)) {
-			log_println(
-					6,
-					"Fault: Negative number of clents waiting=%d, mclients=%d, nuke them",
-					waiting, mclients);
-			while (head_ptr != NULL) {
-				/* send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9933", 4); */
-				send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4); // indicate server waiting in queue
-				shutdown(head_ptr->ctlsockfd, SHUT_WR);
-				close(head_ptr->ctlsockfd);
-				tpid = head_ptr->pid;
-				child_sig(-1);
-				kill(tpid, SIGTERM);
-				child_sig(tpid);
-			}
-			waiting = 0;
-			mclients = 0;
-			continue;
-		}
-
-		if ((waiting == 0) && (head_ptr != NULL)) {
-			log_println(6,
-					"Fault: Something [%d] in queue, but no waiting clients",
-					head_ptr->pid);
-			while (head_ptr != NULL) {
-				/* send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9977", 4); */
-				send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4);
-				shutdown(head_ptr->ctlsockfd, SHUT_WR);
-				close(head_ptr->ctlsockfd);
-				tpid = head_ptr->pid;
-				child_sig(-1);
-				kill(tpid, SIGTERM);
-				child_sig(tpid);
-			}
-			waiting = 0;
-			mclients = 0;
-			continue;
-		}
-
-		if (head_ptr != NULL) {
-			if ((time(0) - head_ptr->stime) > 70) { // 70 => WAIT-TIME-THRESH
-				log_println(
-						6,
-						"Fault: Something in queue, but child %d (fd=%d) has exceeded wait time",
-						head_ptr->pid, head_ptr->ctlsockfd);
-				// Should send new 9977 'test aborted' signal to client.  Using this for now
-				// rac 3/26/10
-
-				log_println(6,
-						"pid=%d, client='%s', stime=%ld, qtime=%ld now=%ld",
-						head_ptr->pid, head_ptr->addr, head_ptr->stime,
-						head_ptr->qtime, time(0));
-				log_println(
-						6,
-						"pipe-fd=%d, running=%d, ctlsockfd=%d, client-type=%d, tests='%s'",
-						head_ptr->pipe, head_ptr->running, head_ptr->ctlsockfd,
-						head_ptr->oldclient, head_ptr->tests);
-				send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4); // boot the client
-				shutdown(head_ptr->ctlsockfd, SHUT_WR);
-				close(head_ptr->ctlsockfd);
-				tpid = head_ptr->pid;
-				child_sig(-1);
-				kill(tpid, SIGTERM);
-				child_sig(tpid);
-				continue;
-			}
-		}
-
-		if ((multiple == 1) && (mclients > waiting)) {
-			log_println(
-					5,
-					"Multi-client mode has uncaught terminated clients mclient=%d, waiting=%d",
-					mclients, waiting);
-			while (mclients > waiting) {
-				child_sig(0);
-				mclients--;
-				log_println(5,
-						"Removed terminated client from count mclients=%d",
-						mclients);
-			}
-		}
-
-		FD_ZERO(&rfd);
-		FD_SET(listenfd, &rfd);
-		if (waiting > 0) { // there are clients waiting
-			sel_tv.tv_sec = 3; // 3 seconds == WAIT_TIME_SRVR
-			sel_tv.tv_usec = 0;
-			log_println(3, "Waiting for new connection, timer running");
-			sel_11: retcode = select(listenfd + 1, &rfd, NULL, NULL, &sel_tv);
-			if ((retcode == -1) && (errno == EINTR))
-				/* continue; */ // a signal caused the select() to exit, re-enter loop & check
-				goto sel_11;
-			tt = time(0);
-
-		} else {
-			// Nothing is in the queue, so wait forever until a new connection request arrives
-			log_println(3, "Timer not running, waiting for new connection");
-			mclients = 0;
-			sel_12: retcode = select(listenfd + 1, &rfd, NULL, NULL, NULL);
-			if ((retcode == -1) && (errno == EINTR))
-				goto sel_12;
-			// a signal caused the select() to exit, re-enter loop & check
-		}
-
-		if (retcode < 0) {
-			// an interrupt or signal caused the select() to exit, go back and start over
-			log_println(5, "Select exited with return code = %d", retcode);
-			continue;
-		}
-
-		if (retcode == 0) { // select exited due to timer expiration
-			log_println(3, "Timer expired while waiting for a new connection");
-			/* if ((waiting > 0) && (testing == 0)) */
-			if (multiple == 0) {
-				if ((waiting > 0) && (testing == 0))
-					goto ChldRdy;
-				continue;
-			} else {
-				if (waiting > 0)
-					goto ChldRdy;
-				continue;
-			}
-		} else {
-			log_println(
-					3,
-					"New connection received, waiting for accept() to complete");
-			if ((waiting > 0) && (testing == 0)) // no clients waiting, no test in progress
-				goto ChldRdy;
-			/* } */
-			clilen = sizeof(cli_addr);
-			memset(&cli_addr, 0, clilen);
-			log_println(6, "Select() found %d clients ready, highest fd=%d",
-					retcode, listenfd);
-			if (retcode > 1) {
-				for (i = 3; i <= listenfd; i++) {
-					if (FD_ISSET(i, &rfd)) {
-						listenfd = i;
-						break;
-					}
-				}
-			}
-			for (i = 0; i < RETRY_COUNT; i++) {
-				ctlsockfd = 0;
-				ctlsockfd = accept(listenfd, (struct sockaddr *) &cli_addr,
-						&clilen);
-
-				if ((ctlsockfd == -1) && (errno == EINTR)) // socket interrupted, retry
-					continue; // sig child
-				size_t tmpstrlen = sizeof(tmpstr);
-				memset(tmpstr, 0, tmpstrlen);
-				// get addr details based on socket info available
-				I2Addr tmp_addr = I2AddrBySockFD(get_errhandle(), ctlsockfd,
-						False);
-				I2AddrNodeName(tmp_addr, tmpstr, &tmpstrlen);
-				/* I2AddrFree(tmp_addr); */
-				log_println(4,
-						"New connection received from 0x%x [%s] sockfd=%d.",
-						tmp_addr, tmpstr, ctlsockfd);
-
-				break;
-			}
-
-			// verify that accept really worked and don't process connections that've failed
-			// RAC 2/11/10
-			if (ctlsockfd <= 0) {
-				log_println(4,
-						"New connection request failed sockfd=%d reason-%d.",
-						ctlsockfd, errno);
-				continue;
-			} else { // accept worked, log protocol validation log to indicate that client tried connecting
-				procstatusenum = PROCESS_STARTED;
-				proctypeenum = CONNECT_TYPE;
-				protolog_procstatus(getpid(), getCurrentTest(), proctypeenum,
-						procstatusenum, ctlsockfd );
-			}
-
-			// the specially crafted data that kicks off the old clients
-			for (i = 0; i < RETRY_COUNT; i++) {
-				retcode = write(ctlsockfd, "123456 654321", 13);
-				if ((retcode == -1) && (errno == EINTR)) // interrupted, retry
-					continue;
-				if (retcode == 13) // 13 bytes correctly written, exit
-					break;
-				if (retcode == -1) { // socket error hindering further retries
-					log_println(1,
-							"Initial contact with client failed errno=%d",
-							errno);
-					close(chld_pipe[0]);
-					close(chld_pipe[1]);
-					shutdown(ctlsockfd, SHUT_WR);
-					close(ctlsockfd);
-					goto mainloop;
-				}
-
-				log_println(6, "xxx, calling initialize_tests()");
-				t_opts = initialize_tests(ctlsockfd, &testopt, test_suite, sizeof(test_suite));
-
-				if (t_opts < 1) {
-					log_println(
-							3,
-							"Invalid test suite string '%s' received, terminate child",
-							test_suite);
-					close(chld_pipe[0]);
-					close(chld_pipe[1]);
-					shutdown(ctlsockfd, SHUT_WR);
-					close(ctlsockfd);
-
-					/* todo: handle other error contitions */
-				}
-			}
-			new_child = (struct ndtchild *) malloc(sizeof(struct ndtchild));
-			memset(new_child, 0, sizeof(struct ndtchild));
-			tt = time(0);
-			name = tmpstr;
-
-			rmt_host = tmpstr;
-
-			// At this point we have received a connection from a client, meaning that
-			//  a test is being requested.  At this point we should apply any policy
-			//  or AAA functions to the incoming connection.  If we don't like the
-			//  client, we can refuse the connection and loop back to the begining.
-			//  There would need to be some additional logic installed if this AAA
-			//  test relied on more than the client's IP address.  The client would
-			//  also require modification to allow more credentials to be created/passed
-			//  between the user and this application.
-
-		}
-
-		if (pipe(chld_pipe) == -1)
-			log_println(6, "pipe() failed errno=%d", errno);
-		chld_pid = fork();
-
-		switch (chld_pid) {
-		case -1: /* an error occured, log it and quit */
-			log_println(0, "fork() failed, errno = %d", errno);
-			/* todo: handle error and continue */
-			break;
-		default: // this is the parent process, handle scheduling and
-				 // queuing of multiple incoming clients
-
-			log_println(5, "Parent process spawned child = %d", chld_pid);
-			log_println(5, "Parent thinks pipe() returned fd0=%d, fd1=%d",
-					chld_pipe[0], chld_pipe[1]);
-
-			close(chld_pipe[0]);
-
-			// Check to see if we have more than max_clients waiting in the queue
-			//  If so, tell them to go away.
-			//  changed for M-Lab deployment  1/28/09  RAC
-
-			if (((multiple == 0) && (waiting >= (max_clients - 1)))
-					|| ((multiple == 1) && (waiting >= ((4 * max_clients) - 1)))) {
-				log_println(
-						0,
-						"Too many clients/mclients (%d) waiting to be served, Please try again later.",
-						chld_pid);
-				snprintf(tmpstr, sizeof(tmpstr), "9988"); // 9988 = server_BUSY_OR_ERROR
-				send_msg(ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
-				close(chld_pipe[0]);
-				close(chld_pipe[1]);
-				shutdown(ctlsockfd, SHUT_WR);
-				close(ctlsockfd);
-				kill(chld_pid, SIGTERM);
-				if (new_child != NULL) {
-					log_println(6, "Too many clients freeing child=0x%x",
-							new_child);
-					free(new_child);
-				}
-				continue;
-			}
-
-			t_opts = initialize_tests(ctlsockfd, &testopt, test_suite, sizeof(test_suite));
-			if (t_opts < 1) { // some error in initialization routines
-				log_println(
-						3,
-						"Invalid test suite string '%s' received, terminate child",
-						test_suite);
-				close(chld_pipe[0]);
-				close(chld_pipe[1]);
-				shutdown(ctlsockfd, SHUT_WR);
-				close(ctlsockfd);
-				kill(chld_pid, SIGTERM);
-				if (new_child != NULL) {
-					log_println(6, "invalid test suite, freeing new_child=0x%x",
-							new_child);
-					free(new_child);
-				}
-				continue;
-			}
-			while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) { // socket interrupt, retry
-				log_println(6, "Waiting for ndtq semaphore to free - 1");
-				continue;
-			}
-			log_println(6, "creating new child - semaphore locked");
-			/*sigprocmask(SIG_BLOCK, &newmask, &oldmask); */
-			new_child->pid = chld_pid;
-			/* strncpy(new_child->addr, rmt_host, strlen(rmt_host));
-			 strncpy(new_child->host, name, strlen(name));*/
-			strlcpy(new_child->addr, rmt_host, sizeof(new_child->addr));
-			strlcpy(new_child->host, name, sizeof(new_child->host));
-
-			// compute start time based in the number of waiting clients
-			// set other properties on this child process
-			if (multiple == 0)
-				new_child->stime = tt + (waiting * 45);
-			else
-				new_child->stime = tt + ((waiting / max_clients) * 45);
-			new_child->qtime = tt;
-			new_child->pipe = chld_pipe[1];
-			new_child->running = 0;
-			new_child->ctlsockfd = ctlsockfd;
-			if (t_opts & TEST_STATUS
-				)
-				new_child->oldclient = 1;
-			else
-				new_child->oldclient = 0;
-			memset(new_child->tests, 0, sizeof(test_suite));
-			memcpy(new_child->tests, test_suite, strlen(test_suite));
-			new_child->next = NULL;
-			/* sigprocmask(SIG_SETMASK, &oldmask, NULL); */
-			sem_post(&ndtq);
-			log_println(6, "Free'd ndtq semaphore lock - 1");
-			if (multiple == 1)
-				mwaiting++;
-			mchild = new_child;
-
-			log_println(
-					3,
-					"initialize_tests returned old/new client = %d, test_suite = %s",
-					new_child->oldclient, new_child->tests);
-
-			close(chld_pipe[0]);
-
-			if ((testing == 1) && (queue == 0)) {
-				log_println(
-						3,
-						"queuing disabled and testing in progress, tell client no");
-				/* send_msg(new_child->ctlsockfd, SRV_QUEUE, "9944", 4); */
-				send_msg(new_child->ctlsockfd, SRV_QUEUE, "9988", 4);
-				close(chld_pipe[1]);
-				shutdown(new_child->ctlsockfd, SHUT_WR);
-				close(new_child->ctlsockfd);
-				log_println(6, "no queuing, free new_child=0x%x", new_child);
-				free(new_child);
-				continue;
-			}
-
-			waiting++; // new client has arrived and is queue-able. increment waiting
-			log_println(5, "Incrementing waiting variable now = %d", waiting);
-			if (head_ptr == NULL)
-				head_ptr = new_child;
-			else {
-				log_println(
-						4,
-						"New request has arrived, adding request to queue list");
-				while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
-					log_println(
-							6,
-							"Waiting for ndtq semaphore to free, adding new client 2");
-					continue;
-				}
-				log_println(6,
-						"Adding new client to fifo queue - semaphore locked");
-				tmp_ptr = head_ptr;
-				while (tmp_ptr->next != NULL)
-					tmp_ptr = tmp_ptr->next;
-				tmp_ptr->next = new_child;
-				sem_post(&ndtq);
-				log_println(6, "Free'd ndtq semaphore lock - 2");
-
-				if (get_debuglvl() > 3) {
-					log_println(4, "Walking scheduling queue");
-					tmp_ptr = head_ptr;
-					while (tmp_ptr != NULL) {
-						log_println(4, "\tChild %d, host: %s [%s], next=0x%x",
-								tmp_ptr->pid, tmp_ptr->host, tmp_ptr->addr,
-								(u_int64_t) tmp_ptr->next);
-						if (tmp_ptr->next == NULL)
-							break;
-						tmp_ptr = tmp_ptr->next;
-					}
-				}
-			}
-
-			// At this point send a message to the client via the ctlsockfd
-			//  saying that N clients are waiting in the queue & testing will
-			//   begin within Nx60 seconds.  Only if (waiting > 0)
-			//    Clients who leave will be handled in the run_test routine.
-
-			if ((multiple == 0) && (waiting > 1)) {
-				log_println(
-						3,
-						"%d clients waiting, telling client (%d) testing will begin within %d minutes",
-						(waiting - 1), tmp_ptr->pid, (waiting-1));
-						snprintf(tmpstr, sizeof(tmpstr), "%d", (waiting-1));
-						send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
-	  continue;
-        }
+  opterr = 0;
+  while ((c =
+          getopt_long(
+              argc,
+              argv,
+              // GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:p:T:A:S:")), long_options, 0)) != -1) {
+              GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:u:e:p:T:A:S:")),
+              long_options, 0)) != -1) {
+                switch (c) {
+                  case 'c':
+                    ConfigFileName = optarg;
+                    break;
+                  case 'd':
+                    debug++;
+                    break;
+                }
+              }
+
+  // Initialize logging system, and then read configuration
+  log_init(argv[0], debug);
+
+  if (ConfigFileName == NULL)
+    ConfigFileName = CONFIGFILE;
+
+  // Load Config file.
+  // lbuf/lbuf_max keep track of a dynamically grown "line" buffer.
+  // (It is grown using realloc.)
+  // This will be used throughout all the config file reading and
+  // should be free'd once all config files have been read.
+
+  opterr = optind = 1;
+  LoadConfig(argv[0], &lbuf, &lbuf_max);
+  debug = 0;
+
+  // set options for test direction
+  enum Tx_DIRECTION currentDirn = S_C;
+  setCurrentDirn(currentDirn);
+  // end protocol logging
+
+  // Get server execution options
+  while ((c =
+          getopt_long(
+              argc,
+              argv,
+              // GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:p:T:A:S:")), long_options, 0)) != -1) {
+              GETOPT_LONG_INET6(GETOPT_LONG_EXP("adhmoqrstvzc:x:b:f:i:l:u:e:p:T:A:S:")),
+              long_options, 0)) != -1) {
+                switch (c) {
+                  case '4':
+                    conn_options |= OPT_IPV4_ONLY;
+                    break;
+                  case '6':
+                    conn_options |= OPT_IPV6_ONLY;
+                    break;
+                  case 'r':
+                    record_reverse = 1;
+                    break;
+                  case 'h':
+                    srv_long_usage("ANL/Internet2 NDT version " VERSION " (server)");
+                    break;
+                  case 'v':
+                    printf("ANL/Internet2 NDT version %s (server)\n", VERSION);
+                    exit(0);
+                    break;
+                  case 'p':
+                    port = optarg;
+
+                    if (check_int(port, &testopt.mainport)) {
+                      char tmpText[200];
+                      snprintf(tmpText, 200, "Invalid primary port number: %s",
+                               optarg);
+                      short_usage(argv[0], tmpText);
+                    }
+                    break;
+                  case 302:
+                    if (check_int(optarg, &testopt.midsockport)) {
+                      char tmpText[200];
+                      snprintf(tmpText, 200, "Invalid Middlebox test port number: %s",
+                               optarg);
+                      short_usage(argv[0], tmpText);
+                    }
+                    break;
+                  case 303:
+                    if (check_int(optarg, &testopt.c2ssockport)) {
+                      char tmpText[200];
+                      snprintf(tmpText, 200,
+                               "Invalid C2S throughput test port number: %s", optarg);
+                      short_usage(argv[0], tmpText);
+                    }
+                    break;
+                  case 304:
+                    if (check_int(optarg, &testopt.s2csockport)) {
+                      char tmpText[200];
+                      snprintf(tmpText, 200,
+                               "Invalid S2C throughput test port number: %s", optarg);
+                      short_usage(argv[0], tmpText);
+                    }
+                    break;
+                  case 'a':
+                    admin_view = 1;
+                    break;
+                  case 'f':
+                    VarFileName = optarg;
+                    break;
+                  case 'i':
+                    device = optarg;
+                    break;
+                  case 'l':
+                    set_logfile(optarg);
+                    break;
+                  case 'u':
+                    set_protologdir(optarg);
+                    break;
+                  case 'e':
+                    log_println(7,"Enabling protocol logging");
+                    enableprotocollogging();
+                    break;
+                  case 'o':
+                    old_mismatch = 1;
+                    break;
+                  case 301:
+                    if (mrange_parse(optarg)) {
+                      char tmpText[300];
+                      snprintf(tmpText, 300, "Invalid range: %s", optarg);
+                      short_usage(argv[0], tmpText);
+                    }
+                  case 'z':
+                    compress = 0;
+                    break;
+                  case 'm':
+                    multiple = 1;
+                    break;
+                  case 'x':
+                    max_clients = atoi(optarg);
+                    break;
+                  case 'q':
+                    queue = 0;
+                    break;
+                  case 's':
+                    usesyslog = 1;
+                    break;
+                  case 't':
+                    dumptrace = 1;
+                    break;
+                  case 'b':
+                    if (check_int(optarg, &window)) {
+                      char tmpText[200];
+                      snprintf(tmpText, 200, "Invalid window size: %s", optarg);
+                      short_usage(argv[0], tmpText);
+                    }
+                    set_buff = 1;
+                    break;
+                  case 'd':
+                    debug++;
+                    break;
+                  case 305:
+                    options.snapDelay = atoi(optarg);
+                    break;
+                  case 'y':
+                    options.limit = atoi(optarg);
+                    break;
+                  case 306:
+                    options.avoidSndBlockUp = 1;
+                    break;
+                  case 308:
+                    options.cwndDecrease = 1;
+                  case 307:
+                    options.snaplog = 1;
+                    break;
+                  case 309:
+                    cputime = 1;
+                    break;
+                  case 310:
+                    useDB = 1;
+                    break;
+                  case 311:
+                    dbDSN = optarg;
+                    break;
+                  case 312:
+                    dbUID = optarg;
+                    break;
+                  case 313:
+                    dbPWD = optarg;
+                    break;
+                  case 'T':
+                    refresh = atoi(optarg);
+                    break;
+                  case 'A':
+                    AdminFileName = optarg;
+                    break;
+                  case 'L':
+                    DataDirName = optarg;
+                    break;
+                  case 'S':
+                    SysLogFacility = optarg;
+                    break;
+                  case '?':
+                    short_usage(argv[0], "");
+                    break;
+                }
+              }
+
+  if (optind < argc) {
+    short_usage(argv[0], "Unrecognized non-option elements");
+  }
+
+  if (debug > get_debuglvl()) {
+    set_debuglvl(debug);
+  }
+
+  testopt.multiple = multiple;
+
+  // First check to see if program is running as root.  If not, then warn
+  // the user that link type detection is suspect.  Then downgrade effective
+  // userid to non-root user until needed.
+
+  if (getuid() != 0) {
+    log_print(
+        0,
+        "Warning: This program must be run as root to enable the Link Type");
+    log_println(
+        0,
+        " detection algorithm.\nContinuing execution without this algorithm");
+  }
+
+  if (VarFileName == NULL) {
+    snprintf(wvfn, sizeof(wvfn), "%s/%s", BASEDIR, WEB100_FILE);
+    VarFileName = wvfn;
+  }
+
+  if (AdminFileName == NULL) {
+    snprintf(apfn, sizeof(apfn), "%s/%s", BASEDIR, ADMINFILE);
+    AdminFileName = apfn;
+  }
+
+  if (DataDirName == NULL) {
+    snprintf(logd, sizeof(logd), "%s/%s/", BASEDIR, LOGDIR);
+    DataDirName = logd;
+  } else if (DataDirName[0] != '/') {
+    snprintf(logd, sizeof(logd), "%s/%s/", BASEDIR, DataDirName);
+    DataDirName = logd;
+  }
+
+  create_protolog_dir();
+
+  if (SysLogFacility != NULL) {
+    i = 0;
+    while (facilitynames[i].c_name) {
+      if (strcmp(facilitynames[i].c_name, SysLogFacility) == 0) {
+        syslogfacility = facilitynames[i].c_val;
+        break;
+      }
+      ++i;
+    }
+    if (facilitynames[i].c_name == NULL) {
+      log_println(
+          0,
+          "Warning: Unknown syslog facility [%s] --> using default (%d)",
+          SysLogFacility, syslogfacility);
+      SysLogFacility = NULL;
+    }
+  }
+
+  log_println(1, "ANL/Internet2 NDT ver %s", VERSION);
+  log_println(1, "\tVariables file = %s\n\tlog file = %s", VarFileName,
+              get_logfile());
+  if (admin_view) {
+    log_println(1, "\tAdmin file = %s", AdminFileName);
+  }
+  if (usesyslog) {
+    log_println(1, "\tSyslog facility = %s (%d)",
+                SysLogFacility ? SysLogFacility : "default", syslogfacility);
+  }
+  log_println(1, "\tDebug level set to %d", debug);
+
+  initialize_db(useDB, dbDSN, dbUID, dbPWD);
+
+  memset(&new, 0, sizeof(new));
+  new.sa_handler = cleanup;
+
+  // Grab all signals and run them through my cleanup routine.  2/24/05 */
+  // sigemptyset(&newmask);
+  // sigemptyset(&oldmask);
+  for (i = 1; i < 32; i++) {
+    if ((i == SIGKILL) || (i == SIGSTOP))
+      continue; /* these signals can't be caught */
+    sigaction(i, &new, NULL);
+    /* sigaddset(&newmask, i); */
+  }
+
+  // Bind our local address so that the client can send to us.
+
+  if (srcname && !(listenaddr = I2AddrByNode(get_errhandle(), srcname))) {
+    err_sys("server: Invalid source address specified");
+  }
+  if ((listenaddr = CreateListenSocket(listenaddr, port, conn_options,
+                                       ((set_buff > 0) ? window : 0))) == NULL) {
+    err_sys("server: CreateListenSocket failed");
+  }
+  listenfd = I2AddrFD(listenaddr);
+
+  log_println(1, "server ready on port %s", port);
+
+  // Initialize Web100 structures
+  count_vars = web100_init(VarFileName);
+  if (count_vars == -1) {
+    log_println(0, "No web100 variables file found, terminating program");
+    exit(-5);
+  }
+
+  //   The administrator view automatically generates a usage page for the
+  //    NDT server.  This page is then accessible to the general public.
+  //    At this point read the existing log file and generate the necessary
+  //    data.  This data is then updated at the end of each test.
+  //    RAC 11/28/03
+
+  if (admin_view == 1)
+    view_init(refresh);
+
+  // Get the server's metadata info (OS name and kernel version
+  // RAC 7/7/09
+
+  if ((fp = fopen("/proc/sys/kernel/hostname", "r")) == NULL)
+    log_println(0, "Unable to determine server Hostname.");
+  else {
+    fscanf(fp, "%s", meta.server_name);
+    fclose(fp);
+  }
+  if ((fp = fopen("/proc/sys/kernel/osrelease", "r")) == NULL)
+    log_println(0, "Unable to determine server OS Version.");
+  else {
+    fscanf(fp, "%s", meta.server_os);
+    fclose(fp);
+  }
+
+  // create a log file entry every time the web100srv process starts up
+
+  ndtpid = getpid();
+  tt = time(0);
+  log_println(6, "NDT server (v%s) process [%d] started at %15.15s", VERSION,
+              ndtpid, ctime(&tt) + 4);
+  fp = fopen(get_logfile(), "a");
+  if (fp == NULL) {
+    log_println(0,
+                "Unable to open log file '%s', continuing on without logging",
+                get_logfile());
+  } else {
+    fprintf(fp, "Web100srv (ver %s) process (%d) started %15.15s\n",
+            VERSION, ndtpid, ctime(&tt) + 4);
+    fclose(fp);
+  }
+  if (usesyslog == 1)
+    syslog(LOG_FACILITY | LOG_INFO, "Web100srv (ver %s) process started",
+           VERSION);
+
+  // create protocol validation entry every time a process starts up
+  // This whole block is not needed since there are protocol log files per client
+  // and server start is not a protocol process
+  /*
+     sprintf(startsrvmsg, "Web100srv (ver %s)", VERSION);
+     srvstatusenum = PROCESS_STARTED;
+     srvstatusdesc = get_procstatusdesc(srvstatusenum, statustemparr);
+     protolog_printgeneric(srvstatusdesc, startsrvmsg);
+     */
+
+  // scan through the interface device list and get the names/speeds of each
+  //  if.  The speed data can be used to cap the search for the bottleneck link
+  //  capacity.  The intent is to reduce the impact of interrupt coalescing on
+  //  the bottleneck link detection algorithm
+  //  RAC 7/14/09
+
+  get_iflist();
+
+  for (i = 0; iflist.speed[i] > 0; i++)
+    log_println(4, "Generated iflist with device=%s and if_speed=%d",
+                iflist.name[i], iflist.speed[i]);
+
+  // Wait at accept() for a new connection from a client process.
+
+  // These 2 flags keep track of running processes.  The 'testing' flag
+  //  indicates a test is currently being performed.  The 'waiting' counter
+  //  shows how many tests are pending.
+  //  Rich Carlson 3/11/04
+
+  options.compress = compress;
+  testing = 0;
+  mclients = 0;
+  waiting = 0;
+  loopcnt = 0;
+  head_ptr = NULL;
+  sig13 = 0;
+  sig17 = 0;
+  sig1 = 0;
+  sig2 = 0;
+  sem_init(&ndtq, 0, 1);
+
+  for (;;) {
+
+mainloop: if (head_ptr == NULL)
+            log_println(3, "nothing in queue");
+          else
+            log_println(
+                3,
+                "Queue pointer=%d, testing=%d, waiting=%d, mclients=%d, zombie_check=%d",
+                head_ptr->pid, testing, waiting, mclients, zombie_check);
+
+          // moved condition from interrupt handler to here
+          /* if ((sig1 > 0) || (sig2 > 0))
+           * 	check_signal_flags;
+           */
+
+          if (sig13 == 1) {
+            log_println(5, "todo: Handle SIGPIPE signal, terminate child?");
+            child_sig(0);
+            sig13 = 0;
+          }
+
+          if (sig17 > 0) {
+            log_println(5, "Handle pending SIGCHLD signal, count=%d", sig17);
+            child_sig(0);
+          }
+
+          if ((multiple == 1) && (mclients < max_clients)
+              && (waiting >= max_clients)) {
+            // This condition means that there are clients waiting and there are open slots
+            //   in the test queue, so dispatch another client.
+            //   RAC 12/11/09
+
+            log_println(5,
+                        "Empty slot in test queue, find new client to dispatch");
+            /* tmp_ptr = head_ptr; */
+            mchild = head_ptr;
+            i = 0;
+            while (mchild != NULL) {
+              i++; // Keep count of how many times we go through this loop
+              log_println(
+                  2,
+                  "walking queue look for non-running client current=%d, running=%d, next=0x%x",
+                  mchild->pid, mchild->running, mchild->next);
+              if (mchild->running == 0) {
+                /* mchild = tmp_ptr; */
+                log_println(
+                    6,
+                    "found non-running client %d, update queue and dispatch this client",
+                    mchild->pid);
+                break;
+              }
+              mchild = mchild->next;
+            }
+            if (i > max_clients) {
+              log_println(6,
+                          "walked through running client list, no empty slots!");
+              continue;
+            }
+
+            /* if ((mchild->next == NULL) && (mchild->running == 0))
+             *   mchild = tmp_ptr;
+             * if (mchild != head_ptr) {
+             */
+            tmp_ptr = mchild;
+
+            // Update queued clients, send message to client when it moves
+            //  up in the queue enough to get closer to running a test.  This happens
+            //  when the client falls into the next lower maxqueue bin
+            //  RAC 3/21/10
+
+            int rac;
+            if (waiting > (2 * max_clients)) {
+              for (i = max_clients; i <= waiting; i++) {
+                if (tmp_ptr == NULL)
+                  break;
+                if (i == (2 * max_clients)) {
+                  rac = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, "1", 1);
+                  log_println(
+                      6,
+                      "sent 45 sec update message to client %d on fd=%d, send_msg() returned %d",
+                      tmp_ptr->pid, tmp_ptr->ctlsockfd, rac);
+                }
+                if (i == (3 * max_clients)) {
+                  rac = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, "2", 1);
+                  log_println(
+                      6,
+                      "sent 90 sec update message to client %d on fd=%d, send_msg() returned %d",
+                      tmp_ptr->pid, tmp_ptr->ctlsockfd, rac);
+                }
+                tmp_ptr = tmp_ptr->next;
+              }
+            }
+            goto dispatch_client;
+          }
+
+          if ((waiting < 0) || (mclients < 0)) {
+            log_println(
+                6,
+                "Fault: Negative number of clents waiting=%d, mclients=%d, nuke them",
+                waiting, mclients);
+            while (head_ptr != NULL) {
+              /* send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9933", 4); */
+              send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4); // indicate server waiting in queue
+              shutdown(head_ptr->ctlsockfd, SHUT_WR);
+              close(head_ptr->ctlsockfd);
+              tpid = head_ptr->pid;
+              child_sig(-1);
+              kill(tpid, SIGTERM);
+              child_sig(tpid);
+            }
+            waiting = 0;
+            mclients = 0;
+            continue;
+          }
+
+          if ((waiting == 0) && (head_ptr != NULL)) {
+            log_println(6,
+                        "Fault: Something [%d] in queue, but no waiting clients",
+                        head_ptr->pid);
+            while (head_ptr != NULL) {
+              /* send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9977", 4); */
+              send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4);
+              shutdown(head_ptr->ctlsockfd, SHUT_WR);
+              close(head_ptr->ctlsockfd);
+              tpid = head_ptr->pid;
+              child_sig(-1);
+              kill(tpid, SIGTERM);
+              child_sig(tpid);
+            }
+            waiting = 0;
+            mclients = 0;
+            continue;
+          }
+
+          if (head_ptr != NULL) {
+            if ((time(0) - head_ptr->stime) > 70) { // 70 => WAIT-TIME-THRESH
+              log_println(
+                  6,
+                  "Fault: Something in queue, but child %d (fd=%d) has exceeded wait time",
+                  head_ptr->pid, head_ptr->ctlsockfd);
+              // Should send new 9977 'test aborted' signal to client.  Using this for now
+              // rac 3/26/10
+
+              log_println(6,
+                          "pid=%d, client='%s', stime=%ld, qtime=%ld now=%ld",
+                          head_ptr->pid, head_ptr->addr, head_ptr->stime,
+                          head_ptr->qtime, time(0));
+              log_println(
+                  6,
+                  "pipe-fd=%d, running=%d, ctlsockfd=%d, client-type=%d, tests='%s'",
+                  head_ptr->pipe, head_ptr->running, head_ptr->ctlsockfd,
+                  head_ptr->oldclient, head_ptr->tests);
+              send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4); // boot the client
+              shutdown(head_ptr->ctlsockfd, SHUT_WR);
+              close(head_ptr->ctlsockfd);
+              tpid = head_ptr->pid;
+              child_sig(-1);
+              kill(tpid, SIGTERM);
+              child_sig(tpid);
+              continue;
+            }
+          }
+
+          if ((multiple == 1) && (mclients > waiting)) {
+            log_println(
+                5,
+                "Multi-client mode has uncaught terminated clients mclient=%d, waiting=%d",
+                mclients, waiting);
+            while (mclients > waiting) {
+              child_sig(0);
+              mclients--;
+              log_println(5,
+                          "Removed terminated client from count mclients=%d",
+                          mclients);
+            }
+          }
+
+          FD_ZERO(&rfd);
+          FD_SET(listenfd, &rfd);
+          if (waiting > 0) { // there are clients waiting
+            sel_tv.tv_sec = 3; // 3 seconds == WAIT_TIME_SRVR
+            sel_tv.tv_usec = 0;
+            log_println(3, "Waiting for new connection, timer running");
+sel_11: retcode = select(listenfd + 1, &rfd, NULL, NULL, &sel_tv);
+        if ((retcode == -1) && (errno == EINTR))
+          /* continue; */ // a signal caused the select() to exit, re-enter loop & check
+          goto sel_11;
+        tt = time(0);
+
+          } else {
+            // Nothing is in the queue, so wait forever until a new connection request arrives
+            log_println(3, "Timer not running, waiting for new connection");
+            mclients = 0;
+sel_12: retcode = select(listenfd + 1, &rfd, NULL, NULL, NULL);
+        if ((retcode == -1) && (errno == EINTR))
+          goto sel_12;
+        // a signal caused the select() to exit, re-enter loop & check
+          }
+
+          if (retcode < 0) {
+            // an interrupt or signal caused the select() to exit, go back and start over
+            log_println(5, "Select exited with return code = %d", retcode);
+            continue;
+          }
+
+          if (retcode == 0) { // select exited due to timer expiration
+            log_println(3, "Timer expired while waiting for a new connection");
+            /* if ((waiting > 0) && (testing == 0)) */
+            if (multiple == 0) {
+              if ((waiting > 0) && (testing == 0))
+                goto ChldRdy;
+              continue;
+            } else {
+              if (waiting > 0)
+                goto ChldRdy;
+              continue;
+            }
+          } else {
+            log_println(
+                3,
+                "New connection received, waiting for accept() to complete");
+            if ((waiting > 0) && (testing == 0)) // no clients waiting, no test in progress
+              goto ChldRdy;
+            /* } */
+            clilen = sizeof(cli_addr);
+            memset(&cli_addr, 0, clilen);
+            log_println(6, "Select() found %d clients ready, highest fd=%d",
+                        retcode, listenfd);
+            if (retcode > 1) {
+              for (i = 3; i <= listenfd; i++) {
+                if (FD_ISSET(i, &rfd)) {
+                  listenfd = i;
+                  break;
+                }
+              }
+            }
+            for (i = 0; i < RETRY_COUNT; i++) {
+              ctlsockfd = 0;
+              ctlsockfd = accept(listenfd, (struct sockaddr *) &cli_addr,
+                                 &clilen);
+
+              if ((ctlsockfd == -1) && (errno == EINTR)) // socket interrupted, retry
+                continue; // sig child
+              size_t tmpstrlen = sizeof(tmpstr);
+              memset(tmpstr, 0, tmpstrlen);
+              // get addr details based on socket info available
+              I2Addr tmp_addr = I2AddrBySockFD(get_errhandle(), ctlsockfd,
+                                               False);
+              I2AddrNodeName(tmp_addr, tmpstr, &tmpstrlen);
+              /* I2AddrFree(tmp_addr); */
+              log_println(4,
+                          "New connection received from 0x%x [%s] sockfd=%d.",
+                          tmp_addr, tmpstr, ctlsockfd);
+
+              break;
+            }
+
+            // verify that accept really worked and don't process connections that've failed
+            // RAC 2/11/10
+            if (ctlsockfd <= 0) {
+              log_println(4,
+                          "New connection request failed sockfd=%d reason-%d.",
+                          ctlsockfd, errno);
+              continue;
+            } else { // accept worked, log protocol validation log to indicate that client tried connecting
+              procstatusenum = PROCESS_STARTED;
+              proctypeenum = CONNECT_TYPE;
+              protolog_procstatus(getpid(), getCurrentTest(), proctypeenum,
+                                  procstatusenum, ctlsockfd );
+            }
+
+            // the specially crafted data that kicks off the old clients
+            for (i = 0; i < RETRY_COUNT; i++) {
+              retcode = write(ctlsockfd, "123456 654321", 13);
+              if ((retcode == -1) && (errno == EINTR)) // interrupted, retry
+                continue;
+              if (retcode == 13) // 13 bytes correctly written, exit
+                break;
+              if (retcode == -1) { // socket error hindering further retries
+                log_println(1,
+                            "Initial contact with client failed errno=%d",
+                            errno);
+                close(chld_pipe[0]);
+                close(chld_pipe[1]);
+                shutdown(ctlsockfd, SHUT_WR);
+                close(ctlsockfd);
+                goto mainloop;
+              }
+
+              log_println(6, "xxx, calling initialize_tests()");
+              t_opts = initialize_tests(ctlsockfd, &testopt, test_suite, sizeof(test_suite));
+
+              if (t_opts < 1) {
+                log_println(
+                    3,
+                    "Invalid test suite string '%s' received, terminate child",
+                    test_suite);
+                close(chld_pipe[0]);
+                close(chld_pipe[1]);
+                shutdown(ctlsockfd, SHUT_WR);
+                close(ctlsockfd);
+
+                /* todo: handle other error contitions */
+              }
+            }
+            new_child = (struct ndtchild *) malloc(sizeof(struct ndtchild));
+            memset(new_child, 0, sizeof(struct ndtchild));
+            tt = time(0);
+            name = tmpstr;
+
+            rmt_host = tmpstr;
+
+            // At this point we have received a connection from a client, meaning that
+            //  a test is being requested.  At this point we should apply any policy
+            //  or AAA functions to the incoming connection.  If we don't like the
+            //  client, we can refuse the connection and loop back to the begining.
+            //  There would need to be some additional logic installed if this AAA
+            //  test relied on more than the client's IP address.  The client would
+            //  also require modification to allow more credentials to be created/passed
+            //  between the user and this application.
+
+          }
+
+          if (pipe(chld_pipe) == -1)
+            log_println(6, "pipe() failed errno=%d", errno);
+          chld_pid = fork();
+
+          switch (chld_pid) {
+            case -1: /* an error occured, log it and quit */
+              log_println(0, "fork() failed, errno = %d", errno);
+              /* todo: handle error and continue */
+              break;
+            default: // this is the parent process, handle scheduling and
+              // queuing of multiple incoming clients
+
+              log_println(5, "Parent process spawned child = %d", chld_pid);
+              log_println(5, "Parent thinks pipe() returned fd0=%d, fd1=%d",
+                          chld_pipe[0], chld_pipe[1]);
+
+              close(chld_pipe[0]);
+
+              // Check to see if we have more than max_clients waiting in the queue
+              //  If so, tell them to go away.
+              //  changed for M-Lab deployment  1/28/09  RAC
+
+              if (((multiple == 0) && (waiting >= (max_clients - 1)))
+                  || ((multiple == 1) && (waiting >= ((4 * max_clients) - 1)))) {
+                log_println(
+                    0,
+                    "Too many clients/mclients (%d) waiting to be served, Please try again later.",
+                    chld_pid);
+                snprintf(tmpstr, sizeof(tmpstr), "9988"); // 9988 = server_BUSY_OR_ERROR
+                send_msg(ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
+                close(chld_pipe[0]);
+                close(chld_pipe[1]);
+                shutdown(ctlsockfd, SHUT_WR);
+                close(ctlsockfd);
+                kill(chld_pid, SIGTERM);
+                if (new_child != NULL) {
+                  log_println(6, "Too many clients freeing child=0x%x",
+                              new_child);
+                  free(new_child);
+                }
+                continue;
+              }
+
+              t_opts = initialize_tests(ctlsockfd, &testopt, test_suite, sizeof(test_suite));
+              if (t_opts < 1) { // some error in initialization routines
+                log_println(
+                    3,
+                    "Invalid test suite string '%s' received, terminate child",
+                    test_suite);
+                close(chld_pipe[0]);
+                close(chld_pipe[1]);
+                shutdown(ctlsockfd, SHUT_WR);
+                close(ctlsockfd);
+                kill(chld_pid, SIGTERM);
+                if (new_child != NULL) {
+                  log_println(6, "invalid test suite, freeing new_child=0x%x",
+                              new_child);
+                  free(new_child);
+                }
+                continue;
+              }
+              while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) { // socket interrupt, retry
+                log_println(6, "Waiting for ndtq semaphore to free - 1");
+                continue;
+              }
+              log_println(6, "creating new child - semaphore locked");
+              /*sigprocmask(SIG_BLOCK, &newmask, &oldmask); */
+              new_child->pid = chld_pid;
+              /* strncpy(new_child->addr, rmt_host, strlen(rmt_host));
+                 strncpy(new_child->host, name, strlen(name));*/
+              strlcpy(new_child->addr, rmt_host, sizeof(new_child->addr));
+              strlcpy(new_child->host, name, sizeof(new_child->host));
+
+              // compute start time based in the number of waiting clients
+              // set other properties on this child process
+              if (multiple == 0)
+                new_child->stime = tt + (waiting * 45);
+              else
+                new_child->stime = tt + ((waiting / max_clients) * 45);
+              new_child->qtime = tt;
+              new_child->pipe = chld_pipe[1];
+              new_child->running = 0;
+              new_child->ctlsockfd = ctlsockfd;
+              if (t_opts & TEST_STATUS
+                 )
+                new_child->oldclient = 1;
+              else
+                new_child->oldclient = 0;
+              memset(new_child->tests, 0, sizeof(test_suite));
+              memcpy(new_child->tests, test_suite, strlen(test_suite));
+              new_child->next = NULL;
+              /* sigprocmask(SIG_SETMASK, &oldmask, NULL); */
+              sem_post(&ndtq);
+              log_println(6, "Free'd ndtq semaphore lock - 1");
+              if (multiple == 1)
+                mwaiting++;
+              mchild = new_child;
+
+              log_println(
+                  3,
+                  "initialize_tests returned old/new client = %d, test_suite = %s",
+                  new_child->oldclient, new_child->tests);
+
+              close(chld_pipe[0]);
+
+              if ((testing == 1) && (queue == 0)) {
+                log_println(
+                    3,
+                    "queuing disabled and testing in progress, tell client no");
+                /* send_msg(new_child->ctlsockfd, SRV_QUEUE, "9944", 4); */
+                send_msg(new_child->ctlsockfd, SRV_QUEUE, "9988", 4);
+                close(chld_pipe[1]);
+                shutdown(new_child->ctlsockfd, SHUT_WR);
+                close(new_child->ctlsockfd);
+                log_println(6, "no queuing, free new_child=0x%x", new_child);
+                free(new_child);
+                continue;
+              }
+
+              waiting++; // new client has arrived and is queue-able. increment waiting
+              log_println(5, "Incrementing waiting variable now = %d", waiting);
+              if (head_ptr == NULL)
+                head_ptr = new_child;
+              else {
+                log_println(
+                    4,
+                    "New request has arrived, adding request to queue list");
+                while ((retcode = sem_wait(&ndtq)) == -1 && errno == EINTR) {
+                  log_println(
+                      6,
+                      "Waiting for ndtq semaphore to free, adding new client 2");
+                  continue;
+                }
+                log_println(6,
+                            "Adding new client to fifo queue - semaphore locked");
+                tmp_ptr = head_ptr;
+                while (tmp_ptr->next != NULL)
+                  tmp_ptr = tmp_ptr->next;
+                tmp_ptr->next = new_child;
+                sem_post(&ndtq);
+                log_println(6, "Free'd ndtq semaphore lock - 2");
+
+                if (get_debuglvl() > 3) {
+                  log_println(4, "Walking scheduling queue");
+                  tmp_ptr = head_ptr;
+                  while (tmp_ptr != NULL) {
+                    log_println(4, "\tChild %d, host: %s [%s], next=0x%x",
+                                tmp_ptr->pid, tmp_ptr->host, tmp_ptr->addr,
+                                (u_int64_t) tmp_ptr->next);
+                    if (tmp_ptr->next == NULL)
+                      break;
+                    tmp_ptr = tmp_ptr->next;
+                  }
+                }
+              }
+
+              // At this point send a message to the client via the ctlsockfd
+              //  saying that N clients are waiting in the queue & testing will
+              //   begin within Nx60 seconds.  Only if (waiting > 0)
+              //    Clients who leave will be handled in the run_test routine.
+
+              if ((multiple == 0) && (waiting > 1)) {
+                log_println(
+                    3,
+                    "%d clients waiting, telling client (%d) testing will begin within %d minutes",
+                    (waiting - 1), tmp_ptr->pid, (waiting-1));
+                snprintf(tmpstr, sizeof(tmpstr), "%d", (waiting-1));
+                send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
+                continue;
+              }
+
+              if ((multiple == 1) && (waiting >= max_clients)) {
+                int xx = waiting/max_clients;
+                log_println(3, "%d mclients waiting, tell client (%d) test will begin within %d minutes",
+                            (waiting-max_clients), mchild->pid, xx);
+                snprintf(tmpstr, sizeof(tmpstr), "%d", xx);
+                send_msg(mchild->ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
+                continue;
+              }
+
+              /*
+               *       if ((multiple == 0) && (testing == 1)) 
+               *         continue;
+               */
+
+              log_println(3, "Line just before ChldRdy: label, did't get here via the goto statement!");
+ChldRdy:
+              log_println(3, "___-------______  client process is ready for testing!");
+
+              // There are clients waiting in the queue, but if running in multi-client mode and
+              // there are already the max number of mclients being served, then just continue
+              // 9/2/09 RAC
+
+              if ((multiple ==1) && (mclients >= max_clients))
+                continue;
+
+              testing = 1;
+
+              // update all the clients so they have some idea that progress is occurring
+              if ((multiple == 0) && (waiting > 1)) {
+                j = waiting - 1;
+                tmp_ptr = head_ptr->next;
+                if (tmp_ptr == NULL) // no more clients waiting after the current one
+                  waiting = 1;
+                while (tmp_ptr != NULL) {
+                  log_println(3, "%d clients waiting, updating client %d testing will begin within %d minutes",
+                              (waiting-1), tmp_ptr->pid, (waiting-j));
+
+                  snprintf(tmpstr, sizeof(tmpstr), "%d", (waiting-j));
+                  send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
+                  tmp_ptr = tmp_ptr->next;
+                  j--;
+                }
+                if ((waiting > 5) && (zombie_check == 0)) { // more then 5 clients waiting, killing zombies
+                  zombie_check = -1;
+                  log_println(4, "More than 5 clients in the queue, remove zombies");
+                  if (pthread_create(&zombieThreadId, NULL, zombieWorker, (void *)head_ptr)) {
+                    log_println(0, "Cannot create thread to kill off zombie clients!");
+                    zombie_check = 0;
+                  }
+                  if (zombie_check > 0) {
+                    waiting -= zombie_check;
+                    zombie_check = 0;
+                  }
+                }
+              }
+
+              /* multi_client: */
+              if ((multiple == 1) && (mclients < max_clients)) {
+                if (mwaiting == 0)
+                  continue;
+                mwaiting--;
+                log_println(3, "Multi-client mode operation, dispatch a new client pid=%d.", mchild->pid);
+              }
+              else
+                log_println(3, "Telling client %d testing will begin now", head_ptr->pid);
+
+              // at this point we have successfully set everything up and are ready to
+              //  start testing.  The write() on the control socket tells the client
+              //  that the applet should drop out of the wait loop and get ready to begin
+              //  testing.  The write() on the pipe tells the child process it's at the
+              //  head of the queue, or it's in multi-client mode, and its OK for this
+              //  client process to wake up and begin testing.
+              //
+              //  This is the point in time where we can/should contact any meta
+              //  scheduler to verify that it is OK to really start a test.  If
+              //  we are sharing the server host with other applications, and we
+              //  want unfettered access to the link, now is the time to make this
+              //  request.
+
+dispatch_client:
+              memset(tmpstr, 0, sizeof(tmpstr));
+              if (multiple == 1) {
+                if (mchild == NULL)
+                  mchild = head_ptr;
+                if (mchild->running == 1)
+                  continue;
+                log_println(3, "New mclient '%d'(%d) asking for service", mclients, mchild->pid);
+                mchild->stime = time(0);
+                mchild->running = 1;
+                mclients++;
+                snprintf(tmpstr, sizeof(tmpstr), "go %d %s", t_opts, mchild->tests);
+                log_println(5, "sending 'GO' signal to client msg='%s'", tmpstr);
+                send_msg(mchild->ctlsockfd, SRV_QUEUE, "0", 1); // test session starts now
+                for (i=0; i<5; i++) {
+                  retcode = write(mchild->pipe, tmpstr, strlen(tmpstr));
+                  log_println(6, "write(%d) returned %d, errno=%d", mchild->pid, retcode, errno);
+                  if ((retcode == -1) && (errno == EINTR))
+                    continue;
+                  if (retcode == strlen(tmpstr))
+                    break;
+                  log_println(6, "Failed to write 'GO' message to client %d, reason=%d, errno=%d",
+                              mchild->pid, retcode, errno);
+                  /* TODO: handle other error conditions */
+                  if (retcode == -1) {
+                    log_println(1, "Dispatch multi-client failed because '%s'", strerror(errno));
+                    shutdown(mchild->ctlsockfd, SHUT_WR);
+                    close(mchild->ctlsockfd);
+                    kill(chld_pid, SIGTERM);
+                    goto mainloop;
+                  }
+                }
+                close(mchild->pipe);
+                close(mchild->ctlsockfd);
+              } // multiple client loop complete
+              else {
+                head_ptr->stime = time(0);
+                head_ptr->running = 1;
+                snprintf(tmpstr, sizeof(tmpstr), "go %d %s", t_opts, head_ptr->tests);
+                log_println(5, "sending 'GO' signal to client msg='%s'", tmpstr);
+                send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "0", 1);
+                for (i=0; i<5; i++) {
+                  retcode = write(head_ptr->pipe, tmpstr, strlen(tmpstr));
+                  if ((retcode == -1) && (errno == EINTR))
+                    continue;
+                  if (retcode == strlen(tmpstr))
+                    break;
+                  /* TODO: handle other error conditions */
+                  if (retcode == -1) {
+                    log_println(1, "Dispatch multi-client failed because '%s'", strerror(errno));
+                    shutdown(head_ptr->ctlsockfd, SHUT_WR);
+                    close(head_ptr->ctlsockfd);
+                    kill(chld_pid, SIGTERM);
+                    goto mainloop;
+                  }
+                }
+                close(head_ptr->pipe);
+                close(head_ptr->ctlsockfd);
+              }
+              continue;
+              break;
+            case 0: // this is the child process, it handles
+              //   the testing function
+              log_println(4, "Child thinks pipe() returned fd0=%d, fd1=%d for pid=%d",
+                          chld_pipe[0], chld_pipe[1], chld_pid);
+              close(listenfd);
+              close(chld_pipe[1]);
+              if ((agent = web100_attach(WEB100_AGENT_TYPE_LOCAL, NULL)) == NULL) {
+                web100_perror("web100_attach");
+                return 1;
+              }
+
+              // This is the child process from the above fork().  The parent
+              //  is in control, and will send this child a signal when it gets
+              //  to the head of the testing queue.  Post a read() and simply
+              //  wait for the parent to let us know it's time to move on.
+              //  Rich Carlson 3/11/04
+              for (;;) {
+                memset(buff, 0, sizeof(buff));
+
+                // the read() could return if an interrupt was caught.  This condition
+                // should be checked for and the read() restarted if necessary
+                // RAC 3/18/10
+                //
+                retcode = read(chld_pipe[0], buff, 32);
+                log_println(6, "Child %d received '%s' from parent", getpid(), buff);
+                if ((retcode == -1) && (errno == EINTR))
+                  continue;
+                if (strncmp(buff, "go", 2) == 0) {
+                  log_println(6, "Got 'go' signal from parent, ready to start testing %d", getpid());
+                  break;
+                }
+                if (buff[0] == 0) {
+                  log_println(6, "Child %d received 'go' signal, exiting", getpid());
+                  exit(-1);
+                }
+              }
+
+              set_timestamp();
+
+              // The next 3 instructions retrieve the passed in values for the tests to run.
+              //  t_opts will be the bitmapped version of this data and test_suite will be a
+              //   character string with the same info.  Note: this assumes that the structure
+              //    of buff is fixed with the character strings starting in these locations.
+              //     RAC 7/8/09
+
+              memset(test_suite, 0, sizeof(test_suite));
+              t_opts = atoi(buff+3);
+              memcpy(test_suite, buff+5, (strlen(buff)-5));
+              /* memcpy(test_suite, buff+6, 7); */
+              log_println(5, "extracting test_suite '%s' and t_opts '%x' from buff '%s'", test_suite, t_opts, buff);
+
+              // construct cputime log folder
+              {
+                I2Addr tmp_addr = I2AddrBySockFD(get_errhandle(), ctlsockfd, False);
+                testPort = I2AddrPort(tmp_addr);
+                meta.ctl_port = testPort;
+                snprintf(testName, 250, "%s", name);
+                I2AddrFree(tmp_addr);
+                memset(cputimelog, 0, 256);
+                if (cputime) {
+                  snprintf(dir, sizeof(dir), "%s_%s:%d.cputime",
+                           get_ISOtime(isoTime, sizeof(isoTime)), name, testPort);
+                  log_println(8, "CPUTIME:suffix=%s",dir);
+                  create_named_logdir(cputimelog, sizeof(cputimelog),dir, 0);
+                  memcpy(meta.CPU_time, dir, strlen(dir));
+                  if (pthread_create(&workerThreadId, NULL, cputimeWorker, (void*) cputimelog)) {
+                    log_println(0, "Cannot create worker thread for writing cpu usage!");
+                    workerThreadId = 0;
+                    memset(cputimelog, 0, 256);
+                  }
+                }
+              }
+              // write the incoming connection data into the log file
+              fp = fopen(get_logfile(),"a");
+              if (fp == NULL) {
+                log_println(0, "Unable to open log file '%s', continuing on without logging", get_logfile());
+              }
+              else {
+                fprintf(fp,"%15.15s  %s port %d\n",
+                        ctime(&tt)+4, name, testPort);
+                if (cputime && workerThreadId) {
+                  log_println(1, "cputime trace file: %s\n", cputimelog);
+                  fprintf(fp, "cputime trace file: %s\n", cputimelog);
+                }
+                fclose(fp);
+              }
+              close(chld_pipe[0]);
+
+              // Set test options
+              if (t_opts & TEST_MID)
+                testopt.midopt = TOPT_ENABLED;
+              if (t_opts & TEST_SFW)
+                testopt.sfwopt = TOPT_ENABLED;
+              if (t_opts & TEST_META)
+                testopt.metaopt = TOPT_ENABLED;
+              if (t_opts & TEST_C2S)
+                testopt.c2sopt = TOPT_ENABLED;
+              if (t_opts & TEST_S2C)
+                testopt.s2copt = TOPT_ENABLED;
+              alarm(120);// die in 120 seconds, but only if a test doesn't get started
+              // reset alarm() before every test
+              log_println(6, "setting master alarm() to 120 seconds, tests must start (complete?) before this timer expires");
+
+              // run tests based on options
+              if (strncmp(test_suite, "Invalid", 7) != 0) {
+                log_println(3, "Valid test sequence requested, run test for client=%d", getpid());
+                retcode = run_test(agent, ctlsockfd, &testopt, test_suite);
+              }
+
+              // conclude all test runs
+              if (retcode == 0)
+                log_println(3, "Successfully returned from run_test() routine");
+              else {
+                log_println(3, "Child %d returned non-zero (%d) from run_test() results some test failed!", getpid(), retcode);
+                child_sig(0);
+              }
+              close(ctlsockfd);
+              web100_detach(agent);
+              log_free();
+
+              if (cputime && workerThreadId) {
+                cputimeworkerLoop = 0;
+                pthread_join(workerThreadId, NULL);
+              }
+
+              // At this point the tests have been run and we need to clean up and handle
+              // and child processes that might still be lying around.  If we don't we get
+              // zombies. The pkt-pair handling created 2 childern and we need to get
+              // rid of them. To know what PIDs to look for on 1/19/10 the run_test()
+              // routine was modified to pass around these values. The values are set in
+              // the proper routine in the testoptions.c file.
+              // Then add call to child_sig() routine and pass in these PID's so we handle
+              // each child in sequence
+
+              log_println(6, "remove pkt-pair children c2s=%d, s2c=%d", testopt.child1, testopt.child2);
+              if (testopt.child1 != 0)
+                child_sig(testopt.child1);
+              if (testopt.child2 != 0)
+                child_sig(testopt.child2);
+              exit(0);
+              break;
+          }
+  }
+}
 
-				if ((multiple == 1) && (waiting >= max_clients)) {
-					int xx = waiting/max_clients;
-					log_println(3, "%d mclients waiting, tell client (%d) test will begin within %d minutes",
-							(waiting-max_clients), mchild->pid, xx);
-					snprintf(tmpstr, sizeof(tmpstr), "%d", xx);
-					send_msg(mchild->ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
-					continue;
-				}
-
-				/*
-				 *       if ((multiple == 0) && (testing == 1)) 
-				 *         continue;
-				 */
-
-				log_println(3, "Line just before ChldRdy: label, did't get here via the goto statement!");
-				ChldRdy:
-				log_println(3, "___-------______  client process is ready for testing!");
-
-				// There are clients waiting in the queue, but if running in multi-client mode and
-				// there are already the max number of mclients being served, then just continue
-				// 9/2/09 RAC
-
-				if ((multiple ==1) && (mclients >= max_clients))
-				continue;
-
-				testing = 1;
-
-				// update all the clients so they have some idea that progress is occurring
-				if ((multiple == 0) && (waiting > 1)) {
-					j = waiting - 1;
-					tmp_ptr = head_ptr->next;
-					if (tmp_ptr == NULL) // no more clients waiting after the current one
-					waiting = 1;
-					while (tmp_ptr != NULL) {
-						log_println(3, "%d clients waiting, updating client %d testing will begin within %d minutes",
-								(waiting-1), tmp_ptr->pid, (waiting-j));
-
-						snprintf(tmpstr, sizeof(tmpstr), "%d", (waiting-j));
-						send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
-						tmp_ptr = tmp_ptr->next;
-						j--;
-					}
-					if ((waiting > 5) && (zombie_check == 0)) { // more then 5 clients waiting, killing zombies
-						zombie_check = -1;
-						log_println(4, "More than 5 clients in the queue, remove zombies");
-						if (pthread_create(&zombieThreadId, NULL, zombieWorker, (void *)head_ptr)) {
-							log_println(0, "Cannot create thread to kill off zombie clients!");
-							zombie_check = 0;
-						}
-						if (zombie_check > 0) {
-							waiting -= zombie_check;
-							zombie_check = 0;
-						}
-					}
-				}
-
-				/* multi_client: */
-				if ((multiple == 1) && (mclients < max_clients)) {
-					if (mwaiting == 0)
-					continue;
-					mwaiting--;
-					log_println(3, "Multi-client mode operation, dispatch a new client pid=%d.", mchild->pid);
-				}
-				else
-				log_println(3, "Telling client %d testing will begin now", head_ptr->pid);
-
-				// at this point we have successfully set everything up and are ready to
-				//  start testing.  The write() on the control socket tells the client
-				//  that the applet should drop out of the wait loop and get ready to begin
-				//  testing.  The write() on the pipe tells the child process it's at the
-				//  head of the queue, or it's in multi-client mode, and its OK for this
-				//  client process to wake up and begin testing.
-				//
-				//  This is the point in time where we can/should contact any meta
-				//  scheduler to verify that it is OK to really start a test.  If
-				//  we are sharing the server host with other applications, and we
-				//  want unfettered access to the link, now is the time to make this
-				//  request.
-
-				dispatch_client:
-				memset(tmpstr, 0, sizeof(tmpstr));
-				if (multiple == 1) {
-					if (mchild == NULL)
-					mchild = head_ptr;
-					if (mchild->running == 1)
-					continue;
-					log_println(3, "New mclient '%d'(%d) asking for service", mclients, mchild->pid);
-					mchild->stime = time(0);
-					mchild->running = 1;
-					mclients++;
-					snprintf(tmpstr, sizeof(tmpstr), "go %d %s", t_opts, mchild->tests);
-					log_println(5, "sending 'GO' signal to client msg='%s'", tmpstr);
-					send_msg(mchild->ctlsockfd, SRV_QUEUE, "0", 1); // test session starts now
-					for (i=0; i<5; i++) {
-						retcode = write(mchild->pipe, tmpstr, strlen(tmpstr));
-						log_println(6, "write(%d) returned %d, errno=%d", mchild->pid, retcode, errno);
-						if ((retcode == -1) && (errno == EINTR))
-						continue;
-						if (retcode == strlen(tmpstr))
-						break;
-						log_println(6, "Failed to write 'GO' message to client %d, reason=%d, errno=%d",
-								mchild->pid, retcode, errno);
-						/* TODO: handle other error conditions */
-						if (retcode == -1) {
-							log_println(1, "Dispatch multi-client failed because '%s'", strerror(errno));
-							shutdown(mchild->ctlsockfd, SHUT_WR);
-							close(mchild->ctlsockfd);
-							kill(chld_pid, SIGTERM);
-							goto mainloop;
-						}
-					}
-					close(mchild->pipe);
-					close(mchild->ctlsockfd);
-				} // multiple client loop complete
-				else {
-					head_ptr->stime = time(0);
-					head_ptr->running = 1;
-					snprintf(tmpstr, sizeof(tmpstr), "go %d %s", t_opts, head_ptr->tests);
-					log_println(5, "sending 'GO' signal to client msg='%s'", tmpstr);
-					send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "0", 1);
-					for (i=0; i<5; i++) {
-						retcode = write(head_ptr->pipe, tmpstr, strlen(tmpstr));
-						if ((retcode == -1) && (errno == EINTR))
-						continue;
-						if (retcode == strlen(tmpstr))
-						break;
-						/* TODO: handle other error conditions */
-						if (retcode == -1) {
-							log_println(1, "Dispatch multi-client failed because '%s'", strerror(errno));
-							shutdown(head_ptr->ctlsockfd, SHUT_WR);
-							close(head_ptr->ctlsockfd);
-							kill(chld_pid, SIGTERM);
-							goto mainloop;
-						}
-					}
-					close(head_ptr->pipe);
-					close(head_ptr->ctlsockfd);
-				}
-				continue;
-				break;
-				case 0: // this is the child process, it handles
-						//   the testing function
-				log_println(4, "Child thinks pipe() returned fd0=%d, fd1=%d for pid=%d",
-						chld_pipe[0], chld_pipe[1], chld_pid);
-				close(listenfd);
-				close(chld_pipe[1]);
-				if ((agent = web100_attach(WEB100_AGENT_TYPE_LOCAL, NULL)) == NULL) {
-					web100_perror("web100_attach");
-					return 1;
-				}
-
-				// This is the child process from the above fork().  The parent
-				//  is in control, and will send this child a signal when it gets
-				//  to the head of the testing queue.  Post a read() and simply
-				//  wait for the parent to let us know it's time to move on.
-				//  Rich Carlson 3/11/04
-				for (;;) {
-					memset(buff, 0, sizeof(buff));
-
-					// the read() could return if an interrupt was caught.  This condition
-					// should be checked for and the read() restarted if necessary
-					// RAC 3/18/10
-					//
-					retcode = read(chld_pipe[0], buff, 32);
-					log_println(6, "Child %d received '%s' from parent", getpid(), buff);
-					if ((retcode == -1) && (errno == EINTR))
-					continue;
-					if (strncmp(buff, "go", 2) == 0) {
-						log_println(6, "Got 'go' signal from parent, ready to start testing %d", getpid());
-						break;
-					}
-					if (buff[0] == 0) {
-						log_println(6, "Child %d received 'go' signal, exiting", getpid());
-						exit(-1);
-					}
-				}
-
-				set_timestamp();
-
-				// The next 3 instructions retrieve the passed in values for the tests to run.
-				//  t_opts will be the bitmapped version of this data and test_suite will be a
-				//   character string with the same info.  Note: this assumes that the structure
-				//    of buff is fixed with the character strings starting in these locations.
-				//     RAC 7/8/09
-
-				memset(test_suite, 0, sizeof(test_suite));
-				t_opts = atoi(buff+3);
-				memcpy(test_suite, buff+5, (strlen(buff)-5));
-				/* memcpy(test_suite, buff+6, 7); */
-				log_println(5, "extracting test_suite '%s' and t_opts '%x' from buff '%s'", test_suite, t_opts, buff);
-
-				// construct cputime log folder
-				{
-					I2Addr tmp_addr = I2AddrBySockFD(get_errhandle(), ctlsockfd, False);
-					testPort = I2AddrPort(tmp_addr);
-					meta.ctl_port = testPort;
-					snprintf(testName, 250, "%s", name);
-					I2AddrFree(tmp_addr);
-					memset(cputimelog, 0, 256);
-					if (cputime) {
-						snprintf(dir, sizeof(dir), "%s_%s:%d.cputime",
-								get_ISOtime(isoTime, sizeof(isoTime)), name, testPort);
-						log_println(8, "CPUTIME:suffix=%s",dir);
-						create_named_logdir(cputimelog, sizeof(cputimelog),dir, 0);
-						memcpy(meta.CPU_time, dir, strlen(dir));
-						if (pthread_create(&workerThreadId, NULL, cputimeWorker, (void*) cputimelog)) {
-							log_println(0, "Cannot create worker thread for writing cpu usage!");
-							workerThreadId = 0;
-							memset(cputimelog, 0, 256);
-						}
-					}
-				}
-				// write the incoming connection data into the log file
-				fp = fopen(get_logfile(),"a");
-				if (fp == NULL) {
-					log_println(0, "Unable to open log file '%s', continuing on without logging", get_logfile());
-				}
-				else {
-					fprintf(fp,"%15.15s  %s port %d\n",
-							ctime(&tt)+4, name, testPort);
-					if (cputime && workerThreadId) {
-						log_println(1, "cputime trace file: %s\n", cputimelog);
-						fprintf(fp, "cputime trace file: %s\n", cputimelog);
-					}
-					fclose(fp);
-				}
-				close(chld_pipe[0]);
-
-				// Set test options
-				if (t_opts & TEST_MID)
-				testopt.midopt = TOPT_ENABLED;
-				if (t_opts & TEST_SFW)
-				testopt.sfwopt = TOPT_ENABLED;
-				if (t_opts & TEST_META)
-				testopt.metaopt = TOPT_ENABLED;
-				if (t_opts & TEST_C2S)
-				testopt.c2sopt = TOPT_ENABLED;
-				if (t_opts & TEST_S2C)
-				testopt.s2copt = TOPT_ENABLED;
-				alarm(120);// die in 120 seconds, but only if a test doesn't get started
-							 // reset alarm() before every test
-				log_println(6, "setting master alarm() to 120 seconds, tests must start (complete?) before this timer expires");
-
-							 // run tests based on options
-				if (strncmp(test_suite, "Invalid", 7) != 0) {
-					log_println(3, "Valid test sequence requested, run test for client=%d", getpid());
-					retcode = run_test(agent, ctlsockfd, &testopt, test_suite);
-				}
-
-				// conclude all test runs
-				if (retcode == 0)
-				log_println(3, "Successfully returned from run_test() routine");
-				else {
-					log_println(3, "Child %d returned non-zero (%d) from run_test() results some test failed!", getpid(), retcode);
-					child_sig(0);
-				}
-				close(ctlsockfd);
-				web100_detach(agent);
-				log_free();
-
-				if (cputime && workerThreadId) {
-					cputimeworkerLoop = 0;
-					pthread_join(workerThreadId, NULL);
-				}
-
-				// At this point the tests have been run and we need to clean up and handle
-				// and child processes that might still be lying around.  If we don't we get
-				// zombies. The pkt-pair handling created 2 childern and we need to get
-				// rid of them. To know what PIDs to look for on 1/19/10 the run_test()
-				// routine was modified to pass around these values. The values are set in
-				// the proper routine in the testoptions.c file.
-				// Then add call to child_sig() routine and pass in these PID's so we handle
-				// each child in sequence
-
-				log_println(6, "remove pkt-pair children c2s=%d, s2c=%d", testopt.child1, testopt.child2);
-				if (testopt.child1 != 0)
-				child_sig(testopt.child1);
-				if (testopt.child2 != 0)
-				child_sig(testopt.child2);
-				exit(0);
-				break;
-			}
-		}
-	}
-
-	/**
-	 * Method to get remote host's address.
-	 * @return remote host name
-	 * */
+/**
+ * Method to get remote host's address.
+ * @return remote host name
+ * */
 char *get_remotehost() {
-	return rmt_host;
+  return rmt_host;
 }
