Rolling Thunder Security · Codex · Network Security 01

The OSI Model & the
Journey of a Packet

Networks pass data through seven conceptual layers. Each layer adds its own envelope on the way out and strips that envelope on the way in. Watch Alice's message "Hello, Bob!" get wrapped, transmitted, and unwrapped, one layer at a time, from chat window to chat window.

Concept · Encapsulation Skill · Read a packet Prereq for · Sniffing, spoofing, firewalls
01
The Concept

Seven layers, one packet

The Open Systems Interconnection (OSI) reference model splits the work of moving data across a network into seven distinct layers. Each layer has one job. The application layer worries about what the data means. The physical layer worries about voltages on copper or photons in fiber. The layers in between handle everything that has to happen so the bytes typed on Alice's keyboard reach Bob's screen intact.

When data leaves Alice's computer it travels down her stack. At each layer a header is added that lets that layer's counterpart on the other side do its job. This is called encapsulation. When data arrives at Bob's computer it travels up his stack. At each layer the corresponding header is read and stripped. This is called decapsulation. The packet that crosses the wire carries every header from every layer it passed through, nested like envelopes inside envelopes.

Why this matters for security

Every attack you will study lives at a specific layer. ARP poisoning is layer 2. IP spoofing is layer 3. SYN floods are layer 4. SQL injection and phishing are layer 7. Firewalls and intrusion detection systems each operate at one or more specific layers. If you cannot say what layer an attack lives at, you cannot pick the right defense.

Top down

  • 7Application· what the data means
  • 6Presentation· how it is encoded
  • 5Session· how the conversation persists
  • 4Transport· reliable end to end delivery
  • 3Network· routing across networks
  • 2Data Link· one hop across a link
  • 1Physical· signals on the medium

Mnemonic, top down

Old standard for memorizing layer 7 down to layer 1:

All People Seem To Need Data Processing

Bottom up, often used to remember the order data is encapsulated:

Please Do Not Throw Sausage Pizza Away

02
Interactive Walkthrough

Follow the packet

Alice sends Bob a one-line message from her chat client. Step through each state to watch the message grow as it descends Alice's stack, fly across the network, and shrink as it ascends Bob's stack. Click any layer card to see the protocol description.

00 / 15
Idle · awaiting input SENDER · LAYER 7
Sender
2.2s

Alice

Sender
IP192.168.1.100
MACaa:bb:cc:dd:ee:ff
AppZephyrChat v2.1
Packet on the Wire
size: 0 bytes

Bob

Receiver
IP203.0.113.50
MAC11:22:33:44:55:66
AppZephyrChat v2.1
What is happening

Alice has typed her message but has not pressed send. The OSI stack is idle.

Technical detail
Cursor in chat input. No bytes have been handed to the protocol stack yet.
Idle
Layer in focus

No active layer

PDU: —

Select a state or press Play to begin the walkthrough.

03
Layer by Layer

What each layer actually does

Each card below describes one OSI layer, the kind of data unit it works with (its PDU, or Protocol Data Unit), what protocols ride at that layer, and the typical header fields you will see in a packet capture.

7

Application

PDU · Data

The layer the user actually touches. It defines the rules of the conversation the application is having: how to ask for a webpage, how to send an email, how to look up a domain. The application does not concern itself with how the bytes get delivered, only with what they should say.

  • HTTP / HTTPS
  • DNS
  • SMTP / IMAP
  • SSH
  • FTP
  • SMB

Typical HTTP request

  • methodPOST
  • path/api/v1/messages
  • hostchat.zzz.local
  • content-typeapplication/json
  • body{"to":"bob","text":"Hello, Bob!"}
6

Presentation

PDU · Data

Translates between the application's view of the data and what is actually sent on the wire. Character encoding (UTF-8, ASCII), compression, and most importantly the cryptographic envelope (TLS) live here. By the time the bytes leave this layer they should look like noise to anyone watching the cable.

  • TLS / SSL
  • UTF-8
  • ASCII
  • JPEG / PNG
  • gzip
  • MIME

TLS record header

  • type0x17 application_data
  • version0x0304 TLS 1.3
  • length0x0040 (64 bytes)
  • ciphertext04 a9 b3 f2 7c 81 d2 1e ...
5

Session

PDU · Data

Opens, manages, and closes the long-running conversation between two endpoints. Tracks dialogues, synchronizes checkpoints, and decides who can speak next. In modern TCP/IP stacks this responsibility is often blended into the application and transport layers, but the OSI model gives it its own seat at the table.

  • NetBIOS
  • RPC
  • PPTP
  • SOCKS
  • session cookies

Session context

  • session_id8f4a-2c91-bd17
  • stateestablished
  • authbearer eyJ...
  • last_seq0x0042
4

Transport

PDU · Segment (TCP) / Datagram (UDP)

End-to-end delivery between two specific processes on two specific hosts. TCP guarantees the bytes arrive in order with no duplicates or losses by using sequence numbers, acknowledgments, and retransmissions. UDP does no such thing and gets out of the way for speed. Port numbers identify the application on each side.

  • TCP
  • UDP
  • QUIC
  • SCTP

TCP header

  • src_port49152
  • dst_port443
  • seq0x9C3E1A47
  • ack0x000003B2
  • flagsACK PSH
  • window65535
  • checksum0x1A2B
3

Network

PDU · Packet

Moves packets between networks. Provides the logical addressing (IP) that lets a packet starting in Columbus reach a server in Chicago by hopping through routers that have never met either endpoint. Each router reads the destination IP, picks the next hop, decrements the TTL, and forwards.

  • IPv4 / IPv6
  • ICMP
  • IPsec
  • OSPF
  • BGP

IPv4 header

  • version4
  • ttl64
  • protocol6 (TCP)
  • src_ip192.168.1.100
  • dst_ip203.0.113.50
  • total_len0x012C
  • checksum0xDEAD
2

Data Link

PDU · Frame

Moves a frame across one physical link, from one network interface to the next directly connected interface. Uses MAC addresses, which are local to that link only, and verifies the frame survived transit with a Frame Check Sequence (CRC32). Routers strip and rebuild this header at every hop.

  • Ethernet (802.3)
  • Wi-Fi (802.11)
  • ARP
  • VLAN (802.1Q)
  • PPP

Ethernet frame

  • dst_mac00:1a:2b:3c:4d:5e
  • src_macaa:bb:cc:dd:ee:ff
  • ethertype0x0800 (IPv4)
  • payload[IP packet]
  • FCS0xC0FFEE01
1

Physical

PDU · Bits · symbols on a medium

The bytes from layer 2 become electrical voltages on copper, light pulses in fiber, or radio waves in the air. Defines the cable type, connector, signaling scheme, and bit rate. The physical layer has no idea what the bits mean. It just transports them faithfully.

  • 100BASE-TX
  • 1000BASE-T
  • 1000BASE-SX
  • RJ45
  • SFP
  • radio (802.11 PHY)

On the wire

  • encoding4B5B / MLT-3
  • bit_rate100 Mbit/s
  • mediumCat5e UTP
  • first_bits0100 1000 0110 0101 0110 1100 0110 1100 ...
04
Security Implications

Every layer has its own attack surface

Every OSI layer adds something useful, and every OSI layer therefore adds something to attack. The card for each layer below names the kinds of threats that live there and the controls a defender can stand up to mitigate them. As you progress through the rest of Rolling Thunder Security you will go deeper into many of these.

7

Application

  • SQL injection, XSS, CSRF
  • Phishing & credential theft
  • Malware in downloads
  • API abuse, broken auth
  • Defenses: input validation, WAF, MFA, secure coding
6

Presentation

  • Weak ciphers / downgrade attacks
  • Expired or rogue certificates
  • Padding oracle attacks
  • SSL stripping
  • Defenses: TLS 1.3, strong cipher suites, certificate pinning, HSTS
5

Session

  • Session hijacking
  • Cookie theft & replay
  • Fixation attacks
  • RPC abuse
  • Defenses: short timeouts, HttpOnly + Secure cookies, rotate session IDs on auth
4

Transport

  • Port scanning (nmap)
  • SYN flood denial of service
  • TCP sequence prediction
  • Reset injection
  • Defenses: stateful firewalls, SYN cookies, rate limiting, IPS
3

Network

  • IP spoofing
  • ICMP tunneling / pings of death
  • Route hijacking (BGP)
  • Smurf attacks
  • Defenses: ingress / egress filtering, RPF, IPsec, segmentation
2

Data Link

  • ARP poisoning / MITM on LAN
  • MAC flooding / CAM overflow
  • VLAN hopping
  • Rogue DHCP / DHCP starvation
  • Defenses: port security, DHCP snooping, dynamic ARP inspection, 802.1X
1

Physical

  • Cable taps & passive sniffing
  • RF eavesdropping (Wi-Fi)
  • Cut cables / signal jamming
  • Theft of network equipment
  • Defenses: locked closets, conduit, fiber where feasible, RF site survey
05
Key Takeaways

What to remember

i.

Encapsulation is wrapping

Going down the stack means adding a header. Going up the stack means stripping that same header. Headers are not magic, they are bytes.

ii.

One header per layer

Each layer reads only its own header. Layer 3 does not care what is inside the layer 4 segment, and layer 4 does not care what is in the application data.

iii.

Locality differs by layer

MAC addresses are good for one hop. IP addresses cross routers. Ports identify processes. Application data is only meaningful to the two endpoints.

iv.

Routers operate at layer 3

Every router along the path strips the layer 2 frame, looks at the layer 3 destination, and rewraps the packet in a fresh layer 2 frame for the next link.

v.

Identify the layer first

When troubleshooting or investigating an attack, the first question is always: at what layer is this happening? The answer narrows the suspect list dramatically.

vi.

TCP/IP collapses the top three

Real-world TCP/IP stacks combine layers 5, 6, and 7 into a single Application layer. The OSI model still gives you sharper vocabulary when describing what is happening.