How TCP Establishes A Connection
来源:互联网 发布:简述什么是javascript 编辑:程序博客网 时间:2024/06/05 08:27
TCP Is a Connection-Oriented Protocol
TCP opens up a virtual connection between the client and serverprograms running on separate computers so that multiple and/or sporadicstreams of data can be sent over an indefinite period of time betweenthem. TCP keeps track of the packets sent by giving each one a sequencenumber with the remote server sending back acknowledgment packetsconfirming correct delivery. Programs that use TCP therefore have ameans of detecting connection failures and requesting theretransmission of missing packets. TCP is a good example of aconnection-oriented protocol.
How TCP Establishes A Connection
Any form of communication requires some form of acknowledgement forit to become meaningful. Someone knocks on the door to a house, theperson inside asks "Who is it?", to which the visitor replies, "It'sme!" Then the door opens. Both persons knew who was on the other sideof the door before it opened and now a conversation can now begin.
TCP acts in a similar way. The server initiating the connectionsends a segment with the SYN bit set in TCP header. The target replieswith a segment with the SYN and ACK bits set, to which the originatingserver replies with a segment with the ACK bit set. This SYN, SYN-ACK,ACK mechanism is often called the "three-way handshake".
The communication then continues with a series of segmentexchanges, each with the ACK bit set. When one of the servers needs toend the communication, it sends a segment to the other with the FIN andACK bits set, to which the other server also replies with a FIN-ACKsegment also. The communication terminates with a final ACK from theserver that wanted to end the session.
This is the equivalent of ending a conversation by saying "Ireally have to go now, I have to go for lunch", to which the reply is"I think I'm finished here too, see you tomorrow..." The conversationends with a final "bye" from the hungry person.
You can clearly see the three way handshake to connect and disconnect the session.
In this trace, the sequence number represents the serial number ofthe first byte of data in the segment. So in the first line, a randomvalue of 9766 was assigned to the first byte and all subsequent bytesfor the connection from this host will be sequentially tracked. Thismakes the second byte in the segment number 9767, the third number 9768etc. The acknowledgment number or Ack, not to be confused with the ACKbit, is the byte serial number of the next segment it expects toreceive from the other end, and the total number of bytes cannot exceedthe Win or window value that follows it. If data isn't receivedcorrectly, the receiver will re-send the requesting segment asking forthe information to be sent again. The TCP code keeps track of all thisalong with the source and destination ports and IP addresses to ensurethat each unique connection is serviced correctly.
- How TCP Establishes A Connection
- TCP closing a connection
- How To Set Up a TCP/IP Peer-to-Peer Network Connection
- A sample for TCP connection
- TCP: terminating a connection 3
- How to Detect a Dialup Connection?
- Establishment of a TCP connection, state diagram
- How does a DMI device establish a connection to NSM?
- How to: Create and Use a Data Connection Library
- How to cancel a persistent connection using NSURLConnection?
- How to Make an HTTP Connection Using TCP/IP with RSocket
- How to Make an HTTP Connection Using TCP/IP with RSocket
- How to Make an HTTP Connection Using TCP/IP with RSocket
- How to release the port of TCP Client immediately when the connection is disconnect with the TCP server. - TCP 客户端与 TCP 服务器断开连接后
- How to know whether a connection leak occured in weblogic8.1
- How to make your intermittent or flaky terminal services connection a little more stable
- How To Connect Using A Sqlplus Preliminary Connection (Doc ID 986640.1)
- TCP Connection Established! ^_^
- #ifndef#define#endif的用法
- 企业开发框架NHibernate和Spring.Net -1
- 企业开发框架NHibernate和Spring.Net -2
- 网络核心交换机技术架构的演进
- 比较C#的静态常量(const)和动态常量(static和readonly)
- How TCP Establishes A Connection
- VBA中的REPLACE函数的问题
- RPC
- 宏并不是类型定义
- 读写锁算法的伪代码实现---摘《多核计算与程序设计》
- 指针数组,数组指针,以及函数指针,以及堆中的分配规则(转载)
- i++与i--的效率问题
- NET框架开发平台的体系架构概览(FCL,CTS,CLS)
- (转帖)vc6--complile通过,但bulid出错误