CN106713462A - Network data packet processing method and device - Google Patents
Network data packet processing method and device Download PDFInfo
- Publication number
- CN106713462A CN106713462A CN201611220118.0A CN201611220118A CN106713462A CN 106713462 A CN106713462 A CN 106713462A CN 201611220118 A CN201611220118 A CN 201611220118A CN 106713462 A CN106713462 A CN 106713462A
- Authority
- CN
- China
- Prior art keywords
- data
- network
- packet processing
- kernel state
- data packet
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims description 20
- 238000012545 processing Methods 0.000 claims abstract description 65
- 238000013507 mapping Methods 0.000 claims abstract description 17
- 238000006243 chemical reaction Methods 0.000 claims abstract description 5
- 230000003139 buffering effect Effects 0.000 claims 8
- 238000013481 data capture Methods 0.000 claims 2
- 238000000034 method Methods 0.000 abstract description 48
- 238000010586 diagram Methods 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000005856 abnormality Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000010076 replication Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/30—Definitions, standards or architectural aspects of layered protocol stacks
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本申请公开了一种网络数据包处理方法和装置,该方法包括:在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系;从所述网络设备的缓冲区中获取数据;将获取的数据从内核态直接转换成用户态;利用CPU对所述数据进行处理,该装置包括:映射关系建立单元,用于在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系;数据获取单元,用于从所述网络设备的缓冲区中获取数据;数据转换单元,用于将获取的数据从内核态直接转换成用户态;数据处理单元,用于利用CPU对所述数据进行处理。上述方法和装置能够减少每个数据包处理占用的系统资源和时间,提高网络数据包处理性能。
The present application discloses a method and device for processing network data packets. The method includes: in the driver of the kernel state, establishing a mapping relationship between the memory space of the user state and the buffer area of the network device; data; the acquired data is directly converted from the kernel state to the user state; the CPU is used to process the data, and the device includes: a mapping relationship establishment unit, which is used in the driver of the kernel state to provide user state memory space and network equipment The buffer to establish a mapping relationship; the data acquisition unit is used to obtain data from the buffer of the network device; the data conversion unit is used to directly convert the acquired data from the kernel state to the user state; the data processing unit is used for The data is processed by the CPU. The above method and device can reduce system resources and time occupied by each data packet processing, and improve network data packet processing performance.
Description
技术领域technical field
本发明属于数据处理技术领域,特别是涉及一种网络数据包处理方法和装置。The invention belongs to the technical field of data processing, in particular to a method and device for processing network data packets.
背景技术Background technique
随着网络通信技术的发展,网络带宽迅速提高,1Gbit、10Gbit网络逐渐普及,40Gbit网络在电信运营商、大型企业级骨干网络中大规模应用。网络流量的指数级增长,对防火墙、IDS/IPS、应用网关等网络数据包分析处理类网络产品的性能提出了新的挑战。传统的网络数据包处理方法在高速网络环境下面临着丢包率高、延时大和系统负载高等问题,无法满足高速网络环境下的网络数据包实时处理的要求。With the development of network communication technology, network bandwidth increases rapidly, 1Gbit and 10Gbit networks are gradually popularized, and 40Gbit networks are widely used in telecom operators and large-scale enterprise-level backbone networks. The exponential growth of network traffic poses new challenges to the performance of network data packet analysis and processing network products such as firewalls, IDS/IPS, and application gateways. Traditional network data packet processing methods face problems such as high packet loss rate, large delay, and high system load in high-speed network environments, and cannot meet the requirements of real-time processing of network data packets in high-speed network environments.
发明内容Contents of the invention
为解决上述问题,本发明提供了一种网络数据包处理方法和装置,能够减少每个数据包处理占用的系统资源和时间,提高网络数据包处理性能。In order to solve the above problems, the present invention provides a network data packet processing method and device, which can reduce system resources and time occupied by each data packet processing, and improve network data packet processing performance.
本发明提供的一种网络数据包处理方法,包括:A kind of network packet processing method provided by the present invention comprises:
在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系;In the kernel mode driver, establish a mapping relationship between the user mode memory space and the buffer of the network device;
从所述网络设备的缓冲区中获取数据;Obtain data from the buffer of the network device;
将获取的数据从内核态直接转换成用户态;Convert the acquired data directly from the kernel state to the user state;
利用CPU对所述数据进行处理。The data is processed by the CPU.
优选的,在上述网络数据包处理方法中,所述从所述网络设备的缓冲区中获取数据为:Preferably, in the above method for processing network data packets, the acquisition of data from the buffer of the network device is:
利用所述轮询线程从所述网络设备的缓冲区中获取数据。Using the polling thread to acquire data from the buffer of the network device.
优选的,在上述网络数据包处理方法中,在所述利用所述轮询线程从所述网络设备的缓冲区中获取数据之前,还包括:Preferably, in the above method for processing network data packets, before using the polling thread to obtain data from the buffer of the network device, it further includes:
将每个所述轮询线程绑定至对应的一个CPU上。Bind each polling thread to a corresponding CPU.
优选的,在上述网络数据包处理方法中,所述在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系之前,还包括:Preferably, in the above-mentioned method for processing network data packets, in the driver of the kernel state, before establishing a mapping relationship between the user state memory space and the buffer of the network device, it also includes:
将设备驱动拆分为所述内核态的驱动和所述用户态内存空间。The device driver is split into the driver of the kernel state and the memory space of the user state.
本发明提供的一种网络数据包处理装置,包括:A network data packet processing device provided by the present invention includes:
映射关系建立单元,用于在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系;A mapping relationship establishment unit is used to establish a mapping relationship between the user mode memory space and the buffer of the network device in the driver of the kernel mode;
数据获取单元,用于从所述网络设备的缓冲区中获取数据;a data acquisition unit, configured to acquire data from the buffer of the network device;
数据转换单元,用于将获取的数据从内核态直接转换成用户态;The data conversion unit is used to directly convert the obtained data from the kernel state to the user state;
数据处理单元,用于利用CPU对所述数据进行处理。The data processing unit is configured to process the data by using the CPU.
优选的,在上述网络数据包处理装置中,所述数据获取单元具体用于:Preferably, in the above-mentioned device for processing network data packets, the data acquisition unit is specifically used for:
利用所述轮询线程从所述网络设备的缓冲区中获取数据。Using the polling thread to acquire data from the buffer of the network device.
优选的,在上述网络数据包处理装置中,还包括:Preferably, in the above-mentioned network data packet processing device, it also includes:
绑定单元,用于将每个所述轮询线程绑定至对应的一个CPU上。The binding unit is used to bind each polling thread to a corresponding CPU.
优选的,在上述网络数据包处理装置中,还包括:Preferably, in the above-mentioned network data packet processing device, it also includes:
拆分单元,用于将设备驱动拆分为所述内核态的驱动和所述用户态内存空间。The splitting unit is configured to split the device driver into the kernel-mode driver and the user-mode memory space.
通过上述描述可知,本发明提供的上述网络数据包处理方法和装置,由于包括:在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系;从所述网络设备的缓冲区中获取数据;将获取的数据从内核态直接转换成用户态;利用CPU对所述数据进行处理。该方法和装置避免了核心态到用户态的拷贝过程,可以简化协议层处理过程,屏蔽socket层的协议处理,因此能够减少每个数据包处理占用的系统资源和时间,提高网络数据包处理性能。It can be seen from the above description that the above-mentioned network data packet processing method and device provided by the present invention include: in the driver of the kernel state, establishing a mapping relationship between the memory space of the user state and the buffer area of the network device; Obtain data in the area; directly convert the acquired data from the kernel state to the user state; use the CPU to process the data. The method and device avoid the copying process from the core state to the user state, can simplify the protocol layer processing process, and shield the protocol processing of the socket layer, so can reduce system resources and time occupied by each data packet processing, and improve network data packet processing performance .
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only It is an embodiment of the present invention, and those skilled in the art can also obtain other drawings according to the provided drawings without creative work.
图1为本申请实施例提供的第一种网络数据包处理方法的示意图;FIG. 1 is a schematic diagram of a first network packet processing method provided by an embodiment of the present application;
图2为本申请实施例提供的第一种网络数据包处理装置的示意图。FIG. 2 is a schematic diagram of a first network data packet processing device provided by an embodiment of the present application.
具体实施方式detailed description
本发明的核心思想在于提供一种网络数据包处理方法和装置,能够减少每个数据包处理占用的系统资源和时间,提高网络数据包处理性能。The core idea of the present invention is to provide a network data packet processing method and device, which can reduce system resources and time occupied by each data packet processing, and improve network data packet processing performance.
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
本申请实施例提供的第一种网络数据包处理方法如图1所示,图1为本申请实施例提供的第一种网络数据包处理方法的示意图。该方法包括如下步骤:The first network data packet processing method provided in the embodiment of the present application is shown in FIG. 1 , and FIG. 1 is a schematic diagram of the first network data packet processing method provided in the embodiment of the present application. The method comprises the steps of:
S1:在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系;S1: In the kernel mode driver, establish a mapping relationship between the user mode memory space and the buffer of the network device;
需要说明的是,网络协议栈在处理网络数据时,不再进行多次的数据复制,而是将硬件中的数据直接拷贝到用户态,避免核心态到用户态的拷贝过程,这样做可以简化协议层处理过程,屏蔽socket层的协议处理。It should be noted that when the network protocol stack processes network data, it no longer performs multiple data copies, but directly copies the data in the hardware to the user state, avoiding the copy process from the core state to the user state, which can simplify The protocol layer processing process shields the protocol processing of the socket layer.
S2:从所述网络设备的缓冲区中获取数据;S2: Obtain data from the buffer of the network device;
在该步骤中,可以采用中断或轮询等方式来获取,此处并不限制。In this step, methods such as interrupt or polling may be used to acquire, which is not limited here.
S3:将获取的数据从内核态直接转换成用户态;S3: Convert the acquired data directly from the kernel state to the user state;
需要说明的是,现有技术中的内核协议栈的实现方式中,数据从到达网卡的物理设备开始,需要经历Firmware-Device Driver-Ethernet-IP-TCP/UDP-Sockets-SystemCall Interface多个过程,在这些步骤中都会涉及数据在内存中直接移动或者索引移动,还要涉及从内核态到用户态的转换,带来不必要的开销,而利用该步骤,将硬件中的数据直接拷贝到用户态,就能够解决此问题。It should be noted that, in the implementation of the kernel protocol stack in the prior art, data needs to go through multiple processes of Firmware-Device Driver-Ethernet-IP-TCP/UDP-Sockets-SystemCall Interface starting from the physical device arriving at the network card, These steps will involve direct movement of data in memory or index movement, as well as conversion from kernel mode to user mode, which will bring unnecessary overhead. Using this step, the data in the hardware will be directly copied to the user mode. , this problem can be solved.
S4:利用CPU对所述数据进行处理。S4: Using the CPU to process the data.
需要说明的是,上述方法通过改写Linux内核网络协议栈的方式对网络数据包的处理过程进行优化,实现提高网络数据包处理性能的目的,在实现处理线程时,避免在处理过程中使用系统调用,减少进入系统调用的开销。It should be noted that the above method optimizes the processing process of network data packets by rewriting the Linux kernel network protocol stack to achieve the purpose of improving the performance of network data packet processing. When implementing processing threads, avoid using system calls in the processing process , to reduce the overhead of entering system calls.
通过上述描述可知,本申请实施例提供的上述第一种网络数据包处理方法,由于包括:在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系;从所述网络设备的缓冲区中获取数据;将获取的数据从内核态直接转换成用户态;利用CPU对所述数据进行处理。该方法避免了核心态到用户态的拷贝过程,可以简化协议层处理过程,屏蔽socket层的协议处理,因此能够减少每个数据包处理占用的系统资源和时间,提高网络数据包处理性能。It can be seen from the above description that the above-mentioned first network data packet processing method provided by the embodiment of the present application includes: in the driver of the kernel state, establishing a mapping relationship between the memory space of the user state and the buffer zone of the network device; Obtain data from the buffer of the device; directly convert the obtained data from the kernel state to the user state; use the CPU to process the data. The method avoids the copying process from the core state to the user state, can simplify the protocol layer processing process, and shield the socket layer protocol processing, so it can reduce the system resources and time occupied by each data packet processing, and improve the network data packet processing performance.
本申请实施例提供的第二种网络数据包处理方法,是在上述第一种网络数据包处理方法的基础上,还包括如下技术特征:The second network data packet processing method provided in the embodiment of the present application is based on the above-mentioned first network data packet processing method, and also includes the following technical features:
所述从所述网络设备的缓冲区中获取数据为:The data obtained from the buffer of the network device is:
利用所述轮询线程从所述网络设备的缓冲区中获取数据。Using the polling thread to acquire data from the buffer of the network device.
需要说明的是,现有技术中的驱动实现方式,大量的采用中断的方式来通知系统数据的变动,当程序中有系统调用语句,程序执行到系统调用时,首先使用软中断等类似指令,保存现场,去进行系统调用,在内核态执行,然后恢复现场,每个进程都会有两个栈,一个内核态栈和一个用户态栈。当中断执行时就会由用户态栈,转向内核态栈。系统调用时需要进行栈的切换。而且内核代码对用户不信任,需要进行额外的检查。系统调用的返回过程有很多额外工作,比如检查是否需要调度等。但随着计算机技术的不断发展,中断资源越来越成为系统性能的瓶颈,取而代之,CPU性能越来越高,轮询线程成为更好的方式,因此,在本申请实施例对驱动的优化中,采用轮询方式代替中断方式,采用此方法有三方面优势:减少对系统中断资源的占用;减少系统调度的影响;由于采用轮询的方式访问外部设备,可以减少外部设备异常对系统的影响。另外,编写处理网络数据包的轮询函数的过程中要避免对系统调用接口的使用,可以采取直接内存操作,比如内存地址操作、内存链表操作、内存数据操作,例如修改用户应用,使用新的接口,比如重新定义的init、start、stop、reset、read、write等接口执行对网络设备的访问,这样可以起到提高处理性能的效果。It should be noted that in the prior art driver implementation methods, a large number of interrupts are used to notify the system of data changes. When there are system call statements in the program, when the program executes to the system call, first use soft interrupts and other similar instructions. Save the scene, make a system call, execute it in the kernel mode, and then restore the scene. Each process will have two stacks, a kernel mode stack and a user mode stack. When the interrupt is executed, it will switch from the user mode stack to the kernel mode stack. The stack needs to be switched when the system is called. Moreover, the kernel code does not trust the user and requires additional checks. The return process of the system call has a lot of extra work, such as checking whether scheduling is required. However, with the continuous development of computer technology, interrupt resources have increasingly become the bottleneck of system performance. Instead, CPU performance has become higher and higher, and polling threads have become a better way. Therefore, in the optimization of the driver in the embodiment of the present application , using the polling method instead of the interrupt method, which has three advantages: reducing the occupation of system interrupt resources; reducing the impact of system scheduling; because the polling method is used to access external devices, the impact of external device abnormalities on the system can be reduced. In addition, in the process of writing the polling function for processing network data packets, avoid using the system call interface. You can use direct memory operations, such as memory address operations, memory linked list operations, and memory data operations, such as modifying user applications and using new Interfaces, such as redefined interfaces such as init, start, stop, reset, read, and write, implement access to network devices, which can improve processing performance.
本申请实施例提供的第三种网络数据包处理方法,是在上述第二种网络数据包处理方法的基础上,还包括如下技术特征:The third network data packet processing method provided in the embodiment of the present application is based on the above-mentioned second network data packet processing method, and also includes the following technical features:
在所述利用所述轮询线程从所述网络设备的缓冲区中获取数据之前,还包括:Before using the polling thread to obtain data from the buffer of the network device, it also includes:
将每个所述轮询线程绑定至对应的一个CPU上。Bind each polling thread to a corresponding CPU.
在这种情况下,根据系统中当前CPU的核心数,设置不多于处理网络数据的polling线程,并与CPU进行绑定,保证每个线程始终在一个核心上运行,可以避免线程在CPU核心之间切换的消耗。In this case, according to the number of cores of the current CPU in the system, set no more than polling threads for processing network data, and bind them to the CPU to ensure that each thread always runs on one core, which can prevent threads from running on the CPU core. The cost of switching between.
本申请实施例提供的第四种网络数据包处理方法,是在上述第一种至第三种网络数据包处理方法的基础上,还包括如下技术特征:The fourth network data packet processing method provided in the embodiment of the present application is based on the above-mentioned first to third network data packet processing methods, and also includes the following technical features:
所述在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系之前,还包括:In the driver in the kernel state, before establishing a mapping relationship between the user state memory space and the buffer of the network device, it also includes:
将设备驱动拆分为所述内核态的驱动和所述用户态内存空间。The device driver is split into the driver of the kernel state and the memory space of the user state.
具体的,就是重写网络设备驱动,将原有的Device Driver拆分成kernel空间的驱动和User空间的驱动两部分,为将数据从内核态转换为用户态提供基础。Specifically, it is to rewrite the network device driver and split the original Device Driver into two parts: the driver in the kernel space and the driver in the user space, so as to provide a basis for converting data from the kernel state to the user state.
本申请实施例提供的第一种网络数据包处理装置如图2所示,图2为本申请实施例提供的第一种网络数据包处理装置的示意图,该装置包括:The first network data packet processing device provided in the embodiment of the present application is shown in Figure 2, and Figure 2 is a schematic diagram of the first network data packet processing device provided in the embodiment of the present application, and the device includes:
映射关系建立单元201,用于在内核态的驱动中,为用户态内存空间与网络设备的缓冲区建立映射关系,需要说明的是,网络协议栈在处理网络数据时,不再进行多次的数据复制,而是将硬件中的数据直接拷贝到用户态,避免核心态到用户态的拷贝过程,这样做可以简化协议层处理过程,屏蔽socket层的协议处理;The mapping relationship establishment unit 201 is used to establish a mapping relationship between the user mode memory space and the buffer zone of the network device in the driver of the kernel mode. Data replication, but directly copy the data in the hardware to the user state, avoiding the copy process from the core state to the user state, which can simplify the protocol layer processing process and shield the protocol processing of the socket layer;
数据获取单元202,用于从所述网络设备的缓冲区中获取数据,,可以采用中断或轮询等方式来获取,此处并不限制;The data obtaining unit 202 is configured to obtain data from the buffer of the network device, which may be obtained by means of interruption or polling, which is not limited here;
数据转换单元203,用于将获取的数据从内核态直接转换成用户态,能够将硬件中的数据直接拷贝到用户态,减少不必要的内存方面的开销;The data conversion unit 203 is used to directly convert the obtained data from the kernel state to the user state, and can directly copy the data in the hardware to the user state, reducing unnecessary memory overhead;
数据处理单元204,用于利用CPU对所述数据进行处理,避免在处理过程中使用系统调用,减少进入系统调用的开销。The data processing unit 204 is configured to use the CPU to process the data, avoid using system calls during processing, and reduce the overhead of entering system calls.
通过上述描述可知,本申请实施例提供的上述第一种网络数据包处理装置,避免了核心态到用户态的拷贝过程,可以简化协议层处理过程,屏蔽socket层的协议处理,因此能够减少每个数据包处理占用的系统资源和时间,提高网络数据包处理性能。It can be seen from the above description that the above-mentioned first network data packet processing device provided by the embodiment of the present application avoids the copy process from the core state to the user state, can simplify the protocol layer processing process, and shield the protocol processing of the socket layer, so it can reduce each The system resources and time occupied by each data packet processing can be improved, and the performance of network data packet processing can be improved.
本申请实施例提供的第二种网络数据包处理装置,是在上述第一种网络数据包处理装置的基础上,还包括如下技术特征:The second network data packet processing device provided in the embodiment of the present application is based on the above-mentioned first network data packet processing device, and further includes the following technical features:
所述数据获取单元具体用于:The data acquisition unit is specifically used for:
利用所述轮询线程从所述网络设备的缓冲区中获取数据。Using the polling thread to acquire data from the buffer of the network device.
需要说明的是,现有技术中的驱动实现方式,大量的采用中断的方式来通知系统数据的变动,当程序中有系统调用语句,程序执行到系统调用时,首先使用软中断等类似指令,保存现场,去进行系统调用,在内核态执行,然后恢复现场,每个进程都会有两个栈,一个内核态栈和一个用户态栈。当中断执行时就会由用户态栈,转向内核态栈。系统调用时需要进行栈的切换。而且内核代码对用户不信任,需要进行额外的检查。系统调用的返回过程有很多额外工作,比如检查是否需要调度等。但随着计算机技术的不断发展,中断资源越来越成为系统性能的瓶颈,取而代之,CPU性能越来越高,轮询线程成为更好的方式。因此,在本申请实施例对驱动的优化中,采用轮询方式代替中断方式,采用此方法有三方面优势:减少对系统中断资源的占用;减少系统调度的影响;由于采用轮询的方式访问外部设备,可以减少外部设备异常对系统的影响。另外,编写处理网络数据包的轮询函数的过程中要避免对系统调用接口的使用,可以采取直接内存操作,比如内存地址操作、内存链表操作、内存数据操作,例如修改用户应用,使用新的接口,比如重新定义的init、start、stop、reset、read、write等接口执行对网络设备的访问,这样可以起到提高处理性能的效果。It should be noted that in the prior art driver implementation methods, a large number of interrupts are used to notify the system of data changes. When there are system call statements in the program, when the program executes to the system call, first use soft interrupts and other similar instructions. Save the scene, make a system call, execute it in the kernel mode, and then restore the scene. Each process will have two stacks, a kernel mode stack and a user mode stack. When the interrupt is executed, it will switch from the user mode stack to the kernel mode stack. The stack needs to be switched when the system is called. Moreover, the kernel code does not trust the user and requires additional checks. The return process of the system call has a lot of extra work, such as checking whether scheduling is required. However, with the continuous development of computer technology, interrupt resources have increasingly become the bottleneck of system performance. Instead, CPU performance is getting higher and higher, and polling threads has become a better way. Therefore, in the optimization of the driver in this embodiment of the application, the polling method is used instead of the interrupt method. This method has three advantages: reducing the occupation of system interrupt resources; reducing the impact of system scheduling; equipment, which can reduce the impact of external equipment abnormalities on the system. In addition, in the process of writing the polling function for processing network data packets, avoid using the system call interface. You can use direct memory operations, such as memory address operations, memory linked list operations, and memory data operations, such as modifying user applications and using new Interfaces, such as redefined interfaces such as init, start, stop, reset, read, and write, implement access to network devices, which can improve processing performance.
本申请实施例提供的第三种网络数据包处理装置,是在上述第二种网络数据包处理装置的基础上,还包括如下技术特征:The third network data packet processing device provided in the embodiment of the present application is based on the above-mentioned second network data packet processing device, and further includes the following technical features:
绑定单元,用于将每个所述轮询线程绑定至对应的一个CPU上。The binding unit is used to bind each polling thread to a corresponding CPU.
在这种情况下,根据系统中当前CPU的核心数,设置不多于处理网络数据的polling线程,并与CPU进行绑定,保证每个线程始终在一个核心上运行,可以避免线程在CPU核心之间切换的消耗。In this case, according to the number of cores of the current CPU in the system, set no more than polling threads for processing network data, and bind them to the CPU to ensure that each thread always runs on one core, which can prevent threads from running on the CPU core. The cost of switching between.
本申请实施例提供的第四种网络数据包处理装置,是在上述第一种至第三种网络数据包处理装置中任一种的基础上,还包括如下技术特征:The fourth network data packet processing device provided in the embodiment of the present application is based on any one of the above-mentioned first to third network data packet processing devices, and further includes the following technical features:
拆分单元,用于将设备驱动拆分为所述内核态的驱动和所述用户态内存空间。The splitting unit is configured to split the device driver into the kernel-mode driver and the user-mode memory space.
具体的,就是重写网络设备驱动,将原有的Device Driver拆分成kernel空间的驱动和User空间的驱动两部分,为将数据从内核态转换为用户态提供基础。Specifically, it is to rewrite the network device driver and split the original Device Driver into two parts: the driver in the kernel space and the driver in the user space, so as to provide a basis for converting data from the kernel state to the user state.
综上所述,本申请实施例提供的上述方法和装置,能够减少每个网络数据包处理的时间,优点如下:减少数据在内存中拷贝的次数,防止重复拷贝;减少对系统资源的占用,包括系统硬中断、软中断和CPU资源等;减少外部设备异常对系统稳定性的影响;提高网络数据包处理性能。To sum up, the above-mentioned method and device provided by the embodiment of the present application can reduce the processing time of each network data packet, and the advantages are as follows: reduce the number of times data is copied in the memory, prevent repeated copying; reduce the occupation of system resources, Including system hard interrupts, soft interrupts and CPU resources, etc.; reducing the impact of external device exceptions on system stability; improving network packet processing performance.
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本发明。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本发明的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (8)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611220118.0A CN106713462A (en) | 2016-12-26 | 2016-12-26 | Network data packet processing method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611220118.0A CN106713462A (en) | 2016-12-26 | 2016-12-26 | Network data packet processing method and device |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN106713462A true CN106713462A (en) | 2017-05-24 |
Family
ID=58903435
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201611220118.0A Pending CN106713462A (en) | 2016-12-26 | 2016-12-26 | Network data packet processing method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN106713462A (en) |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107749893A (en) * | 2017-11-09 | 2018-03-02 | 北京精强远科技有限公司 | The quick method for receiving and storing data is realized in a kind of shared-file system |
| CN108712308A (en) * | 2018-06-06 | 2018-10-26 | 郑州云海信息技术有限公司 | The method and apparatus that the network equipment is detected in virtual network |
| CN112698934A (en) * | 2019-10-22 | 2021-04-23 | 华为技术有限公司 | Resource scheduling method and device, PMD scheduling device, electronic equipment and storage medium |
| CN114356591A (en) * | 2020-10-14 | 2022-04-15 | 阿里巴巴集团控股有限公司 | Interprocess communication method, device, IoT operating system, and IoT device |
| CN114969121A (en) * | 2022-06-07 | 2022-08-30 | 深圳市欢太科技有限公司 | Data acquisition method, device, storage medium and computer equipment |
| CN116319308A (en) * | 2023-03-31 | 2023-06-23 | 深圳市领创星通科技有限公司 | A packet forwarding system |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101267361A (en) * | 2008-05-09 | 2008-09-17 | 武汉飞思科技有限公司 | A high-speed network data packet capturing method based on zero duplication technology |
| CN101478549A (en) * | 2009-01-20 | 2009-07-08 | 电子科技大学 | Operation method for memory sharing media server and functional module construction |
| CN102326149A (en) * | 2011-07-28 | 2012-01-18 | 华为技术有限公司 | Method and device for implementing memory migration |
| EP2552081A2 (en) * | 2006-07-10 | 2013-01-30 | Solarflare Communications Inc | Interrupt management |
| CN103731364A (en) * | 2014-01-16 | 2014-04-16 | 赛特斯信息科技股份有限公司 | X86 platform based method for achieving trillion traffic rapid packaging |
-
2016
- 2016-12-26 CN CN201611220118.0A patent/CN106713462A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| EP2552081A2 (en) * | 2006-07-10 | 2013-01-30 | Solarflare Communications Inc | Interrupt management |
| CN101267361A (en) * | 2008-05-09 | 2008-09-17 | 武汉飞思科技有限公司 | A high-speed network data packet capturing method based on zero duplication technology |
| CN101478549A (en) * | 2009-01-20 | 2009-07-08 | 电子科技大学 | Operation method for memory sharing media server and functional module construction |
| CN102326149A (en) * | 2011-07-28 | 2012-01-18 | 华为技术有限公司 | Method and device for implementing memory migration |
| CN103731364A (en) * | 2014-01-16 | 2014-04-16 | 赛特斯信息科技股份有限公司 | X86 platform based method for achieving trillion traffic rapid packaging |
Cited By (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107749893A (en) * | 2017-11-09 | 2018-03-02 | 北京精强远科技有限公司 | The quick method for receiving and storing data is realized in a kind of shared-file system |
| CN108712308A (en) * | 2018-06-06 | 2018-10-26 | 郑州云海信息技术有限公司 | The method and apparatus that the network equipment is detected in virtual network |
| CN108712308B (en) * | 2018-06-06 | 2021-11-26 | 郑州云海信息技术有限公司 | Method and device for detecting network equipment in virtual network |
| CN112698934A (en) * | 2019-10-22 | 2021-04-23 | 华为技术有限公司 | Resource scheduling method and device, PMD scheduling device, electronic equipment and storage medium |
| CN112698934B (en) * | 2019-10-22 | 2023-12-15 | 华为技术有限公司 | Resource scheduling method and device, PMD scheduling device, electronic equipment, storage medium |
| CN114356591A (en) * | 2020-10-14 | 2022-04-15 | 阿里巴巴集团控股有限公司 | Interprocess communication method, device, IoT operating system, and IoT device |
| CN114969121A (en) * | 2022-06-07 | 2022-08-30 | 深圳市欢太科技有限公司 | Data acquisition method, device, storage medium and computer equipment |
| CN114969121B (en) * | 2022-06-07 | 2025-04-11 | 深圳市欢太科技有限公司 | Data acquisition method, device, storage medium and computer equipment |
| CN116319308A (en) * | 2023-03-31 | 2023-06-23 | 深圳市领创星通科技有限公司 | A packet forwarding system |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106713462A (en) | Network data packet processing method and device | |
| CN110535813B (en) | Kernel mode protocol stack and user mode protocol stack coexist processing method and device | |
| US12452176B2 (en) | Load balancing method for multi-thread forwarding and related apparatus | |
| CN103200128B (en) | The methods, devices and systems that a kind of network packet processes | |
| CN102098227B (en) | Packet capture method and kernel module | |
| CN103942178A (en) | Communication method between real-time operating system and non-real-time operating system on multi-core processor | |
| CN108366018B (en) | A DPDK-based network data packet processing method | |
| CN110636139B (en) | An optimization method and system for cloud load balancing | |
| CN103532876A (en) | Processing method and system of data stream | |
| TWI478055B (en) | Asymmetrical multiprocessing multi-core system and network device | |
| CN113271336B (en) | DPDK-based robot middleware DDS data transmission method, electronic device and computer-readable storage medium | |
| CN104182234A (en) | Business processing method and business system | |
| CN106873915A (en) | A kind of data transmission method and device based on RDMA registers memory blocks | |
| CN111209123A (en) | Local storage IO protocol stack data interaction method and device | |
| CN110737530B (en) | A method to improve the packet receiving ability of the HANDLE identification analysis system | |
| US11784946B2 (en) | Method for improving data flow and access for a neural network processor | |
| KR20130051820A (en) | Software migration apparatus in mobile environment and the method thereof | |
| CN115473811A (en) | Network performance optimization method, device, equipment and medium | |
| CN108037898A (en) | A kind of method, system and device of the dpdk communications based on Ceph | |
| CN104133671B (en) | The hardware interface screening arrangement and method of a kind of digital processing device | |
| WO2023000817A1 (en) | Virtual machine hot-upgrading method and apparatus, device, and storage medium | |
| CN116360930A (en) | Method and device for task processing | |
| US10284501B2 (en) | Technologies for multi-core wireless network data transmission | |
| WO2024061179A1 (en) | Logic bonding port management method, apparatus and system, and storage medium | |
| CN118055084A (en) | Network packet receiving method, device, electronic device, storage medium and program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20170524 |
|
| RJ01 | Rejection of invention patent application after publication |