Network protocols

From j4flmao/agent-skills · View interactive version

Network protocols is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks about TCP state, TIME_WAIT, the three-way handshake, congestion control, CUBIC vs BBR, Nagle and TCP_NODELAY, retransmission, MTU, QUIC, HTTP/3, socket tuning or tcpdump. Produces transport-level diagnosis and socket and kernel settings. Not for HTTP API design (use backend-ap

How to use this skill

Skill file

Network Protocols (Transport Layer)

Purpose

Latency spikes, stalled transfers, connection exhaustion and "slow on mobile" problems usually trace back to transport behaviour: handshakes, congestion windows, retransmission timers, Nagle/delayed-ACK interaction, MTU black holes, or TIME_WAIT. This skill explains the mechanisms with their RFCs and gives the knobs and captures to diagnose them.

Agent Protocol

Trigger

"TCP state", "TIME_WAIT", "handshake", "congestion control", "CUBIC", "BBR", "Nagle", "TCP_NODELAY", "retransmission", "MTU", "QUIC", "HTTP/3", "UDP vs TCP", "socket tuning", "tcpdump".

Input Context

Output Artifact

Diagnosis, socket/sysctl changes, capture/analysis commands. No file unless requested.

Response Format

Symptom: {observed}
Mechanism: {protocol behaviour responsible}
Evidence: {ss/pcap/counter lines}
Fix: {socket option / sysctl / design change}
Verify: {metric to re-measure}

1. TCP Connection Lifecycle (RFC 9293, which obsoletes RFC 793)

Client: CLOSED → SYN_SENT → ESTABLISHED → FIN_WAIT_1 → FIN_WAIT_2 → TIME_WAIT → CLOSED
Server: LISTEN → SYN_RCVD → ESTABLISHED → CLOSE_WAIT → LAST_ACK → CLOSED

2. Flow Control and Throughput

3. Congestion Control

| Algorithm | Signal | Behaviour |

|-----------|--------|-----------|

| Reno/NewReno | loss | AIMD: additive increase, halve on loss |

| CUBIC (RFC 9438; Linux default) | loss | window grows as a cubic function of time since last reduction; scales on high-BDP paths; fills buffers (bufferbloat) |

| BBR (v1 in mainline Linux; v3 developed by Google) | model: bottleneck bandwidth + min RTT | paces at estimated bandwidth, keeps queues short; v1 can be unfair to CUBIC and ignore loss up to high rates |

| DCTCP | ECN marks | data centres with ECN-capable switches |

4. Loss Recovery

5. Small-Message Latency: Nagle and Delayed ACK

6. MTU and Fragmentation

7. QUIC and HTTP/3

8. UDP vs TCP Decision

| Need | Choose |

|------|--------|

| Reliable ordered byte stream, broad middlebox support | TCP (+TLS) |

| Many independent streams, mobility, fast setup | QUIC |

| Real-time media/games where late data is useless | UDP with app-level reliability (RTP/WebRTC, game netcode) |

| Multicast/discovery | UDP |

9. Diagnosis Toolkit

ss -tinp state established '( dport = :443 )'     # per-socket cwnd/rtt/retrans
nstat -az | grep -i -E 'retrans|timeout|listendrop' # counters
tcpdump -i eth0 -s 128 -w cap.pcap 'tcp port 443'   # then analyse in Wireshark (Statistics → TCP Stream Graphs)
mtr -rwzc 100 host                                  # per-hop loss/latency

In Wireshark look for retransmissions, zero windows, duplicate ACKs, long gaps after small segments (Nagle/delayed ACK) and missing large packets (MTU).

10. Anti-Patterns

11. Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.