- 论坛徽章:
- 0
|
TCP:Transmission Control Protocol
TCP provides a connection-oriented, reliable, byte stream service.
1:Connection-oriented means the two appliations using TCP must establish a TCP connection with eath other before they can exchange data.
2:Reliability:
(1):The application data is broken into what TCP consider the best sized chunks to send, the unit of information passed by TCP to IP is called a segment.
(2):When TCP sends a segment it maintains a timer, waiting for the other end to acknowledge reception of the segment. If an acknowledgment isn't received in time, the segment is retransmitted.
(3):When TCP receives data from the other end of the connection, it sends an acknowledgment. This acknowledgment is not sent immediately, but normally delayed a fraction of a second.
(4):TCP maintains a checksum on its header and data. This is an end-to-end checksum whose purpose is to detect any modification of the data in transit. If a segment arrives with an invalid checksum, TCP discards it and doesn't acknowledge receiving it. (It expects the sender to time out and retransmit.)
(5):Since TCP segments are transmitted as IP datagrams, and since IP datagrams can arrive out of order, TCP segments can arrive out of order. A receiving TCP resequences the data if necessary, passing the received data in the correct order to the application.
(6):Since IP datagrams can get duplicated, a receiving TCP must discard duplicate data.
(7):TCP also provides flow control. Each end of a TCP connection has a finite amount of buffer space. A receiving TCP only allows the other end to send as much data as the receiver has buffers for. This prevents a fast host from taking all the buffers on a slower host.
3:A stream of 8-bit bytes is exchanged across the TCP connection between the two applications. There are no record markers automatically inserted by TCP. This is what we called a byte stream service.
4:TCP does not interpret the contents of the bytes at all. 'TCP has no idea if the data bytes being exchanged are binary data, ASCII characters, EBCDIC characters, or whatever. The interpretation of this byte stream is up to the applications on each end of the connection.
TCP header encapsulated:
||
||
| IP header | TCP header | TCP data |
| 20 bytes | 20 bytes | |
TCP header:
| 16-bit Source port number | 16-bit Destination port number|
| 32-bit sequence number |
| 32-bit acknowledge number |
| 4-bit | reserved |U|A|P|R|S|P| |
| header | 6bits |R|C|S|S|Y|I| 16-bit window size |
| length |(all zero)|G|K|H|T|N|N| |
| 16-bit TCP checksum | 16-bit urgent pointer |
| options(if any) |
| data |
URG:The urgent pointer is valid.
ACK:The acknowledgment number is valid.
PSH:The receiver should pass this data to the application as soon as possible.
RST:Reset the connection.
SYN:Synchronize sequence numbers to initiate a connection. This flag and the next are described in Chapter 18.
FIN:The sender is finished sending data.
# 2009-09-20 22:5
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/104229/showart_2056413.html |
|