Message modification method, device, equipment and storage medium

文档序号:291265 发布日期:2021-11-23 浏览:4次 中文

阅读说明:本技术 报文修改的方法、装置、设备及存储介质 (Message modification method, device, equipment and storage medium ) 是由 王森 桑建 曾达 沈玲 张雨昕 于 2020-05-19 设计创作,主要内容包括:本发明实施例公开了一种报文修改的方法、装置、设备及存储介质。该方法包括:获取报文,报文包括协议信息;获取报文的关键字段,并通过查询关键字段匹配规则表获得关键字段匹配信息,关键字段匹配信息包括报文修改动作信息;从预设的修改规则中获取与协议信息中的第一协议,以及关键字段匹配信息中的第一关键字段匹配信息相符合的第一修改规则,第一修改规则包括报文修改动作信息;根据第一修改规则和与第一修改规则对应的修改动作参数对报文进行修改,得到修改后的第一报文。本发明实施例的报文修改的方法、装置、设备及存储介质,可以提升数据包转发处理的灵活性。(The embodiment of the invention discloses a method, a device, equipment and a storage medium for message modification. The method comprises the following steps: acquiring a message, wherein the message comprises protocol information; acquiring a key field of the message, and acquiring key field matching information by inquiring a key field matching rule table, wherein the key field matching information comprises message modification action information; acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises message modification action information; and modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message. The message modification method, the message modification device, the message modification equipment and the storage medium can improve the flexibility of data packet forwarding processing.)

1. A method for message modification, the method comprising:

acquiring a message, wherein the message comprises protocol information;

acquiring key fields of the message, and acquiring key field matching information by inquiring a key field matching rule table, wherein the key field matching information comprises message modification action information;

acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises the message modification action information;

and modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message.

2. The method of claim 1, further comprising:

acquiring a second modification rule which is consistent with the first protocol and the first keyword matching information from the preset modification rule;

and modifying the message in the first message according to the second modification rule and the message modification action parameter corresponding to the second modification rule to obtain a modified second message.

3. The method according to claim 1 or 2, wherein the message modification action information comprises replacement action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, including:

acquiring a replacement action parameter from a preset action type rule parameter library according to the replacement action information;

and modifying the message according to the replacement action parameters to obtain a modified first message, wherein the replacement action parameters comprise a replacement initial position, a replacement field length and a replacement target field length.

4. The method according to claim 1 or 2, wherein the message modification action information comprises adding action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, including:

acquiring an increased action parameter from a preset action type rule parameter library according to the increased action information;

and modifying the message according to the added action parameter to obtain a modified first message, wherein the added action parameter comprises an added initial position and an added field length.

5. The method according to claim 1 or 2, wherein the message modification action information comprises deletion action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, including:

acquiring a deletion action parameter from a preset action type rule parameter library according to the deletion action information;

and modifying the message according to the deletion action parameter to obtain a modified first message, wherein the deletion action parameter comprises a deletion initial position and a deletion field length.

6. The method according to claim 1 or 2, wherein the message modification action information comprises verification action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, including:

acquiring a verification action parameter from a preset action type rule parameter library according to the verification action information;

and modifying the message according to the verification action parameters to obtain a modified first message, wherein the verification action parameters comprise a verification initial position, a verification field length, a verification result field replacement position and a verification result field replacement length.

7. The method according to claim 1 or 2, wherein the message modification action information comprises a padding action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, including:

acquiring a completion action parameter from a preset action type rule parameter library according to the completion action information;

and modifying the message according to the completion action parameters to obtain a modified first message, wherein the completion action parameters comprise the length of a completion field and the content of the completion field.

8. The method according to claim 1 or 2, wherein the message modification action information comprises encryption action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, including:

acquiring encryption action parameters from a preset action type rule parameter library according to the encryption action information;

and modifying the message according to the encryption action parameters to obtain a modified first message, wherein the encryption action parameters comprise an encryption field initial position, an encryption field length, an encryption replacement field position, an encryption replacement field length and an encryption replacement target field length.

9. The method according to claim 1 or 2, wherein the message modification action information comprises summary action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, including:

acquiring abstract action parameters from a preset action type rule parameter library according to the abstract action information;

and modifying the message according to the summary action parameters to obtain a modified first message, wherein the summary action parameters comprise a summary field initial position, a summary field length, a summary increasing field insertion position and a summary increasing field length.

10. An apparatus for message modification, the apparatus comprising:

the acquisition module is used for acquiring messages, and the messages comprise protocol information;

the acquisition module is further configured to acquire a key field of the packet and acquire matching information by querying a key field matching rule table, where the key field matching information includes packet modification action information;

the obtaining module is further configured to obtain, from preset modification rules, a first modification rule that conforms to a first protocol in the protocol information and first key field matching information in the key field matching information, where the first modification rule includes the message modification action information;

and the processing module is used for modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message.

11. An apparatus for message modification, the apparatus comprising: a processor and a memory storing computer program instructions;

the processor, when executing the computer program instructions, implements a method of message modification as claimed in any of claims 1-9.

12. A computer storage medium having computer program instructions stored thereon which, when executed by a processor, implement a method of message modification as claimed in any of claims 1 to 9.

Technical Field

The present invention relates to the field of data transmission, and in particular, to a method, an apparatus, a device, and a storage medium for modifying a packet.

Background

Modern society has become an Internet-based networking society, and a Transmission Control Protocol/Internet Protocol (TCP/IP) Protocol stack is a basic technology of the Internet, thereby causing the technology to be widely implemented in a plurality of devices connected to the Internet. In a TCP/IP protocol stack, forwarding of a data packet is a very critical function, and due to the rapid development of technology and the continuous change of requirements, a forwarding processing algorithm for the data packet needs to meet the requirement of flexibility.

The flexibility of the data packet forwarding processing algorithm requires that when a new protocol or new requirements appear in the network, the codes of software and hardware can be changed as far as possible, and the forwarding of the data packet is realized only through data configuration. Thereby avoiding service interruption and huge maintenance workload brought by software and hardware upgrading. The flexibility of the packet forwarding processing algorithm must depend on modifying the packet message.

Because other systems are basically the same as or different from Linux, taking Linux operating system as an example, implementing message modification in data message forwarding processing by Linux operating system is implemented in code logic in a solidified manner, so that each new protocol is added, new codes are required to implement message modification content of protocol-related message forwarding processing, software and upgrade software must be newly developed, and users pay development cost and upgrade cost for the new software and risk of customer loss caused by service interruption. In addition, the implementation manner of message modification in the message forwarding processing of Linux inevitably brings pipelining of protocol processing, an upper layer protocol needs to be processed after the lower layer protocol is processed, and the capability of concurrent processing of multiple protocols brought by Central Processing Unit (CPU) multi-core multithreading cannot be fully utilized.

Therefore, the problem of strong coupling with protocol processing codes exists when messages are modified in the existing data message forwarding processing process.

Disclosure of Invention

Embodiments of the present invention provide a method, an apparatus, a device, and a storage medium for modifying a packet, which solve the problem of strong coupling with a protocol processing code in modifying a packet in the existing data packet forwarding processing process, so that the implementation of modifying a packet in the data packet forwarding processing is relatively independent from the protocol processing code, and the flexibility of the data packet forwarding processing is improved.

In order to solve the technical problem, the invention is realized as follows:

in a first aspect, a method for modifying a packet is provided, where the method includes:

acquiring a message, wherein the message comprises protocol information;

acquiring a key field of the message, and acquiring key field matching information by inquiring a key field matching rule table, wherein the key field matching information comprises message modification action information;

acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises message modification action information;

and modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message.

In some implementations of the first aspect, the method further comprises:

acquiring a second modification rule which accords with the first protocol and the first keyword matching information from the preset modification rule;

and modifying the message in the first message according to the second modification rule and the message modification action parameter corresponding to the second modification rule to obtain a modified second message.

In some implementations of the first aspect, the method further comprises:

acquiring a replacement action parameter from a preset action type rule parameter library according to the replacement action information;

and modifying the message according to the replacement action parameters to obtain a modified first message, wherein the replacement action parameters comprise a replacement initial position, a replacement field length and a replacement destination field length.

In some implementations of the first aspect, the method further comprises:

acquiring an increased action parameter from a preset action type rule parameter library according to the increased action information;

and modifying the message according to the added action parameters to obtain a modified first message, wherein the added action parameters comprise an initial position and a field length.

In some implementations of the first aspect, the method further comprises:

acquiring a deletion action parameter from a preset action type rule parameter library according to the deletion action information;

and modifying the message according to the deletion action parameter to obtain a modified first message, wherein the deletion action parameter comprises a deletion starting position and a deletion field length.

In some implementations of the first aspect, the method further comprises:

acquiring a verification action parameter from a preset action type rule parameter library according to the verification action information;

and modifying the message according to the verification action parameters to obtain a modified first message, wherein the verification action parameters comprise a verification initial position, a verification field length, a verification result field replacement position and a verification result field replacement length.

In some implementations of the first aspect, the method further comprises:

acquiring a completion action parameter from a preset action type rule parameter library according to the completion action information;

and modifying the message according to the completion action parameters to obtain a modified first message, wherein the completion action parameters comprise the length of a completion field and the content of the completion field.

In some implementations of the first aspect, the method further comprises:

acquiring encryption action parameters from a preset action type rule parameter library according to the encryption action information;

and modifying the message according to the encryption action parameters to obtain a modified first message, wherein the encryption action parameters comprise an encryption field starting position, an encryption field length, an encryption replacement field position, an encryption replacement field length and an encryption replacement target field length.

In some implementations of the first aspect, the method further comprises:

acquiring abstract action parameters from a preset action type rule parameter library according to the abstract action information;

and modifying the message according to the summary action parameters to obtain a modified first message, wherein the summary action parameters comprise a summary field initial position, a summary field length, a summary increasing field insertion position and a summary increasing field length.

In a second aspect, an apparatus for modifying a packet is provided, where the apparatus includes:

the acquisition module is used for acquiring messages, and the messages comprise protocol information;

the acquisition module is also used for acquiring the key field of the message and acquiring matching information by inquiring the key field matching rule table, wherein the key field matching information comprises message modification action information;

the acquisition module is further used for acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises message modification action information;

and the processing module is used for modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message.

In some implementations of the second aspect,

the acquisition module is further used for acquiring a second modification rule which accords with the first protocol and the first keyword end matching information from the preset modification rule;

and the processing module is further used for modifying the message in the first message according to the second modification rule and the message modification action parameter corresponding to the second modification rule to obtain a modified second message.

In some implementations of the second aspect,

the acquisition module is also used for acquiring the replacement action parameters from a preset action type rule parameter library according to the replacement action information;

and the processing module is further used for modifying the message according to the replacement action parameters to obtain a modified first message, wherein the replacement action parameters comprise a replacement starting position, a replacement field length and a replacement destination field length.

In some implementations of the second aspect,

the acquisition module is also used for acquiring the increased action parameters from a preset action type rule parameter library according to the increased action information;

and the processing module is further used for modifying the message according to the added action parameter to obtain a modified first message, wherein the added action parameter comprises an increased initial position and an increased field length.

In some implementations of the second aspect,

the acquisition module is also used for acquiring the deletion action parameters from a preset action type rule parameter library according to the deletion action information;

and the processing module is further used for modifying the message according to the deletion action parameter to obtain a modified first message, wherein the deletion action parameter comprises a deletion starting position and a deletion field length.

In some implementations of the second aspect,

the acquisition module is also used for acquiring the verification action parameters from a preset action type rule parameter library according to the verification action information;

and the processing module is further used for modifying the message according to the verification action parameters to obtain a modified first message, wherein the verification action parameters comprise a verification initial position, a verification field length, a verification result field replacement position and a verification result field replacement length.

In some implementations of the second aspect,

the acquisition module is also used for acquiring the completion action parameters from a preset action type rule parameter library according to the completion action information;

and the processing module is further used for modifying the message according to the completion action parameters to obtain a modified first message, wherein the completion action parameters comprise the length of the completion field and the content of the completion field.

In some implementations of the second aspect,

the acquisition module is also used for acquiring the encryption action parameters from a preset action type rule parameter library according to the encryption action information;

and the processing module is further used for modifying the message according to the encryption action parameters to obtain a modified first message, wherein the encryption action parameters comprise an encryption field starting position, an encryption field length, an encryption replacement field position, an encryption replacement field length and an encryption replacement target field length.

In some implementations of the second aspect,

the acquisition module is also used for acquiring abstract action parameters from a preset action type rule parameter library according to the abstract action information;

and the processing module is further used for modifying the message according to the summary action parameters to obtain a modified first message, wherein the summary action parameters comprise a summary field initial position, a summary field length, a summary increasing field insertion position and a summary increasing field length.

In a third aspect, an apparatus for modifying a packet is provided, where the apparatus includes: a processor and a memory storing computer program instructions;

the first aspect, and methods of message modification in some implementations of the first aspect, are implemented when computer program instructions are executed by a processor.

In a fourth aspect, a computer storage medium is provided having computer program instructions stored thereon that, when executed by a processor, implement the first aspect and a method of message modification in some implementations of the first aspect.

The embodiment of the invention provides a method, a device, equipment and a storage medium for message modification. Acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises the message modification action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, wherein the modification process is independent of any protocol, a newly-added protocol can be supported by only increasing the configuration of database table entries, and software and hardware code logic does not need to be newly added any more, so that the problem of strong coupling with protocol processing codes existing in the process of modifying the message in the process of forwarding the data message is solved, the message modification in the process of forwarding the data packet is relatively independent of the protocol processing codes, and the flexibility of the process of forwarding the data packet is improved.

Drawings

In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the embodiments of the present invention will be briefly described below, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.

Fig. 1 is a schematic structural diagram of a TCP/IP protocol stack provided in an embodiment of the present invention;

fig. 2 is a schematic flowchart of a method for modifying a message according to an embodiment of the present invention;

fig. 3 is a schematic structural diagram of a message modification apparatus according to an embodiment of the present invention;

fig. 4 is a block diagram of an exemplary hardware architecture of a computing device provided by an embodiment of the present invention.

Detailed Description

Features and exemplary embodiments of various aspects of the present invention will be described in detail below, and in order to make objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not to be construed as limiting the invention. It will be apparent to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present invention by illustrating examples of the present invention.

It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Modern society has become an Internet-based networking society, and a Transmission Control Protocol/Internet Protocol (TCP/IP) Protocol stack is a basic technology of the Internet, thereby causing the technology to be widely implemented in a plurality of devices connected to the Internet. In a TCP/IP protocol stack, forwarding of a data packet is a very critical function, and due to the rapid development of technology and the continuous change of requirements, a forwarding processing algorithm for the data packet needs to meet the requirement of flexibility.

The flexibility of the data packet forwarding processing algorithm requires that when a new protocol or new requirements appear in the network, the codes of software and hardware can be changed as far as possible, and the forwarding of the data packet is realized only through data configuration. Thereby avoiding service interruption and huge maintenance workload brought by software and hardware upgrading. The flexibility of the packet forwarding processing algorithm must depend on modifying the packet message.

Fig. 1 is a schematic diagram of a TCP/IP protocol stack structure provided in an embodiment of the present invention.

As shown in fig. 1, the TCP/IP stack structure usually has a link layer protocol ethernet protocol packet as the bottom layer, and sequentially includes an IP protocol packet, a TCP protocol packet, an application layer protocol packet, and user data. The user data is usually added with an application layer protocol header (api), a TCP protocol header (TCP header), an IP protocol header (IP header), an ethernet protocol header (ethernet header) and an ethernet trailer (ethernet trailer) from top to bottom in sequence.

In addition, the modification of the data packet may include adding, stripping headers, inserting partial content into the packet, stripping partial content, and modifying partial content.

For the implementation of message modification in packet forwarding processing, the implementation mode of Linux is a representative, and other systems are basically the same as or different from Linux, so the message modification in packet forwarding processing of a Linux operating system is taken as an example.

The implementation of message modification in the Linux operating system data message forwarding processing is implemented in code logic in a fixed manner. The protocol stack has a section of fixed code for each protocol, which includes the implementation of message modification during the data message forwarding process. For example, when the layer two bridge forwards, a VLAN field is added to the Ethernet protocol header; and modifying the source of the Ethernet protocol header, the field of the destination MAC address and the like during route forwarding. Each protocol has a code module, which includes the message modification implementation of the layer protocol message forwarding process.

In the above method for modifying a packet in a data packet forwarding process, which takes the Linux operating system as an example, every time a new protocol is added, a new code is required to implement the packet modification content of the protocol-related packet forwarding process, software and upgrade software must be newly developed, and a user must pay development cost and upgrade cost for the new software and risk of client loss caused by service interruption.

In addition, the implementation of message modification in the message forwarding processing inevitably brings pipelining of protocol processing, an upper layer protocol can be processed only after the lower layer protocol is processed, and the capability of multi-protocol concurrent processing brought by multi-core and multi-thread of a Central Processing Unit (CPU) cannot be fully utilized. The delay of data packet processing is increased, and some service requirements with harsh requirements on delay cannot be met.

In summary, the method for modifying the packet in the data packet forwarding process has a problem of strong coupling with the protocol processing code.

In order to solve the problem of strong coupling with a protocol processing code in the above technical solution, embodiments of the present invention provide a method, an apparatus, a device, and a storage medium for modifying a message, on the basis of analyzing general characteristics of message modification in message forwarding processing, by obtaining a key field and protocol information included in a message, and by querying a key field matching rule table, matching information is obtained, where the key field matching information includes message modification action information. Acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises the message modification action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, wherein the modification process is independent of any protocol, a newly-added protocol can be supported by only increasing the configuration of database table entries, and software and hardware code logic does not need to be newly added any more, so that the problem of strong coupling with protocol processing codes existing in the process of modifying the message in the process of forwarding the data message is solved, the message modification in the process of forwarding the data packet is relatively independent of the protocol processing codes, and the flexibility of the process of forwarding the data packet is improved.

Before describing the method, the device, the equipment and the storage medium for message modification provided by the embodiment of the invention, the inventor analyzes the message modification in the forwarding processing of each protocol of a TCP/IP protocol stack to obtain the commonalities in the method for message modification, and lists the following characteristics:

1. the message modification comprises four modifications of field addition, field deletion, field modification and field encryption.

2. Each modification starts based on an offset in the header of the message protocol and requires specifying the length of the modification field.

3. Some modifications may require starting based on a trailer at the header of the message protocol, or based on a trailer at the protocol layer.

4. The modified content of the field is generally related to a certain key field of the header of the message protocol, and the modified content needs to be obtained through key field matching.

5. Some contents of the modified fields need to be obtained according to calculation, and the calculation mainly includes checksum calculation and summary calculation. The calculation is performed on the basis of certain fields of the data message. The algorithms for Checksum calculations and digest calculations are limited.

6. And encrypting fields, wherein an encryption algorithm is required, the encryption algorithm is limited, and the encryption algorithm is carried out according to certain fields of the data message.

Based on the above characteristics of analysis, the inventor provides a method, an apparatus, a device and a storage medium for message modification.

The technical solutions provided by the embodiments of the present invention are described below with reference to the accompanying drawings.

Fig. 2 is a flowchart illustrating a method for modifying a message according to an embodiment of the present invention. As shown in fig. 2, an execution subject of the method may be a terminal device, and the method for modifying a message may include:

s201: and acquiring the message.

S202: and acquiring the key field of the message, and acquiring the key field matching information by inquiring the key field matching rule table.

The key field matching information comprises message modification action information.

S203: and acquiring a first protocol in the protocol information and a first modification rule according with the first key field matching information in the key field matching information from a preset modification rule, wherein the first modification rule comprises message modification action information.

S204: and modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message.

Specific implementations of the above steps will be described in detail below.

The method for modifying a packet shown in fig. 2 is independent of any protocol on the basis of analyzing the general characteristics of packet modification in packet forwarding processing, can support a newly added protocol by only increasing the configuration of database table entries, and does not need to add software and hardware code logic newly, so that the problem of strong coupling with protocol processing codes in the process of forwarding a data packet is solved, the packet modification in packet forwarding processing is relatively independent of the protocol processing codes, and the flexibility of packet forwarding processing is improved.

In order to match the modification action parameters of the acquired message, in S201, before the message is acquired, a unified protocol coding rule database is predefined, a key field configuration database, a modification rule table, a replacement modification rule parameter database, a deletion modification rule parameter database, a verification modification rule parameter database, a completion modification rule parameter database, an encryption modification rule parameter database, and a digest modification rule parameter database.

Wherein, each element of the table entry of the protocol coding rule database is stored by network byte order, which comprises the following steps: the protocol encoding rule base index (starting from 0), the protocol header length field gets the bitmap, the protocol header length (byte length) protocol type name. Wherein, the protocol coding rule base index is a primary key. The database is generated by the configuration.

The key field configures a database, and all elements of database table entries are stored by network byte order, including: key field rule base index (starting from 0), key field protocol encoding rule base index, key field acquisition bitmap.

Modifying the rule table, including: protocol coding rule base index, key field rule base index, modification rule table sequence number, modification action (replacement (0), addition (1), deletion (2), verification (4), completion (5), encryption (6) and summary (7)).

The replacement modification rule parameter library comprises: the method comprises the steps of protocol coding rule base index, key field rule base index, modification rule table sequence number, replacement field offset (relative to a protocol head), replacement field protocol head tail offset (relative to a protocol head tail), replacement field protocol tail offset (relative to a whole protocol message tail), replacement field length (field in a data message), replacement destination field length and key field matching item action parameter sequence number.

Adding a modification rule parameter library, comprising: the method comprises the steps of protocol coding rule base index, key field rule base index, modification rule table sequence number, field offset increasing (relative to a protocol head), field protocol head tail offset increasing (relative to a protocol head tail), field protocol tail offset increasing (relative to a whole protocol message tail), field length increasing and key field matching item action parameter sequence number.

Deleting the modification rule parameter library, including: the protocol coding rule base index, the key field rule base index, the sequence number of the modification rule table, the offset of the deleted field (relative to the head of the protocol), the offset of the tail of the head of the deleted field protocol (relative to the tail of the head of the protocol), the offset of the tail of the deleted field protocol (relative to the tail of the whole protocol message), and the length of the deleted field.

The verification modification rule parameter library comprises: the method comprises the steps of protocol coding rule base index, key field rule base index, modification rule table sequence number, check field offset (relative to a protocol head), check field protocol head tail offset (relative to a protocol head tail), check field protocol tail offset (relative to the tail of the whole protocol message), check field length (field in a datagram), check replacement field offset (relative to a protocol head), check replacement field protocol head tail offset (relative to a protocol head tail), check replacement field protocol tail offset (relative to the tail of the whole protocol message), check replacement field length (field in the datagram), and check replacement target field length.

The completion modification rule parameter library comprises: protocol coding rule base index, key field rule base index, modification rule table sequence number, field alignment block length completion and byte content completion.

An encryption modification rule parameter base comprising: a protocol coding rule base index, a key field rule base index, a modification rule table sequence number, an encryption field offset (relative to a protocol header), an encryption field protocol header tail offset (relative to a protocol header tail), an encryption field protocol tail offset (relative to a whole protocol packet tail), an encryption field length (field in a data packet), an encryption replacement field offset (relative to a protocol header), an encryption replacement field protocol header tail offset (relative to a protocol header tail), an encryption replacement field protocol tail offset (relative to a whole protocol packet tail), an encryption replacement field length (field in a data packet), an encryption replacement destination field length, a key field matching item action number 1, a key field matching item action parameter number 2, and a key field matching item action parameter number 3.

The abstract modification rule parameter library comprises: protocol coding rule base index, key field rule base index, modification action sequence number, summary field offset (relative to protocol header), summary field protocol header tail offset (relative to protocol header tail), summary field protocol tail offset (relative to whole protocol packet tail), summary field length (field in data packet), summary increase field offset (relative to protocol header), summary increase field protocol header tail offset (relative to protocol header tail), summary increase field protocol tail offset (relative to whole protocol packet tail), summary increase field length (field in data packet), key field matching item action number 1, key field matching item action parameter number 2, key field matching item action parameter number 3.

Specific implementations of the above steps are described below.

S201: and acquiring the message.

The message includes protocol information, and the message may also be referred to as a data message.

Specifically, all protocol information of the data packet may be acquired and set as the current protocol information table of the data packet.

S202: and acquiring the key field of the message, and acquiring the key field matching information by inquiring the key field matching rule table.

The key field matching information includes message modification action information, and the key field matching rule table may include a predefined key field configuration database.

Specifically, the related key fields may be obtained from the data packet, a predefined key field configuration database of the system is searched, matching information of all key fields is obtained, and is set as a current key field matching information table, where the matching information table includes message modification action information, and the message modification action information may be modification actions (replacement (0), addition (1), deletion (2), verification (4), completion (5), encryption (6), and digest (7)) in a predefined modification rule table.

S203: and acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises message modification action information.

Specifically, the first protocol in the current protocol information table of the data message can be obtained and set as the current protocol; and acquiring first key field matching information in the current key field matching information table, and setting the first key field matching information as the current key field matching information.

And then, acquiring a first modification rule corresponding to the current protocol and the current key field matching information from the preset modification rule, and setting the first modification rule as the current modification rule, wherein the preset modification rule can comprise a predefined modification rule table, the current modification rule comprises message modification action information, and the preset modification rule can be a preset modification rule table.

After the message modification action information is acquired according to the message, modification parameters may be determined to modify the message according to the acquired message modification action information, that is, the process proceeds to S104.

S204: and modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message.

Specifically, the first modification rule is referred to as a current modification rule, and the current modification rule includes message modification action information, so that it may be determined whether the current modification rule exists, and if so, the modification action parameter corresponding to the message modification action information is obtained from a modification rule parameter library corresponding to the current modification rule to modify the message, so as to obtain a modified first message.

In addition, after the message is modified to obtain the modified first message, in order to more comprehensively modify the message according to the message modification action information included in the message, optionally, in an embodiment, a next modification rule conforming to the current protocol and the current key field matching information may be further obtained from a predefined modification rule table, and set as a new current modification rule, where the predefined modification rule may include a predefined modification rule table, and the current modification rule includes message modification action information.

And then, whether a new current modification rule exists can be judged, if yes, the corresponding modification action parameter is obtained from a modification rule parameter library corresponding to the new current modification rule to modify the message, and a modified second message is obtained.

Optionally, in an embodiment, the current modification rule may be updated circularly until the current modification rule is not updated, and the circulation is stopped to generate the final modified packet.

Additionally, modifying the action information may include replacing the action information, adding the action information, deleting the action information, verifying the action information, complementing the action information, encrypting the action information, and summarizing the action information.

Optionally, in an embodiment, the replacement action parameter may be obtained from a preset action type rule parameter library according to the replacement action information.

Modifying the message according to the replacement action parameter to obtain a modified first message, wherein the replacement action parameter may include a replacement field offset (relative to the protocol header), a replacement field protocol header tail offset (relative to the protocol header tail), a replacement field protocol tail offset (relative to the tail of the entire protocol message), a replacement field length (field in the datagram), and a replacement destination field length.

Optionally, in an embodiment, the add action parameter may be obtained from a preset action type rule parameter library according to the add action information.

Modifying the message according to the added action parameter to obtain a modified first message, wherein the added action parameter comprises added field offset (relative to the protocol head), added field protocol head tail offset (relative to the protocol head tail), added field protocol tail offset (relative to the tail of the whole protocol message) and added field length.

Optionally, in an embodiment, the delete action parameter may be obtained from a preset action type rule parameter library according to the delete action information.

Modifying the message according to the deleting action parameter to obtain a modified first message, wherein the deleting action parameter comprises a deleting field offset (relative to the protocol head), a deleting field protocol head tail offset (relative to the protocol head tail), a deleting field protocol tail offset (relative to the tail of the whole protocol message), and a deleting field length.

Optionally, in an embodiment, the verification action parameter may be obtained from a preset action type rule parameter library according to the verification action information.

Modifying the message according to the checking action parameters to obtain a modified first message, wherein the checking action parameters comprise a checking field offset (relative to a protocol head), a checking field protocol head tail offset (relative to a protocol head tail), a checking field protocol tail offset (relative to a whole protocol message tail), and a checking field length (field in a data message); the method can also comprise checking a replacement field offset (relative to a protocol header), checking a replacement field protocol header tail offset (relative to a protocol header tail), checking a replacement field protocol tail offset (relative to the tail of the whole protocol message), checking a replacement field length (field in a data message), and checking a replacement destination field length.

Optionally, in an embodiment, the completion action parameter may be obtained from a preset action type rule parameter library according to the completion action information.

And modifying the message according to the completion action parameters to obtain a modified first message, wherein the completion action parameters comprise the length of a completion field alignment block and the content of a completion byte.

Optionally, in an embodiment, the encryption action parameter may be obtained from a preset action type rule parameter library according to the encryption action information.

Modifying the message according to the encryption action parameters to obtain a modified first message, wherein the encryption action parameters comprise encryption field offset (relative to a protocol header), encryption field protocol header tail offset (relative to a protocol header tail), encryption field protocol tail offset (relative to a whole protocol message tail), encryption field length (field in the datagram), encryption replacement field offset (relative to a protocol header), encryption replacement field protocol header tail offset (relative to a protocol header tail), encryption replacement field protocol tail offset (relative to a whole protocol message tail), encryption replacement field length (field in the datagram), and encryption replacement target field length.

Optionally, in an embodiment, the summary action parameters may be obtained from a preset action type rule parameter library according to the summary action information.

Modifying the message according to the summary action parameters to obtain a modified first message, wherein the summary action parameters comprise summary field offset (relative to a protocol header), summary field protocol header tail offset (relative to a protocol header tail), summary field protocol tail offset (relative to a whole protocol message tail), summary field length (field in a datagram), summary increasing field offset (relative to a protocol header), summary increasing field protocol header tail offset (relative to a protocol header tail), summary increasing field protocol tail offset (relative to a whole protocol message tail), and summary increasing field length (field in a datagram).

The method for modifying the message provided by the embodiment of the invention can use the same software processing and flow for the requirements of different data message modification of different protocols, such as field addition and deletion, field replacement, field completion, calculation verification, compression, encryption, abstract and the combination of the modification on any position of the message. The process of newly developing software or upgrading software due to different protocols, different modification positions and different modification combinations can be avoided.

The method for modifying the message provided by the embodiment of the invention obtains the matching information by acquiring the key field and the protocol information included in the message and inquiring the key field matching rule table on the basis of analyzing the general characteristics of message modification in the message forwarding process, wherein the key field matching information includes message modification action information. Acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises message modification action information; the message is modified according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain the modified first message, the modification process is independent of any protocol, a newly-added protocol can be supported by only increasing the configuration of the table entry of the database, and software and hardware code logic does not need to be newly added any more, so that the problem that the message is modified in the data message forwarding processing process and is strongly coupled with the protocol processing code is solved, the message modification in the data packet forwarding processing is relatively independent of the protocol processing code, and the flexibility of the data packet forwarding processing is improved.

Corresponding to the embodiment of the message modification method, the embodiment of the invention also provides a message modification device.

Fig. 3 is a schematic structural diagram of a message modification apparatus according to an embodiment of the present invention.

As shown in fig. 3, the message modification apparatus may include: an acquisition module 301 and a processing module 302.

The obtaining module 301 may be configured to obtain a message, where the message includes protocol information.

The obtaining module 301 may further be configured to obtain a key field of the packet, and obtain matching information by querying a key field matching rule table, where the key field matching information includes packet modification action information.

The obtaining module 301 may further be configured to obtain, from preset modification rules, a first modification rule that conforms to a first protocol in the protocol information and first key field matching information in the key field matching information, where the first modification rule includes message modification action information.

The processing module 302 may further be configured to modify the packet according to the first modification rule and the modification action parameter corresponding to the first modification rule, so as to obtain a modified first packet.

The obtaining module 301 may further be configured to obtain, from the preset modification rule, a second modification rule that conforms to the first protocol and the first keyword matching information.

The processing module 302 may further be configured to modify the packet in the first packet according to the second modification rule and the packet modification action parameter corresponding to the second modification rule, so as to obtain a modified second packet.

The obtaining module 301 may further be configured to obtain a replacement action parameter from a preset action type rule parameter library according to the replacement action information.

The processing module 302 may further be configured to modify the packet according to the replacement action parameter to obtain a modified first packet, where the replacement action parameter includes a replacement start position, a replacement field length, and a replacement destination field length.

The obtaining module 301 may further be configured to obtain an add action parameter from a preset action type rule parameter library according to the add action information.

The processing module 302 may further be configured to modify the packet according to the added action parameter to obtain a modified first packet, where the adding the action parameter includes adding the start position and increasing the length of the field.

The obtaining module 301 may further be configured to obtain the delete action parameter from the preset action type rule parameter library according to the delete action information.

The processing module 302 may further be configured to modify the packet according to the deletion action parameter, so as to obtain a modified first packet, where the deletion action parameter includes a deletion start position and a deletion field length.

The obtaining module 301 may further be configured to obtain the verification action parameter from a preset action type rule parameter library according to the verification action information.

The processing module 302 may further be configured to modify the packet according to the verification action parameter to obtain a modified first packet, where the verification action parameter includes a verification start position, a verification field length, a verification result field replacement position, and a verification result field replacement length.

The obtaining module 301 may further be configured to obtain a completion action parameter from a preset action type rule parameter library according to the completion action information.

The processing module 302 may further be configured to modify the packet according to the completion action parameter to obtain a modified first packet, where the completion action parameter includes a completion field length and a completion field content.

The obtaining module 301 may further be configured to obtain the encryption action parameter from a preset action type rule parameter library according to the encryption action information.

The processing module 302 may further be configured to modify the packet according to the encryption action parameter to obtain a modified first packet, where the encryption action parameter includes an encryption field start position, an encryption field length, an encryption replacement field position, an encryption replacement field length, and an encryption replacement destination field length.

The obtaining module 301 may further be configured to obtain the summary action parameters from a preset action type rule parameter library according to the summary action information.

The processing module 302 may further be configured to modify the packet according to the digest action parameter to obtain a modified first packet, where the digest action parameter includes a digest field start position, a digest field length, a digest increase field insertion position, and a digest increase field length.

The message modification device provided by the embodiment of the invention obtains the matching information by acquiring the key field and the protocol information included in the message and inquiring the key field matching rule table on the basis of analyzing the general characteristics of message modification in the message forwarding process, wherein the key field matching information includes message modification action information. Acquiring a first modification rule which is consistent with a first protocol in the protocol information and first key field matching information in the key field matching information from preset modification rules, wherein the first modification rule comprises the message modification action information; modifying the message according to the first modification rule and the modification action parameter corresponding to the first modification rule to obtain a modified first message, wherein the modification process is independent of any protocol, a newly-added protocol can be supported by only increasing the configuration of database table entries, and software and hardware code logic does not need to be newly added any more, so that the problem of strong coupling with a protocol processing code in the process of modifying the message in the process of forwarding the data message is solved, the message modification in the process of forwarding the data packet is relatively independent of the protocol processing code, and the flexibility of the process of forwarding the data packet is improved.

Fig. 4 is a block diagram illustrating an exemplary hardware architecture of a computing device capable of implementing a method of message modification according to an embodiment of the present invention. As shown in fig. 4, computing device 400 includes an input device 401, an input interface 402, a central processor 403, a memory 404, an output interface 405, and an output device 406. The input interface 402, the central processing unit 403, the memory 404, and the output interface 405 are connected to each other through a bus 410, and the input device 401 and the output device 406 are connected to the bus 410 through the input interface 402 and the output interface 405, respectively, and further connected to other components of the computing device 400.

Specifically, the input device 401 receives input information from the outside and transmits the input information to the central processor 403 through the input interface 402; the central processor 403 processes the input information based on computer-executable instructions stored in the memory 404 to generate output information, stores the output information temporarily or permanently in the memory 404, and then transmits the output information to the output device 406 through the output interface 405; output device 406 outputs the output information outside of computing device 400 for use by a user.

That is, the computing device shown in fig. 4 may also be implemented as a message modification device, which may include: a memory storing computer-executable instructions; and the processor, when executing the computer executable instruction, can implement the message modification method provided by the embodiment of the invention.

An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium has computer program instructions stored thereon; the computer program instructions, when executed by a processor, implement the method for message modification provided by embodiments of the present invention.

It is to be understood that the invention is not limited to the specific arrangements and instrumentality described above and shown in the drawings. A detailed description of known methods is omitted herein for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present invention are not limited to the specific steps described and illustrated, and those skilled in the art can make various changes, modifications and additions or change the order between the steps after comprehending the spirit of the present invention.

The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, plug-in, function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted by a data signal carried in a carrier wave over a transmission medium or a communication link. A "machine-readable medium" may include any medium that can store or transfer information. Examples of a machine-readable medium include electronic circuits, semiconductor memory devices, ROM, flash memory, Erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, Radio Frequency (RF) links, and so forth. The code segments may be downloaded via computer networks such as the internet, intranet, etc.

It should also be noted that the exemplary embodiments mentioned in this patent describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, may be performed in an order different from the order in the embodiments, or may be performed simultaneously.

As described above, only the specific embodiments of the present invention are provided, and it can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system, the module and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. It should be understood that the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the present invention, and these modifications or substitutions should be covered within the scope of the present invention.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:网络设备连网方法、电子装置及计算机可读储存媒体

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类