One of the unique challenges with phones
today is that if we get a call and we have the same ring
tone for everybody, we really don't
know who is calling until we take another look at the phone
and learn more details about it.
And one solution to that is to have unique ringtones
for certain callers.
And in the world of networking, a computer
can have many services available.
For example, web server has HTTP web services available.
Or a specific type of file server has files available.
But when a customer comes knocking at the door looking
for various services, how does that server know exactly which
services the customer is after?
And one of the solutions to that is to use port numbers.
So as an example of this, let's use two devices.
We have PC 1 over here on the left and a server on the right,
and they are connected over a network.
And for our discussion, let's imagine
that this server has several services, including a Telnet
service that's running.
And what Telnet allows a person to do
is to connect remotely to another system
and get a command line interface.
That's the Telnet protocol.
And if this server has some software running
that provides that Telnet service,
it is listening for an incoming request on a specific port.
And for Telnet, that well-known and agreed-to port for a Telnet
service is port number 23.
So 23 is the well-known port for a Telnet server
that's running the Telnet service.
Now, at the same time, the same server
could be running software supporting web services,
or HTTP.
So in that sense, we could also say
the server is providing an HTTP service or web service.
And the well-known port for HTTP is TCP port number 80.
So the question I have is, if this client over here on PC 1
makes a request over to the server,
how does the server know if the PC is
going for web services on TCP port 80
or if it's going for Telnet services on TCP port 23?
And the answer is that the client,
in its request for services, is going
to include the port number for the service
that it wants to access.
So from the client's perspective,
let's imagine that we have, at PC 1, a user,
like Bob or Sally or Lois, and they
have some software running on their computer that's
acting as a Telnet client.
So they're running that application
and thus taking advantage of the protocol stack
that's going to allow them to reach out over the network
and access a Telnet service.
So as this Telnet client on PC 1 logically
is sending this information down the protocol
stack on their local computer, when it gets to layer 4,
it's going to use a destination port of 23.
And by doing so, once that information is delivered over
to the server and it works its way up the protocol stack, when
it gets to the transport layer, when it sees
that well-known port of 23, the Telnet service
is considered to be listening or paying attention to port 23,
and as a result, can go ahead and process that request,
that Telnet request, via the Telnet
service running on the server.
And Telnet happens to use-- at the transport layer,
it happens to use TCP.
So the destination port number in the request
would be as part of the TCP information, layer 4,
destined to port 23.
And on the server side, the Telnet service
is listening for TCP port 23 for incoming requests.
So that would be for the request portion of our show.
Now, what happens if we have a really good server?
What should it do if it gets a request?
And here's what I'm thinking.
I'm thinking maybe the server should respond back
to the client.
However, if this server responds back
to the client, how in the world do
we make sure that the Telnet server
responds to the correct port back on the client?
And the answer begins back with the client.
When the client makes that initial request,
not only is it going to include the destination
port, the well-known port for a Telnet service on port 23,
but it's also going to include, as part of the Layer 4
information, a source port.
And that begs the question-- well,
what exactly is the source port going to be used by the client?
And the answer depends on what are
the available unused ports at that moment on this client,
on this PC.
And then it's up to the PC and the client
to go ahead and choose a random unused port.
So for our example here, let's imagine
that the PC made a free will choice
and chose the port number of 1550 as its source port.
So in the initial request, at the transport layer,
this Telnet client is using a destination port
at layer 4 of 23 and a source port that it chose of 1550.
So when that request comes in, the Telnet service
processing that request sees that the destination port
is 23 on its local system and that the source port
that it's coming from is 1550.
And as a result, when this server responds back
to the client, it's going to include any TCP layer 4
information.
It's going to include the fact that it's
going to be destined to the client's port of 1550.
So on the server side, it would use-- for the response,
it would use 23 as the source port and port 1550
as the destination port.
And that would be for the response from the server
back to the client.
So let's do one more example just to confirm.
Imagine that this server on the right
is running an HTTP service and that well-known port for HTTP
is TCP port number 80.
And let's imagine that the PC here is making an HTTP request.
And let's imagine that the source port
that PC 1 is using for that conversation
to this server on port 80 is going
to be source port number 6783.
And so given this information and the discussion
that we just had regarding how ports are used,
I'd like you to pause the video here for a moment
and think to yourself, OK, for the packet, the initial packet
that's going from PC 1 over to the server,
what would the source and destination ports
be in that initial request from the client at PC 1?
And then if the server responds to that request, what
would be the server's source and destination
ports in the reply packet going from the server over to PC 1?
And here we go.
Well, the PC, the source port for the initial request,
is going to be port number 6783.
It's right there.
So we'll just put that in.
And for the destination port, if it's
going to the web services on this server,
the destination port is going be that well-known port for HTTP,
which is port number 80.
And for the reply coming back from the server
back to the client, it would be these two ports for the reply
traffic, but reversed.
The source port would be coming from the well-known port
of port 80 on the server back to that client's initial port
that it chose of 6783.
In this Nugget, we've taken a look
at how ports can be used at the transport layer in the TCP/IP
Protocol Suite.
I hope this has been informative for you,
and I'd like to thank you for viewing.