Computer network summary (a)

● Do you talk about how to ensure the reliability of TCP, and briefly established TCP connection and disconnection procedures

Reference answer:

TCP guarantees reliability:

(1) sequence number, acknowledgment, retransmission timeout

Data arrives at the receiving side, the receiving side needs to send a confirmation response indicating the data segment has been received, the acknowledgment number and the data sequence number will be described next time it needs to receive. If the sender sent the delay confirmation response is not received, there may be a loss of data sent, it could be the acknowledgment is lost, then the sender after waiting a certain time will be retransmitted. This time is generally 2 * RTT (round trip time segment) + an offset value.

(2) the window control and high-speed retransmission control / fast retransmission (duplicate acknowledgment)

TCP will use window controls to increase the transmission speed, which means within a window size, do not have to wait for a response before sending the next piece of data, the window size is no need to wait for confirmation and can continue to send data to the maximum. If you do not use window controls, each did not receive the acknowledgment of the data to be retransmitted.

Using the control window, if the data segment is lost 1001-2000, behind each transmission data, will continue to send the acknowledgment number 1001 as a response, to receive the data I represents the beginning of 1001, the transmit end receives three times if the same response, it will be retransmitted immediately; but there is a situation there may be data are received, but some responses are missing, this will not be retransmitted because the sender knows that if the data segment is lost, the receiver does not will let it, it would be crazy to remind ......

(3) Congestion Control

If the window is given a large, continuous sending end sends large amounts of data may result in network congestion (we are using the network, what are you crazy hair, throughput is so big, of course, will be blocked), and even cause the network paralysis. Therefore, in order to prevent this TCP performs congestion control.

Slow start: Define congestion window, start the window size to 1, after each receive a confirmation reply (after a rtt), the congestion window size * 2.

Congestion Avoidance: Set slow start threshold, generally are set to begin 65536. Congestion avoidance is when the congestion window size reaches the threshold value of the congestion window no longer rose, but the increase in the adder (each acknowledgment / each RTT, the congestion window size + 1), in order to avoid congestion.

The retransmission timeout seen as congested segment, the event of retransmission timeout, we need to first set the threshold to half of the current window size, and window size to the initial value of 1, and then re-enter the slow start.

Fast retransmit: immediately retransmitted in the face 3 times repeated acknowledgment response (high-speed retransmission control), Representative received three segments, but the one before that segment is lost, it will be.

Then, the first threshold is set to half of the current window size, then the congestion window size to the size of the slow start threshold +3.

This can be achieved: when TCP traffic, showed a gradual increase in network throughput, and throughput to reduce congestion with, and then slowly rise into the process, the network paralysis does not occur easily.

TCP connection establishment and disconnection:

 

 

 

Three-way handshake:

1. Client SYN flag bit is set to 1, a randomly generated value seq = J, and the packet is sent to the Server, Client enters the SYN_SENT state, waiting for acknowledgment Server.

2. Server receives the packet data from the flag bit SYN = 1 know Client requests to establish a connection, Server SYN and ACK flag bit are set to 1, ack = J + 1, a randomly generated value seq = K, the data and packet to the connection request to confirm Client, Server enters SYN_RCVD state.

3. Client receives the acknowledgment, checking whether the ack J + 1, ACK is 1, then if the correct ACK flag is set to 1, ack = K + 1, and the packet is sent to the Server, Server checks ack whether K + 1, ACK is 1, if correct, the connection is established, Client and Server enters eSTABLISHED state, complete the three-way handshake, then you can begin to transfer data between Client and Server.

Four wave:

Since the TCP connection is full-duplex, thus, each direction must be shut down separately, this principle is that when one task is finished sending data, sending a FIN to terminate the connection in this direction, but means receives a FIN There is no data on the flow in that direction, that is no longer receive data, but still be able to send data over the TCP connection until this direction also send a FIN. First off will be the one to perform active close, while the other performs a passive close.

1. After completing the data transfer, the client application process makes a connection release segment, and stops sending data, the client enters FIN_WAIT_1 state, then the client may still receiving data sent by the server.

2. After the server receives the FIN, ACK sent to a client, the acknowledgment number is the sequence number + 1 received, the server enters CLOSE_WAIT state. FIN_WAIT_2 into the client after receipt of state.

3. When the server is no data to send, the server sends a FIN packet, which the server enters LAST_ACK state, waiting for confirmation of the client

4. client after the server receives a FIN packet, sends an ACK packet to the server to confirm the sequence number of the received sequence number +1. In this case the client enters the TIME_WAIT state, waiting 2MSL (MSL: segment maximum survival time), and then close the connection.

● Please answer about the difference between HTTP and HTTPS, HTTPS, and what are the disadvantages?

Reference answer:

HTTP protocol and HTTPS protocol differences as follows:

1) HTTP protocol in the clear in the data transmission network, the data transmission protocol is HTTPS TLS-encrypted, HTTPS having a higher security

2) HTTPS after the TCP three-way handshake stage, the need for handshake SSL and encrypted using symmetric encryption key agreement of

3) HTTPS protocol requires the server certificate request, the corresponding browser installed root certificate

4) HTTP protocol port 80, HTTPS protocol port 443

HTTPS advantages:

HTTPS transmission data encrypted using a key process, so a higher security

HTTPS protocol can authenticate the user and the server, make sure to send data to the correct user and server

HTTPS Disadvantages:

HTTPS handshake phase delay higher: Since prior to the HTTP session also need an SSL handshake, so HTTPS protocol handshake phase delay increases

HTTPS deployment cost: on the one hand HTTPS protocol requires the use of certificates to verify their security, so it is necessary to purchase a CA certificate; on the other hand due to the use of HTTPS protocol requires encryption and decryption calculations, taking up more CPU resources, or the need for server configuration a high number

● Do you talk about HTTP return code

HTTP protocol response message by the status line, and the response packet in response to the head body, whose overall response status code is described as follows:

1xx: indication information - indicates a request has been received, processing continues.

2xx: Success - indicates that the request has been successfully received, understood, accepted.

3xx: Redirection - to fulfill the request must go a step further.

4xx: Client Error - The request contains a syntax error or a request can not be achieved.

5xx: Server-side Error - The server failed to achieve a legitimate request.

Common status codes, the status described in the detailed description below.

200 OK: The client request was successful.

206 partial content server correctly has processed a partial GET request or HTTP implemented simultaneously slice download, the request must indicate the range of up request including a Range client obtained the desired

300 multiple choices (optional redirection): a series of requested resources for the feedback information selected by the browser / user to select one of their own.

301 moved permanently (permanent redirect): The resource has been moved permanently to a new location, any future access to the resources have to use one of several URI this response back.

302 move temporarily (temporary redirect): now the temporary resource request from a different URI obtained in

304: not modified: if the client sends a GET request and the request pending condition to be allowed through, while the content of the document is not changed, is returned 304, the response does not contain inclusions (cache can be used directly).

403 Forbidden: server receives the request, but refused to provide services.

● Do you talk about the TCP three-way handshake and four waving process and the reasons

Reference answer:

TCP three-way handshake is as follows:

C-> SYN -> S

S->SYN/ACK->C

C->ACK->S

 

Three-way handshake reasons:

// There are three different views:

1. waste of resources point of view: quote from "computer network" doubts and exercise solutions Xie Xiren

Three-way handshake has failed to prevent the connection request packet to the server suddenly transport the waste of resources caused by the server. For example, the client sends a SYN, but because of network congestion, the SYN packet at a node long stay. The client then retransmitted SYN packet and correctly establish a TCP connection, and then close the connection After transmitting data. The connection release failure after the SYN packet to reach the server. Under the premise of the second handshake, the server will think this is a client-initiated another request, and then send SYN, and create socket socket on the server side, we have been waiting for the client to send data. However, because the client does not initiate a new request, it will drop SYN service side. At this point the client server waits to send data resulting in waste of resources.

2, the reliability of judgment:

Another want to determine if the two-channel unobstructed, you must use three transmitting and receiving packets, i.e. three-way handshake: "The essence of the problem is that the channel is not reliable, the communication will require a double question agree. and to solve this problem, whether you what information is contained in the message, the communication is three times the theoretical minimum. so TCP three-way handshake is not a requirement per se, but to meet the "reliably unreliable channel transmission of information, "the demand caused. 

Three is to ensure that the parties can receive clear each other can be made of the minimum value. In theory, no matter how many times the handshake can not confirm the channel is a "reliable", but can be confirmed by at least 3-way handshake it is "available", and then further on to improve the added handshakes but "it is available." This conclusion of credibility. In addition more reliable transmission Tcp is to rely on retransmission mechanisms to ensure the

3. Initial Sequence Number:

TCP connection establishment handshake, in essence, is to establish a reliable two-way communication link, while a back and forth, each side comes retransmission timeout ensure reliability (rather than by the number of handshakes). TCP three-way handshake is the result of optimization, in fact, it should be a 4-way handshake to establish a connection because it is zero-based, so the SYN ACK and the passive open SYN merged into a SYN-ACK.
Handshake action, intended to determine the two bidirectional initial sequence number, TCP sequence number to compile byte access transmission, because it is connected to both directions, it is necessary to two sequence numbers, do not transmit any byte handshake procedure, determining an initial sequence number only.

TCP's four waved as follows:

C->FIN->S

S->ACK->C

S->FIN->C

C->ACK->S

 

Four waving reason: since the close control of the connection in the application layer , the passive closed upon receiving one of FIN packets, TCP stack will send a direct acknowledgment packet ACK, the priority of the closed end of the communication. Then inform the application layer, the application layer decide when to send FIN packets. The application layer function uses a system call to read == 0 determines whether the peer closes the connection. (That initiative off the party does not send data after sending FIN, but may also need to accept data)

● Will the tcp handshake Why not twice? Why not four?

Two not: tcp is a full duplex communication, two-way handshake only determine the data communication link is, does not guarantee a normal communication reverse

Not four:
Originally shake hands and waved, like all need to be confirmed in both directions can Unicom have been the model should be:
1. The client sends to the server syn0
2. The server receives syn0, reply ACK (syn0 + 1)
3 server sends SYN1
4. client receives SYN1, reply ack (syn1 + 1)
as tcp is full duplex, the upper four data confirmed in both directions can be arrived correctly, steps 2 and 3 but there is no up and down links that can be combined to accelerate the efficiency of the handshake, all becomes a 3-way handshake.

● Do you look for TCP congestion control?

Reference answer:

Maintaining sender called congestion window cwnd (congestion window) state variable. Congestion window size depends on the degree of network congestion, and dynamically changing. The sender sends the window to make their equal congestion window, while taking into account the receiving capacity of the recipient, send window may be less than the congestion window. (That is, the ability to receive and transmit window congestion window equal to the lesser of the recipient's) idea of ​​the slow start algorithm is, do not start sending large amounts of data, to detect what level of network congestion, that is to say from small to big gradually increase the size of the congestion window.

Process cwnd size grows exponentially until it exceeds the slow start threshold, then enter the congestion avoidance phase, the size of the linear growth of cwnd when (three duplicate ack or a timeout) when there is network congestion, the slow start threshold is set to appear congestion time half the size, cwnd size re-entered the slow start from zero.
Fast retransmission and fast recovery: fast retransmission requirements issued by the recipient immediately repeated confirmation (in order to enable the sender to know as soon as possible segment does not reach the other side) and not wait until they send out of order after the receipt of a segment piggybacking data. Fast retransmission algorithm specifies, as long as the sender receive three consecutive duplicate acknowledgments should immediately retransmit the other segments have not yet received, rather than continue to wait for the retransmission timer set time expires

 

Note two things:

1. TCP congestion control algorithm has four kinds, i.e. the slow start, congestion avoidance, fast retransmission and fast recovery

2. After the implementation of fast retransmit fast recovery rather than slow start. When 4 points, not to start slow start, but performs fast recovery algorithm, the threshold and the congestion window size are set to the current congestion window / 2, and begin to implement congestion avoidance algorithm.

 

Guess you like

Origin www.cnblogs.com/lfri/p/12444083.html
Recommended