TCP Connection Establishment and Termination Mechanism
TCP Connection Establishment and Termination Mechanisms
Overview of TCP Segments
- The video introduces the topic of TCP segments, referencing a previous discussion for more detailed information on each field within a TCP segment.
- It emphasizes that TCP is a connection-oriented protocol, necessitating connection establishment before data transfer.
Three-Way Handshaking Mechanism
- The three-way handshaking mechanism is explained as essential for establishing a connection, requiring the exchange of three messages.
- The client initiates the process by sending a connection request to the server, indicated by setting the SYN flag in the TCP header to 1.
Client and Server Communication
- The client sends a message with a sequence number (e.g., 8000), prompting the server to respond with its own sequence number (e.g., 15000).
- The server acknowledges receipt of the client's request by indicating it expects the next byte (801), using cumulative acknowledgment.
Acknowledgment Process
- Both parties must communicate their sequence numbers and acknowledgments; thus, both SYN and ACK flags are set during this phase.
- Upon receiving an acknowledgment from the server, the client responds with its own acknowledgment (15001), completing the three-way handshake.
Data Transmission After Connection Establishment
- Once established, data transmission can commence. Each segment sent consumes one sequence number but does not carry data until after connection setup.
Understanding Acknowledgement Flags and Connection Termination
Acknowledgement Flags in Data Transmission
- The use of acknowledgement flags is crucial; setting
ato 1 indicates an acknowledgment flag is active, while settingpto 1 signifies the push flag (psh) is enabled.
- When
pshis set to 1, it instructs the transport layer not to optimize but to send data immediately, ensuring timely delivery.
Cumulative Acknowledgements
- Upon receiving all data up to 10,000 bytes, the server sends a cumulative acknowledgment with a value of 10,001 and uses sequence number 15,1 for tracking.
- If the server has additional data (e.g., 2,000 bytes), it can send this alongside the acknowledgment.
Client Acknowledgment Process
- If the client has no more data to send, it will acknowledge receipt of all data up to byte 177,000 by sending an acknowledgment back.
Connection Establishment and Termination Phases
- The connection process involves three phases: establishing a connection, transferring data, and terminating the connection using a three-way handshake.
- Instead of setting a SYN flag during termination like in standard procedures, a FIN flag is set by the client indicating a request to disconnect.
Abrupt Disconnection Issues
- If both client and server wish to terminate without any pending data transfer (server also has no data), they exchange sequence numbers and acknowledgments indicating disconnection intentions.
- The final step involves the client sending an acknowledgment confirming agreement on termination from both ends.
Challenges in Connection Termination
Complexity of Connection Termination
- Terminating connections can be complex; if one host sends a disconnection request before all transmitted data arrives at its destination (due to loss), this results in abrupt disconnection leading to potential data loss.
Two Army Problem Analogy
- The "Two Army Problem" illustrates synchronization challenges where two armies must coordinate their attack on a third army. Both need confirmation that messages have been received before proceeding with their plans.
Communication Failures Impacting Coordination
- Even if one army proposes an attack time (e.g., at 10:00 AM), uncertainty about message receipt leads them not to act unless they receive confirmation from each other.
Infinite Acknowledgment Loop Issue
Connection Release Mechanisms in Networking
Understanding Connection Disconnection Scenarios
- The critical issue at hand is the loss of life during connection disconnections, which can be serious. However, if a disconnection is mistakenly initiated, there are opportunities to release the connection.
- In a typical three-way handshake for disconnection, a request and its acknowledgment are exchanged. If an acknowledgment is lost after sending a disconnection request, it complicates the process.
- When host two does not receive an acknowledgment for its disconnection request, it cannot terminate the connection immediately. Instead, it starts a timer; if no acknowledgment is received before timeout, it will proceed to terminate the connection.
- If both hosts send disconnection requests that get lost, host two will again start a timer upon sending another request. This mechanism allows for retries until successful or until termination occurs due to repeated timeouts.
- A strategy involves retrying multiple times (e.g., five attempts). If no response is received after these attempts, host two assumes that the other host does not exist and terminates the connection.
Summary of Connection Establishment and Termination
- The discussion covers how connections are established through three-way handshakes followed by data transmission. The termination process mirrors challenges faced in scenarios like the "two army problem."