diff --git a/include/freerdp/autodetect.h b/include/freerdp/autodetect.h index 40bff7150..3f69f9254 100644 --- a/include/freerdp/autodetect.h +++ b/include/freerdp/autodetect.h @@ -43,7 +43,8 @@ struct rdp_autodetect ALIGN64 UINT32 netCharBandwidth; /* 5 */ ALIGN64 UINT32 netCharBaseRTT; /* 6 */ ALIGN64 UINT32 netCharAverageRTT; /* 7 */ - UINT64 paddingA[16 - 8]; /* 8 */ + ALIGN64 BOOL bandwidthMeasureStarted; /* 8 */ + UINT64 paddingA[16 - 9]; /* 9 */ ALIGN64 pRTTMeasureRequest RTTMeasureRequest; /* 16 */ ALIGN64 pRTTMeasureResponse RTTMeasureResponse; /* 17 */ diff --git a/libfreerdp/core/autodetect.c b/libfreerdp/core/autodetect.c index 7dca1e902..c63677820 100644 --- a/libfreerdp/core/autodetect.c +++ b/libfreerdp/core/autodetect.c @@ -322,6 +322,12 @@ static BOOL autodetect_recv_bandwidth_measure_start(rdpRdp* rdp, wStream* s, AUT rdp->autodetect->bandwidthMeasureStartTime = GetTickCount(); rdp->autodetect->bandwidthMeasureByteCount = 0; + /* Continuous Auto-Detection: mark the start of the measurement */ + if (autodetectReqPdu->requestType == 0x0014) + { + rdp->autodetect->bandwidthMeasureStarted = TRUE; + } + return TRUE; } @@ -373,6 +379,12 @@ static BOOL autodetect_recv_bandwidth_measure_stop(rdpRdp* rdp, wStream* s, AUTO /* Add the payload length to the bandwidth measurement parameters */ rdp->autodetect->bandwidthMeasureByteCount += payloadLength; + /* Continuous Auto-Detection: mark the stop of the measurement */ + if (autodetectReqPdu->requestType == 0x0429) + { + rdp->autodetect->bandwidthMeasureStarted = FALSE; + } + /* Send a response the server */ responseType = autodetectReqPdu->requestType == 0x002B ? 0x0003 : 0x000B; diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 914140b7c..3b2bb625c 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -1001,6 +1001,11 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) if (rdp->disconnect) return 0; + if (rdp->autodetect->bandwidthMeasureStarted) + { + rdp->autodetect->bandwidthMeasureByteCount += length; + } + if (rdp->settings->DisableEncryption) { if (!rdp_read_security_header(s, &securityFlags)) @@ -1096,6 +1101,11 @@ static int rdp_recv_fastpath_pdu(rdpRdp* rdp, wStream* s) return -1; } + if (rdp->autodetect->bandwidthMeasureStarted) + { + rdp->autodetect->bandwidthMeasureByteCount += length; + } + if (fastpath->encryptionFlags & FASTPATH_OUTPUT_ENCRYPTED) { UINT16 flags = (fastpath->encryptionFlags & FASTPATH_OUTPUT_SECURE_CHECKSUM) ? SEC_SECURE_CHECKSUM : 0;