← All lessons Stage 1 · Lesson 3
20 min

TCP/IP without the textbook

Stage 1 · Lesson 3 · 20 minutes · Requires Lessons 1–2


The one-line answer

Data is chopped into packets, each wrapped in layers of addressing, and either delivered reliably (TCP) or thrown as fast as possible (UDP).


Why you should care

Networking is where most beginners give up, because it is usually taught as a diagram to memorise rather than a thing to understand.

You need it for three reasons. Scanning makes no sense without knowing what a scanner sends. Firewalls and segmentation are the main defensive controls in any network. And traffic analysis — reading a packet capture — is a core blue team skill and a very common interview exercise.

We will skip the parts you will never use.


How it actually works

Layers, briefly

Data gets wrapped like an envelope inside an envelope. Each layer adds its own addressing.

LayerAddsExample
ApplicationThe actual contentHTTP, DNS, SSH
TransportPort numbers, reliabilityTCP, UDP
NetworkIP addresses, routingIP
LinkMAC addresses, local deliveryEthernet, Wi-Fi

Sending a request wraps it downward. Receiving unwraps it upward.

Why this matters practically: a firewall rule usually operates at the network and transport layers — it sees IP addresses and ports. It does not see HTTP paths unless it is specifically an application-layer firewall. That distinction explains a great deal about what defences catch and what they miss.

You may hear about the seven-layer OSI model. In practice, people say "layer 3" meaning IP, "layer 4" meaning TCP/UDP, and "layer 7" meaning the application. Learn those three phrases and you can hold any conversation in this field.

TCP — reliable and connection-oriented

TCP guarantees delivery, ordering, and retransmission of anything lost. It costs some speed in exchange.

The three-way handshake opens every TCP connection:

Client                          Server
  │                                │
  │────────  SYN  ────────────────>│   "Can we talk?"
  │                                │
  │<───────  SYN-ACK  ─────────────│   "Yes, can we?"
  │                                │
  │────────  ACK  ────────────────>│   "Yes. Beginning."
  │                                │
  │═════  connection open  ════════│

This handshake is the foundation of port scanning, so understand what each outcome means:

Server respondsPort stateWhat it tells you
SYN-ACKOpenA service is listening here
RSTClosedHost is alive, nothing on this port
NothingFilteredA firewall dropped the probe silently

That is exactly the open/closed/filtered distinction from Stage 0 Lesson 2 — now you know the mechanism behind it.

Connection teardown uses FIN packets, or an abrupt RST to kill a connection immediately.

Flags you will see in a packet capture:

FlagMeaning
SYNOpen a connection
ACKAcknowledging received data
FINClose gracefully
RSTAbort immediately
PSHDeliver this to the application now

UDP — fast and connectionless

No handshake, no guarantee, no ordering. Send and hope.

Used where speed beats reliability: DNS, video streaming, VoIP, gaming, and increasingly HTTP/3 via QUIC.

Security consequences of no handshake:

Source addresses are trivially spoofed, because nothing verifies the sender. That enables amplification attacks — send a small DNS or NTP query with a forged source address, and the server sends a much larger reply to the victim. A 60-byte request producing a 4,000-byte response gives the attacker roughly 67× amplification for free.

UDP scanning is also slow and ambiguous, because "no response" might mean open, or filtered, or the packet was simply lost.

What is actually in a packet

You do not need every header field. These matter:

IP header: source address, destination address, TTL, protocol.

TTL (time to live) decrements at each router hop and the packet dies at zero — preventing infinite loops. It also fingerprints operating systems, because defaults differ: Linux typically 64, Windows 128, some network devices 255. A TTL of 57 arriving at you suggests a Linux host seven hops away.

TCP header: source port, destination port, sequence number, acknowledgement number, flags, window size.

Sequence numbers order the data and detect loss. They are randomised at connection start specifically because predictable sequence numbers historically allowed connection hijacking.

MAC addresses and ARP

Inside a local network, delivery uses MAC addresses — hardware identifiers like a4:83:e7:1c:9d:22.

ARP maps an IP address to a MAC address: "who has 192.168.1.1?" broadcast to everyone, and the owner replies.

ARP has no authentication whatsoever. Any device can reply claiming any IP. That is ARP spoofing, and it is how an attacker on the same network positions themselves between you and the router — a man-in-the-middle attack that requires no vulnerability, just presence on the network.

This is one concrete reason public Wi-Fi is risky, and why network segmentation matters internally.

NAT, revisited

Your router rewrites private source addresses to its single public address and tracks which internal machine each connection belongs to.

Two security consequences worth holding onto: inbound connections cannot reach internal machines unless deliberately forwarded, which is accidental protection rather than a designed firewall. And in logs, many devices appear as one address — which is why attribution behind NAT requires timestamps and port numbers, not just an IP.


See it yourself

Watch a handshake:

curl -v http://example.com

The verbose output shows the connection being established before any HTTP is sent.

Trace the path:

traceroute example.com        # Mac/Linux
tracert example.com           # Windows

Each line is a router between you and the destination. This works by sending packets with deliberately low TTLs and reading which router complains.

See your own connections:

ss -tunap        # Linux
netstat -ano     # Windows
lsof -i          # Mac

Every open connection your machine currently has, with local and remote addresses and ports.

Read real traffic.

Install Wireshark — it is free, and it is the standard tool for this in every SOC.

  1. Start a capture on your active interface
  2. Visit http://example.com in a browser (deliberately not HTTPS)
  3. Stop the capture
  4. Filter with http in the display filter bar
  5. Right-click a packet → Follow → HTTP Stream

You will see the entire request and response in plain text. That is the single most persuasive demonstration of why HTTP without TLS is unacceptable — and it is far more convincing seen once than explained ten times.

Then repeat with https://example.com and filter on tls. You will see the handshake, the certificate exchange, and then nothing readable. The encryption is doing exactly what Stage 0 Lesson 6 described.

Boundary: capture only your own traffic on your own network. Capturing traffic on a network you do not administer — a campus network, an office network, a café — is interception, and Stage 0 Lesson 9 applies with full force. In India this can engage the IT Act and the Telecommunications Act, 2023 (which replaced the old Telegraph Act). Use your own machine and your own connection.


How attackers abuse this

SYN scanning. Send SYN, read the reply, never complete the handshake. Faster than a full connection and historically less logged, which is why it is nmap's default when run with privileges.

SYN flooding. Open thousands of half-connections and never complete them, exhausting the server's connection table. SYN cookies are the standard defence.

ARP spoofing. Claim to be the gateway, intercept all local traffic, then relay it onward so nothing appears broken. Combined with tools that strip TLS or exploit users clicking through certificate warnings, this is a practical attack on any flat network.

Amplification DDoS. Spoof the victim's address, query open DNS, NTP or memcached servers, and let the responses overwhelm them.

Firewall evasion. Fragmenting packets, using unusual flag combinations, or sending traffic on ports that policy permits — commonly 53 or 443 — because those are rarely blocked outbound.

Tunnelling. Wrapping one protocol inside another to escape restrictions. DNS tunnelling from Stage 0 Lesson 4 is the classic; SSH over 443 is the everyday version.

Passive sniffing. On an unencrypted or poorly segmented network, simply listening reveals credentials, session cookies and internal hostnames without sending a single packet.


Common mistakes

"TCP is secure, UDP is not." Neither provides confidentiality or authentication. TCP provides reliability. Security comes from TLS on top, not from the transport layer.

"Internal networks do not need encryption." Stage 0 Lesson 1 covered why private addresses are not protection. Once an attacker is inside — through a phished user or a compromised web server — unencrypted internal traffic is a gift. This is precisely the reasoning behind zero trust architectures.

"My firewall blocks everything dangerous." Most firewalls filter inbound aggressively and outbound loosely. Attackers know this, which is why command-and-control traffic almost always leaves over 443 and looks like ordinary HTTPS.

"I need to memorise the OSI model." You need layer 3, layer 4 and layer 7 as vocabulary. The rest is exam material.


Check yourself

  1. You send a SYN to port 8080 and receive RST. What have you learned, and how does it differ from receiving nothing?
  2. Why does UDP enable amplification attacks when TCP largely does not?
  3. An attacker is on the same Wi-Fi network as you. Why is ARP spoofing possible without exploiting any software vulnerability?
Answers
  1. RST means the port is closed — but critically, the host is alive and reachable. Receiving nothing means filtered: a firewall silently dropped the probe, so you learn nothing about the host. From a defender's perspective, dropping is preferable to rejecting because it gives an attacker less information.
  1. UDP requires no handshake, so the source address is never verified. An attacker forges the victim's address in a small query and the server sends a much larger response to the victim. TCP's three-way handshake means the responder must receive an ACK from the claimed source before sending substantial data, which a spoofing attacker never sees.
  1. ARP has no authentication built into the protocol. Any device on the segment can broadcast a reply claiming to own any IP address, and other devices simply believe it. It is a design assumption from an era when local networks were trusted — not a bug, which is why the fix is segmentation, dynamic ARP inspection, and encrypting traffic rather than patching.

Your lab

Challenge 10 — Traffic capture walkthrough

You will be given a packet capture file. Find the credentials transmitted in the clear, and identify which host sent them.

→ Open Stage 1 labs


Summary in your language

தமிழ் சுருக்கம் (Tamil summary)

TCP/IP — புத்தகம் இல்லாமல்

தரவு சிறு துண்டுகளாக (packets) பிரிக்கப்பட்டு, ஒவ்வொன்றும் பல அடுக்குகளால் மூடப்பட்டு அனுப்பப்படுகிறது.

மூன்று layer-கள் தெரிந்தால் போதும்:

  • Layer 3 — IP address (எந்த machine)
  • Layer 4 — TCP/UDP, port (எந்த service)
  • Layer 7 — HTTP, DNS (உண்மையான உள்ளடக்கம்)

TCP — நம்பகமானது

இணைப்பு தொடங்க three-way handshake நடக்கும்:

Client ──SYN──────> Server      "பேசலாமா?"
Client <─SYN-ACK─── Server      "ஆம், நாமும்?"
Client ──ACK──────> Server      "ஆம். தொடங்கலாம்."

Port scanning-ன் அடிப்படை இதுதான்:

பதில்பொருள்
SYN-ACKOpen — service இயங்குகிறது
RSTClosed — machine உயிருடன் உள்ளது, ஆனால் இந்த port-ல் ஒன்றுமில்லை
பதிலே இல்லைFiltered — firewall அமைதியாக நிராகரித்தது

UDP — வேகமானது, உத்தரவாதம் இல்லை

handshake இல்லை. DNS, video call, gaming-க்கு பயன்படுகிறது.

பாதுகாப்பு பிரச்சனை: அனுப்புநரின் முகவரியை சரிபார்ப்பதே இல்லை. எனவே amplification attack சாத்தியம் — சிறிய கேள்வி அனுப்பி, பெரிய பதிலை பாதிக்கப்பட்டவருக்கு திருப்பிவிடலாம்.

ARP spoofing — பொது Wi-Fi ஆபத்தானது ஏன்?

Local network-ல் IP-ஐ MAC address ஆக மாற்ற ARP பயன்படுகிறது. ஆனால் ARP-ல் எந்த authentication-ம் இல்லை.

எந்த device-ம் "நான்தான் router" என்று சொல்லலாம். மற்ற devices நம்பிவிடும். இப்படி attacker உங்களுக்கும் router-க்கும் இடையில் நுழைந்துவிடுவார் — இதற்கு எந்த software bug-ம் தேவையில்லை.

நீங்களே பார்க்கவும்: Wireshark

  1. Wireshark நிறுவுங்கள் (இலவசம்)
  2. capture தொடங்குங்கள்
  3. http://example.com பாருங்கள் (HTTPS அல்ல)
  4. filter-ல் http எழுதுங்கள்
  5. வலது-கிளிக் → Follow → HTTP Stream

முழு request-ம் response-ம் தெளிவாக தெரியும். HTTPS இல்லாத website ஏன் ஆபத்தானது என்பதை இதைவிட நன்றாக எதுவும் விளக்காது.

எச்சரிக்கை: உங்கள் சொந்த network-ல், உங்கள் சொந்த traffic-ஐ மட்டும் capture செய்யுங்கள். கல்லூரி அல்லது அலுவலக network-ல் பிறரின் traffic-ஐ படிப்பது சட்டவிரோதம் — IT Act பொருந்தும்.

हिंदी सारांश (Hindi summary)

TCP/IP — बिना किताब के

Data छोटे टुकड़ों (packets) में बँटकर, कई परतों में लिपटकर भेजा जाता है।

तीन layers जान लें, काफ़ी है:

  • Layer 3 — IP address (कौन सी machine)
  • Layer 4 — TCP/UDP, port (कौन सी service)
  • Layer 7 — HTTP, DNS (असली सामग्री)

TCP — भरोसेमंद

connection शुरू करने के लिए three-way handshake होता है:

Client ──SYN──────> Server      "बात करें?"
Client <─SYN-ACK─── Server      "हाँ, हम भी?"
Client ──ACK──────> Server      "हाँ। शुरू करते हैं।"

Port scanning का आधार यही है:

जवाबमतलब
SYN-ACKOpen — service चल रही है
RSTClosed — machine ज़िंदा है, पर इस port पर कुछ नहीं
कोई जवाब नहींFiltered — firewall ने चुपचाप गिरा दिया

UDP — तेज़, पर कोई गारंटी नहीं

कोई handshake नहीं। DNS, video call, gaming में इस्तेमाल होता है।

सुरक्षा समस्या: भेजने वाले का पता जाँचा ही नहीं जाता। इसलिए amplification attack संभव है — छोटा सवाल भेजकर, बड़ा जवाब पीड़ित की ओर मोड़ा जा सकता है।

ARP spoofing — public Wi-Fi ख़तरनाक क्यों है?

Local network में IP को MAC address में बदलने के लिए ARP इस्तेमाल होता है। लेकिन ARP में कोई authentication नहीं है।

कोई भी device कह सकता है "मैं ही router हूँ"। बाक़ी devices मान लेते हैं। इस तरह attacker आपके और router के बीच आ जाता है — इसके लिए किसी software bug की ज़रूरत नहीं।

ख़ुद देखें: Wireshark

  1. Wireshark install करें (मुफ़्त)
  2. capture शुरू करें
  3. http://example.com खोलें (HTTPS नहीं)
  4. filter में http लिखें
  5. right-click → Follow → HTTP Stream

पूरा request और response साफ़ दिखेगा। HTTPS के बिना website क्यों ख़तरनाक है, इससे बेहतर कोई समझा नहीं सकता।

चेतावनी: सिर्फ़ अपने network पर, अपनी traffic capture करें। कॉलेज या ऑफ़िस के network पर दूसरों की traffic पढ़ना ग़ैरक़ानूनी है — IT Act लागू होता है।

Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.


What's next

You know how packets travel. Now the conversation they carry — HTTP examined properly, at the level you will actually work with it.

→ Lesson 4: Request and response, line by line