Ping is a command used to measure the latency between two devices on a network. The ping command is available on every operating systems, and many online games display a visible ping you can use to understand latency.
Ping is just a measure of the latency we feel in everything we do online, whether it’s clicking a link, posting a status update, sending a message, playing a game, uploading a file, streaming an online video, or anything else. If you’re using a website and it takes a long time to load a new page every time you click a link, you’re probably experiencing a high ping to that site. If it’s fast, you probably have a low ping.
What Ping Is Used For
Ping isn’t just a measure of “performance”. Specifically, it’s a measure of the latency between your computer and a remote device. A ping tells you the time it takes for a single packet to leave your computer, reach a remote server, and then return to you.
Have you ever noticed that, when you click a link on a web page, the new web page doesn’t load instantly? Instead, there’s a small delay — this is latency. Your computer has to request the new page and have it sent back to you, and it takes a small amount of time for every packet to travel between your computer and the remote computer. Ping lets you measure this latency.
This is very perceptible in online games. For example, if you’re playing a game with a 20 ms ping, you should have very low latency. Actions you take appear to take place in the game near instantly. If you have a higher ping like 200 ms, actions you take will be noticeably delayed and you won’t be able to keep up with other people playing the game.
This is why ping is displayed prominently in many multiplayer games. It helps you understand how good your connection is and what kind of experience you should expect on the server. A lower ping is always better — it means lower latency, which is faster communication between you and the remote server. This applies to everything you do online — whether you’re playing an online game or just browsing the web.
Ping may sometimes just be displayed as “latency”, but it’s basically the same thing. Games often display ping with a visual color to help you understand how good your ping is at a glance — green is good, yellow is borderline, and red is bad.
How A Ping Works
Here’s how a ping works, in a simplified way:
- Your computer sends a small package of data — known as a packet in networking terms — to a remote computer.
- The remote computer receives the packet, which requests it reply.
- The remote computer sends a packet back to you.
This is a single ping. Ping allows you to measure the round-trip time for a packet between your computer and a remote computer. For example, below we used the ping command in a Windows Command Prompt to ping google.com. This command sends four packets, or four individual pings. For the first three pings, the time is 10 ms. For the last ping, the time is 12 ms. This means that, for the first three pings, it took ten milliseconds for a packet to reach Google and be sent back to us. For the last ping, it took twelve milliseconds. Why did it take longer? Well, it could be many things — Google’s server performing more slowly, an Internet router between us and Google’s servers could be a bit more busy, our Wi-Fi reception may have been a bit worse, or many other things. Some fluctuation is normal.
A Ping Is An ICMP Echo Request
When you send a ping, your computer sends an ICMP echo request packet. ICMP stands for “Internet Control Message Protocol”, and is a protocol that’s generally used between network devices so they can communicate with each other. The packet requests an “echo” — in other words, a reply. The remote server, when it receives the ping, will generally respond with a message of its own. When you run a ping command and see several pings in a row, each line is a single packet and its reply.
However, not every computer or server is set up to reply to ICMP echo request packets. Computer that are set up not to respond to pings won’t respond at all, so you’ll simply see “Request timed out” message as the server fails to respond to your pings in the allotted time. The ICMP protocol could be abused for DDoS attacks.
Spotting Packet Loss
Ping can also help you spot packet loss. For example, let’s say you ran the ping command and you saw a mix of replies and “Request timed out” lines. This would indicate some ping packets either weren’t being received by the remote computer, or that their replies weren’t reaching you. The packets are getting lost somewhere along the way.
You’d know that packet loss was occurring somewhere between you and the server — either on the remote computer’s network, a router somewhere in between, your ISP, or your home network. If you’re experiencing trouble while browsing the Internet or playing an online game — especially if you sometimes have to click links twice to get them to load — the ping command can help you see whether that’s packet loss or not. You can also run the ping command against several different remote servers to get a better idea of where the packet loss is occurring.
Ping also displays the severity of packet loss. For example, below our first packet reached the server and made it back to us, but our three others didn’t. Ping displays this as 75% packet loss — 3 out of the 4 packets were lost.
Is A Zero Ping Possible?
The lower the ping, the better. A zero ping would be ideal and would mean that our computer was communicating instantly with a remote server.
Due to the laws of physics, even a small piece of data — known as a packet — takes some time to travel. Even if your packet is travelling entirely over fiber-optic cables, it’s still limited by the speed of light. It’s also limited by the routers sitting along those fiber-optic cables, which have to receive the packet and forward it along different connections.
If you try pinging your local computer — with the ping localhost command — you’re asking your computer to contact itself and reply to itself. In this case, you’ll often see a 0 ms ping. This simply means that your computer can communicate with itself instantly. Of course, it really isn’t instant because the software takes a small amount of time to perform these operations. However, it’s so low that we can round it down to 0 ms and say we have a 0 ping to our own computer.
However, once you start adding in lengths of cable, routers, and distances, you won’t get a 0 ms ping. For example, you could try pinging your own home router. Here we pinged our home router, which we’re connected to wirelessly. It’s just a few rooms away, but we see an average ping of 3 ms and a minimum ping of 1 ms. It takes some time just to communicate with a device sitting in the other room. Even if we weren’t connected wirelessly, just communicating with our routers would often bring our ping around 0 ms, and it will take also take a packet some time to reach your ISP’s network once it leaves your router and heads towards the Internet.
In other words, you can’t really get to a 0 ms ping. This is a limit of the laws of physics. We can’t transmit information instantly — except maybe with quantum entanglement. If we found a way to use quantum entanglement to transmit information across the Internet, we could get to 0 ms ping — but that’s the only option here. Don’t hold your breath for this breakthrough!
In the future, we can absolutely reduce latency on the Internet and deal with it better. For example, web browsers like Chrome, Firefox, and Internet Explorer are already “pre-fetching” pages you might want to see next to eliminate that perceptible latency when you click a link. However, a 0 ms ping — instant information transmission — will likely remain elusive.
Image Credit: sleepy kitty on Flickr