2007년 12월 20일 목요일

Why 3-way Handshake is needed for TCP?

A Connection-Oriented Protocol, such as TCP, exchanges Control Information(called a Handshake) with the remote computer to verify that it is ready to receive data before sending it. When the handshaking is successful, the computers are said to have established a connection.
In contrast, a Connectionless Protocol, such as IP, doesn't exchange Control Information to establish an end-to-end connection before transmitting data.

TCP Connection Establishing: 3-Way Handshake

TCP Connection이 성립되기 위해서는 먼저 Server가 Connection을 수락할 준비상태에 들어가 있어야 하는데, 이를 'Passive open'이라 한다. Client는 Server로의 Connection Establishment를 요구하며, 이것은 'Active open'이다.

사용자 삽입 이미지

1. SYN Segment(Client의 Synchronization Information 전송): Client는 Source Port에 자신을 나타내는 Port Number를 넣고, Destination Port에는 Server를 가리키는 Port Number를 넣는다.(그림에서 Destination Port가 23이므로 Telnet Server로 Connection Request하는 경우이다). Sequence Number에는 Client의 ISN(Initialization Sequence Number)를 넣고, Acknowledgment Number는 0을 넣고, Flag는 SYN bit를 1로 설정하여 전송한다.

2. SYN+ACK Segment(Server의 Synchronization Information 전송 + SYN Segment 수신 확인): Server는 Source Port에 자신을 나타내는 Port Number를 넣고, Destination Port에는 Sender 나타내는 Port Number를 넣는다.(Telnet Server를 예로 들고 있으므로 Source Port에는 23번이 들어간다, Sender의 Port Number는 첫번째 단계에서 수신한 SYN Segment에서 있다. 결과적으로 보면 Sender가 보낸 SYN Segment에서 Source Port와 Destination Port가 서로 바뀌어 들어간 것과 같다). Sequence Number에는 Server의 ISN를 넣고, Acknowledgment Number에는 “Client의 ISN + 1”의 값을 넣고, Flag는 SYN 와 ACK bit를 모두 1로 설정하여 전송한다.

3. ACK Segment(SYN Segment 수신 확인): Client는 첫번째 단계와 동일하게 Source Port와 Destination Port를 설정하고, Acknowledgment Number에는 “Server의 ISN + 1”의 값을 넣고, Flag는 ACK bit를 1로 설정하여 전송한다.

TCP is a connection oriented protocol. It has to establish a connection between two parties (host and server) before it can start transmitting data (as opposed to for example, IP). The 3-way handshake verifies that both ends are connected properly.


[Related Articles]
[DOC] AMAN2002를 활용한 TCP 연결 설정과 연결 종료 분석 by NetMan
2007/11/08 - [Network] - [scrap] TCP/IP Sliding Window
2007/10/23 - [Network/Network Story] - Network Selfstudy
2007/10/21 - [Network/cisco.com] - [cisco.com] Understanding TCP/IP
2007/09/28 - [Network/Link for Network] - [Link] TCP/IP의 이해(IP Address & Subnet)

댓글 없음:

댓글 쓰기