# Networking Models

There are a lot of moving pieces in a network. In order to simplify, or more precisly to be able to focus on one area of the system, we often use models.

Amongst other, the OSI model is probably the most well known. Another one is the Internet protocol suite, commonly known as the TCP/IP, or historically the DoD (Department of Defense) model.

The first model has seven layers while the second only has four but both models overlap in some way.

A model is just that: a model. They are useful to grasp how the system work as a whole and permit to focus on some area of a system, however no model will ever perfectly represent a real-world implementation.

## OSI model

The OSI model divides the layers according to their provided functions: physical addressing, logical addressing, routing, encryption, compression, etc.

The layers are:

• Layer 7:
• Layer 6: Presentation
• Layer 5: Session
• Layer 4:
• Layer 3:
• Layer 2:
• Layer 1:

For a great overview of how packets move through a network at different layer, check this YouTube video.

## Internet Protocol Suite

The TCP/IP model divides the layers according to the scope of communications within each layer (local network, between networks, etc).

The layers are:

• Layer 4:
• Layer 3:
• Layer 2:
• Layer 1:

## Data Encapsulation

In network model, we use data encapsulation to hide data from one layer by encapsulating it within a data unit of the layer below.

A Protocol Data Unit (PDU) is an amount of data transferred over a network. The name to refer to PDUs vary between layers. Some of the name may be familiar:

• Internet/Network layer: packet
• Transport layer (TCP): segment
• Transport layer (UDP): datagram

The name may be different but a PDU almost always consists of a header and a data payload, and sometimes a trailer or footer:

+----------+--------------------------+
|          |                          |
|          |                          |
+----------+--------------------------+

Note that this PDU does not have a trailer.

What is included in the header and trailer varies from protocol to protocol but their purpose is the same: it provides protocol-specifit metadata about the PDU. an Internet Protocol (IP) packet header would include the source IP address and the destination IP address in order to correctly route the packet.

The data payload of the PDU is, as its name implies, the data we want to transport over the network.

Data encapsulation in network model is implemented by using this concept of data payload. The entire PDU from one layer (the header + data payload in the text image above) becomes the data payload of the layer below.

           +----------+--------------------------+
|          |                          |
|          |                          |
+----------+--------------------------+
+----------+-------------------------------------+
|          |                                     |
+----------+-------------------------------------+