From a727f4d8b155a2489ab24eb7c366aef8a814c8e2 Mon Sep 17 00:00:00 2001 From: Kleissner Date: Sat, 13 Nov 2021 14:41:14 +0100 Subject: [PATCH] Define and document the flow window size for transfer. Document webapi timeout parameters. --- Transfer UDT.go | 7 +++++++ webapi/API.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Transfer UDT.go b/Transfer UDT.go index 107b8ea..a942566 100644 --- a/Transfer UDT.go +++ b/Transfer UDT.go @@ -27,6 +27,11 @@ import ( // transferSequenceTimeout is the timeout for a follow-up message to appear, otherwise the transfer will be terminated. var transferSequenceTimeout = time.Minute * 10 +// maxFlowWinSize is the maximum number of unacknowledged packets to permit. A higher number means using more memory, but reduces potential overhead since it does not stop so quickly for missing packets. +// Each unacknowledged packet may store protocol.TransferMaxEmbedSize (currently 1121 bytes) payload data in memory. A too high number may impact the speed of real-time streaming in case of lost packets. +// The actual used number will be negotiated through the UDT handshake and must be a minimum of 32. +const maxFlowWinSize = 64 + // startFileTransferUDT starts a file transfer from the local warehouse to the remote peer. // It creates a virtual UDT client to transfer data to a remote peer. Counterintuitively, this will be the "file server" peer. func (peer *PeerInfo) startFileTransferUDT(hash []byte, fileSize uint64, offset, limit uint64, sequenceNumber uint32) (err error) { @@ -46,6 +51,7 @@ func (peer *PeerInfo) startFileTransferUDT(hash []byte, fileSize uint64, offset, udtConfig := udt.DefaultConfig() udtConfig.MaxPacketSize = protocol.TransferMaxEmbedSize + udtConfig.MaxFlowWinSize = maxFlowWinSize // start UDT sender // Set streaming to true, otherwise udtSocket.Read returns the error "Message truncated" in case the reader has a smaller buffer. @@ -85,6 +91,7 @@ func (peer *PeerInfo) FileTransferRequestUDT(hash []byte, offset, limit uint64) udtConfig := udt.DefaultConfig() udtConfig.MaxPacketSize = protocol.TransferMaxEmbedSize + udtConfig.MaxFlowWinSize = maxFlowWinSize // start UDT receiver udtListener := udt.ListenUDT(udtConfig, virtualConn, virtualConn.incomingData, virtualConn.outgoingData, virtualConn.terminationSignal) diff --git a/webapi/API.go b/webapi/API.go index 61d6b9d..b4ad608 100644 --- a/webapi/API.go +++ b/webapi/API.go @@ -31,7 +31,8 @@ var WSUpgrader = websocket.Upgrader{ }, } -// Start starts the API. ListenAddresses is a list of IP:Ports +// Start starts the API. ListenAddresses is a list of IP:Ports. +// The certificate file and key are only used if SSL is enabled. The read and write timeout may be 0 for no timeout. func Start(ListenAddresses []string, UseSSL bool, CertificateFile, CertificateKey string, TimeoutRead, TimeoutWrite time.Duration) { if len(ListenAddresses) == 0 { return @@ -77,6 +78,7 @@ func Start(ListenAddresses []string, UseSSL bool, CertificateFile, CertificateKe } // startWebServer starts a web-server with given parameters and logs the status. If may block forever and only returns if there is an error. +// The certificate file and key are only used if SSL is enabled. The read and write timeout may be 0 for no timeout. func startWebServer(WebListen string, UseSSL bool, CertificateFile, CertificateKey string, Handler http.Handler, Info string, ReadTimeout, WriteTimeout time.Duration) { tlsConfig := &tls.Config{MinVersion: tls.VersionTLS12} // for security reasons disable TLS 1.0/1.1