What are the layers of the tcp/ip reference model?
The tcp/ip reference model is divided into 4 layers, namely: 1. Data link layer, which implements the network driver of the network card interface to handle the transmission of data on physical media; 2. Network layer, which implements Routing and forwarding of data packets; 3. Transport layer, which provides end-to-end communication for applications on two hosts; 4. Application layer, which is responsible for processing application logic.
The TCP/IP protocol suite is a four-layer protocol system. From bottom to top, they are the data link layer, network layer, transport layer and application layer. Each layer completes different
functions and is implemented through several protocols. The upper layer protocol uses the services provided by the lower layer protocol.
Data link layer (network interface layer)
The data link layer implements the network card interface Network driver to handle the transmission of data over physical media (such as Ethernet, Token Ring, etc.).
Two commonly used protocols in the data link layer are the ARP protocol (Address Resolve Protocol, address resolution protocol) and the RARP protocol (ReverseAddress Resolve Protocol, reverse address resolution protocol). They convert IP addresses to and from the machine's physical address (usually a MAC address, which is used by Ethernet, Token Ring, and 802.11 wireless networks).
The network layer uses an IP address to address a machine, while the data link layer uses a physical address to address a machine. Therefore, the network layer must first convert the IP address of the target machine into its physical address before it can be used. The services provided by the data link layer, This is the purpose of the ARP protocol.
The RARP protocol is only used by certain diskless workstations on the network. Due to the lack of storage devices, diskless workstations cannot remember their own IP addresses, but they can use the physical address on the network card to query the network manager (server or network management software) for their own IP address. The network administrator running the RARP service usually maintains a mapping of physical addresses to IP addresses for all machines on the network.
Network layer
The network layer implements routing and forwarding of data packets. WAN (Wide Area Network, Wide Area Network) usually uses many hierarchical routers to connect dispersed hosts or LAN (Local Area Network, Local Area Network). Therefore, the two communicating hosts are generally not directly connected, but Connected through multiple intermediate nodes (routers). The task of the network layer is to select these intermediate nodes to determine the communication path between the two hosts. At the same time, the network layer hides the details of the network topology connection from the upper layer protocol, so that from the perspective of the transport layer and network applications, the two parties in communication are directly connected.
ICMP messages into two major categories
Error messages. This type of message is mainly used to respond to network errors, such as the target is unreachable (type value is 3) and redirection (type value is 5);
query message, this type of message is used to query network information. For example, the ping program uses ICMP messages to check whether the target is reachable (type value is 8). Some ICMP messages also use an 8-bit code field to further subdivide different conditions. For example, a redirect message uses a code value of 0 to indicate network redirection, and a code value of 1 to indicate host redirection.
ICMP messages use a 16-bit checksum field to perform a Cyclic Redundancy Check (CRC) on the entire message (including header and content) to check whether the message is damaged during transmission. Different ICMP message types have different body contents.
Transport layer
The transport layer provides end-to-end communication for applications on two hosts . Different from the hop-by-hop communication method used by the network layer, the transport layer only cares about the origin and destination of the communication and does not care about the transfer process of the data packet.
The vertical solid arrows represent the physical communication between the layers of the TCP/IP protocol suite (data packets are indeed transmitted along these lines), while the horizontal dashed arrows represent logical communication lines. The diagram also describes how different physical networks are connected. It can be seen that the
data link layer (driver) encapsulates the electrical details of the physical network; the network layer encapsulates the details of the network connection; the transport layer encapsulates an end-to-end logical communication link for the application. It is responsible for sending and receiving data, link timeout reconnection, etc.
Transport layer protocol: TCP protocol, UDP protocol.
TCP protocol (Transmission Control Protocol, Transmission Control Protocol) provides reliable, connection-oriented and stream-based services for the application layer. The TCP protocol uses timeout retransmission, data acknowledgment, etc. to ensure that data packets are sent correctly to the destination, so the TCP service is reliable. Both parties communicating using the TCP protocol must first establish a TCP connection and maintain some necessary data structures for the connection in the kernel, such as connection status, read and write buffers, and many timers. When the communication ends, both parties must close the connection to release this kernel data. TCP services are stream-based. Stream-based data has no boundary (length) limit and flows continuously from one end of the communication to the other. The sender can write data into the data stream byte by byte, and the receiver can read them out byte by byte.
UDP protocol (User Datagram Protocol) is completely opposite to TCP protocol. It provides unreliable, connectionless and datagram-based services for the application layer. "Unreliable" means that the UDP protocol cannot guarantee that the data is correctly transmitted from the sender to the destination. If the data is lost midway, or the destination finds data errors through data verification and discards it, the UDP protocol simply notifies the application of the failure to send. Therefore, applications that use the UDP protocol usually have to handle logic such as data confirmation, timeout retransmission, etc. by themselves. The UDP protocol is connectionless, that is, the communicating parties do not maintain a long-term connection, so the application must clearly specify the address of the receiving end (IP address and other information) every time it sends data. Datagram-based services are relative to stream-based services. Each UDP datagram has a length, and the receiving end must read all its contents at once with this length as the minimum unit, otherwise the data will be truncated.
Application layer
The application layer is responsible for processing the logic of the application.
The data link layer, network layer and transport layer are responsible for handling the details of network communication. This part must be both stable and efficient, so they are all implemented in the kernel space. The application layer is implemented in user space because it is responsible for handling many logics, such as file transfer, name query, and network management. If the application layer is also implemented in the kernel, it will make the kernel very large. Of course, there are also a few server programs that are implemented in the kernel, so that the code does not need to switch back and forth between user space and kernel space (mainly data copying), which greatly improves work efficiency. However, this kind of code is complex to implement, not flexible enough, and not easy to transplant.
Ping is an application, not a protocol. As mentioned earlier, it uses ICMP messages to detect network connections and is an essential tool for debugging the network environment.
The telnet protocol is a remote login protocol that allows us to complete remote tasks locally.
OSPF (Open Shortest Path First, Open Shortest Path First) protocol is a dynamic routing update protocol used for communication between routers to inform each other of their routing information.
DNS (Domain Name Service, Domain Name Service) protocol provides conversion of machine domain names to IP addresses.
Application layer protocols (or programs) may skip the transport layer and directly use services provided by the network layer, such as ping programs and OSPF protocols. Application layer protocols (or programs) can usually use both TCP services and UDP services, such as the DNS protocol. We can view all well-known application layer protocols and which transport layer services they can use through the /etc/services file.
The idea behind the five-layer protocol: the upper layer shields the details of the lower layer and only uses the services it provides. High cohesion and low coupling, each layer focuses on its function, and there is little dependence on the relationship between the layers.
Data packets have different formats at each layer. They are called segments, datagrams, and frames from top to bottom. The data is passed down from the application layer through the protocol stack, and each layer adds the corresponding The header of the layer protocol is finally encapsulated into a frame and sent to the transmission medium. When it reaches the router or destination host, the header is stripped off and delivered to the upper layer requester. This process is called encapsulation, transmission, separation, and decentralization.
The above is the detailed content of What are the layers of the tcp/ip reference model?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The full name of tcp/ip is "Transmission Control Protocol/Internet Protocol", which means "Transmission Control Protocol/Internet Protocol" in Chinese. The TCP/IP protocol not only refers to the two protocols TCP and IP, but also refers to a protocol cluster composed of FTP, SMTP, TCP, UDP, IP and other protocols, just because in the TCP/IP protocol, the TCP protocol and the IP protocol The most representative, so it is called TCP/IP protocol.

How to use PHP and TCP/IP protocol for data communication Introduction: In the modern Internet era, data communication is a very important aspect. Whether it is communication between a client and a server or communication between different servers, the TCP/IP protocol has always been one of the most commonly used communication protocols. This article will introduce how to use PHP language and TCP/IP protocol for data communication, and provide relevant code examples. 1. Introduction to TCP/IP protocol TCP/IP protocol is the basis of the Internet protocol cluster. It defines

Differences: 1. TCP/IP is a protocol cluster, while OSI is a model; 2. TCP/IP is a five-layer structure, while OSI is a seven-layer structure; 3. The third layer of TCP/IP only supports the IP protocol, and OSI Supports all network layer protocols. Connection: 1. OSI introduces the concepts of services, interfaces, protocols, and layers, while TCP/IP draws on the concepts of OSI; 2. OSI has models first, then protocols, standards first, and then practices, while TCP/IP IP first has protocols and applications and then proposes a model, which is the reference OSI model.

TCP and IP are two different protocols in the Internet: 1. TCP is a transport layer protocol, while IP is a network layer protocol; 2. TCP provides functions such as segmentation, sorting, confirmation and retransmission of data packets. , and the IP protocol is responsible for providing source and destination addresses for data packets; 3. TCP is a connection-oriented protocol, while the IP protocol is connectionless; 4. TCP also provides flow control and congestion control.

Application layer protocols include: 1. Telnet, which allows users on one machine to log in to a remote machine and perform work; 2. FTP, which provides a method to move files from one machine to another; 3. SMTP is a protocol that provides email transmission; 4. SNMP is a standard protocol used to manage network nodes in IP networks; 5. DNS is mainly used to "translate" familiar web addresses into An IP address that a computer can understand; 6. HTTP is a request-response protocol used to obtain the home page on the WWW.

The Go language is a growing programming language that is designed to be ideal for implementing network applications with high performance, reliability, and concurrency. When using Go to write network programs related to the TCP/IP protocol, we are prone to encounter various errors, and some common TCP/IP errors will also bring certain difficulties to the debugging of the program. This article will focus on the topic of how to solve common TCP/IP errors in the Go language. 1. EOF error EOF (EndOfFile) error usually

IP belongs to the "network layer" protocol of computer network architecture. IP refers to the Internet Interconnection Protocol, which is a network layer protocol in the TCP/IP system. It can provide information of various protocols to the transport layer, such as TCP, UDP, etc.; IP information packets can be placed in the link layer through Various technologies such as Ethernet and Token Ring network are used for transmission.

The "TCP/IP" protocol is the most basic protocol on the Internet. TCP/IP (Transmission Control Protocol/Internet Protocol) is a network communication protocol that standardizes all communication devices on the network, especially the format and transmission method of data exchange between one host and another host; TCP/IP protocol It is the core and most basic protocol of the Internet. Strictly speaking, it is a four-layer architecture, including the application layer, transport layer, network layer and data link layer.