What is TCP/IP
Simply put, TCP/IP is a set of rules. Two computers to communicate with each other, there must be rules, a very common example is the sending of letters. Imagine, if the letter above the address and zip code and other information is casually written, then the destination of the postman received the letter, will be confused, do not know exactly where to send. Similarly, if the recipient is "XX", and you write the word is "yy", the other party is certainly not understand, so the two sides of the language should be interlinked.
Communication between computers, but also need rules, so TCP/IP appeared. TCP and IP are two protocols respectively, and TCP/IP generally refers to a protocol family. The protocol family consists of four layers, namely the link layer, the network layer, the transport layer and the application layer. Where TCP is the protocol of the Transport layer, IP is the protocol of the network layer.
The reason for layering, like the role of the MVC framework, is to make professional people do professional things. Remember the single principle of responsibility in the design pattern, which is actually the embodiment of this principle. Each layer only does what it is supposed to do and does it well, which is good for expansion and maintenance.
The actual transmission is a byte stream
Four-story Introduction
Next, let's give you a brief introduction to each layer.
link Layer : This is the closest to the hardware layer, also known as the "bottom." It mainly refers to our commonly known network card and network card driver, network card is the hardware, the driver is responsible for controlling the network card. The link layer is responsible for the actual data transfer work with the transmission medium (such as fiber). You can think of it as an abominable toll station on the freeway, with a toll station at the entrance and exit of each road, and there is an agreement between these toll stations, such as charging by distance. These toll stations are like network interfaces, while highways are like fiber optics.
Network layer : This layer is above the link layer, mainly responsible for the data reported in the network activities, such as where to go. This layer is like a signpost on a highway, and the road signs determine how you should go at each intersection. The network layer is precisely doing this thing, such as IP protocol, in fact, is to develop a set of rules, so that the data according to this set of rules can find the destination.
Transport Layer : This layer is already relatively close to my dick, it is responsible for end-to-end communication between applications, so it may be difficult to understand. This is more like a logistics scene, such as now LZ in Beijing, and in Shanghai bought a girlfriend to send over, then the process should be like this. First by the Shanghai Express brother took the LZ's girlfriend, and then handed to Beijing to send goods to the driver, then the LZ's girlfriend to Beijing will be handed to the logistics company's unified delivery office, ultimately by courier small brother responsible to send the girl to LZ hands. Please note that in this process, the lorry driver does not care where the goods are sent to, he just sent to Beijing, and finally the courier will need to send the goods to the specific consignee. This is similar to the network layer and the Transport layer, the network layer just send the datagram from one computer to another computer, specifically which process data, the network layer can no matter, this is the transport layer is responsible for. The end-to-end communication here, in fact, refers to port-to-port communication.
Application Layer : This layer and I wait for the cock silk already has the skin's kiss, can be described as more familiar. Like the HTTP protocol you use every day, it's a protocol to the application layer. HTTP defines various protocol headers, what requests the protocol header, the response protocol header, and the mess. What are these protocol headers for, since it's an application layer, of course, for applications. For example, in the response protocol header, there is the header of the text format, which defines how the browser should display the response information sent back by the Web server, such as xml,html or something else.
Summary: The IP layer is responsible for communication between hosts, and the transport layer is responsible for communication between processes
Reference Documentation:
First meeting with the TCP/IP protocol (i)
Introduction to the highest-largest link layer in TCP/IP (II.)
Introduction to TCP/IP protocol