如何在不使用文件的情况下计算C#中的下载和上传速度。 [英] How to calculate download and upload speed in C# without using file.

查看:86
本文介绍了如何在不使用文件的情况下计算C#中的下载和上传速度。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计算我们正在使用的互联网的下载和上传速度。

但我不想上传或下载文件以找出答案。



例如,http://beta.speedtest.net/ [ ^ ]



喜欢这个,需要以C#获得下载和上传速度。



建议。



什么我试过了:



我试过如何计算c#中的网络带宽速度 - Mohamed Mansour [ ^ ]有这个链接,但它给出了实际速度之间的差异。



还尝试使用Ping类如何在C#中使用Ping [ ^ ]。通过这个我们可以找到状态,地址,往返,但不知道找到上传和下载速度。

I need to calculate download and upload speed of internet which we are using.
But i don't want to upload or download the file to find out that.

For example , "http://beta.speedtest.net/"[^]

Like this, need to get the download and upload speed in C#.

Suggest on this.

What I have tried:

I tried How to calculate network bandwidth speed in c# - Mohamed Mansour[^] with this link but its giving difference between real speed.

Also tried with using Ping Class How to Use Ping in C#[^] . By this we can find out Status,Address,Roundtrip but dont know to find upload and download speed.

推荐答案

Ping不测量吞吐量和你用最小的做任何事情大量数据(例如,如果您可以计算这些事务并知道传输字节数,则可以考虑使用HTTP Get / Post来估计下行链路/上行链路吞吐量)。然而,这种方法是完全有缺陷的 - 不要浪费你的时间。



正如Richard MaxCutchan所说,你必须传输数据,如果估计是任何用途,您将需要转移合理的金额。合理多少钱?嗯,您传输的数据越多,您在所有分组数据网络(包括互联网)上实现的可变吞吐量的平均值就越高。这就是为什么你会看到像speedtest.net这样的站点的吞吐量估计在测试开始时波动很大,然后稳定到更长期的平均值。



还要记住,需要考虑延迟。也就是说,您触发上传/下载的请求与实际开始传输之间的延迟。如果您的测试使用大字节数,那么您可以忽略该时间延迟,否则您需要从吞吐时间中小心地消除它。



有一个非常一个名为iPerf的好工具(以及一个配有GUI的iPerf配套工具jPerf),可用于吞吐量测量。 iPerf允许您在网络上的任何位置设置服务器,该服务器将抽出数据字节(用于下载测试)或接收字节(用于上载测试),以及您希望作为客户端连接并执行下载/上载的任何设备。 iPerf日志包含您应该需要的所有内容。更多此处以及更多内容很容易找到。
Ping does not measure throughput and anything that you do using minimal amounts of data (e.g. you might consider using HTTP Get/Post to estimate downlink/uplink throughput if you can time those transactions and know the transfer byte counts). However such an approach would be totally flawed - don't waste your time on this.

As Richard MaxCutchan has said you have to transfer data, and if the estimate is to be of any use you're going to need to transfer a "reasonable" amount. How much is reasonable? Well, the more data you transfer the better you average over the variable throughput that's achieved on ALL packet data networks (including the internet). This is why you'll see the throughput estimates on sites like speedtest.net fluctuate wildly at the start of the test, then stabilise to a longer-term average.

Remember also that there's latency to consider. That is, a delay between your request to trigger an upload/download and the transfer actually beginning. If your test uses large byte counts then you may be able to ignore that time delay, otherwise you need to carefully eliminate it from the throughput time.

There is a very good tool called iPerf (and a companion tool jPerf which is iPerf with a GUI) that can be used for throughput measurement. iPerf allows you to setup a server anywhere on your network that will pump-out data bytes (for download test) or sink bytes (for upload test), with whatever device you wanted connected as a client and doing the downloads/uploads. iPerf logs contain all that you should need. More here and in plenty more can easily be found.


有2个上传/下载速度:

- 首先是实际速度,即在给定时间内传输的音量(数据大小)框架,它只需挂钩你要测试的设备。

- 第二是最高速度,要获得最大速度,你需要确保你处于最高速度,最好的方法是传输文件使接口饱和。

如果你没有使链接饱和,你就无法知道最大速度。
there is 2 upload/download speeds:
- First is actual speed, which is volume (size of data) transmitted in a given time frame, it just need to hook on the device you want to test.
- Second is maximum speed, to get maximum speed, you need to ensure that you are at maximum speed, and the best way is to have a file transmitted saturate the interface.
If you don't saturate the link, you can't know the maximum speed.


速度主要是由系统和目标系统之间的最慢路径设置。



但你无法确定最慢的路径。您的站点是否连接到互联网,中间某处或目的地互联网连接?



所有路径都取决于实际的网络工作负载。

inbetween pathes可能会改变(这就是互联网的工作方式)。

使用您的系统和目标系统,这取决于系统工作负载。



唯一有意义的值是您的互联网连接,通常由您的提供商指定(当不使用由设备设置的POT(普通老式电话)线路调制解调器时)。



使用DSL时,您可能会检查调制解调器是否提供实际连接的状态。当DSL调制解调器与DSLAM连接时(数字用户线接入多路复用器 - 维基百科 [ ^ ])他们进行一些线路检查并协商两个方向的最大速度。可以使用管理GUI和/或读取系统日志文件从调制解调器查询这些速度。
The speed is mainly set by the slowest path between your system and the destination system.

But you can't identify that slowest path. Is at your sites connection to the internet, somewhere inbetween, or the destination internet connection?

With all pathes it depends on the actual network workload.
The inbetween pathes may change (that is how the internet works).
With your system and the destination system it depends on the system workload.

The only meaningful value is that of your internet connection which is usually specified by your provider (when not using a POT (Plain Old Telephone) line modem where it is set by the device).

When using DSL you might check if your modem provides the status of the actual connection. When a DSL modem connects with the DSLAM (Digital subscriber line access multiplexer - Wikipedia[^]) they do some line checks and negotiate a maximum speed for both directions. These speeds may be queried from the modem using the administration GUI and/or reading the system log file.


这篇关于如何在不使用文件的情况下计算C#中的下载和上传速度。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆