Skip to content
Tutorials Center
My learning

Topics

Lesson 79 of 79 ยท Practice and Review

Computer Networks Cheat Sheet

A dense networking cheat sheet: layers and protocols, port numbers, header fields, subnet table, delay and window formulas, HTTP status codes and tool commands.

This page packs the whole Computer Networks course onto one screen's worth of tables. Use it before an exam, an interview or a late-night debugging session when you know the idea but need the exact number: the port of a protocol, the size of a header, the mask of a /27, the formula for utilization. Each section links to the lesson that explains the topic in full.

Three live editors generate the tables you would otherwise have to recompute by hand: the subnet table, the delay and window formulas, and a protocol lookup. Everything else is plain reference text, and the command listings are read-only because they need a real network.

Layers and protocols

TCP/IP layer OSI layers PDU Addressing Example protocols and devices
Application 7 Application, 6 Presentation, 5 Session message / data names, URLs HTTP, DNS, SMTP, IMAP, SSH, TLS, DHCP
Transport 4 Transport segment (TCP) / datagram (UDP) port numbers TCP, UDP, QUIC, SCTP
Internet (network) 3 Network packet IP address IPv4, IPv6, ICMP, OSPF, BGP; router
Link 2 Data Link frame MAC address Ethernet, Wi-Fi, ARP, VLAN; switch, bridge
Physical 1 Physical bit / symbol none copper, fiber, radio; hub, repeater, modem

Memory aid for OSI from the bottom: Please Do Not Throw Sausage Pizza Away. See Layered Models.

Encapsulation: data โ†’ TCP/UDP header โ†’ IP header โ†’ Ethernet header + trailer (FCS) โ†’ bits.

Well-known ports

Ranges: 0-1023 well-known, 1024-49151 registered, 49152-65535 dynamic (ephemeral). A connection is the 4-tuple (source IP, source port, destination IP, destination port).

Port Protocol Transport Notes
20, 21 FTP data, control TCP cleartext; use SFTP or FTPS
22 SSH, SFTP, SCP TCP secure shell
23 Telnet TCP cleartext, obsolete
25 SMTP TCP server to server mail
53 DNS UDP and TCP TCP for large answers and zone transfers
67, 68 DHCP server, client UDP IPv6 uses 546, 547
69 TFTP UDP
80 HTTP TCP
110 POP3 TCP 995 with TLS
123 NTP UDP time sync
143 IMAP TCP 993 with TLS
161, 162 SNMP, traps UDP
179 BGP TCP
389, 636 LDAP, LDAPS TCP
443 HTTPS TCP (HTTP/3: UDP)
465, 587 SMTP over TLS, submission TCP mail clients to server
500, 4500 IPsec IKE, NAT-T UDP
514 Syslog UDP
853 DNS over TLS TCP
3306 MySQL TCP
3389 RDP TCP
5432 PostgreSQL TCP
6379 Redis TCP
51820 WireGuard UDP default

Header fields

Header Size Key fields
Ethernet II 14 bytes + 4 FCS destination MAC (6), source MAC (6), EtherType (2); 802.1Q adds 4 bytes
IPv4 20-60 bytes version, IHL, DSCP/ECN, total length, identification, flags (DF, MF), fragment offset, TTL, protocol, header checksum, source, destination
IPv6 40 bytes fixed version, traffic class, flow label, payload length, next header, hop limit, source, destination (128 bits each)
TCP 20-60 bytes source port, destination port, sequence, acknowledgment, data offset, flags, window, checksum, urgent pointer, options
UDP 8 bytes source port, destination port, length, checksum
ICMP 8 bytes + data type, code, checksum, rest of header

EtherType: 0x0800 IPv4, 0x0806 ARP, 0x86DD IPv6, 0x8100 VLAN tag. IP protocol numbers: 1 ICMP, 6 TCP, 17 UDP, 41 IPv6 encapsulation, 47 GRE, 50 ESP, 89 OSPF. TCP flags: SYN, ACK, FIN, RST, PSH, URG, ECE, CWR. Typical MSS on Ethernet: 1,500 - 20 - 20 = 1,460 bytes. Frame limits: minimum 64 bytes on Ethernet, MTU 1,500 bytes, maximum frame 1,518 (1,522 tagged). See Ethernet and Frames and The IPv4 Packet and Fragmentation.

flowchart LR
    A["Ethernet header<br/>14 B"] --> B["IP header<br/>20 B"] --> C["TCP header<br/>20 B"] --> D["Payload<br/>up to 1460 B"] --> E["FCS<br/>4 B"]

A full-size Ethernet frame carrying TCP over IPv4: 14 + 20 + 20 + 1,460 + 4 = 1,518 bytes.

Addressing quick reference

Range Meaning
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 private (RFC 1918)
127.0.0.0/8 loopback
169.254.0.0/16 link-local (APIPA)
100.64.0.0/10 carrier-grade NAT shared space
224.0.0.0/4 multicast
0.0.0.0/0 default route
255.255.255.255 limited broadcast
::1/128, fe80::/10, fc00::/7, ff00::/8, 2000::/3 IPv6 loopback, link-local, unique local, multicast, global unicast

Formulas: addresses in a block = 2(32 โˆ’ prefix); usable hosts = that โˆ’ 2 (not for /31 and /32); network address = IP AND mask; broadcast = network OR NOT mask. See Subnetting and Subnet Masks.

Python Subnet table generator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Formulas

Topic Formula
Transmission delay Tt = L / R (bits / bits per second)
Propagation delay Tp = d / s (about 2 ร— 108 m/s in fiber or copper)
Round trip RTT โ‰ˆ 2 Tp + queuing + processing
Bandwidth-delay product R ร— RTT, in bits (divide by 8 for bytes)
Throughput with a window at most W / RTT
Stop-and-wait utilization 1 / (1 + 2a), where a = Tp / Tt
Sliding window utilization min(1, W / (1 + 2a))
Go-Back-N / Selective Repeat max window 2k โˆ’ 1 / 2kโˆ’1
Nyquist (noiseless) C = 2 B log2 M
Shannon (noisy) C = B log2(1 + SNR)
Pure / slotted ALOHA peak 1/(2e) โ‰ˆ 18.4 % / 1/e โ‰ˆ 36.8 %
CSMA/CD minimum frame frame time โ‰ฅ 2 Tp
Hamming code 2m โ‰ฅ k + m + 1; distance d detects d โˆ’ 1, corrects โŒŠ(d โˆ’ 1)/2โŒ‹
CRC remainder of M ร— 2r divided by generator of degree r; catches bursts โ‰ค r
RTO (Jacobson/Karels) RTTVAR โ† ยพ RTTVAR + ยผ |SRTT โˆ’ R|; SRTT โ† โ…ž SRTT + โ…› R; RTO = SRTT + 4 RTTVAR
Slow start / AIMD cwnd doubles per RTT; then +1 MSS per RTT; halve on loss

See Bandwidth, Latency, Throughput and Loss, Flow Control and ARQ and TCP Reliability.

Python Delay, window and capacity calculator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

  • MAC address: 48 bits, written as six hex pairs; broadcast is ff:ff:ff:ff:ff:ff.
  • Switch: learns source MACs, forwards by destination MAC, floods unknown and broadcast frames. Hub: repeats everything.
  • STP blocks redundant links to stop loops. VLAN: 802.1Q tag with a 12-bit ID (1-4094 usable); access ports carry one VLAN untagged, trunk ports carry many tagged.
  • ARP: broadcast "who has IP?", unicast reply, cached; gratuitous ARP announces or updates a mapping.
  • Access methods: ALOHA, CSMA/CD (Ethernet, half-duplex), CSMA/CA (Wi-Fi), token passing.
  • Wi-Fi: SSID names a network, BSSID identifies the access point; 2.4 GHz non-overlapping channels are 1, 6, 11.

See Switches, Bridges and MAC Learning and VLANs and ARP.

Routing

Protocol Type Metric Transport Scope
Static manual none none any
RIP distance-vector hop count (16 = unreachable) UDP 520 small networks
OSPF link-state (Dijkstra) cost IP protocol 89 inside an AS
BGP path-vector attributes and policy TCP 179 between ASes

Route choice: the longest matching prefix wins; ties are broken by administrative preference, then metric. A packet with TTL 0 is dropped and an ICMP Time Exceeded (type 11) is returned. See Routing and Forwarding.

Transport

  • UDP: connectionless, 8-byte header, no ordering, no retransmission. Used by DNS, DHCP, NTP, VoIP, QUIC.
  • TCP: connection-oriented reliable byte stream. Handshake: SYN โ†’ SYN-ACK โ†’ ACK. Teardown: FIN โ†’ ACK โ†’ FIN โ†’ ACK, then TIME_WAIT (2 ร— MSL, 60 seconds on Linux).
  • States: CLOSED, LISTEN, SYN_SENT, SYN_RECEIVED, ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, CLOSE_WAIT, CLOSING, LAST_ACK, TIME_WAIT.
  • Reliability: cumulative ACKs, retransmit on RTO or after 3 duplicate ACKs, SACK for gaps, exponential backoff of the RTO.
  • Flow control: receive window (scaled with the window-scale option); congestion control: cwnd, slow start, congestion avoidance, fast recovery (Reno, CUBIC, BBR). Sending limit = min(rwnd, cwnd).
  • Nagle batches small writes; delayed ACK waits up to about 40 ms or 200 ms depending on the system.

See TCP Segments and the Three-Way Handshake, TCP Connection Teardown and UDP.

Application layer

DNS record types: A, AAAA, CNAME, MX, NS, TXT, PTR, SOA, SRV, CAA. Resolution: stub resolver โ†’ recursive resolver โ†’ root โ†’ TLD โ†’ authoritative; cached for the TTL.

HTTP methods: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS. Safe: GET, HEAD, OPTIONS. Idempotent: GET, HEAD, PUT, DELETE, OPTIONS.

Code Meaning Code Meaning
200 OK 400 Bad Request
201 Created 401 Unauthorized (not authenticated)
204 No Content 403 Forbidden
301 Moved Permanently 404 Not Found
302 / 307 Temporary redirect 405 Method Not Allowed
304 Not Modified 409 Conflict
308 Permanent redirect (method kept) 429 Too Many Requests
500 Internal Server Error 502 Bad Gateway
503 Service Unavailable 504 Gateway Timeout

Cache headers: Cache-Control: max-age=โ€ฆ, no-store, no-cache, private, public, ETag with If-None-Match, Last-Modified with If-Modified-Since. Cookies: Set-Cookie: id=โ€ฆ; Secure; HttpOnly; SameSite=Lax.

Email: SMTP sends (25, 587), IMAP syncs (143, 993), POP3 downloads (110, 995); SPF, DKIM and DMARC protect against forged senders.

See DNS, HTTP Fundamentals and Caching, Cookies and State.

Python Port, protocol and status lookup

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Security

  • CIA triad: confidentiality, integrity, availability.
  • Crypto roles: symmetric (AES, ChaCha20) for bulk data; asymmetric (RSA, ECDSA, X25519) for authentication and key exchange; hashes (SHA-256) and MACs (HMAC) for integrity.
  • TLS 1.3: ClientHello (with key share and SNI) โ†’ ServerHello, certificate, finished โ†’ client finished; one round trip, forward secrecy always. ALPN picks h2 or http/1.1; HSTS forces HTTPS.
  • Firewalls: stateless packet filters vs stateful inspection; DMZ for public servers. VPNs: IPsec (ESP, IKE), WireGuard (UDP 51820), TLS-based VPNs.
  • Attacks and defenses: ARP spoofing (dynamic ARP inspection), DNS spoofing (DNSSEC, DoH/DoT), SYN flood (SYN cookies), amplification DDoS (source address validation, rate limiting), port scans (firewall, IDS).

See TLS and HTTPS and Firewalls, VPNs and Intrusion Detection.

Tool commands

These are read-only here because they need a real network.

Terminal
# Reachability and path
ping -c 4 example.com              # Windows: ping -n 4
traceroute example.com             # Windows: tracert; mtr for a live view
ping -M do -s 1472 example.com     # path MTU probe (Linux): 1472 + 28 = 1500

# Names
dig example.com A +short
dig @1.1.1.1 example.com MX
dig +trace example.com
nslookup example.com

# Local configuration (Linux)
ip addr                            # addresses
ip route                           # routing table
ip neigh                           # ARP cache
ss -tulpn                          # listening sockets and their processes
ss -tan state established          # established TCP connections
# Windows equivalents: ipconfig /all, route print, arp -a, netstat -ano

# HTTP and TLS
curl -v https://example.com        # request, headers, TLS details
curl -I https://example.com        # response headers only
curl -w '%{time_namelookup} %{time_connect} %{time_appconnect} %{time_total}\n' -o /dev/null -s https://example.com
openssl s_client -connect example.com:443 -servername example.com

# Capture and scan
tcpdump -i eth0 -nn 'tcp port 443 and host 203.0.113.9'
tcpdump -i any -nn udp port 53 -w dns.pcap
nmap -sS -p 1-1024 192.0.2.10      # only scan hosts you are authorized to test
whois example.com

Wireshark display filters: ip.addr == 10.0.0.5, tcp.port == 443, tcp.flags.syn == 1 && tcp.flags.ack == 0, dns, http.request, tls.handshake.type == 1, tcp.analysis.retransmission. A capture filter (tcpdump syntax) limits what is recorded; a display filter only hides packets already captured. See Essential Network Tools and Packet Capture with tcpdump and Wireshark.

Troubleshooting order: link and cable โ†’ IP, mask, gateway (ip addr, ip route) โ†’ ping the gateway โ†’ ping a public IP โ†’ DNS (dig) โ†’ TCP port (curl -v, ss) โ†’ application logs. Mismatch between "ping an IP works" and "name fails" points at DNS; small packets work but large ones hang points at MTU or MSS. See Troubleshooting Network Problems.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the usual TCP MSS on an Ethernet link with a 1,500-byte MTU and no options?

    The MTU covers the IP header (20 bytes) and the TCP header (20 bytes), leaving 1,460 bytes for TCP payload.
  2. 2. Which port range holds the ephemeral (dynamic) ports?

    Clients normally take a source port from the dynamic range 49152-65535 (Linux defaults to 32768-60999).
  3. 3. How many usable host addresses does a /28 block contain?

    A /28 leaves 4 host bits: 16 addresses, minus the network and broadcast addresses, gives 14.
  4. 4. Which pair is correct for 401 and 403?

    401 asks the client to authenticate. 403 says the server understood who you are (or does not care) and still refuses.

Summary

  • Remember the stack: application (names), transport (ports), internet (IP), link (MAC), physical (bits), and which PDU belongs to each.
  • Keep the key numbers handy: port ranges, 1,460-byte MSS, 1,500-byte MTU, 64-byte minimum frame, 20-byte IPv4 and TCP headers, 8-byte UDP header, 40-byte IPv6 header.
  • Subnet math is powers of two: addresses = 2(32 โˆ’ prefix), usable = that โˆ’ 2.
  • Delay, utilization and window formulas follow from transmission time, propagation time and the round trip.
  • Troubleshoot bottom-up and let each tool (ping, dig, curl, ss, tcpdump) prove one layer.

Back to the start of the review: Practice: Addressing and Routing Exercises