A computer network (II) - interview questions

1.HTTP request, which has several ways?

In the HTTP request, the first row must be a request line (request line), used to illustrate the type of request to access the resource, and the HTTP version.

Followed by a header (header) section, for explaining the additional information server to be used. After the header is a blank line, then this can then add any other data [called body (body)]

Eight kinds:

 
The OPTIONS   : Returns the request method supported by the server
GET            : Gets the specified resource to the server
The HEAD         : consistent with the GET, but the body does not respond to return, only to return response headers
POST         : submit data to the server, requesting data on the body, there is likely to lead to a revision of existing resources or establishing new resources
PUT            : POST with similar, but with a power and other characteristics, generally used for updating (to upload their content to the latest specified resource location)
DELETE     : delete the specified resource server (request-URL marked the resources)
The TRACE       : back to the requesting client receives significant server for testing and diagnosis
The CONNECT:  the HTTP / 1.1 protocol can be connected to the proxy server Ducted
 

GET and POST requests differences:
  Essentially there is no difference between the two. They are the request method HTTP protocol. The underlying implementation is based on TCP / IP protocol.
(1) is placed in a GET request parameter in the URL, POST request body parameters are placed in the request;
(2) GET request to the URL transmission parameter having a length limiting, but no length limit POST request;
(3) parameters GET request can only be ASCII code, so the Chinese need URL encoding, mass participation and POST requests do not have this restriction;
(4) GET request parameter data submitted will be displayed in the address bar, and POST will not. POST therefore safer.
(5) GET is harmless when the browser is returned, and POST will submit the request again.
 
Form submission get and post difference in the way:
(. 1) is to get the data acquired from the server, the server transmits data to a post.
(2) For the form submission, the server can only be used to acquire data Get Request.QueryString submission to the data submitted by the Post manner can only be used to obtain Request.Form.
(3) In general, try to avoid using Get submit forms, because there may lead to security problems. Get example, the user inputs a user name and password in the address bar will be exposed in using the login form. But in the pager, the way you use Get better than with Post.
The only real difference in the response that the status information by the request information instead of the first line. Status line (status line) by providing a status code to illustrate the requested resources.
The most common status codes have:
◆ 200 (the OK): find the resources and everything is normal.
◆ 304 (NOT MODIFIED): The resource is not any changes since the last request. This is typically used for caching browsers.
◆ 401 (UNAUTHORIZED): The client does not have access to the resources. This usually makes the browser requires the user to enter a user name and password to log in to the server.
◆ 403 (FORBIDDEN): The client failed to obtain authorization. This is usually after 401 entered an incorrect user name or password.
◆ 404 (NOT FOUND): Resources requested does not exist at the specified location.

2.TCP and UDP What are the differences?

1, TCP connection-oriented (e.g., dial-up connection is established first call); the UDP is connectionless, i.e. without establishing a connection before sending data
2, TCP provides reliable service. In other words, the data transfer connection of TCP, error-free, not lost, not repeat, and arrive out of order; UDP best effort, that does not guarantee reliable delivery

Tcp by verifying and, retransmission control, serial number identification, sliding window, reliable transmission of the acknowledgment. The retransmission control packet loss, also a mess on the order of sub-sequence control.

3, UDP has better real-time performance, higher efficiency than TCP, suitable for high-speed transmission and higher real-time communication or broadcast communication.

4. Each TCP connection is only a point; the UDP support one to one, one to many, and many-to-many interactive communication

5, TCP more demanding on system resources, UDP less demanding on system resources.

3.TCP to achieve reliable data transmission by what measures?

1, TCP before the effective data transmission requirements of the communicating parties must shake hands, we can establish communication for data transmission.                                                (Handshake before they can establish communication for data transmission)
1, application data is divided into data block deemed most appropriate TCP transmission. This is completely different UDP datagram length generated by the application will remain unchanged.      (Data will be truncated to a reasonable length) 2, when a TCP segment sent, it starts a timer, waits for the destination to acknowledge receipt of the segment. If you can not receive a confirmation, it will retransmit this segment.     (Retransmission timeout) 3, when the TCP connection is received from the bottom of the other end of the TCP data, it sends an acknowledgment.                                                                                       (For requests received acknowledgment is given)  
 
4, TCP will automatically adjust the speed according to the transmission network bandwidth - the sliding window technique That reception situation based on the reception side is automatically adjusted each time the number of packets, and each packet which contains the number of bytes transmitted                                      

4. Describe in detail three-way handshake to establish a TCP connection, two handshakes okay?

 

TCP three-way handshake

  1. Client - sending packets with the SYN flag - a handshake - server
  2. Server - transmitting packets with the SYN / ACK flag - secondary handshake - Client
  3. Client - three-way handshake - - sent by the server with packets with the ACK flag

Two-way handshake can not, because the two sides in order to confirm their three-way handshake with each other sending and receiving is normal

The first handshake: the client can not confirm anything; the server confirmed the other party to send normal

The second handshake: The client confirmed: they send, receive normal, the other party to send, receive normal; the server confirmed: they normally receive, send each other normal

Third handshake: the client confirmed: they send, receive normal, the other party to send, receive normal; the server confirmed: they send, receive normal, the other normal transmission and reception

So three-way handshake will be able to confirm the double transceiver functions are normal, indispensable.

5. A detailed description of the process shut down four times and waved a TCP connection, why should four wave?

TCP four wave

Disconnect a TCP connection is required "four wave":

  1. When the client finishes the data transfer, the control bit is set to 1 FIN, the TCP connection stop request made
  2. After receiving the server response thereto FIN, the TCP connection acknowledgment will be closed in that direction, 1 is set to ACK
  3. Server then made in the opposite direction close request, sets FIN 1
  4. The client requests the server to be confirmed, is set to ACK, both to the closed end.

Any party can notice of connection release after the data transfer, the wait for confirmation that enters the half-closed state. When there is no other time and then send the data, the connection release notification is issued, the person confirmed after the TCP connection is fully closed.

For example: A and B call, the call will be ended, A said, "I want to say nothing of the" B replied "I know", but B may also have to say, A can not ask follow B at their own pace to end the call, then B may well barabara that a pass, the last B said, "I'm done", a replied "I know", considered the end of this call.

 

Guess you like

Origin www.cnblogs.com/toria/p/network2.html