Analyze and implement the speed function on the P1 router (can also be used for Jinshan speed measurement function)

Source: Internet
Author: User

Now all kinds of intelligent routers and some of the firewall software on the PC, all provide the network speed measurement function. The author has studied this and implemented this function on my router. Here's a summary.

General network speed Measurement, the main focus on two aspects: network latency and download rate

1. Network delay: That is, the client from sending a request message, to receive the response message, the time spent in the middle. The length of this time, can detect the transmission delay of network messages

2. Download rate: That is, the client to some download Service site (typically HTTP) for data download, test download rate.

These two data are more reliable than the broadband packages that operators have told them.

Let's talk about how I did it.

1. Network latency: The simple approach is to take advantage of Ping's own statistical functions. Issue a certain number of ping requests to see the AVG round-trip value obtained by the final statistic. Similar to the following:

Example ping–s 36–c www.baidu.com , you can get the output:

.......

Bytes from 180.97.33.107:seq=38 ttl=55 time=296.485 ms

Bytes from 180.97.33.107:seq=39 ttl=55 time=225.084 ms

---www.baidu.com ping statistics---

Packets transmitted, packets received, 2% packet loss

Round-trip Min/avg/max = 4.120/144.129/1052.541 ms

Red, that's a delay.

Mainly talk about the download rate test

2. Download Rate test:

Analysis of the P1 and Jinshan speed of the message, found that the use of multi-threaded +http download, to some (Jinshan is to 6 addresses) to provide fixed download links to the site, to initiate a real download request, and in the fixed test time estimated download rate: Download message size/test time

So, I developed a test program: set multiple URL download target (also 6, and use the target address of Jinshan), using Pthread multithreaded +socket programming, constructs the HTTP concurrent GET request, and loops over the received data message (Note that For statistical accuracy, you need to remove the HTTP headers from the back packet. In addition, a timer is set up that sets the timing time to be the test duration. Terminates all threads and ends the socket when the timer expires. The rate at which each URL is downloaded is counted and summed. That's the test rate for this round.

After simple verification, the test results of this program, with Jinshan, 360P1 test results, on the same accuracy.

Need code, can contact Oh ^_^

Analyze and implement the speed function on the P1 router (can also be used for Jinshan speed measurement function)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.