- [Instructor] TCP and UDP utilize the two connection types,
connection oriented and connectionless.
TCP is considered connection oriented.
This means, it uses a system
to provide reliable delivery of traffic.
TCP utilizes a system known as three way handshake
to establish connections.
Before a connection is considered established,
both hosts need to send and receive a SYN packet
and an ACK packet.
Technically, this could be four separate messages
but one of these transmissions can include
both a SYN and an ACK, thus we have a three way handshake.
The client host will initiate the interaction to the server
by sending a SYN Packet.
The client then waits for a response.
The server responds to the client by sending SYN ACK packet.
The client then completes the handshake by returning an ACK.
The ACK packet is part of
the positive acknowledgment system of TCP.
Once enough information is sent,
TCP will wait for an ACK or acknowledgment.
The amount of information that can be sent
before a response is necessary is known as the window size.
If no ACK is returned, then the previous information
must have been lost in transit and is re-sent.
The resending of packets is known as retransmission.
Packets also contain a sequence number.
This allows the receiving host to determine
if it missed any packets.
If it determines that it has, it will request the sender
to retransmit the missing information.
TCP is especially useful
for unreliable or often congested networks.
This was very important in the early days
with half-duplex networks producing collisions,
resulting in lost packets.
There are some cases where reliable delivery isn't necessary
and for this, UDP is used.
With UDP, when information is sent, it is done so
with no acknowledgements, no ordering
and no duplication protection.
This means UDP can transmit information far faster than TCP.
It no longer waits for ACKs,
which on far-flung networks reduces delays.
The headers are also streamlined,
further improving throughput.
The speed does mean that an occasional
dropped packet will happen.
But services that use UDP
generally prefer speed over 100% reliability.
VoIP and video streaming are far more concerned
with getting the packets there in a timely manner
as opposed to missing an occasional packet.
Remember, it's TCP for reliability and UDP for speed.