开发者

How to test the speed for Socket?

开发者 https://www.devze.com 2023-02-01 09:40 出处:网络
I write a pro开发者_运维问答gram which can forward ip packets between 2 servers, so how to test the speed of the program ? thanks!There are a number of communication metrics that may be of interest to

I write a pro开发者_运维问答gram which can forward ip packets between 2 servers, so how to test the speed of the program ? thanks!


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":

Node 1:
    for n = 1 to MAXSIZE, step via n*=2
    send message of size n bytes
    receive a response of size n bytes

Node 2:
    for n = 1 to MAXSIZE, step via n*=2
    receive a message of size n bytes
    send response of size n bytes

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 sustainable n/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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号