Optimize sbws for congestion control
In #40125 (closed), we added the ability for sbws to use only Exit relays that support congestion control as the Exit hop. In this way, it will use congestion control to measure all relays (since it measures only the first hop, which does not need to support congestion control for the Exit to use it).
This should give us much more accurate measurements, and is for the most part a decent alternative to #40022 (closed). I believe it will also mostly solve location-dependent issues of bandwidth auths (analysis#13, onbasca#111).
However, three further optimizations can help us both further reduce the dependency on location of the bw auths, and improve their accuracy:
- sbws should use upload to bwauth http servers, instead of download
- sbws should track the CIRC_BW event to only start measuring upload bandwidth once the CIRC_BW field SS=0.
- sbws should monitor STREAM events during upload, and if it ever gets STREAM STATUS=XOFF_RECV, it knows that the bwauth httpd server is too slow to properly measure some relays
Using upload instead of download allows the congestion control algorithms to be under control of the sbws Tor client, instead of the Exit relay. This means that sbws can know when "slow start" has exited. "Slow start" is the initial ramp-up phase of congestion control to the full circuit capacity, and the duration of this rampup is still path and latency dependent. By removing this period of time from the stream bandwidth calculation, we will only measure the stream throughput, and not the latency-bound startup period.
Furthermore, in the third optimization, if sbws watches for XON/XOFF, it can tell if the bwauth servers themselves are too slow. XON/XOFF will only be sent if the connection from the Exit to the bwauth server is slower than Tor. These datapoints can help us know if any of our bandwidth auths need to be moved to higher capacity servers.
All of these optimizations do require that the bw auth servers support upload, so those http servers will need to be configured to accept HTTP POST/PUT (which may not currently be the case). This also means that the sbws code will have to use HTTP POST/PUT instead of HTTP GET.
Putting these three optimizations behind a Tor consensus parameter value "bwscanner_cc=2" will allow us to test their effects by toggling between "bwscanner_cc=1" and "bwscanner_cc=2". So the bw http servers should retain the ability to do HTTP GET.