0

I have a number of processes which are communicating between cloud and my application. Now I want to assign bandwidth to those processes through my code only. after going through some links to find out how to do that. And came up with this solution : https://www.codeproject.com/Articles/18243/Bandwidth-throttling

If there is any other way in which i can achieve this Bandwidth throttling, Please let me know. Any reference documents or links regarding this will be very much helpful.

manlio
  • 18,345
  • 14
  • 76
  • 126
  • what have you tried? can you show some code, especially the part where you handle the communication? https://stackoverflow.com/help/how-to-ask – BNT Nov 30 '17 at 07:17
  • I want to find some logic before start developing the Bandwidth throttling concept. I understood how to achieve that by going through the link i posted. I just wanted to know if there is any other way we can achieve Bandwidth throttling . – Sumana Bagchi Nov 30 '17 at 07:27
  • Had a short glance on your link. I don't know so much details about network programming but a rather simple idea beyond this would be: Insert [`sleep()`](http://en.cppreference.com/w/cpp/thread/sleep_for)s inbetween the loops which write to network sockets (assuming that each communication is in its own thread or process). You could tune the bandwidth by adjusting the sleep time. If multiple communications happen in same process/thread then you probably need something like a scheduler and send-queues which can be built from `std` containers... – Scheff's Cat Nov 30 '17 at 09:06

1 Answers1

0

You can try the below techniques,

  1. You can define a desired data transfer rate and a current transfer rate. Current transfer rate depends upon the number of bytes that you can per sec send/receive to/from the cloud, you can increase/decrease the Current transfer rate by a scale factor X but this should not increase beyond desired transfer rate. You can make a custom class on socket class to make your read/write functions.

  2. Second one is a predefined amount of data for only which you will execute a read/write operation on the socket. You can consider this amount of data as a unit/token which qualifies for a read/write operation. This technique also you can add to your custom class.