Introduction
Recently, LZ had a little time, so he began to read TCP/IP books. At the beginning, it was boring. Now it's easy to get started, so I kept a record in a hurry for fear that I would forget it in a twinkling of an eye. However, the principle of computer systems is a pity. Recently, I have not had time to check whether TCP is more important or more important at this stage.
Okay. Let's record it.
What is TCP/IP?
To discuss TCP/IP, you must know what it is. This is the premise for getting deeper into something, and TCP/IP is no exception.
LZ uses his own words to answer this question. What is TCP/IP?
Simply put, TCP/IP is a set of rules. To communicate with each other, two computers must have rules. A very common example is sending letters. Imagine that if the address, zip code, and other information on the mail are written at will, the destination postman will be confused when receiving the mail and do not know where to deliver it. Similarly, if the recipient is "buy credit" and you write the word "split mud stains", the other party will certainly not understand it, so the languages of both parties should also be the same.
Communication between computers also requires rules, so TCP/IP appears. TCP/IP and IP are two Protocols respectively, while TCP/IP generally refers to one protocol family. The protocol family consists of four layers: link layer, network layer, transmission layer, and application layer. TCP is the transport layer protocol, and IP is the network layer protocol.
The reason for layering is similar to the role of the MVC framework, in order to let professional people do professional things. Do you still remember the single Responsibility Principle in the design model? This is actually the embodiment of this principle. Each layer only does what you should do and completes it well, which is conducive to expansion and maintenance.
Layer-4 Introduction
Next, LZ will give you a brief introduction to each layer.
Link Layer: This layer is the closest to the hardware layer, also known as "bottom layer ". It is commonly known as the nic and nic driver. The NIC is the hardware, and the driver is responsible for controlling the NIC. The link layer works with transmission media (such as optical fiber cables) to complete actual data transmission. You can think of it as a terrible toll station on a highway. Each highway has a toll station at its entrance and exit, and there is an agreement between these toll stations, such as charging by distance. These toll stations are like network interfaces, while roads are like optical fibers.
Network Layer: Over the link layer, this layer is mainly responsible for the activities of data packets in the network, such as where to go. This layer is like a road sign on a highway. A road sign determines how you go to an intersection. The network layer is just doing this. For example, the IP protocol is actually developing a set of rules so that data can find the destination according to these rules.
Transport Layer: This layer is close to the other layer. It is responsible for end-to-end communication between applications, which may be hard to understand. This is similar to a logistics scenario. For example, if LZ is now in Beijing and has bought a girlfriend in Shanghai to deliver it, the process should be like this. First, the courier from Shanghai took LZ's girlfriend and handed it to the driver who sent the goods to Beijing. Then the LZ's girlfriend will be handed over to the logistics company's uniform shipping place after arriving in Beijing, finally, the courier brother is responsible for sending his girlfriend to LZ. Please note that in this process, the freight car driver does not care about where the goods are delivered. He only sends the goods to Beijing, and the courier needs to deliver the goods to the specific consignee. This is similar to the relationship between the network layer and the transport layer. The network layer only sends data from one computer to another. The Network Layer does not care which process the data belongs, this is what the transport layer is responsible. The end-to-end communication refers to the communication between the port and the port.
Application Layer: This layer is already familiar with the skin of some coders. For example, the HTTP protocol you use every day is a protocol at the application layer. HTTP defines various protocol headers, request protocol headers, and response protocol headers. What are these protocol headers? Since it is the application layer, it is for the application. For example, the response protocol header contains the text format header, which defines how the browser should display the response information sent back from the Web server, such as XML, HTML, and other things.
4-layer Summary
In this case, the TCP/IP protocol family is quite understandable, and LZ will use the above logistics example to illustrate it.
The link layer is the driver responsible for transporting the LZ girlfriend. He is actually responsible for transportation (that is, the actual data transmission ). The network layer is the road sign, which guides drivers on the highway (that is, activities on the network) and allows drivers to reach their destination correctly. The transport layer is the courier, responsible for receiving messages between the specific deliveryman and the receiver (that is, the sending port and receiving port. The application layer is like the instructions of LZ's girlfriend. This is what happens between LZ and the seller (that is, between applications.
Highlights
This article ends here. After all, there are not many content, so it is fine. Just to better illustrate the content of this article, LZ sacrificed his own image, but hoped that his daughter-in-law would not see this article. LZ vowed that all examples in this article are purely fictitious.
To be continued!
First meeting with TCP/IP protocol (1)