CN112130859A - An application running method, device, device and storage medium - Google Patents
An application running method, device, device and storage medium Download PDFInfo
- Publication number
- CN112130859A CN112130859A CN201910554939.5A CN201910554939A CN112130859A CN 112130859 A CN112130859 A CN 112130859A CN 201910554939 A CN201910554939 A CN 201910554939A CN 112130859 A CN112130859 A CN 112130859A
- Authority
- CN
- China
- Prior art keywords
- target
- platform
- application
- data packet
- version
- 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
- 238000000034 method Methods 0.000 title claims abstract description 76
- 230000008569 process Effects 0.000 claims abstract description 18
- 230000006870 function Effects 0.000 claims description 33
- 238000012545 processing Methods 0.000 claims description 29
- 238000004590 computer program Methods 0.000 claims description 11
- 238000011084 recovery Methods 0.000 claims 2
- 238000012423 maintenance Methods 0.000 abstract description 7
- 230000001419 dependent effect Effects 0.000 description 13
- 230000008676 import Effects 0.000 description 8
- 238000011161 development Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 4
- 238000004064 recycling Methods 0.000 description 4
- 238000013461 design Methods 0.000 description 3
- 239000000047 product Substances 0.000 description 3
- 239000013589 supplement Substances 0.000 description 3
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000011897 real-time detection Methods 0.000 description 2
- 238000012827 research and development Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 1
- 238000004883 computer application Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
本发明公开了一种应用运行方法,该方法利用宏开关的方式决定对目标应用的包含与目标平台对应的汇编代码的平台源代码进行编译,使得编译出来的执行程序为目标平台下的可执行程序。对于代码的可维护性较强,提高了代码维护的便利性,降低了人力成本。本发明还公开了一种应用运行方法,在目标平台上运行目标应用过程中,对于待发送的目标数据包,先对其进行包头空间的扩充,得到预留空间,内核模块在预留空间中填充交换标签发送给交换芯片,交换芯片据此确定用于传输目标数据包的网口。使得目标应用能够在应用平台上顺利运行。本发明还公开了一种应用运行装置、设备及存储介质,具有相应技术效果。
The invention discloses an application running method. The method uses a macro switch to decide to compile the platform source code of the target application including the assembly code corresponding to the target platform, so that the compiled execution program is executable under the target platform. program. The maintainability of the code is strong, which improves the convenience of code maintenance and reduces labor costs. The invention also discloses an application running method. In the process of running the target application on the target platform, for the target data packet to be sent, the packet header space is first expanded to obtain the reserved space, and the kernel module is in the reserved space. The padding switch label is sent to the switch chip, and the switch chip determines the network port used for transmitting the target data packet according to it. The target application can run smoothly on the application platform. The invention also discloses an application running device, equipment and storage medium, which have corresponding technical effects.
Description
技术领域technical field
本发明涉及计算机应用技术领域,特别是涉及一种应用运行方法、装置、设备及存储介质。The present invention relates to the technical field of computer applications, and in particular, to an application running method, apparatus, device and storage medium.
背景技术Background technique
随着互联网技术的快速发展,云产业的快速突起,基础架构网络逐渐向基于通用计算平台的架构的网络融合,以支持多样化的网络系统。With the rapid development of Internet technology and the rapid emergence of the cloud industry, the infrastructure network is gradually integrating into a network based on a general computing platform to support diverse network systems.
一个应用多会包含依赖于运行环境硬件架构的汇编代码,这些代码的实现依赖于某一架构下的指令集,如x86架构,如果要将该应用移植到其他架构的平台上运行,如移植到Aarch64架构的平台上,因为不同架构的指令集存在较大的不同,需要对该应用的所有代码重新编写。An application will often contain assembly code that depends on the hardware architecture of the operating environment. The implementation of these codes depends on the instruction set under a certain architecture, such as the x86 architecture. If the application is to be ported to run on platforms of other architectures, such as porting to On the platform of the Aarch64 architecture, because the instruction sets of different architectures are quite different, all the codes of the application need to be rewritten.
也就是说,一个应用如果要运行在某一架构的平台上,对应有一套与该架构的平台对应的代码,如果要运行在另一架构的平台上,则对应有另一套与另一架构的平台对应的代码。这样,在维护时,就需要对该应用的与不同架构的平台对应的代码进行单独维护。而一个应用不只是包含依赖于运行环境硬件架构的代码,同时还包含不依赖于运行环境硬件架构的代码。如果对于不同架构的平台对应的代码进行单独维护,那么只要有代码更新,就需要同时对多份代码进行更改,即使涉及到更改的内容是不依赖于运行环境硬件架构的代码,也需要对每一份单独维护的代码同时进行更改。可维护性较差,所需人力成本较高。That is to say, if an application is to run on a platform of a certain architecture, it corresponds to a set of codes corresponding to the platform of this architecture. The code corresponding to the platform. In this way, during maintenance, it is necessary to separately maintain the code of the application corresponding to platforms with different architectures. An application not only contains code that depends on the hardware architecture of the operating environment, but also contains code that does not depend on the hardware architecture of the operating environment. If the code corresponding to platforms with different architectures is maintained separately, as long as there is a code update, multiple codes need to be changed at the same time, even if the content of the change is code that does not depend on the hardware architecture of the operating environment, each code needs to be updated. A separately maintained code with simultaneous changes. The maintainability is poor and the labor cost is high.
另外,目前,大多数产品架构是基于Linux内核转发模式,这种模式存在一定的问题,首先是性能问题,其存在性能瓶颈,无法满足新业务的发展需求,其次是可靠性问题,运行在内核态的进程一旦执行失败,将会引起业务中断。基于这两方面的问题,目前业界公认的一个演进趋势是在用户空间利用自身提供的数据平面来收发数据包,绕过Linux内核协议栈对数据包的处理,以解决传统Linux内核转发的性能和可靠性问题。In addition, at present, most product architectures are based on the Linux kernel forwarding mode, which has certain problems. The first is the performance problem, which has performance bottlenecks and cannot meet the development needs of new services, and the second is the reliability problem, running in the kernel. Once the state process fails to execute, it will cause business interruption. Based on these two problems, an evolution trend recognized by the industry is to use the data plane provided by itself to send and receive data packets in user space, bypassing the processing of data packets by the Linux kernel protocol stack, so as to solve the performance and performance of traditional Linux kernel forwarding. reliability issues.
鉴于以上问题,网络基础平台NFP应用应运而生,其数据面是基于VPP研发的可扩展框架。VPP(Vector Packet Processing,矢量数据包处理)平台是一个可扩展的框架,提供开箱即用的交换机/路由器功能。但是现有的NFP应用只支持运行于x86架构的硬件平台下,并不支持运行在ARM硬件平台下,致使大多数ARM硬件平台仍然采用Linux的内核作为转发业务的支撑,导致业务发展受到性能制约。In view of the above problems, the network infrastructure platform NFP application emerges as the times require, and its data plane is an extensible framework based on VPP research and development. The VPP (Vector Packet Processing) platform is an extensible framework that provides out-of-the-box switch/router functionality. However, the existing NFP applications only support running on the hardware platform of the x86 architecture, and do not support running on the ARM hardware platform. As a result, most ARM hardware platforms still use the Linux kernel as the support for forwarding services, resulting in performance constraints on business development. .
发明内容SUMMARY OF THE INVENTION
本发明的目的是提供一种应用运行方法、装置、设备及存储介质,以提高代码维护的便利性,降低人力成本,且使得目标应用能够在目标平台上顺利运行。The purpose of the present invention is to provide an application running method, device, device and storage medium, so as to improve the convenience of code maintenance, reduce labor costs, and enable the target application to run smoothly on the target platform.
为解决上述技术问题,本发明提供如下技术方案:In order to solve the above-mentioned technical problems, the present invention provides the following technical solutions:
一种应用运行方法,包括:An application running method, including:
在达到预设的版本编译触发条件时,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,所述目标版本为与待运行所述目标应用的目标平台对应的版本;When a preset version compilation trigger condition is reached, the target version of the target application to be compiled is determined according to the pre-imported environment variables and the macros required for compilation, where the target version corresponds to the target platform on which the target application is to be run version of;
确定所述目标平台的二进制文件的依赖库的保存目录及所述目标平台的二进制文件的生成目录;Determine the storage directory of the dependency library of the binary file of the target platform and the generation directory of the binary file of the target platform;
引入所述目标应用的与所述目标平台对应的汇编代码;Introducing the assembly code corresponding to the target platform of the target application;
调用预设的编译工具对包含所述汇编代码的平台源代码进行编译,获得所述目标应用的二进制文件,以基于所述目标应用的二进制文件,在所述目标平台上运行所述目标应用。A preset compiling tool is invoked to compile the platform source code including the assembly code, and a binary file of the target application is obtained, so as to run the target application on the target platform based on the binary file of the target application.
在本发明的一种具体实施方式中,所述目标版本为x86版本或者Aarch64版本。In a specific implementation manner of the present invention, the target version is an x86 version or an Aarch64 version.
在本发明的一种具体实施方式中,所述目标应用为网络基础平台NFP应用、所述目标版本为Aarch64版本、所述目标平台为Aarch64架构平台,所述NFP应用部署于用户空间,所述方法还包括:In a specific embodiment of the present invention, the target application is a network infrastructure platform NFP application, the target version is an Aarch64 version, the target platform is an Aarch64 architecture platform, the NFP application is deployed in user space, and the Methods also include:
在所述Aarch64架构平台上运行所述NFP应用过程中,如果所述NFP应用的数据面的收发包模块检测到待发送的目标数据包,则通过所述收发包模块对所述目标数据包的包头空间进行扩充处理,获得预留空间;During the process of running the NFP application on the Aarch64 architecture platform, if the packet sending and receiving module of the data plane of the NFP application detects the target data packet to be sent, The header space is expanded to obtain reserved space;
调用所述Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的所述目标数据包发送出去,以在内核模块将在所述预留空间填充交换标签的所述目标数据包发送给Marvell交换芯片后,所述Marvell交换芯片通过所述交换标签,确定用于传输所述目标数据包的网口。Call the kernel function interface of the kernel space of the Aarch64 architecture platform to send the target data packet after the expansion processing, so that the target data packet filled with the switching label in the reserved space is sent to Marvell by the kernel module After switching chips, the Marvell switching chip determines the network port for transmitting the target data packet through the switching label.
在本发明的一种具体实施方式中,在所述通过所述收发包模块对所述目标数据包的包头空间进行扩充处理之后、所述调用所述Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的所述目标数据包发送出去之前,还包括:In a specific embodiment of the present invention, after the packet header space of the target data packet is expanded by the packet sending and receiving module, the kernel function interface calling the kernel space of the Aarch64 architecture platform will Before the target data packet after the expansion processing is sent out, it also includes:
对所述目标数据包添加扩充标记;adding an extension mark to the target data packet;
在所述调用所述Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的所述目标数据包发送出去之后,还包括:After the kernel function interface that calls the kernel space of the Aarch64 architecture platform sends the expanded target data packet, it also includes:
如果检测到发送失败的数据包、且该数据包存在所述扩充标记,则对该数据包进行回收处理。If a data packet that fails to be sent is detected and the extended flag exists in the data packet, the data packet is recycled.
在本发明的一种具体实施方式中,所述目标数据包为所述用户空间的发送缓冲区中的一个数据包。In a specific embodiment of the present invention, the target data packet is a data packet in the sending buffer of the user space.
一种应用运行方法,包括:An application running method, including:
在目标平台上运行目标应用过程中,如果所述目标应用检测到有待发送的目标数据包,则对所述目标数据包的包头空间进行扩充处理,获得预留空间;In the process of running the target application on the target platform, if the target application detects the target data packet to be sent, the header space of the target data packet is expanded to obtain reserved space;
调用所述目标平台的内核函数接口将进行扩充处理后的所述目标数据包发送出去,以在内核模块将在所述预留空间填充交换标签的所述目标数据包发送给交换芯片后,所述交换芯片通过所述交换标签,确定用于传输所述目标数据包的网口。Call the kernel function interface of the target platform to send the target data packet after expansion processing, so that after the kernel module sends the target data packet filled with the switching label in the reserved space to the switching chip, the target data packet is sent out. The switch chip determines the network port for transmitting the target data packet through the switch label.
在本发明的一种具体实施方式中,在所述对所述目标数据包的包头空间进行扩充处理之后、所述调用所述目标平台的内核函数接口将进行扩充处理后的所述目标数据包发送出去之前,还包括:In a specific embodiment of the present invention, after the expansion processing is performed on the header space of the target data packet, the invoking the kernel function interface of the target platform will perform the expansion processing on the target data packet. Before sending, also include:
对所述目标数据包添加扩充标记;adding an extension mark to the target data packet;
在所述调用所述目标平台的内核函数接口将进行扩充处理后的所述目标数据包发送出去之后,还包括:After the call to the kernel function interface of the target platform sends the expanded target data packet, the method further includes:
如果检测到发送失败的数据包、且该数据包存在所述扩充标记,则对该数据包进行回收处理。If a data packet that fails to be sent is detected and the extended flag exists in the data packet, the data packet is recycled.
在本发明的一种具体实施方式中,所述目标应用部署于所述目标平台的用户空间,所述目标数据包为所述用户空间的发送缓冲区中的一个数据包。In a specific embodiment of the present invention, the target application is deployed in the user space of the target platform, and the target data packet is a data packet in the sending buffer of the user space.
在本发明的一种具体实施方式中,所述目标平台为Aarch64架构平台,所述目标应用为网络基础平台NFP应用,所述交换芯片为Marvell交换芯片。In a specific embodiment of the present invention, the target platform is an Aarch64 architecture platform, the target application is a network basic platform NFP application, and the switch chip is a Marvell switch chip.
在本发明的一种具体实施方式中,还包括:In a specific embodiment of the present invention, it also includes:
在达到预设的版本编译触发条件时,根据预先导入的环境变量和编译所需要的宏,确定所述目标应用的待编译的目标版本,所述目标版本为与待运行所述目标应用的所述目标平台对应的版本;When a preset version compilation trigger condition is reached, the target version to be compiled of the target application is determined according to the pre-imported environment variables and the macros required for compilation, and the target version is the same as the target application to be run. the version corresponding to the target platform;
确定所述目标平台的二进制文件的依赖库的保存目录及所述目标平台的二进制文件的生成目录;Determine the storage directory of the dependency library of the binary file of the target platform and the generation directory of the binary file of the target platform;
引入所述目标应用的与所述目标平台对应的汇编代码;Introducing the assembly code corresponding to the target platform of the target application;
调用预设的编译工具对包含所述汇编代码的平台源代码进行编译,获得所述目标应用的二进制文件,以基于所述目标应用的二进制文件,在所述目标平台上运行所述目标应用。A preset compiling tool is invoked to compile the platform source code including the assembly code, and a binary file of the target application is obtained, so as to run the target application on the target platform based on the binary file of the target application.
在本发明的一种具体实施方式中,所述目标版本为x86版本或者Aarch64版本。In a specific implementation manner of the present invention, the target version is an x86 version or an Aarch64 version.
一种应用运行装置,包括:An application running device, comprising:
版本确定单元,用于在达到预设的版本编译触发条件时,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,所述目标版本为与待运行所述目标应用的目标平台对应的版本;The version determination unit is used to determine the target version to be compiled of the target application according to the pre-imported environment variables and the macros required for compilation when a preset version compilation trigger condition is reached, and the target version is the same as the target version to be executed. The version corresponding to the target platform of the target application;
目录确定单元,用于确定所述目标平台的二进制文件的依赖库的保存目录及所述目标平台的二进制文件的生成目录;a directory determination unit, configured to determine the storage directory of the dependency library of the binary file of the target platform and the generation directory of the binary file of the target platform;
代码引入单元,用于引入所述目标应用的与所述目标平台对应的汇编代码;a code introduction unit, used for introducing the assembly code corresponding to the target platform of the target application;
代码编译单元,用于调用预设的编译工具对包含所述汇编代码的平台源代码进行编译,获得所述目标应用的二进制文件,以基于所述目标应用的二进制文件,在所述目标平台上运行所述目标应用。a code compiling unit, configured to invoke a preset compiling tool to compile the platform source code containing the assembly code, and obtain the binary file of the target application, so as to generate a binary file on the target platform based on the binary file of the target application Run the target application.
一种应用运行装置,包括:An application running device, comprising:
扩充单元,用于在目标平台上运行目标应用过程中,如果所述目标应用检测到有待发送的目标数据包,则对所述目标数据包的包头空间进行扩充处理,获得预留空间;The expansion unit is used for running the target application process on the target platform, if the target application detects the target data packet to be sent, then the header space of the target data packet is expanded to obtain reserved space;
发送单元,用于调用所述目标平台的内核函数接口将进行扩充处理后的所述目标数据包发送出去,以在内核模块将在所述预留空间填充交换标签的所述目标数据包发送给交换芯片后,所述交换芯片通过所述交换标签,确定用于传输所述目标数据包的网口。A sending unit, configured to call the kernel function interface of the target platform to send the expanded target data packet, so that the kernel module sends the target data packet filled with the switching label in the reserved space to the target data packet. After switching chips, the switching chip determines the network port for transmitting the target data packet through the switching label.
一种应用运行设备,包括:An application running device including:
存储器,用于存储计算机程序;memory for storing computer programs;
处理器,用于执行所述计算机程序时实现上述应用运行方法的步骤。The processor is configured to implement the steps of the above application running method when executing the computer program.
一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述应用运行方法的步骤。A computer-readable storage medium stores a computer program on the computer-readable storage medium, and when the computer program is executed by a processor, implements the steps of the above application running method.
应用本发明实施例所提供的技术方案,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,并进一步确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录,引入目标应用的与目标平台对应的汇编代码,调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,这样可以基于目标应用的二进制文件,在目标平台上运行目标应用。即要将应用从第一个架构的平台移植到第二个架构的平台上运行时,利用宏开关的方式决定,决定对目标应用的包含与第二个架构的平台对应的汇编代码的平台源代码进行编译,使得编译出来的执行程序为第二个架构的平台下的可执行程序。对于目标应用的依赖于不同运行环境硬件架构的代码进行单独维护,对于目标应用的不依赖于运行环境硬件架构的代码可以只维护一份,这样在有针对不依赖于运行环境硬件架构的代码的更新时,只需要更新一次即可。可维护性较强,提高了代码维护的便利性,降低了人力成本。The technical solution provided by the embodiment of the present invention is applied, and the target version to be compiled of the target application is determined according to the pre-imported environment variables and the macros required for compilation, and the storage directory and target of the dependency library of the binary file of the target platform are further determined. The directory for generating the binary files of the platform, introducing the assembly code of the target application corresponding to the target platform, calling the preset compilation tool to compile the platform source code containing the assembly code, and obtaining the binary file of the target application, which can be based on the target application. Binaries that run the target application on the target platform. That is, when the application is to be migrated from the platform of the first architecture to the platform of the second architecture, the macro switch is used to determine the platform source of the target application that contains the assembly code corresponding to the platform of the second architecture. The code is compiled, so that the compiled executable program is an executable program under the platform of the second architecture. The code of the target application that depends on the hardware architecture of different operating environments can be maintained separately, and only one copy of the code of the target application that does not depend on the hardware architecture of the operating environment can be maintained. When updating, it only needs to be updated once. The maintainability is strong, which improves the convenience of code maintenance and reduces labor costs.
另外,在目标平台上运行目标应用过程中,如果目标应用检测到有待发送的目标数据包,则先对目标数据包的包头空间进行扩充处理,获得预留空间,然后调用目标平台的内核函数接口将进行扩充处理后的目标数据包发送出去,这样,在内核模块将在预留空间填充交换标签的目标数据包发送给交换芯片后,交换芯片通过交换标签,可以确定用于传输目标数据包的网口。使得目标应用能够在目标平台上顺利运行。并且,较好的解决了目前Netmap驱动并不支持交换标签DSA TAG特性,因此在使用原生的Netmap作为收发包模块,有数据包发送时,数据包经过Netmap发送至内核模块后,内核模块补充DSA TAG标记在以太网帧中,而数据包却并没有预留出空间来填写DSA TAG,因此内核模块在扩充数据包的包头来填充DSA TAG时,会发生宕机的问题。In addition, in the process of running the target application on the target platform, if the target application detects the target data packet to be sent, it first expands the header space of the target data packet to obtain the reserved space, and then calls the kernel function interface of the target platform. The target data packet after expansion processing is sent out, so that after the kernel module sends the target data packet filled with the switching label in the reserved space to the switching chip, the switching chip can determine the target data packet used to transmit the target data packet through the switching label. network port. The target application can run smoothly on the target platform. In addition, it better solves the problem that the current Netmap driver does not support the switch tag DSA TAG feature. Therefore, when using the native Netmap as the sending and receiving packet module, when a data packet is sent, after the data packet is sent to the kernel module through Netmap, the kernel module supplements the DSA. The TAG is marked in the Ethernet frame, but the data packet does not reserve space to fill in the DSA TAG, so the kernel module will crash when expanding the header of the data packet to fill the DSA TAG.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying 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 These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.
图1为本发明实施例中一种应用运行方法的实施流程图;FIG. 1 is an implementation flowchart of an application running method in an embodiment of the present invention;
图2为本发明实施例中网络基础平台NFP运行的总体框架图;2 is an overall frame diagram of the operation of the network infrastructure platform NFP in an embodiment of the present invention;
图3为本发明实施例中另一种应用运行方法的实施流程图;3 is an implementation flowchart of another application running method in an embodiment of the present invention;
图4为与图1所示方法实施例对应的应用运行装置的结构示意图;FIG. 4 is a schematic structural diagram of an application running device corresponding to the method embodiment shown in FIG. 1;
图5为与图3所示方法实施例对应的应用运行装置的结构示意图;5 is a schematic structural diagram of an application running device corresponding to the method embodiment shown in FIG. 3;
图6为本发明实施例中一种应用运行设备的结构示意图。FIG. 6 is a schematic structural diagram of an application running device in an embodiment of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面结合附图和具体实施方式对本发明作进一步的详细说明。显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make those skilled in the art better understand the solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, but not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
参见图1所示,为本发明实施例所提供的一种应用运行方法的实施流程图,该方法可以包括以下步骤:Referring to FIG. 1, it is an implementation flowchart of an application running method provided by an embodiment of the present invention, and the method may include the following steps:
S110:在达到预设的版本编译触发条件时,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本。S110: When a preset version compilation trigger condition is reached, determine a target version to be compiled of the target application according to a pre-imported environment variable and a macro required for compilation.
目标版本为与待运行目标应用的目标平台对应的版本。The target version is the version corresponding to the target platform of the target application to be run.
在本发明实施例中,可以预先设定一个版本编译触发条件,如在接收到编译指令时,认为达到了预设的版本编译触发条件,或者,在检测到汇编代码有更新时,认为达到了预设的版本编译触发条件。In the embodiment of the present invention, a version compilation trigger condition may be preset. For example, when a compilation instruction is received, it is considered that the preset version compilation trigger condition is reached, or when an update of the assembly code is detected, it is considered that the predetermined version compilation trigger condition is reached. Preset version build trigger conditions.
在达到预设的版本编译触发条件时,可以先获得预先导入的环境变量和编译所需要的宏。在实际应用中,在编译准备阶段,可以根据目标应用的待编译的版本,执行该版本的环境构建脚本,导入编译该版本运行程序所需要的环境变量和编译所需要的宏。如,如果目标应用的待编译的版本为x86版本,则执行x86版本的环境构建脚本,导入编译x86版本运行程序所需的环境变量和编译所需要的宏;如果目标应用的待编译的版本为Aarch64版本,则执行Aarch64版本的环境构建脚本,导入编译Aarch64版本运行程序所需的环境变量和编译所需要的宏;如果目标应用的待编译的版本为其他版本,则执行该其他版本的环境构建脚本,导入编译该其他版本运行程序所需的环境变量和编译所需要的宏。When the preset version compilation trigger condition is reached, the pre-imported environment variables and the macros required for compilation can be obtained first. In practical applications, in the compilation preparation stage, the environment build script of the version can be executed according to the version to be compiled of the target application, and the environment variables and macros required for compiling the running program of this version are imported. For example, if the version to be compiled of the target application is the x86 version, execute the environment build script of the x86 version, import the environment variables required to compile the x86 version running program and the macros required for compilation; if the version to be compiled of the target application is For the Aarch64 version, execute the environment build script of the Aarch64 version, import the environment variables required to compile the Aarch64 version running program and the macros required for compilation; if the version to be compiled of the target application is another version, execute the environment build of the other version script, import the environment variables required to compile the other version of the running program and the macros required for compilation.
根据预先导入的环境变量和编译所需要的宏,可以确定目标应用的待编译的目标版本,该目标版本为与待运行目标应用的目标平台对应的版本。可以是x86版本,还可以是Aarch64版本,当然,还可以为其他版本。According to the pre-imported environment variables and the macros required for compilation, the target version of the target application to be compiled can be determined, and the target version is the version corresponding to the target platform of the target application to be run. It can be the x86 version, it can also be the Aarch64 version, of course, it can also be other versions.
x86泛指一系列基于Intel 8086且向后兼容的中央处理器指令集架构,通常32位的x86架构被称为i386、x86,64位的x86架构被称为x86-64。x86 generally refers to a series of CPU instruction set architectures based on Intel 8086 and backward compatible, usually the 32-bit x86 architecture is called i386, x86, and the 64-bit x86 architecture is called x86-64.
Aarch64是ARMv8指令集架构的64位执行状态。ARM(Advanced RISC Machine,进阶精简指令集机器)是一个32位(或64位)元精简指令集(RISC)处理器架构,其广泛地应用在许多嵌入式系统设计中。在其他领域上也有很多作为,由于节能的特点,ARM处理器非常适用于行动通讯领域,符合其主要设计目标为低成本、高效能、低耗电的特性。Aarch64 is the 64-bit execution state of the ARMv8 instruction set architecture. ARM (Advanced RISC Machine, advanced reduced instruction set machine) is a 32-bit (or 64-bit) meta-reduced instruction set (RISC) processor architecture, which is widely used in many embedded system designs. There are also many achievements in other fields. Due to the characteristics of energy saving, the ARM processor is very suitable for the field of mobile communication, which is in line with its main design goals of low cost, high performance and low power consumption.
S120:确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录。S120: Determine the storage directory of the dependency library of the binary file of the target platform and the generation directory of the binary file of the target platform.
确定目标应用的待编译的目标版本后,可以进一步确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录。编译出不同架构的平台对应的代码,其依赖库、环境变量和宏各不相同,所以不同架构的目标平台对应的二进制文件的依赖库的保存目录和二进制文件的生成目录不同。After the target version of the target application to be compiled is determined, the storage directory of the dependent library of the binary file of the target platform and the generation directory of the binary file of the target platform can be further determined. The code corresponding to the platforms of different architectures is compiled, and the dependent libraries, environment variables and macros are different. Therefore, the storage directories of the dependent libraries of the binary files corresponding to the target platforms of different architectures and the generation directory of the binary files are different.
如,如果确定的目标应用的待编译的目标版本为x86版本,则可以进一步确定x86架构的目标平台的二进制文件的依赖库的保存目录为lib_x86,x86架构的目标平台的二进制文件的生成目录为bin_x86;如果确定的目标应用的待编译的目标版本为Aarch64版本,则可以进一步确定Aarch64架构的目标平台的二进制文件的依赖库的保存目录为lib_arm64,Aarch64架构的目标平台的二进制文件的生成目录为bin_arm64。For example, if the target version to be compiled of the determined target application is the x86 version, it can be further determined that the storage directory of the dependent library of the binary file of the target platform of the x86 architecture is lib_x86, and the generation directory of the binary file of the target platform of the x86 architecture is bin_x86; if the target version to be compiled of the determined target application is the Aarch64 version, it can be further determined that the storage directory of the dependent library of the binary file of the target platform of the Aarch64 architecture is lib_arm64, and the generation directory of the binary file of the target platform of the Aarch64 architecture is bin_arm64.
S130:引入目标应用的与目标平台对应的汇编代码。S130: The assembly code corresponding to the target platform of the target application is introduced.
目标应用的与目标平台对应的汇编代码可以由技术人员预先编写完成。在确定目标应用的待编译的目标版本,确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录之后,可以引入目标应用的与目标平台对应的汇编代码。The assembly code corresponding to the target platform of the target application can be pre-written by a technician. After determining the target version of the target application to be compiled, the storage directory of the dependency library of the target platform binary file and the generation directory of the target platform binary file, the assembly code of the target application corresponding to the target platform can be imported.
S140:调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,以基于目标应用的二进制文件,在目标平台上运行目标应用。S140: Invoke a preset compiling tool to compile the platform source code including the assembly code, obtain a binary file of the target application, and run the target application on the target platform based on the binary file of the target application.
在实际应用中,可以预先设定待使用的编译工具,如设定编译工具为GCC(GNUCompiler Collection,GNU编译器套件)编译工具。调用预设的编译工具对包含汇编代码的平台源代码进行编译,可以获得目标应用的二进制文件,该二进制文件即为目标应用在目标平台上的可执行程序。基于目标应用的二进制文件,即可在目标平台上运行目标应用。In practical applications, the compilation tool to be used may be preset, for example, the compilation tool is set as a GCC (GNU Compiler Collection, GNU Compiler Suite) compilation tool. Calling the preset compilation tool to compile the platform source code including the assembly code, the binary file of the target application can be obtained, and the binary file is the executable program of the target application on the target platform. Based on the binary file of the target application, the target application can be run on the target platform.
获得的目标应用的二进制文件可以存储于之前确定的目标平台的二进制文件的生成目录中,在二进制文件的文件名中可以标记编译时间等信息,以便于后期查找。The obtained binary file of the target application may be stored in the generation directory of the binary file of the previously determined target platform, and information such as compilation time may be marked in the file name of the binary file to facilitate later search.
目标应用的二进制文件的依赖库存储于之前确定的目标平台的二进制文件的依赖库的保存目录中,以便运行二进制文件时调用。The dependency library of the binary file of the target application is stored in the storage directory of the dependency library of the binary file of the target platform determined before, so that the binary file can be called when running the binary file.
应用本发明实施例所提供的方法,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,并进一步确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录,引入目标应用的与目标平台对应的汇编代码,调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,这样可以基于目标应用的二进制文件,在目标平台上运行目标应用。即要将应用从第一个架构的平台移植到第二个架构的平台上运行时,利用宏开关的方式决定,决定对目标应用的包含与第二个架构的平台对应的汇编代码的平台源代码进行编译,使得编译出来的执行程序为第二个架构的平台下的可执行程序。对于目标应用的依赖于不同运行环境硬件架构的代码进行单独维护,对于目标应用的不依赖于运行环境硬件架构的代码可以只维护一份,这样在有针对不依赖于运行环境硬件架构的代码的更新时,只需要更新一次即可。可维护性较强,提高了代码维护的便利性,降低了人力成本。Using the method provided by the embodiment of the present invention, according to the pre-imported environment variables and the macros required for compilation, determine the target version of the target application to be compiled, and further determine the storage directory of the dependency library of the binary file of the target platform and the target platform The generation directory of the binary file of the target application, import the assembly code corresponding to the target platform of the target application, call the preset compilation tool to compile the platform source code containing the assembly code, and obtain the binary file of the target application, which can be based on the target application. file to run the target application on the target platform. That is, when the application is to be migrated from the platform of the first architecture to the platform of the second architecture, the macro switch is used to determine the platform source of the target application that contains the assembly code corresponding to the platform of the second architecture. The code is compiled, so that the compiled executable program is an executable program under the platform of the second architecture. The code of the target application that depends on the hardware architecture of different operating environments can be maintained separately, and only one copy of the code of the target application that does not depend on the hardware architecture of the operating environment can be maintained. When updating, it only needs to be updated once. The maintainability is strong, which improves the convenience of code maintenance and reduces labor costs.
本发明实施例所提供的技术方案增强了应用的可扩展性,如果需要将应用移植到新的架构的目标平台上运行,那么开发人员只需要编写出目标平台的环境构建脚本,重写依赖于新的架构的汇编代码并用宏开关控制是否编译即可,使得一份代码可以编译出多个平台对应的运行程序。The technical solution provided by the embodiment of the present invention enhances the scalability of the application. If the application needs to be transplanted to run on the target platform of the new architecture, the developer only needs to write the environment construction script of the target platform, and the rewrite depends on the target platform. The assembly code of the new architecture can be compiled or not controlled by the macro switch, so that a code can be compiled to run programs corresponding to multiple platforms.
在本发明的一个实施例中,目标应用为网络基础平台NFP应用、目标版本为Aarch64版本、目标平台为Aarch64架构平台,NFP应用部署于用户空间,该方法还可以包括以下步骤:In one embodiment of the present invention, the target application is a network infrastructure platform NFP application, the target version is an Aarch64 version, the target platform is an Aarch64 architecture platform, and the NFP application is deployed in the user space, and the method may further include the following steps:
步骤一:在Aarch64架构平台上运行NFP应用过程中,如果NFP应用的数据面的收发包模块检测到待发送的目标数据包,则通过收发包模块对目标数据包的包头空间进行扩充处理,获得预留空间;Step 1: During the process of running the NFP application on the Aarch64 architecture platform, if the transceiver packet module of the data plane of the NFP application detects the target data packet to be sent, the packet header space of the target data packet is expanded by the transceiver packet module to obtain Reserved space;
步骤二:调用Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去,以在内核模块将在预留空间填充交换标签的目标数据包发送给Marvell交换芯片后,Marvell交换芯片通过交换标签,确定用于传输目标数据包的网口。Step 2: Call the kernel function interface of the kernel space of the Aarch64 architecture platform to send the expanded target data packet, so that after the kernel module sends the target data packet filled with the switching label in the reserved space to the Marvell switch chip, Marvell The switch chip determines the network port for transmitting the target data packet by exchanging the label.
为便于描述,将上述两个步骤结合起来进行说明。For the convenience of description, the above two steps are combined for description.
在本发明实施例中,目标应用可以为网络基础平台NFP应用,NFP为一款网络功能基础平台,该平台实现的优点是高性能、成熟的技术,其模块化和灵活性以及丰富的功能集,可以适配不同的产品线供其搭建网络基础平台。In the embodiment of the present invention, the target application may be a network basic platform NFP application, and NFP is a network function basic platform. The advantages of this platform are high performance and mature technology, its modularity and flexibility, and its rich function set. , which can be adapted to different product lines for building a basic network platform.
目标版本可以为Aarch64版本,目标平台为Aarch64架构平台,如Marvell家庭交换机为基础的硬件平台,即属于Aarch64架构。The target version can be an Aarch64 version, and the target platform is an Aarch64 architecture platform, such as a hardware platform based on a Marvell home switch, which belongs to the Aarch64 architecture.
目前,大多数产品架构是基于Linux内核转发模式,这种模式存在一定的问题,首先是性能问题,其存在性能瓶颈,无法满足新业务的发展需求,其次是可靠性问题,运行在内核态的进程一旦执行失败,将会引起业务中断。基于这两方面的问题,目前业界公认的一个演进趋势是在用户空间利用自身提供的数据平面来收发数据包,绕过Linux内核协议栈对数据包的处理,以解决传统Linux内核转发的性能和可靠性问题。At present, most product architectures are based on the Linux kernel forwarding mode. This mode has certain problems. The first is the performance problem, which has performance bottlenecks and cannot meet the development needs of new services. The second is the reliability problem. Once the process fails to execute, it will cause business interruption. Based on these two problems, an evolution trend recognized by the industry is to use the data plane provided by itself to send and receive data packets in user space, bypassing the processing of data packets by the Linux kernel protocol stack, so as to solve the performance and performance of traditional Linux kernel forwarding. reliability issues.
鉴于以上问题,网络基础平台NFP应用应运而生,其数据面是基于VPP研发的可扩展框架。VPP(Vector Packet Processing,矢量数据包处理)平台是一个可扩展的框架,提供开箱即用的交换机/路由器功能。但是现有的NFP应用只支持运行于x86架构的硬件平台下,并不支持运行在ARM硬件平台下,致使大多数ARM硬件平台仍然采用Linux的内核作为转发业务的支撑,导致业务发展受到性能制约。In view of the above problems, the network infrastructure platform NFP application emerges as the times require, and its data plane is an extensible framework based on VPP research and development. The VPP (Vector Packet Processing) platform is an extensible framework that provides out-of-the-box switch/router functionality. However, the existing NFP applications only support running on the hardware platform of the x86 architecture, and do not support running on the ARM hardware platform. As a result, most ARM hardware platforms still use the Linux kernel as the support for forwarding services, resulting in performance constraints on business development. .
本发明实施将网络基础平台NFP应用部署于用户空间,在Aarch64架构的平台上运行。即通过利用Aarch64架构下的指令集,对网络基础平台NFP应用的依赖于架构部分的代码进行重写,然后对相应代码进行编译可以使得网络基础平台NFP运行于Aarch64架构的平台上。The implementation of the present invention deploys the network basic platform NFP application in the user space and runs on the platform of the Aarch64 architecture. That is, by using the instruction set under the Aarch64 architecture to rewrite the architecture-dependent code of the NFP application of the network infrastructure platform, and then compiling the corresponding code, the network infrastructure platform NFP can run on the platform of the Aarch64 architecture.
在Aarch64架构平台上运行NFP应用过程中,NFP应用的数据面的收发包模块可以执行实时检测,具体的,可以对用户空间的发送缓冲区进行检测,如果用户空间的发送缓冲区中存在数据包,则可以选择一个数据包作为待发送的目标数据包。收发包模块具体可以是Netmap模块,Netmap是一款用于处理高速I/O的框架,其被实现成为单个的内核模块,可用于FreeBSD、Linux和Windows。Netmap支持访问网卡、虚拟接口和Netmap管道,可以轻松达到10G网卡的线速速率。In the process of running the NFP application on the Aarch64 architecture platform, the sending and receiving module of the data plane of the NFP application can perform real-time detection. Specifically, it can detect the sending buffer of the user space. If there are data packets in the sending buffer of the user space , you can select a data packet as the target data packet to be sent. Specifically, the module for sending and receiving packets can be a Netmap module. Netmap is a framework for processing high-speed I/O. It is implemented as a single kernel module and can be used in FreeBSD, Linux and Windows. Netmap supports access to network cards, virtual interfaces and Netmap pipes, which can easily reach the wire-speed rate of 10G network cards.
在检测到待发送的目标数据包后,可以通过收发包模块对目标数据包的包头空间进行扩充处理,获得预留空间。具体的,可以根据具体的网络协议,在目标数据包的包头中预留4或8个字节的空间。After detecting the target data packet to be sent, the packet header space of the target data packet can be expanded and processed by the sending and receiving packet module to obtain the reserved space. Specifically, a space of 4 or 8 bytes may be reserved in the header of the target data packet according to a specific network protocol.
对目标数据包的包头空间进行扩充处理后,可以调用目标平台,即Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去。这样,内核模块可以在目标数据包的预留空间中填充交换标签DSA TAG。然后将填充有交换标签的目标数据包发送给Marvell交换芯片,Marvell交换芯片对该交换标签进行识别,可以确定用于传输目标数据包的网口,即确定通过哪一个网口将目标数据包传输出去。DSA TAG的全称为DSA Switch Tag。DSA(Distributed Switch Architecture,分布式交换架构)是Marvell家庭交换机的一种术语,DSA技术使得设备之间通过级联的方式组成一个大型交换网络,最大程度上加速报文的转发和处理。After expanding the header space of the target data packet, the target platform, that is, the kernel function interface of the kernel space of the Aarch64 architecture platform, can be called to send the expanded target data packet. In this way, the kernel module can fill the DSA TAG in the reserved space of the target packet. Then, the target data packet filled with the switching label is sent to the Marvell switching chip. The Marvell switching chip identifies the switching label and can determine the network port used to transmit the target data packet, that is, determine which network port to transmit the target data packet through. go out. The full name of DSA TAG is DSA Switch Tag. DSA (Distributed Switch Architecture) is a term for Marvell home switches. The DSA technology enables devices to form a large-scale switching network in a cascaded manner, which speeds up packet forwarding and processing to the greatest extent.
Marvell家庭交换机的硬件框架特点在于数据包从以太网控制器流出后并没有直接流向网口,而是流向了Marvell交换芯片,在Marvell交换芯片中通过解析数据包的交换标签DSA TAG来决定数据流的具体走向,即从哪一个网口发送。The hardware framework of Marvell's home switch is characterized in that the data packet does not flow directly to the network port after flowing out of the Ethernet controller, but flows to the Marvell switch chip. In the Marvell switch chip, the data flow is determined by parsing the switch label DSA TAG of the data packet. The specific direction, that is, which network port to send from.
本发明实施例较好地解决了如下技术问题:目前Netmap驱动并不支持交换标签DSA TAG特性,因此在使用原生的Netmap作为收发包模块,有数据包发送时,数据包经过Netmap发送至内核模块后,内核模块补充DSA TAG标记在以太网帧中,而数据包却并没有预留出空间来填写DSA TAG,因此内核模块在扩充数据包的包头来填充DSA TAG时,会发生宕机。The embodiments of the present invention better solve the following technical problems: at present, the Netmap driver does not support the switch tag DSA TAG feature. Therefore, when the native Netmap is used as the module for sending and receiving packets, when data packets are sent, the data packets are sent to the kernel module through Netmap. After that, the kernel module adds the DSA TAG tag in the Ethernet frame, but the data packet does not reserve space to fill in the DSA TAG, so the kernel module will crash when expanding the header of the data packet to fill the DSA TAG.
如图2所示,NFP应用部署于用户空间,有数据平面和多个控制平面,数据包从数据平面,Netmap模块检测用户空间的发送缓冲区,确定是否有数据包要发送,如果有,则可以将待发送的数据包进行扩充处理,放入Netmap队列中,然后调用内核空间的内核函数接口发送数据包,数据包经过Netmap模块发送至内核空间后,内核模块会在数据包包头的预留空间中填充交换标签,基于主机协议栈Host stack放入网卡队列,经由以太网控制器流出,流向Marvell交换芯片,Marvell交换芯片对交换标签进行识别,可以确定数据流的具体走向,即通过哪个网口发送,如通过Port1、Port2等。As shown in Figure 2, NFP applications are deployed in user space, with data plane and multiple control planes. Data packets are sent from data plane. Netmap module detects the send buffer of user space to determine whether there are data packets to be sent. If so, then The data packets to be sent can be expanded and placed in the Netmap queue, and then the kernel function interface of the kernel space can be called to send the data packets. After the data packets are sent to the kernel space through the Netmap module, the kernel module will reserve the header of the data packet. The space is filled with switching labels, which are put into the network card queue based on the host protocol stack Host stack, flow out through the Ethernet controller, and flow to the Marvell switching chip. The Marvell switching chip identifies the switching label and can determine the specific direction of the data flow, that is, which network port, such as through Port1, Port2, etc.
在本发明的一个实施例中,在上述步骤一之后、步骤二之前,该方法还可以包括以下步骤:In an embodiment of the present invention, after the first step and before the second step, the method may further include the following steps:
对目标数据包添加扩充标记;Add an extension tag to the target packet;
在步骤二之后,该方法还可以包括以下步骤:After the second step, the method may further include the following steps:
如果检测到发送失败的数据包、且该数据包存在扩充标记,则对该数据包进行回收处理。If a data packet that fails to be sent is detected and the data packet has an extension mark, the data packet is recycled.
在本发明实施例中,通过收发包模块对目标数据包的包头空间进行扩充处理之后,可以对目标数据包添加扩充标记,具体的,可以通过目标数据包的文件名进行添加。这样,在调用目标平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去之后,如果检测到发送失败的数据包、且确定该数据包存在扩充标记,则可以对该数据包进行回收处理。In the embodiment of the present invention, after the packet header space of the target data packet is expanded by the sending and receiving module, the expansion mark may be added to the target data packet, and specifically, the addition may be performed by the file name of the target data packet. In this way, after calling the kernel function interface of the kernel space of the target platform to send the expanded target data packet, if the data packet that fails to be sent is detected and it is determined that the data packet has an expansion mark, the data packet can be sent out. for recycling.
因为进行扩充处理的数据包的包头存在预留空间,这样的数据包传送给其他模块,不会被正确解析,所以,当检测到发送失败的数据包,且该数据包中存在扩充标记时,可以对该数据包进行回收处理,如删除,以释放数据包空间。Because there is reserved space in the header of the data packet for expansion processing, such a data packet will not be correctly parsed when it is transmitted to other modules. The packet can be recycled, such as deleted, to free up packet space.
参见图3所示,为本发明实施例所提供的一种应用运行方法的实施流程图,该方法可以包括以下步骤:Referring to FIG. 3, it is an implementation flowchart of an application running method provided by an embodiment of the present invention, and the method may include the following steps:
S310:在目标平台上运行目标应用过程中,如果目标应用检测到有待发送的目标数据包,则对目标数据包的包头空间进行扩充处理,获得预留空间。S310 : During the process of running the target application on the target platform, if the target application detects a target data packet to be sent, it expands the header space of the target data packet to obtain a reserved space.
在本发明实施例中,目标应用可以部署于目标平台的用户空间,在目标平台上运行目标应用过程中,目标应用的数据面的收发包模块可以执行实时检测,具体的,可以对用户空间的发送缓冲区进行检测,如果用户空间的发送缓冲区中存在数据包,则可以选择一个数据包作为待发送的目标数据包。收发包模块具体可以是Netmap模块,Netmap是一款用于处理高速I/O的框架,其被实现成为单个的内核模块,可用于FreeBSD、Linux和Windows。Netmap支持访问网卡、虚拟接口和Netmap管道,可以轻松达到10G网卡的线速速率。In this embodiment of the present invention, the target application may be deployed in the user space of the target platform, and during the process of running the target application on the target platform, the sending and receiving module of the data plane of the target application may perform real-time detection. The sending buffer is used for detection. If there is a data packet in the sending buffer of the user space, a data packet can be selected as the target data packet to be sent. Specifically, the module for sending and receiving packets can be a Netmap module. Netmap is a framework for processing high-speed I/O. It is implemented as a single kernel module and can be used in FreeBSD, Linux and Windows. Netmap supports access to network cards, virtual interfaces and Netmap pipes, which can easily reach the wire-speed rate of 10G network cards.
在检测到待发送的目标数据包后,可以通过收发包模块对目标数据包的包头空间进行扩充处理,获得预留空间。具体的,可以根据具体的网络协议,在目标数据包的包头中预留4或8个字节的空间。After detecting the target data packet to be sent, the packet header space of the target data packet can be expanded and processed by the sending and receiving packet module to obtain the reserved space. Specifically, a space of 4 or 8 bytes may be reserved in the header of the target data packet according to a specific network protocol.
在本发明实施例中,目标平台可以为Aarch64架构平台,目标应用可以为网络基础平台NFP应用。In this embodiment of the present invention, the target platform may be an Aarch64 architecture platform, and the target application may be a network basic platform NFP application.
S320:调用目标平台的内核函数接口将进行扩充处理后的目标数据包发送出去,以在内核模块将在预留空间填充交换标签的目标数据包发送给交换芯片后,交换芯片通过交换标签,确定用于传输目标数据包的网口。S320 : calling the kernel function interface of the target platform to send the expanded target data packet, so that after the kernel module sends the target data packet filled with the switch label in the reserved space to the switch chip, the switch chip determines by exchanging the label The network port used to transmit target data packets.
对目标数据包的包头空间进行扩充处理后,可以调用目标平台,即Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去。这样,内核模块可以在目标数据包的预留空间中填充交换标签DSA TAG。然后将填充有交换标签的目标数据包发送给交换芯片,如Marvell交换芯片,Marvell交换芯片对该交换标签进行识别,可以确定用于传输目标数据包的网口,即确定通过哪一个网口将目标数据包传输出去。DSA TAG的全称为DSA Switch Tag。DSA(Distributed Switch Architecture,分布式交换架构)是Marvell家庭交换机的一种术语,DSA技术使得设备之间通过级联的方式组成一个大型交换网络,最大程度上加速报文的转发和处理。After expanding the header space of the target data packet, the target platform, that is, the kernel function interface of the kernel space of the Aarch64 architecture platform, can be called to send the expanded target data packet. In this way, the kernel module can fill the DSA TAG in the reserved space of the target packet. Then, the target data packet filled with the switching label is sent to the switching chip, such as the Marvell switching chip. The Marvell switching chip identifies the switching label and can determine the network port used to transmit the target data packet, that is, determine which network port to use to transmit the target data packet. The destination packet is transmitted. The full name of DSA TAG is DSA Switch Tag. DSA (Distributed Switch Architecture) is a term for Marvell home switches. The DSA technology enables devices to form a large-scale switching network in a cascaded manner, which speeds up packet forwarding and processing to the greatest extent.
Marvell家庭交换机的硬件框架特点在于数据包从以太网控制器流出后并没有直接流向网口,而是流向了Marvell交换芯片,在Marvell交换芯片中通过解析数据包的交换标签DSA TAG来决定数据流的具体走向,即从哪一个网口发送。The hardware framework of Marvell's home switch is characterized in that the data packet does not flow directly to the network port after flowing out of the Ethernet controller, but flows to the Marvell switch chip. In the Marvell switch chip, the data flow is determined by parsing the switch label DSA TAG of the data packet. The specific direction, that is, which network port to send from.
应用本发明实施例所提供的方法,在目标平台上运行目标应用过程中,如果目标应用检测到有待发送的目标数据包,则先对目标数据包的包头空间进行扩充处理,获得预留空间,然后调用目标平台的内核函数接口将进行扩充处理后的目标数据包发送出去,这样,在内核模块将在预留空间填充交换标签的目标数据包发送给交换芯片后,交换芯片通过交换标签,可以确定用于传输目标数据包的网口。使得目标应用能够在目标平台上顺利运行。并且,较好的解决了目前Netmap驱动并不支持交换标签DSA TAG特性,因此在使用原生的Netmap作为收发包模块,有数据包发送时,数据包经过Netmap发送至内核模块后,内核模块补充DSA TAG标记在以太网帧中,而数据包却并没有预留出空间来填写DSA TAG,因此内核模块在扩充数据包的包头来填充DSA TAG时,会发生宕机的问题。Applying the method provided by the embodiment of the present invention, in the process of running the target application on the target platform, if the target application detects the target data packet to be sent, the header space of the target data packet is expanded and processed to obtain reserved space, Then call the kernel function interface of the target platform to send the expanded target data packet. In this way, after the kernel module sends the target data packet filled with the switching label in the reserved space to the switching chip, the switching chip can exchange the label. Determines the network port used to transmit the destination packet. The target application can run smoothly on the target platform. In addition, it better solves the problem that the current Netmap driver does not support the switch tag DSA TAG feature. Therefore, when using the native Netmap as the sending and receiving packet module, when a data packet is sent, after the data packet is sent to the kernel module through Netmap, the kernel module supplements the DSA. The TAG is marked in the Ethernet frame, but the data packet does not reserve space to fill in the DSA TAG, so the kernel module will crash when expanding the header of the data packet to fill the DSA TAG.
在本发明的一个实施例中,在步骤S310之后、S320之前,该方法还可以包括以下步骤:In an embodiment of the present invention, after step S310 and before step S320, the method may further include the following steps:
对目标数据包添加扩充标记;Add an extension tag to the target packet;
在步骤S320之后,该方法还可以包括以下步骤:After step S320, the method may further include the following steps:
如果检测到发送失败的数据包、且该数据包存在扩充标记,则对该数据包进行回收处理。If a data packet that fails to be sent is detected and the data packet has an extension mark, the data packet is recycled.
在本发明实施例中,通过收发包模块对目标数据包的包头空间进行扩充处理之后,可以对目标数据包添加扩充标记,具体的,可以通过目标数据包的文件名进行添加。这样,在调用目标平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去之后,如果检测到发送失败的数据包、且确定该数据包存在扩充标记,则可以对该数据包进行回收处理。In the embodiment of the present invention, after the packet header space of the target data packet is expanded by the sending and receiving module, the expansion mark may be added to the target data packet, and specifically, the addition may be performed by the file name of the target data packet. In this way, after calling the kernel function interface of the kernel space of the target platform to send the expanded target data packet, if the data packet that fails to be sent is detected and it is determined that the data packet has an expansion mark, the data packet can be sent out. for recycling.
因为进行扩充处理的数据包的包头存在预留空间,这样的数据包传送给其他模块,不会被正确解析,所以,当检测到发送失败的数据包,且该数据包中存在扩充标记时,可以对该数据包进行回收处理,如删除,以释放数据包空间。Because there is reserved space in the header of the data packet for expansion processing, such a data packet will not be correctly parsed when it is transmitted to other modules. The packet can be recycled, such as deleted, to free up packet space.
在本发明的一个实施例中,该方法还可以包括以下步骤:In one embodiment of the present invention, the method may further include the following steps:
步骤一:在达到预设的版本编译触发条件时,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,目标版本为与待运行目标应用的目标平台对应的版本;Step 1: When the preset version compilation trigger condition is reached, the target version of the target application to be compiled is determined according to the pre-imported environment variables and the macros required for compilation, and the target version is the target version corresponding to the target platform of the target application to be run. Version;
步骤二:确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录;Step 2: Determine the storage directory of the dependency library of the binary file of the target platform and the generation directory of the binary file of the target platform;
步骤三:引入目标应用的与目标平台对应的汇编代码;Step 3: Introduce the assembly code corresponding to the target platform of the target application;
步骤四:调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,以基于目标应用的二进制文件,在目标平台上运行目标应用。Step 4: Invoke a preset compiling tool to compile the platform source code including the assembly code, obtain the binary file of the target application, and run the target application on the target platform based on the binary file of the target application.
为便于描述,将上述四个步骤结合起来进行说明。For the convenience of description, the above four steps are combined for description.
在本发明实施例中,可以预先设定一个版本编译触发条件,如在接收到编译指令时,认为达到了预设的版本编译触发条件,或者,在检测到汇编代码有更新时,认为达到了预设的版本编译触发条件。In the embodiment of the present invention, a version compilation trigger condition may be preset. For example, when a compilation instruction is received, it is considered that the preset version compilation trigger condition is reached, or when an update of the assembly code is detected, it is considered that the predetermined version compilation trigger condition is reached. Preset version build trigger conditions.
在达到预设的版本编译触发条件时,可以先获得预先导入的环境变量和编译所需要的宏。在实际应用中,在编译准备阶段,可以根据目标应用的待编译的版本,执行该版本的环境构建脚本,导入编译该版本运行程序所需要的环境变量和编译所需要的宏。如,如果目标应用的待编译的版本为x86版本,则执行x86版本的环境构建脚本,导入编译x86版本运行程序所需的环境变量和编译所需要的宏;如果目标应用的待编译的版本为Aarch64版本,则执行Aarch64版本的环境构建脚本,导入编译Aarch64版本运行程序所需的环境变量和编译所需要的宏;如果目标应用的待编译的版本为其他版本,则执行该其他版本的环境构建脚本,导入编译该其他版本运行程序所需的环境变量和编译所需要的宏。When the preset version compilation trigger condition is reached, the pre-imported environment variables and the macros required for compilation can be obtained first. In practical applications, in the compilation preparation stage, the environment build script of the version can be executed according to the version to be compiled of the target application, and the environment variables and macros required for compiling the running program of this version are imported. For example, if the version to be compiled of the target application is the x86 version, execute the environment build script of the x86 version, import the environment variables required to compile the x86 version running program and the macros required for compilation; if the version to be compiled of the target application is For the Aarch64 version, execute the environment build script of the Aarch64 version, import the environment variables required to compile the Aarch64 version running program and the macros required for compilation; if the version to be compiled of the target application is another version, execute the environment build of the other version script, import the environment variables required to compile the other version of the running program and the macros required for compilation.
根据预先导入的环境变量和编译所需要的宏,可以确定目标应用的待编译的目标版本,该目标版本为与待运行目标应用的目标平台对应的版本。可以是x86版本,还可以是Aarch64版本,当然,还可以为其他版本。According to the pre-imported environment variables and the macros required for compilation, the target version of the target application to be compiled can be determined, and the target version is the version corresponding to the target platform of the target application to be run. It can be an x86 version, an Aarch64 version, or, of course, other versions.
确定目标应用的待编译的目标版本后,可以进一步确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录。编译出不同架构的平台对应的代码,其依赖库、环境变量和宏各不相同,所以不同架构的目标平台对应的二进制文件的依赖库的保存目录和二进制文件的生成目录不同。After the target version of the target application to be compiled is determined, the storage directory of the dependent library of the binary file of the target platform and the generation directory of the binary file of the target platform can be further determined. The code corresponding to the platforms of different architectures is compiled, and the dependent libraries, environment variables and macros are different. Therefore, the storage directories of the dependent libraries of the binary files corresponding to the target platforms of different architectures and the generation directory of the binary files are different.
如,如果确定的目标应用的待编译的目标版本为x86版本,则可以进一步确定x86架构的目标平台的二进制文件的依赖库的保存目录为lib_x86,x86架构的目标平台的二进制文件的生成目录为bin_x86;如果确定的目标应用的待编译的目标版本为Aarch64版本,则可以进一步确定Aarch64架构的目标平台的二进制文件的依赖库的保存目录为lib_arm64,Aarch64架构的目标平台的二进制文件的生成目录为bin_arm64。For example, if the target version to be compiled of the determined target application is the x86 version, it can be further determined that the storage directory of the dependent library of the binary file of the target platform of the x86 architecture is lib_x86, and the generation directory of the binary file of the target platform of the x86 architecture is bin_x86; if the target version to be compiled of the determined target application is the Aarch64 version, it can be further determined that the storage directory of the dependent library of the binary file of the target platform of the Aarch64 architecture is lib_arm64, and the generation directory of the binary file of the target platform of the Aarch64 architecture is bin_arm64.
目标应用的与目标平台对应的汇编代码可以由技术人员预先编写完成。在确定目标应用的待编译的目标版本,确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录之后,可以引入目标应用的与目标平台对应的汇编代码。The assembly code corresponding to the target platform of the target application can be pre-written by a technician. After determining the target version of the target application to be compiled, the storage directory of the dependency library of the target platform binary file and the generation directory of the target platform binary file, the assembly code of the target application corresponding to the target platform can be imported.
在实际应用中,可以预先设定待使用的编译工具,如设定编译工具为GCC(GNUCompiler Collection,GNU编译器套件)编译工具。调用预设的编译工具对包含汇编代码的平台源代码进行编译,可以获得目标应用的二进制文件,该二进制文件即为目标应用在目标平台上的可执行程序。基于目标应用的二进制文件,即可在目标平台上运行目标应用。In practical applications, the compilation tool to be used may be preset, for example, the compilation tool is set as a GCC (GNU Compiler Collection, GNU Compiler Suite) compilation tool. Calling the preset compilation tool to compile the platform source code including the assembly code, the binary file of the target application can be obtained, and the binary file is the executable program of the target application on the target platform. Based on the binary file of the target application, the target application can be run on the target platform.
获得的目标应用的二进制文件可以存储于之前确定的目标平台的二进制文件的生成目录中,在二进制文件的文件名中可以标记编译时间等信息,以便于后期查找。The obtained binary file of the target application may be stored in the generation directory of the binary file of the previously determined target platform, and information such as compilation time may be marked in the file name of the binary file to facilitate later search.
目标应用的二进制文件的依赖库存储于之前确定的目标平台的二进制文件的依赖库的保存目录中,以便运行二进制文件时调用。The dependency library of the binary file of the target application is stored in the storage directory of the dependency library of the binary file of the target platform determined before, so that the binary file can be called when running the binary file.
根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,并进一步确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录,引入目标应用的与目标平台对应的汇编代码,调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,这样可以基于目标应用的二进制文件,在目标平台上运行目标应用。即要将应用从第一个架构的平台移植到第二个架构的平台上运行时,利用宏开关的方式决定,决定对目标应用的包含与第二个架构的平台对应的汇编代码的平台源代码进行编译,使得编译出来的执行程序为第二个架构的平台下的可执行程序。对于目标应用的依赖于不同运行环境硬件架构的代码进行单独维护,对于目标应用的不依赖于运行环境硬件架构的代码可以只维护一份,这样在有针对不依赖于运行环境硬件架构的代码的更新时,只需要更新一次即可。可维护性较强,提高了代码维护的便利性,降低了人力成本。According to the pre-imported environment variables and the macros required for compilation, determine the target version of the target application to be compiled, and further determine the storage directory of the dependent library of the target platform's binary files and the generation directory of the target platform's binary files, and introduce the target application. The assembly code corresponding to the target platform is called, the preset compilation tool is called to compile the platform source code containing the assembly code, and the binary file of the target application is obtained, so that the target application can be run on the target platform based on the binary file of the target application. That is, when the application is to be migrated from the platform of the first architecture to the platform of the second architecture, the macro switch is used to determine the platform source of the target application that contains the assembly code corresponding to the platform of the second architecture. The code is compiled, so that the compiled executable program is an executable program under the platform of the second architecture. The code of the target application that depends on the hardware architecture of different operating environments can be maintained separately, and only one copy of the code of the target application that does not depend on the hardware architecture of the operating environment can be maintained. When updating, it only needs to be updated once. The maintainability is strong, which improves the convenience of code maintenance and reduces labor costs.
相应于上面图1所示的方法实施例,本发明实施例还提供了一种应用运行装置,下文描述的一种应用运行装置与上文描述的一种应用运行方法可相互对应参照。Corresponding to the method embodiment shown in FIG. 1 above, an embodiment of the present invention further provides an application running apparatus, and an application running apparatus described below and an application running method described above may refer to each other correspondingly.
参见图4所示,该装置包括以下单元:Referring to Figure 4, the device includes the following units:
版本确定单元410,用于在达到预设的版本编译触发条件时,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,目标版本为与待运行目标应用的目标平台对应的版本;The
目录确定单元420,用于确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录;A
代码引入单元430,用于引入目标应用的与目标平台对应的汇编代码;a
代码编译单元440,用于调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,以基于目标应用的二进制文件,在目标平台上运行目标应用。The
应用本发明实施例所提供的装置,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,并进一步确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录,引入目标应用的与目标平台对应的汇编代码,调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,这样可以基于目标应用的二进制文件,在目标平台上运行目标应用。即要将应用从第一个架构的平台移植到第二个架构的平台上运行时,利用宏开关的方式决定,决定对目标应用的包含与第二个架构的平台对应的汇编代码的平台源代码进行编译,使得编译出来的执行程序为第二个架构的平台下的可执行程序。对于目标应用的依赖于不同运行环境硬件架构的代码进行单独维护,对于目标应用的不依赖于运行环境硬件架构的代码可以只维护一份,这样在有针对不依赖于运行环境硬件架构的代码的更新时,只需要更新一次即可。可维护性较强,提高了代码维护的便利性,降低了人力成本。Using the device provided by the embodiment of the present invention, according to the pre-imported environment variables and the macros required for compilation, the target version to be compiled of the target application is determined, and the storage directory of the dependency library of the binary file of the target platform and the target platform are further determined. The generation directory of the binary file of the target application, import the assembly code corresponding to the target platform of the target application, call the preset compilation tool to compile the platform source code containing the assembly code, and obtain the binary file of the target application, which can be based on the target application. file to run the target application on the target platform. That is, when the application is to be migrated from the platform of the first architecture to the platform of the second architecture, the macro switch is used to determine the platform source of the target application that contains the assembly code corresponding to the platform of the second architecture. The code is compiled, so that the compiled executable program is an executable program under the platform of the second architecture. The code of the target application that depends on the hardware architecture of different operating environments can be maintained separately, and only one copy of the code of the target application that does not depend on the hardware architecture of the operating environment can be maintained. When updating, it only needs to be updated once. The maintainability is strong, which improves the convenience of code maintenance and reduces labor costs.
在本发明的一种具体实施方式中,目标版本为x86版本或者Aarch64版本。In a specific implementation manner of the present invention, the target version is an x86 version or an Aarch64 version.
在本发明的一种具体实施方式中,目标应用为网络基础平台NFP应用、目标版本为Aarch64版本、目标平台为Aarch64架构平台,NFP应用部署于用户空间,装置还包括:In a specific embodiment of the present invention, the target application is a network basic platform NFP application, the target version is an Aarch64 version, the target platform is an Aarch64 architecture platform, the NFP application is deployed in the user space, and the device further includes:
扩充单元,用于在Aarch64架构平台上运行NFP应用过程中,如果NFP应用的数据面的收发包模块检测到待发送的目标数据包,则通过收发包模块对目标数据包的包头空间进行扩充处理,获得预留空间;The expansion unit is used to run the NFP application process on the Aarch64 architecture platform. If the transceiver packet module of the data plane of the NFP application detects the target data packet to be sent, the packet header space of the target data packet is expanded through the transceiver packet module. , get reserved space;
发送单元,用于调用Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去,以在内核模块将在预留空间填充交换标签的目标数据包发送给Marvell交换芯片后,Marvell交换芯片通过交换标签,确定用于传输目标数据包的网口。The sending unit is used to call the kernel function interface of the kernel space of the Aarch64 architecture platform to send the expanded target data packet, so that after the kernel module sends the target data packet filled with the switching label in the reserved space to the Marvell switch chip , the Marvell switching chip determines the network port used to transmit the target data packet by exchanging labels.
在本发明的一种具体实施方式中,还包括:In a specific embodiment of the present invention, it also includes:
标记单元:用于在通过收发包模块对目标数据包的包头空间进行扩充处理之后、调用Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去之前,对目标数据包添加扩充标记;Marking unit: After the packet header space of the target data packet is expanded and processed by the transceiver module, and the kernel function interface of the kernel space of the Aarch64 architecture platform is called to send the expanded target data packet, the target data packet is sent out. add extension tag;
回收单元,用于在调用Aarch64架构平台的内核空间的内核函数接口将进行扩充处理后的目标数据包发送出去之后,如果检测到发送失败的数据包、且该数据包存在扩充标记,则对该数据包进行回收处理。The recycling unit is used to send the expanded target data packet after calling the kernel function interface of the kernel space of the Aarch64 architecture platform. Packets are recycled.
在本发明的一种具体实施方式中,目标数据包为用户空间的发送缓冲区中的一个数据包。In a specific embodiment of the present invention, the target data packet is a data packet in the sending buffer of the user space.
相应于上面图3所示的方法实施例,本发明实施例还提供了一种应用运行装置,下文描述的一种应用运行装置与上文描述的一种应用运行方法可相互对应参照。Corresponding to the method embodiment shown in FIG. 3 above, an embodiment of the present invention further provides an application running device, and an application running device described below and an application running method described above may refer to each other correspondingly.
参见图5所示,该装置包括以下单元:Referring to Figure 5, the device includes the following units:
扩充单元510,用于在目标平台上运行目标应用过程中,如果目标应用检测到有待发送的目标数据包,则对目标数据包的包头空间进行扩充处理,获得预留空间;The
发送单元520,用于调用目标平台的内核函数接口将进行扩充处理后的目标数据包发送出去,以在内核模块将在预留空间填充交换标签的目标数据包发送给交换芯片后,交换芯片通过交换标签,确定用于传输目标数据包的网口。The sending
应用本发明实施例所提供的装置,在目标平台上运行目标应用过程中,如果目标应用检测到有待发送的目标数据包,则先对目标数据包的包头空间进行扩充处理,获得预留空间,然后调用目标平台的内核函数接口将进行扩充处理后的目标数据包发送出去,这样,在内核模块将在预留空间填充交换标签的目标数据包发送给交换芯片后,交换芯片通过交换标签,可以确定用于传输目标数据包的网口。使得目标应用能够在目标平台上顺利运行。并且,较好的解决了目前Netmap驱动并不支持交换标签DSA TAG特性,因此在使用原生的Netmap作为收发包模块,有数据包发送时,数据包经过Netmap发送至内核模块后,内核模块补充DSA TAG标记在以太网帧中,而数据包却并没有预留出空间来填写DSA TAG,因此内核模块在扩充数据包的包头来填充DSA TAG时,会发生宕机的问题。By applying the device provided by the embodiment of the present invention, in the process of running the target application on the target platform, if the target application detects the target data packet to be sent, the header space of the target data packet is expanded and processed to obtain the reserved space, Then call the kernel function interface of the target platform to send the expanded target data packet. In this way, after the kernel module sends the target data packet filled with the switching label in the reserved space to the switching chip, the switching chip can exchange the label. Determines the network port used to transmit the destination packet. The target application can run smoothly on the target platform. In addition, it better solves the problem that the current Netmap driver does not support the switch tag DSA TAG feature. Therefore, when using the native Netmap as the sending and receiving packet module, when a data packet is sent, after the data packet is sent to the kernel module through Netmap, the kernel module supplements the DSA. The TAG is marked in the Ethernet frame, but the data packet does not reserve space to fill in the DSA TAG, so the kernel module will crash when expanding the header of the data packet to fill the DSA TAG.
在本发明的一种具体实施方式中,还包括:In a specific embodiment of the present invention, it also includes:
标记单元,用于在对目标数据包的包头空间进行扩充处理之后、调用目标平台的内核函数接口将进行扩充处理后的目标数据包发送出去之前,对目标数据包添加扩充标记;The marking unit is used to add an expansion mark to the target data packet after the expansion processing is performed on the header space of the target data packet and before the target data packet after the expansion processing is sent out by calling the kernel function interface of the target platform;
回收单元,用于在调用目标平台的内核函数接口将进行扩充处理后的目标数据包发送出去之后,如果检测到发送失败的数据包、且该数据包存在扩充标记,则对该数据包进行回收处理。The recycling unit is used to recycle the data packet if it is detected that the data packet that fails to be sent is detected and the data packet has an expansion mark after calling the kernel function interface of the target platform to send the expanded target data packet. deal with.
在本发明的一种具体实施方式中,目标应用部署于目标平台的用户空间,目标数据包为用户空间的发送缓冲区中的一个数据包。In a specific embodiment of the present invention, the target application is deployed in the user space of the target platform, and the target data packet is a data packet in the sending buffer of the user space.
在本发明的一种具体实施方式中,目标平台为Aarch64架构平台,目标应用为网络基础平台NFP应用,交换芯片为Marvell交换芯片。In a specific embodiment of the present invention, the target platform is an Aarch64 architecture platform, the target application is a network basic platform NFP application, and the switching chip is a Marvell switching chip.
在本发明的一种具体实施方式中,还包括:In a specific embodiment of the present invention, it also includes:
版本确定单元,用于在达到预设的版本编译触发条件时,根据预先导入的环境变量和编译所需要的宏,确定目标应用的待编译的目标版本,目标版本为与待运行目标应用的目标平台对应的版本;The version determination unit is used to determine the target version to be compiled of the target application according to the pre-imported environment variables and the macros required for compilation when the preset version compilation trigger condition is reached, and the target version is the target of the target application to be run. The version corresponding to the platform;
目录确定单元,用于确定目标平台的二进制文件的依赖库的保存目录及目标平台的二进制文件的生成目录;The directory determination unit is used to determine the storage directory of the dependency library of the binary file of the target platform and the generation directory of the binary file of the target platform;
代码引入单元,用于引入目标应用的与目标平台对应的汇编代码;The code introduction unit is used to introduce the assembly code corresponding to the target platform of the target application;
代码编译单元,用于调用预设的编译工具对包含汇编代码的平台源代码进行编译,获得目标应用的二进制文件,以基于目标应用的二进制文件,在目标平台上运行目标应用。The code compiling unit is used for invoking a preset compiling tool to compile the platform source code including the assembly code, obtaining the binary file of the target application, and running the target application on the target platform based on the binary file of the target application.
在本发明的一种具体实施方式中,目标版本为x86版本或者Aarch64版本。In a specific implementation manner of the present invention, the target version is an x86 version or an Aarch64 version.
相应于上面的方法实施例,本发明实施例还提供了一种应用运行设备,如图6所示,包括:Corresponding to the above method embodiments, an embodiment of the present invention further provides an application running device, as shown in FIG. 6 , including:
存储器610,用于存储计算机程序;
处理器620,用于执行计算机程序时实现上述应用运行方法的步骤。The
相应于上面的方法实施例,本发明实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现上述应用运行方法的步骤。Corresponding to the above method embodiments, embodiments of the present invention further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above application running method are implemented.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts of the various embodiments may be referred to each other.
专业人员还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Professionals may further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two, in order to clearly illustrate the possibilities of hardware and software. Interchangeability, the above description has generally described the components and steps of each example in terms of functionality. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of the present invention.
结合本文中所公开的实施例描述的方法或算法的步骤可以直接用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of a method or algorithm described in conjunction with the embodiments disclosed herein may be directly implemented in hardware, a software module executed by a processor, or a combination of the two. A software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other in the technical field. in any other known form of storage medium.
本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的技术方案及其核心思想。应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以对本发明进行若干改进和修饰,这些改进和修饰也落入本发明权利要求的保护范围内。The principles and implementations of the present invention are described herein by using specific examples, and the descriptions of the above embodiments are only used to help understand the technical solutions and core ideas of the present invention. It should be pointed out that for those skilled in the art, without departing from the principle of the present invention, several improvements and modifications can also be made to the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
Claims (15)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910554939.5A CN112130859A (en) | 2019-06-25 | 2019-06-25 | An application running method, device, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910554939.5A CN112130859A (en) | 2019-06-25 | 2019-06-25 | An application running method, device, device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112130859A true CN112130859A (en) | 2020-12-25 |
Family
ID=73849125
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910554939.5A Pending CN112130859A (en) | 2019-06-25 | 2019-06-25 | An application running method, device, device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112130859A (en) |
Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5815415A (en) * | 1996-01-19 | 1998-09-29 | Bentley Systems, Incorporated | Computer system for portable persistent modeling |
US20070294682A1 (en) * | 2006-06-20 | 2007-12-20 | Demetriou Christopher G | Systems and methods for caching compute kernels for an application running on a parallel-processing computer system |
WO2009021371A1 (en) * | 2007-08-13 | 2009-02-19 | Zte Corporation | A method and a device for implementing pseudo wire emulation edge to edge |
CN102137182A (en) * | 2010-01-27 | 2011-07-27 | 广州盛华信息技术有限公司 | Method and system for downloading mobile phone user operation system |
CN102281191A (en) * | 2011-07-07 | 2011-12-14 | 武汉微创光电股份有限公司 | Multicast label switching method for uncompressed video |
CN102364433A (en) * | 2011-06-24 | 2012-02-29 | 浙大网新科技股份有限公司 | Method for realizing Wine construction tool transplanting on ARM (Advanced RISC Machines) processor |
CN102364442A (en) * | 2011-06-24 | 2012-02-29 | 浙大网新科技股份有限公司 | Method for transplanting Wine from x86 to advanced risc machine (ARM) platform |
CN103365665A (en) * | 2013-07-25 | 2013-10-23 | 成都品果科技有限公司 | Application program transplantation method based on virtual instruction |
US8953460B1 (en) * | 2012-12-31 | 2015-02-10 | Juniper Networks, Inc. | Network liveliness detection using session-external communications |
WO2015117419A1 (en) * | 2014-07-16 | 2015-08-13 | 中兴通讯股份有限公司 | Method and device for cross-platform transplantation of python program |
US9477461B1 (en) * | 2014-03-12 | 2016-10-25 | Cloud Linux Zug GmbH | Systems and methods for generating and applying operating system live updates |
CN106873771A (en) * | 2017-01-03 | 2017-06-20 | 杭州医学院 | A kind of Man Machine Interface system towards affection computation |
CN107608677A (en) * | 2017-09-05 | 2018-01-19 | 腾讯科技(深圳)有限公司 | A kind of process of compilation method, apparatus and electronic equipment |
-
2019
- 2019-06-25 CN CN201910554939.5A patent/CN112130859A/en active Pending
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5815415A (en) * | 1996-01-19 | 1998-09-29 | Bentley Systems, Incorporated | Computer system for portable persistent modeling |
US20070294682A1 (en) * | 2006-06-20 | 2007-12-20 | Demetriou Christopher G | Systems and methods for caching compute kernels for an application running on a parallel-processing computer system |
WO2009021371A1 (en) * | 2007-08-13 | 2009-02-19 | Zte Corporation | A method and a device for implementing pseudo wire emulation edge to edge |
CN102137182A (en) * | 2010-01-27 | 2011-07-27 | 广州盛华信息技术有限公司 | Method and system for downloading mobile phone user operation system |
CN102364442A (en) * | 2011-06-24 | 2012-02-29 | 浙大网新科技股份有限公司 | Method for transplanting Wine from x86 to advanced risc machine (ARM) platform |
CN102364433A (en) * | 2011-06-24 | 2012-02-29 | 浙大网新科技股份有限公司 | Method for realizing Wine construction tool transplanting on ARM (Advanced RISC Machines) processor |
CN102281191A (en) * | 2011-07-07 | 2011-12-14 | 武汉微创光电股份有限公司 | Multicast label switching method for uncompressed video |
US8953460B1 (en) * | 2012-12-31 | 2015-02-10 | Juniper Networks, Inc. | Network liveliness detection using session-external communications |
CN103365665A (en) * | 2013-07-25 | 2013-10-23 | 成都品果科技有限公司 | Application program transplantation method based on virtual instruction |
US9477461B1 (en) * | 2014-03-12 | 2016-10-25 | Cloud Linux Zug GmbH | Systems and methods for generating and applying operating system live updates |
WO2015117419A1 (en) * | 2014-07-16 | 2015-08-13 | 中兴通讯股份有限公司 | Method and device for cross-platform transplantation of python program |
CN106873771A (en) * | 2017-01-03 | 2017-06-20 | 杭州医学院 | A kind of Man Machine Interface system towards affection computation |
CN107608677A (en) * | 2017-09-05 | 2018-01-19 | 腾讯科技(深圳)有限公司 | A kind of process of compilation method, apparatus and electronic equipment |
Non-Patent Citations (4)
Title |
---|
刘跃生: "ARM自动编译工具的设计与开发", 中国优秀硕士论文 信息科技 * |
苏隆: "WLAN控制器中QoS子系统的设计与实现", 中国优秀硕士论文 信息科技 * |
袁学贵: "放疗运动控制系统的移植与改造方法研究及实践", 中国优秀硕士论文 信息科技 * |
韩大卫: "Marvell交换芯片DSA(分布式交换架构)功能介绍", Retrieved from the Internet <URL:《blog.csdn.net/han_dawei/article/details/8655671》> * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6832367B1 (en) | Method and system for recording and replaying the execution of distributed java programs | |
US6691303B2 (en) | Method and system of testing and verifying computer code in a multi-threaded environment | |
US10713213B2 (en) | Systems and methods for multi-architecture computing | |
US9411568B2 (en) | Asynchronous workflows | |
US20090193399A1 (en) | Performance improvements for nested virtual machines | |
US20180173674A1 (en) | Systems and methods for multi-architecture computing | |
US10303449B2 (en) | Compiling non-native constants | |
CN113805882A (en) | Method and device for developing application program, electronic equipment and storage medium | |
US20140040923A1 (en) | Automated Application Programming Interface (API) Generation | |
CN107577609A (en) | A kind of embedded system dynamic module adjustment method of Intrusion Detection based on host end dynamic link | |
CN113268239A (en) | Desktop application view construction method, device, equipment and storage medium | |
CN113791870A (en) | Fine-grained migration method and system for distributed system of WebAssembly virtual machine | |
CN111782730A (en) | File uploading method and device and storage medium | |
US7428729B2 (en) | Methods, systems, and computer program products for integrating legacy applications into a platform-independent environment | |
CN105335203A (en) | Binary translation execution method of shared libraries and device | |
CN107229506B (en) | A virtual machine migration method and device | |
US7296187B1 (en) | Hardware debug device having script-based host interface | |
CN112130859A (en) | An application running method, device, device and storage medium | |
US8806435B2 (en) | Remote logging mechanism | |
CN114168150B (en) | Application compilation method, device, electronic device and storage medium | |
WO2023083071A1 (en) | View interaction method and apparatus, electronic device, and computer readable medium | |
JP2000222242A (en) | Method and device for compilation and method and device for stack tracing | |
Wang et al. | DisTA: Generic dynamic taint tracking for java-based distributed systems | |
US11429358B2 (en) | Representing asynchronous state machine in intermediate code | |
CN107957902A (en) | A kind of high in the clouds Android running environment construction methods based on Unikernel |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20201225 |
|
RJ01 | Rejection of invention patent application after publication |