Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 4

Network Connectivity: Ping and Traceroute

Recommended resources

Hello! Welcome to your fourth lesson in the "Network and Internet Fundamentals" module.

In our last session, we explored the difference between TCP and UDP, the two main protocols for transporting data. We learned about the critical trade-off between TCP's reliability and UDP's speed, and why that choice is so important for applications like web browsing and online gaming.

Today, we're moving from theory to practice. Now that you understand the basics of addressing and transport, you'll learn how to actively test and investigate network connections yourself. The learning outcome for this lesson is to use the command-line tools ping and traceroute to test connectivity and map network paths. These are two of the most fundamental and widely used utilities in all of networking and cybersecurity.

1. The Basic Connectivity Check: ping

Imagine you're in a large cave and want to know if anyone else is there. You might shout "Hello!" and listen for an echo. The ping command works on a similar principle. It sends a small data packet, called an ICMP Echo Request, to a target device and waits for that device to send back an ICMP Echo Reply.

This simple exchange can tell you two crucial things:

  1. Is the target device online and reachable?
  2. How long did it take for the message to go there and back? (This is known as latency or round-trip time).

Let's watch a video that explains and demonstrates how it works.

Ping Command Explained | Real World Example

This video from CertBros provides a great introduction to the ping command, explains its output, and shows how it's used in a real-world troubleshooting scenario.

Please watch from the beginning until 05:31. The video will cover: What ping is and how it uses ICMP (00:00 - 02:20). A demonstration and explanation of the command's output (02:20 - 03:32). Common error messages and what they mean (03:32 - 05:31). Focus on understanding the meaning of time= and TTL= in the output.

As you saw in the video, ping provides a quick health check of a network connection. Let's break down a typical successful response:

Reply from 142.250.191.78: bytes=32 time=15ms TTL=117

  • bytes=32: The size of the packet sent.
  • time=15ms: The round-trip time, or latency. Lower is better. For online games, high latency causes lag.
  • TTL=117: Stands for Time To Live. This is a counter that prevents packets from looping forever on the internet. Every time a packet crosses a router (a "hop"), this number goes down by one. If it reaches zero, the packet is discarded. We'll see why this is so important in the next section.

Your Turn: Using ping

Now it's time to try it yourself. You'll need to open your system's command-line interface.

  • On Windows: Press the Windows key, type cmd, and press Enter to open the Command Prompt.
  • On macOS: Open the Spotlight search (Cmd+Space), type Terminal, and press Enter.

Once you have a command prompt open, try these commands:

  1. ping google.com
  2. ping 8.8.8.8

You'll notice that the output is very similar. The first command uses a domain name, which your computer first has to translate into an IP address using DNS (as we learned in a previous lesson). The second command pings that IP address directly.


2. Mapping the Path: traceroute

Ping is great for telling you if you can reach a destination. But what if you can't? Or what if the connection is very slow? You need a tool that can show you the entire path your data takes, hop by hop. That tool is traceroute (or tracert on Windows).

Traceroute cleverly uses the TTL field we just discussed. It works like this:

  1. It sends a packet to the destination with a TTL of 1. The first router it hits decrements the TTL to 0, discards the packet, and sends back an error message ("Time exceeded"). Traceroute records that router's IP address.
  2. It then sends a new packet with a TTL of 2. This packet makes it past the first router, but is stopped by the second one, which sends back an error. Traceroute records the second router's IP.
  3. It continues this process, increasing the TTL by one each time, until the packet finally reaches the destination.

The result is a complete, ordered list of every router your packets travel through to get to their destination. This is invaluable for diagnosing where a network problem might be.

This next video explains the process.

Traceroute Explained | Real World Examples

From the same channel, this video explains how traceroute works by manipulating TTL and shows how to interpret its output.

Please watch from the beginning to 07:53. This segment covers: The concept of traceroute and network hops (00:00 - 02:38). A live demonstration of the command and a breakdown of its output (02:38 - 07:53). Pay attention to how the TTL value is used to map out the path.

Here is an example of what the output looks like. The command used here is tracert -d 8.8.8.8, where -d tells it not to resolve IP addresses to names, making it a bit faster.

Traceroute Command Output in Windows Command Prompt
This image shows the output of the `tracert` command in Windows. Each numbered line represents a "hop" (a router) on the path to the destination. The columns show the round-trip times to that hop, and the final column shows the IP address of the router at that hop.

Notice a few things:

  • Each line is a sequential hop. Hop 1 is your local router.
  • There are three time measurements for each hop. This is because traceroute sends three packets to each hop to get an average and see if the latency is consistent.
  • Sometimes you'll see * * * or Request timed out. This usually means that a router along the path is configured not to respond to traceroute packets, often for security reasons. The trace will typically continue past it.

Your Turn: Using traceroute

Let's trace the path to a destination. In your Command Prompt or Terminal, run the following command:

  • On Windows: tracert google.com
  • On macOS/Linux: traceroute google.com

Watch as it builds the path from your computer, through your Internet Service Provider's network, and across the internet to Google's servers. You can see how many hops it takes and how the latency changes as the data travels further away. This is the exact path your game data or web traffic might take. Network engineers for gaming companies use this tool constantly to diagnose sources of lag and poor routing for their players.


3. A Practical Diagnostic Workflow

While powerful on their own, ping and traceroute are most effective when used together to diagnose a problem.

Here's a standard workflow you can follow:

  1. Start with ping: Try to ping the destination (e.g., ping website.com).
    • If it works: You know you have a valid network path and the host is online. If the time= value is high, you have a latency problem.
    • If it fails ("Request timed out" or "Destination unreachable"): You know there's a problem, but you don't know where.
  2. Move to traceroute: Run a traceroute to the same destination.
    • The trace will show you exactly where the connection stops. The last successful hop is the point just before the problem. For example, if the trace dies after leaving your ISP's network, the issue is likely not on your end.
    • If you're investigating high latency, look for a sudden jump in the time values between two hops. This can pinpoint a slow or congested router along the path.

For a deeper look into this diagnostic process, the following article provides excellent real-world examples.

Diagnose Network Issues Like a Pro Using Ping

This article, "Diagnose Network Issues Like a Pro Using Ping," reinforces what we've learned and summarizes the workflow for using these tools together.

Please read the following sections: ping: The Basic Connectivity Check: A good text-based review of what ping does and how to interpret its output. traceroute: Mapping the Path of Traffic: A similar review for traceroute. Using the Tools Together: This section provides a concise summary of the diagnostic workflow we just discussed. Don't worry about the mtr tool mentioned; we are focusing on ping and traceroute.


Conclusion

Congratulations! You've just added two of the most essential tools in network analysis to your toolkit. You've gone from understanding network concepts to actively probing and diagnosing network paths.

Key Takeaways:

  • ping is a simple tool to test reachability and measure latency to a specific host using ICMP packets.
  • traceroute (tracert) is a more advanced tool that maps the entire hop-by-hop path your data takes to a destination by manipulating the TTL field of packets.
  • Together, they form a powerful combination for troubleshooting network issues, allowing you to determine if a host is down or if a problem exists somewhere along the network path.

Next Steps

So far, we've covered addressing (IP, MAC, DNS), transport (TCP, UDP), and now path testing (ping, traceroute). You have all the pieces needed to understand a complete network transaction. In our next lesson, we will outline the sequence of a web request, from the moment you type a URL into your browser to the moment the page appears on your screen, tying all these concepts together.