5 July - CN - Flow Control, WSFO

Duration: 2 hr 10 min

This video lesson is available to enrolled students.

Enroll to watch — GATE Guidance by Sanchit Sir

AI Summary

An AI-generated summary of this video lecture.

This comprehensive lecture covers advanced concepts in the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). The session begins with a detailed explanation of TCP connection termination, specifically focusing on the FIN segment and the step-by-step state transitions involved in closing a connection. The instructor uses board diagrams to illustrate the interaction between a client and a server, highlighting states such as FIN_WAIT_1, CLOSE_WAIT, LAST_ACK, and TIME_WAIT. The lecture then transitions to TCP header fields, discussing the Window Size field, its 16-bit limitation, and the mechanism of Window Scaling to overcome this constraint. Key concepts like flow control, the Push (PSH) flag, and the Urgent (URG) flag are explained with practical examples. The session concludes with an introduction to UDP, contrasting its connectionless nature and lightweight header with TCP's reliability features, and discusses real-world applications of both protocols.

Chapters

  1. 0:00 2:00 00:00-02:00

    The video begins with a title card displaying the name 'Sanchit Jain' in white text against a black background. This introductory segment sets the stage for the lecture, identifying the instructor. There is no technical content presented in this initial window, serving purely as an opening sequence before the main educational material begins.

  2. 2:00 5:00 02:00-05:00

    The instructor introduces the topic of TCP connection termination. On the blackboard, the text '9. What happens when sender sends FIN segment?' is written in pink. The instructor explains that a TCP connection is half-duplex closed when one side sends a FIN and the other acknowledges it. The board text clarifies that both sides must send a FIN to fully close the connection, establishing the fundamental concept of the four-way handshake for termination.

  3. 5:00 10:00 05:00-10:00

    The lecture delves into the step-by-step behavior of the FIN segment. The board displays '10. Step by Step behaviour -' in yellow. The instructor writes '(i) Sender A sends a FIN (A has nothing to send now)'. The text explains that the TCP header has the FIN flag set to 1, and the sequence number of the FIN segment is the last byte of data plus one. This section breaks down the initial action of a sender initiating a connection close.

  4. 10:00 15:00 10:00-15:00

    A detailed diagram of the client-server interaction during connection termination is drawn on the board. The instructor illustrates the flow of segments, including 'FIN=1, Seq no (100-120)' from the client and 'ACK=121' from the server. The states are labeled, such as 'FIN_WAIT_STATE_1 of client' and 'Server is at CLOSE_WAIT state'. The diagram visually tracks the transition through states like LAST_ACK and TIME_WAIT, providing a clear visual representation of the termination process.

  5. 15:00 20:00 15:00-20:00

    The instructor discusses alternative methods for connection termination. The board text reads 'Connection can also be terminated abruptly by using RST (reset)'. It is noted that 'Here no FIN/ACK exchange is required'. Following this, the lecture transitions to TCP header fields, with the text 'Now time has come to discuss header fields of TCP' written in pink. The instructor introduces the HLEN field, specifying it is '4 bits' and similar to concepts studied in IP.

  6. 20:00 25:00 20:00-25:00

    The focus shifts to the Window Size field in the TCP header. The board text states 'Window Size - 16 bits'. The instructor explains that this field is also known as the 'advertise window size'. It tells the sender how many bytes the receiver is willing to accept. The text emphasizes that 'It is advertised by the receiver in every ACK segment' and is part of TCP's sliding window mechanism for flow control.

  7. 25:00 30:00 25:00-30:00

    A specific question is posed on the board to illustrate window size concepts: 'My Question - If the receiver advertises a TCP Window Size 4000 Bytes and the sender transmits 4000 bytes accordingly, must the sender wait for an acknowledgement before sending additional data?'. The instructor sets up a scenario where the receiver provides a new window size of 100 bytes in the ACK, prompting a discussion on how the sender calculates the effective window size based on the updated advertisement.

  8. 30:00 35:00 30:00-35:00

    The instructor draws a diagram to visualize the window size scenario. The board shows 'Client' and 'Server' with 'WS=4000' written next to the server. The client is depicted with a buffer containing segments labeled 1, 2, 3, 4. The instructor explains that the sender transmits four segments of 1000 bytes each, fully utilizing the advertised window. The diagram helps visualize the data in flight and the receiver's buffer capacity.

  9. 35:00 40:00 35:00-40:00

    The lecture continues with the calculation of the effective window. The board text shows 'Total unacknowledged at this instance = 4000 bytes' and 'New window size = 4000 bytes'. The instructor explains that the sender can send another 4000 bytes minus the unacknowledged bytes. The text 'unacknowledged bytes < Advertised window size' is highlighted, showing the condition for sending more data. The calculation '4000 - 100 = 3900' is shown to determine how much more data can be sent.

  10. 40:00 45:00 40:00-45:00

    The instructor addresses a hypothetical scenario regarding lost acknowledgments. The board text asks 'What if ack segment is lost?'. The explanation states that the 'Sender will continue to transmit until unacknowledged segments matches to Current window size and then wait for acknowledgment of time out'. This highlights the sender's behavior when feedback is missing, relying on timers to manage the flow of data.

  11. 45:00 50:00 45:00-50:00

    Another scenario is explored: 'What if receiver sends an ack segment that also advertises a reduced window size, but that segment is lost in transit?'. The instructor explains that the sender does not immediately become aware of the updated window size and continues sending based on the old value. This leads to a discussion on how the sender handles potential buffer overflows at the receiver if the window size has actually shrunk.

  12. 50:00 55:00 50:00-55:00

    The concept of a Zero Window Size (WS=0) is introduced. The board text asks 'How will sender behaves after getting WS=0?'. The answer provided is 'It cannot send new data because even 1 byte would exceed the advertise window'. The instructor explains that while the application layer continues sending data, the TCP layer buffers it, waiting for the receiver's reply. The connection remains active, but data transmission is paused.

  13. 55:00 60:00 55:00-60:00

    The mechanism for preventing deadlock in a zero-window scenario is explained. The board text states 'Sender sets a probe timer after receiving WS=0'. The timer is typically based on the RTO (Retransmission Time Out). The instructor explains that after the timer expires, the sender sends a 1-byte probe segment with the next expected sequence number. This 'Zero Window Probe' checks if the receiver's buffer has opened up.

  14. 60:00 65:00 60:00-65:00

    The lecture moves to the Push (PSH) flag. The board text reads 'PSH -> push flag '1-bit''. The instructor explains that this flag 'Instructs the receiving TCP stack to immediately deliver the received data to the application without waiting to fill the buffer'. By default, TCP might wait to collect more data, but the PSH flag forces immediate delivery, optimizing performance for interactive applications.

  15. 65:00 70:00 65:00-70:00

    The Urgent (URG) flag is discussed next. The board text says 'URG flag -> It tells the receiving system that some of the data in this packet should be treated as Urgent'. The instructor clarifies that the URG flag itself doesn't mark which data is urgent; instead, it tells the receiver to look at another field called the 'Urgent pointer'. This pointer specifies how much data from the current position is urgent, allowing for out-of-band data transmission.

  16. 70:00 75:00 70:00-75:00

    A comparison between the PUSH and URG flags is presented on the board. The text 'Difference in URG flag & PUSH flag?' is written. The instructor explains that PUSH tells the receiver to immediately pass data to the application, bypassing buffer waiting. In contrast, URG indicates that some data is urgent and needs to be prioritized. The receiver checks the Urgent pointer to find the end of the urgent data, distinguishing it from the standard data stream.

  17. 75:00 80:00 75:00-80:00

    The instructor draws a diagram to illustrate the difference between PUSH and URG. The board shows a data segment with '1st byte' and 'data'. The instructor explains that if you send a 'low spicer, low oil note to the kitchen', this flag will be read first and prioritized before serving. This analogy helps clarify how urgent data is handled differently from standard data that is just pushed for immediate delivery.

  18. 80:00 85:00 80:00-85:00

    The lecture transitions to the TCP Header structure. The board displays a table with fields like 'Source Port', 'Destination Port', 'Sequence Number', 'Acknowledgment Number', 'Header Length', 'Reserved', 'Flags', and 'Window Size'. The instructor points out that the header is 20 bytes minimum, with options adding up to 40 bytes. This section provides a comprehensive overview of the TCP segment format.

  19. 85:00 90:00 85:00-90:00

    The instructor introduces the User Datagram Protocol (UDP). The board text reads 'UDP - User datagram protocol'. A diagram shows the UDP header structure, which is 8 bytes long, consisting of 'Source Port', 'Destination Port', 'Total Length', and 'Checksum'. The instructor notes that the datagram size can be up to 65535 bytes, and the header is significantly smaller than TCP's, reflecting UDP's lightweight nature.

  20. 90:00 95:00 90:00-95:00

    The concept of Wrap-around time is introduced. The board text states 'Wrap around time - It is a fundamental concept in understanding how long it takes for TCP's 32 bit sequence numbers to exhaust and restart'. The instructor explains that the reuse of sequence numbers is known as 'Wrap up time'. Since TCP uses 32 bits for sequence numbers, the maximum number of sequence numbers is 2^32, which equals 4GB of data.

  21. 95:00 100:00 95:00-100:00

    The instructor calculates the wrap-around time. The board shows the formula 'Wrap time = 2^32 / Bandwidth'. An example is given with a bandwidth of 100 Mbps, resulting in a wrap time of 343.6 seconds. The instructor explains that after this time, TCP can reuse sequence numbers. The concept of MSL (Maximum Segment Life) is introduced to prevent confusion if sequence numbers wrap around within the time a segment is in transit.

  22. 100:00 105:00 100:00-105:00

    The lecture returns to UDP characteristics. The board text states 'UDP is Connectionless and lightweight protocol that gives priority to speed over reliability'. The instructor explains that there is no handshaking, and communication happens without establishing a connection. The 8-byte header is emphasized again, contrasting it with TCP's larger header. This section reinforces the trade-off between speed and reliability in network protocols.

  23. 105:00 110:00 105:00-110:00

    The instructor discusses services that use TCP versus UDP. The board text lists 'Services like HTTP, FTP, SMTP etc uses TCP'. It is noted that when reliable service is wanted, TCP is used regardless of speed. Conversely, 'When we want fast service it doesn't matter for us whether reliable or not then we use UDP'. This distinction helps students understand the practical application of each protocol in real-world scenarios.

  24. 110:00 115:00 110:00-115:00

    Specific examples of UDP services are provided on the board. The text lists 'Services like DNS, video call, sharing of routing table among routers etc uses UDP'. The instructor also mentions DHCP. These examples illustrate scenarios where speed is critical and some packet loss is acceptable, making UDP the preferred choice over TCP for these applications.

  25. 115:00 120:00 115:00-120:00

    The lecture introduces the Window Size Scaling factor Option (WSFO). The board text explains that the original TCP header allows only a 16-bit window field, meaning a maximum window size of 64KB. To scale or increase the window size, the WSFO is used. The instructor explains that this option allows TCP to multiply the 16-bit window size by a scaling factor of 2^n, where n <= 14.

  26. 120:00 125:00 120:00-125:00

    The instructor calculates the effective maximum window sizes using the scaling option. The board shows 'Effective Max Window Sizes - 1. At Client = 2^16 bytes * 2^6 = 2^22 bytes => 4MB'. For the server, the calculation is '2^15 bytes * 2^6 = 2^21 = 1MB'. This demonstrates how the scaling option expands the maximum window size from 64KB to 1GB, allowing for higher throughput in high-speed networks.

  27. 125:00 129:41 125:00-129:41

    The lecture concludes with a discussion on how TCP implements the window scaling option. The board text states 'How does TCP implement this? During TCP 3-way handshake both sides use the window scale option to indicate support to their desired scaling factor'. The instructor explains that the field in the TCP header still only carries 16 bits, but each side knows it must scale that value by 2^n. This negotiation happens during the handshake, ensuring both parties agree on the scaling factor before data transfer begins.

The lecture provides a thorough exploration of TCP and UDP protocols, focusing on their mechanisms for connection management, flow control, and data transmission. It begins by detailing the TCP connection termination process, emphasizing the role of FIN segments and the state transitions involved. The instructor then shifts to TCP header fields, explaining the Window Size field and its limitations, followed by the Window Scaling Option which allows for larger window sizes in high-speed networks. The concepts of flow control, including the Push and Urgent flags, are clarified with diagrams and analogies. The session concludes with a comparison of TCP and UDP, highlighting their respective use cases based on reliability and speed requirements. This comprehensive overview equips students with a deep understanding of transport layer protocols and their practical applications.