Home  >  Article  >  What are the layers of the tcp/ip reference model?

What are the layers of the tcp/ip reference model?

青灯夜游
青灯夜游Original
2020-11-25 14:01:16116981browse

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.

What are the layers of the tcp/ip reference model?

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.
What are the layers of the tcp/ip reference model?

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.

The core protocol of the network layer is the IP protocol (Internet Protocol). The IP protocol determines how to deliver the data packet based on its destination IP address. If the data packet cannot be sent directly to the destination host, then the IP protocol finds a suitable next hop router for it and delivers the data packet to the router for forwarding. This process is repeated several times, and the packet eventually reaches the destination host, or is discarded due to failure to send. It can be seen that the IP protocol uses a hop by hop method to determine the communication path.

Another important protocol in the network layer is the ICMP protocol (Internet Control Message Protocol). It is an important supplement to the IP protocol and is mainly used to detect network connections.


What are the layers of the tcp/ip reference model?

The 8-bit type field is used to distinguish the message type. It divides

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.

What are the layers of the tcp/ip reference model?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn