260-380% transfer speed performance *increase* over WAN (internet) links


FTP throughput is sensitive to tcp window scaling if there is any latency (>10ms) on the route. I made the below changes and got a speed up from 283 KBps to 1017 KBps for a single upload stream with 27ms latency. Over a 250ms link the speed changed from 40 KBps to 193 KBps - your mileage may vary. Note this wont improve (or hurt) local LAN transfer speeds.

FTPSClient v1.1.0 (75876)
disk buffer: 1 KB
send window: 8 KB (TcpClient default)
receive window: 8 KB (TcpClient default)

My update (tuned for up to 20Mbit @ 250ms):
disk buffer: 4 KB
send window: 40 KB
receive window: 640 KB

For comparison, Filezilla uses:
send window: 256 KB
receive window: 4096 KB
which is probably overkill but might be needed to saturate high-latency 100Mbit links (in my testing this resulted in a lot of re-transmits and dupe ACKs).

Changes to FTPSClient.cs:

In GetFile() and SendFile() change "byte[] buf = new byte[1024];" to 4096.

In SetupPassiveDataConnection() add
dataClient.SendBufferSize = 40 * 1024;
dataClient.ReceiveBufferSize = 640 * 1024;

Note a window over 64kb requires an O/S that supports tcp window scaling (win 2000+).

Ref http://bradhedlund.com/2008/12/19/how-to-calculate-tcp-throughput-for-long-distance-links/