1 00:00:00,000 --> 00:00:00,500 2 00:00:00,500 --> 00:00:02,270 One of the unique challenges with phones 3 00:00:02,270 --> 00:00:05,180 today is that if we get a call and we have the same ring 4 00:00:05,180 --> 00:00:06,920 tone for everybody, we really don't 5 00:00:06,920 --> 00:00:10,460 know who is calling until we take another look at the phone 6 00:00:10,460 --> 00:00:11,930 and learn more details about it. 7 00:00:11,930 --> 00:00:14,660 And one solution to that is to have unique ringtones 8 00:00:14,660 --> 00:00:15,910 for certain callers. 9 00:00:15,910 --> 00:00:18,320 And in the world of networking, a computer 10 00:00:18,320 --> 00:00:20,260 can have many services available. 11 00:00:20,260 --> 00:00:24,440 For example, web server has HTTP web services available. 12 00:00:24,440 --> 00:00:27,410 Or a specific type of file server has files available. 13 00:00:27,410 --> 00:00:30,110 But when a customer comes knocking at the door looking 14 00:00:30,110 --> 00:00:33,620 for various services, how does that server know exactly which 15 00:00:33,620 --> 00:00:35,420 services the customer is after? 16 00:00:35,420 --> 00:00:39,000 And one of the solutions to that is to use port numbers. 17 00:00:39,000 --> 00:00:41,330 So as an example of this, let's use two devices. 18 00:00:41,330 --> 00:00:44,270 We have PC 1 over here on the left and a server on the right, 19 00:00:44,270 --> 00:00:46,339 and they are connected over a network. 20 00:00:46,339 --> 00:00:47,880 And for our discussion, let's imagine 21 00:00:47,880 --> 00:00:51,530 that this server has several services, including a Telnet 22 00:00:51,530 --> 00:00:52,805 service that's running. 23 00:00:52,805 --> 00:00:54,590 And what Telnet allows a person to do 24 00:00:54,590 --> 00:00:57,080 is to connect remotely to another system 25 00:00:57,080 --> 00:00:58,970 and get a command line interface. 26 00:00:58,970 --> 00:01:00,497 That's the Telnet protocol. 27 00:01:00,497 --> 00:01:02,330 And if this server has some software running 28 00:01:02,330 --> 00:01:04,010 that provides that Telnet service, 29 00:01:04,010 --> 00:01:08,060 it is listening for an incoming request on a specific port. 30 00:01:08,060 --> 00:01:11,270 And for Telnet, that well-known and agreed-to port for a Telnet 31 00:01:11,270 --> 00:01:14,390 service is port number 23. 32 00:01:14,390 --> 00:01:18,050 So 23 is the well-known port for a Telnet server 33 00:01:18,050 --> 00:01:19,497 that's running the Telnet service. 34 00:01:19,497 --> 00:01:21,080 Now, at the same time, the same server 35 00:01:21,080 --> 00:01:23,180 could be running software supporting web services, 36 00:01:23,180 --> 00:01:24,212 or HTTP. 37 00:01:24,212 --> 00:01:25,670 So in that sense, we could also say 38 00:01:25,670 --> 00:01:28,640 the server is providing an HTTP service or web service. 39 00:01:28,640 --> 00:01:33,620 And the well-known port for HTTP is TCP port number 80. 40 00:01:33,620 --> 00:01:37,010 So the question I have is, if this client over here on PC 1 41 00:01:37,010 --> 00:01:38,720 makes a request over to the server, 42 00:01:38,720 --> 00:01:40,790 how does the server know if the PC is 43 00:01:40,790 --> 00:01:43,460 going for web services on TCP port 80 44 00:01:43,460 --> 00:01:47,210 or if it's going for Telnet services on TCP port 23? 45 00:01:47,210 --> 00:01:49,640 And the answer is that the client, 46 00:01:49,640 --> 00:01:51,770 in its request for services, is going 47 00:01:51,770 --> 00:01:54,470 to include the port number for the service 48 00:01:54,470 --> 00:01:56,180 that it wants to access. 49 00:01:56,180 --> 00:01:57,590 So from the client's perspective, 50 00:01:57,590 --> 00:01:59,840 let's imagine that we have, at PC 1, a user, 51 00:01:59,840 --> 00:02:01,790 like Bob or Sally or Lois, and they 52 00:02:01,790 --> 00:02:04,070 have some software running on their computer that's 53 00:02:04,070 --> 00:02:06,931 acting as a Telnet client. 54 00:02:06,931 --> 00:02:08,389 So they're running that application 55 00:02:08,389 --> 00:02:11,097 and thus taking advantage of the protocol stack 56 00:02:11,097 --> 00:02:13,430 that's going to allow them to reach out over the network 57 00:02:13,430 --> 00:02:15,510 and access a Telnet service. 58 00:02:15,510 --> 00:02:18,136 So as this Telnet client on PC 1 logically 59 00:02:18,136 --> 00:02:20,010 is sending this information down the protocol 60 00:02:20,010 --> 00:02:23,150 stack on their local computer, when it gets to layer 4, 61 00:02:23,150 --> 00:02:27,080 it's going to use a destination port of 23. 62 00:02:27,080 --> 00:02:29,960 And by doing so, once that information is delivered over 63 00:02:29,960 --> 00:02:33,017 to the server and it works its way up the protocol stack, when 64 00:02:33,017 --> 00:02:34,850 it gets to the transport layer, when it sees 65 00:02:34,850 --> 00:02:37,820 that well-known port of 23, the Telnet service 66 00:02:37,820 --> 00:02:41,840 is considered to be listening or paying attention to port 23, 67 00:02:41,840 --> 00:02:44,600 and as a result, can go ahead and process that request, 68 00:02:44,600 --> 00:02:46,490 that Telnet request, via the Telnet 69 00:02:46,490 --> 00:02:48,320 service running on the server. 70 00:02:48,320 --> 00:02:50,720 And Telnet happens to use-- at the transport layer, 71 00:02:50,720 --> 00:02:52,880 it happens to use TCP. 72 00:02:52,880 --> 00:02:55,220 So the destination port number in the request 73 00:02:55,220 --> 00:02:58,640 would be as part of the TCP information, layer 4, 74 00:02:58,640 --> 00:03:00,380 destined to port 23. 75 00:03:00,380 --> 00:03:02,900 And on the server side, the Telnet service 76 00:03:02,900 --> 00:03:07,050 is listening for TCP port 23 for incoming requests. 77 00:03:07,050 --> 00:03:10,610 So that would be for the request portion of our show. 78 00:03:10,610 --> 00:03:13,940 Now, what happens if we have a really good server? 79 00:03:13,940 --> 00:03:16,212 What should it do if it gets a request? 80 00:03:16,212 --> 00:03:17,420 And here's what I'm thinking. 81 00:03:17,420 --> 00:03:20,420 I'm thinking maybe the server should respond back 82 00:03:20,420 --> 00:03:21,489 to the client. 83 00:03:21,489 --> 00:03:23,030 However, if this server responds back 84 00:03:23,030 --> 00:03:24,860 to the client, how in the world do 85 00:03:24,860 --> 00:03:26,450 we make sure that the Telnet server 86 00:03:26,450 --> 00:03:30,210 responds to the correct port back on the client? 87 00:03:30,210 --> 00:03:32,720 And the answer begins back with the client. 88 00:03:32,720 --> 00:03:34,722 When the client makes that initial request, 89 00:03:34,722 --> 00:03:36,680 not only is it going to include the destination 90 00:03:36,680 --> 00:03:39,770 port, the well-known port for a Telnet service on port 23, 91 00:03:39,770 --> 00:03:42,470 but it's also going to include, as part of the Layer 4 92 00:03:42,470 --> 00:03:46,040 information, a source port. 93 00:03:46,040 --> 00:03:47,630 And that begs the question-- well, 94 00:03:47,630 --> 00:03:50,910 what exactly is the source port going to be used by the client? 95 00:03:50,910 --> 00:03:52,340 And the answer depends on what are 96 00:03:52,340 --> 00:03:55,580 the available unused ports at that moment on this client, 97 00:03:55,580 --> 00:03:56,720 on this PC. 98 00:03:56,720 --> 00:03:59,060 And then it's up to the PC and the client 99 00:03:59,060 --> 00:04:02,370 to go ahead and choose a random unused port. 100 00:04:02,370 --> 00:04:04,100 So for our example here, let's imagine 101 00:04:04,100 --> 00:04:06,590 that the PC made a free will choice 102 00:04:06,590 --> 00:04:12,450 and chose the port number of 1550 as its source port. 103 00:04:12,450 --> 00:04:15,450 So in the initial request, at the transport layer, 104 00:04:15,450 --> 00:04:17,890 this Telnet client is using a destination port 105 00:04:17,890 --> 00:04:22,790 at layer 4 of 23 and a source port that it chose of 1550. 106 00:04:22,790 --> 00:04:25,010 So when that request comes in, the Telnet service 107 00:04:25,010 --> 00:04:28,190 processing that request sees that the destination port 108 00:04:28,190 --> 00:04:30,890 is 23 on its local system and that the source port 109 00:04:30,890 --> 00:04:34,550 that it's coming from is 1550. 110 00:04:34,550 --> 00:04:37,330 And as a result, when this server responds back 111 00:04:37,330 --> 00:04:40,455 to the client, it's going to include any TCP layer 4 112 00:04:40,455 --> 00:04:40,955 information. 113 00:04:40,955 --> 00:04:42,621 It's going to include the fact that it's 114 00:04:42,621 --> 00:04:46,490 going to be destined to the client's port of 1550. 115 00:04:46,490 --> 00:04:49,400 So on the server side, it would use-- for the response, 116 00:04:49,400 --> 00:04:54,050 it would use 23 as the source port and port 1550 117 00:04:54,050 --> 00:04:55,275 as the destination port. 118 00:04:55,275 --> 00:04:57,920 And that would be for the response from the server 119 00:04:57,920 --> 00:05:00,110 back to the client. 120 00:05:00,110 --> 00:05:02,379 So let's do one more example just to confirm. 121 00:05:02,379 --> 00:05:03,920 Imagine that this server on the right 122 00:05:03,920 --> 00:05:08,150 is running an HTTP service and that well-known port for HTTP 123 00:05:08,150 --> 00:05:11,060 is TCP port number 80. 124 00:05:11,060 --> 00:05:14,960 And let's imagine that the PC here is making an HTTP request. 125 00:05:14,960 --> 00:05:16,880 And let's imagine that the source port 126 00:05:16,880 --> 00:05:18,950 that PC 1 is using for that conversation 127 00:05:18,950 --> 00:05:21,050 to this server on port 80 is going 128 00:05:21,050 --> 00:05:24,890 to be source port number 6783. 129 00:05:24,890 --> 00:05:27,380 And so given this information and the discussion 130 00:05:27,380 --> 00:05:29,850 that we just had regarding how ports are used, 131 00:05:29,850 --> 00:05:32,360 I'd like you to pause the video here for a moment 132 00:05:32,360 --> 00:05:36,190 and think to yourself, OK, for the packet, the initial packet 133 00:05:36,190 --> 00:05:38,780 that's going from PC 1 over to the server, 134 00:05:38,780 --> 00:05:40,910 what would the source and destination ports 135 00:05:40,910 --> 00:05:45,200 be in that initial request from the client at PC 1? 136 00:05:45,200 --> 00:05:48,260 And then if the server responds to that request, what 137 00:05:48,260 --> 00:05:50,900 would be the server's source and destination 138 00:05:50,900 --> 00:05:54,140 ports in the reply packet going from the server over to PC 1? 139 00:05:54,140 --> 00:05:59,250 140 00:05:59,250 --> 00:06:00,180 And here we go. 141 00:06:00,180 --> 00:06:02,730 Well, the PC, the source port for the initial request, 142 00:06:02,730 --> 00:06:04,842 is going to be port number 6783. 143 00:06:04,842 --> 00:06:05,550 It's right there. 144 00:06:05,550 --> 00:06:06,979 So we'll just put that in. 145 00:06:06,979 --> 00:06:08,520 And for the destination port, if it's 146 00:06:08,520 --> 00:06:10,590 going to the web services on this server, 147 00:06:10,590 --> 00:06:13,830 the destination port is going be that well-known port for HTTP, 148 00:06:13,830 --> 00:06:16,590 which is port number 80. 149 00:06:16,590 --> 00:06:18,960 And for the reply coming back from the server 150 00:06:18,960 --> 00:06:21,780 back to the client, it would be these two ports for the reply 151 00:06:21,780 --> 00:06:23,437 traffic, but reversed. 152 00:06:23,437 --> 00:06:25,770 The source port would be coming from the well-known port 153 00:06:25,770 --> 00:06:29,250 of port 80 on the server back to that client's initial port 154 00:06:29,250 --> 00:06:33,784 that it chose of 6783. 155 00:06:33,784 --> 00:06:35,200 In this Nugget, we've taken a look 156 00:06:35,200 --> 00:06:38,590 at how ports can be used at the transport layer in the TCP/IP 157 00:06:38,590 --> 00:06:39,730 Protocol Suite. 158 00:06:39,730 --> 00:06:41,800 I hope this has been informative for you, 159 00:06:41,800 --> 00:06:45,390 and I'd like to thank you for viewing. 160 00:06:45,390 --> 00:06:45,978