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.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
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:
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
Applications access files through system calls. For example, open 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."
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() …
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.
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.
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!