Transfer speed management

Limiting transfer speed (bandwidth throttling) 

High transfer speed is not always desirable - if you prefer high network throughput, you might wish to limit the transfer speed.

To achieve this, use MaxDownloadSpeed and MaxUploadSpeed properties:

// set download and upload speed limits
ftp.MaxDownloadSpeed = 4 * 1024;
ftp.MaxUploadSpeed = 2 * 1024;

// transfer files
// ...
' set download and upload speed limits
ftp.MaxDownloadSpeed = 4 * 1024
ftp.MaxUploadSpeed = 2 * 1024

' transfer files
' ...

Speed monitoring (transfer speed event) 

To keep informed about the current speed of the transfer (in order to display it to the user, for example), register a TransferProgressChanged event handler. Current transfer speed is available through FtpTransferProgressChangedEventArgs.BytesPerSecond property, moving average calculation is used to smooth the value.

Sample event handler:

void client_SpeedMonitoring(object sender, FtpTransferProgressChangedEventArgs e)
{
    // display current speed info
    Console.WriteLine("Current speed: {0} B/s", e.BytesPerSecond);
}
Sub client_SpeedMonitoring(ByVal sender As Object, ByVal e As FtpTransferProgressChangedEventArgs)
    ' display current speed info
    Console.WriteLine("Current speed: {0} B/s", e.BytesPerSecond)
End Sub

Registering the event handler:

// register TransferProgressChanged event handler
ftp.TransferProgressChanged += client_SpeedMonitoring;

// transfer files
// ...
' register TransferProgressChanged event handler
AddHandler ftp.TransferProgressChanged, AddressOf client_SpeedMonitoring

' transfer files
' ...

TLS/SSL session caching 

In FTP, each data transfer (such as upload, download or file and directory listing) uses a separate data channel. In TLS/SSL mode, this means that TLS/SSL encryption has to be negotiated for each data transfer. To improve speed significantly, Rebex FTP/SSL supports TLS/SSL session caching and resuming.

Note: This feature can be switched off by setting Ftp.Settings.SslReuseSessions to false.

Large buffer mode 

Occasionally, using larger buffers may increase the transfer speed, particularly for downloads. Set Ftp.Settings.UseLargeBuffers to true to use larger buffers.

Internal buffer sizes:

Buffer No option UseLargeBuffers
TCP socket's receive buffer Socket's default 4MB
TCP socket's send buffer Socket's default 256KB