Recently, I worked on a development project involving network programming. The development process went smoothly, but after completing the task, I still felt some confusion. This was mainly due to my unfamiliarity with network protocols and my lack of clarity on some concepts. Later, I spent some time understanding these network protocols, and I now have a preliminary understanding of the TCP/IP network protocol. I would like to summarize my understanding of network protocols here to reinforce my impressions.
When two computers need to communicate, they must adhere to common rules, just as two people must use a common language to communicate. A person who only understands English cannot communicate with someone who only understands Chinese because they lack a common language (rules). The rules that two computers follow to communicate are called network protocols.
So who establishes these network protocols?
The International Organization for Standardization (ISO) defines the basic framework for network protocols, known as the OSI model. To establish communication rules, there are many considerations, such as how computer A finds computer B, whether computer A needs feedback from computer B when sending information, and what the format of the data sent from computer A to computer B is. There are too many and too varied details, so the OSI model categorizes these communication standards into layers, with each layer addressing a specific category of issues, making the standardization process less complex. The seven-layer standard model established by the OSI model consists of: Application Layer, Presentation Layer, Session Layer, Transport Layer, Network Layer, Data Link Layer, and Physical Layer.
Although the International Organization for Standardization established such a model for network protocols, the actual network protocol used for internet communication is the TCP/IP network protocol.
TCP/IP is a suite of protocols that is also categorized into layers. It has four layers: Application Layer, Transport Layer, Internet Layer, and Network Interface Layer. So what is the difference between the TCP/IP protocol and the OSI model? The OSI network protocol model is a reference model, while the TCP/IP protocol is the de facto standard. The TCP/IP protocol references the OSI model but does not strictly divide the standards into the seven layers prescribed by the OSI; it only divides them into four layers, which I personally think simplifies things. When there are too many layers, it becomes difficult to distinguish which protocol belongs to which layer. The TCP/IP protocol and the OSI model do not conflict; the application layer protocols in TCP/IP correspond to the application layer, presentation layer, and session layer in the OSI model. It’s like having a Ministry of Industry and a Ministry of Information Industry in the past, but now, after implementing a large ministry system, there is only one Ministry of Industry and Information Technology, yet this ministry still has to handle as many tasks as the previous two departments, essentially making little difference. There are two important protocols in TCP/IP: the TCP protocol at the transport layer and the IP protocol at the Internet layer, which is why these two protocols are used to represent the entire protocol suite. When we refer to the TCP/IP protocol, we are referring to the entire protocol suite.
The TCP/IP protocol is divided into four layers, but we do not need to understand all the protocols at each layer; I think focusing on the protocols at the application layer and transport layer is sufficient. For example, when sending mail, computer A is concerned about what format and content to write to computer B (application layer content), and whether to send it as a registered letter or a regular letter (transport layer content). However, A does not need to worry about the route taken during the delivery process or how the postman delivers the letter to B (Internet layer, Network Interface layer).
First, let’s talk about the transport layer. There are multiple protocols at the transport layer, but the most important ones are TCP and UDP. The difference between the two is that the TCP protocol requires feedback from the receiver, while the UDP protocol does not. TCP is like a registered letter; when computer A sends information to computer B, it needs feedback from B to know whether B has received the information. UDP is like a regular letter; when computer A sends information to computer B, B does not send feedback to A. After A sends the information, it does not know whether B has received it. Therefore, TCP transmission is more reliable than UDP transmission, but TCP is less efficient than UDP. As for which transmission method to choose during delivery, it depends on the specific situation. In unreliable network transmission scenarios, TCP is generally chosen. In situations where efficiency is prioritized or transmission errors are not a concern, UDP can be chosen to improve transmission speed.
There are many protocols at the application layer, each representing a type of service. The HTTP protocol is for World Wide Web services, the FTP protocol is for file transfer services, POP3 is for email services, and the SOAP protocol is for web service services.
During my understanding of the TCP/IP protocol, I encountered three confusions.
1. What is a socket?
I have heard of socket programming before, and some refer to it as socket programming. When I searched for information about sockets, I found some saying that a socket refers to a connection, while others say a socket refers to an endpoint. Using a phone call as an analogy, if phone A and phone B are in conversation, does the socket refer to the connection line between A and B or the phones (endpoints)?
My current understanding is that a socket is an endpoint in a connection; during a communication (connection), both endpoints A and B will have a socket. One socket corresponds to one connection.
2. Is the HTTP protocol part of the application layer or the transport layer?
The HTTP (Hypertext Transfer Protocol) sounds like it could be a transport layer protocol. However, it is well known that HTTP, like FTP, is an application layer protocol. I was puzzled at first; since it is an application layer protocol, why does it have such a misleading name? When I was not yet familiar with the TCP/IP protocol, this could easily lead to misunderstanding and confusion. Later, I found this statement on Wikipedia:
HTTP Translation Issues in China
HTTP is translated as “Hypertext Transfer Protocol” in mainland China because “transfer” implies “transmission” in Chinese. However, according to the paper by Dr. Roy Fielding, one of the authors of HTTP [1] (section 6.5.3), he specifically emphasizes that “transfer” refers to “(the transfer of representation state)” and not “transport.” Thus, its Chinese translation “Hypertext Transfer Protocol” reflects this misunderstanding. A more accurate translation should be “Hypertext Transfer Protocol.”
This statement resolved my confusion. Therefore, the HTTP protocol is indeed an application layer protocol.
3. Can SOAP be transmitted using the HTTP protocol?
In the process of understanding the SOAP protocol, I saw descriptions stating that SOAP can be transmitted via TCP, UDP, and HTTP protocols. This description is also confusing. At first glance, it seems that HTTP is being listed alongside TCP and UDP. Does this mean that HTTP is still considered a transport layer protocol? Coupled with the translation issue of HTTP, which sounds like a transport layer, beginners might find it perplexing.
In fact, HTTP is an application layer protocol, and this is beyond doubt. However, a new question arises: since both SOAP and HTTP are application layer protocols, how can SOAP be transmitted using the HTTP protocol? Can application layer protocols transmit other application layer protocols?
I researched and found that SOAP serializes information in XML format and then packages it using the HTTP protocol for transmission, while the actual transmission occurs over TCP or UDP. To make it easier to understand, let’s use an analogy. TCP and UDP are like roads; let’s consider TCP as a regular road and UDP as a highway. SOAP and HTTP are both vehicles. Thus, SOAP and HTTP can travel on TCP and UDP. When we say that SOAP can be transmitted via HTTP, we mean that SOAP is like a small car and HTTP is like a truck carrying the car. The information from SOAP is loaded into HTTP and then transported, but the roads taken are still TCP or UDP.
So, saying that SOAP can be transmitted via the HTTP protocol is not entirely accurate; a more accurate statement would be: SOAP information can be packaged using the HTTP protocol and transmitted over TCP or UDP.

-
From: Dana丶Li – Blog Garden
-
Link:
http://www.cnblogs.com/visec479/archive/2014/07/28/3872486.html
-
Published by Programmer Community Reading, please contact the author for authorization to reprint.

↙ Click “Read the Original” to join
『Zhongshu』