Module 2 · Networking Fundamentals · Lesson 4 of 75

How data travels: layers, packets, switches and routers

The OSI and TCP/IP models, encapsulation, MAC versus IP addresses, and what switches and routers actually do.

In this lesson · about 35 minutes

  • Name the seven OSI layers and the four TCP/IP layers
  • Explain encapsulation using headers at each layer
  • Tell a MAC address from an IP address, and a switch from a router

The OSI model: seven layers

The OSI model splits networking into seven layers, so each problem can be discussed on its own. Security people use it constantly: "that's a layer 7 attack" means it targets the application, not the cables.

#LayerWhat lives hereExample attacks or controls
7ApplicationHTTP, DNS, SMTP, SSHSQL injection, phishing, web application firewall
6PresentationEncoding, compression, encryption (TLS is often placed here)Weak TLS versions
5SessionOpening and keeping conversationsSession hijacking
4TransportTCP and UDP, portsSYN flood, port scanning
3NetworkIP addresses, routersIP spoofing, firewall rules by address
2Data linkMAC addresses, switches, Wi-Fi framesARP spoofing, MAC flooding, VLANs
1PhysicalCables, radio, lightWire-tapping, jamming, locked network cupboards

Memory aid, from layer 1 up: Please Do Not Throw Sausage Pizza Away.

The TCP/IP model is the one the internet really uses. It squeezes the seven into four: Link (1–2), Internet (3), Transport (4) and Application (5–7).

Encapsulation

Going down the layers, each one wraps the data in its own header: the application data gets a TCP header (ports) to become a segment, then an IP header (addresses) to become a packet, then an Ethernet header and trailer (MAC addresses) to become a frame, then bits on the wire. The receiver unwraps in reverse.

MAC versus IP addresses

  • MAC address (layer 2): burned into the network card, 48 bits written in hex, such as 3C:22:FB:91:0A:4E. Only used on the local network. Easy to fake ("MAC spoofing"), so never rely on it alone for security.
  • IP address (layer 3): given by the network, such as 192.168.1.20. Used to route data between networks, all the way across the internet.

Switches and routers

  • A switch connects devices on the same network. It learns which MAC address is on which port and sends each frame only where it needs to go.
  • A router connects different networks, choosing the next hop by IP address. Your home "router" is really a router, a switch, a Wi-Fi access point and a firewall in one box.

Try it · watch it move

Wrap a message like a parcel

Watch a message get wrapped layer by layer on the way down and unwrapped on the way up. Pause on each header and say what it adds.

The letter itself · Application

Please send me the menu page

💻 Wrapping on your laptop
📮 Relabelled at a router
🗄️ Unwrapping at the server
Step 1 of 7Your browser writes the message: 'please send me the menu page'. This is the application layer: the actual conversation.

Try it · watch it move

Follow a packet's trip

Follow one packet from a laptop to its destination. Notice which devices it passes through, and remember: the IP address stays the same end to end, while the MAC label is rewritten for every leg.

Send something:
Your local network💻Your laptop10.10.10.20🖨️Printer10.10.10.30🔀Switchmail room📮Routerpost office☁️The internetmany routers🗄️Web server93.184.215.14to website
Building label (MAC)to router 00:1a:2b:3c:4d:01
Street address (IP)to 93.184.215.14
Door number (port)443 (secure web)
Step 1 of 6You open a website. Its server is at 93.184.215.14, which is NOT on your local network. So your laptop does what you do with a letter to another city: it hands it to the post office. On a network, the post office is the router, called the default gateway.

Sorting drill

Which layer?

Place each item on its OSI layer group.

  • A MAC address
  • A router choosing the next hop
  • TCP port 443
  • An HTTP GET request
  • A switch learning which device is on port 7
  • A SYN flood
  • A phishing email
  • An IP address of 10.0.0.5

0 of 8 sorted

Check your understanding0 of 4 correct

Question 1

1.At which OSI layer do routers make decisions?

Question 2

2.As a packet crosses three routers, which address changes at every hop?

Question 3

3.A TCP header is added at which layer?

Question 4

4.Why is filtering by MAC address alone weak security?

Quiz score: 0 of 4

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.