I had the following idea:
- Sender sends the data.
- Receiver waits a couple of seconds and then calculates the throughput rate / s
- Receiver sends the rate at which its receiving packets (bytes / s) to sender
- Sender calculates its rate of sending packets
- If the rate of sender is significantly higher, reduce it to match receiving rate.
Alternatively, a more advanced approach:
- Sender starts sending at a predefined min rate (eg. 1kb / s)
- Receiver sends the calculated receiving rate back to sender.
- If the receiving rate is the same as sending rate (taking latency into account) increase the rate by a set pct (eg. rate * 2)
- Keep doing this until the sending rate becomes higher than receiving rate.
- Keep monitoring the rates to account for changes in bandwidth increase / reduce rate if needed.
Disclaimer: im not network expert, this might not work for you.