Diagnose Your Network in China with Ping and Traceroute, which one is better?

2022/12/22 | 8 mins

If your organization is considering entering China, one of the first steps is to ensure that your current website is accessible from China. This step is not trivial since the Great Firewall of China (GFW) is known to block much traffic from outside its borders. However, even if your website displays correctly within China, there are other challenges that you should pay attention to. Possibly the biggest has to do with latency since it is one of the aspects that has the most significant impact on the user experience.

This article is the first in a series dedicated to connectivity testing (without physically being in China) for evaluating how your website performs.

Why is it essential to test the Internet connection?

A common mistake is to think in terms of advertised internet speed. This is true for any market or region, but even more so in China. 

For example, internet latency can affect website performance in several ways. High latency can cause delays in loading web pages or downloading files, and if we talk about streaming video, high latency can completely kill the user experience. On the other hand, packet loss can cause data to be lost or corrupted, and jitter can cause data to be delivered out of order, which can cause delays or errors in loading web pages or downloading files.

Simply put, when it comes to website performance, three aspects stand out above the rest:

Latency. In simple terms, you can think of latency as the time it takes data packets to travel from one endpoint to another, in this case, from your web server to the user's browser. It is measured in milliseconds.

Packet loss. It is the number of data packets that are lost during transmission. It is measured as a percentage. Data packets are commonly lost due to network errors, such as data corruption, physical damage to the infrastructure, or overloaded nodes. However, in China, there is an additional factor, the GFW. 

Click on the image to use our China Firewall testing tool

Corrupting packages is one of the common methods to censor the internet used by the GFW. This is serious since packet loss can significantly impact the quality of your internet connection. When data packets are lost, it can cause delays in loading web pages, streaming video, and gaming. In some cases, packet loss can even cause complete disconnection from the internet.

Jitter is the variation in the latency of data packets. It is measured in milliseconds.

Now that you understand why it is essential to test the Internet connection, it is time to learn how to do it.

Network Latency Test Tools and Packet Loss Tests

There are several ways to detect latency, packet loss, and jitter problems. Let's start with the simplest ones, which are based on commands executed from a terminal.

How does ping works?

Ping is one of the most basic commands that can be used from the command console. In principle, when you ping, you send a special type of packet, called an ICMP Echo Request to a specific IP address or URL and wait for a reply. When the ping command is successful, a reply from the IP address is returned, as well as the time in milliseconds that it took to receive the reply. 

If you remember the concept of latency from a moment ago, you could take the time it takes to receive the response as the latency. So, the further the source is from the destination, the higher the ping and therefore the latency.

Ping is a command available on major operating systems like Windows, macOS, and Linux. Its use is very simple; you just have to write ping and the target IP address or URL, i.e., ping 10.10.10.10

By default, ping performs one test per second for an indefinite amount of time. You can change this behavior by using the "-c" flag to indicate the number of pings and the "-i" flag to set the time interval for each request. The following image shows an example where ten requests of 0.1 seconds each are made.

The output shows the Ping statistics, including the packet loss percentage and minimum, average, and maximum response time (latency).

Although the Ping command offers data regarding latency, it is not exempt from certain limitations that we will discuss below.

Ping: advantages and limitations

No doubt that the main advantage of Ping is that it offers a straightforward way to test the latency of a particular IP address. It is also relatively fast since it uses a short, simple packet. However, one fundamental limitation of Ping is that it can only test whether an IP address is accessible, not whether it is running any particular service. Furthermore, Ping relies on the ICMP protocol, which the GFW often blocks.

Another notable disadvantage of using the Ping command from a console is that it doesn't provide much insight compared to a specialized synthetic testing tool like the one below.

Although it's hard to believe, the dashboard above makes extensive use of the Ping command to infer response time and latency.

How does traceroute work?

Like Ping, the traceroute command also sends ICMP packets to the destination IP address, but with one difference, these packets also contain a time to live (TTL) value. The TTL value starts out at 1 and is increased by each router the packet passes through. 

It works as follows: 

  • The first router the packet reaches sees that the TTL value is 1 and decrements it to 0. 
  • The router then sends an ICMP time exceeded message back to the origin of the request, where the traceroute program sees the ICMP message and knows that the first router is 1 hop away. 
  • Next, it sends out another packet with a TTL value of 2, which is answered by the next router but this time with a value of 1. 
  • This process is repeated until the packet reaches the destination address, from where it responds with an ICMP echo reply packet.

Once the process is complete, the traceroute program can map the packet's route no matter how complex the network is.

Something that traceroute has in common with Ping is that it is also effortless to use. Just type traceroute and the target IP address or URL as shown below.

Let's break down the results shown above.

  • The first column corresponds to the hop. In this example, the destination URL was reached after 14 hops.
  • The second column corresponds to the IP address of each hop. The first address is that of the machine that initiates the traceroute, and the last one is that of the URL/IP target.
  • The following three columns correspond to the round trip time (RTT) that it takes for each packet to go to the hop and return to the origin. In both Linux and Windows, by default, three packets are sent; hence there are three results per hop. Note that the RTT (latency) increases as you go from one hop to another. Also, note that the result looks very similar to that obtained with the Ping command.

Once the output of the traceroute command has been explained, it is time to review its pros and cons.

Traceroute: advantages and limitations

Let's start with the advantages. A key advantage of traceroute over Ping is that it lets you know which path packets take during their journey. In fact, many graphical tools allow you to visualize such a path. In addition, traceroute is a helpful tool for network administrators to diagnose network problems as it allows them to identify which hops are experiencing high latency or packet loss, something that is not possible with Ping.

Despite its advantages, traceroute also suffers from some limitations that we list below. 

Nodes discovery. Given the way traceroute works, when a node does not respond to the ICMP request, it will not be discovered. Returning to the example above, hops 8, 9, and 11 did not respond (response * * *), so identifying them is impossible.

Path discovery. Traceroute's simple working principle is also its biggest weakness. When you try to use this command on a target that uses a load balancer, the results can be misleading. This is because the packet can take different routes on each request.

Accurate metrics. In addition to what was discussed in the two previous points, for most nodes on the Internet, ICMP packets have low priority. In other words, the latency values returned by the traceroute command may be inaccurate and, therefore, cannot be considered a reliable metric.

In addition to the above, we must add that traceroute may not work if the destination host is behind a firewall, making it very difficult to carry out tests outside China.

Although this is a limitation shared by synthetic test tools, at least they offer an easier-to-understand representation than console output.

Ping vs. Traceroute, which is better?

At this point, you probably have doubts about which tool is best to use to diagnose your network and measure latency. For that reason, we have prepared the following table:

PingTraceroute
Latency MetricsPacket loss %RTT (latency) min, avg, max, standard deviation (mdev)Approximate number of hops to destinationIP address of the hops that respond to the requestRTT delayapproximate packet lossNetwork path (with the limitations described)
Test ImplementationSupported by most routers and computersSupported by most routers and computers
AdvantagesSimple to useSupported by major OSesQuite fastSimple to useSupported by major OSesRelatively fastProvides more visibility into the path packets take
LimitationsLimited accuracyOnly offer total RTT latency (does not give an idea of the path that the packets follow)Limited accuracyOnly offer RTT latency

Conclusion

During this article we have seen how Traceroute is a tool mainly used to trace the path of packets from a source to a destination. We have also discussed how the Ping command is useful for testing the reachability of a host and the round-trip time for messages sent from the source to the destination.

The bottom line is that both traceroute and ping can be used to measure latency, but traceroute will provide more information about the route taken by the packets and the round-trip time for each hop. In this sense, you can think of ping as the ideal tool to get a quick idea of the latency to a destination and traceroute as a tool with information that can be used for a more detailed diagnosis.

That being said, we have also mentioned that both ping and traceroute use ICMP packets, limiting their use for testing from outside of China. To overcome this problem, the ideal is to have a solution like GoClick China's.

Our dashboard is specially designed to provide your organization with detailed latency, packet loss, and jitter information. To find out more, contact us now; our specialists will be happy to answer all your questions.

Subscribe and get a great takeaway for building your organization's Chinese web presence!