Home>Article>Operation and Maintenance> What is the linux protocol stack?

What is the linux protocol stack?

WBOY
WBOY Original
2022-07-13 16:05:53 2330browse

In Linux, the protocol stack is a specific software implementation of the computer network protocol suite, which is the sum of the protocols at all layers in the network; a protocol in the protocol suite is usually designed for only one purpose, so Can make the design easier, the protocol stack reflects the process of file transfer in a network.

What is the linux protocol stack?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What is the protocol stack of Linux

Protocol stack (English: Protocol stack), also known as protocol stack, is a specific software implementation of the computer network protocol suite. A protocol in a protocol suite is usually designed for only one purpose, which makes design easier. Because each protocol module usually communicates with two other protocol modules above and below it, they can usually be thought of as layers in a protocol stack. The lowest level protocols always describe physical interaction with hardware. Each advanced level adds more features. User applications only handle the top-level protocols.

Explanation: The sum of all layers of protocols in the network reflects the process of file transfer in a network

Linux storage protocol stack introduction:

What is the linux protocol stack?

Data flow:
The application issues a write request through a system call. The ultimate goal is to write the data to the disk, and the

  1. file system is responsible for positioning This writes the location of the request and converts it into the blocks required by the block device, and then sends the request to the device.
  2. The memory plays the role of a disk cache in this process, isolating the upper and lower parts into two processes that run asynchronously. For the upper part, it is best to keep the data in the memory. method, because there is no way to predict whether it will be modified in the future. If the same location needs to be modified frequently, continuous data synchronization with the disk is not necessary. As for the second half, the data is synchronized from the page cache (Page Cache) to the disk, and the issued request is packaged into a request. A request contains a set of bios, and each bio contains the data pages that need to be synchronized.

Application layer

Applications access files through system calls. For example, open calls

system calls

The way for user applications to access and use various services provided by the kernel is through system calls.
The kernel provides a set of system call interfaces through which applications can access system hardware and operating system resources.
The application calls the system call interface->kernel->operates the hardware->returns to the kernel->application
The main ones related to the storage system are read, write, and open
“mmap() Map a block of length starting from the offset position of the file (specified by the file handle fd) into the memory area, thereby mapping a certain section of the file to the address space of the process, so that the program can access the memory by to access files."
"A typical example is to use /dev/mem to map some physical addresses that the MMU can access to application layer virtual addresses, so that certain physical addresses can be directly accessed at the application layer. Some simple driver development."

Virtual File System

By using a common set of APIs, Linux can support multiple file systems on multiple devices.
A file system is a mechanism for storing and organizing files and data on a storage device.
Linux supports multiple file systems

"The virtual file system shields the differences between different file systems by establishing an abstraction layer on various specific file systems. Through the virtual file system layered architecture ), when we operate files, we do not need to care about the details of the specific file system where the relevant files are located."
"It is the virtual file system that makes this kind of operation across different storage devices and different file systems possible. ”
The common APIs provided by VFS are:

mount(), umount() … open(),close() … mkdir() …

File system

I believe everyone is familiar with this layer of file system. At present, The default file system used by most Linux distributions is generally ext4. In addition, a new generation of btrfs is also about to emerge. No matter what kind of file system, it is created by a series of mkfs.xxx commands, such as:

mkfs.ext4 /dev/sda mkfs.btrfs /dev/sdb

The file system types supported by the kernel can be viewed through the contents of the fs directory of the kernel directory tree.

General block device layer

The role of this layer is that different hard drives will provide different IO interfaces. The kernel believes that this messy interface is not conducive to For management, these interfaces need to be abstracted to form a unified external interface. In this way, no matter what kind of hard disk or driver you have, externally speaking, there is no difference in the IO interfaces they provide, and they are all treated equally as block devices. .

So, if any modification is made at one level, it will directly affect all file systems, whether it is ext3, ext4 or other file systems. As long as some modification is made at this level, they will all be affected. Make an impact.

Hard drive

Common hard drive types include PATA, SATA and AHCI. In Linux systems, the driver modules provided for different hard drives are generally stored in the kernel directory tree drivers /ata, and for general-purpose hard disk drives, they may be compiled directly into the kernel and will not appear as modules. You can confirm this by viewing the /boot/config-xxx.xxx file.

Recommended learning:Linux video tutorial

The above is the detailed content of What is the linux protocol stack?. 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