1 00:00:00,060 --> 00:00:06,720 The Transmission Control Protocol, TCP, provides a communication service at an intermediate level between 2 00:00:06,720 --> 00:00:10,160 an application program and the Internet Protocol. 3 00:00:10,400 --> 00:00:17,640 It provides host-­to-­host connectivity at the Transport Layer of the Internet model. TCP works with the 4 00:00:17,700 --> 00:00:24,770 Internet Protocol (IP), which defines how computers send packets of data to each other. Together, 5 00:00:24,810 --> 00:00:34,720 TCP and IP are the basic rules defining the Internet. TCP is a connection-­oriented protocol which means 6 00:00:34,720 --> 00:00:41,030 a connection is establish and maintain until the application programs at each end have finished exchanging 7 00:00:41,030 --> 00:00:49,360 messages. It determines how to fragment application data into packets that networks can deliver, sends 8 00:00:49,360 --> 00:00:57,970 packets to accept packets from the network layer, manages flow control and because it is meant to provide 9 00:00:58,090 --> 00:01:04,810 error free data transmission handles retransmission of dropped or garbled packets as well as acknowledgement 10 00:01:04,840 --> 00:01:11,980 of all packets that arrive, Let’s see the connection-­oriented, error-­free communication of TCP in an example: 11 00:01:12,160 --> 00:01:19,360 When a Web server sends a HTML file to a client, it uses the HTTP protocol to do so. 12 00:01:19,450 --> 00:01:26,070 The HTTP program layer asks the TCP layer to set up the connection and send the file. 13 00:01:26,140 --> 00:01:32,980 The TCP stack divides the file into packets, numbers them and then forwards them individually to the 14 00:01:32,980 --> 00:01:34,420 IP layer for delivery. 15 00:01:34,480 --> 00:01:39,940 Although each packet in the transmission will have the same source and destination IP addresses packets 16 00:01:39,940 --> 00:01:47,340 packets may be sent along multiple routes. The TCP program layer in the client computer waits until all of the 17 00:01:47,340 --> 00:01:54,060 packets have arrived, then acknowledges those it receives and asks for the retransmission on any it does 18 00:01:54,060 --> 00:02:01,800 not (based on missing packet numbers), then assembles them into a file and delivers the file to the receiving 19 00:02:01,800 --> 00:02:02,790 application. 20 00:02:03,550 --> 00:02:10,750 The TCP three-­way handshake is the method used by TCP to set up a connection. TCP's three way handshaking 21 00:02:10,750 --> 00:02:18,780 technique is often referred to as SYN, SYN-­ACK, ACK because there are three messages transmitted by TCP 22 00:02:18,780 --> 00:02:26,370 to negotiate and start a TCP session between two computers. This 3-­way handshake process is also 23 00:02:26,370 --> 00:02:34,140 designed so that both ends can initiate and negotiate separate TCP socket connections at the same time. 24 00:02:34,170 --> 00:02:37,660 That means, the connection is full-­duplex. 25 00:02:37,810 --> 00:02:43,610 Oh you know what we have to take a break at this point and talk about TCP flags. 26 00:02:43,780 --> 00:02:51,590 There are 1-­bit flags in TCP headers which are called TCP flags. TCP flags are used within TCP packet 27 00:02:51,600 --> 00:02:57,310 transfers to indicate a particular connection state or provide additional information. 28 00:02:58,390 --> 00:03:09,900 Ignoring ECE, CWR and NS flags for now, there are basically 6 TCP flags: 29 00:03:10,560 --> 00:03:15,320 The SYN, or Synchronisation flag, is used as a first step in establishing a 3-­ way handshake between two hosts. 30 00:03:15,450 --> 00:03:23,510 Only the first packet from both the sender and receiver should have this flag set. The ACK flag, which 31 00:03:23,510 --> 00:03:29,060 stands for “Acknowledgment”, is used to acknowledge the successful receipt of a packet. 32 00:03:29,190 --> 00:03:35,460 The RST flag, which stands for “Reset”, gets sent from the receiver to the sender when a packet is sent to 33 00:03:35,460 --> 00:03:43,400 a particular host that was not expecting it. The FIN flag, which stands for “Finished”, means there is no more 34 00:03:43,400 --> 00:03:44,690 data from the sender. 35 00:03:44,690 --> 00:03:49,740 Therefore it is used in the last packet sent from the sender. 36 00:03:49,810 --> 00:03:57,190 The PSH flag, which stands for “Push”, is somewhat similar to the URG flag and tells the receiver to process these packets 37 00:03:57,190 --> 00:04:04,930 as they are received instead of buffering them. The URG flag is used to notify the receiver 38 00:04:04,940 --> 00:04:09,710 to process the urgent packets before processing all other packets. 39 00:04:10,510 --> 00:04:16,870 OK now we can continue to talk about TCP’s three-­way handshake. 40 00:04:17,060 --> 00:04:25,280 STEP 1: Computer A sends a SYN data packet to Computer B. SYN data packet means, the data packet 41 00:04:25,280 --> 00:04:28,020 where the SYN flag of the TCP header is set. 42 00:04:29,700 --> 00:04:32,540 Well, what does setting the SYN flag mean? T 43 00:04:32,550 --> 00:04:39,710 hat means, making the SYN bit 1. The objective of this packet is to ask if Computer B is open for 44 00:04:39,710 --> 00:04:40,780 new connections. 45 00:04:41,770 --> 00:04:46,720 Computer B must have open ports that can accept and initiate new connections. 46 00:04:48,000 --> 00:04:55,890 STEP 2: When Computer B receives the SYN packet from Computer A, it responds and returns a confirmation receipt 47 00:04:56,160 --> 00:05:06,290 the SYN/ACK packet. As you understand, SYN/ACK packet means the packet in which the SYN and the ACK flags are set. 48 00:05:06,400 --> 00:05:13,610 STEP 3: Computer A receives the SYN/ACK from Computer A and responds with an ACK packet. 49 00:05:13,630 --> 00:05:19,300 At this point, both computers have received an acknowledgment of the connection. With these, a full-duplex 50 00:05:19,300 --> 00:05:21,030 communication is established. 51 00:05:22,020 --> 00:05:29,700 UDP is another protocol of Transport Layer, Layer 4, used primarily for establishing low- latency and loss 52 00:05:29,700 --> 00:05:32,970 tolerating connections between applications on the Internet. 53 00:05:33,150 --> 00:05:39,360 TCP has emerged as the dominant protocol used for the bulk of Internet connectivity owing to its services 54 00:05:39,360 --> 00:05:46,590 for breaking large datasets into individual packets checking for and responding lost packet and reassembling 55 00:05:46,590 --> 00:05:49,290 packets into the correct sequence. 56 00:05:49,410 --> 00:05:56,100 But these additional services come at a cost in terms of additional data overhead and delays called 57 00:05:56,120 --> 00:05:57,890 latency. 58 00:05:58,060 --> 00:06:01,710 In contrast UDP just sends the packets. 59 00:06:01,960 --> 00:06:09,100 Which means that it has a much lower bandwidth overhead and latency but packets can be lost or received 60 00:06:09,100 --> 00:06:10,520 out of order as a result. 61 00:06:10,810 --> 00:06:15,550 Owing to the different paths individual packets traverse between Center and receiver. 62 00:06:15,550 --> 00:06:23,090 So UDP uses a simple connection less communication model with a minimum of protocol mechanism. 63 00:06:23,270 --> 00:06:30,110 It has no handshaking dialogs and thus exposes the user's program to any unreliability of the underlying 64 00:06:30,110 --> 00:06:31,070 network. 65 00:06:31,500 --> 00:06:36,110 There is no guarantee of delivery ordering or duplicate protection. 66 00:06:36,110 --> 00:06:43,280 UDP is suitable for purposes where error checking and correction are either not necessary or are performed 67 00:06:43,520 --> 00:06:51,900 in the application. UDP is an ideal protocol for network applications in which perceive latency is critical 68 00:06:52,350 --> 00:06:58,860 such as gaming voice and video communications which can set for some data loss without adversely affecting 69 00:06:59,040 --> 00:07:01,080 perceived quality. 70 00:07:01,080 --> 00:07:07,770 In addition since it's transaction oriented suitable for simple query response protocols such as the 71 00:07:08,100 --> 00:07:11,310 domain name system or the network protocol.