30 Mins

8. Performance Bottlenecks & Retransmission Audits

Detecting TCP Retransmissions and Out-of-Order Packets

TCP retransmissions occur when a sender does not receive an acknowledgment (ACK) within the expected RTO (Retransmission Timeout) window. This is a primary indicator of packet loss in the path.

Out-of-order packets occur when packets arrive at the destination in a different sequence than they were sent. While handled by the TCP stack, excessive occurrences indicate buffer overflow or network instability.

Wireshark helps identify these using display filters: tcp.analysis.retransmission and tcp.analysis.out_of_order.

To identify these via command line, TShark provides an automated way to process pcap files for specific flags.

Security Operator Note: Always check if the retransmission is triggered by the sender (fast retransmit) or by a timeout, as this distinguishes between mild congestion and complete path failure.
Text
tshark -r traffic.pcap -Y 'tcp.analysis.retransmission or tcp.analysis.out_of_order' -T fields -e frame.number -e ip.src -e ip.dst -e tcp.seq

Analyzing TCP ZeroWindow and Window Full Congestion

A ZeroWindow signal occurs when the receiver informs the sender that its buffer is full and it cannot process any more data. The sender must stop transmitting until a 'Window Update' is received.

A 'Window Full' signal indicates that the sender has filled the entire window available to it but the receiver has not yet exhausted its buffer space.

These conditions create massive latency spikes. You can filter these in Wireshark using tcp.analysis.zero_window or tcp.analysis.window_full.

Security Operator Note: ZeroWindow probes are frequent in low-bandwidth, high-latency scenarios. Use these to identify misconfigured receiver buffers.
Python 3
import struct
def check_window_size(packet_bytes):
    # Extract 16-bit Window Size field from TCP Header (Offset 14)
    tcp_header = packet_bytes[34:54]
    window_size = struct.unpack('!H', tcp_header[14:16])[0]
    if window_size == 0:
        return 'CRITICAL: ZeroWindow Detected'
    return f'Window Size: {window_size}'
print(check_window_size(b'\x00' * 60))

Measuring RTT and TCP Handshake Latency

Round-Trip Time (RTT) is the duration from sending a segment to receiving its ACK. It is the most critical metric for network latency analysis.

During the three-way handshake (SYN, SYN-ACK, ACK), the time between the SYN and the SYN-ACK provides the initial path latency. In Wireshark, this is often exposed via tcp.time_delta.

Calculating this programmatically requires tracking the sequence numbers and timestamps of the packets.

Security Operator Note: An RTT exceeding 200ms is often considered problematic for real-time applications like VoIP or high-frequency trading.
Python 3
import time
# Simulating handshake RTT calculation
syn_time = time.time()
syn_ack_time = syn_time + 0.045 # 45ms simulated latency
rtt = syn_ack_time - syn_time
print(f'Handshake RTT: {rtt*1000:.2f}ms')

Generating I/O Graphs in Wireshark

I/O Graphs allow visual correlation between spikes in packet volume and network errors.

By setting the Y-Axis to Advanced, you can plot specific filters like tcp.analysis.retransmission alongside total packet count, allowing for an immediate visual diagnosis of bottleneck correlation.

Below is a comparison of common network indicators and their impacts.

Security Operator Note: When creating I/O graphs, set the interval to 1s for general trends or 10ms for micro-burst analysis.
SignalImpact
ZeroWindowComplete traffic stall
RetransmissionHigh jitter, reduced throughput

Knowledge Check

Ready to test your understanding of 8. Performance Bottlenecks & Retransmission Audits?

Back