Skip to article frontmatterSkip to article content

We know how to navigate, how do we communicate now

➡️ We need the 4th layer of the OSI model


Layer 4

specification of how to send data
from server A to client B and vice versa.

Different established protocols :

  • TCP

  • UDP

  • ...

⚠️ Attention ⚠️

The transport layer only defines the way two applications communicate
but does not specify the content of these communications


A server == an application?

Knowing the server’s IP doesn’t allow you to communicate with the application on that server yet

❓ By the way, can there be only one network application on a server or can we put several ❓

We can have several applications on the same server, and fortunately 🥳

The choice of the application we will talk to involves the notion of port

port = service entry door 🚪

(but we don’t run that many applications on a server)


Network packet anatomy

and here is what a packet looks like



Standard ports

On a machine we have 216 = 65,536 ports

Some standardized ports:

serviceport
SSH22
SMTP25
DNS53
HTTP80
HTTPS443
......

TCP/IP

Principle

Transmission Control Protocol

is the historical protocol (Bob Kahn and Vinton Cerf, September 1973), which owes its longevity to its robustness and reliability.

Today when you browse the web
most exchanges that take place between your browser and websites are based on TCP


The principle of TCP is very simple and breaks down into three steps:


TCP/IP: open

The connection of a client to a TCP server breaks down into three steps

three way handshake

in the following way:

  • 1️⃣ Client: Hello server can you hear me ?

  • 2️⃣ Server: Yes I hear you and you?

  • 3️⃣ Client: Yes it’s good I hear you


TCP/IP: close

Closure in 4 steps

  • 1️⃣ Client: I’m done

  • 2️⃣ Server: Ok noted

  • 3️⃣ Server: me too I have nothing more to tell you

  • 4️⃣ Client: Ok see you next time


Let’s see how it really works

let’s go see the python/tcp folder of the course


TCP a rich thing 🤑

You can therefore see that with this approach

✅ the connection is extremely reliable and there is little chance of having misses

However this reliability is not free 💰️

❌ it is accompanied by a relatively high cost in terms of exchanges

That’s why there’s an alternative to TCP 😯


UDP

The UDP protocol (User Datagram Protocol) is complementary to the TCP protocol. Created by David Reed in 1980.

Use cases:

Fast data transmission and reception of the whole not imperative

TCP = very reliable but slow

vs

UDP = fast but unreliable

UDP applications are numerous, for example: