diff -N -r -u wu-ftpd-2.6.1/.bld.hlp auto_wuftp/.bld.hlp
--- wu-ftpd-2.6.1/.bld.hlp	1969-12-31 19:00:00.000000000 -0500
+++ auto_wuftp/.bld.hlp	2001-04-23 08:56:30.000000000 -0400
@@ -0,0 +1,32 @@
+Usage: build <make-options> <target-platform>
+
+<target-platform> may be one of the following:
+  gen    : generic make (copy this when porting to a new system)
+  aix    : IBM AIX
+  aux    : AU/X
+  bdi    : BSD/OS
+  bsd    : BSD
+  dec    : DEC Unix 3.X
+  du4    : DEC Unix 4.X or later
+  dyn    : Dynix
+  fbs    : FreeBSD 2.0 or later
+  him    : Hitachi SR2201 and S-3600 Unix (HI-UX/MPP and HI-OSF/1-MJ)
+  hiu    : Hitachi 3050 Unix (HI-UX/WE2)
+  hpx    : HP-UX
+  lnx    : Linux (tested on 1.2.X and 2.0.0)
+  nbs    : NetBSD 1.X
+  nx2    : NeXTstep 2.x
+  nx3    : NeXTstep 3.x
+  osf    : OSF/1
+  osx    : Mac OS X
+  ptx    : ???
+  sco    : SCO Unix 3.2v4.2 / SCO OpenServer 5
+  sgi    : SGI Irix 5.3
+  ir4    : SGI Irix 4.0.5a
+  sny    : Sony NewsOS
+  sol    : SunOS 5.x / Solaris 2.x 
+  s41    : SunOS 4.1.x 
+  ult    : Ultrix 4.x
+  uxw    : UnixWare 1.1 or later
+  clean  : Clean up object files and such to reduce disk space after building.
+  install: Install ftpd.
diff -N -r -u wu-ftpd-2.6.1/CHANGES-AUTOTUNE auto_wuftp/CHANGES-AUTOTUNE
--- wu-ftpd-2.6.1/CHANGES-AUTOTUNE	1969-12-31 19:00:00.000000000 -0500
+++ auto_wuftp/CHANGES-AUTOTUNE	2001-10-20 07:33:29.000000000 -0400
@@ -0,0 +1,22 @@
+Modifications/Additions by Gaurav Navlakha for Auto Tuning
+April 15th, 2001.
+
+ftpcmd.y:
+
+line 102: extern int TCPwindowsize.
+line 180: BUFSIZE
+line 192: bufsize type
+line 996: Added case for SITE BUFSIZE
+line 1328: BUFSIZE..
+line 2035: set_bufsize() function to set socket buffer size (TCPwindowsize)
+
+Modifications/Additions by Gaurav Navlakha for Auto Tuning
+June 21st, 2001.
+
+ftpcmd.y: 51
+ftpcmd.y: 2063 
+ftpcmd.y: 2093 
+New file: buf_udp.h
+
+ftpcmd.y 2105: measure_bufsize() function for UDP auto tuning
+
diff -N -r -u wu-ftpd-2.6.1/src/buf_udp.h auto_wuftp/src/buf_udp.h
--- wu-ftpd-2.6.1/src/buf_udp.h	1969-12-31 19:00:00.000000000 -0500
+++ auto_wuftp/src/buf_udp.h	2001-06-06 08:41:18.000000000 -0400
@@ -0,0 +1,18 @@
+/*********************************************************
+
+Udp Packet structure for Auto Tuning Measurements
+-Gaurav Navlakha, NLANR. June 2001.
+
+*********************************************************/
+#ifndef __BUF_UDP_H__
+#define __BUF_UDP_H__
+#include <sys/time.h>
+#include <unistd.h>
+
+typedef struct buf_udp
+{
+struct timeval tval;
+int seqno;
+} buf_udp_t;
+
+#endif
diff -N -r -u wu-ftpd-2.6.1/src/ftpcmd.y auto_wuftp/src/ftpcmd.y
--- wu-ftpd-2.6.1/src/ftpcmd.y	2000-07-01 14:17:39.000000000 -0400
+++ auto_wuftp/src/ftpcmd.y	2001-10-20 07:35:38.000000000 -0400
@@ -21,6 +21,9 @@
   at http://www.wu-ftpd.org/license.html.  
    
   $Id: ftpcmd.y,v 1.27 2000/07/01 18:17:39 wuftpd Exp $  
+
+* Modified for Auto tuning, by Gaurav Navlakha, DAST, NLANR. 
+* (April & June of 2001)
    
 ****************************************************************************/ 
 /*
@@ -31,6 +34,7 @@
 %{
 
 #include "config.h"
+#include "buf_udp.h"
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -44,6 +48,24 @@
 #include <ctype.h>
 #include <pwd.h>
 #include <setjmp.h>
+
+/* Modified by Gaurav Navlakha for Auto Tuning */
+#include <poll.h>
+
+#define INTERVAL_SEC 2
+#define INTERVAL_USEC 0 
+
+#define UDP_NUMBER_OF_PACKAGES 10
+
+#define UDP_PKT_SIZE 5000
+
+struct itimerval val;
+int all_lost = 0;
+int udp_conn_setup = 0;
+int udp_conn = 0;
+
+/* End of modification */
+
 #ifdef HAVE_SYS_SYSLOG_H
 #include <sys/syslog.h>
 #endif
@@ -99,6 +121,8 @@
 extern char *formnames[];
 extern int restricted_user;	/* global flag indicating if user is restricted to home directory */
 
+extern int TCPwindowsize;
+
 #ifdef TRANSFER_COUNT
 extern int data_count_total;
 extern int data_count_in;
@@ -175,7 +199,8 @@
 
     UMASK   IDLE    CHMOD   GROUP   GPASS   NEWER
     MINFO   INDEX   EXEC    ALIAS   CDPATH  GROUPS
-    CHECKMETHOD     CHECKSUM
+    CHECKMETHOD     CHECKSUM		BUFSIZE
+	BUFSIZEMEASURE
 
     LEXERR
 
@@ -187,6 +212,7 @@
 %type <String>  STRING password pathname pathstring username method
 %type <Number>  NUMBER byte_size check_login form_code 
 %type <Number>  struct_code mode_code octal_number
+%type <Number>	bufsize remote_mtu_size 
 
 %start  cmd_list
 
@@ -985,8 +1011,28 @@
 	    if ($2)
 		CheckSumLastFile();
 	}
+    | SITE check_login SP BUFSIZE CRLF
+    =   {
+        if (log_commands) syslog(LOG_INFO, "SITE BUFSIZE");
+        print_bufsize (); 
+    }
+
+    | SITE check_login SP BUFSIZEMEASURE SP remote_mtu_size CRLF
+    =   {
+		int size = $6;
+        if (log_commands) syslog(LOG_INFO, "SITE BUFSIZEMEASURE");
+        measure_bufsize (size); 
+    }
+
+    | SITE check_login SP BUFSIZE SP bufsize CRLF
+    =   {
+        int size = $6; 
+
+        if (log_commands) syslog(LOG_INFO, "SITE BUFSIZE %d", size);
+        set_bufsize (size);
+    }
     ;
-        
+
 username: STRING
     ;
 
@@ -1223,6 +1269,10 @@
 	}
     ;
 
+bufsize: NUMBER
+remote_mtu_size: NUMBER
+	;
+
 %%
 
 extern jmp_buf errcatch;
@@ -1307,6 +1357,8 @@
     {"GROUPS", GROUPS, OSTR, 1, "[ <sp> ] "},
     {"CHECKMETHOD", CHECKMETHOD, OSTR, 1, "[ <sp> method ]"},
     {"CHECKSUM", CHECKSUM, OSTR, 1, "[ <sp> file-name ]"},
+	{"BUFSIZE", BUFSIZE, ARGS, 1, "[ <sp> <socket buffer size in bytes> ]"},
+	{"BUFSIZEMEASURE", BUFSIZEMEASURE, ARGS, 1, "[ <sp> <remote mtu in bytes> ]"},
     {NULL, 0, 0, 0, 0}
 };
 
@@ -2008,3 +2060,182 @@
     (void) fflush(stdout);
     reply(214, "");
 }
+
+/* Modified by Gaurav Navlakha for Auto Tuning */
+set_bufsize(int size)
+{
+#ifdef AUTO_DEBUG
+    FILE *fp;
+#endif
+
+	/* Use the new Window Size sent by client for data connection */
+    TCPwindowsize = size;
+
+    reply(214, "TCP window size set to %d kilobytes.",
+		  TCPwindowsize);
+
+#ifdef AUTO_DEBUG
+    fp = fopen("/home/navlakha/WUFTPFILE", "a");
+    fprintf(fp, "set_bufsize: TCPwindowsize = [%d]\n", TCPwindowsize);
+    fclose(fp);
+#endif
+
+}
+
+print_bufsize()
+{
+    if (TCPwindowsize > 0)
+    reply(214, "TCP window size is %d kilobytes.",
+          TCPwindowsize);
+    else
+    reply(214, "TCP window size is the system default.");
+}
+
+/* Modified by Gaurav Navlakha for Auto Tuning */
+void udp_timeout(int signo)
+{
+    all_lost = 1;
+
+    /* cancel the interval timer */
+    val.it_interval.tv_sec = 0;
+    val.it_interval.tv_usec = 0;
+    val.it_value.tv_sec = 0;
+    val.it_value.tv_usec = 0;
+}
+
+measure_bufsize(int size)
+{
+#ifdef AUTO_DEBUG
+	FILE *fp;
+#endif
+	static int i = 0;
+	int conn = -1;
+	buf_udp_t sendreply[UDP_PKT_SIZE/(sizeof(buf_udp_t))];
+	struct sockaddr_in addr;
+	int yes = 1;
+	int n=0;
+
+	struct sockaddr_in cli_addr;
+	socklen_t addrlen;
+	struct pollfd fds[1];
+	int seqno;
+
+	/* Signals for setting up interval (2 sec) timer */
+    struct sigaction action;
+    struct sigaction oldaction;
+
+	all_lost = 0;
+	
+    val.it_interval.tv_sec = 0;
+    val.it_interval.tv_usec = 0;
+    val.it_value.tv_sec = INTERVAL_SEC;
+    val.it_value.tv_usec = INTERVAL_USEC;
+
+    /* set up interval timer */
+    sigemptyset(&action.sa_mask);
+    action.sa_handler = udp_timeout;
+    action.sa_flags = SA_RESTART;
+    if(sigaction(SIGALRM, &action, &oldaction) == -1){
+        return (-1);
+    }
+
+    if(setitimer(ITIMER_REAL, &val, 0) == -1){
+        return (-1);
+    }
+
+	++i;
+
+    reply(211, "Got SITE BUFSIZEMEASURE command [%d]", size);
+
+#ifdef AUTO_DEBUG
+    /* Use the new Window Size sent by client for data connection */
+    fp = fopen("/home/navlakha/BUFSIZEMEASUREFILE", "a");
+    fprintf(fp, "Got SITE BUFSIZEMEASURE [%d]\n", i);
+	fprintf(fp, "replied 211\n");
+#endif
+
+	/* Create and bind the socket only once initially */
+	if (udp_conn_setup==0)
+	{
+		if ((udp_conn = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+		{
+			return (-1);
+		}
+		if (setsockopt(udp_conn, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
+		{
+#ifdef AUTO_DEBUG
+			fprintf(fp, "Error in call to setsockopt(SO_REUSEADDR)\n");
+#endif
+			return (-1);
+		}
+	
+		addr.sin_family = AF_INET;			/* host byte order */
+		addr.sin_port = htons(9001);		/* short, network byte order */
+		addr.sin_addr.s_addr = INADDR_ANY;	/* automatically fill with my IP */
+		bzero(&(addr.sin_zero), sizeof(addr.sin_zero));        /* zero the rest of the struct */
+	
+		if (bind(udp_conn, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1)
+		{
+			return;
+		}
+
+		udp_conn_setup = 1;
+	}
+	fds[0].fd = udp_conn;
+	fds[0].events = POLLIN;
+
+	i=0;
+	while (!all_lost && i<UDP_NUMBER_OF_PACKAGES)
+	{
+		if (poll(fds, 1, 0) == -1)
+		{
+			if (errno == EINTR) /* interrupted by alarm */
+			{
+				continue;
+			}
+			else
+			{
+				perror("poll");
+				continue;
+			}
+		}
+		if (!(fds[0].revents & POLLIN))
+			continue;
+
+		++i;
+	
+		if ((n=recvfrom(udp_conn, (void *)sendreply, size, 0, 
+			&cli_addr, &addrlen))<0)
+		{
+#ifdef AUTO_DEBUG
+			fprintf(fp, "recv error [%d]\n", errno);
+#endif
+			return -1;
+		}
+		seqno = sendreply[0].seqno; /* this might be reverse byte order */
+#ifdef AUTO_DEBUG
+		fprintf(fp, "Got SeqNo [%d] [%d] \n", seqno, ntohs(seqno));
+		fprintf(fp, "Bytes RECVD: [%d]\n", n);
+#endif
+		if ((n=sendto(udp_conn, (const void *)sendreply, sizeof(buf_udp_t), 0,
+				(struct sockaddr *)&cli_addr, sizeof(struct sockaddr))) <0)
+		{
+#ifdef AUTO_DEBUG
+			fprintf(fp, "send() error \n");
+#endif
+			return (-1);
+		}
+#ifdef AUTO_DEBUG
+		fprintf(fp, "Reply [%d] - [%d] bytes sent \n", i, n);
+#endif
+
+		if (i==UDP_NUMBER_OF_PACKAGES) break;
+	}
+	alarm(0);
+	sigaction(SIGALRM, &oldaction, 0);
+#ifdef AUTO_DEBUG
+	fclose(fp);
+#endif
+}
+/* End of Modification */
+
