network-protocols
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…
от j4flmao★ 47 звёзд на GitHub
Установить network-protocols в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
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
- Symptom and where it appears (client, server, load balancer), RTT and loss characteristics
- OS/kernel version, protocol stack (TCP+TLS, QUIC), traffic pattern (request/response, bulk, streaming)
- Available evidence:
ss -ti,netstat -s, pcap
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
- Handshake costs 1 RTT before data (plus 1 RTT for TLS 1.3, 2 for TLS 1.2). TCP Fast Open and TLS 1.3 0-RTT can trim this with replay caveats.
- TIME_WAIT is held by the side that closes first for 2×MSL (Linux: fixed 60 s) so delayed segments cannot corrupt a new connection with the same 4-tuple. Many TIME_WAIT sockets on a client exhaust ephemeral ports: reuse connections (keep-alive/pooling), widen
net.ipv4.ip_local_port_range, enablenet.ipv4.tcp_tw_reuse(safe for outgoing connections with timestamps). Never use the removedtcp_tw_recycle. - CLOSE_WAIT piling up means the application never calls
close()— an app bug, not a kernel setting. - Listen backlog: SYN queue + accept queue (
somaxconn,listen(fd, backlog)); overflows show innetstat -s("SYNs to LISTEN sockets dropped").
2. Flow Control and Throughput
- Receiver advertises a window; window scaling (RFC 7323) allows > 64 KB. Throughput ≤ window / RTT, so the bandwidth-delay product (BDP = bandwidth × RTT) must fit in socket buffers: 1 Gbit/s × 100 ms ≈ 12.5 MB.
- Linux auto-tunes buffers within
net.ipv4.tcp_rmem/tcp_wmem; raise the max for long fat networks rather than settingSO_RCVBUF(which disables auto-tuning).
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 |
- Slow start doubles cwnd per RTT from an initial window of 10 segments (RFC 6928) — short transfers are RTT-bound, not bandwidth-bound.
- Switch per host:
sysctl net.ipv4.tcp_congestion_control=bbr(withfqqdisc for pacing on older kernels). Measure on your paths; BBR mainly helps lossy, long-RTT links.
4. Loss Recovery
- Fast retransmit on 3 duplicate ACKs; SACK (RFC 2018) tells the sender exactly what is missing; RACK-TLP (RFC 8985) is Linux's time-based loss detection.
- RTO: minimum 200 ms on Linux (RFC 6298 suggests 1 s), doubling on each timeout — a single tail loss on a short request can add hundreds of ms; this is a classic p99 latency source.
- Inspect with
ss -ti(cwnd, rtt, retrans, pacing rate) andnstat/netstat -sretransmission counters.
5. Small-Message Latency: Nagle and Delayed ACK
- Nagle holds small segments while unacknowledged data is in flight; the peer's delayed ACK (up to ~40 ms on Linux, 200 ms on some stacks) waits for more data → write-write-read patterns stall.
- Fix:
TCP_NODELAYfor request/response and interactive protocols (most RPC/HTTP libraries set it), or coalesce writes (writev,TCP_CORK/MSG_MOREthen flush).
6. MTU and Fragmentation
- Ethernet MTU 1500 → TCP MSS 1460 (IPv4) / 1440 (IPv6) without options. Tunnels (VXLAN, WireGuard, IPsec) reduce it.
- Path MTU discovery relies on ICMP "fragmentation needed"/"packet too big"; firewalls dropping ICMP create black holes (handshake works, large responses hang). Fixes: allow ICMP, MSS clamping on tunnel endpoints, PLPMTUD (
net.ipv4.tcp_mtu_probing=1). - UDP protocols should keep datagrams ≤ ~1200 bytes unless the path is known (QUIC's minimum is 1200).
7. QUIC and HTTP/3
- QUIC (RFC 9000, TLS 1.3
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл network-protocols?
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-api-design) or game netcode (use multiplayer-netcode).
Как установить скилл network-protocols?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл network-protocols запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…