Skip to content
ShellOps Daily

Linux server hardening, systemd, and Bash automation tips

Networking & Proxy

Troubleshoot Slow Network Routes with MTR and Tcpdump

Victor Novak8 min read

Slow network routes can severely impact system performance, leading to delays, dropped connections, and frustrated users. As a system administrator or DevOps engineer, you need reliable tools to troubleshoot slow network routes with mtr and tcpdump. These command-line utilities offer deep insights into network behavior, helping you pinpoint bottlenecks and resolve issues quickly. Whether you're dealing with latency or packet loss, the right approach can save time and improve reliability.

This article walks you through the fundamentals of network latency and packet loss, explaining how they affect data transmission. You'll learn to use MTR to trace network paths and identify where delays occur, and how Tcpdump captures real-time traffic for detailed analysis. By combining these tools, you gain a powerful way to diagnose and fix network performance problems.

The practical steps provided will guide you through real-world scenarios, from basic command syntax to advanced filtering techniques. Whether you're troubleshooting internal infrastructure or external connectivity, this guide equips you with the skills to maintain a fast and stable network environment.

Understanding Network Latency and Packet Loss

Network latency and packet loss are critical factors that can significantly affect the performance and reliability of networked applications. Understanding these concepts is essential for diagnosing and resolving issues that impact data transmission speed and consistency.

What Is Network Latency?

Network latency refers to the time it takes for data to travel from its source to its destination across a network. This delay can be caused by various factors, including the physical distance between devices, the number of hops data must traverse, and the processing time at each network node. High latency can result in slower application responses, reduced user experience, and potential disruptions in real-time services such as video conferencing or online gaming.

What Is Packet Loss?

Packet loss occurs when data packets fail to reach their intended destination, often due to network congestion, hardware failures, or routing errors. When packets are lost, the receiving end may request retransmission, which can further degrade performance and increase latency. Packet loss can lead to incomplete data delivery, corrupted information, and unreliable application behavior, especially in critical systems that rely on consistent data flow.

Using MTR to Analyze Network Routes

MTR is a powerful tool that merges the functionality of traceroute and ping to provide detailed insights into network paths and performance. It allows administrators to monitor the latency and packet loss at each hop along a route, making it essential for diagnosing slow or unstable network connections.

  1. Install MTR using your package manager, such as 'sudo apt install mtr' on Debian-based systems or 'sudo yum install mtr' on Red Hat-based systems.
  2. Run MTR with the command 'mtr [hostname or IP]'. This will display a live report of the network path, including latency and packet loss statistics for each hop.
  3. Use the '-r' flag to run MTR in 'report' mode, which provides a summary of the network path and performance metrics after the test completes.
  4. For more detailed analysis, combine MTR with other tools like Tcpdump to capture and inspect network traffic at specific points in the path.

Basic MTR Command Syntax

The basic MTR command syntax is simple and versatile. You can start by typing 'mtr [hostname or IP]' to initiate the test. This command will trace the path from your machine to the destination, showing real-time data on each hop. If you want to run MTR in report mode for a more comprehensive overview, add the '-r' flag to the command. This mode is useful for generating a detailed summary after the test completes.

Interpreting MTR Output

Interpreting MTR output involves understanding the columns that represent each hop in the network path. The first column shows the hop number, followed by the hostname or IP address, and then the average, minimum, maximum, and standard deviation of the latency in milliseconds. The final column indicates the percentage of packet loss. A high latency or significant packet loss at a particular hop suggests potential issues such as congestion, routing problems, or hardware limitations. By analyzing these metrics, administrators can pinpoint where the network becomes slow or unstable.

Capturing Network Traffic with Tcpdump

Tcpdump is a powerful packet sniffer that captures network traffic in real time. It allows system administrators and DevOps engineers to inspect raw data packets, helping to identify traffic patterns, packet loss, and latency issues. By capturing and analyzing network traffic, Tcpdump provides valuable insights into the behavior of network protocols and potential bottlenecks.

  1. Start with the basic command `tcpdump -i <interface>` to capture packets on a specific network interface. Replace `<interface>` with the actual name of the interface, such as `eth0` or `ens3`. This command displays live packet data in the terminal, providing a real-time view of network activity.
  2. Use the `-n` option to prevent DNS resolution, which speeds up the output and makes it easier to analyze. For example, `tcpdump -i eth0 -n` will display IP addresses instead of hostnames, making it more efficient for troubleshooting.
  3. To capture packets on a specific port, use the `port` filter. For instance, `tcpdump -i eth0 port 80` will capture HTTP traffic on port 80, while `tcpdump -i eth0 port 443` targets HTTPS traffic. This helps isolate specific services or applications.
  4. Combine filters for more precise analysis. For example, `tcpdump -i eth0 tcp and port 80` captures only TCP traffic on port 8, and `tcpdump -i eth0 icmp` captures ICMP packets for network diagnostics. These filters allow focused analysis of network behavior.

Basic Tcpdump Command Syntax

The basic Tcpdump command syntax is essential for starting packet capture. The `-i` flag specifies the network interface to monitor, and without additional options, Tcpdump will display all packets passing through that interface. This provides a comprehensive view of the network traffic, which is useful for baseline analysis and troubleshooting.

Filtering Traffic with Tcpdump

Filtering traffic with Tcpdump enables targeted analysis of specific protocols, ports, or interfaces. By applying filters, you can narrow down the data to focus on relevant network activity, which is crucial for identifying performance issues or security anomalies. Filters also help reduce the volume of data, making it easier to spot patterns or irregularities.

Combining MTR and Tcpdump for Deep Analysis

Combining MTR and Tcpdump allows for a more comprehensive analysis of slow network routes. Start by using MTR to identify where latency spikes or packet loss occurs along the network path. Once the problematic segment is pinpointed, Tcpdump can be deployed at that location to capture detailed traffic data. This combination helps isolate whether the issue lies in routing, firewall rules, or network congestion.

When using Tcpdump, focus on capturing traffic at the point where MTR shows packet loss or high latency. Use filters to narrow down the data to relevant protocols and IP addresses, such as `tcpdump -i eth0 port 80` for HTTP traffic. This targeted approach reduces noise and makes it easier to spot anomalies like retransmissions or dropped packets.

To effectively troubleshoot, run MTR in continuous mode to monitor real-time changes in network performance. At the same time, start a Tcpdump session to record traffic for later analysis. If the issue is intermittent, capture traffic for several minutes to ensure you capture the problem during its occurrence.

Once data is collected, analyze Tcpdump logs to identify patterns such as repeated timeouts, malformed packets, or unexpected traffic. Cross-reference these findings with MTR results to determine if the issue stems from a specific router, ISP, or internal network device. This methodical approach ensures accurate diagnosis and targeted resolution of network performance problems.

Practical Steps to Troubleshoot Slow Network Routes

Begin by running MTR against the target IP or domain to map the network path and identify where latency or packet loss occurs. Use the command `mtr [IP or domain]` to gather real-time statistics across each hop. Focus on hops showing high latency or packet loss, as these are likely the source of the problem.

  1. Run MTR against the target IP or domain to identify the slow segment of the network path.
  2. Capture traffic with Tcpdump on the affected interface to analyze packet behavior in real time.
  3. Use Tcpdump to inspect the captured data for retransmissions, malformed packets, or unusual traffic patterns.
  4. Compare MTR and Tcpdump data to pinpoint the root cause, such as routing issues, congestion, or misconfigured firewall rules.

Once MTR identifies the problematic segment, use Tcpdump to capture traffic on the affected interface. Run `tcpdump -i [interface] -w capture.pcap` to save the traffic for later analysis. Capture packets during the time the issue is occurring to ensure you have relevant data.

Analyze the captured Tcpdump file using tools like Wireshark or `tcpdump -r capture.pcap` to inspect packet behavior. Look for retransmissions, malformed packets, or unusual traffic patterns that may indicate routing issues, firewall rules, or hardware problems.

Combine MTR and Tcpdump data to determine the root cause. If MTR shows packet loss at a specific hop and Tcpdump reveals retransmissions there, the issue may be with the router or link. If the problem is on the local network, check for congestion, misconfigured rules, or hardware limitations.

Frequently Asked Questions

How do I use MTR to check for network latency?

To check for network latency, run 'mtr [hostname/IP]'. This command traces the network route and displays latency and packet loss. Look for high latency or packet loss in the output to identify performance issues.

Can I use Tcpdump to capture network traffic on a specific port?

Yes, use 'tcpdump -i [interface] port [port_number]' to capture traffic on a specific port. Replace [interface] with your network interface and [port_number] with the desired port. This helps isolate traffic for analysis.

What does packet loss mean in network troubleshooting?

Packet loss refers to the number of packets that fail to reach their destination. It indicates network congestion, hardware failure, or routing issues. High packet loss can severely impact performance and reliability.

How can I combine MTR and Tcpdump to diagnose network issues?

Use MTR to identify the affected network path and Tcpdump to capture traffic on the relevant interface. This combination allows you to correlate latency and packet loss with specific traffic patterns, aiding in precise troubleshooting.

Next Steps for Network Optimization

MTR and Tcpdump are powerful tools for diagnosing slow network routes. MTR helps identify latency and packet loss, while Tcpdump captures detailed traffic data for deeper analysis. Together, they provide a comprehensive view of network performance issues.

To address slow network routes, start by using MTR to trace the path and identify problematic segments. Then, use Tcpdump to capture traffic and analyze patterns. This approach enables targeted optimization of network performance.