CN113835712A - Fast data packet routing method for judging according to given field value - Google Patents
Fast data packet routing method for judging according to given field value Download PDFInfo
- Publication number
- CN113835712A CN113835712A CN202111115900.7A CN202111115900A CN113835712A CN 113835712 A CN113835712 A CN 113835712A CN 202111115900 A CN202111115900 A CN 202111115900A CN 113835712 A CN113835712 A CN 113835712A
- Authority
- CN
- China
- Prior art keywords
- expression
- value
- packet
- judgment
- creating
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44568—Immediately runnable code
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention belongs to the field of aerospace measurement and control and information processing, and discloses a rapid data packet grouping routing method for judging according to a given field value. The method comprises the following 7 steps: step one, defining the format of a packet routing condition (GRC); defining the formats of a packet routing rule and a packet routing rule file; step three, compiling a packet routing rule file; step four, establishing a reference value object list according to the routing rule file; step five, generating a field judgment expression object list; step six, generating a packet routing rule object list; step seven, grouping the routing data by using the grouping routing rule object list. Compared with other methods, the method has the advantages that the packet routing conditions defined by the user are compiled into a direct comparison method in advance by using an expression tree technology, branch judgment statements for performing comparison one by one according to judgment symbols are reduced, the packet routing speed is higher, and the method is more suitable for high-real-time tasks such as space launch.
Description
Technical Field
The invention belongs to the field of aerospace measurement and control and information processing, and relates to a rapid data packet grouping routing method for judging according to a user given position field value in a data packet.
Background
In the space launch test task, various sensors are used for carrying out real-time tracking measurement on the flight process of a target, and the various sensors comprise various types of radar equipment, optical equipment, telemetering equipment, a multi-speed measurement system, navigation satellite measuring equipment and the like. The multi-source and multi-type measurement data acquired by the sensors are transmitted to each data processing center and each flight control center in real time through various networks.
The data processing center and the flight control center are composed of various processing subsystems, and each processing subsystem needs different measurement data, for example, the outer trajectory processing subsystem only needs the measurement data of radar equipment and a multi-speed measurement system, and the remote measurement processing subsystem only needs remote measurement equipment to measure the data, and the like.
In the aerospace test task, in order to send data to a plurality of processing centers and control centers in real time at the same time, measuring equipment generally cannot send data point to point in an on-demand mode, but uniformly sends data to each center in a multicast mode, measuring sensors of various types send data to the same multicast group, and each center joins the same multicast group to receive data at the same time. Thus, conventional IP-based routing does not effectively distinguish between data types and thus does not efficiently group route packets according to processing system requirements. This results in all processing devices receiving all types of packets and then discarding the packets that are not needed (or cannot be processed), greatly increasing the throughput and processing pressure of the infrastructure, especially the pressure on the intranet, and also increasing the workload and pressure on the network receive modules of the data processing system. Even when the peak flow occurs, it may cause blocking of the receiving module, overflow of the buffer, etc., thereby resulting in loss of useful data packets or abnormal exit of the system in severe cases.
How to fast group and route multi-source and multi-type measurement data in real time according to the requirements of processing equipment in a complex network transmission environment in an aerospace task is an urgent problem to be solved.
Disclosure of Invention
The invention aims to provide a rapid data packet grouping routing method for judging according to a given field value, which solves the problem of real-time rapid routing of multi-source and multi-type measurement data according to user requirements in a complex network transmission environment in an aerospace task.
In order to achieve the purpose, the technical scheme of the invention is as follows:
a fast packet routing method for performing a decision according to a given field value, the method comprising the steps of:
the method comprises the following steps: defining the format of a packet routing condition GRC;
step two: defining a packet routing rule GRR and a packet routing rule file based on the packet routing condition GRC;
step three: compiling a packet routing rule file;
step four: establishing a reference value object list according to the packet routing rule file;
step five: and generating a field judgment expression object list according to the packet routing rule file and the reference value object list.
Step six, generating a grouping routing rule object list;
and step seven, grouping the routing data by using the grouping routing rule object list.
Further, the first step further comprises:
the packet routing condition GRC is composed of one or more field judgment expressions, which are divided by semicolons (;), such as:
FCE1;FCE2;…
the field judgment expression comprises a field starting position, a type, a judgment symbol and a judgment reference value, wherein the field starting position refers to the position of a field which a user wants to check in a data packet and is marked as P; the numerical Type of the field is recorded as Type, and the Type represents the Type of the field starting from P in the data packet; the judgment reference value is BaseValue, which refers to a reference value used for comparing with the value of the check field, and may be a single value a, two values a, b, or a plurality of values a, b, c, d, … according to the judgment method; the judgment symbol is a symbol representing a judgment method, is marked as S, and has comparison operations of equal to, unequal to, greater than, less than, greater than or equal to, less than or equal to, between the two, one of a plurality of values and the like;
a field judgment expression FCE is expressed as follows:
P:Type:[S]BaseValue
in the above formula, when S is "═ then S may be omitted from being unwritten.
Further, the second step further comprises:
defining a packet routing rule GRR according to the following formula according to the format of the packet routing condition GRC defined in the step one:
GRC IP:Port
wherein, the Port represents the route destination, which is composed of the IP address of the destination host and the Port of the destination Port and is divided by a semicolon (:);
the packet routing rule file is formed by a plurality of lines of GRRs and is used for realizing packet routing of different data packets according to rules.
Further, the third step further comprises:
3.1 determining the position P and the data Type of each field used for grouping in the data packet;
3.2 determining a reference value BaseValue and a judgment method S for the grouping according to the grouping requirement for each field for grouping;
3.3 writing a field judgment expression FCE for each key field according to the field judgment expression format P defined in the first step, wherein the Type is S base value;
3.4 combining the field judgment expressions FCE to form a packet routing condition GRC according to the packet routing condition format defined in the first step;
3.5 determining the routing destination IP address and Port, forming the packet routing rule GRR:
GRCIP:Port
3.6 for each data packet to be grouped and routed, executing the steps 3.1 to 3.5, and adding the routing rule to the file line by line to form a final grouping and routing rule file.
Further, the fourth step further comprises:
4.0 creates an empty reference value object list baseValueList for storing the created IOpValue object.
4.1 reading a routing rule GRR from the packet routing rule file;
4.2, dividing GRR by using a blank space, and obtaining a grouping routing condition GRC by taking the first half part of the divided character string array;
4.3 dividing GRC by using semicolon (;) to form field judgment expression arrays FCEs;
4.4, aiming at the array FCEs, taking a first element to obtain a field judgment expression FCE;
4.5 obtaining Type from FCE of Type [ S ] BaseValue;
4.6 get the [ S ] BaseValue part from FCE;
4.8 judging whether S is one of-, "-" or "" or not, if so, executing 4.9, otherwise, executing 4.10;
4.9 creating a benchmark object MultiValue representing a plurality of numerical value compositions from S, Type and BaseValue;
4.9.1 partitioning BaseValue with comma (,) and converting the resulting string to a numerical value, resulting in a numerical value V1,V2,…,Vn;
4.9.2 at S, Type and V1,V2,…,VnFor the parameter, calling a constructor to create a MultiValue object;
4.9.3, constructing a judgment method expression tree of MultiValue:
Expression<Func<T1,bool>>CheckExpression<T1>(string op)
in the formula, the form parameter op represents a judgment method, and the value range is shown in table 2. In the MultiValue object, the value can only be one of "-", "-" or "," between the two or one of a plurality of data.
4.10 creating a reference value object SingleValue representing the composition of the individual values from S, Type and BaseValue;
4.10.1, carrying out numerical value conversion on the BaseValue character string to obtain a numerical value V of a judgment standard;
4.10.2 calling a constructor to create a SingleValue object by taking S, Type and V as parameters;
4.10.3, constructing a judgment method expression tree of SingleValue:
Expression<Func<T1,bool>>CheckExpression<T1>(string op)
the shape parameter op in the formula represents a judgment method; in the SingleValue object, the value is "═ and"! One of "", ">", "<" > ", and" < ">";
4.11 add the created benchmark object MultiValue or SingleValue object to the end of the baseValueList.
4.12 taking down an element from the array FCEs to obtain a new field judgment expression FCE;
4.13 circularly executing the steps 4.5 to 4.12 until the processing of the current packet routing condition GRC is finished;
4.14 reading the next routing rule GRR from the packet routing rule file, and circularly executing 4.2 to 4.13 until the file is completely processed.
Further, the specific steps of constructing the judgment method expression tree are as follows:
(1) if the value of op is determined to be "" or "-", the steps (2) to (9) are executed, and if the value is ",", the steps (10) to (14) are executed.
(2) Creating an expression tree node v representing input parameters, wherein v represents data to be compared and has the type of T1;
(3) a smaller one of V1, V2, creates a constant expression min;
(4) creating a constant expression max from the larger one of V1, V2;
(5) creating a comparison expression greatExp which is more than or equal to v and min respectively, and comparing whether the input parameter v is more than or equal to a reference value min or not;
(6) creating a less than comparison expression lessExp with parameters of v and max respectively, and comparing whether the input parameter v is less than a reference value max;
(7) creating logic And connecting the greatExp And the lessExp with an And expression betweenExp, wherein the logic And the Ant expression betweenExp represent that the input v simultaneously meets the conditions that the input v is more than or equal to a reference value min And less than a reference value max;
(8) creating a function expression func, wherein the parameter is beta-enExp, the input parameter is v, the return value is Boolean, and the function expression func represents that whether the input parameter v is larger than or equal to or smaller than the check is completed, namely whether v is between the two checks is completed;
(9) returning to func, and judging that the construction of the method expression tree is finished;
(10) creating zero-time variable expressions p and v, wherein v represents a parameter to be input later, and p is a zero-time variable;
(11) creating an equality comparison expression equalExp with parameters p and v, respectively, for checking whether p is equal to v;
(12) creating a method call expression Exists, calling a method 'Exists' of an array, wherein the parameter is equalExp, and the method equalExp is used for checking whether data equal to p exist in the array or not;
(13) creating a function expression func, wherein the parameter is exists, the return value is Boolean, the input parameter is v, and the method for executing the exists expression on the input parameter v is represented, namely, the judgment equal to one of a plurality of data is realized;
(14) and returning to func, and judging that the construction of the expression tree of the method is finished.
Further, the specific steps of constructing the expression tree of the SingleValue judgment method are as follows:
(1) creating an expression p representing an input parameter, wherein the type of the expression p is T1;
(2) creating a constant expression c, and taking the value as a value V represented by the current reference value object;
(3) judging the value of the op, and if the value of the op is equal to the value, executing the steps (4) and (5); if the value of op is "! "executing the steps (6) and (7); if the value of the op is' >, executing the steps (8) and (9); if the value of op is "<", executing the (10) th and (11) th steps; if the value of op is ">, the (12) th and (13) th steps are executed; if the value of the op is < ═ then steps (14) and (15) are executed, and finally step (16) is executed uniformly to obtain the final result;
(4) creating an 'equality' comparison expression equalExp, wherein parameters are p and c respectively, and the equality comparison is carried out on an input parameter and a reference v;
(5) creating a function expression func, wherein the parameter is equal exp, the input parameter is p, the return value is boolean, and the function expression func represents that the input parameter p is equally compared, namely the check whether p is equal to the current reference value object is completed;
(6) creating an 'inequality' comparison expression noEqualExp, wherein parameters are p and c respectively, and the inequality comparison is carried out on an input parameter and a reference v;
(7) creating a function expression func, wherein the parameter is noEqualExp, the input parameter is p, the return value is Boolean, and the function expression means that the input parameter p is not equal to the Boolean value, namely, the check whether p is not equal to the current reference value object is completed;
(8) creating a 'greater than' comparison expression greaterExp, wherein the parameters are p and c respectively, and the greater than comparison is carried out on the input parameter and the reference v;
(9) creating a function expression func, wherein the parameter is greaterExp, the input parameter is p, the return value is Boolean, and the function expression represents that the input parameter p is greater than or equal to the Boolean value, namely the check of whether p is greater than the reference value object is completed;
(10) creating a comparison expression of 'less', wherein parameters are p and c respectively, and the parameters represent that the input parameter and the reference v are subjected to comparison of less;
(11) creating a function expression func, wherein the parameter is lessExp, the input parameter is p, the return value is Boolean, and the function expression func represents that the input parameter p is smaller than the reference value, namely the check of whether p is smaller than the reference value object is completed;
(12) creating a comparison expression of 'more than or equal to' grease Exp, wherein the parameters are p and c respectively, and the comparison between the input parameter and the reference v is more than or equal to performed;
(13) creating a function expression func, wherein the parameter is greaterEqualExp, the input parameter is p, the return value is Boolean, and the function expression represents that the input parameter p is compared with the reference value or not, namely, the check on whether p is equal to or larger than the reference value object is completed;
(14) creating a comparison expression of less than or equal to, wherein parameters are p and c respectively, and represent that the input parameter and the reference v are compared less than or equal to;
(15) creating a function expression func, wherein the parameter is lessEqualExp, the input parameter is p, the return value is Boolean, and the function expression shows that the input parameter p is compared with the input parameter p which is less than or equal to the Boolean value, namely, the check of whether the p is less than or equal to the reference value object is completed;
(16) and returning to func, and judging that the construction of the expression tree of the method is finished.
Further, the fifth step further comprises:
5.0 creates an empty field judge expression object list, criterion List, for storing the created field judge expression object.
5.1 reading a routing rule GRR from the routing rule file;
5.2, dividing the GRR by using a blank space, and obtaining a grouping routing condition GRC by taking the first half part of the divided character string array;
5.3 dividing GRC by using semicolon (;) to form field judgment expression arrays FCEs;
5.4, aiming at the array FCEs, taking a first element to obtain a field judgment expression FCE;
5.5 obtaining a starting position P, a field Type and a judgment method S from FCE with the shape of P: Type: [ S ] BaseValue;
5.6 obtaining a reference value object corresponding to the current FCE from the reference value object list baseValueList created in the third step, and marking as opValue;
5.7 using parameters P, Type, S and opValue to call a construction function creation field to judge an expression object criterion;
5.8 according to P, Type, S and opValue, constructing a pass _ check method for judging the expression object, which comprises the following specific processes:
5.8.1 creating a parameter expression tree node packet representing the packet to be inspected;
5.8.2 creating a constant expression tree node position with a value p, which represents the position in the packet;
5.8.3 creating a constant expression tree node len whose value is the length taken by Type according to Table 1;
5.8.4, creating index data expression tree nodes sliceBytes, wherein parameters are packet, p and len, and indicate that bytes with length len are taken from the p position of the packet;
5.8.5 creating Type conversion expression tree node convertExp, converting the byte sequence sliceBytes obtained from 5.8.3 into a value with Type;
5.8.6, creating a judgment method expression tree node checkExp, and making the checkExp be equal to opvalue.checkexpression (S), namely, calling the function CheckExpression of opValue to generate a judgment expression tree;
5.8.7 creating a method call expression tree, ispassExp, wherein the called method is checkExp, the input parameter is convertExp, and the result of checking the convertExp by using the method checkExp is represented;
5.8.8, calling the compiling method of the expression tree, assigning the value to pass _ check after the ispassExp is compiled, and completing the construction of a pass _ check field, as follows:
pass_check=isPassExp.Compile();
5.9 IsPass (packet: byte [ ]) method for generating field judgment expression object, which indicates whether the packet of the input data packet satisfies the judgment criterion defined by the field judgment expression, and the specific method is as follows: call pass _ check with parameter packet as follows:
returnpass_check(packet);
5.10 field judges the expression object criterion to list criterion tail;
5.11 taking down one FCE from the FCEs array, and circularly executing 5.5 to 5.11 until all processing is finished;
and 5.12 reading a routing rule GRR from the routing rule file, and circularly executing 5.2 to 5.12 until the routing rule file is completely processed.
Further, the sixth step further comprises:
6.0 creates an empty routing rule object list ruleList for storing the routing rule object to be created.
6.1 reading a routing rule GRR from the routing rule file;
6.2 using blank space to divide GRR, getting the first half of the divided character string array to obtain the packet routing condition GRC, the routing destination IP and the Port;
6.3 extracting the sub-list Criteria of the field judgment expression object criterion corresponding to the GRC from the field judgment expression object list Criteria List created in the step four;
6.4 calling the constructor of Rule with criteria, IP and Port to create a routing Rule object (Rule);
6.5 generating an IsPass (packet) method of the route Rule object Rule, wherein the specific process is that all fields in Criteria are called circularly by using a parameter packet to judge an IsPass (packet) method of an expression object criterion, and the result is subjected to logic and combination and returned;
6.6 add the generated Rule to the tail of the routing Rule object list ruleList;
6.7 reading the next routing rule GRR from the routing rule file, and circularly executing 6.2 to 6.7 until the routing rule file is completely processed.
Further, the seventh step further comprises:
7.1 selecting a first routing Rule object Rule from a routing Rule object list ruleList;
7.2 using the IsPass method of Rule to check, if the check is passed, the data packet is shown to meet the current Rule, and the data is routed according to the IP address and the Port in the Rule; if not, executing 7.3;
7.3 checking if the ruleList has the next object, if yes, taking the next routing Rule object Rule, and executing 7.2; otherwise, the packet is not routed.
The invention has the advantages that: the method can effectively solve the problem that multi-source and multi-type measurement data in a complex network transmission environment are quickly grouped and routed in real time according to the requirements of processing equipment in an aerospace task; compared with other methods, the method has the advantages that the packet routing conditions defined by the user are compiled into a direct comparison method in advance by using an expression tree technology, branch judgment statements for performing comparison one by one according to judgment symbols are reduced, and as shown in figure 2, the packet routing speed is higher, and the method is more suitable for space launch which is a high-real-time task. In addition, the invention is also applicable to the scenes except the space mission which needs to carry out packet routing (forwarding) according to the value of the specific field of the data packet.
Drawings
FIG. 1 is a schematic diagram of a data frame format
FIG. 2 comparison of the other methods (left) with the method of the invention (right)
FIG. 3 reference value objects SingleValue and MultiValue
UML diagram of field judge expression object Criterion of FIG. 4
FIG. 5 packet routing rule object
FIG. 6 is a flow chart of a fast packet routing method based on a given field value
Detailed Description
The invention is described in further detail below with reference to figures 1 to 6.
In the aerospace test task, data obtained by a measuring device is firstly packaged into a standard data packet according to a specified format, and the data packet consists of a frame header and measurement data, as shown in fig. 1. At the frame header fixing position, a measuring device identifier, a task identifier, a data type identifier and the like are identified. By using the fixed field information, different devices and different kinds of data can be effectively distinguished.
The expression tree technology is a high-level technology introduced by the C # language, allows a user to convert text into executable code, allows a developer to dynamically generate required code during program execution, and can be compiled into executable functions as other codes.
The invention utilizes the advanced characteristic of C #, when the system is started, the code is dynamically generated according to the grouping routing rule written by the user, compared with the traditional method for carrying out character string comparison branch operation, a plurality of branch judgment statements are reduced, and the program running efficiency is greatly improved. Aiming at the characteristics of space mission data transmission frame format, transmission method and high real-time property, the invention provides a method, which allows a user to give the value or range of a specific position field in a data frame, converts the judgment rules into judgment functions by using an expression tree technology, and then performs fast packet routing (distribution) of data packets according to the judgment functions. Therefore, the flow pressure of the basic network and the working pressure of the data receiving module of the processing system are reduced, and the problems of packet loss, abnormal exit and the like caused by peak flow can be effectively avoided.
The main terms used in the present invention are described below:
expression tree: the code is represented in a tree structure, wherein each node is an expression, such as a method call, a binary operation of x < y, and the like. The code in the expression tree can be edited and operated, so that the executable code can be dynamically modified.
Packet routing: the packets are divided into groups according to certain rules and then routed to different destinations.
The following terms are defined in the present invention:
field judge Expression (FCE): refers to an expression used to determine whether a field in a packet satisfies a specified condition.
Packet Routing Condition (GRC): in this context, the term packet routing condition refers to a user-written representation of a string based on the size or range of one or more specified field values in a data frame, in a specific format as described in step one, for packet grouping and routing purposes.
Packet Routing Rule (GRR): a packet routing rule consists of a packet routing condition and a routing purpose to indicate to which address a packet satisfying which rule is routed.
Packet Routing Rule File (GRRF): user-written files composed of packet routing rules for routing different packets to different destinations.
Group Expression Tree (GET): when the expression tree converted by the packet routing rule (GRR) receives the data packet, the method expressed by the expression tree is directly executed, and the data packet can be quickly grouped.
Reference value target: the type object for representing the judgment reference value in the program has a structure as shown in fig. 3, and the core thereof is that an expression tree method for judgment (comparison) with the reference value is realized according to the judgment symbol.
Referring to fig. 6, the present invention provides a fast packet routing method based on a custom field value range, which includes the following steps:
the method comprises the following steps: the format of the packet routing condition (GRC) is defined.
The packet routing condition is composed of one or more field judgment expressions (FCE), wherein the field judgment expressions refer to one expression used for judging whether a certain field in the data packet meets the specified condition, and the field judgment expressions are connected by semicolons (;), and support the packet routing condition composed of any field judgment expressions.
The field judgment expression is composed of a field starting position, a field type, a judgment symbol and a judgment reference value. Wherein, the field starting position refers to the position of the field which the user wants to check in the data packet, and is marked as P; the value Type of the field is denoted as Type, and the Type represents the Type of the field in the data packet starting from P (the length can be deduced from the Type), and also indicates the Type of the given judgment reference value, as shown in table 1; the judgment reference value is denoted as BaseValue, which refers to a reference value used for comparing with the value of the check field, and according to the judgment method, the judgment reference value BaseValue can be composed of a single value a, two values a and b, or a plurality of values a, b, c and d, and the like, and the composition mode is shown in Table 2; the judgment symbol is a symbol indicating a judgment method, is denoted as S, and has comparison operations of equal to, unequal to, greater than, less than, greater than or equal to, less than or equal to, between the two, one of a plurality of values, and the like, and specific symbols are shown in table 2.
TABLE 1 Type and Length (in bytes)
TABLE 2 notation and description of the determination methods
From the above description, a field judgment expression (FCE) can be written as:
P:Type:[S]BaseValue
in the above formula, when S is "═ then S may be omitted from being unwritten; the BaseValue may be a single value a, two values a, b or multiple values a, b, c, d, ….
The packet routing condition (GRC) is composed of one or more field judgment expressions partitioned with semicolons (;), such as:
FCE1;FCE2;…
step two: a packet routing rule (GRR) and a packet routing rule file are defined based on the packet routing condition (GRC).
Defining a packet routing rule (GRR) according to the following formula according to the format of the packet routing condition (GRC) defined in step one:
GRC IP:Port
wherein, the IP: Port represents the route destination, is composed of the IP address of the destination host and the destination Port, and is divided by a semicolon (: to).
The packet routing rule file is formed by a plurality of lines of GRRs and is used for realizing packet routing of different data packets according to rules.
Step three: a packet routing rule file is written.
And (2) writing a packet routing rule file by the user according to the defined packet routing rule file format in the step two, wherein the specific method comprises the following steps:
3.1 determining the position P and the data Type of each field used for grouping in the data packet;
3.2 determining a reference value BaseValue and a judgment method S for the grouping according to the grouping requirement for each field for grouping;
3.3 writing a field judgment expression FCE for each key field according to the field judgment expression format P defined in the first step, wherein the Type is S base value;
3.4 according to the packet routing condition format defined in the step one, combining the field judgment expressions FCE to form a packet routing condition (GRC);
3.5 determining the routing destination IP address and Port, forming the packet routing rule GRR:
GRCIP:Port
3.6 for each data packet to be grouped and routed, executing the steps 3.1 to 3.5, and adding the routing rule to the file line by line to form a final grouping and routing rule file.
Step four: and establishing a reference value object list according to the packet routing rule file.
The reference value object refers to a type of object representing a judgment reference value in a program, which is composed of numerical values representing the judgment reference and an expression tree how to compare with the numerical values according to a specified judgment method, as shown in fig. 3, and in the program, the reference value object is uniformly represented by IOpValue, because we only need to know how to compare with input data without paying attention to specific implementation details, specifically, an object representing a single reference value, SingleValue, and an object representing multiple reference values are implemented. The IOpValue defines an interface
Expression<Func<T1,bool>>CheckExpression<T1>(string op)
The interface defines a method of generating an expression tree according to an input decision method (op), the generated expression tree representing a function with an input parameter type of T1 and an output of boolean value. The main function of the SingleValue and the MultiValue is to generate the method according to the reference value BaseValue and the judgment method S, and generate an expression tree for judgment.
The specific steps for establishing the reference value object list are as follows:
4.0 creates an empty reference value object list baseValueList for storing the created IOpValue object.
4.1 reading a routing rule (GRR) from the packet routing rule file;
4.2 using space to divide GRR, getting the first half of character string array after division to get the Grouping Route Condition (GRC);
4.3 dividing GRC by using semicolon (;) to form field judgment expression arrays FCEs;
4.4, aiming at the array FCEs, taking a first element to obtain a field judgment expression FCE;
4.5 obtaining Type from FCE of Type [ S ] BaseValue;
4.6 get the [ S ] BaseValue part from FCE;
4.8 judging whether S is one of-, "-" or "" or not, if so, executing 4.9, otherwise, executing 4.10;
4.9 creating a reference value object MultiValue representing a plurality of numerical values according to S, Type and BaseValue, the structure of which is shown in fig. 3, and the specific method for constructing the MultiValue is as follows:
4.9.1 partitioning BaseValue with comma (,) and converting the resulting string to a numerical value, resulting in a numerical value V1,V2,…,Vn;
4.9.2 at S, Type and V1,V2,…,VnFor the parameter, calling a constructor to create a MultiValue object;
4.9.3, constructing a judgment method expression tree of MultiValue:
Expression<Func<T1,bool>>CheckExpression<T1>(string op)
in the formula, the form parameter op represents a judgment method, and the value range is shown in table 2. In the MultiValue object, the value can only be one of "-", "-" or "," between the two or one of a plurality of data.
The specific steps for constructing the judgment method expression tree are as follows:
(1) if the value of op is determined to be "" or "-", the steps (2) to (9) are executed, and if the value is ",", the steps (10) to (14) are executed.
(2) Creating an expression tree node v representing input parameters, wherein v represents data to be compared and has the type of T1;
(3) a smaller one of V1, V2, creates a constant expression min;
(4) creating a constant expression max from the larger one of V1, V2;
(5) creating a comparison expression greatExp which is more than or equal to v and min respectively, and comparing whether the input parameter v is more than or equal to a reference value min or not;
(6) creating a less than comparison expression lessExp with parameters of v and max respectively, and comparing whether the input parameter v is less than a reference value max;
(7) creating a logic And (And) expression betweenex to connect the greatExp And the lessExp, wherein the logic And (And) expression betweenex represents that the input v simultaneously satisfies a reference value min which is greater than or equal to the reference value And is less than the reference value max;
(8) creating a function expression func, wherein the parameter is beta-enExp, the input parameter is v, the return value is Boolean, and the function expression func represents that whether the input parameter v is larger than or equal to or smaller than the check is completed, namely whether v is between the two checks is completed;
(9) returning to func, and judging that the construction of the method expression tree is finished;
(10) creating zero-time variable expressions p and v, wherein v represents a parameter to be input later, and p is a zero-time variable;
(11) creating an equality comparison expression equalExp with parameters p and v, respectively, for checking whether p is equal to v;
(12) creating a method call expression Exists, calling a method 'Exists' of an array, wherein the parameter is equalExp, and the method equalExp is used for checking whether data equal to p exist in the array or not;
(13) creating a function expression func, wherein the parameter is exists, the return value is Boolean, the input parameter is v, and the method for executing the exists expression on the input parameter v is represented, namely, the judgment equal to one of a plurality of data is realized;
(14) and returning to func, and judging that the construction of the expression tree of the method is finished.
4.10 creating a reference value object SingleValue representing a single numerical value composition according to S, Type and BaseValue, the structure of which is shown in fig. 3, and the specific method for constructing SingleValue is as follows:
4.10.1, carrying out numerical value conversion on the BaseValue character string to obtain a numerical value V of a judgment standard;
4.10.2 calling a constructor to create a SingleValue object by taking S, Type and V as parameters;
4.10.3, constructing a judgment method expression tree of SingleValue:
Expression<Func<T1,bool>>CheckExpression<T1>(string op)
the shape parameter op in the formula represents a judgment method, and the value range is shown in table 2. In the SingleValue object, the value is "═ and"! The term "a", ">", "<" ═ and "< ═" are used.
The specific steps for constructing the judgment method expression tree are as follows:
(1) creating an expression p representing an input parameter, wherein the type of the expression p is T1;
(2) creating a constant expression c, and taking the value as a value V represented by the current reference value object;
(3) judging the value of the op, and if the value of the op is equal to the value, executing the steps (4) and (5); if the value of op is "! "executing the steps (6) and (7); if the value of the op is' >, executing the steps (8) and (9); if the value of op is "<", executing the (10) th and (11) th steps; if the value of op is ">, the (12) th and (13) th steps are executed; if the value of op is "< ═ then steps (14) and (15) are performed and finally step (16) is performed in unison to obtain the final result.
(4) Creating an 'equality' comparison expression equalExp, wherein parameters are p and c respectively, and the equality comparison is carried out on an input parameter and a reference v;
(5) creating a function expression func, wherein the parameter is equal exp, the input parameter is p, the return value is boolean, and the function expression func represents that the input parameter p is equally compared, namely the check whether p is equal to the current reference value object is completed;
(6) creating an 'inequality' comparison expression noEqualExp, wherein parameters are p and c respectively, and the inequality comparison is carried out on an input parameter and a reference v;
(7) creating a function expression func, wherein the parameter is noEqualExp, the input parameter is p, the return value is Boolean, and the function expression means that the input parameter p is not equal to the Boolean value, namely, the check whether p is not equal to the current reference value object is completed;
(8) creating a 'greater than' comparison expression greaterExp, wherein the parameters are p and c respectively, and the greater than comparison is carried out on the input parameter and the reference v;
(9) creating a function expression func, wherein the parameter is greaterExp, the input parameter is p, the return value is Boolean, and the function expression represents that the input parameter p is greater than or equal to the Boolean value, namely the check of whether p is greater than the reference value object is completed;
(10) creating a comparison expression of 'less', wherein parameters are p and c respectively, and the parameters represent that the input parameter and the reference v are subjected to comparison of less;
(11) creating a function expression func, wherein the parameter is lessExp, the input parameter is p, the return value is Boolean, and the function expression func represents that the input parameter p is smaller than the reference value, namely the check of whether p is smaller than the reference value object is completed;
(12) creating a comparison expression of 'more than or equal to' grease Exp, wherein the parameters are p and c respectively, and the comparison between the input parameter and the reference v is more than or equal to performed;
(13) creating a function expression func, wherein the parameter is greaterEqualExp, the input parameter is p, the return value is Boolean, and the function expression represents that the input parameter p is compared with the reference value or not, namely, the check on whether p is equal to or larger than the reference value object is completed;
(14) creating a comparison expression of less than or equal to, wherein parameters are p and c respectively, and represent that the input parameter and the reference v are compared less than or equal to;
(15) creating a function expression func, wherein the parameter is lessEqualExp, the input parameter is p, the return value is Boolean, and the function expression shows that the input parameter p is compared with the input parameter p which is less than or equal to the Boolean value, namely, the check of whether the p is less than or equal to the reference value object is completed;
(16) and returning to func, and judging that the construction of the expression tree of the method is finished.
4.11 add the created benchmark object MultiValue or SingleValue object to the end of the baseValueList.
4.12 taking down an element from the array FCEs to obtain a new field judgment expression FCE;
4.13 loop through steps 4.5 to 4.12 until the current packet routing condition GRC is processed.
4.14 reading the next routing rule GRR from the packet routing rule file, and circularly executing 4.2 to 4.13 until the file is completely processed.
Step five: and generating a field judgment expression object list according to the packet routing rule file and the reference value object list.
The field judgment expression object (Criterion) is a type object used for representing a field judgment expression in a program, and has a structure as shown in fig. 4, and main members of the field judgment expression object include an interface opValue representing a reference value object, a method pass _ check representing some check on input data, and a method IsPass for checking an input data packet. pass check represents a method that can be called, the input parameter is the data packet to be checked, and the output value indicates whether the check is passed; IsPass is a function that performs a check on a received packet, which calls internally for pass check to perform the check.
The specific steps of constructing the field to judge the object criterion of the expression are as follows:
5.0 creates an empty field judge expression object list, criterion List, for storing the created field judge expression object.
5.1 reading a routing rule (GRR) from the routing rule file;
5.2 using space to divide GRR, getting the first half of character string array after division to get the Grouping Route Condition (GRC);
5.3 dividing GRC by using semicolon (;) to form field judgment expression arrays FCEs;
5.4, aiming at the array FCEs, taking a first element to obtain a field judgment expression FCE;
5.5 obtaining a starting position P, a field Type and a judgment method S from FCE with the shape of P: Type: [ S ] BaseValue;
5.6 obtaining a reference value object corresponding to the current FCE from the reference value object list baseValueList created in the third step, and marking as opValue;
5.7 using parameters P, Type, S and opValue to call a construction function creation field to judge an expression object criterion;
5.8 according to P, Type, S and opValue, constructing a pass _ check method for judging the expression object, which comprises the following specific processes:
5.8.1 creating a parameter expression tree node packet representing the packet to be inspected;
5.8.2 creating a constant expression tree node position with a value p, which represents the position in the packet;
5.8.3 creating a constant expression tree node len whose value is the length taken by Type according to Table 1;
5.8.4, creating index data expression tree nodes sliceBytes, wherein parameters are packet, p and len, and indicate that bytes with length len are taken from the p position of the packet;
5.8.5 creating Type conversion expression tree node convertExp, converting the byte sequence sliceBytes obtained from 5.8.3 into a value with Type;
5.8.6, creating a judgment method expression tree node checkExp, and making the checkExp be equal to opvalue.checkexpression (S), namely, calling the function CheckExpression of opValue to generate a judgment expression tree;
5.8.7 creating a method call expression tree, ispassExp, wherein the called method is checkExp, the input parameter is convertExp, and the result of checking the convertExp by using the method checkExp is represented;
5.8.8, calling the compiling method of the expression tree, assigning the value to pass _ check after the ispassExp is compiled, and completing the construction of a pass _ check field, as follows:
pass_check=isPassExp.Compile();
5.9 IsPass (packet: byte [ ]) method for generating field judgment expression object, which indicates whether the packet of the input data packet satisfies the judgment criterion defined by the field judgment expression, and the specific method is as follows: call pass _ check with parameter packet as follows:
returnpass_check(packet);
5.10 field judges the expression object criterion to list criterion tail;
5.11 taking down one FCE from the FCEs array, and circularly executing 5.5 to 5.11 until all processing is finished;
and 5.12 reading a routing rule GRR from the routing rule file, and circularly executing 5.2 to 5.12 until the routing rule file is completely processed.
Step six, generating a grouping routing rule object list;
the packet routing Rule object (Rule) refers to a type object used in a program for representing a packet routing Rule, and has a structure as shown in fig. 5, and mainly consists of packet routing condition (i.e., a list consisting of one or more field expression objects) criterion, routing destination address destIP, destination port destPort, and a judgment method ispass (pckey).
The specific steps for generating the routing Rule object (Rule) list are as follows:
6.0 creates an empty routing rule object list ruleList for storing the routing rule object to be created.
6.1 reading a routing rule (GRR) from the routing rule file;
6.2 using blank space to divide GRR, getting the first half of the divided character string array to get the Grouping Route Condition (GRC), the route destination IP and the Port;
6.3 extracting the sub-list Criteria of the field judgment expression object criterion corresponding to the GRC from the field judgment expression object list Criteria List created in the step four;
6.4 calling the constructor of Rule with criteria, IP and Port to create a routing Rule object (Rule);
6.5 generating an IsPass (packet) method of the route Rule object Rule, wherein the specific process is that all fields in Criteria are called circularly by using a parameter packet to judge an IsPass (packet) method of an expression object criterion, and the result is subjected to logic and combination and returned;
6.6 add the generated Rule to the tail of the routing Rule object list ruleList;
6.7 reading the next routing rule (GRR) from the routing rule file, and circularly executing 6.2 to 6.7 until the routing rule file is completely processed.
And step seven, grouping the routing data by using the grouping routing rule object list.
The specific method for grouping and routing data by using the grouping and routing rule object list for the received data packet is as follows:
7.1 selecting a first routing Rule object Rule from a routing Rule object list ruleList;
7.2 using the IsPass method of Rule to check, if the check is passed, the data packet is shown to meet the current Rule, and the data is routed according to the IP address and the Port in the Rule; if not, executing 7.3;
7.3 checking if the ruleList has the next object, if yes, taking the next routing Rule object Rule, and executing 7.2; otherwise, the packet is not routed.
The first three steps, mainly defining packet routing condition and rule format and writing method of packet routing rule file; step four to step six, the processes of constructing a grouping routing rule object according to a user-defined grouping routing rule file, generating a needed judgment expression tree and compiling the expression tree into a code which can be directly executed are completed; and step seven, the process of calling the packet routing rule object to perform packet routing on the received data packet is mainly completed.
Claims (10)
1. A fast packet routing method for performing a decision according to a given field value, the method comprising the steps of:
the method comprises the following steps: defining the format of a packet routing condition GRC;
step two: defining a packet routing rule GRR and a packet routing rule file based on the packet routing condition GRC;
step three: compiling a packet routing rule file;
step four: establishing a reference value object list according to the packet routing rule file;
step five: and generating a field judgment expression object list according to the packet routing rule file and the reference value object list.
Step six, generating a grouping routing rule object list;
and step seven, grouping the routing data by using the grouping routing rule object list.
2. The fast packet routing method according to a given field value, as claimed in claim 1, wherein said step one further comprises:
the packet routing condition GRC is composed of one or more field judgment expressions, which are divided by semicolons (;), such as:
FCE1;FCE2;…
the field judgment expression comprises a field starting position, a type, a judgment symbol and a judgment reference value, wherein the field starting position refers to the position of a field which a user wants to check in a data packet and is marked as P; the numerical Type of the field is recorded as Type, and the Type represents the Type of the field starting from P in the data packet; the judgment reference value is BaseValue, which refers to a reference value used for comparing with the value of the check field, and may be a single value a, two values a, b, or a plurality of values a, b, c, d, … according to the judgment method; the judgment symbol is a symbol representing a judgment method, is marked as S, and has comparison operations of equal to, unequal to, greater than, less than, greater than or equal to, less than or equal to, between the two, one of a plurality of values and the like;
a field judgment expression FCE is expressed as follows:
P:Type:[S]BaseValue
in the above formula, when S is "═ then S may be omitted from being unwritten.
3. The fast packet routing method according to a given field value, as claimed in claim 2, wherein said step two further comprises:
defining a packet routing rule GRR according to the following formula according to the format of the packet routing condition GRC defined in the step one:
GRC IP:Port
wherein, the Port represents the route destination, which is composed of the IP address of the destination host and the Port of the destination Port and is divided by a semicolon (:);
the packet routing rule file is formed by a plurality of lines of GRRs and is used for realizing packet routing of different data packets according to rules.
4. The fast packet routing method judged according to a given field value as claimed in claim 3, wherein said step three further comprises:
3.1 determining the position P and the data Type of each field used for grouping in the data packet;
3.2 determining a reference value BaseValue and a judgment method S for the grouping according to the grouping requirement for each field for grouping;
3.3 writing a field judgment expression FCE for each key field according to the field judgment expression format P defined in the first step, wherein the Type is S base value;
3.4 combining the field judgment expressions FCE to form a packet routing condition GRC according to the packet routing condition format defined in the first step;
3.5 determining the routing destination IP address and Port, forming the packet routing rule GRR:
GRCIP:Port
3.6 for each data packet to be grouped and routed, executing the steps 3.1 to 3.5, and adding the routing rule to the file line by line to form a final grouping and routing rule file.
5. The fast packet routing method decided according to a given field value as claimed in claim 4, wherein said step four further comprises:
4.0 creates an empty reference value object list baseValueList for storing the created IOpValue object.
4.1 reading a routing rule GRR from the packet routing rule file;
4.2, dividing GRR by using a blank space, and obtaining a grouping routing condition GRC by taking the first half part of the divided character string array;
4.3 dividing GRC by using semicolon (;) to form field judgment expression arrays FCEs;
4.4, aiming at the array FCEs, taking a first element to obtain a field judgment expression FCE;
4.5 obtaining Type from FCE of Type [ S ] BaseValue;
4.6 get the [ S ] BaseValue part from FCE;
4.8 judging whether S is one of-, "-" or "" or not, if so, executing 4.9, otherwise, executing 4.10;
4.9 creating a benchmark object MultiValue representing a plurality of numerical value compositions from S, Type and BaseValue;
4.9.1 partitioning BaseValue with comma (,) and converting the resulting string to a numerical value, resulting in a numerical value V1,V2,…,Vn;
4.9.2 at S, Type and V1,V2,…,VnFor the parameter, calling a constructor to create a MultiValue object;
4.9.3, constructing a judgment method expression tree of MultiValue:
Expression<Func<T1,bool>>CheckExpression<T1>(string op)
in the formula, the form parameter op represents a judgment method, and the value range is shown in table 2. In the MultiValue object, the value can only be one of "-", "-" or "," between the two or one of a plurality of data.
4.10 creating a reference value object SingleValue representing the composition of the individual values from S, Type and BaseValue;
4.10.1, carrying out numerical value conversion on the BaseValue character string to obtain a numerical value V of a judgment standard;
4.10.2 calling a constructor to create a SingleValue object by taking S, Type and V as parameters;
4.10.3, constructing a judgment method expression tree of SingleValue:
Expression<Func<T1,bool>>CheckExpression<T1>(string op)
the shape parameter op in the formula represents a judgment method; in the SingleValue object, the value is "═ and"! One of "", ">", "<" > ", and" < ">";
4.11 add the created benchmark object MultiValue or SingleValue object to the end of the baseValueList.
4.12 taking down an element from the array FCEs to obtain a new field judgment expression FCE;
4.13 circularly executing the steps 4.5 to 4.12 until the processing of the current packet routing condition GRC is finished;
4.14 reading the next routing rule GRR from the packet routing rule file, and circularly executing 4.2 to 4.13 until the file is completely processed.
6. The fast packet routing method with decision according to a given field value as claimed in claim 5, wherein the specific steps of constructing the decision method expression tree are as follows:
(1) if the value of op is determined to be "" or "-", the steps (2) to (9) are executed, and if the value is ",", the steps (10) to (14) are executed.
(2) Creating an expression tree node v representing input parameters, wherein v represents data to be compared and has the type of T1;
(3) a smaller one of V1, V2, creates a constant expression min;
(4) creating a constant expression max from the larger one of V1, V2;
(5) creating a comparison expression greatExp which is more than or equal to v and min respectively, and comparing whether the input parameter v is more than or equal to a reference value min or not;
(6) creating a less than comparison expression lessExp with parameters of v and max respectively, and comparing whether the input parameter v is less than a reference value max;
(7) creating logic And connecting the greatExp And the lessExp with an And expression betweenExp, wherein the logic And the Ant expression betweenExp represent that the input v simultaneously meets the conditions that the input v is more than or equal to a reference value min And less than a reference value max;
(8) creating a function expression func, wherein the parameter is beta-enExp, the input parameter is v, the return value is Boolean, and the function expression func represents that whether the input parameter v is larger than or equal to or smaller than the check is completed, namely whether v is between the two checks is completed;
(9) returning to func, and judging that the construction of the method expression tree is finished;
(10) creating zero-time variable expressions p and v, wherein v represents a parameter to be input later, and p is a zero-time variable;
(11) creating an equality comparison expression equalExp with parameters p and v, respectively, for checking whether p is equal to v;
(12) creating a method call expression Exists, calling a method 'Exists' of an array, wherein the parameter is equalExp, and the method equalExp is used for checking whether data equal to p exist in the array or not;
(13) creating a function expression func, wherein the parameter is exists, the return value is Boolean, the input parameter is v, and the method for executing the exists expression on the input parameter v is represented, namely, the judgment equal to one of a plurality of data is realized;
(14) and returning to func, and judging that the construction of the expression tree of the method is finished.
7. The fast packet routing method with decision made according to a given field value as claimed in claim 5, wherein the specific steps of constructing the tree of the expression of the decision method of SingleValue are as follows:
(1) creating an expression p representing an input parameter, wherein the type of the expression p is T1;
(2) creating a constant expression c, and taking the value as a value V represented by the current reference value object;
(3) judging the value of the op, and if the value of the op is equal to the value, executing the steps (4) and (5); if the value of op is "! "executing the steps (6) and (7); if the value of the op is' >, executing the steps (8) and (9); if the value of op is "<", executing the (10) th and (11) th steps; if the value of op is ">, the (12) th and (13) th steps are executed; if the value of the op is < ═ then steps (14) and (15) are executed, and finally step (16) is executed uniformly to obtain the final result;
(4) creating an 'equality' comparison expression equalExp, wherein parameters are p and c respectively, and the equality comparison is carried out on an input parameter and a reference v;
(5) creating a function expression func, wherein the parameter is equal exp, the input parameter is p, the return value is boolean, and the function expression func represents that the input parameter p is equally compared, namely the check whether p is equal to the current reference value object is completed;
(6) creating an 'inequality' comparison expression noEqualExp, wherein parameters are p and c respectively, and the inequality comparison is carried out on an input parameter and a reference v;
(7) creating a function expression func, wherein the parameter is noEqualExp, the input parameter is p, the return value is Boolean, and the function expression means that the input parameter p is not equal to the Boolean value, namely, the check whether p is not equal to the current reference value object is completed;
(8) creating a 'greater than' comparison expression greaterExp, wherein the parameters are p and c respectively, and the greater than comparison is carried out on the input parameter and the reference v;
(9) creating a function expression func, wherein the parameter is greaterExp, the input parameter is p, the return value is Boolean, and the function expression represents that the input parameter p is greater than or equal to the Boolean value, namely the check of whether p is greater than the reference value object is completed;
(10) creating a comparison expression of 'less', wherein parameters are p and c respectively, and the parameters represent that the input parameter and the reference v are subjected to comparison of less;
(11) creating a function expression func, wherein the parameter is lessExp, the input parameter is p, the return value is Boolean, and the function expression func represents that the input parameter p is smaller than the reference value, namely the check of whether p is smaller than the reference value object is completed;
(12) creating a comparison expression of 'more than or equal to' grease Exp, wherein the parameters are p and c respectively, and the comparison between the input parameter and the reference v is more than or equal to performed;
(13) creating a function expression func, wherein the parameter is greaterEqualExp, the input parameter is p, the return value is Boolean, and the function expression represents that the input parameter p is compared with the reference value or not, namely, the check on whether p is equal to or larger than the reference value object is completed;
(14) creating a comparison expression of less than or equal to, wherein parameters are p and c respectively, and represent that the input parameter and the reference v are compared less than or equal to;
(15) creating a function expression func, wherein the parameter is lessEqualExp, the input parameter is p, the return value is Boolean, and the function expression shows that the input parameter p is compared with the input parameter p which is less than or equal to the Boolean value, namely, the check of whether the p is less than or equal to the reference value object is completed;
(16) and returning to func, and judging that the construction of the expression tree of the method is finished.
8. The fast packet routing method judged according to a given field value as claimed in claim 5, wherein said step five further comprises:
5.0 creates an empty field judge expression object list, criterion List, for storing the created field judge expression object.
5.1 reading a routing rule GRR from the routing rule file;
5.2, dividing the GRR by using a blank space, and obtaining a grouping routing condition GRC by taking the first half part of the divided character string array;
5.3 dividing GRC by using semicolon (;) to form field judgment expression arrays FCEs;
5.4, aiming at the array FCEs, taking a first element to obtain a field judgment expression FCE;
5.5 obtaining a starting position P, a field Type and a judgment method S from FCE with the shape of P: Type: [ S ] BaseValue;
5.6 obtaining a reference value object corresponding to the current FCE from the reference value object list baseValueList created in the third step, and marking as opValue;
5.7 using parameters P, Type, S and opValue to call a construction function creation field to judge an expression object criterion;
5.8 according to P, Type, S and opValue, constructing a pass _ check method for judging the expression object, which comprises the following specific processes:
5.8.1 creating a parameter expression tree node packet representing the packet to be inspected;
5.8.2 creating a constant expression tree node position with a value p, which represents the position in the packet;
5.8.3 creating a constant expression tree node len whose value is the length taken by Type according to Table 1;
5.8.4, creating index data expression tree nodes sliceBytes, wherein parameters are packet, p and len, and indicate that bytes with length len are taken from the p position of the packet;
5.8.5 creating Type conversion expression tree node convertExp, converting the byte sequence sliceBytes obtained from 5.8.3 into a value with Type;
5.8.6, creating a judgment method expression tree node checkExp, and making the checkExp be equal to opvalue.checkexpression (S), namely, calling the function CheckExpression of opValue to generate a judgment expression tree;
5.8.7 creating a method call expression tree, ispassExp, wherein the called method is checkExp, the input parameter is convertExp, and the result of checking the convertExp by using the method checkExp is represented;
5.8.8, calling the compiling method of the expression tree, assigning the value to pass _ check after the ispassExp is compiled, and completing the construction of a pass _ check field, as follows:
pass_check=isPassExp.Compile();
5.9 IsPass (packet: byte [ ]) method for generating field judgment expression object, which indicates whether the packet of the input data packet satisfies the judgment criterion defined by the field judgment expression, and the specific method is as follows: call pass _ check with parameter packet as follows:
returnpass_check(packet);
5.10 field judges the expression object criterion to list criterion tail;
5.11 taking down one FCE from the FCEs array, and circularly executing 5.5 to 5.11 until all processing is finished;
and 5.12 reading a routing rule GRR from the routing rule file, and circularly executing 5.2 to 5.12 until the routing rule file is completely processed.
9. The fast packet routing method decided according to a given field value as claimed in claim 8, wherein the sixth step further comprises:
6.0 creates an empty routing rule object list ruleList for storing the routing rule object to be created.
6.1 reading a routing rule GRR from the routing rule file;
6.2 using blank space to divide GRR, getting the first half of the divided character string array to obtain the packet routing condition GRC, the routing destination IP and the Port;
6.3 extracting the sub-list Criteria of the field judgment expression object criterion corresponding to the GRC from the field judgment expression object list Criteria List created in the step four;
6.4 calling the constructor of Rule with criteria, IP and Port to create a routing Rule object (Rule);
6.5 generating an IsPass (packet) method of the route Rule object Rule, wherein the specific process is that all fields in Criteria are called circularly by using a parameter packet to judge an IsPass (packet) method of an expression object criterion, and the result is subjected to logic and combination and returned;
6.6 add the generated Rule to the tail of the routing Rule object list ruleList;
6.7 reading the next routing rule GRR from the routing rule file, and circularly executing 6.2 to 6.7 until the routing rule file is completely processed.
10. The fast packet routing method decided according to a given field value as claimed in claim 9, wherein said seventh step further comprises:
7.1 selecting a first routing Rule object Rule from a routing Rule object list ruleList;
7.2 using the IsPass method of Rule to check, if the check is passed, the data packet is shown to meet the current Rule, and the data is routed according to the IP address and the Port in the Rule; if not, executing 7.3;
7.3 checking if the ruleList has the next object, if yes, taking the next routing Rule object Rule, and executing 7.2; otherwise, the packet is not routed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111115900.7A CN113835712B (en) | 2021-09-23 | 2021-09-23 | Fast data packet routing method for judging according to given field value |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111115900.7A CN113835712B (en) | 2021-09-23 | 2021-09-23 | Fast data packet routing method for judging according to given field value |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113835712A true CN113835712A (en) | 2021-12-24 |
CN113835712B CN113835712B (en) | 2023-09-26 |
Family
ID=78969429
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111115900.7A Active CN113835712B (en) | 2021-09-23 | 2021-09-23 | Fast data packet routing method for judging according to given field value |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113835712B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115348169A (en) * | 2022-08-24 | 2022-11-15 | 大陆汽车研发(重庆)有限公司 | Route configuration method, device, equipment and storage medium for vehicle-mounted gateway |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100088350A1 (en) * | 2008-10-03 | 2010-04-08 | Microsoft Corporation | Packaging system to facilitate declarative model-driven development |
TW201210261A (en) * | 2010-08-24 | 2012-03-01 | Gemtek Technolog Co Ltd | Routing apparatus and method for processing network packet thereof |
CN102427428A (en) * | 2011-12-07 | 2012-04-25 | 西安电子科技大学 | Stream identifying method and device based on multi-domain longest match |
CN104683231A (en) * | 2013-11-29 | 2015-06-03 | 英业达科技有限公司 | Rout control method and route control device |
-
2021
- 2021-09-23 CN CN202111115900.7A patent/CN113835712B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100088350A1 (en) * | 2008-10-03 | 2010-04-08 | Microsoft Corporation | Packaging system to facilitate declarative model-driven development |
TW201210261A (en) * | 2010-08-24 | 2012-03-01 | Gemtek Technolog Co Ltd | Routing apparatus and method for processing network packet thereof |
CN102427428A (en) * | 2011-12-07 | 2012-04-25 | 西安电子科技大学 | Stream identifying method and device based on multi-domain longest match |
CN104683231A (en) * | 2013-11-29 | 2015-06-03 | 英业达科技有限公司 | Rout control method and route control device |
Non-Patent Citations (1)
Title |
---|
封侣;: "基于JSON格式的自定义组合条件查询设计与实现", 电子世界, no. 12 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115348169A (en) * | 2022-08-24 | 2022-11-15 | 大陆汽车研发(重庆)有限公司 | Route configuration method, device, equipment and storage medium for vehicle-mounted gateway |
CN115348169B (en) * | 2022-08-24 | 2023-09-22 | 大陆汽车研发(重庆)有限公司 | Route configuration method, device, equipment and storage medium for vehicle-mounted gateway |
Also Published As
Publication number | Publication date |
---|---|
CN113835712B (en) | 2023-09-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9864582B2 (en) | Code processor to build orthogonal execution blocks for programmable network devices | |
US6314093B1 (en) | Traffic route finder in communications network | |
CN103080900B (en) | The method of parallelization automatic control program and compiler | |
CN103020024B (en) | A kind of file layout change-over method | |
CN111131159A (en) | Message parser and design method thereof | |
CN104020756B (en) | Logic network topology sorting and storing method for fault diagnosing system | |
WO2021159929A1 (en) | Topology diagram conversion system and method | |
CN113835712A (en) | Fast data packet routing method for judging according to given field value | |
CN101986282B (en) | Topology adaptation method and device | |
CN115794106A (en) | Method and system for analyzing configuration of binary protocol data of rail transit | |
CN108629124B (en) | Method for automatically generating simulation parameter data based on active graph path | |
US20040148320A1 (en) | Minimum processor instruction for implementing weighted fair queuing and other priority queuing | |
JPWO2009063550A1 (en) | Data relay device and route selection method | |
CN109446146B (en) | State transition sequence generation method of application layer communication protocol | |
Balbo et al. | First passage time computation in tagged GSPNs with queue places | |
CN115250251B (en) | Transmission path planning method and device in network-on-chip simulation, electronic equipment and computer readable storage medium | |
US7839849B1 (en) | Formatting fields of communication packets | |
CN103999435B (en) | For the apparatus and method of efficient network address translation and ALG process | |
CN116523045A (en) | Deep learning reasoning simulator oriented to multi-core chip | |
CN113568598B (en) | Yosys-based FPGA logic synthesis method and device for realizing summation operation | |
CN116248615A (en) | Programmable message editing acceleration engine, message editing method and system | |
CN1156112C (en) | Method for simulating WDM optical network | |
CN112311679B (en) | State detection method, state detection device, electronic equipment and readable storage medium | |
EP3113038B1 (en) | A data handling method | |
CN108599834B (en) | Method and system for analyzing utilization rate of satellite communication network link |
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 |