CN111800223B - Method, device and system for generating sending message and processing receiving message - Google Patents
Method, device and system for generating sending message and processing receiving message Download PDFInfo
- Publication number
- CN111800223B CN111800223B CN201910755214.2A CN201910755214A CN111800223B CN 111800223 B CN111800223 B CN 111800223B CN 201910755214 A CN201910755214 A CN 201910755214A CN 111800223 B CN111800223 B CN 111800223B
- Authority
- CN
- China
- Prior art keywords
- control information
- preset
- received message
- bytes
- check codes
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L1/00—Arrangements for detecting or preventing errors in the information received
- H04L1/004—Arrangements for detecting or preventing errors in the information received by using forward error control
- H04L1/0056—Systems characterized by the type of code used
- H04L1/0061—Error detection codes
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Communication Control (AREA)
Abstract
本发明公开了生成发送报文、处理接收报文的方法、装置和系统,涉及计算机技术领域。该方法的一具体实施方式包括:根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;根据所述控制信息的取值,选择对应校验码的生成方式;根据所述生成方式生成校验码;所述校验码的生成方式包括:采用中央处理器生成校验码、采用网卡生成校验码;根据所述输入数据和所述校验码,生成发送报文。该实施方式避免了现有技术采用硬件生成校验码时对硬件设备的要求高成本高、采用软件生成校验码时所消耗的时间成本高的技术缺陷,进而达到在降低生成校验码成本的同时,提高生成校验码的效率。
The invention discloses a method, device and system for generating sending messages and processing receiving messages, and relates to the technical field of computers. A specific implementation of the method includes: generating control information according to the relationship between the number of bytes of the input data and the number of preset check codes; selecting a corresponding check code generation method according to the value of the control information; Generate a check code according to the generation method; the generation method of the check code includes: using a central processing unit to generate a check code, using a network card to generate a check code; according to the input data and the check code, generating and sending message. This embodiment avoids the technical defects of high requirements on hardware equipment and high cost of hardware equipment when using hardware to generate check codes in the prior art, and high time and cost consumption when using software to generate check codes, thereby reducing the cost of generating check codes. At the same time, the efficiency of generating check codes is improved.
Description
技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种生成发送报文、处理接收报文的方法、装置和系统。The invention relates to the field of computer technology, in particular to a method, device and system for generating sending messages and processing receiving messages.
背景技术Background technique
报文在传输的过程中,需要确定预传输内容在传输过程中的准确性。故在报文生成的过程中需要添加校验码,用于后续传输后校验;在接收外部传输到报文时,需要对接收报文进行解析,用于进一步获取报文中的信息。During the transmission of the message, it is necessary to determine the accuracy of the pre-transmission content during transmission. Therefore, a check code needs to be added during the message generation process for subsequent post-transmission checks; when receiving externally transmitted messages, the received message needs to be parsed to further obtain information in the message.
在发送报文的过程中,现有技术采用利用CPU计算输入数据的校验码(也就是采用软件计算校验码),然后与输入数据进行组合传出;或通过高性能网卡计算校验码,再与输入数据进行组合传出。对应处理接收报文的方式与发送报文相对应。In the process of sending the message, the existing technology uses the CPU to calculate the check code of the input data (that is, the software calculates the check code), and then combines it with the input data to send out; or calculates the check code through a high-performance network card , and then combined with the input data and sent out. Correspondingly, the way of processing the received message is corresponding to that of the sent message.
在实现本发明过程中,发明人发现现有技术中至少存在如下问题:In the course of realizing the present invention, the inventor finds that there are at least the following problems in the prior art:
1.采用软件计算校验码,较大的消耗CPU的计算能力;1. Use software to calculate the check code, which consumes a lot of CPU computing power;
2.采用高性能网卡计算校验码,虽节约了CPU的计算力,但是需要专用的复杂的高性能网卡芯片实现,成本较高。2. Using a high-performance network card to calculate the check code saves the computing power of the CPU, but requires a dedicated and complex high-performance network card chip to implement, and the cost is relatively high.
发明内容Contents of the invention
有鉴于此,本发明实施例提供一种生成发送报文、处理接收报文的方法、装置和系统,能够避免现有技术采用硬件生成校验码时对硬件设备的要求高成本高、采用软件生成校验码时所消耗的时间成本高的技术缺陷,进而达到在降低生成校验码成本的同时,提高生成校验码的效率。In view of this, the embodiments of the present invention provide a method, device, and system for generating sent messages and processing received messages, which can avoid the high cost and high requirements for hardware equipment when using hardware to generate check codes in the prior art, and the use of software The technical defect of high time cost when generating the check code can further improve the efficiency of generating the check code while reducing the cost of generating the check code.
为实现上述目的,根据本发明实施例的一个方面,提供了一种生成发送报文的方法,包括:In order to achieve the above purpose, according to an aspect of the embodiments of the present invention, a method for generating a sending message is provided, including:
根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;Generate control information according to the relationship between the number of bytes of input data and the number of preset checksums;
根据所述控制信息的取值,选择对应校验码的生成方式;According to the value of the control information, select the generation method of the corresponding check code;
根据所述生成方式生成校验码;所述校验码的生成方式包括:采用中央处理器生成校验码、采用网卡生成校验码;Generate a check code according to the generation method; the generation method of the check code includes: using a central processing unit to generate a check code, and using a network card to generate a check code;
根据所述输入数据和所述校验码,生成发送报文。Generate a sending message according to the input data and the verification code.
可选地,所述控制信息的取值包括:第一控制信息值和第二控制信息值;Optionally, the value of the control information includes: a first control information value and a second control information value;
其中,所述第一控制信息值,用于表示所述输入数据的字节数量与预设校验码数目不存在预设关系;Wherein, the first control information value is used to indicate that there is no preset relationship between the number of bytes of the input data and the number of preset check codes;
所述第二控制信息值,用于表示所述输入数据的字节数量与预设校验码数目存在预设关系。The second control information value is used to indicate that there is a preset relationship between the number of bytes of the input data and the number of preset check codes.
可选地,根据所述控制信息的取值,选择对应校验码的生成方式,包括:Optionally, according to the value of the control information, selecting a corresponding verification code generation method includes:
当所述控制信息的取值是第一控制信息值时,采用中央处理器生成校验码的方式;When the value of the control information is the first control information value, the central processing unit generates a check code;
当所述控制信息的取值是第二控制信息值时,采用网卡生成校验码的方式。When the value of the control information is the second control information value, a method of generating a check code by the network card is adopted.
根据本发明实施例的再一个方面,提供了一种处理接收报文的方法,包括:According to another aspect of the embodiments of the present invention, a method for processing a received message is provided, including:
获取接收报文;Get received message;
根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择所述接收报文的校验方式;所述接收报文的处理方式包括:采用中央处理器进行校验、采用网卡进行校验;According to the relationship between the number of bytes in the received message and the number of preset check codes, select the check method of the received message; the processing method of the received message includes: using a central processing unit to check Check, use the network card to check;
根据所述校验方式对接收报文进行校验,若所述接收报文正确,则对所述接收报文进行存储。The received message is verified according to the verification mode, and if the received message is correct, the received message is stored.
可选地,根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择所述接收报文的校验方式,包括:Optionally, according to the relationship between the number of bytes in the received message and the number of preset check codes, selecting a check method for the received message includes:
当所述接收报文中的字节数量与预设校验码数目存在预设关系时,校验所述接收报文的方式为采用网卡进行校验;When there is a preset relationship between the number of bytes in the received message and the number of preset check codes, the way to verify the received message is to use a network card for verification;
当所述接收报文中的字节数量与预设校验码数目不存在预设关系时,校验所述接收报文的方式为采用中央处理器进行校验。When there is no preset relationship between the number of bytes in the received message and the number of preset check codes, the way to verify the received message is to use a central processing unit to perform verification.
可选地,根据所述校验方式对接收报文进行校验,若所述接收报文正确,则对所述接收报文进行存储,包括:Optionally, verifying the received message according to the verification method, if the received message is correct, storing the received message, including:
根据所述校验方式对接收报文进行校验,并且根据所述校验方式生成控制信息;Verifying the received message according to the verification method, and generating control information according to the verification method;
若所述接收报文正确,则将所述接收报文与对应的控制信息进行组合存储;If the received message is correct, combining and storing the received message and corresponding control information;
其中,当所述校验方式为采用中央处理器进行校验,则所述控制信息的取值为第一控制信息值;当所述校验方式为采用网卡进行校验,则所述控制信息的取值为第二控制信息值。Wherein, when the verification method is to use a central processing unit for verification, the value of the control information is the first control information value; when the verification method is to use a network card for verification, the control information The value of is the second control information value.
根据本发明实施例的再一个方面,提供了一种处理报文的系统,包括:中央处理模块和网卡模块;According to still another aspect of the embodiments of the present invention, a system for processing messages is provided, including: a central processing module and a network card module;
其中,应用于生成发送报文时:Among them, when applying to generate sending message:
所述中央处理模块,用于根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;根据所述控制信息的取值,选择对应校验码的生成方式;当所述控制信息的取值为第一控制信息值的情况,生成校验码;The central processing module is used to generate control information according to the relationship between the number of bytes of the input data and the number of preset check codes; select the corresponding check code generation method according to the value of the control information; when When the value of the control information is the first control information value, a check code is generated;
所述网卡模块,用于当所述控制信息的取值为第二控制信息值的情况,生成校验码;根据所述输入数据和所述校验码,生成发送报文;The network card module is configured to generate a check code when the value of the control information is the second control information value; generate a sending message according to the input data and the check code;
其中,所述第一控制信息值,用于表示所述输入数据的字节数量不是预设校验码数目的整数倍;所述第二控制信息值,用于表示所述输入数据的字节数量是预设校验码数目的整数;Wherein, the first control information value is used to indicate that the number of bytes of the input data is not an integral multiple of the number of preset check codes; the second control information value is used to indicate that the number of bytes of the input data Quantity is an integer of the number of preset check codes;
和/或,and / or,
应用于处理接收报文时:When applied to processing received messages:
所述网卡模块,用于获取接收报文;根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择处理所述接收报文的方式;当所述接收报文中的字节数量是预设校验码数目的整数倍时,对所述接收报文进行校验;The network card module is used to obtain a received message; according to the relationship between the number of bytes in the received message and the number of preset check codes, select a method for processing the received message; when the received message When the number of bytes in the text is an integer multiple of the number of preset check codes, the received message is checked;
所述中央处理模块,用于当所述接收报文中的字节数量不是预设校验码数目的整数倍时,对所述接收报文进行校验;若所述接收报文正确,则对所述接收报文进行存储。The central processing module is used to check the received message when the number of bytes in the received message is not an integral multiple of the number of preset check codes; if the received message is correct, then Store the received message.
根据本发明实施例的再一个方面,提供了一种生成发送报文的装置,包括:According to another aspect of the embodiments of the present invention, there is provided an apparatus for generating a sending message, including:
控制信息生成模块,用于根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;A control information generation module, configured to generate control information according to the relationship between the number of bytes of input data and the number of preset checksums;
校验码生成方式确定模块,用于根据所述控制信息的取值,选择对应校验码的生成方式;A verification code generation method determining module is used to select a corresponding verification code generation method according to the value of the control information;
校验码生成模块,用于根据所述生成方式生成校验码;所述校验码的生成方式包括:采用中央处理器生成校验码、采用网卡生成校验码;A verification code generation module, used to generate a verification code according to the generation method; the generation method of the verification code includes: using a central processing unit to generate a verification code, and using a network card to generate a verification code;
发送报文生成模块,用于根据所述输入数据和所述校验码,生成发送报文。A sending message generating module, configured to generate a sending message according to the input data and the verification code.
根据本发明实施例的再一个方面,提供了一种处理接收报文的装置,包括:According to another aspect of the embodiments of the present invention, a device for processing received messages is provided, including:
接收报文获取模块,用于获取接收报文;A receiving message obtaining module, configured to obtain receiving messages;
接收报文处理方式确定模块,用于根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择所述接收报文的校验方式;所述接收报文的处理方式包括:采用中央处理器进行校验、采用网卡进行校验;A received message processing mode determination module, configured to select the check mode of the received message according to the relationship between the number of bytes in the received message and the number of preset check codes; The processing methods include: using the central processing unit for verification, and using the network card for verification;
接收报文存储模块,用于根据所述方式对接收报文进行校验,若所述接收报文正确,则对所述接收报文进行存储。The received message storage module is configured to verify the received message according to the method, and store the received message if the received message is correct.
根据本发明实施例的另一个方面,提供了一种处理报文的电子设备,包括:According to another aspect of the embodiments of the present invention, an electronic device for processing messages is provided, including:
一个或多个处理器;one or more processors;
存储装置,用于存储一个或多个程序,storage means for storing one or more programs,
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现本发明提供的处理报文的方法。When the one or more programs are executed by the one or more processors, the one or more processors are made to implement the message processing method provided by the present invention.
根据本发明实施例的还一个方面,提供了一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现本发明提供的处理报文的方法。According to still another aspect of the embodiments of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method for processing a packet provided by the present invention is implemented.
上述发明中的一个实施例具有如下优点或有益效果:An embodiment of the above invention has the following advantages or beneficial effects:
本申请可选实施例中采用硬件(也就是网卡)实现固定一种或几种长度的报文的校验码的计算,除上述一种或集中长度之外的其它长度的报文需要传输时可以利用软件在CPU上生成校验码,进而避免了现有技术采用硬件生成校验码时对硬件设备的要求高成本高、采用软件生成校验码时所消耗的时间成本高的技术缺陷,进而达到在降低生成校验码成本的同时,提高生成校验码的效率。In the optional embodiment of the present application, hardware (that is, a network card) is used to realize the calculation of the check code of a message with one or more fixed lengths. Software can be used to generate check codes on the CPU, thereby avoiding the technical defects of high requirements for hardware devices and high cost of hardware equipment when using hardware to generate check codes in the prior art, and high time and cost consumption when using software to generate check codes. Furthermore, while reducing the cost of generating the verification code, the efficiency of generating the verification code is improved.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。The further effects of the above-mentioned non-conventional alternatives will be described below in conjunction with specific embodiments.
附图说明Description of drawings
附图用于更好地理解本发明,不构成对本发明的不当限定。其中:The accompanying drawings are used to better understand the present invention, and do not constitute improper limitations to the present invention. in:
图1是根据本发明实施例的一种生成发送报文的方法的主要流程的示意图;Fig. 1 is a schematic diagram of the main flow of a method for generating and sending a message according to an embodiment of the present invention;
图2是根据本发明实施例的将输入数据发送至外部网络的过程的主要流程的示意图;2 is a schematic diagram of the main flow of the process of sending input data to an external network according to an embodiment of the present invention;
图3是根据本发明实施例的一种处理接收报文的主要流程的示意图;FIG. 3 is a schematic diagram of a main flow for processing received messages according to an embodiment of the present invention;
图4是根据本发明实施例的处理接收报文的详细流程的示意图;FIG. 4 is a schematic diagram of a detailed flow of processing a received message according to an embodiment of the present invention;
图5是根据本发明实施例的一种处理报文系统的示意图;FIG. 5 is a schematic diagram of a message processing system according to an embodiment of the present invention;
图6是根据本发明实施例的一种生成发送报文的装置的主要模块的示意图;FIG. 6 is a schematic diagram of main modules of a device for generating and sending messages according to an embodiment of the present invention;
图7是根据本发明实施例的一种处理接收报文的装置的主要模块的示意图;FIG. 7 is a schematic diagram of main modules of a device for processing received messages according to an embodiment of the present invention;
图8是本发明实施例可以应用于其中的示例性系统架构图;Fig. 8 is an exemplary system architecture diagram to which the embodiment of the present invention can be applied;
图9是适于用来实现本发明实施例的终端设备或服务器的计算机系统的结构示意图。FIG. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present invention are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding, and they should be regarded as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
数据通信领域中最常用的查错校验码的方法包括但不限于一下三种之一主要有三种方法,具体地,包括:奇偶校验、海明码、CRC循环冗余校验码(Cyclic RedundancyCheck)。当采用CRC循环冗余校验码生成校验码时,可以将校验码设置在输入数据的尾部。The most commonly used method of error checking code in the field of data communication includes but is not limited to one of the following three main methods, specifically, including: parity check, Hamming code, CRC cyclic redundancy check code (Cyclic RedundancyCheck ). When a CRC cyclic redundancy check code is used to generate a check code, the check code can be set at the end of the input data.
为了提高校验码的计算速度,现有技术硬件通常采用并行计算的方法。具体地,假设报文中输入数据位宽是32B,则硬件需要设置一个位宽是32B的硬件计算校验码的模块。由于报文本身的长度是任意的,所以报文输入的最后一个数据位宽可能是1B~32B,所以硬件还需要设置另外31种不同数据位宽的硬件计算校验码的模块。进而现有技术在采用硬件计算校验码时,需要采用较高性能的网卡,由于高性能网卡的结构较为复杂、成本较高,故采用高性能网卡所消耗的成本较高。In order to increase the calculation speed of the check code, hardware in the prior art usually adopts a parallel calculation method. Specifically, assuming that the bit width of the input data in the message is 32B, the hardware needs to set a module with a bit width of 32B to calculate the check code. Since the length of the message itself is arbitrary, the last data bit width of the message input may be 1B to 32B, so the hardware also needs to set up another 31 hardware calculation modules with different data bit widths. Furthermore, in the prior art, when using hardware to calculate the check code, a higher-performance network card needs to be used. Since the structure of the high-performance network card is relatively complicated and the cost is high, the cost consumed by the high-performance network card is relatively high.
现有技术在传输报文时,也存在采用软件计算校验码的情况。其中,采用软件计算是将报文存放在CPU(中央处理器)对应的内存上,由CPU计算输入数据的校验码。但是采用软件计算校验码会产生消耗CPU计算力的技术缺陷,也存在无法满足高带宽的网络传输要求的技术缺陷。In the prior art, when transmitting a message, software is also used to calculate a check code. Among them, the software calculation is to store the message in the memory corresponding to the CPU (Central Processing Unit), and the CPU calculates the check code of the input data. However, the use of software to calculate the check code will produce technical defects that consume CPU computing power, and there are also technical defects that cannot meet the requirements of high-bandwidth network transmission.
本申请可选实施例中采用硬件(也就是网卡)实现固定一种或几种长度的报文的校验码的计算,除上述一种或集中长度之外的其它长度的报文需要传输时可以利用软件在CPU上生成校验码,进而避免了现有技术采用硬件生成校验码时对硬件设备的要求高成本高、采用软件生成校验码时所消耗的时间成本高的技术缺陷,进而达到在降低生成校验码成本的同时提高生成校验码的效率的技术效果。In the optional embodiment of the present application, hardware (that is, a network card) is used to realize the calculation of the check code of a message with one or more fixed lengths. Software can be used to generate check codes on the CPU, thereby avoiding the technical defects of high requirements for hardware devices and high cost of hardware equipment when using hardware to generate check codes in the prior art, and high time and cost consumption when using software to generate check codes. Furthermore, the technical effect of increasing the efficiency of generating the verification code while reducing the cost of generating the verification code is achieved.
具体地,图1是根据本发明实施例的一种生成发送报文的方法的主要流程的示意图,如图1所示,包括:Specifically, FIG. 1 is a schematic diagram of the main flow of a method for generating and sending a message according to an embodiment of the present invention, as shown in FIG. 1 , including:
步骤S101、根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;Step S101, generating control information according to the relationship between the number of bytes of input data and the number of preset check codes;
步骤S102、根据所述控制信息的取值,选择对应校验码的生成方式;Step S102, according to the value of the control information, select the generation method of the corresponding check code;
步骤S103、根据所述生成方式生成校验码;所述校验码的生成方式包括:采用中央处理器生成校验码、采用网卡生成校验码;Step S103, generating a check code according to the generation method; the generation method of the check code includes: using a central processing unit to generate a check code, and using a network card to generate a check code;
步骤S104、根据所述输入数据和所述校验码,生成发送报文。Step S104, generating a sending message according to the input data and the verification code.
当CPU发送报文时,利用CPU先根据输入数据中字节数量的长度,判断生成校验码的生成方式。具体地,如果网卡不支持该输入数据中字节数量长度的校验码的计算,则利用CPU中的软件计算校验码,然后拼接到输入数据尾部后再发给网卡进行传输;如果网卡支持该长度的校验码的计算,则直接把输入数据发给网卡传输,由网卡计算校验码,拼接到输入数据的尾部再传输到外部网络。When the CPU sends a message, the CPU is used to judge the generation method of the check code according to the length of the number of bytes in the input data. Specifically, if the network card does not support the calculation of the check code of the number of bytes in the input data, then use the software in the CPU to calculate the check code, and then splicing it to the end of the input data and then sending it to the network card for transmission; if the network card supports For the calculation of the check code of this length, the input data is directly sent to the network card for transmission, and the network card calculates the check code, which is spliced to the end of the input data and then transmitted to the external network.
通过上述技术手段,可以简化实现上述步骤的硬件部分,也就是硬件部分采用低性能的网卡可以进行部分生成检验码的操作,进而降低了硬件实现生成校验码的成本。本方案在满足相同的网络传输带宽的要求下,节约了硬件实现成本。Through the above technical means, the hardware part for implementing the above steps can be simplified, that is, the hardware part can use a low-performance network card to perform part of the operation of generating the verification code, thereby reducing the cost of generating the verification code by hardware. This solution saves hardware implementation costs while meeting the same network transmission bandwidth requirements.
并且,本方案通过将部分校验码由CPU进行计算的技术手段,解决了现有技术采用CPU计算全部输入数据校验码时,对CPU计算压力过大的技术问题,进而达到提高计算校验码效率,降低计算成本的技术效果。本申请通过减少CPU的计算量,还可以达到满足当前对高带宽传输需求的技术效果。Moreover, this solution solves the technical problem of excessive calculation pressure on the CPU when the CPU is used to calculate the check code of all input data in the prior art by using the technical means of calculating part of the check code by the CPU, thereby achieving improved calculation and verification. Code efficiency, the technical effect of reducing computing costs. The present application can also achieve the technical effect of meeting the current demand for high-bandwidth transmission by reducing the calculation amount of the CPU.
当CPU确定输入数据的字节数量与预设校验码数目之间的关系之后,就可以生成针对所述输入数据设置控制信息。所述控制信息可以利用0和1,或其他预设字段表示利用网卡设置校验码和利用CPU中的软件设置校验码。After the CPU determines the relationship between the number of bytes of the input data and the number of preset checksums, it can generate control information for setting the input data. The control information can use 0 and 1, or other preset fields to indicate that the check code is set by using the network card and the check code is set by software in the CPU.
具体地,所述控制信息的取值可以包括:第一控制信息值和第二控制信息值;Specifically, the value of the control information may include: a first control information value and a second control information value;
在所述控制信息中可以包含输入数据的字节数量与预设校验码数目之间的关系的判断结果和/或是否需要网卡进行校验码计算的标识;The control information may include the judgment result of the relationship between the number of bytes of input data and the number of preset check codes and/or an identification of whether the network card is required to perform check code calculation;
其中,所述第一控制信息值,用于表示所述输入数据的字节数量与预设校验码数目不存在预设关系;Wherein, the first control information value is used to indicate that there is no preset relationship between the number of bytes of the input data and the number of preset check codes;
所述第二控制信息值,用于表示所述输入数据的字节数量与预设校验码数目存在预设关系。The second control information value is used to indicate that there is a preset relationship between the number of bytes of the input data and the number of preset check codes.
具体地,所述预设关系包括但不限于:所述输入数据的字节数量是预设校验码数目的整数倍,也可以为整数倍后添加其他的数字。Specifically, the preset relationship includes but is not limited to: the number of bytes of the input data is an integer multiple of the number of preset check codes, and other numbers may be added after the integer multiple.
其中,所述预设校验码数目是指预设在系统中用于并行计算的字节数,例如32B。Wherein, the preset number of check codes refers to the number of bytes preset in the system for parallel calculation, for example, 32B.
当所述输入数据的字节数量与预设校验码数目存在预设关系时,所述字节数量可以存在多种情况,也就是网卡可以为一种或多种不同长度的输入数据生成校验码。由于本申请所采用的网卡仅需要实现几种长度的报文的crc校验,无需采用较高性能的网卡,故本申请在提高性能的同时不会提高经济成本。When there is a preset relationship between the number of bytes of the input data and the number of preset check codes, the number of bytes can be in multiple situations, that is, the network card can generate checksums for one or more input data of different lengths. check code. Since the network card used in this application only needs to realize the CRC check of messages of several lengths, and does not need to use a higher-performance network card, this application will not increase economic costs while improving performance.
具体地,当所述控制信息的取值为第一控制信息值(也就是所述输入数据的字节数量与预设校验码数目之间不存在预设关系)的情况,将采用中央处理器生成校验码的方式,设置为所述控制信息对应的校验码的生成方式;Specifically, when the value of the control information is the first control information value (that is, there is no preset relationship between the number of bytes of the input data and the number of preset check codes), the central processing The way the device generates the check code is set as the way of generating the check code corresponding to the control information;
当所述控制信息的取值为第二控制信息值(也就是所述输入数据的字节数量与预设校验码数目之间存在预设关系)的情况,将采用网卡生成校验码的方式设置为所述控制信息对应校验码的生成方式。When the value of the control information is the second control information value (that is, there is a preset relationship between the number of bytes of the input data and the number of preset check codes), the network card will be used to generate the check code The method is set as the method of generating the verification code corresponding to the control information.
本申请通过设置控制信息可以使得当软件(CPU)完成生成校验码时,硬件无需重复生成校验码;当硬件完成生成校验码时,软件无需重复生成校验码。The application sets the control information so that when the software (CPU) completes the generation of the verification code, the hardware does not need to repeatedly generate the verification code; when the hardware completes the generation of the verification code, the software does not need to repeatedly generate the verification code.
通过软硬件协同的技术手段,可以根据所述输入数据的长度选择合适的生成输入数据的技术手段,进而提高生成校验码的效率。Through the technical means of software and hardware coordination, an appropriate technical means for generating input data can be selected according to the length of the input data, thereby improving the efficiency of generating check codes.
可选地,将小流量的输入数据校验码的计算放在软件实现,将大流量的输入数据校验码的计算放在专用硬件实现,进而达到保证了网卡功能的完整性、支持所有长度的输入数据的传输,满足了高带宽的传输需要,使得大部分的输入数据校验码的计算由网卡完成。Optionally, the calculation of the input data verification code for small flows is implemented in software, and the calculation of input data verification codes for large flows is implemented in dedicated hardware, thereby ensuring the integrity of the network card functions and supporting all lengths The transmission of the input data satisfies the need of high-bandwidth transmission, so that most of the calculation of the input data check code is completed by the network card.
图2是根据本发明实施例的将输入数据发送至外部网络的过程的主要流程的示意图,如图2所示,包括:Fig. 2 is a schematic diagram of the main flow of the process of sending input data to an external network according to an embodiment of the present invention, as shown in Fig. 2 , including:
S201、利用CPU确定输入数据;S201. Using the CPU to determine input data;
S202、确定输入数据的字节长度;S202. Determine the byte length of the input data;
S203、确定所述字节长度判断与预设校验码数目之间的关系;S203. Determine the relationship between the byte length judgment and the number of preset check codes;
S204、根据所述关系,生成控制信息;其中,当确定所述关系为整数倍,则所述控制信息的取值为第一控制信息值,执行S206;当确定所述关系不是整数倍,则所述控制信息的取值为第二控制信息值,执行S205;S204. Generate control information according to the relationship; wherein, when it is determined that the relationship is an integer multiple, the value of the control information is the first control information value, and perform S206; when it is determined that the relationship is not an integer multiple, then The value of the control information is the second control information value, execute S205;
S205、采用中央处理器生成校验码,将输入数据和生成的校验码进行组合,发送至网卡,并在网卡中采用透传的模式发送至外部网络;S205. Use the central processing unit to generate a check code, combine the input data and the generated check code, send it to the network card, and send it to the external network in a transparent transmission mode in the network card;
S206、采用网卡读取输入数据;执行S207;S206, using the network card to read the input data; execute S207;
S207、网卡根据所述控制信息判断输入数据是否需要计算校验码;若需要,则根据所述输入数据生成校验码;S207. The network card determines whether the input data needs to calculate a check code according to the control information; if necessary, generates a check code according to the input data;
S206、根据所述输入数据和S207生成的校验码,生成发送报文,发送至外部网络。S206. Generate a sending message according to the input data and the verification code generated in S207, and send it to the external network.
与为输入数据生成发送报文的方法相对应的一种处理接收报文,如图3所示,其中,图3是根据本发明实施例的一种处理接收报文的主要流程的示意图。具体地,包括如下步骤:A method of processing a received message corresponding to the method of generating a sent message for input data is shown in FIG. 3 , wherein FIG. 3 is a schematic diagram of a main process of processing a received message according to an embodiment of the present invention. Specifically, include the following steps:
S301、获取接收报文;S301. Obtain a received message;
S302、根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择所述接收报文的校验方式;所述接收报文的处理方式包括:采用中央处理器进行校验、采用网卡进行校验;S302. According to the relationship between the number of bytes in the received message and the number of preset check codes, select a verification method for the received message; the processing method for the received message includes: using a central processing unit Perform verification, use network card for verification;
S303、根据所述校验方式对接收报文进行校验,若所述接收报文正确,则对所述接收报文进行存储。S303. Verify the received message according to the verification method, and store the received message if the received message is correct.
所述接收报文是来自外部网络的原始报文,当生成校验的方式为CRC循环冗余校验码(Cyclic Redundancy Check)时,其校验码可以在原始报文的尾部。The received message is an original message from an external network, and when the verification method is CRC (Cyclic Redundancy Check), the check code may be at the end of the original message.
上述处理接收报文的步骤是与生成发送报文的步骤相对应的。The above steps of processing the received message correspond to the steps of generating the sent message.
输入数据若与预设校验码数目存在预设关系,则将输入数据添加上校验码后,依旧与所述预设校验码存在预设关系。故在接收报文时可以在网卡端选择处理接收报文的方式。If there is a preset relationship between the input data and the number of preset check codes, after adding the check codes to the input data, there is still a preset relationship with the preset check codes. Therefore, when receiving a message, you can choose the way to process the received message on the network card side.
具体地,根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择所述接收报文的校验方式,包括:Specifically, according to the relationship between the number of bytes in the received message and the number of preset check codes, selecting a check method for the received message includes:
当所述接收报文中的字节数量是预设校验码数目的整数倍时,校验所述接收报文的方式为采用网卡进行校验;When the number of bytes in the received message is an integral multiple of the number of preset check codes, the way to verify the received message is to use a network card for verification;
当所述接收报文中的字节数量不是预设校验码数目的整数倍时,可以采用透传的模式将所述接收报文传输到CPU对应的内存中等到CPU的校验,具体地,校验所述接收报文的方式为采用中央处理器进行校验。When the number of bytes in the received message is not an integer multiple of the number of preset check codes, the received message can be transmitted to the memory corresponding to the CPU in a transparent transmission mode until the CPU checks, specifically , the method of verifying the received message is to use the central processing unit to perform verification.
可选地,根据所述校验方式对接收报文进行校验,若所述接收报文正确,则对所述接收报文进行存储,包括:Optionally, verifying the received message according to the verification method, if the received message is correct, storing the received message, including:
根据所述校验方式对接收报文进行校验,并且根据所述校验方式生成控制信息;所述控制信息的取值为第一控制信息值和第二控制信息值;Verifying the received message according to the verification method, and generating control information according to the verification method; the value of the control information is a first control information value and a second control information value;
当所述校验方式为采用中央处理器进行校验,则所述控制信息的取值为第一控制信息值;When the verification method is to use a central processing unit to perform verification, the value of the control information is the first control information value;
当所述校验方式为采用网卡进行校验,则所述控制信息的取值为第二控制信息值;When the verification method is to use a network card for verification, the value of the control information is the second control information value;
若所述接收报文正确,则将所述接收报文与对应的控制信息进行组合存储。If the received message is correct, combine and store the received message and corresponding control information.
图4是根据本发明实施例的处理接收报文的详细流程的示意图。如图4所示,下面以一具体实施例详细说明处理接收报文的过程,包括:Fig. 4 is a schematic diagram of a detailed flow of processing a received message according to an embodiment of the present invention. As shown in Figure 4, the process of processing received messages will be described in detail below with a specific embodiment, including:
S401、接收来自外部网络的报文;S401. Receive a message from an external network;
S402、根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择所述接收报文的校验方式;若采用中央处理器进行校验则执行S403,若采用网卡进行校验则执行S404;S402. According to the relationship between the number of bytes in the received message and the number of preset check codes, select the check method of the received message; if the central processing unit is used for checking, then execute S403; If the network card is verified, S404 is executed;
S403、判断接收报文中的校验码是否完成校验,若否,则将所述接收报文通过透传模式传输到CPU对应的内存中,对所述接收报文进行校验,若正确则存储所述接收报文,并生成用于表示校验方式的控制信息,若否则丢弃所述接收报文;S403. Determine whether the verification code in the received message has been verified, if not, transmit the received message to the memory corresponding to the CPU through the transparent transmission mode, and verify the received message, if correct Then store the received message, and generate control information for indicating the verification mode, otherwise discard the received message;
S404、利用网卡对所述接收报文进行校验,若正确则存储所述接收报文,并生成用于表示校验方式的控制信息,存储在CPU对应的内存中;若否则丢弃所述接收报文。S404. Use the network card to verify the received message, if it is correct, store the received message, and generate control information for indicating the verification method, and store it in the memory corresponding to the CPU; otherwise, discard the received message message.
图5是根据本发明实施例的一种处理报文系统的示意图。如图5所示,一种处理报文的系统,包括:中央处理模块和网卡模块;Fig. 5 is a schematic diagram of a message processing system according to an embodiment of the present invention. As shown in Figure 5, a system for processing messages includes: a central processing module and a network card module;
其中,应用于生成发送报文时:Among them, when applying to generate sending message:
所述中央处理模块,用于根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;根据所述控制信息的取值,选择对应校验码的生成方式;当所述控制信息的取值为第一控制信息值的情况,生成校验码;The central processing module is used to generate control information according to the relationship between the number of bytes of the input data and the number of preset check codes; select the corresponding check code generation method according to the value of the control information; when When the value of the control information is the first control information value, a check code is generated;
所述网卡模块,用于当所述控制信息的取值为第二控制信息值的情况,生成校验码;根据所述输入数据和所述校验码,生成发送报文;The network card module is configured to generate a check code when the value of the control information is the second control information value; generate a sending message according to the input data and the check code;
其中,所述第一控制信息值,用于表示所述输入数据的字节数量不是预设校验码数目的整数倍;所述第二控制信息值,用于表示所述输入数据的字节数量是预设校验码数目的整数;Wherein, the first control information value is used to indicate that the number of bytes of the input data is not an integral multiple of the number of preset check codes; the second control information value is used to indicate that the number of bytes of the input data Quantity is an integer of the number of preset check codes;
和/或,and / or,
应用于处理接收报文时:When applied to processing received messages:
所述网卡模块,用于获取接收报文;根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择处理所述接收报文的方式;当所述接收报文中的字节数量是预设校验码数目的整数倍时,对所述接收报文进行校验;The network card module is used to obtain a received message; according to the relationship between the number of bytes in the received message and the number of preset check codes, select a method for processing the received message; when the received message When the number of bytes in the text is an integer multiple of the number of preset check codes, the received message is checked;
所述中央处理模块,用于当所述接收报文中的字节数量不是预设校验码数目的整数倍时,对所述接收报文进行校验;若所述接收报文正确,则对所述接收报文进行存储。The central processing module is used to check the received message when the number of bytes in the received message is not an integral multiple of the number of preset check codes; if the received message is correct, then Store the received message.
具体地,本申请也可以用于网络协议ROCEv2,其中所述网络协议ROCEv2所对应的校验字段命名为ICRC,其计算方法类似于太网报文的crc。本申请中提供的计算校验码的模块和软硬件协同的计算校验码的方法也可以适用rocev2协议报文的发送和接收。其中,RoCE(RDMA over Converged Ethernet)是一种允许通过以太网使用远程直接内存访问(RDMA)的网络协议。Specifically, this application can also be used in the network protocol ROCEv2, wherein the check field corresponding to the network protocol ROCEv2 is named ICRC, and its calculation method is similar to the crc of an Ethernet packet. The module for calculating the check code provided in this application and the method for calculating the check code with the cooperation of software and hardware can also be applied to the sending and receiving of rocev2 protocol messages. Among them, RoCE (RDMA over Converged Ethernet) is a network protocol that allows the use of remote direct memory access (RDMA) over Ethernet.
图6是根据本发明实施例的一种生成发送报文的装置的主要模块的示意图;如图6所示,提供了一种生成发送报文的装置600,包括:Fig. 6 is a schematic diagram of a main module of a device for generating a sending message according to an embodiment of the present invention; as shown in Fig. 6 , a
控制信息生成模块601,用于根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;A control
校验码生成方式确定模块602,用于根据所述控制信息的取值,选择对应校验码的生成方式;A check code generation
校验码生成模块603,用于根据所述生成方式生成校验码;所述校验码的生成方式包括:采用中央处理器生成校验码、采用网卡生成校验码;The verification
发送报文生成模块604,用于根据所述输入数据和所述校验码,生成发送报文。A sending
图7是根据本发明实施例的一种处理接收报文的装置的主要模块的示意图;如图7所示,提供了一种处理接收报文的装置700,包括:FIG. 7 is a schematic diagram of main modules of a device for processing received messages according to an embodiment of the present invention; as shown in FIG. 7 , a
接收报文获取模块701,用于获取接收报文;A received
接收报文处理方式确定模块702,用于根据所述接收报文中的字节数量与预设校验码数目之间的关系,选择所述接收报文的校验方式;所述接收报文的处理方式包括:采用中央处理器进行校验、采用网卡进行校验;The received message processing
接收报文存储模块703,用于根据所述方式对接收报文进行校验,若所述接收报文正确,则对所述接收报文进行存储。The received
图8示出了可以应用本发明实施例的生成发送报文、处理接收报文方法或生成发送报文、处理接收报文装置的示例性系统架构800。Fig. 8 shows an
如图8所示,系统架构800可以包括终端设备801、802、803,网络804和服务器805。网络804用以在终端设备801、802、803和服务器805之间提供通信链路的介质。网络804可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 8 , a
用户可以使用终端设备801、802、803通过网络804与服务器805交互,以接收或发送消息等。终端设备801、802、803上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等(仅为示例)。Users can use
终端设备801、802、803可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The
服务器805可以是提供各种服务的服务器,例如对用户利用终端设备801、802、803所浏览的购物类网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的产品信息查询请求等数据进行分析等处理,并将处理结果(例如目标推送信息、产品信息--仅为示例)反馈给终端设备。The
需要说明的是,本发明实施例所提供的生成发送报文、处理接收报文方法一般由服务器805执行,相应地,生成发送报文、处理接收报文装置一般设置于服务器805中。It should be noted that the methods for generating sent messages and processing received messages provided by the embodiments of the present invention are generally executed by the
应该理解,图8中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in FIG. 8 are only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.
下面参考图9,其示出了适于用来实现本发明实施例的终端设备的计算机系统900的结构示意图。图9示出的终端设备仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Referring now to FIG. 9 , it shows a schematic structural diagram of a
如图9所示,计算机系统900包括中央处理模块(CPU)901,其可以根据存储在只读存储器(ROM)902中的程序或者从存储部分908加载到随机访问存储器(RAM)903中的程序而执行各种适当的动作和处理。在RAM 903中,还存储有系统900操作所需的各种程序和数据。CPU 901、ROM 902以及RAM 903通过总线904彼此相连。输入/输出(I/O)接口905也连接至总线904。As shown in FIG. 9 , a
以下部件连接至I/O接口905:包括键盘、鼠标等的输入部分906;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分907;包括硬盘等的存储部分908;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分909。通信部分909经由诸如因特网的网络执行通信处理。驱动器910也根据需要连接至I/O接口905。可拆卸介质911,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器910上,以便于从其上读出的计算机程序根据需要被安装入存储部分908。The following components are connected to the I/O interface 905: an
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分909从网络上被下载和安装,和/或从可拆卸介质911被安装。在该计算机程序被中央处理模块(CPU)901执行时,执行本发明的系统中限定的上述功能。In particular, according to the disclosed embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the disclosed embodiments of the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, where the computer program includes program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program codes are carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. . Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or portion of code that includes one or more logical functions for implementing specified executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block in the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a A combination of dedicated hardware and computer instructions.
描述于本发明实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器包括发送模块、获取模块、确定模块和第一处理模块。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定,例如,发送模块还可以被描述为“向所连接的服务端发送图片获取请求的模块”。The modules involved in the embodiments described in the present invention may be implemented by software or by hardware. The described modules may also be set in a processor. For example, it may be described as: a processor includes a sending module, an acquiring module, a determining module, and a first processing module. Wherein, the names of these modules do not limit the module itself under certain circumstances, for example, the sending module can also be described as "a module that sends a picture acquisition request to the connected server".
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:As another aspect, the present invention also provides a computer-readable medium. The computer-readable medium may be contained in the device described in the above embodiments, or it may exist independently without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the device, the device includes:
根据输入数据的字节数量与预设校验码数目之间的关系,生成控制信息;Generate control information according to the relationship between the number of bytes of input data and the number of preset checksums;
根据所述控制信息的取值,选择对应校验码的生成方式;According to the value of the control information, select the generation method of the corresponding check code;
根据所述生成方式生成校验码;所述校验码的生成方式包括:采用中央处理器生成校验码、采用网卡生成校验码;Generate a check code according to the generation method; the generation method of the check code includes: using a central processing unit to generate a check code, and using a network card to generate a check code;
根据所述输入数据和所述校验码,生成发送报文。Generate a sending message according to the input data and the verification code.
根据本发明实施例的技术方案,可以达到如下有益效果:According to the technical solutions of the embodiments of the present invention, the following beneficial effects can be achieved:
本申请可选实施例中采用硬件(也就是网卡)实现固定一种或几种长度的报文的校验码的计算,除上述一种或集中长度之外的其它长度的报文需要传输时可以利用软件在CPU上生成校验码,进而避免了现有技术采用硬件生成校验码时对硬件设备的要求高成本高、采用软件生成校验码时所消耗的时间成本高的技术缺陷,进而达到在降低生成校验码成本的同时,提高生成校验码的效率的技术效果。In the optional embodiment of the present application, hardware (that is, a network card) is used to realize the calculation of the check code of a message with one or more fixed lengths. Software can be used to generate check codes on the CPU, thereby avoiding the technical defects of high requirements for hardware devices and high cost of hardware equipment when using hardware to generate check codes in the prior art, and high time and cost consumption when using software to generate check codes. Furthermore, the technical effect of improving the efficiency of generating the verification code while reducing the cost of generating the verification code is achieved.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above specific implementation methods do not constitute a limitation to the protection scope of the present invention. It should be apparent to those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims (8)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910755214.2A CN111800223B (en) | 2019-08-15 | 2019-08-15 | Method, device and system for generating sending message and processing receiving message |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910755214.2A CN111800223B (en) | 2019-08-15 | 2019-08-15 | Method, device and system for generating sending message and processing receiving message |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN111800223A CN111800223A (en) | 2020-10-20 |
| CN111800223B true CN111800223B (en) | 2023-06-23 |
Family
ID=72805430
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201910755214.2A Active CN111800223B (en) | 2019-08-15 | 2019-08-15 | Method, device and system for generating sending message and processing receiving message |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111800223B (en) |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114499757B (en) * | 2022-01-07 | 2024-06-18 | 锐捷网络股份有限公司 | Method and device for generating checksum and electronic equipment |
| CN115081429B (en) * | 2022-07-07 | 2024-10-22 | 北京微纳星空科技股份有限公司 | Instruction verification method, device, equipment and storage medium |
| CN117318892B (en) * | 2023-11-27 | 2024-04-02 | 阿里云计算有限公司 | Computing system, data processing method, network card, host computer and storage medium |
| CN118523874B (en) * | 2024-07-24 | 2024-11-12 | 江苏小牛电动科技有限公司 | A dynamic data packet error correction method and system for electric vehicle cloud services |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6968492B1 (en) * | 2002-03-28 | 2005-11-22 | Annadurai Andy P | Hardware-efficient CRC generator for high speed communication networks |
| CN102708022A (en) * | 2005-12-23 | 2012-10-03 | 英特尔公司 | Performing a cyclic redundancy checksum operation responsive to a user-level instruction |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US4700350A (en) * | 1986-10-07 | 1987-10-13 | Douglas Phillip N | Multiple phase CRC generator |
| US8661314B2 (en) * | 2009-03-23 | 2014-02-25 | Broadcom Corporation | Method and apparatus for calculating frame check sequence |
| CN101902228B (en) * | 2009-05-25 | 2012-11-28 | 中兴通讯股份有限公司 | Rapid cyclic redundancy check encoding method and device |
| CN101789044B (en) * | 2010-01-27 | 2012-03-28 | 武汉大学 | A Genetic Algorithm Software-Hardware Collaborative Implementation Method |
| CN103701566B (en) * | 2013-12-18 | 2017-09-12 | 华为技术有限公司 | A kind of method of calibration and device |
| CN105790887A (en) * | 2014-12-26 | 2016-07-20 | 上海贝尔股份有限公司 | Method and device for generating parallel CRC values for packets |
-
2019
- 2019-08-15 CN CN201910755214.2A patent/CN111800223B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6968492B1 (en) * | 2002-03-28 | 2005-11-22 | Annadurai Andy P | Hardware-efficient CRC generator for high speed communication networks |
| CN102708022A (en) * | 2005-12-23 | 2012-10-03 | 英特尔公司 | Performing a cyclic redundancy checksum operation responsive to a user-level instruction |
Also Published As
| Publication number | Publication date |
|---|---|
| CN111800223A (en) | 2020-10-20 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111800223B (en) | Method, device and system for generating sending message and processing receiving message | |
| CN109756568B (en) | File processing method and device and computer readable storage medium | |
| CN105071976A (en) | Data transmission method and device | |
| CN110019125A (en) | The method and apparatus of data base administration | |
| CN110572422A (en) | Data download method and device | |
| CN110764770A (en) | Method and device for conversion and assignment between objects | |
| CN110795328A (en) | Interface testing method and device | |
| CN115134208A (en) | Message conversion method, device, electronic device and storage medium | |
| CN114780519A (en) | DBC file generation method, device, equipment and medium based on CAN communication | |
| CN114866533A (en) | File uploading method and device and electronic equipment | |
| CN115987965A (en) | File uploading method, device, equipment and storage medium | |
| US10237184B2 (en) | Resource management system | |
| CN109788010A (en) | A kind of method and apparatus of data localization access | |
| CN112052152A (en) | A method and device for simulating testing | |
| CN110557341A (en) | Method and device for data current limiting | |
| CN111917835A (en) | A system, method and device for monitoring network data | |
| CN113641359B (en) | A data processing method and device | |
| CN114896244A (en) | Method, apparatus, apparatus, and computer-readable medium for configuring database tables | |
| CN113132480B (en) | Data transmission method, device and system | |
| CN109241040B (en) | Method and apparatus for data cleaning | |
| US20120284382A1 (en) | Programmatically selecting a service provider based on assured quality of service attributes | |
| WO2023083066A1 (en) | Data synchronization method and apparatus | |
| CN115422067A (en) | Interface testing method and device | |
| CN110728009A (en) | Simulation method, device and system | |
| CN114417318A (en) | Method, device and electronic device for jumping to third-party pages |
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 | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |