Let's assume that there is no TCP or even no IP layer. Only the data link layer corresponding to the MAC, how far can the HTTP protocol run?
Is it possible to encapsulate HTTP directly in the Ethernet Frame? Of course, in the same Layer 2 broadcast domain, the MAC address is used to identify the other party, and then the HTTP data is sent and received through the network card interface function.
The question is coming, how to ensure that the data arrives at the other party without fail? Let the network card to ensure reliable transmission of data? The NIC only interprets the Ethernet frame header. The Ethernet header does not have any field for reliable transmission. The HTTP is a reliable mechanism for data transmission, such as sending a 1000-byte data. TCP is an important topic of CCNP collaboration .learning Wait for the other party to confirm the receipt, and then send it again, so that the data can be reliably transmitted.
Similarly, FTP, STMP, POP, and BGP are all about ensuring reliable data transmission. Do they have to implement these reliable mechanisms themselves? That is certain, that is to say, as long as there is an application, reliable transmission must be implemented by the application protocol! Is it very stupid? The reliable transport mechanism for all application protocols is the same implementation, and the code should be similar. If we encapsulate this reused code, the interface function API, let him implement reliable data transfer, and use an identifier to indicate this. Which application protocol is it feasible? feasible!!!
This is the highly abstracted creator of the great TCP/IP protocol: TCP! It encapsulates the reliable transport mechanism code into an interface function API, namely socket, and uses TCP Port to identify the application protocol of its service. The application protocol only needs to explain its own protocol and protocol data to complete the end-to-end session.
The second question: Now Ethernet + TCP + application protocol, how far can this package run? Is that a broadcast domain as large as it is? Yes, sir, how the demo can't escape the circle of the broadcast domain. The IP layer is to solve this problem. With the IP layer, the Internet can be made possible. An ad word: impossible is nothing! To know that IP is an abbreviation of Internet Protocol.
Then you may have to ask, I want the IP layer, do not want the TCP layer, can directly encapsulate the data in the IP layer? That's ok! Not only can, but a lot of protocols do the same, OSPF, EIGRP, GRE, ESP, AH and other protocols are doing this, if they want to ensure reliable transmission, they use code to achieve, of course.
The problem is that IP only uses one byte to represent the protocol number. In theory, it can only identify 255 upper-layer protocols. The resources are very tight, and they are all dominated by well-known big-name protocols, such as TCP, ICMP, IGMP, including the above mentioned. Where are you on the wheel! In order to solve this resource shortage problem, there is another little thing that is not used to identify the application protocol: UDP!
In fact, in addition to providing a port to distinguish the application protocol, UDP does not do anything else, but the port number occupies 2 bytes. In theory, it can resolve 65,535 application protocols. This can make its merits complete, precisely because Unlike TCP, it is a completely stateless protocol, so it is also favored by some applications. Because UDP is stateless, IP is stateless, and all state of the session is controlled by the application protocol. This is also an option.
In addition, UDP-based applications can achieve reliable transmission, such as TFTP, then TFTP can achieve reliable transmission by itself; it can also send data to UDP, let it send out, no need to confirm the sent data, students Will ask: What kind of application is this? Voice traffic is lost when you lose it, and the other party can't hear it.
In summary, TCP provides a reliable transport mechanism, stateful; UDP provides a more space to identify the upper layer protocol, stateless.
1. Without the network layer and the transport layer, the functions of routing and reliable transmission must be implemented by other layers, which makes the protocol of some layers too complicated.
2. The transport layer below is the communication between the hosts. Above the transport layer is the communication between the application processes. In addition to reliable transmission, the transport layer also needs to handle signal multiplexing and demultiplexing for different applications.