1

Are there any facilities to enable me to limit bandwidth usage (rx) when utilizing Winsock (TCP)?

I have looked into QoS but, for one it seems overly complex and secondly much of the discussion revolves around a feature (RSVP) that isn't even available on post-Win2k platforms.

(Only interested in native solutions; no .NET or the like)

Emjayen
  • 113
  • 1
  • 8
  • Possible duplicate of: http://stackoverflow.com/questions/8000719/what-api-of-linux-windows-corresponds-to-limiting-network-download-upload-spee – selbie Dec 01 '11 at 07:43
  • See my answer on the link to the question I called out as a dupe. You can try QOS, but you may find it easier to just do your own throttling by controlling the rate at which winsock send() and recv() calls are made. – selbie Dec 01 '11 at 07:46
  • Yeah that was my alternate plan however it seems a tad inelegant as opposed to simply modifying the TCP window directly. Thanks for your input anyway. – Emjayen Dec 01 '11 at 09:05
  • Leaky bucket algorithm + Sleep? – Damon Dec 01 '11 at 11:25
  • @Damon Something similiar. Sleep's accuracy is insufficient. – Emjayen Dec 02 '11 at 00:00

1 Answers1

0

Set very small socket send and receive buffer sizes, such as 1k or less if the platform will allow it. That limits the bandwidth-delay product, which in turn limits the receive window, which in turn limits the throughput.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • I'm not using socket-level buffering. – Emjayen Dec 01 '11 at 09:05
  • @Matt.J Yes you are. You can't help it. The kernel provides a socket send buffer and a socket receive buffer. – user207421 Dec 01 '11 at 09:09
  • Yes, what's your point? Your solution relies on socket-level buffering which I just pointed out is disabled; access to the internal buffers in AFD are not accessible. – Emjayen Dec 01 '11 at 09:16
  • @Matt.J It isn't 'disabled'. It is an integral part of TCP, defined in the RFCs. An implementation of TCP could not function without send and receive buffers. You can control them via `setsockopt()` at the C level and via various higher level APIs. I don't see what AFD has to do with it. – user207421 Dec 01 '11 at 09:38
  • Seems like your understanding is limited to abstract models; I will clarify: SO_SNDBUF=0 SO_RCVBUF=0 How does your solution fit in now? – Emjayen Dec 01 '11 at 09:49
  • @Matt.J I still don't know what AFD has to do with it, although AFD certainly maintains send and receive buffers. But you said Winsock above, and Winsock has socket buffers too. Perhaps you need to clarify your question so that mortals who only understand 'abstract models' can actually understand it. Most of what you have just written is brand new to this thread. But if you already have buffer sizes of zero, somehow, you are already, somehow, adopting my suggestion. If that isn't adequate rate-limiting you will certainly need another solution on top. – user207421 Dec 01 '11 at 09:59
  • It was established in my original reply as to why your solution is not suitable and if you could answer my above question maybe we'd get somewhere. – Emjayen Dec 01 '11 at 10:03