0

I need to do following things:

1. Find the current network bandwidth.

2. Limit the bandwidth to download the file by 50%.

I did some research over this but i am not able to find any good way of doing this.

Like calculating the bandwidth by sending some data for some time and doing some arithmetic over it.

I was wondering if there is any better approach? Since this will take extra time(sending and receiving data+calculating bandwidth). Every time a download request comes i don't want to do it again and again.

1 Answers1

0

Fetch a quantum of data. Remember how long it takes. Sleep for the same amount of time.

Note that this isn't guaranteed to work for sufficiently small quanta, since the system's read-ahead will be working to keep the input flowing even when you're not asking for it.

ddyer
  • 1,792
  • 19
  • 26