Fundamentals

Understanding network layers

Network communication is built in layers. Each layer has a job, and understanding them helps you read packet captures without getting lost.

4 min readLesson 2

Captures used in this lesson

When you open a PCAP and look at a single packet, you will see it broken down into layers. Wireshark shows these as expandable sections: Ethernet, IP, TCP, HTTP, and so on. Each one wraps around the next like an envelope inside an envelope.

This is not just a display choice. Networks are actually designed this way.

Why layers exist

Imagine you are sending a letter. You write the message (the data), put it in an envelope with the recipient's address (addressing), and hand it to the postal service (delivery). The postal service does not care what is in the envelope. Your recipient does not care how the postal service routed it. Each part of the system handles one job and trusts the others to handle theirs.

Networks work the same way. Each layer handles one concern and passes data up or down to the next layer.

The layers you will see in a PCAP

In practice, most traffic you capture will have four layers:

Layer 2: Data Link (Ethernet)

This is the lowest layer you will typically see in a PCAP. It contains MAC addresses, which identify devices on the local network segment. The Ethernet header tells you which physical device sent the frame and which device should receive it.

MAC addresses look like 00:1a:2b:3c:4d:5e. They are assigned to network interface cards by the manufacturer.

Ethernet (Layer 2)

Handles communication between devices on the same local network using MAC addresses. Every packet in most PCAPs starts with an Ethernet frame.

  • Source MAC: who sent it
    • Destination MAC: who should receive it
    • EtherType: what protocol comes next (0x0800 = IPv4, 0x86DD = IPv6)

Layer 3: Network (IP)

The IP layer handles addressing across networks. While MAC addresses only work on a local segment, IP addresses can route traffic across the entire internet.

Every IP packet has a source address (where it came from) and a destination address (where it is going). This is usually the first thing you look at when analysing a capture: who is talking to whom.

Layer 4: Transport (TCP/UDP)

The transport layer adds port numbers, which identify which application on the machine should receive the data. Port 80 is HTTP, port 443 is HTTPS, port 53 is DNS, and so on.

TCP also adds reliability: sequence numbers, acknowledgments, and flow control. UDP is simpler and just sends data without guarantees.

Layer 7: Application (HTTP, DNS, TLS, etc.)

This is where the actual content lives. An HTTP request, a DNS query, an email, a file transfer. If the traffic is not encrypted, you can read it directly. If it is encrypted (TLS), you will see the handshake but not the payload.

How layers appear in a packet viewer

When you expand a packet in a viewer, you read it from top to bottom:

  1. Frame (metadata about the capture itself: timestamp, length)
  2. Ethernet (MAC addresses)
  3. IP (source and destination IP addresses)
  4. TCP or UDP (ports and connection state)
  5. Application protocol (HTTP, DNS, TLS, etc.)

Each layer only knows about its own job. The Ethernet layer does not understand HTTP. The TCP layer does not care what application data it is carrying. This separation is what makes the whole system work.

Which layer contains IP addresses?

What do port numbers identify?

Practical tip

When you are analysing a capture and feeling overwhelmed, ask yourself: "What layer am I looking at?" If you are trying to understand who is communicating, look at Layer 3 (IP addresses). If you are trying to understand what service is being used, look at Layer 4 (ports). If you want to see the actual content, look at Layer 7 (application data).

Working one layer at a time keeps things manageable.