8

Let's say I'm building my own download accelerator.

Let's simplify it to the point where:

  • my code runs at 3rd party whose network parameters I cannot control
  • an item is downloaded from a single IP
  • number of parallel range transfers is adjustable
  • there will be many transfers to learn ideal parameters
  • client runs Linux
  • server is outside my control
  • path is over WAN and download is over HTTPS
  • downloaded segments are large

How do I measure if enough connections are used to saturate the path between client and server?

What bits from getsockopt(..., TCP_INFO) are actually useful?

How fast can I adjust to varying network conditions?

It's possible to measure CPU and memory pressure on a client system, how about network pressure?

Mike Pennington
  • 41,899
  • 19
  • 136
  • 174
Dima Tisnek
  • 11,241
  • 4
  • 68
  • 120
  • Mike, your answer correctly infers that what I need is PABW. However it only mentions it, without practical details. As stated in the question, `server is outside my control`, thus I cannot use `yaz`. – Dima Tisnek Nov 20 '14 at 07:33
  • 1
    I wish you luck with your endeavor; however I have lost interest in answering any more questions about this problem. – Mike Pennington Nov 26 '14 at 11:20
  • 1
    Given that a single TCP connection with large windows or small RTT can saturate any network link, I don't see what benefit you expect from multiple TCP sessions. Each new piece will begin with slow-start and so have a lower transfer-rate than an established connection would have. – Brian White Nov 27 '14 at 17:21
  • 1
    I agree with @BrianWhite. This question, as written, appears to demonstrate a big misunderstanding about how TCP networks operate. – theMayer Nov 28 '14 at 01:27
  • @BrianWhite and +theMayer, true in theory but not in practice. Intercontinental traffic is throttled per connection and not e.g. per ip pair. Surely 1MB/s does not saturate the undersea link :P In my case server itself is not known to throttle downloads. – Dima Tisnek Nov 30 '14 at 17:51
  • 2
    @qarma, networks typically do *not* do deep packet inspection to shape traffic based on a "connection". Therefore it does not matter if the packets are part of a single connection or multiple connections, the result will be the same. Also, anything that wants to throttle traffic will find a way regardless of how many different connections are used. – Brian White Dec 05 '14 at 16:41
  • 1
    To test whether a black-box link is at saturation, it would seem that one would have to keep adding traffic until bandwidth stopped increasing proportionately. Ie, one would have to saturate the link. I'm not sure that would be a good idea. – Andras Dec 21 '14 at 21:36

1 Answers1

2

The answer is very simple: One TCP connection is sufficient to saturate the path between client and server.

At least, that is true with standard TCP/IP protocols and standard network devices between the client and server. If you have some devices in the path that are doing some sort of customized processing that is "throttling" individual TCP connections then maybe the answer is different. But in that case it's impossible to answer unless you specify exactly what that custom processing is. As others have commented, in most cases network traffic shaping or limiting is probably being done based on IP addresses rather than on the TCP headers, so creating additional TCP connections isn't going to help. If your case is different, that might be interesting to hear about - please explain further.

In my opinion (just an opinion, you may disagree, of course) the real answer to a question about building a custom "download accelerator" is: Don't do that. TCP works very well just as it is. Apart from a few special cases (e.g. SCPS-TP) you are unlikely to improve TCP performance by playing tricks with multiple connections or messing with socket options. And if you do manage to improve performance, you are probably doing it at the expense of degrading overall network performance for other users. That's ill-advised.

Duncan
  • 507
  • 3
  • 14
  • My practical experience shows that two long downloads achieve better throughput that one; It scales well to about 10 connections (last mile bandwidth). It's as if someone caps intercontinental traffic to ~1MB/s (.5..2. depending on time of day). I don't know who, but traffic within each continent is OK. Case in point, speedtest.net uses 4 connections to download and 2 to upload. Such cap may even be a pragmatic approach to ensuring SLA across customers... – Dima Tisnek Nov 17 '15 at 11:51