AhFei

AhFei

简洁的写作需要勇气

VPS Network Testing and Long-term Monitoring

For a server, a high-quality network connection ensures the maximum connectivity between the machine and the local network. Due to different network environments, the performance of the same server may vary significantly. Therefore, to achieve the best experience, it is necessary to conduct network testing and comprehensive comparisons locally to confirm. Network testing can be divided into two categories:

  1. Instantaneous testing, including latency, packet loss, jitter, upstream and downstream bandwidth.
  2. Long-term testing, which allows you to view the network conditions over a period of days, months, or years, including latency, packet loss, and jitter.

The following are the main indicators for measuring network conditions.

  • Bandwidth: Refers to the maximum rate at which data can be transmitted from one point to another within a specific time range, usually measured in bits per second (bps). Higher bandwidth means more data can be transmitted, which is particularly important for data-intensive services.
  • Throughput: Refers to the amount of data successfully transmitted within a unit of time. It is limited by the network bandwidth and other factors such as error rate, which refers to the rate of error data packets caused by noise, interference, etc., during the transmission process.

Upstream and downstream bandwidth can be tested using iperf3 or LibreSpeed, which is easier to operate.


  • Latency: Latency refers to the time it takes for data to travel from the source to the destination, usually measured in milliseconds (ms). Low latency is crucial for applications that require real-time response, such as online gaming, voice or video calls, etc.
  • Round Trip Time (RTT): RTT is the total time it takes for a data packet to be sent from the sender to the receiver and then returned to the sender.
  • Packet Loss Rate: Packet loss rate refers to the proportion of lost data packets during the transmission process from the sender to the receiver. High packet loss rate may result in unstable network connections and affect the integrity of data transmission.
  • Jitter: Jitter refers to the variation in latency, i.e., the inconsistency in the arrival time of data packets.
  • Availability: Availability refers to the ratio of time during which the network can function properly and provide services. High availability means more reliable network services and reduced downtime.

Latency, packet loss, jitter, and long-term data are more valuable for monitoring network conditions during peak and off-peak periods in a day. This can be achieved using SmokePing.

Depending on the specific application scenarios and requirements, certain indicators may be more important than others. For example, for real-time communication, latency and jitter are more important than bandwidth, while for file transfer, bandwidth and throughput are more important.

iPerf3#

iPerf3 is a professional network testing tool based on TCP/IP and UDP/IP protocols. It is used to measure the network bandwidth between two network nodes on TCP and UDP ports, and can also provide statistical information such as network latency and packet loss rate.

When working, iPerf3 requires one side of the test to act as the server and the other side as the client. The command to start the program is the same, but different parameters are used to distinguish the working mode. Usually, the server side is started first to listen on a specific port, and then the client side executes the corresponding command to start the test.

Installation#

Install iPerf3 on both machines that need to be tested.

Download links for all platforms: iPerf - Download iPerf3 and original iPerf pre-compiled binaries

For the Windows version of iPerf, download and extract it, and then run it directly in the command prompt.

For Linux:

sudo apt-get install -y iperf3

It will prompt whether to run as a daemon, select "no".

Once you are familiar with the basic working principles, you can refer to the parameter instructions directly without searching for information.

iperf3 --help

Using iPerf3 as a Server#

Start the iPerf3 server.

iperf3 --server -i 10 -p 19302
  • -s, --server: Start iPerf3 as a server.
  • -i 10: Set the reporting interval to 10 seconds, output the test results every 10 seconds.
  • -p 19302: Specify the port number to use as 19302. Change this port number as needed.

Multiple clients cannot test simultaneously.

Run in the background, even if SSH is disconnected.

iperf3 --server -D -i 10 -p 19302 --logfile ./iperf.log
  • -D, --daemon: Run iPerf3 in the background as a daemon.
  • --logfile ./iperf.log: Record the output log of iPerf3 to the specified file ./iperf.log.

Using iPerf3 as a Client#

Run iPerf3 to upload data to the server for testing, run for 60 seconds.

iperf3 --client 192.168.1.51 -p 19302 -t 60 -f M -P 1 --get-server-output
  • -c, --client 192.168.0.18: Connect to the server with the IP address 192.168.0.18.
  • -p 19302: Specify the port number to use as 19302.
  • -t 60: Set the test duration to 60 seconds.
  • -f M: Set the bandwidth unit to megabytes per second (Mbps).
  • -P 1: Use 1 concurrent connection for testing.
  • --get-server-output: Get the output information from the server.

In actual use, I prefer to configure variables first and then perform the test, which makes it easier to change the server IP and port.

server_ip=52.16.84.15
server_port=19302
iperf3 -c ${server_ip} -p ${server_port} -t 60 -f M -P 1    # Upload to the server

This command is similar to the first command, but by adding the -R parameter, it performs a reverse test, which means uploading speed test from the server to the client.

iperf3 -c ${server_ip} -p ${server_port} -t 60 -f M -P 1 -R   # Download from the server
  • -R: Reverse test, which means uploading speed test from the server to the client, similar to the speed when downloading from the client.

LibreSpeed#

LibreSpeed is a browser-based tool that allows you to test the download speed, upload speed, ping, and jitter between your current network and a VPS. It can be used on any device with a browser.

GitHub: librespeed/speedtest: Self-hosted Speedtest for HTML5 and more. Easy setup, examples, configurable, mobile friendly. Supports PHP, Node, Multiple servers, and more (github.com)

DockerHub: adolfintel/speedtest - Docker Image | Docker Hub, built based on the above project.

You need to install Docker in advance, and then run the following command:

docker run -d -e MODE=standalone -p 88:80 -it --name speedtest adolfintel/speedtest:latest

Access http://ip_addr:88 in your browser to test the connection quality between your local network and the server network. Replace ip_addr with the address of the monitoring server.

image.png

After the test, stop the container and then delete the container and image (478MB, why so big (〝▼皿▼) ).

docker stop speedtest && docker rm speedtest && docker rmi adolfintel/speedtest

SmokePing#

SmokePing is a powerful and flexible network latency monitoring tool that allows you to view the results graphically on a web page. AhFei uses it on the "Portable Server" to monitor the network conditions between the current network and the VPS no matter where he goes.

Official website: SmokePing - About SmokePing (oetiker.ch)
GitHub: oetiker/SmokePing: The Active Monitoring System (github.com)

Docker image built by linuxserver:

image.png

image.png

SmokePing can be used to test various aspects of the network, not just ping. Here are some commonly used tools:

  1. FPing: Similar to ping, used to measure the latency of ICMP Echo requests, the most common and default probe.
  2. EchoPingHttp: Similar to FPing, but it can also measure the latency of HTTP requests.
  3. SSH: Used to measure the latency of connecting to a remote server via SSH. SSH may also be blocked, sometimes SSH cannot be connected, or it is not using port 22, but the webpage can be opened smoothly.
  4. DNS: Used to measure the latency of DNS resolution.
  5. SMTP: Used to measure the latency of sending SMTP emails.
  6. TCP: Used to measure the availability and response time of TCP ports.
  7. cURL: HTTP, HTTPS, FTP, etc., with more custom settings, request headers, etc.
  8. FPing6: IPv6.

Standalone Mode#

Installation steps: Installation and Configuration of SmokePing, a Network Latency Monitoring Tool - 技焉洲 (vfly2.com)

Master-Slave Mode#

In master-slave mode, the slave side does not start the web interface and can synchronize the configuration from the master side. The test results of the slave side can be viewed on the master side.

Instructions: Enable SmokePing Master-Slave Mode Based on LinuxServer Images - 技焉洲 (vfly2.com)

The second "from Home to vfly2" is the data monitored by the smokeping deployed on the home server.

image


Original article link: https://technique.vfly2.com/2023/07/vps-network-testing-long-term-monitoring/

Copyright Notice: All articles on this blog are original works by AhFei, licensed under CC BY-NC-SA 4.0. Please indicate the source 技焉洲 (technique.vfly2.com) when reprinting.

Stay updated with clear and beneficial practical skills. Feel free to subscribe via RSS or follow @[email protected] on platforms that support ActivityPub to receive push notifications for new articles.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.