TCP service brief

1 Introduction
Although TCP and UDP use the same network layer (IP), TCP and UDP but provide different services to the application layer.
TCP provides a connection-oriented, reliable byte stream service.
Connection-oriented means that the two applications using TCP (usually a client and a server) in exchange data with each other
before must first establish a TCP connection. This process is similar to making a phone call, first dial ringing, wait for the other hook to say
, "Hello", before explain who you are. We will see how a TCP connection is established, and when one of the communication
how disconnected after that.
In a TCP connection, only two parties communicate with each other. In Chapter 2 introduces the first broadcast and multicast can not be used for TCP.
TCP to provide reliability in the following ways:
• Application data is divided into TCP deemed most appropriate data blocks sent. This is a completely different and UDP, the application generates
the data packet length will remain unchanged. Passed by the TCP to IP information units called segment or segments (segment)
• When TCP sends a segment, it starts a timer and wait for the destination to acknowledge receipt of this segment. If you can not
timely receive a confirmation, it will retransmit this segment.
• When the TCP receive a confirmation from the bottom of the other end of the TCP connection data, it will send. This acknowledgment is not sent immediately,
usually postpone fraction of a second.
• TCP test and it will keep the header and data. This checksum is an end, the purpose of data transmission is detected
any changes in the process. If you receive a section of the test and an error, TCP discards this segment and do not acknowledge receipt of
this segment (want to start a timeout and retransmits).
• Since the TCP segment as the IP datagram transmission, to reach the IP datagram may be out of order, so the TCP segments
arrive out of order may be. If necessary, the data received by the TCP will reorder the data will be received in
the correct order to the application layer.
• Repeat Since IP datagrams can occur, the receiving TCP must discard duplicate data.
• TCP also provides flow control. Each TCP connection has a fixed side buffer space size. Receiving TCP only
allows the other end of the transmitting and receiving end can receive the data buffer. This will prevent the host resulting in faster slower host buffer
overflow.
Two applications exchanging connection via TCP byte stream consisting of 8 bit bytes. TCP byte stream is not recorded in the inserted identification
character. We call this byte-stream service (byte stream service). If one of the first application 10 byte transfer, and transfer
20 bytes, 50-byte re-transmission, connected to the other of the sender will not know how many bytes for each transmission. 4 times recipient can then
receive these 80 bytes, 20 bytes each reception. Exiled to the end of the byte TCP connection, in the same byte stream will appear
other end of the TCP connection.
Further, TCP byte stream of the content without any explanation. TCP byte stream does not know the data transmission of binary data,
or ASCII character, EBCDIC character or other types of data. Interpretation of the byte stream from the TCP application layer both connected
explained.
This approach is very similar to the U nix operating system for handling byte stream file. U nix kernel
for the contents of an application to read or write, without any explanation, but to the application process. U nix kernel for it,
It can not distinguish between a binary file and a text file in a TCP data is encapsulated in an IP datagram, as shown in FIG.

The following figure shows the data format of the TCP header. Excluding optional field, which is typically 20 bytes.

Guess you like

Origin www.cnblogs.com/momenglin/p/11300856.html