Transport Layer
The Transport Layer consists of methods used to transport data over IP. We will primarily focus on TCP and UDP
TCP
TCP is Transmission Control Protocol
Ensures that data:
- Arrives in the right order
- Ensures that nothing is missing
- Ensures that data is not corrupted
This is our slower but more reliable way of Delivery.
Over the internet, packets of data can:
- Get lost
- Arrive out of order
- Become corrupted (e.g a bit of information might flip)
TCP handles all these cases by performing a Handshake. Before sending data, TCP creates a connection called the 3-way handshake.
- Client → server:
SYN(Can we talk?) - Server → Client:
SYN-ACK(Yes, the server is up) - Client → Server:
ACK(Okay, will send over information)
TCP then assigns each chunk of information with a sequence number such that if something is missing, it will be asked for again. TCP also has flow control and congestion control to adjust speed depending on the network condition and prevent flooding of data.
TCP is used in regular browsing (E.g HTTP is run on it)
UDP
UDP is User Datagram Protocol with the philosophy of sending information fast. It does not aim to make a connection or retry.
UDP:
- Takes data
- Wrap it in a small header (of ports and checksum)
- Sends it across the internet
No:
- Handshakes
- Delivery Confirmation
- Retransmission
- Ordering
UDP is used for communication that is faster, e.g streaming services, voice calls, gaming and other real time services. Trades reliability for speed and low latency. Also great for broadcasting. For real time services, if a packet is late, it’s useless.
Packets can however be lost, dupplicated and corrupted through UCP though so must handle reliaiblity yourself.