My need for the application is to limit the bandwidth in the console application.
Please suggest something according to the need.
Thanks in advance.
What I have tried:
I have tried something to get the average speed till now. I also tried Throttling Stream class, but didn't found something related as i am new to this.
Kindly suggest me some logic for that.
public static void ShowInterfaceSpeedAndQueue()
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties properties = adapter.GetIPProperties();
IPv4InterfaceStatistics stats = adapter.GetIPv4Statistics();
Console.WriteLine(adapter.Description);
Console.WriteLine(" Speed .................................: {0}",
adapter.Speed);
Console.WriteLine(" Output queue length....................: {0}",
stats.OutputQueueLength);
}
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
WebClient webClient = new WebClient();
string address = "ftp://speedtest:speedtest@ftp.otenet.gr/test10Mb.db";
var uri = new Uri(address);
webClient.DownloadFile(uri, "D:\\Sample3.db");
//Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
string time = Convert.ToString(stopwatch.Elapsed);
double timeInSecond = TimeSpan.Parse(time).TotalSeconds;
int speed = 10240 / Convert.ToInt32(timeInSecond);
Console.WriteLine("Average Download speed: " + speed + "kbps");
}