Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, An Introduction to Computer Networking for Teachers. Join the course to learn more.

Skip to 0 minutes and 3 seconds Transporting both data and IP packets across a variety of links and devices poses as a problem. One solution is to redesign all data link protocols to understand IP addressing and packet structure. But this redesign would render much of the existing network infrastructure we have redundant. Instead, we can use the data link protocols to transport the IP packets as their data. Previously you learned that frames transport data from the network layer. Now this data is in fact an IP packet, which contains or encapsulates the real data we want delivered to the end device. Imagine an envelope inside another envelope. We call this double encapsulation. In this model, the operating system sends the data to the transport layer.

Skip to 0 minutes and 59 seconds The transport layer then sends the data down to the network layer. The network layer then breaks up the data into blocks and encapsulates each block into an IP packet. The network layer then sends these packets down to the data link layer. The data link layer encapsulates these packets into frames. The frames are then transmitted as bits onto the media, such as an Ethernet cable. Let’s look at one example of using a computer to view a web page and send the data to a distant web server. The data starts its journey on your computer sent via the transport layer to the network layer. The network layer encapsulates the data as IP packets.

Skip to 1 minute and 41 seconds Each packet then travels to the data link layer, which encapsulates it into an Ethernet frame. This Ethernet frame travels along the Ethernet cable to the switch. The switch reads the MAC address and sends the frame out of the correct ports on the router. The router decapsulates the IP packet from the frame. And the network layer of the router examines the IP address to see where the packet is being sent. The next link to the destination is across an ADSL link. The IP packet travels to the data link layer of the router and becomes encapsulated into an ADSL frame. The ADSL frame moves across the ADSL link to the internet service provider. This process repeats over and over.

Skip to 2 minutes and 26 seconds Each step of the journey decapsulates the packet and examines the destination address. The next link is selected, and a new frame encapsulates the packet ready for transmission. The IP packet is transmitted from one device to the next one in the chain until it reaches its destination.

Explaining the Layered Model

In the previous step, you saw many simliarities between Internet Protocol (IP) addresses and IP packets on the one hand, and MAC addresses and Ethernet frames on the other hand. Do we need both, or can they coexist?

In this step, you’ll learn more about IP packets and how they are transported in frames. This is visualised as the next layer in the TCP/IP model.

Last week, we looked at how frames operate at the data link layer, particularly at how Ethernet frames transport data.

To transport IP packets across all the various links, there are two theoretical options:

  1. Change all the data link protocols so they understand IP addresses and the structure of IP packets.
  2. Use the data link protocols to transport IP packets as their data.

Option 1 would require a vast amount of redesign that would make much of the existing network infrastructure redundant — option 2 is the logical choice.

So the data transmitted in data link frames (such as Ethernet frames) is IP packets. These IP packets contain (encapsulate) the actual data that one device is sending to another.

Diagram showing encapsulation of Data as it travels from device's core OS. At the Network layer it is encapsulated in an IP packet with an IP header. At the Data link layer this IP packet is encapsulated into a Frame. This bits that make up this frame are encoded as signals onto the network media.

It’s like an envelope inside an envelope: double encapsulation! (The attached activity can help you and your students visualise this)

A slip labelled "DATA" going into an envelope labelled "PACKET", which is itself going into an envelope labelled "FRAME".

So in the same way that the data link layer encapsulates data from the network layer, the network layer encapsulates data from another Layer. This ‘higher’ layer is called the transport layer, which you’ll learn about later in the course.

NOTE: the network layer is sometimes referred to as the internet layer. We will use the term network layer here.

The network layer as a service

In the same way the data link layer provides a service to the network layer by transporting its data in frames, the network layer also provides a service to the transport layer by transporting its data.

  1. One device’s transport layer wants to send some data to the equivalent transport layer on a distant device.

  2. The transport layer uses the services of the network layer to transport the data inside IP packets.

  3. The network layer uses the services of the data link layer to transport the IP packets as frames across the local links. In practice this involves intermediary devices (e.g. routers) that check each IP packet’s destination address and choose the next link.

  4. The data link layers connect to the media and transmit the frames as bits encoded into electrical, optical, or electromagnetic (wireless) signals. If the media is Ethernet, a switch will be involved.

The journey of the data from one Transport Layer to the Transport Layer on a distant device, via a switch.

Next Step

In the next step, you’ll learn about the fields that make up an IP packet.


  • Why do we refer to IP as an ‘end-to-end’ protocol?
  • Switches can be called ‘layer 2 devices’ because they work at the data link layer. What do you think routers are called?
  • On a typical journey across the internet, how many times do you think an IP packet encapsulated in a frame and then decapsulated again? This happens each time the packet crosses a new link.

Share your answers and join the conversation below.

Share this video:

This video is from the free online course:

An Introduction to Computer Networking for Teachers

Raspberry Pi Foundation