RDP: Add handling for connect-time network autodetection
Quoting the main commit here:
Connect-time autodetection is an optional phase during the connection
sequence, where the server side can use the network autodetect PDUs to
determine the round trip time or the bandwidth.
This is helpful, since the initial measured round trip times after the
connection sequence are for some reason higher than they actually are
and than during the rest of the connection.
In addition to that, also measure the available bandwidth. For now, just
use the result to inform the client about the measured network
characteristics.
In the future, use the measured bandwidth also to determine, whether the
initial frame updates should be compressed more.
This will be necessary to maintain a stable round trip time, since when
the available bandwidth is fully used, the measured round trip time
suffers under it, making the frame controller unreliable.
To measure the network characteristics, use a state machine with two
phases:
1. Bandwidth measurement
2. Round trip time (RTT) measurement
Since it is not yet known how high or low the available bandwidth is,
measure the bandwidth in three phases. Start with small payloads first,
and then, if the measurement was accomplished in not a too long time
window, increase the size.
If the available bandwidth is low, transferring the payload would
already take too long, so don't try the higher payloads.
Low payloads are, however, unreliable for proper bandwidth measurement,
as the actual available bandwidth may be much higher, so try to increase
these payloads, when possible.
The payloads themselves are randomized data, generated by FreeRDP. In
theory, the maximum payload size is UINT16_MAX.
However, since the maximum TLS segment size is 16KiB and fast- and
slowpath PDUs need to be manually split, do not create too large
payloads, but multiple payloads of sizes, that are close to 16KiB.
After the bandwidth has been measured, emit several RTT requests to
measure the initial RTT values.
Then inform the client about the measured network characteristics. Some
clients, like mstsc, show a network indicator, when the server side
informs the client about the measured network characteristics.
Also hook up the Network Characteristics Sync PDU. The client can send
this PDU as response to short-circuit the connect-time network
autodetection, when an autoreconnect happened.
Depends on !193 (commits included here)
Built on top of !193 (commits included here)