Jason: In this lesson,
we're going to discuss IP protocol types,
including TCP, UDP,
and the concepts of connectionless
versus connection-oriented methods.
Now, what is TCP?
TCP is a Transmission Control Protocol.
It is a connection-oriented protocol,
which means it's a reliable way
to transport segments across our network.
Now, if a segment is dropped,
the protocol will actually ask for acknowledgement
each and every time.
And if it doesn't get that acknowledgement,
it's going to resend that piece of information.
That's why we call this a connection-full protocol
because it has this two-way type of information
where I'm sending you information
and I'm verifying that you actually got it
by listening that you got it and you give me a response.
Now let's look at this little diagram
here on the screen for a second.
You're going to see that I have a client on the left
and a server on the right.
Now, the client is going to send what's called a syn packet,
or a synchronization packet,
over to the server.
Now, when the server gets that,
it's going to send back
a synchronization acknowledgement to the client,
known as a syn ack.
Now, when the client gets that acknowledgement,
it's going to send back its own acknowledgement to the server.
This is known as the ack.
Now, when we do this syn, syn ack, ack,
this is what we refer to as a three-way handshake.
Essentially, it's the client going,
"Hey server, are you ready to get some information?"
And then the server says,
"Sure. Why not?
"Send me some information."
And the client says, "Okay, here it comes."
And then the transmission is going to begin
because we've established that three-way handshake
and we know that both sides are ready to communicate.
"Now, are you ready?"
"Yes, I am."
"Here it comes. "
Now every time this data, which we call a segment,
is sent across the network,
there is going to be an acknowledgement that was received
and that tells us there was successful
two-way communication occurring.
Now, if this server's expecting to get
100 pieces of information,
but it only got 98 of those,
it's going to say to the client,
"Hey, you told me you were going to send me 100 things,
"but you only sent me 98.
"Send me over those two things that I'm missing."
And then, a retransmission occurs.
This way,
the communication can go for us
and we can always make sure
we're getting what we're supposed to
because we have this resending of the packets
across the network.
Now, this is used for all network data
that needs to be assured to get to its final destination.
I like to think about this like certified mail.
If I want to send a message to the IRS, for example,
I want to make sure that they get it
and it doesn't get lost in the mail.
So I might pay a little extra money
to get a certified receipt
that when it gets there, they have to sign it,
and that gets mailed back to me.
This way,
when I get that receipt back,
I know that the IRS got my mail package.
That's the way TCP works.
Now, on the other hand,
we have another protocol known as UDP.
UDP is what we call a connectionless protocol,
meaning it doesn't have to wait for connections.
UDP stands for the User Datagram Protocol.
And the reason why we call it a datagram
is because if you're using UDP,
you're using this type of data.
It's called a datagram.
Now, when we talk about UDP,
UDP is unreliable
and it transmits segments called datagrams.
And if they're dropped,
the sender will never even know that it happened.
Now, why would I want to send stuff
where the sender isn't aware of it
and I don't get any kind of receipt?
Well, UDP is really good for audio and visual streaming
because you send a lot of data
and there's a lot less overhead when you use UDP,
because we don't have that constant three-way handshake
to establish it
and we don't have all the checks and balances
that are associated by using TCP.
So by using UDP,
you can really increase the performance of your network
because you're going to have zero retransmissions.
You're just going to end up dropping information.
Now, isn't that a bad thing?
Why would we want to drop information?
Well, for certain applications,
it really doesn't matter.
For example, you're streaming this video right now.
And if I dropped out for 1/100 of a second,
would you even notice?
Well, you probably wouldn't
and that's why UDP is so good
because we can drop 1/100 of the time here
and you're really never even going to notice it,
and there won't be a retransmission.
But with TCP,
it's going to lead to a lot more buffering
because you have to wait,
and then get it resent to you,
and then put it in the right place,
and then play it back.
And so, because of that acknowledgement and that overhead,
for every single second of this video,
it's going to end up making it a lot larger
and use a lot more bandwidth.
And that's one of the big reasons
why we use UDP for video streaming and audio streaming.
Now, let's do a quick little summary here of TCP versus UDP.
Because this is a really, really important concept.
In fact, if you have your notes out right now,
I would write down this chart
that I'm going to tell you right now
as we talk about TCP versus UDP.
Because it really is that important.
Now, first, TCP is reliable,
it has a three-way handshake,
where UDP is not very reliable.
It's an unreliable protocol
because there is no three-way handshake.
TCP is what we call connection-oriented
or a connection-full protocol
because we have that three-way handshake
in the acknowledgements,
but UDP is connectionless.
It's a fire and forget method.
I just start sending out information
and hopefully you're going to get it.
TCP uses segment retransmission and flow control
that's being handled through windowing.
UDP, on the other hand,
there is no retransmission and no windowing.
With TCP,
we have segmentation of our sequencing
of all of our different segments.
With UDP, there is no sequencing.
Now, what this means is as I send everything out,
I'm going to send it out in the proper order,
from one to 100.
I'll do this for both TCP and UDP.
Now, if you miss some of those pieces,
or they arrive in a different order
because they take different path over the network,
with TCP,
they're sequencing,
so it knows that you have one to 1000
and it puts them back in the right sequence.
With UDP,
whatever they come in as,
that's how it's going to broadcast it.
And so, it can be coming in
one, 50,
two, 500,
three, four, five, six, 20,
in any random order like that.
And that's how you're going to hear it.
So with video, you may hear a little bit of jumpiness,
or a little bit of high-pitched squeaks,
or something like that,
because one of those frames may have come out of order.
Now, when we go back to TCP,
it is going to acknowledge each of those segments.
And so we have acknowledgement.
If I don't get it,
I know that I didn't get it
and I can get it retransmitted to me,
and then get it again.
With UDP, there is no acknowledgement.
So again, UDP has a lot less overhead
because there's no connection,
no windowing, no retransmission,
no sequencing, and no acknowledgement.
Now, if you have to get something there
and you want to make sure the person got it,
you really have to use TCP as your protocol of choice.
And that's why we really are going to use TCP
for things like banking and websites and eCommerce,
and things like that.
But if we have something that has a lot of data
like audio or video streaming,
UDP really does well with that
because we don't need to get
every single piece of that file.
We can skip a little bit here and there,
and that's okay.
-: [Another Instructor] Now, when it comes to TCP and UDP,
we talked about the fact that these are connection-full
or connection-oriented protocols,
and connectionless protocols.
So let me give you a couple of examples
of protocols that use either TCP or UDP
so you can understand why we use each one.
First,
let's look at TCP
and our connection-oriented or connection-full protocols.
This includes things like SSH, and HTTP, or HTTPS.
Now, why would we need connection-oriented in these cases?
Well, in the case of using something like SSH,
I'm doing two-way communication and control
of remote server or remote workstation,
and be able to do that over port 22.
I want to make sure I'm doing that
in a connection-oriented or connection-full manner.
That way, when I send out a command and say,
reboot the server,
I know that command actually got there
and the server reboot will happen.
Similarly, when we're dealing with HTTPS,
we want to make sure we're having a connection-full
or connection-oriented protocol using TCP.
The reason for this
is, again, we want to make sure
that what we're sending is actually received there.
And that may include things like authentication
as we're trying to log into a website
using our username and password,
or maybe it's the information
we're getting back from that website,
such as our account balances and our banking information.
Now, on the other hand,
if we're using UDP as our protocol,
we are dealing in a connectionless manner.
Now, I already mentioned the fact
that we use this all the time
for things like audio and video streaming.
But in addition to that,
we also use it for things like DHCP,
and the Trivial File Transfer Protocol, known as TFTP.
Now, if you remember,
DHCP is used as the Dynamic Host Control Protocol
and it operates over port 67 and 68.
Now, when you join a network,
your device, if it's set up
for a dynamic assignment of its IP address,
will then send out a broadcast message on that network
looking for a DHCP server.
And this is why we use it as a connectionless protocol.
Because if that information is sent out and nobody responds,
your client will simply send that out again
in hopes that somebody else will be there.
That's how DHCP works.
It's going to allow a broadcast message to go out,
and then wait for a response to come back.
If it doesn't get that response
within a certain amount of time,
it will simply rebroadcast out its message,
and again, seeking out a new DHCP server.
Now, similarly, when we have TFTP
or the Trivial File Transfer Protocol,
which operates over port 69,
it is going to work in a connectionless manner
using UDP as its transport.
The reason for this
is because TFTP is the Trivial File Transfer Protocol,
and therefore, we don't need to have the assurances
that every single packet was sent and received
with those acknowledgements,
and that creates a lot more overhead if we use TCP.
So by using UDP,
we can have a quicker file transfer
when we're using something like TFTP,
instead of using a more connection-full protocol, like FTP.