Network Packet Analysis with Wireshark: A Practical Guide

Introduction to Wireshark

Wireshark is the world's foremost network protocol analyzer and an essential tool for any network administrator, security professional, or IT specialist. It allows you to examine network traffic at a microscopic level, capturing and interactively browsing the traffic running on a computer network. This open-source software provides powerful features for deep inspection of hundreds of protocols, live capture and offline analysis capabilities, and runs on virtually all platforms.

Why Use Wireshark?

  • Network Troubleshooting: Identify network problems, connection issues, and performance bottlenecks
  • Security Analysis: Detect suspicious network activity, analyze traffic patterns, and investigate security incidents
  • Protocol Development: Debug and verify implementations of network protocols
  • Network Education: Learn about networking protocols and how they operate in real-world scenarios
  • Network Forensics: Collect evidence of network-based attacks or policy violations

Getting Started with Wireshark

Capturing Packets

To begin capturing packets with Wireshark:

  1. Select the appropriate network interface from the main screen
  2. Click the "Start Capturing Packets" button (blue shark fin icon)
  3. Generate network traffic by browsing websites, connecting to services, etc.
  4. Click the "Stop Capturing Packets" button (red square icon) when finished

For more targeted captures, use capture filters to reduce the amount of data collected. For example, to capture only HTTP traffic, you could use the filter: tcp port 80

Understanding the Wireshark Interface

The Wireshark interface consists of three main panels:

  • Packet List Pane (Top): Shows a summary of each packet including timestamp, source and destination addresses, protocol, and basic information
  • Packet Details Pane (Middle): Displays the protocols and protocol fields of the selected packet in a hierarchical view
  • Packet Bytes Pane (Bottom): Shows the raw data of the packet in hex and ASCII format

Essential Wireshark Features for Network Analysis

Display Filters

Display filters are Wireshark's most powerful feature, allowing you to focus on the specific traffic you're interested in. Some useful display filters include:

  • ip.addr == 192.168.1.1 - Show only traffic to/from a specific IP address
  • http - Show only HTTP traffic
  • tcp.port == 443 - Show only HTTPS traffic
  • dns - Show only DNS queries and responses
  • tcp.flags.syn == 1 && tcp.flags.ack == 0 - Show only TCP SYN packets (connection attempts)

Following TCP Streams

One of Wireshark's most useful features is the ability to follow TCP streams, which allows you to see the entire conversation between two endpoints:

  1. Right-click on a packet that's part of the conversation you want to follow
  2. Select "Follow" → "TCP Stream"
  3. View the entire conversation in a new window, with client and server messages in different colors

Protocol Statistics

Wireshark offers various statistical tools to analyze network traffic patterns:

  • Protocol Hierarchy: Displays the percentage breakdown of protocols in your capture
  • Conversations: Shows all connections between endpoints
  • Endpoints: Lists all network endpoints with packet and byte counts
  • I/O Graphs: Visual representation of network traffic over time

IP Address Analysis with Wireshark

Wireshark is an excellent tool for analyzing IP address usage and behavior in your network. With it, you can:

  • Identify which IP addresses are most active on your network
  • Detect unauthorized IP addresses or unexpected communications
  • Analyze the geographic location of external IPs (using GeoIP databases)
  • Monitor how your devices obtain IP addresses (through DHCP)
  • Verify your public IP address through external connections

To find your own IP address in Wireshark captures, look for connections to external servers, or filter for DHCP traffic (dhcp) to see address assignments. Tools like "What's My IP" can be used alongside Wireshark to correlate your actual public IP with what appears in your network traffic.

Common Network Issues Detected with Wireshark

TCP Retransmissions

Excessive retransmissions indicate network congestion or packet loss. Filter for them with: tcp.analysis.retransmission

DNS Resolution Problems

Use the filter dns.flags.rcode != 0 to find DNS errors that might indicate name resolution issues.

Slow HTTP Responses

Analyze the time between HTTP requests and responses to identify slow-performing web servers or applications.

Duplicate IP Addresses

Look for ARP conflicts with the filter arp.duplicate-address-detected

Security Analysis with Wireshark

Detecting Port Scans

Port scans often appear as multiple SYN packets to different ports from the same source. Filter for potential port scans with: tcp.flags.syn == 1 && tcp.flags.ack == 0

Identifying Malware Traffic

Look for these potential indicators of compromise:

  • Unusual destination ports or addresses
  • Unencrypted data transfers to external servers
  • Periodic beaconing to command and control servers
  • DNS queries for algorithmically generated domain names

Finding Cleartext Passwords

Search for passwords in unencrypted protocols with filters like:

  • http.request.method == "POST" - For HTTP form submissions
  • ftp - For FTP authentication
  • telnet - For Telnet sessions

Advanced Wireshark Techniques

Decrypting SSL/TLS Traffic

With the appropriate keys, Wireshark can decrypt encrypted traffic:

  1. Obtain the private key or session keys (from browsers or applications)
  2. Configure Wireshark under Preferences → Protocols → TLS → RSA keys list
  3. Add the key file and the appropriate IP address and port

Using Wireshark with Command Line Tools

Wireshark includes powerful command-line tools:

  • tshark: Terminal-based version of Wireshark for headless systems or automated analysis
  • editcap: Edit or split capture files
  • mergecap: Combine multiple capture files
  • capinfos: Display information about capture files

Ethical and Legal Considerations

When using Wireshark, always be aware of these important considerations:

  • Only capture traffic on networks you own or have explicit permission to monitor
  • Be mindful of privacy laws and regulations in your jurisdiction
  • In corporate environments, ensure you have proper authorization and follow company policies
  • Avoid capturing sensitive data like passwords or personal information when possible
  • Securely store and dispose of capture files that may contain sensitive information

Conclusion

Wireshark is an indispensable tool for anyone working with computer networks. Whether you're troubleshooting connectivity issues, investigating security incidents, or simply learning about network protocols, Wireshark provides unparalleled visibility into what's happening on your network. By mastering its features and techniques, you can become more effective at managing, securing, and optimizing network systems.

Awesome findWhatIsMyIP Blog