如何测试Socket的速度?
我写了一个程序,可以在2个服务器之间转发ip数据包,那么如何测试程序的速度呢?谢谢!
I write a program which can forward ip packets between 2 servers, so how to test the speed of the program ? thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的潜在用户可能会对许多通信指标感兴趣。
延迟是发送消息的时间量,对于共置设备通常以微秒为单位,对于所有其他情况以毫秒为单位。它通常被称为“零字节延迟”,意思是传输消息的元数据所需的时间。越低越好。
带宽以每秒位数来衡量。它通常被称为“峰值带宽”,可以通过在线发送大量数据来获得。越高越好。
CPU 利用率是传输消息所需的 CPU 时间的百分比。可以卸载消息传输的网络协议利用率较低,这意味着通信可以“重叠”用户应用程序中的某些其他计算,从而具有隐藏延迟的效果。越低越好。
所有这些都可以通过 ping 测试的变体来测量,通常称为“ping-pong”:
还有一个“ping-ping”测试,其中两个节点在同一时间。这需要设置非阻塞通信。
只需输出
n
以及每次迭代所需的时间。第一次是零字节延迟。最大的可持续n/时间
是带宽(转换为每秒位数以成为行业标准)。您还可以测量运行较大迭代所需的 CPU 利用率,但这对于完全不同的问题来说是一个棘手的话题。There are a number of communication metrics that may be of interest to your potential users.
Latency is the amount of time to send a message, usually quoted in microseconds for co-located devices and in milliseconds for all other scenarios. It is usually quoted as the "zero-byte latency", meaning the time required to transmitted the meta-data of a message. Lower is better.
Bandwidth is measured in bits per second. It is often quoted as "peak bandwidth" and can be obtained by sending a massive amount of data over the line. Higher is better.
CPU utilization is the percent of CPU time required to transmit a message. Network protocols that can offload a message's transmission have low utilization, which means that the communication can "overlap" some other computation in the user's application, which has the effect of hiding latency. Lower is better.
All of these are measured simply by a variation of the ping test, usually called the "ping-pong":
There's also a "ping-ping" test, in which both nodes write to each other at the same time. This requires non-blocking communication to set-up.
Just output
n
and the time required for each iteration. The first time is the zero-byte latency. The largest sustainablen/time
is the bandwidth (convert to bits per second to be industry standard). You can also measure the CPU utilization required to run the larger iterations, but that's a tricky topic for a whole different question.看看 iperf。如果你用谷歌搜索一下,你可以在 http://sourceforge.net/projects/iperf/ 找到它会找到它的教程。您可以查看源代码,可能会了解他是如何做到这一点的一些好主意。我用它进行日常测试,它非常强大
Take a look at iperf. You can find it at http://sourceforge.net/projects/iperf/ If you google around you will find tutorials for it. You can look at the source and might get some good ideas of how he does it. I use it for routine testing and it is quite robust