From ec3cbc6748a4d39086ca609625b5ffdfc8e5c90d Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 2 Sep 2016 19:08:45 -0500 Subject: [PATCH] Implement option to tune Marinetti for high throughput. This sets the tcpTUNEIPUSERPOLLCT and tcpTUNEIPRUNQCT tuning parameters to 10 (the maximum) instead of the default of 2. This makes Marinetti process more incoming data at once and significantly increases throughput. (Actually, current versions of Marinetti only seem to use tcpTUNEIPUSERPOLLCT, but we set both for compatibility with any future versions that actually use tcpTUNEIPRUNQCT.) --- vncsession.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++---- vncview.cc | 3 +++ vncview.h | 1 + 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/vncsession.cc b/vncsession.cc index 4c20396..e3998ba 100644 --- a/vncsession.cc +++ b/vncsession.cc @@ -66,6 +66,8 @@ static BOOLEAN GetIpid (void); static BOOLEAN DoVNCHandshaking (void); static BOOLEAN DoDES (void); static BOOLEAN FinishVNCHandshaking (void); +static void TuneMarinetti (void); +static void UnTuneMarinetti (void); #define buffTypePointer 0x0000 /* For TCPIPReadTCP() */ #define buffTypeHandle 0x0001 @@ -88,6 +90,8 @@ void DoConnect (void) { colorTablesComplete = TRUE; CloseConnectStatusWindow(); } + + TuneMarinetti(); /* Get server & password */ @@ -98,13 +102,13 @@ void DoConnect (void) { if (ConnectTCPIP() == FALSE) { SysBeep(); AlertWindow(awResource, NULL, noTCPIPConnectionError); - return; + goto errorReturn; } if (GetIpid() == FALSE) { SysBeep(); AlertWindow(awResource, NULL, badGetIpidError); - return; + goto errorReturn; } if (DoVNCHandshaking() == FALSE) { @@ -115,14 +119,14 @@ void DoConnect (void) { AlertWindow(awResource, NULL, badHandshakingError); else alerted = FALSE; - return; + goto errorReturn; } if (FinishVNCHandshaking() == FALSE) { CloseConnectStatusWindow(); InitCursor(); AlertWindow(awResource, NULL, badOptionNegotiationError); SysBeep(); - return; + goto errorReturn; } InitVNCWindow(); @@ -136,6 +140,11 @@ void DoConnect (void) { myEvent.wmTaskMask = 0x001D79FE; /* don't let TaskMaster process keys */ InitMenus(noKB); vncConnected = TRUE; + return; + +errorReturn: + UnTuneMarinetti(); + return; } /******************************************************************* @@ -704,6 +713,49 @@ static BOOLEAN FinishVNCHandshaking (void) { } +/* Marinetti tuning structures */ +static tuneStruct oldTune; +static tuneStruct newTune; + +/********************************************************************** +* TuneMarinetti() - Set Marinetti tuning options for max throughput +**********************************************************************/ +void TuneMarinetti (void) { + if (tuneMarinetti) { + TCPIPGetTuningTable(&oldTune); + + /* Tune to process max number of datagrams each time polled */ + newTune.tcpTUNECOUNT = 10; + newTune.tcpTUNEIPUSERPOLLCT = 10; + newTune.tcpTUNEIPRUNQFREQ = oldTune.tcpTUNEIPRUNQFREQ; + newTune.tcpTUNEIPRUNQCT = 10; + newTune.tcpTUNETCPUSERPOLL = oldTune.tcpTUNETCPUSERPOLL; + TCPIPSetTuningTable(&newTune); + } +} + +/********************************************************************** +* UnTuneMarinetti() - Set Marinetti tuning options back to old values +**********************************************************************/ +void UnTuneMarinetti (void) { + tuneStruct currentTune; + + if (tuneMarinetti) { + TCPIPGetTuningTable(¤tTune); + + /* Restore original tuning table unless something else seems to have + * modified it in the meantime. + */ + if ( currentTune.tcpTUNEIPUSERPOLLCT == newTune.tcpTUNEIPUSERPOLLCT + && currentTune.tcpTUNEIPRUNQFREQ == newTune.tcpTUNEIPRUNQFREQ + && currentTune.tcpTUNEIPRUNQCT == newTune.tcpTUNEIPRUNQCT + && currentTune.tcpTUNETCPUSERPOLL == newTune.tcpTUNETCPUSERPOLL) + { + TCPIPSetTuningTable(&oldTune); + } + } +} + /********************************************************************** * CloseTCPConnection() - Close the TCP connection to the host **********************************************************************/ @@ -716,5 +768,6 @@ void CloseTCPConnection (void) { TCPIPLogout(hostIpid); } while (toolerror() == terrSOCKETOPEN); CloseConnectStatusWindow(); + UnTuneMarinetti(); InitCursor(); } diff --git a/vncview.cc b/vncview.cc index 2e6b154..2121a82 100644 --- a/vncview.cc +++ b/vncview.cc @@ -87,6 +87,7 @@ BOOLEAN allowClipboardTransfers = TRUE; BOOLEAN emulate3ButtonMouse = TRUE; BOOLEAN viewOnlyMode = FALSE; BOOLEAN useHextile = FALSE; +BOOLEAN tuneMarinetti = TRUE; char vncServer[257]; char vncPassword[10]; @@ -238,6 +239,8 @@ static void HandleControl (void) { break; case chkEmul3Btn: emulate3ButtonMouse = !emulate3ButtonMouse; break; case chkViewOnly: viewOnlyMode = !viewOnlyMode; break; + case chkTuneMarinetti: + tuneMarinetti = !tuneMarinetti; break; case txtTransfers: allowClipboardTransfers = !allowClipboardTransfers; SetCtlValueByID(allowClipboardTransfers, newConnWindow, chkClipboard); break; diff --git a/vncview.h b/vncview.h index 0fd6086..ccc65c0 100644 --- a/vncview.h +++ b/vncview.h @@ -15,6 +15,7 @@ extern BOOLEAN allowClipboardTransfers; extern BOOLEAN emulate3ButtonMouse; extern BOOLEAN viewOnlyMode; extern BOOLEAN useHextile; +extern BOOLEAN tuneMarinetti; extern char vncServer[257]; extern char vncPassword[10];