1 00:00:00,000 --> 00:00:00,700 2 00:00:00,700 --> 00:00:03,910 It is a nice comfort to be able to rely on something 3 00:00:03,910 --> 00:00:04,840 and have it happen. 4 00:00:04,840 --> 00:00:09,880 And so many applications, such as HTTP, and SSH and telnet-- 5 00:00:09,880 --> 00:00:13,270 those application layer services use, at the transport layer, 6 00:00:13,270 --> 00:00:14,200 TCP. 7 00:00:14,200 --> 00:00:15,850 And one of the benefits of using TCP 8 00:00:15,850 --> 00:00:18,142 is that it's connection-oriented and reliable. 9 00:00:18,142 --> 00:00:20,100 Meaning, there are going to be sequence numbers 10 00:00:20,100 --> 00:00:22,150 and acknowledgment numbers to validate 11 00:00:22,150 --> 00:00:24,430 that the communications are working between the two 12 00:00:24,430 --> 00:00:25,107 devices. 13 00:00:25,107 --> 00:00:27,190 And one of the terms that I've heard thrown around 14 00:00:27,190 --> 00:00:30,400 is a thing called the Protocol Data Unit, which I just 15 00:00:30,400 --> 00:00:33,250 don't ever imagine using that phrase in a conversation 16 00:00:33,250 --> 00:00:34,120 with a friend. 17 00:00:34,120 --> 00:00:36,184 Instead of calling it a protocol data unit, 18 00:00:36,184 --> 00:00:38,350 we'd simply call it a segment, for example, if we're 19 00:00:38,350 --> 00:00:40,390 talking about data at layer 4. 20 00:00:40,390 --> 00:00:43,720 Or we would call a protocol data unit at layer 3, the network 21 00:00:43,720 --> 00:00:46,420 layer, we call that a packet, or layer 2, we 22 00:00:46,420 --> 00:00:48,940 refer to that protocol data unit as a frame. 23 00:00:48,940 --> 00:00:50,560 And that layer 1, the physical layer, 24 00:00:50,560 --> 00:00:52,630 we're just dealing with individual bits. 25 00:00:52,630 --> 00:00:55,570 So those would be the quote unquote "protocol data units" 26 00:00:55,570 --> 00:00:57,130 at those respective layers. 27 00:00:57,130 --> 00:00:59,560 And as traffic is moved across the network, 28 00:00:59,560 --> 00:01:03,010 various network devices focus on and pay close attention 29 00:01:03,010 --> 00:01:04,180 to various layers. 30 00:01:04,180 --> 00:01:07,840 And so for the purpose of moving a packet, for example, 31 00:01:07,840 --> 00:01:10,090 between one network and another, that 32 00:01:10,090 --> 00:01:11,620 would be a router's function. 33 00:01:11,620 --> 00:01:13,990 And it's focusing on the information at the network 34 00:01:13,990 --> 00:01:15,520 layer inside of each packet. 35 00:01:15,520 --> 00:01:18,250 We also have some devices on our networks called switches. 36 00:01:18,250 --> 00:01:20,740 And one of the advantages of a layer 2 switch 37 00:01:20,740 --> 00:01:24,220 is it has the ability to look at the information at layer 2 38 00:01:24,220 --> 00:01:26,200 in the frames and make forwarding 39 00:01:26,200 --> 00:01:29,110 decisions on a local network based on that information 40 00:01:29,110 --> 00:01:29,890 and frame. 41 00:01:29,890 --> 00:01:32,200 And then we have devices that the physical layer like 42 00:01:32,200 --> 00:01:35,260 a hub, or a physical network adapter card, 43 00:01:35,260 --> 00:01:37,240 or cables that are all considered 44 00:01:37,240 --> 00:01:39,460 to be layer 1 devices because they 45 00:01:39,460 --> 00:01:42,110 don't focus or process on anything higher in the protocol 46 00:01:42,110 --> 00:01:42,610 stack. 47 00:01:42,610 --> 00:01:44,050 I wanted to focus, in this Nugget, 48 00:01:44,050 --> 00:01:46,060 also on the TCP three-way handshake, which 49 00:01:46,060 --> 00:01:49,570 is the magic which allows TCP to do 50 00:01:49,570 --> 00:01:53,380 connection-oriented and reliable communications between itself 51 00:01:53,380 --> 00:01:54,350 and another party. 52 00:01:54,350 --> 00:01:56,290 So when it comes to TCP, setting up 53 00:01:56,290 --> 00:01:59,890 a reliable connection-oriented session between two devices, 54 00:01:59,890 --> 00:02:02,110 it involves three transmissions. 55 00:02:02,110 --> 00:02:05,171 And they refer to it as TCP's three-way handshake. 56 00:02:05,171 --> 00:02:06,670 And to set the stage for this, let's 57 00:02:06,670 --> 00:02:09,660 imagine that Bob is going to be acting as a client, 58 00:02:09,660 --> 00:02:13,180 and that Lois's computer is running an HTTP server 59 00:02:13,180 --> 00:02:15,010 service on her computer. 60 00:02:15,010 --> 00:02:17,140 So we can just imagine that Lois's computer 61 00:02:17,140 --> 00:02:18,550 is acting as a web server. 62 00:02:18,550 --> 00:02:21,740 And the TCP three-way handshake goes like this. 63 00:02:21,740 --> 00:02:24,100 The individual or entity that's initiating it 64 00:02:24,100 --> 00:02:25,700 is going to send over a SYN request. 65 00:02:25,700 --> 00:02:27,350 Now, that's not a SYN request like, 66 00:02:27,350 --> 00:02:28,990 hey, let's go rob somebody. 67 00:02:28,990 --> 00:02:30,940 This is a synchronization request. 68 00:02:30,940 --> 00:02:32,920 And I put a B here to represent that this 69 00:02:32,920 --> 00:02:36,610 is Bob's synchronization request that he is sending over 70 00:02:36,610 --> 00:02:38,230 to Lois's computer. 71 00:02:38,230 --> 00:02:40,185 And in the TCP header, there's going 72 00:02:40,185 --> 00:02:42,310 to be a little flag that marked a little bit that's 73 00:02:42,310 --> 00:02:44,470 on that says, hey, this is a synchronization. 74 00:02:44,470 --> 00:02:47,170 And there's also going to be a little field for a sequence 75 00:02:47,170 --> 00:02:47,740 number. 76 00:02:47,740 --> 00:02:49,540 And let's just imagine that Bob pulled 77 00:02:49,540 --> 00:02:56,140 from the air, the number 951,057,939. 78 00:02:56,140 --> 00:02:59,830 And that's the sequence number Bob's computer chose to use. 79 00:02:59,830 --> 00:03:02,140 And it sends it over to Lois. 80 00:03:02,140 --> 00:03:04,060 Also, as part of that TCP segment, 81 00:03:04,060 --> 00:03:05,950 if Bob was requesting web services, 82 00:03:05,950 --> 00:03:07,780 it would be going to the well-known port 83 00:03:07,780 --> 00:03:09,790 of TCP port number 80. 84 00:03:09,790 --> 00:03:11,920 And if Lois is listening on port 80, 85 00:03:11,920 --> 00:03:13,870 because she's running the web server software, 86 00:03:13,870 --> 00:03:16,150 she can go ahead and respond back to Bob. 87 00:03:16,150 --> 00:03:18,370 So if Bob sent a SYN request, Lois 88 00:03:18,370 --> 00:03:20,770 is going to send an acknowledgment of Bob's SYN 89 00:03:20,770 --> 00:03:21,460 request. 90 00:03:21,460 --> 00:03:24,250 She's going to send back an acknowledgment number that 91 00:03:24,250 --> 00:03:27,400 is going to be the sequence number of Bob plus one. 92 00:03:27,400 --> 00:03:34,170 So the acknowledgment here should be 951, 057,940. 93 00:03:34,170 --> 00:03:36,780 So Lois is simply taking the sequence number she received 94 00:03:36,780 --> 00:03:38,539 an incrementing by one. 95 00:03:38,539 --> 00:03:40,330 And when Bob receives that, he goes, great. 96 00:03:40,330 --> 00:03:43,330 Not only do I know that she's talking to me or the server 97 00:03:43,330 --> 00:03:45,850 talking to me, but for my next sequence number, 98 00:03:45,850 --> 00:03:47,855 I'm going to use that 940. 99 00:03:47,855 --> 00:03:50,230 Because behind the scenes, that's what that really means. 100 00:03:50,230 --> 00:03:51,730 It's the next sequence number that's 101 00:03:51,730 --> 00:03:53,560 expected to come from Bob. 102 00:03:53,560 --> 00:03:54,880 So Bob's a happy client. 103 00:03:54,880 --> 00:03:56,800 He's thinking, great, she wants to talk to me. 104 00:03:56,800 --> 00:03:59,630 However, Lois also, the server in this case, 105 00:03:59,630 --> 00:04:02,370 needs to synchronize her sequence numbers with Bob 106 00:04:02,370 --> 00:04:05,480 the other direction because life is a two-way street. 107 00:04:05,480 --> 00:04:07,390 So as part of that reply, not only 108 00:04:07,390 --> 00:04:10,120 will include the acknowledgment and the acknowledgment number, 109 00:04:10,120 --> 00:04:13,570 but Lois is also going to send her own synchronization 110 00:04:13,570 --> 00:04:15,370 request to Bob. 111 00:04:15,370 --> 00:04:18,130 And let's imagine, for fun, that Lois's computer 112 00:04:18,130 --> 00:04:21,550 running the web server software chose a sequence number as part 113 00:04:21,550 --> 00:04:27,310 of the request of 290,218,379. 114 00:04:27,310 --> 00:04:29,299 So all that information, including the sequence 115 00:04:29,299 --> 00:04:31,840 numbers in the acknowledgment numbers and the ACK and the SYN 116 00:04:31,840 --> 00:04:34,090 flags are all sent back in one message 117 00:04:34,090 --> 00:04:36,670 back to Bob, at which point, Bob needs 118 00:04:36,670 --> 00:04:40,060 to go ahead and acknowledge the synchronization request 119 00:04:40,060 --> 00:04:42,260 that he got from Lois. 120 00:04:42,260 --> 00:04:44,559 So he's going to send a final message back. 121 00:04:44,559 --> 00:04:45,850 So I've got a question for you. 122 00:04:45,850 --> 00:04:48,760 If Lois sent over this sequence number 123 00:04:48,760 --> 00:04:51,100 as part of her SYN request, what would 124 00:04:51,100 --> 00:04:53,650 be the appropriate acknowledgment number that Bob 125 00:04:53,650 --> 00:04:54,970 should send back to Lois? 126 00:04:54,970 --> 00:04:57,385 [MUSIC PLAYING] 127 00:04:57,385 --> 00:04:58,840 128 00:04:58,840 --> 00:05:01,280 And if we consider the logic on the previous one, 129 00:05:01,280 --> 00:05:03,530 the acknowledgment is going to be the initial sequence 130 00:05:03,530 --> 00:05:04,790 number plus 1. 131 00:05:04,790 --> 00:05:09,560 So if Louis's initial sequence number is 290,218,379, 132 00:05:09,560 --> 00:05:11,540 Bob's acknowledgment number to acknowledge 133 00:05:11,540 --> 00:05:14,240 that he received that should be one more, 134 00:05:14,240 --> 00:05:19,010 which would be 290,218,380. 135 00:05:19,010 --> 00:05:21,597 These devices can now send data back and forth. 136 00:05:21,597 --> 00:05:23,180 They can manage their sequence numbers 137 00:05:23,180 --> 00:05:25,070 in acknowledgment numbers to make sure 138 00:05:25,070 --> 00:05:27,590 that all the data that's sent from one party 139 00:05:27,590 --> 00:05:29,630 is acknowledged by the other side. 140 00:05:29,630 --> 00:05:32,750 And that, my friend, is how TCP establishes 141 00:05:32,750 --> 00:05:37,070 reliable communications by using its three-way handshake. 142 00:05:37,070 --> 00:05:39,410 I hope this has been informative for you. 143 00:05:39,410 --> 00:05:42,880 And I'd like to thank you for viewing.