I would like to make the following happen:
- My application runs on a Windows machine (call it application A).
- I can modify the source code of application A to introduce bandwidth throttling.
- I would like to be able to reuse my bandwidth throttling code and drop it into any other applications that I have (in other words, I would like to try and throttle the bandwidth on an application domain level in order to not have to re-factor existing applications for bandwidth throttling).
- I want to throttle A's cumulative upload and download speed separately. For example, if A has a maximum of 5 Kbps allotted to upload, then all of A's upload streams will be capped to a cumulative amount of 5 Kbps.
My requirements:
- I cannot use a kernel-mode driver.
- I need to add throttling on an application domain level.
I have tried to research into this, especially on Stack Overflow but could not find anything useful for my case:
- I have seen this example of using a ThrottledStream class wrapper around a Stream object that will introduce throttling when used, but I need this to be at a domain level; taking this approach is problematic because it would require me to refactor a lot of existing code in other applications.
- I have seen this question who's answer speaks about using the Windows Filtering Platform API. Unfortunately, a requirement I have is that I absolutely can't use a kernel-mode driver to accomplish this, and my understanding is that the WFP API requires one.
Does anyone know a way to implement my specific bandwidth throttling requirements in order to throttle applications on an application domain level?