0

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:

  1. Does bandwidth between TCP HOPS affects our bandwidth?
  2. Does traffic between TCP HOPS affects our bandwidth?
  3. How to effectively consume entire bandwidth using HTTP / TCP downloads and C# .NET?
  4. Does ISP throttles bandwidth per TCP Socket connection?
  5. 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;
    }
    
D Deshmane
  • 1,125
  • 4
  • 15
  • 27
  • Now here are my few questions: 1) what is the difference between your method and speed test 2) where is the code that you use to download the file and calculate the speed? – Paweł Łukasik Feb 07 '17 at 05:36
  • @PawełŁukasik I have added the code snippet that computes the bandwidth. Please share your thoughts. – D Deshmane Feb 07 '17 at 06:26

1 Answers1

2

There's no such thing as internet "speed" there's only speed between 2 hosts, if you have 1 computer on gigabit ethernet and a server also on gigabit ethernet, even if just 1 node on the way is saturated speed will go down, when you use speedtest.net it has a lot of close servers (including likely one at your isp) so you're going to get a very positive estimate.

And if your isp throttled you'd see it on speedtest just the same.

The only thing to remember is that downloading a file from a server will only give you an estimate of the speed TO/FROM that server, and not an "internet speed" which is a concept that doesn't really exist to begin with.

Ronan Thibaudau
  • 3,413
  • 3
  • 29
  • 78