We are working on Windows Desktop application in which we need to capture current internet Bandwidth. We are downloading a ZIP file multiple times sequentially but our results are not matching with Speed Test. We are capturing bytes received on ACTIVE network card, but sequential download doesn't provide expected result. We even tried parallel downloading of different files multiple times but failed.
We got success only when we downloaded different files in parallel and performed test using Speed Test simultaneously.
Now here are my few questions:
- Does bandwidth between TCP HOPS affects our bandwidth?
- Does traffic between TCP HOPS affects our bandwidth?
- How to effectively consume entire bandwidth using HTTP / TCP downloads and C# .NET?
- Does ISP throttles bandwidth per TCP Socket connection?
Does ISP provides bandwidth to http://www.speedtest.net? (Could be possible as it can always show expected result but other sites cannot)
for (int downloadCount = 0; downloadCount < iterations; downloadCount++) { try { string downloadUrl = GetUniqueDownloadUrl(); bool isValidUrl = Uri.IsWellFormedUriString(downloadUrl, UriKind.Absolute); if (true != isValidUrl) { return result; } // Download file and register total time to download file. Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); byte[] fileContent = webclient.DownloadData(new Uri(downloadUrl, UriKind.Absolute)); stopwatch.Stop(); double downloadTime = stopwatch.ElapsedMilliseconds / 1000; // Milliseconds to Seconds // Convert bytes to Mbits. fileSizeInMbits = fileContent.Length / 125000; // bytes to Megabits double speed = fileSizeInMbits / downloadTime; // speed in Mbps // Store speeds for average calculation. speeds.Add(speed); } catch (Exception e) { result.Error = e; break; } } } // Calculate average bandwidth for total successful downloads. double totalAvgSpeed = speeds.Average(); result.FileSizeInMB = fileSizeInMbits / 8; result.Speed = Math.Round(totalAvgSpeed, 2, MidpointRounding.AwayFromZero); return result; }