Back to Articles
Cloud & Network6 min readHow Internet Requests Actually Work · Part 5 of 8

Packets and Network Layers: MAC, Switches, Routers, and Gateways

Follow application data as it is encapsulated into TCP segments, IP packets, and Ethernet or Wi-Fi frames, then forwarded through switches, routers, and a default gateway.

PacketsNetwork LayersRouterSwitchMAC Address

Application data is wrapped as it moves down the networking stack. Each layer adds information required for its job, and the receiver removes that information in reverse. This is encapsulation.

Diagram 1

What Is a Network Packet?

Packets carry addressing and protocol headers around a piece of payload as data crosses an IP network.

HTTP data -> TLS records -> TCP segments -> IP packets -> Ethernet or Wi-Fi frames -> Signals

What a Packet Carries

At the IP layer, a packet contains source and destination information plus a transport payload. That payload may hold part of a TCP stream or a UDP datagram. Real headers contain more fields, but source, destination, protocol, lifetime, and payload are the useful starting concepts.

The envelope analogy explains headers and payload, but traffic is nested: an Ethernet frame can carry an IP packet, which carries a TCP segment, which carries TLS-protected HTTP bytes.

The Simplified Layer Model

Application
HTTP, DNS, SSH, MQTT, and similar protocols define meaning.
Transport
TCP or UDP identifies ports and provides transport behavior.
Network
IP provides addressing and routing across networks.
Local link
Ethernet or Wi-Fi moves frames across the current segment.
Physical
Copper, fiber, and radio carry encoded signals.

MAC and IP Addresses Have Different Scope

A MAC address is used on a local link. An IP address is used across routed networks. When a laptop contacts a distant server, the IP destination can remain that server while the local frame is addressed to the MAC address of the next hop—usually the default gateway. A new link-layer frame is created at each routed link.

Switches and Routers

A switch connects devices within a local Ethernet network. It learns which MAC addresses are reachable through its ports and forwards frames accordingly. A router connects IP networks, examines destination IP addresses, and selects the next route for packets.

Diagram 2

Routers, Switches, Gateways, and NAT

Switches forward local frames, routers connect IP networks, the default gateway is the route outward, and NAT translates endpoints at the boundary.

Local and routed forwarding

PC -> switch -> printer on the same networkPC -> switch or Wi-Fi -> default gateway for a remote networkGateway -> ISP -> internet routers -> destination network

Default Gateways and TTL

If no more specific route matches, a host sends the packet toward a default gateway. Each router needs a suitable next hop rather than knowledge of the complete physical path. The packet's TTL acts as a hop limit; routers decrement it and discard the packet at zero so routing loops cannot circulate forever.

Follow the scope

MAC gets a frame across the current link. IP and routers move a packet across networks. Transport ports deliver its contents to the correct endpoint service.

Series

How Internet Requests Actually Work

An eight-part beginner series tracing internet communication from an HTTP request through DNS, IP, ports, transport protocols, packets, network devices, server infrastructure, security, and troubleshooting.

Part 5 of 8
About the Author

Nikhlesh Yadav is a Technical Lead and Solution Architect with 12+ years of experience across cloud-native systems, distributed platforms, AI integrations, Web3, and cyber security.

Read full profile