Back to series
· 17 min read

Hands-On: Analyzing Network Packets with Wireshark


I. What Is Wireshark?

Wireshark is an open-source network protocol analysis tool that can capture packets on network interfaces and parse their contents layer by layer according to network protocols.

It helps developers, network engineers, and security analysts observe the details of network communication and diagnose problems such as connection failures, request timeouts, TCP retransmissions, and DNS anomalies.

In real-world development, we often encounter the following problems:

  • Why can't the client connect to the server?
  • Why is no data returned after the TCP connection is established?
  • Why does the HTTP request remain in a Pending state?
  • Why does DNS resolution suddenly become slow?
  • Why are there a large number of TCP retransmissions?
  • Why does the HTTPS handshake fail?
  • Why is the download speed significantly lower than the link bandwidth?
  • Why does network access occasionally lag?

These problems often cannot be explained by application logs alone and require further observation of underlying network packets.

1. Core Capabilities of Wireshark

Capability Description Use Case
Packet capture Capture packets from network interfaces Observe actual communication
Protocol dissection Dissect protocols such as Ethernet, IP, TCP, and DNS Understand protocol structure
Display filters Filter packets by conditions Locate target traffic
Traffic tracing Reconstruct communication processes such as TCP, UDP, and HTTP Analyze requests and responses
Statistics Analyze traffic distribution, endpoints, and conversations Detect anomalous traffic
Expert information Identify retransmissions, anomalies, and protocol issues Troubleshooting
Data export Export packets, objects, and analysis results Further processing

2. How Wireshark Works

Wireshark itself is not responsible for establishing network connections. Instead, it obtains data sent and received by network interfaces through a capture interface, and then uses protocol dissectors to identify protocol fields in the packets.

A typical architecture includes:

  • Network interface: receives and sends network data.
  • Capture library: obtains data through the capture capabilities provided by the system.
  • Capture engine: manages the capture process.
  • Protocol dissectors: identify and parse protocols at each layer.
  • Display filters: filter the packets to be observed.
  • Analysis and statistics module: provides traffic statistics and anomaly analysis.

Common packet capture components:

Platform Common Components
Windows Npcap
Linux libpcap
macOS BPF, libpcap

Basic workflow of Wireshark:

flowchart TD
    A["Network interface receives or sends data"] --> B["Capture driver or capture library"]
    B --> C["Capture engine"]
    C --> D["Read packets"]
    D --> E["Protocol dissectors"]
    E --> F["Generate protocol field tree"]
    F --> G["Display filtering and analysis"]
    G --> H["Packet list and statistics results"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#EAE4FA,stroke:#B8A5E5,color:#514078
    style D fill:#F6FAF7,stroke:#DCE9E0,color:#334155
    style E fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style F fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style G fill:#FFF2CC,stroke:#E7C76A,color:#72551B
    style H fill:#F6FAF7,stroke:#DCE9E0,color:#334155

Note that Wireshark can usually only capture traffic that the current device can observe. Switched networks, wireless networks, VPNs, virtual network adapters, and cloud network environments can all affect the capture scope.

II. Installing Wireshark and Preparing the Lab Environment

1. Installing Wireshark

Official download URL:

https://www.wireshark.org/download.html

Select the installer according to your operating system.

Windows

Download the Windows Installer. During installation, it is recommended that you also install Npcap.

Npcap provides Wireshark with network packet capture capabilities.

After installation, you can see the available network interfaces in Wireshark.

macOS

You can download the installer from the official website, or use Homebrew:

brew install --cask wireshark

After installation, you need to configure packet capture permissions as prompted by the system.

Ubuntu / Debian

sudo apt update
sudo apt install wireshark

If you want a regular user to be able to capture packets, you can configure permissions for the wireshark user group.

sudo dpkg-reconfigure wireshark-common

Follow the on-screen prompts to decide whether to allow non-root users to capture packets.

Add the current user to the corresponding user group:

sudo usermod -aG wireshark "$USER"

The change takes effect after you log in again.

Note: packet capture privileges are powerful, so grant them only to trusted users. The permission setup may differ slightly between distributions.

2. Verify that Wireshark was installed successfully

Check the version from the command line:

wireshark --version

List the available capture interfaces:

tshark -D

TShark is the command-line capture and analysis tool provided by Wireshark.

For example:

1. eth0
2. wlan0
3. lo

Common interfaces:

Interface Meaning
eth0 Wired network interface
wlan0 Wireless network interface
lo Local loopback interface
any Aggregate capture interface available on Linux

3. Getting to know network interfaces

Before capturing packets, you first need to determine which network interface the data actually passes through.

Linux:

ip addr

View the routing table:

ip route

macOS:

ifconfig

Windows:

ipconfig /all

You can also observe the real-time traffic curve of each interface on the Wireshark start screen.

Choosing the wrong interface may mean you never capture the packets you are after.

4. Preparing the lab environment

It is recommended that you prepare the following environment:

Lab item Example Purpose
Client Local computer Generate network requests
Target domain example.com Test DNS
HTTP service http://neverssl.com Observe plaintext HTTP
HTTPS service https://example.com Observe TLS
Packet capture tool Wireshark Capture and analysis
Auxiliary tools curl, ping, dig Generate and verify traffic

Use public test sites during the experiment, and do not send large numbers of requests to unfamiliar servers.

III. The Wireshark Interface and Basic Operations

When you open Wireshark, you will see several main areas.

1. Composition of the main window

Packet List

Displays a summary of the captured packets.

Common fields:

Field Meaning
No. Packet number
Time Capture time
Source Source address
Destination Destination address
Protocol Protocol
Length Packet length
Info Packet summary

Packet Details

Shows the layered protocol structure of the selected packet.

For example:

Frame
Ethernet II
Internet Protocol Version 4
Transmission Control Protocol
Hypertext Transfer Protocol

Packet Bytes

Shows the hexadecimal content and ASCII representation of the raw packet.

Display Filter bar

Enter a filter expression to show only the packets that match the criteria.

2. Starting a capture

Basic steps:

  1. Open Wireshark.
  2. Select the network interface you want to capture on.
  3. Double-click the interface to start capturing.
  4. Visit the target website in a browser, or use curl to generate requests.
  5. Return to Wireshark to view the captured results.
  6. Click the stop button to end the capture.

3. Capture workflow

flowchart TD
    A["Launch Wireshark"] --> B["Select network interface"]
    B --> C["Configure capture filter"]
    C --> D["Start capture"]
    D --> E["Generate test network requests"]
    E --> F["Observe packets"]
    F --> G["Set display filter"]
    G --> H["Analyze protocol fields"]
    H --> I["Save capture file"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#EAE4FA,stroke:#B8A5E5,color:#514078
    style D fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style E fill:#FFF2CC,stroke:#E7C76A,color:#72551B
    style F fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style G fill:#EAE4FA,stroke:#B8A5E5,color:#514078
    style H fill:#F6FAF7,stroke:#DCE9E0,color:#334155
    style I fill:#DCEFE5,stroke:#8EBFA5,color:#24563F

4. Saving the capture file

Wireshark saves captured data in the pcapng format by default.

Steps:

File -> Save As

Common file formats:

Format Description
pcapng The format commonly used by Wireshark, supporting more capture metadata
pcap The traditional packet capture format, with better compatibility

You can also save captures from the command line:

sudo tcpdump -i eth0 -w capture.pcap

Open it with Wireshark:

wireshark capture.pcap

Capture files may contain sensitive data, so necessary anonymization should be performed when saving, transferring, and sharing them.

IV. Capture Filters and Display Filters

Wireshark has two types of filters that are easily confused:

  • Capture Filter.
  • Display Filter.

They serve different purposes.

1. Capture filters

Capture filters take effect during the capture process.

They determine which packets are captured.

The filter syntax is mainly based on BPF syntax.

For example:

Capture only TCP:

tcp

Capture only UDP:

udp

Capture only a specified host:

host 192.168.1.100

Capture only a specified port:

port 443

Capture only DNS:

port 53

Capture only a specified subnet:

net 192.168.1.0/24

Capture only TCP port 80:

tcp port 80

Exclude SSH traffic:

not port 22

Combined conditions:

tcp and host 192.168.1.100

Capture filters reduce the amount of data saved, but if the filter conditions are written incorrectly, packets needed for analysis may be permanently lost.

2. Display filters

Display filters screen the packet list after the packets have already been captured.

They use Wireshark's own display filter syntax.

For example:

Display only TCP:

tcp

Display only UDP:

udp

Display only DNS:

dns

Display only HTTP:

http

Display only TLS:

tls

Display only packets from a specified IP:

ip.src == 192.168.1.100

Display only packets destined for a specified IP:

ip.dst == 192.168.1.100

Display only a specified TCP port:

tcp.port == 443

Show only the specified UDP port:

udp.port == 53

Show only HTTP error status codes:

http.response.code >= 400

Show only TCP retransmissions:

tcp.analysis.retransmission

Show only duplicate ACKs:

tcp.analysis.duplicate_ack

3. Differences Between the Two Types of Filters

Comparison Capture Filter Display Filter
When it takes effect Before or during capture After capture
Primary purpose Control the capture scope Filter already-captured data
Syntax BPF Wireshark Display Filter
Discards non-matching data Not captured Not discarded, only hidden
Syntax example port 443 tcp.port == 443

Pay special attention:

tcp port 443

is capture filter syntax.

tcp.port == 443

is display filter syntax.

The two cannot be used interchangeably.

4. Common Display Filters Quick Reference

Target Expression
TCP tcp
UDP udp
DNS dns
HTTP http
TLS tls
ARP arp
ICMP icmp
IPv4 ip
IPv6 ipv6
TCP SYN tcp.flags.syn == 1
TCP FIN tcp.flags.fin == 1
TCP RST tcp.flags.reset == 1
TCP retransmission tcp.analysis.retransmission
Duplicate ACK tcp.analysis.duplicate_ack
TCP zero window tcp.analysis.zero_window
DNS query dns.flags.response == 0
DNS response dns.flags.response == 1
HTTP GET http.request.method == "GET"
HTTP POST http.request.method == "POST"
TLS ClientHello tls.handshake.type == 1
TLS ServerHello tls.handshake.type == 2

Combining filter conditions:

ip.addr == 192.168.1.100 and tcp.port == 443
dns or tcp.port == 443
tcp.analysis.retransmission or tcp.analysis.duplicate_ack

Filter field names and protocol dissection capabilities may change from one Wireshark version to another. You can type a field prefix in the filter bar and use autocomplete to look up the available fields.

V. Lab 1: Analyzing DNS Name Resolution

DNS (Domain Name System) is responsible for resolving domain names into IP addresses.

When a user visits a website, the client usually must first obtain the IP address of the target server before it can establish a network connection.

1. Generate a DNS Query

Open a terminal and run:

dig example.com

You can also use:

nslookup example.com

In Wireshark, use the display filter:

dns

Observe the DNS query and response.

2. DNS Request and Response Structure

A DNS request typically contains:

  • Transaction ID: transaction identifier.
  • Flags: flag bits.
  • Questions: query questions.
  • Query Name: queried domain name.
  • Query Type: query type.

A DNS response typically contains:

  • Transaction ID.
  • Response Flags.
  • Answer Records.
  • Authority Records.
  • Additional Records.

Common DNS records:

Type Meaning
A IPv4 address
AAAA IPv6 address
CNAME Alias
MX Mail exchange record
NS Name server
TXT Text record
PTR Reverse lookup record

3. DNS Query Sequence

sequenceDiagram
    participant C as DNS Client
    participant R as Recursive DNS
    participant A as Authoritative DNS

    C->>R: Query the A record for example.com
    R->>A: Query domain record
    A-->>R: Return DNS record
    R-->>C: Return resolution result
    C->>C: Cache the resolution result

This diagram shows a simplified recursive resolution process. Actual DNS resolution may also involve root DNS, top-level domain DNS, caching, forwarders, and multiple authoritative servers.

4. Analyze DNS Fields

In Wireshark, select a DNS query packet and expand:

Domain Name System

Focus on:

Transaction ID

Used to match queries with responses.

Flags

You can observe:

  • QR: distinguishes queries from responses.
  • Opcode: operation type.
  • RD: whether recursive query is requested.
  • RA: whether the server supports recursive queries.
  • RCODE: response status.

Queries

Observe the requested domain name and record type.

Answers

Observe the IP address or other records returned by the server.

5. Identify DNS Anomalies

Common DNS problems:

Symptom Possible Cause
No DNS response Packet loss, server unreachable, firewall restrictions
NXDOMAIN Domain name does not exist
SERVFAIL DNS server processing failure
Response timeout Network problem or DNS service anomaly
High response latency Slow recursive resolution, cache miss
Incorrect IP returned DNS misconfiguration or poisoning

You can use the following filters:

dns.flags.response == 0
dns.flags.response == 1
dns.flags.rcode != 0

Note that traditional DNS often uses UDP port 53, but it may also use TCP 53. DoH and DoT encapsulate DNS queries in HTTPS or TLS connections, and ordinary DNS filters may not be able to directly identify the internal query content.

VI. Experiment 2: Analyze ARP and LAN Communication

ARP (Address Resolution Protocol) is used in an IPv4 LAN to find the corresponding MAC address based on an IP address.

For example:

If a host wants to send data to the gateway 192.168.1.1 but does not currently know the gateway's MAC address, it needs to perform an ARP query.

1. Generate ARP Traffic

Linux:

ip neigh

View the neighbor table.

You can generate an ARP query by clearing the cache for a specified neighbor and then accessing the gateway again. Note that clearing the cache may briefly affect network communication.

sudo ip neigh flush to 192.168.1.1
ping -c 1 192.168.1.1

Windows:

arp -a

View the ARP table.

2. ARP Packet Structure

ARP packets mainly contain:

Field Description
Hardware Type Hardware type
Protocol Type Protocol type
Hardware Size MAC address length
Protocol Size Protocol address length
Opcode Request or response
Sender MAC Sender MAC
Sender IP Sender IP
Target MAC Target MAC
Target IP Target IP

3. ARP Resolution Process

sequenceDiagram
    participant A as Host A
    participant LAN as Local Area Network
    participant B as Gateway B

    A->>LAN: Broadcast ARP Request
    LAN->>B: Forward broadcast request
    B-->>A: Unicast ARP Reply
    A->>A: Update ARP neighbor cache
    A->>B: Send subsequent IP packets

4. Wireshark Analysis

Display filter:

arp

ARP Request:

arp.opcode == 1

ARP Reply:

arp.opcode == 2

Key observations:

  • Whether the request is broadcast.
  • Whether the target IP is correct.
  • Whether an ARP response is received.
  • Whether the returned MAC address matches expectations.
  • Whether duplicate IPs or abnormal ARP behavior occur.

ARP applies only to IPv4. IPv6 uses the Neighbor Discovery Protocol (NDP) to perform similar neighbor resolution.

VII. Experiment 3: Analyzing the TCP Three-Way Handshake

TCP is a connection-oriented, reliable transport protocol.

Before a client and a server exchange application data, they usually need to establish a TCP connection first.

1. Create a TCP Connection

Run:

curl -v http://neverssl.com

You can also use:

curl -v https://example.com

In Wireshark, use:

tcp

Observe the TCP packets.

2. TCP Three-Way Handshake

Establishing a TCP connection requires exchanging three key packets:

  1. SYN: The client requests to establish a connection.
  2. SYN + ACK: The server acknowledges and requests to establish a connection.
  3. ACK: The client acknowledges the server's response.

Sequence diagram:

sequenceDiagram
    participant C as Client
    participant S as Server

    C->>S: SYN
    S-->>C: SYN ACK
    C->>S: ACK
    Note over C,S: TCP connection established
    C->>S: Application data
    S-->>C: Application response

3. Key TCP Packet Fields

Field Description
Source Port Source port
Destination Port Destination port
Sequence Number Sequence number
Acknowledgment Number Acknowledgment number
Header Length TCP header length
Flags Control flags
Window Size Receive window
Checksum Checksum
Options TCP options

Focus on Flags:

Flag Meaning
SYN Establish connection
ACK Acknowledgment
FIN Normal connection close
RST Reset connection
PSH Prompt delivery of data to the application as soon as possible
URG Urgent pointer is valid

4. Filtering TCP SYN

View only SYN:

tcp.flags.syn == 1

View only packets with SYN and no ACK:

tcp.flags.syn == 1 and tcp.flags.ack == 0

View only RST:

tcp.flags.reset == 1

5. Analyzing TCP Sequence Numbers

TCP uses sequence numbers to manage the byte stream.

Suppose the client sends:

Sequence Number = 1000
Payload Length = 500

Then, after the receiver acknowledges normally, the acknowledgment number is usually:

Acknowledgment Number = 1500

This means the receiver has received all contiguous bytes with sequence numbers less than 1500.

During actual analysis, note the following:

  • Wireshark may enable relative sequence numbers by default.
  • Relative sequence numbers are not equal to real on-wire sequence numbers.
  • TCP sequence numbers can wrap around.
  • A single TCP segment may carry multiple application-layer data fragments.
  • Segment boundaries do not necessarily equal application message boundaries.

VIII. Lab 4: Analyzing TCP Four-Way Termination

TCP uses FIN and ACK to control normal connection closure.

A common active close process includes:

  1. The active closer sends FIN.
  2. The passive closer sends ACK.
  3. The passive closer sends FIN after finishing data transmission.
  4. The active closer sends ACK.

1. TCP Four-Way Termination Sequence

sequenceDiagram
    participant C as Client
    participant S as Server

    C->>S: FIN
    S-->>C: ACK
    Note over S: Server may continue sending remaining data
    S-->>C: FIN
    C->>S: ACK
    Note over C: Enters TIME_WAIT waiting phase

During actual connection closure, FIN and ACK may be combined in some cases, so packet captures do not always show exactly four independent packets.

2. Filtering FIN and RST

FIN:

tcp.flags.fin == 1

RST:

tcp.flags.reset == 1

When observing connection state, you can focus on:

  • Whether FIN is sent successfully.
  • Whether ACK returns normally.
  • Whether RST appears.
  • Whether there are connections that remain unclosed for a long time.
  • Whether there are abnormal retransmissions.

3. Differences Between RST and FIN

Dimension FIN RST
Meaning Gracefully closes the data flow in one direction Immediately resets the connection
Handling Allows orderly shutdown Terminates the connection
Common scenarios Request completed, connection closed Port not listening, connection abnormal
Data handling Can complete delivery of data already sent Unfinished data may not be delivered normally

Do not assume a server failure based solely on RST. Firewalls, proxies, applications, and operating systems can all generate RST.

IX. Lab 5: Analyzing HTTP Requests and Responses

HTTP is an application-layer protocol that runs on top of the transport layer.

When using plaintext HTTP communication, you can directly observe the request line, request headers, response status code, and response content in a packet capture.

1. Generating an HTTP Request

curl -v http://neverssl.com

Filter in Wireshark:

http

If you do not see HTTP data, check:

  • Whether the wrong network interface was selected.
  • Whether HTTPS is being used.
  • Whether a proxy or cache is involved.
  • Whether an existing connection is being reused.
  • Whether HTTP/2 or HTTP/3 is used.

2. HTTP Request Structure

Typical HTTP/1.1 request:

GET / HTTP/1.1
Host: neverssl.com
User-Agent: curl/8.0
Accept: */*
Connection: keep-alive

Mainly includes:

  • Request method.
  • Request path.
  • HTTP version.
  • Request headers.
  • Optional request body.

3. HTTP Response Structure

A typical HTTP response:

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1256
Cache-Control: max-age=3600

<html>
<body>Hello</body>
</html>

Key fields:

Field Meaning
Status Code HTTP status code
Content-Type Response content type
Content-Length Content length
Cache-Control Cache control
Set-Cookie Set Cookie
Location Redirect address
Server Server identifier

4. HTTP Filters

View GET only:

http.request.method == "GET"

View POST only:

http.request.method == "POST"

View 404 only:

http.response.code == 404

View all 4xx:

http.response.code >= 400 and http.response.code < 500

View all 5xx:

http.response.code >= 500 and http.response.code < 600

5. Follow TCP Stream

This is an extremely useful feature in Wireshark.

Steps:

  1. Select a TCP packet.
  2. Right-click and choose Follow.
  3. Select TCP Stream.
  4. View the communication content between the client and the server.

It can reassemble the data within the same TCP connection into a bidirectional data stream.

Suitable for analyzing:

  • HTTP requests and responses.
  • Login requests.
  • API calls.
  • Application-layer protocol interactions.
  • Data transfer anomalies.

Note that the application-layer content of HTTPS is encrypted, so an ordinary TCP Stream usually shows only TLS ciphertext, and the HTTP content cannot be seen directly.

6. HTTP Redirect Analysis

HTTP redirects are usually implemented through a 3xx status code and the Location response header.

sequenceDiagram
    participant C as Client
    participant S1 as Original Server
    participant S2 as Target Server

    C->>S1: GET /old
    S1-->>C: 301 Location /new
    C->>S2: GET /new
    S2-->>C: 200 OK

With Wireshark you can observe:

  • The original request.
  • The 3xx response.
  • The Location field.
  • The subsequent request to the target.
  • Whether the redirect occurs multiple times.

10. Lab 6: Analyzing HTTPS and the TLS Handshake

HTTPS is a protocol that uses TLS on top of HTTP communication to provide security protection.

TLS mainly provides:

  • Data confidentiality.
  • Data integrity.
  • Server identity authentication.
  • Client identity authentication when appropriately configured.

1. Generating an HTTPS Request

curl -v https://example.com

Wireshark filter:

tls

2. TLS Handshake Process

Taking TLS 1.3 as an example, a simplified full handshake usually includes:

  1. ClientHello.
  2. ServerHello.
  3. Encrypted handshake messages from the server.
  4. The client verifies and completes the handshake.
  5. Both parties begin transmitting encrypted application data.

Sequence diagram:

sequenceDiagram
    participant C as TLS Client
    participant S as TLS Server

    C->>S: ClientHello
    S-->>C: ServerHello
    S-->>C: EncryptedExtensions
    S-->>C: Certificate
    S-->>C: CertificateVerify
    S-->>C: Finished
    C->>S: Finished
    Note over C,S: Handshake complete
    C->>S: Encrypted application data
    S-->>C: Encrypted application data

This is a simplified illustration of the full handshake for ease of understanding. The actual handshake may be affected by factors such as session resumption, PSK, client authentication, and protocol extensions.

3. Analyze ClientHello

Filter:

tls.handshake.type == 1

Select ClientHello and observe:

  • Supported Versions.
  • Server Name.
  • Supported Groups.
  • Signature Algorithms.
  • Key Share.
  • ALPN Protocols.

Among these:

SNI

Used during the TLS handshake to indicate the target domain name to the server.

ALPN

Used to negotiate the application-layer protocol, such as HTTP/2 or HTTP/1.1.

Supported Versions

The TLS protocol versions supported by the client.

4. Analyze ServerHello

Filter:

tls.handshake.type == 2

Focus on:

  • The selected TLS version.
  • Key exchange-related parameters.
  • Cipher suite.
  • Negotiation result.

The handshake structures of TLS 1.3 and TLS 1.2 differ, so their field layouts cannot be directly equated.

5. Why Can't You See HTTP Content in HTTPS?

HTTPS uses TLS to encrypt application-layer data.

An ordinary packet capture can usually show:

  • Client and server IP addresses.
  • Ports.
  • TCP or QUIC traffic.
  • TLS handshake information.
  • Packet sizes.
  • Time intervals.
  • Transmission direction.

But you cannot directly see the encrypted HTTP request path, request headers, or response body.

Some handshake metadata may also be protected by encryption. For example, in TLS 1.3, most handshake messages after ServerHello are encrypted.

6. Decrypt Using TLS Session Keys

In an authorized test environment, you can use TLS session keys exported by the browser to help Wireshark decrypt traffic.

For a browser that supports this capability, you can configure the environment variable:

export SSLKEYLOGFILE="$HOME/sslkeys.log"

Start the browser and visit a test HTTPS website; the browser may write the TLS session keys to this file.

Configure in Wireshark:

Edit -> Preferences -> Protocols -> TLS

Locate:

(Pre)-Master-Secret log filename

Select the corresponding key log file.

After reloading the capture file, Wireshark can attempt to decrypt the corresponding TLS traffic if it has the required session keys.

Note:

  • Not all clients and TLS libraries support key log export.
  • You must use the key log that corresponds to the captured connection.
  • Scenarios such as TLS session resumption also require matching session keys.
  • Key logs are highly sensitive.
  • Do not casually collect or share key logs in production environments.
  • With TLS 1.3 and modern key exchange mechanisms, the server private key generally cannot be used directly to decrypt historical captures.

XI. Lab 7: Analyzing TCP Retransmissions and Network Packet Loss

TCP retransmission is one of the most common analysis targets in network troubleshooting.

When the sender believes that data did not successfully reach the receiver, it may resend the relevant data.

1. Generate a Retransmission Analysis Scenario

In a normal network environment, TCP retransmissions may not be reliably reproducible.

You can use a controlled lab environment and simulate packet loss with a network emulation tool.

On Linux, you can use tc netem.

For example, add 1% packet loss on a test interface:

sudo tc qdisc add dev eth0 root netem loss 1%

After testing is complete, delete the rule:

sudo tc qdisc del dev eth0 root

Note:

  • Must be performed in a controlled test environment.
  • The interface name must be adjusted according to the actual environment.
  • This rule may affect other network traffic on the interface.
  • When operating remotely, it may cause the SSH connection to drop.
  • Do not execute it directly on a production network interface.

2. View TCP Retransmissions

Display filter:

tcp.analysis.retransmission

Fast retransmission:

tcp.analysis.fast_retransmission

Duplicate ACK:

tcp.analysis.duplicate_ack

Out-of-order packets:

tcp.analysis.out_of_order

3. How to Identify Retransmissions?

Suppose the client sends:

Seq=1000
Len=1000

If the sender does not receive the expected acknowledgment, it may resend data in the same sequence range.

Wireshark provides analysis markers based on information such as packet sequence numbers, ACKs, and time intervals.

Note:

Wireshark's retransmission determination is an analytical inference and may be affected by capture location, packet capture drops, out-of-order packets, capture timestamps, and offload features.

A retransmission marker does not necessarily mean that the physical network is dropping packets.

4. TCP Retransmission Troubleshooting Sequence

sequenceDiagram
    participant C as Client
    participant N as Network
    participant S as Server

    C->>N: TCP Segment Seq=1000
    N--xS: Packet loss
    Note over C: Waiting for acknowledgment
    C->>N: Retransmit Seq=1000
    N->>S: Forward retransmitted data
    S-->>C: ACK
    Note over C,S: Data transmission resumes

5. Possible Causes of Retransmission

Cause Description
Network congestion Queue overflow causes packets to be dropped
Link failure Physical link instability
Wireless interference Packet loss on the wireless link
Receiver overload Data processing is not timely
Packet capture loss The capture system itself misses packets
Path change Different paths cause out-of-order packets
MTU issue Some packets cannot pass normally

6. Retransmission and Throughput

TCP retransmissions consume extra bandwidth and may trigger congestion control algorithms to reduce the sending rate.

Therefore, an increase in retransmissions usually means:

  • Effective throughput decreases.
  • Request completion time increases.
  • RTT or timeouts may increase.
  • Long-lived connection performance may deteriorate.

However, you should not look only at the number of retransmissions; you should also analyze them together with the retransmission rate, total connection traffic, and application request performance.

12. Lab 8: Analyzing TCP Window and Zero Window

TCP uses the receive window to control the sender's data transmission rate.

The receiver uses the TCP Window field to tell the sender how much more data it can currently receive.

1. Receive Window

The receive window (rwnd) is used for flow control.

When the receiver's processing speed cannot keep up with the data arrival rate, it may gradually reduce the receive window.

If the receiver is temporarily unable to receive more data, it can advertise a zero window.

2. Filtering Zero Window

tcp.analysis.zero_window

View window updates:

tcp.analysis.window_update

3. Causes of Zero Window

  • The receiving application reads data too slowly.
  • The receive buffer is full.
  • The server process is blocked.
  • The receiver's CPU is overloaded.
  • Insufficient application-layer processing capacity.

4. Zero Window Sequence

sequenceDiagram
    participant S as Sender
    participant R as Receiver

    S->>R: Send TCP data
    R-->>S: ACK Window=0
    Note over S,R: The receiver is temporarily unable to receive more data
    S->>R: Zero Window Probe
    R-->>S: ACK Window=0
    Note over R: The application reads data from the buffer
    R-->>S: Window Update
    S->>R: Resume data transmission

5. Zero Window Troubleshooting Approach

When a zero window is observed, you should not adjust only the sender's parameters.

Further checks should include:

  • Whether the receiving application continuously reads data.
  • Whether the process is blocked.
  • Whether the receive buffer size is reasonable.
  • Whether the CPU is overloaded.
  • Whether there is an application-layer processing bottleneck.

A zero window usually reflects the receiver's processing capacity or buffer status, rather than simply insufficient link bandwidth.

13. Lab 9: Analyzing HTTP/2 and HTTP/3

Modern web applications make extensive use of HTTP/2 and HTTP/3.

They differ significantly from HTTP/1.1 in transport methods and multiplexing mechanisms.

1. HTTP/2

HTTP/2 is usually transmitted over TCP, uses a binary framing format, and supports multiplexing multiple streams over a single connection.

Common features:

  • Binary framing.
  • Multiplexing.
  • HPACK header compression.
  • Stream priority-related mechanisms.
  • Server push capability.

Display filter:

http2

You can focus on observing:

  • HEADERS.
  • DATA.
  • SETTINGS.
  • WINDOW_UPDATE.
  • RST_STREAM.
  • GOAWAY.

2. HTTP/3

HTTP/3 is based on QUIC, and QUIC runs on top of UDP.

Display filter:

quic

You can also combine it with:

udp.port == 443

to observe QUIC traffic.

Main features of HTTP/3: