TCP / IP protocol brief summary

 

1, TCP / IP main features:

(1) TCP is a connection-oriented transport layer protocol.

(2) Each TCP connection has two endpoints intelligent.

(3) TCP provides reliable service delivery.

Connected via TCP data transfer, error-free, is not lost, will not be repeated, and the arrival demand;

(4) TCP provides full-duplex communication.

(5) facing the byte stream.

"Flow" refers to a sequence of bytes flowing into or out of the process from the process.

 

2, TCP connections

Endpoint of the TCP connection is called a socket or socket. Splicing the port number to the IP address that is configured socket.

Socket soket = (IP address: port number)

Each TCP connection is uniquely ends of the two communication end points (i.e., two sockets) are determined: namely:

TCP connection :: = {soket1, soket2} = {(IP1: port1), (IP2: port2)}

3, the working principle of reliable transmission

TCP segment is sent to the IP layer transmission, but refers to the IP layer provides a best effort service, is to say, the following TCP provided by the network is unreliable transport. Therefore, TCP must adopt appropriate measures in order to make communication between two transport layer becomes reliable.

Transmission conditions over the following two characteristics:

(1) no transmission channel errors.

(2) Whether a sender to transmit data perusal plurality of recipient always enough time to process the information received.

Stop waiting for the agreement:

Error-free case, the sender A transmits packet M1, finished to suspend transmission, wait for confirmation of B. B received it sends an acknowledgment to M1 A. A confirmation of the receipt of the M1, then transmits a next packet M2, and so forth.

Errors: B detect when something goes wrong to accept the M1, discarded M1, nothing else to do. M1 may also be lost during transmission, then B does not know of course;

   The above has such a design: A long over a period of time still have not received confirmation, I think just sent the packet loss, and thus retransmission packets sent over the front. This timeout retransmission;

  Achieve retransmission timeout, a timeout timer is set in the packet for each one finished.

Missing Acknowledge and confirm late: if in some cases, B M1 has received a packet retransmission. At this time it should take two actions: (1) discard the duplicate packets M1, does not deliver up. (2) send an acknowledgment to A. Can not be deemed to have been sent a confirmation is not sent, because the reason why A retransmission M1 says that A does not receive acknowledgment M1.

4, TCP segment header format

 

 

The first 20 bytes of the header CP segment is fixed, followed by 4N bytes are needed to increase the options, thus minimizing the length of the header is 20 bytes.

Meaning a fixed part of the header fields are as follows:

1. The source port and destination port fields

Occupies 2 bytes. Port is the service interface transport layer and the application layer. Transport layer multiplexing and demultiplexing functionality can be achieved through the port.


2. Sequence Number field

It occupies 4 bytes. TCP is a byte-oriented stream, byte stream transmitted in a TCP connection in each byte sequentially numbered. Whole starting sequence number of the byte stream to be transmitted must be provided at connection establishment.

Sequence number value in the header section refers to the first byte sequence number of data segments transmitted newspaper.


3. Confirmation Number:
4 bytes, looking first interface receives a data byte sequence number of the next segment. If the acknowledgment number = N, N-1 show the number up to all of the data have been received correctly!


4. Data offset (i.e., the header length)

Accounting for 4, indicating that the data at the beginning of TCP segments are far from the beginning of the segment of the TCP. "Data Offset" in units of 32-bit words (4 bytes for the unit). 

Because there are indefinite length header option field, it is necessary for the data offset field

And the unit data offset is 4 bytes, this field is used to meter the TCP header length, the maximum length of 4 bytes * 15, 60, i.e., the option is no longer than 40 bytes.


5. Leave the field:

Accounting for 6, reserved for future use, but should be set to 0.


6. Emergency URG:

When URG == 1, indicate the urgent pointer field is valid. It tells the system in this segment there is urgent data to be transmitted (the equivalent of high-priority data) as soon as possible. Not transmitted in the order of the original line.

When URG = 1, to tell the sending process data to be transmitted emergency TCP, TCP urgent data will be inserted into the top of the newspaper segment, which requires urgent and header pointer field used in conjunction.

 

7. acknowledgment ACK (ACKnowlegment):

When ACK = 1, the acknowledgment number field is valid, if ACK = 0, the acknowledgment number field is invalid. TCP provides that all segments transmitted after the connection must be set to ACK.


8. Push PSH (PuSH):

When the two-process communication, process and sometimes one end of hope after typing a command, the other party can receive an immediate response, then it can be TCP PSH = 1,

And immediately create a segment sent, the receiving TCP receive PSH = 1, will be delivered to the receiving end of the process as soon as possible, and not wait any longer before the entire cache fill delivery.


9. reset RST (ReSeT) 
when RST = 1, show serious error occurs in connection TCP (eg due to host crashes or other reasons), the connection must be released and then re-establish the transport connection

RST to 1 may be used to reject an illegal segment or refuse to open a connection.


10. The sync SYN:
used to synchronize the serial connection is established, when the SYN = 1 && ACK = 0, indicates that this is a connection request packet segments,

If the other party agrees to establish a connection, in response to the segment so that SYN = 1 && ACK = 1.

Therefore, SYN = 1: Indicates that this is a connection request packet and the receiving connector.


11. Termination FIN:

For releasing a connection, when the FIN = 1, this represents a segment of the sender data transmission is completed, and release the connection requirements.


12. Window:

2 bytes starting from 0, the window of the receive window refers to a transmission side of the newspaper segment (instead of its own transmission window), the window value as the recipient is provided which allows the sender based on the send window.
Window value to tell each other: since the beginning of the confirmation number from the head of the newspaper segment,
the receiver currently allows (values window is often dynamically changing) amount of data sent by the sender.
Field clearly points out the window now allows the amount of data sent by the other party.

13. Inspection and 

2 bytes. The checksum field test range comprises two portions and header data. In calculating the checksum, to add the pseudo-header of 12 bytes in front of the TCP segment.


14. Urgent Pointer:

2 bytes, if URG = 1, urgent pointer makes sense, indicates the number of bytes of urgent data segment newspaper.

Note: When the window is 0, urgent data may be transmitted.


15. Options:

Up to 40 bytes, when there is no option, TCP header length of 20 bytes.

1, TCP / IP main features:

(1) TCP is a connection-oriented transport layer protocol.

(2) Each TCP connection has two endpoints intelligent.

(3) TCP provides reliable service delivery.

Connected via TCP data transfer, error-free, is not lost, will not be repeated, and the arrival demand;

(4) TCP provides full-duplex communication.

(5) facing the byte stream.

"Flow" refers to a sequence of bytes flowing into or out of the process from the process.

 

2, TCP connections

Endpoint of the TCP connection is called a socket or socket. Splicing the port number to the IP address that is configured socket.

Socket soket = (IP address: port number)

Each TCP connection is uniquely ends of the two communication end points (i.e., two sockets) are determined: namely:

TCP connection :: = {soket1, soket2} = {(IP1: port1), (IP2: port2)}

3, the working principle of reliable transmission

TCP segment is sent to the IP layer transmission, but refers to the IP layer provides a best effort service, is to say, the following TCP provided by the network is unreliable transport. Therefore, TCP must adopt appropriate measures in order to make communication between two transport layer becomes reliable.

Transmission conditions over the following two characteristics:

(1) no transmission channel errors.

(2) Whether a sender to transmit data perusal plurality of recipient always enough time to process the information received.

Stop waiting for the agreement:

Error-free case, the sender A transmits packet M1, finished to suspend transmission, wait for confirmation of B. B received it sends an acknowledgment to M1 A. A confirmation of the receipt of the M1, then transmits a next packet M2, and so forth.

Errors: B detect when something goes wrong to accept the M1, discarded M1, nothing else to do. M1 may also be lost during transmission, then B does not know of course;

   The above has such a design: A long over a period of time still have not received confirmation, I think just sent the packet loss, and thus retransmission packets sent over the front. This timeout retransmission;

  Achieve retransmission timeout, a timeout timer is set in the packet for each one finished.

Missing Acknowledge and confirm late: if in some cases, B M1 has received a packet retransmission. At this time it should take two actions: (1) discard the duplicate packets M1, does not deliver up. (2) send an acknowledgment to A. Can not be deemed to have been sent a confirmation is not sent, because the reason why A retransmission M1 says that A does not receive acknowledgment M1.

4, TCP segment header format

 

 

The first 20 bytes of the header CP segment is fixed, followed by 4N bytes are needed to increase the options, thus minimizing the length of the header is 20 bytes.

Meaning a fixed part of the header fields are as follows:

1. The source port and destination port fields

Occupies 2 bytes. Port is the service interface transport layer and the application layer. Transport layer multiplexing and demultiplexing functionality can be achieved through the port.


2. Sequence Number field

It occupies 4 bytes. TCP is a byte-oriented stream, byte stream transmitted in a TCP connection in each byte sequentially numbered. Whole starting sequence number of the byte stream to be transmitted must be provided at connection establishment.

Sequence number value in the header section refers to the first byte sequence number of data segments transmitted newspaper.


3. Confirmation Number:
4 bytes, looking first interface receives a data byte sequence number of the next segment. If the acknowledgment number = N, N-1 show the number up to all of the data have been received correctly!


4. Data offset (i.e., the header length)

Accounting for 4, indicating that the data at the beginning of TCP segments are far from the beginning of the segment of the TCP. "Data Offset" in units of 32-bit words (4 bytes for the unit). 

Because there are indefinite length header option field, it is necessary for the data offset field

And the unit data offset is 4 bytes, this field is used to meter the TCP header length, the maximum length of 4 bytes * 15, 60, i.e., the option is no longer than 40 bytes.


5. Leave the field:

Accounting for 6, reserved for future use, but should be set to 0.


6. Emergency URG:

When URG == 1, indicate the urgent pointer field is valid. It tells the system in this segment there is urgent data to be transmitted (the equivalent of high-priority data) as soon as possible. Not transmitted in the order of the original line.

When URG = 1, to tell the sending process data to be transmitted emergency TCP, TCP urgent data will be inserted into the top of the newspaper segment, which requires urgent and header pointer field used in conjunction.

 

7. acknowledgment ACK (ACKnowlegment):

When ACK = 1, the acknowledgment number field is valid, if ACK = 0, the acknowledgment number field is invalid. TCP provides that all segments transmitted after the connection must be set to ACK.


8. Push PSH (PuSH):

When the two-process communication, process and sometimes one end of hope after typing a command, the other party can receive an immediate response, then it can be TCP PSH = 1,

And immediately create a segment sent, the receiving TCP receive PSH = 1, will be delivered to the receiving end of the process as soon as possible, and not wait any longer before the entire cache fill delivery.


9. reset RST (ReSeT) 
when RST = 1, show serious error occurs in connection TCP (eg due to host crashes or other reasons), the connection must be released and then re-establish the transport connection

RST to 1 may be used to reject an illegal segment or refuse to open a connection.


10. The sync SYN:
used to synchronize the serial connection is established, when the SYN = 1 && ACK = 0, indicates that this is a connection request packet segments,

If the other party agrees to establish a connection, in response to the segment so that SYN = 1 && ACK = 1.

Therefore, SYN = 1: Indicates that this is a connection request packet and the receiving connector.


11. Termination FIN:

For releasing a connection, when the FIN = 1, this represents a segment of the sender data transmission is completed, and release the connection requirements.


12. Window:

2 bytes starting from 0, the window of the receive window refers to a transmission side of the newspaper segment (instead of its own transmission window), the window value as the recipient is provided which allows the sender based on the send window.
Window value to tell each other: since the beginning of the confirmation number from the head of the newspaper segment,
the receiver currently allows (values window is often dynamically changing) amount of data sent by the sender.
Field clearly points out the window now allows the amount of data sent by the other party.

13. Inspection and 

2 bytes. The checksum field test range comprises two portions and header data. In calculating the checksum, to add the pseudo-header of 12 bytes in front of the TCP segment.


14. Urgent Pointer:

2 bytes, if URG = 1, urgent pointer makes sense, indicates the number of bytes of urgent data segment newspaper.

Note: When the window is 0, urgent data may be transmitted.


15. Options:

Up to 40 bytes, when there is no option, TCP header length of 20 bytes.

Guess you like

Origin www.cnblogs.com/1819zzh/p/11940643.html