Network and Communication: Network Protocol (concept)

Source: Internet
Author: User

Computer network technology is the foundation of Internet development. It is a combination of computer technology and communication technology, is now an important part of information technology, and is moving towards the digital, high-speed, intelligent direction of rapid development. With the rise of 3G, 4G technology, more and more enterprises participate in the network and communication-related industries, network and communications-related industries, networks and communications become the pioneer of information technology. and the network-related technology investigation has been more and more important it enterprises pay attention to.

    • What are the differences between TCP and UDP?
    • What's a three-time handshake? What's called a four-time disconnection
      • Extension 1TCP Why does it take three handshakes to use two handshakes?
      • Extension 2 Why establishing a Connection agreement is three handshake and closing the connection is four times the handshake
    • What is Arprarp
    • What is a ping command
    • What are the basic HTTP processes

What are the differences between TCP and UDP?

The Transport Layer protocol mainly has TCP and UDP. UDP (User Datagram Protocol) provides no-connection communication and does not guarantee that packets are sent to the destination address, typically using UDP for applications that transmit small amounts of data on the fly. TCP (transmission Control Protocol) is a connection-oriented (connection-oriented), reliable, byte-stream-based communication protocol that provides connection-oriented and reliable communication for transmitting large amounts of data or for applications that need to accept data licensing.

The TCP connection is like the telephone, the user dials the specific number, the other person is online and picks up the telephone, then the two sides carries on the call, after the call finishes, hangs up, the entire process is one mutually links the indispensable process. And UDP connection is like texting, the user text message to each other, the other party did not receive information, the sender does not know, and the other side whether the answer is not known, the other side of the message sender sent the same message.

TCP and UDP are common means of communication and play different roles under certain conditions. Specifically, the differences between TCP and UDP are mainly expressed in the following areas:

(1) TCP is a connection-oriented Transmission Control protocol, and UDP provides a non-connected datagram service.

(2) TCP has high reliability, ensure the correctness of transmission data, no loss or disorderly sequence; UDP does not establish a connection before transmitting data, does not check and modify the datagram, does not need to wait for the other party's answer, so the packet loss, duplication, chaos, the application needs to be responsible for all the work of transmission reliability.

(3) TCP requires more system resources, and UDP has less requirements on system resources.

(4) UDP has better real-time performance and higher efficiency than TCP.

(5) The segment structure of UDP is simpler than the segment structure of TCP, so the network overhead is also small.

UDP is more efficient than TCP, why is TCP still able to retain it? In fact, TCP and UDP strengths, each has a short, suitable for different requirements of the communication environment, some environments using UDP is really efficient, and some environments require reliable connection, when using TCP is better. IP is also generally mentioned when referring to TCP. IP protocol is a network layer protocol, which stipulates that each Internet computer has a unique IP address, so that packets can be forwarded through the router to the designated computer, but IP does not guarantee the reliability of data transmission.

What do you call a three-time handshake? What's called Four disconnects

TCP is a connection-oriented protocol, so-called connection refers to the two sides of the communication before sending data to each other must establish a secure channel, like a telephone, must wait until the other side of the phone ringing, and the other person to answer the phone, to communicate with the other party. And UDP is not a connection-oriented protocol, UDP-based communication between the two parties do not need to negotiate with the other party and establish a connection, regardless of the other side of the IP address and the port number is present, directly send data, this processing method is a bit like mobile phone texting, regardless of whether the other phone is down or shutdown, just send information, Whether or not the other person can receive the message.

In TCP/IP, a three-time handshake is used to establish a connection,
(1) First handshake: When establishing the connection, the client sends the SYN packet (if the serial number seq=100) to the server and enters the Syn_send state, waiting for the server to confirm.
(2) Second handshake: After the server receives the SYN packet, it must confirm the client, so it is necessary to send an ACK packet (ack=101), and the server must also send a SYN packet (serial number seq=300), such as the acknowledgement of the client, when the server enters the SYN_RECV state
(3) The third handshake: After the client receives the Syn+ack packet, sends the confirmation packet (ack=301) to the server, the packet sends complete, at this time the client and the server enters the established, the two can carry on the data exchange, completes three times the handshake.

Because TCP connections are full-duplex, they must be closed separately in each direction, and when a party completes the data-sending task, it can send a fin to terminate the connection in that direction. A TCP connection is still able to send data after receiving a fin, and the first one to close will actively execute the shutdown, while the other side will perform a passive shutdown.

(1) After the client sends the data, send a fin to ask for disconnection
(2) After the server receives the fin packet, responds to it by sending an ACK packet confirming that the connection in this direction will be closed
(3) When the server's application is ready to close, the server sends a FIN packet in the opposite direction to the client, requesting that the connection request be closed.
(4) The client confirms the request sent by the server and sends an ACK packet.

In the fourth step, why do you need time_wait? The ACK sent by HOST1 may be lost and cause HOST2 to resend the fin message, time_wait maintain the connection status. If the active shutdown party HOST1 does not enter the TIME_WAIT state to close the connection, when the retransmission of the fin message arrives, because TCP is no longer connected to the information, so with the RST (restart) message reply, so that the HOST2 into the wrong state instead of the ordered termination state. If the party sending the last ACK message is in a time_wait state and still records the information of the connection, it can correctly HOST2 the fin message for the corresponding peer.

Second, TIME_WAIT provides time for the "outlier segment" of the connection to disappear from the network, typically because TCP simply discards the data and affects the RST message, so this does not cause any problems. When the RST message arrives at the host that issued the delay period, it also discards the segment because the host does not have any information to record the connection. However, if a new connection with the same port number is established between the two identical hosts, then the segment of the outlier may be read through as a new connection, and if any sequence number of the data in the segment of the outlier is in the current receive window of the new connection, the data is re-received, and the result is breaking the new connection.

Extension 1:TCP Why do you need to shake hands three times, with two handshakes?

The process of establishing a connection is to take advantage of the client server model, assuming that host A is the client and Host B is the server side.

(1) TCP Three handshake process: Host A to Host B to send a connection request, Host B to receive a message segment of host A to confirm, host a again to confirm the Host B.

(2) The use of three-time handshake is to prevent the failure of the connection request packet suddenly transmitted to host B, resulting in an error. Invalid connection request message segment refers to: Host a connection request did not receive the confirmation of Host B, so after a period of time, host A and then re-send the connection request to host B, and establish a successful, sequential completion of data transmission. Considering such a special case, host a first send the connection request is not lost, but because the network node caused the delay to host B, Host B thought it was host A and the new connection initiated, so Host B agreed to connect, and to host a back to confirm, but at this time, host A will not listen to, Host B has been waiting for host A to send data, resulting in a waste of Host B resources.

(3) The use of two handshake is not possible, because the above said the amount of failure of the connection request special circumstances.

Extension 2: Why the Connection Agreement is a three-time handshake, while closing the connection is a four-time handshake?

Since the socket in the server-side listen state receives a connection request for the SYN message, it can send the ACK and SYN (ACK-response, and SYN-sync) to a message. However, when the connection is closed, when the other side of the fin message notification, it only means that no data sent to you, but not all of your data are sent to the other side, so you may not immediately close the socket, that is, you might also need to send some data to the other side, Send fin message to the other side to express consent can now close the connection, so here the ACK message and fin messages are sent separately in most cases.

What is Arp/rarp

ARP (Address Resolution Protocol) is a low-level protocol located in the TCP/IP protocol stack that maps the physical and network IP addresses of a computer. In an Internet-distributed environment, where each host is assigned a 32-bit network address, there is a conversion problem between the IP address of the computer and the physical address. The work of ARP is to obtain the MAC address according to the target IP address before the host sends the frame, in order to ensure the smooth communication process.

The process is as follows:
(1) Each host establishes an ARP list in its own ARP buffer to store the correspondence between the IP address and the MAC address.
(2) When the source host needs to send a packet to the target host, it will first check whether its ARP list has the MAC address of the IP address. Sends the packet directly to the MAC address if it exists, and, if it does not exist, initiates an ARP request broadcast packet to the local network segment due to the corresponding MAC address of the target host. This ARP Request packet includes the IP address of the source host, the hardware address, and the IP address of the destination host.
(3) After receiving this ARP request from all the hosts on the network, the IP address in the packet is checked to see if it is consistent with its own IP addresses, and if it is different, the host will add the MAC address and IP address of the sending side to its own ARP list. If there is already information about the IP address in the ARP list, overwrite it, then send an ARP response packet to the source host, telling the other person that it is the MAC address it is looking for.
(4) After the source host receives this ARP response packet, it adds the IP address and MAC address of the destination host to its own ARP list, and uses this information to start the transmission of the data. If the source host has not received an ARP response package, it indicates that the ARP query failed.

Rarp is the opposite of how ARP works. The RARP emits the physical address to reverse parse and wants to return its corresponding IP address, including an IP address issued by the RARP server that can provide the required information. Rarp the process of obtaining an IP address is as follows:
First you need to know your IP address of the machine to send a request to a server on another machine, and wait for the server to respond, start not knowing the physical address of the server so broadcast. Once a request for an address is broadcast, it must uniquely identify its own hardware identity (such as the CPU serial number), which can be easily obtained by the executable program. After the source host receives a response message from the RARP server, it can use the resulting IP address to communicate.

What is a ping command

Ping (Packet internet Grope, Internet Packet Explorer) is a program used to test the amount of network connections. It uses the icmp,ping to send an ICMP (Internet control and message protocal, Internet Controlled message Protocol) to request a message to the destination and report whether the desired ICMP response was received.

ICMP is a sub-protocol of the TCP/IP protocol cluster that is used to pass control messages between IP hosts and routers. It is the command used to check whether the network is unobstructed or the speed of the network connection.
Because the machine on the network has a unique IP address, when sending a packet to the destination IP address (including the other's IP address and its own address and sequence number), the other party will return a packet of the same size (including both sides of the address), according to the returned packet can determine the existence of the target host, Can initially determine the target host operating system, and so on.

What are the basic HTTP processes

HTTP is an abbreviation for the Hyper Text Transfer Protocol (Hypertext Transfer Protocol), which is primarily responsible for communication between the server and the browser. HTTP sends the client browser's request to the server and returns the response's Web page content to the client browser by the server.

A complete HTTP process typically consists of the following steps:
(1) Open the HTTP connection. Because HTTP is a stateless protocol, each request needs to establish a new connection.

(2) Initialize the method request. Contains some types of method indicators, which describe what method to call and what parameters are required

(3) Set the HTTP request header. Contains the type of data to transfer and the length of the data

(4) Send the request. Writing a binary stream to the server

(5) Read request. Invokes the target Servlet program and accepts HTTP request data. If the request is the client's first request, a new instance of the server object needs to be created.

(6) Call method. Provides methods for invoking objects on the server side

(7) Initialize the response method. If the calling method has an exception, the customer will receive an error message; otherwise, the Send return type

(8) Set the HTTP response header. Setting the type and length of data to be sent in the response header

(9) Send a response. The server sends a binary stream to the client in response.

(10) Close the connection, and when the response is finished, the server must be disconnected to ensure that other requests are able to establish a connection to the server.

Network and Communication: Network Protocol (concept)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.