Multi-modal network compiling method and system, and storage medium
Through a multimodal network compilation method, the problem of difficult deployment of multimodal networks in programmable network element devices is solved. By converting the source program code of the multimodal network into a programming instruction sequence of the target network element device, flexible processing and deployment of custom protocol data packets are realized.
Patent Information
- Application Number
- PCT/CN2023/123675
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-25
- Filing Date
- 2023-10-10
- Publication Date
- 2025-04-03
AI Technical Summary
It is difficult to deploy multimodal networks in programmable network element devices, mainly because traditional network switches use ASIC chips and ASIC chips identify packet logic fixed, making it difficult to support unknown protocol message processing. Moreover, the supporting compiler for commercial chips developed by programmable ASIC is not open source and has a confidentiality protocol, which limits the deployment of multimodal networks.
A multimodal network compilation method is provided. By obtaining the intermediate representation of the source program code of the multimodal network, traversing the intermediate representation, extracting node attributes according to the node type, and converting node attributes into a programming instruction sequence of the target network element device according to the user-defined fields. The method includes building an abstract visitor, instantiating the visitor, traversing the intermediate representation, extracting node attributes, and converting the attributes into a sequence of programming instructions, and finally converting the program instruction sequence and preset flow table files into microcode instructions and sending them to the target network element device.
This method can block the underlying heterogeneous hardware resources of the network switch, map multimodal network programs to programmable network element devices, reduce the difficulty of development and deployment of multimodal networks, and realize the flexible processing of custom protocol packets.
Smart Images

Figure CN2023123675_03042025_PF_FP_ABST
Abstract
Description
Multimodal network compilation method, system and storage medium
[0001] Related applications
[0002] This application claims priority to Chinese patent application number 202311235737.7, filed on September 25, 2023, entitled “Multimodal network compilation method, system and storage medium,” the entire text of which is hereby incorporated by reference. Technical Field
[0003] The present application relates to the field of network communications, and in particular to a multimodal network compilation method, system, and storage medium. Background Art
[0004] Multimodal networking is a technology that supports diverse addressing and routing. By deconstructing and analyzing the addressing mechanisms, routing processes, data packet structures, network element data exchange processes, and application support methods of various identity networks, it establishes a multimodal, heterogeneous identity space addressing and routing model based on the operating logic and respective advantages of any identity space. In multimodal network scenarios, programmable network elements are required to support the processing of unknown protocol messages during network element design.
[0005] Traditional network switches use ASIC chips for data exchange, which forward incoming traffic through the ASIC at a limited rate. The ASIC's message recognition logic is fixed and supports only native protocols. Once developed, it's difficult to expand into other applications, and adding new features requires chip development companies to spend a long development cycle. Because the compilers for commercial chips developed with programmable ASICs are not open source and are subject to various confidentiality agreements, multimodal networks are difficult to deploy on programmable network elements.
[0006] Currently, no effective solution has been proposed to the problem that multimodal networks are difficult to deploy in programmable network element devices in related technologies.
[0007] Summary of the Invention
[0008] According to various embodiments of the present application, a multimodal network compilation method, system, and storage medium are provided.
[0009] In a first aspect, this embodiment provides a multimodal network compilation method, including:
[0010] Obtaining an intermediate representation of the source code of the multimodal network; wherein the intermediate representation is composed of a plurality of nodes, each node represents an intermediate representation element, and the node type includes at least one of the following: a header, a structure, a parser, an action, a matching action table, and a control program;
[0011] Traversing the intermediate representation, and extracting node attributes according to the traversed node type;
[0012] According to the user-defined fields, the node attributes are converted into a programming instruction sequence of a target network element device; wherein the target network element device supports user-defined fields and flexible programmable functions;
[0013] The programming instruction sequence and the preset flow table file are converted into microcode instructions, and the microcode instructions are sent to the target network element device; wherein the preset flow table file carries instruction information for forwarding the microcode instructions.
[0014] In some embodiments, traversing the intermediate representation and extracting node attributes according to the traversed node type includes:
[0015] Construct an abstract visitor and declare the interface method for accessing specific element classes;
[0016] The abstract visitor is instantiated to obtain a specific implementation visitor, and the specific implementation visitor is used to implement the operation of accessing the specific element class.
[0017] In some embodiments, an abstract visitor is constructed and an interface method for accessing a specific element class is declared, including:
[0018] Treat each node as an abstract node and define a visitor acceptance method, wherein the visitor acceptance method represents that each node can be visited by a visitor;
[0019] The constant representation of the node type is used as a specific element class, and a specific implementation for accessing the specific element class is provided.
[0020] In some embodiments, traversing the intermediate representation and extracting node attributes according to the traversed node type includes:
[0021] When traversing to the current node according to the preset search method, determining whether the current node already exists in a preset set; wherein the preset set stores the visited nodes;
[0022] If so, visit the next node;
[0023] If not, the current node is saved in the preset set, and the remaining nodes are recursively accessed.
[0024] In some embodiments, traversing to the current node according to a preset search method includes:
[0025] First traverse the root node, then recursively traverse the child nodes of the root node; or,
[0026] For each parent node, first traverse the child nodes of the parent node, then traverse the parent node; or,
[0027] The current node is moved into a preset queue. If the preset queue is not empty, the current node is moved out of the queue and the current node is accessed. If the current node has child nodes, the child nodes are moved into the preset queue in sequence.
[0028] In some of these embodiments, the intermediate representation includes:
[0029] In the intermediate representation of the header, each node represents a header. The attributes of the node include Node_type, name, and fields. Node_type is the Type_Header constant, name is the header alias, and fields is a list set containing header attributes and attribute lengths.
[0030] In the intermediate representation of the structure, each node represents a structure. The attributes of the node include Node_type, name, and fields. Node_type is the Type_Struct constant, name is the custom structure name, and fields is a list set containing the structure variable type, variable name, and variable length.
[0031] The intermediate representation of the parser, the attributes of the root node include Node_type, name, applyParams, and state. Node_type is the PolymorphicParser constant, name is the custom parser name, the applyParams node is used to store formal parameter variables, where each formal parameter is a child node, the state node is used to store parsed statements, where each state statement is a child node, the Node_type of the state child node is the ParserState constant, the state child node contains the components child node and the selectExpression child node. The components child node is used to store the methods and parameters required for parsing the packet header, and the selectExpression child node is used to determine the next packet header to be parsed based on the currently parsed packet header;
[0032] Action intermediate representation, node attributes include Node_type, name, parameters, and body. Node_type is a PolymorphicAction constant, name is a custom action name, the parameters node is used to store formal parameter variables, where each formal parameter is a child node, and the body node is used to store action execution statements, where each action is a child node.
[0033] Matching action table intermediate representation. Node attributes include Node_type, name, and properties. Node_type is a TableProperties constant, name is the matching-action table name, and the properties node contains the condition matching node, action node, and default action node of the action table.
[0034] Control program intermediate representation, the node attributes include Node_type, components, Node_type is the BlockStatement constant, the components node is used to store judgment statements, where each judgment condition is a child node, the Node_type of the components child node is the IfStatement constant, and the attributes of components include the condition child node, ifTrue child node, and ifFalse child node.
[0035] In some embodiments, the action intermediate representation, the matching action table intermediate representation, and the control program intermediate representation have the same parent node, and the attributes of the parent node include Node_type, name, applyParams, controlLocals, and body. Node_type is a PolymorphicControl constant, name is a custom control pipeline name, the applyParams node is used to store formal parameter variables, where each formal parameter is a child node, the controlLocals node is composed of an action intermediate representation node and a matching action table intermediate representation node, and the body node is composed of a control program intermediate representation node.
[0036] In some embodiments, traversing the intermediate representation and extracting node attributes according to the traversed node type includes:
[0037] When the Node_type of the traversed node is the Type_Header constant, extract the header attributes and attribute length information of the current node;
[0038] When the Node_type of the traversed node is the Type_Struct constant, extract the structure variable type, variable name, and variable length information of the current node;
[0039] When the Node_type of the traversed node is a PolymorphicParser constant, extract the parsed statement information of the current node;
[0040] When the Node_type of the traversed node is the PolymorphicAction constant, extract the action execution information of the current node;
[0041] When the Node_type of the traversed node is the TableProperties constant, extract the action table information of the current node;
[0042] When the Node_type of the traversed node is the BlockStatement constant, extract the judgment statement information of the current node.
[0043] In some embodiments, the programming instruction sequence of the target network element device includes a key-value pair, wherein the user-defined field serves as the key of the key-value pair, and the length, offset, priority, and offset starting point of the user-defined field serve as the value of the key-value pair.
[0044] In some embodiments, converting the programming instruction sequence and the preset flow table file into microcode instructions, and sending the microcode instructions to the target network element device includes:
[0045] Extracting the field matching value of the user-defined field from the flow table file;
[0046] The extracted field matching value is combined with the programming instruction sequence to generate the microcode instruction.
[0047] In some embodiments, the multimodal network includes at least one of the following: an IPv4 network, an IPv6 network, a mobile-first network, a named data network, a geographic identification network, and an industrial control protocol network.
[0048] In a second aspect, a multimodal network compilation system is provided in this embodiment. The multimodal network compilation system includes:
[0049] A front-end compiler is used to analyze the source code of the multimodal network and generate an intermediate representation;
[0050] A back-end compiler is coupled to the front-end compiler, and is configured to receive the intermediate representation and execute the multimodal network compilation method described in the first aspect.
[0051] In a third aspect, this embodiment provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the multimodal network compilation method described in the first aspect above.
[0052] The details of one or more embodiments of the present application are set forth in the accompanying drawings and the description below. Other features, objects, and advantages of the present application will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to better describe and illustrate the embodiments and / or examples of the inventions disclosed herein, reference may be made to one or more of the accompanying drawings. The additional details or examples used to describe the accompanying drawings should not be considered to limit the scope of the disclosed inventions, the presently described embodiments and / or examples, and any of the best modes currently understood for these inventions.
[0054] FIG1 is a hardware structure block diagram of a terminal of a multimodal network compilation method according to one or more embodiments;
[0055] FIG2 is a flowchart of a multimodal network compilation method according to one or more embodiments;
[0056] FIG3 is a schematic diagram of traversing an intermediate representation according to one or more embodiments;
[0057] FIG4 is a flowchart of a multimodal network compilation method according to one or more embodiments;
[0058] FIG5 is a structural block diagram of a multimodal network compilation system according to one or more embodiments;
[0059] FIG6 is a structural block diagram of a multimodal network compilation system according to one or more embodiments;
[0060] 7 is a flowchart of an operating method of a multimodal network compilation system according to one or more embodiments;
[0061] FIG8 is a schematic diagram of a data packet format according to one or more embodiments;
[0062] FIG9 is a diagram illustrating an internal structure of a computer device according to one or more embodiments. DETAILED DESCRIPTION
[0063] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0064] Unless otherwise defined, the technical terms or scientific terms involved in this application should have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "an", "a", "the", "these" and the like in this application do not indicate quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "plurality" involved in this application refers to two or more. "And / or" describes the relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, and B exists alone. Generally, the character " / " indicates that the related objects are in an "or" relationship. The terms "first," "second," "third," etc. used in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0065] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, when running on a terminal, Figure 1 is a hardware structure block diagram of a terminal of a multimodal network compilation method according to an embodiment of the present application. As shown in Figure 1, the terminal may include one or more (only one is shown in Figure 1) processors 102 and a memory 104 for storing data, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above-mentioned terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that the structure shown in Figure 1 is only for illustration and does not limit the structure of the above-mentioned terminal. For example, the terminal may also include more or fewer components than those shown in Figure 1, or have a different configuration than that shown in Figure 1.
[0066] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the multimodal network compilation method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0067] The transmission device 106 is used to receive or send data via a network. The network may include a wireless network provided by the terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0068] In one embodiment, FIG2 shows a flowchart of the multimodal network compilation method of this embodiment, which is illustrated by taking the method running on the terminal shown in FIG1 as an example. The process includes the following steps:
[0069] Step S201: Obtain an intermediate representation of the source code of the multimodal network; wherein the intermediate representation is composed of multiple nodes, each node represents an intermediate representation element, and the node type includes at least one of the following: packet header, structure, parser, action, matching action table, and control program.
[0070] Multimodal networks, including IPV4 networks, IPV6 networks, mobile-first networks, named data networks, geographic identification networks, and industrial control protocol networks.
[0071] Intermediate representation elements (IREs) refer to the representation of the source code in a multimodal network during the conversion process from source code to target code. IREs include headers, structures, parsers, actions, matching action tables, and control programs. IRE types are node types.
[0072] Intermediate representation refers to storing intermediate representation elements in the form of a graph structure. The intermediate representation can be a directed acyclic graph.
[0073] Step S202: traverse the intermediate representation and extract node attributes according to the traversed node types.
[0074] The node attributes of each node include common attributes and special attributes. The common attributes include node type and node name, and the special attributes have different settings depending on the node type.
[0075] Step S203: converting the node attributes into a programming instruction sequence of a target network element device according to the user-defined fields; wherein the target network element device supports user-defined fields and flexible programmable functions.
[0076] The target network element device supports User Defined Fields (UDF) and Flex Edit. UDF allows you to specify specific fields within a message by customizing offsets starting from the Layer 2, Layer 3, or Layer 4 header. This, combined with Access Control Lists (ACLs), allows you to process special messages. Flex Edit allows you to add, delete, or modify data segments of a specified length at a specified offset starting from the Layer 2, Layer 3, or Layer 4 header. Combined with UDF, you can customize message content and provide more flexible support for new protocol types.
[0077] The programming instruction sequence of the target network element device includes a key-value pair, wherein the user-defined field serves as the key of the key-value pair, and the length, offset, priority, and offset starting point of the user-defined field serve as the value of the key-value pair.
[0078] Step S204 , converting the programming instruction sequence and the preset flow table file into microcode instructions, and sending the microcode instructions to the target network element device; wherein the preset flow table file carries instruction information for forwarding the microcode instructions.
[0079] Specifically, the field matching value of the user-defined field is extracted from the flow table file; the extracted field matching value is combined with the programming instruction sequence to generate a microcode instruction.
[0080] In the above steps S201 to S204, by obtaining the intermediate representation of the source program code of the multimodal network, extracting the node attributes, and converting the node attributes into a programming instruction sequence of the target network element device according to the user-defined fields, the programming instruction sequence and the preset flow table file are converted into microcode instructions, and the microcode instructions are sent to the target network element device. This can shield the underlying heterogeneous hardware resources of the network switch, map the multimodal network program to the programmable network element device, reduce the difficulty of development and deployment of the multimodal network, and realize flexible processing of custom protocol data packets.
[0081] In one embodiment, the following types of intermediate representations are given.
[0082] (1) Intermediate representation of packet header. Each node represents a packet header. The attributes of the node include Node_type, name, and fields. Node_type is the Type_Header constant, name is the packet header alias, and fields is a list set containing packet header attributes and attribute lengths.
[0083] (2) Intermediate representation of the structure. Each node represents a structure. The attributes of the node include Node_type, name, and fields. Node_type is the Type_Struct constant, name is the custom structure name, and fields is a list set containing the structure variable type, variable name, and variable length.
[0084] (3) Parser intermediate representation. The attributes of the root node include Node_type, name, applyParams, and state. Node_type is the PolymorphicParser constant, name is the custom parser name, the applyParams node is used to store formal parameter variables, where each formal parameter is a child node, the state node is used to store parsed statements, where each state statement is a child node, the Node_type of the state child node is the ParserState constant, the state child node contains the components child node and the selectExpression child node, the components child node is used to store the methods and parameters required for parsing the packet header, and the selectExpression child node is used to determine the next packet header to be parsed based on the currently parsed packet header.
[0085] (4) Action intermediate representation. The attributes of the node include Node_type, name, parameters, and body. Node_type is the PolymorphicAction constant, name is the custom action name, the parameters node is used to store formal parameter variables, where each formal parameter is a child node, and the body node is used to store action execution statements, where each action is a child node.
[0086] (5) The intermediate representation of the matching action table. The attributes of the node include Node_type, name, and properties. Node_type is the TableProperties constant, name is the matching-action table name, and the properties node contains the condition matching node, action node, and default action node of the action table.
[0087] (6) Control program intermediate representation. The attributes of the node include Node_type and components. Node_type is the BlockStatement constant. The components node is used to store judgment statements, where each judgment condition is a child node. The Node_type of the components child node is the IfStatement constant. The attributes of components include the condition child node, the ifTrue child node, and the ifFalse child node.
[0088] Furthermore, the action intermediate representation, matching action table intermediate representation, and control program intermediate representation have the same parent node. The attributes of the parent node include Node_type, name, applyParams, controlLocals, and body. Node_type is a PolymorphicControl constant, name is a custom control pipeline name, the applyParams node is used to store formal parameter variables, where each formal parameter is a child node. The controlLocals node is composed of the action intermediate representation node and the matching action table intermediate representation node, and the body node is composed of the control program intermediate representation node.
[0089] In one embodiment, traversing the intermediate representation and extracting node attributes according to the traversed node type includes:
[0090] When the Node_type of the traversed node is the Type_Header constant, extract the header attributes and attribute length information of the current node;
[0091] When the Node_type of the traversed node is the Type_Struct constant, extract the structure variable type, variable name, and variable length information of the current node;
[0092] When the Node_type of the traversed node is a PolymorphicParser constant, extract the parsed statement information of the current node;
[0093] When the Node_type of the traversed node is the PolymorphicAction constant, extract the action execution information of the current node;
[0094] When the Node_type of the traversed node is the TableProperties constant, extract the action table information of the current node;
[0095] When the Node_type of the traversed node is the BlockStatement constant, extract the judgment statement information of the current node.
[0096] In one embodiment, the intermediate representation is traversed and node attributes are extracted according to the traversed node type, including: constructing an abstract visitor and declaring an interface method for accessing a specific element class; instantiating the abstract visitor to obtain a specific implementation visitor, and using the specific implementation visitor to implement operations for accessing the specific element class.
[0097] Furthermore, an abstract visitor is constructed and an interface method for accessing a specific element class is declared, including: treating each node as an abstract node and defining a visitor acceptance method, wherein the visitor acceptance method represents that each node can be accessed by the visitor; representing the constant of the node type as a specific element class and providing a specific implementation for accessing the specific element class.
[0098] In this embodiment, by decoupling the intermediate representation and access actions, operations on the intermediate representation are made scalable. For example, for an intermediate representation, nodes may be modified or added later. According to the intermediate representation traversal method of this embodiment, the subsequent processing of the nodes will not be affected.
[0099] Exemplarily, the terminal includes a back-end compiler, and FIG3 shows a schematic diagram of the principle of traversing the intermediate representation in this embodiment. As shown in FIG3 , the back-end compiler 52 uses the visitor pattern to traverse the directed acyclic graph 31. The directed acyclic graph 31 is implemented using DAGTree. DAGTree, as a tree structure, provides a method for the visitor object to traverse all abstract nodes 34 in the container. The abstract visitor 32 is used to declare the interface method for accessing a specific element class. The specific implementation visitor 33 is used to implement the operation of accessing the specific element class 35 and determine the operation of the visitor to access the specific element. The abstract node 34 defines an accept method for accepting the visitor, which means that each node can be accessed by the visitor. The specific element class 35 includes TypeHeaderNode, TypeStructNode, ParserStateNode, PolymorphicActionNode, PolymorphicTableNode, and PolymorphicControlNode, which are used to provide the visitor with a specific implementation of accessing the element class.
[0100] Furthermore, three optional preset search methods are given below.
[0101] (1) First traverse the root node, then recursively traverse the child nodes of the root node.
[0102] (2) For each parent node, first traverse the child nodes of the parent node, and then traverse the parent node.
[0103] (3) Move the current node into the preset queue. If the preset queue is not empty, move the current node out of the queue and access the current node. If the current node has child nodes, move the child nodes into the preset queue in sequence.
[0104] In one embodiment, FIG4 shows a flowchart of another multimodal network compilation method. As shown in FIG4 , the process includes the following steps:
[0105] Step S401, obtaining an intermediate representation of the source code of the multimodal network;
[0106] Step S402, determine whether the intermediate representation is successfully generated; if so, execute step S403; if not, execute step S404;
[0107] Step S403, traverse the intermediate representation and extract node attributes according to Node_Type;
[0108] Step S404, handle the error;
[0109] Step S405: converting node attributes into attribute information of the target platform according to the mapping rules between the source code and the target code of the multimodal network;
[0110] Step S406, determining whether the target platform's attribute information has errors; if so, returning to step S404; if not, executing step S407;
[0111] Step S407, generating a programming instruction sequence recognizable by the target platform based on the attribute information of the target platform;
[0112] Step S408, determining whether there is an error in the programming instruction sequence; if so, returning to step S404; if not, executing step S409;
[0113] Step S409 , converting the programming instruction sequence and the preset flow table file into microcode instructions, and outputting the microcode instructions to a target file.
[0114] Among them, node attributes are extracted according to Node_type and converted into attribute information of the target platform; the network element platform functions are formalized into a target platform action parameter set, and a programming instruction sequence based on user-defined fields and flexible programmable network element devices is generated and output to the target file.
[0115] In one embodiment, a multimodal network compilation system is provided. Figure 5 is a block diagram of the multimodal network compilation system of this embodiment. As shown in Figure 5, the multimodal network compilation system 5 includes a front-end compiler 51 and a back-end compiler 52. The front-end compiler 51 is used to analyze the source code of the multimodal network and generate intermediate representation data; the back-end compiler 52 is coupled to the front-end compiler 51 and is used to receive the intermediate representation and execute the multimodal network compilation method of any of the above-mentioned method embodiments.
[0116] In one embodiment, Figure 6 provides a block diagram of another multimodal network compilation system. As shown in Figure 6, the front-end compiler 51 includes a lexical analysis module 511, a syntax analysis module 512, a semantic analysis module 513, and an intermediate code generation module 514; the back-end editor 52 includes a target code generation module 521.
[0117] The lexical analysis module 511 is used to extract words from the multimodal network source code using regular expression matching and scan line by line to identify grammatical elements. The identified grammatical elements are stored in a hash table. The hash table keys are type codes, consisting of keywords, operators, constants, and identifiers, and the hash table values are identifier names or constant values.
[0118] The syntax analysis module 512 is used to remove and merge non-critical multimodal network source programs, such as spaces and comments, and generate an abstract syntax tree.
[0119] The semantic analysis module 513 is used to perform semantic checking to check whether the abstract syntax tree generated by the grammatical analysis module 512 is consistent with the defined semantics. If there are semantic errors such as type errors, length out of bounds, duplicate definitions, etc., the front-end compiler 51 exits compilation and outputs an error message.
[0120] The intermediate code generation module 514 is used to generate a directed acyclic graph of the intermediate representation according to the abstract syntax tree information and merge common sub-expressions.
[0121] The target code generation module 521 is used to take the intermediate representation as input, generate an instruction set based on the target language according to the mapping rules between the multimodal network source program language and the target language, and construct it into a corresponding target file output.
[0122] In one embodiment, a method for operating a multimodal network compilation system is provided. FIG7 shows a flow chart of the method for operating a multimodal network compilation system according to this embodiment. As shown in FIG7 , the flow chart includes the following steps:
[0123] Step S501, using a multimodal network program to program and describe the data packet processing logic of the multimodal network;
[0124] Step S502: Using a multimodal network compilation system, compile the multimodal network program into a programming instruction sequence recognizable by a target platform; wherein the target platform includes a network element device based on user-defined fields and flexible programmability;
[0125] Step S503: On the target platform, the programming instruction sequence and the flow table file are converted into microcode instructions through the ASIC management plane driver and sent to the ASIC chip.
[0126] Among them, node attributes are extracted according to Node_type and converted into attribute information of the target platform; the network element platform functions are formalized into a target platform action parameter set, and a programming instruction sequence based on user-defined fields and flexible programmable network element devices is generated and output to the target file.
[0127] Among them, multimodal networks include IPV4 networks, IPV6 networks, mobile-first networks, named data networks, geographic identification networks, and industrial control protocol networks.
[0128] Among them, the packet processing logic refers to the forwarding of multimodal network packets. Specifically, it models the header of a multimodal network packet; models the header parsing of a multimodal network packet; models the tables and actions of a multimodal network; and models the control flow of a multimodal network. Taking the forwarding of the geographic identification modality as an example, a multimodal network program is used to write a geographic identification modality program, which is addressed by information such as longitude and latitude, coverage, etc. The front-end compiler converts the multimodal network program into a target-independent intermediate representation and hands the intermediate representation to the back-end compiler. The back-end compiler converts the intermediate representation into a sequence of programming instructions based on user-defined fields and flexible programmability.
[0129] In one embodiment, keywords such as latitude and longitude, length and width, and shape are extracted from the match field of the geographic identification modality, as shown below:
[0130] hdr.gbc.geoAreaPosLat, hdr.gbc.geoAreaPosLon, hdr.gbc.disa, hdr.gbc.disb, hdr.its.stationid;
[0131] Convert these keywords into programming instruction sequence fields as follows:
[0132] "key":{"disa":{"length":16,"offset":496,"priority":7,"start":"L2","value":"~ / "},"disb":{"len gth":,"offset":512,"priority":7,"start":"L2","value":"~ / "},"etherType":{"length":16,"offset":96,"p priority":7,"start":"L2","value":"0x8947"},"geoAreaPosLat":{"length":32,"offset":432,"priority":7,"start":"L2","value":"~ / "},"geoAreaPosLon":{" length":32,"offset":464,"priority":7,"start":"L2","value":"~ / "},"stationid":{"length":32,"offset":16,"priority":7,"start":"L2","value":"~ / "}}.
[0133] In the field, "length":16 indicates that the length of the disa field is 16 bits, "offset":496 indicates that the offset is 496 bits, "priority":7 indicates the priority, "start":"L2" indicates the offset from the start of the Layer 2 header field, and "value":"~ / " indicates that the matching value should be obtained from the flow table.
[0134] The programming instruction sequence is synchronized to the ASIC management plane driver, and a flow table file is written to guide the ASIC chip to forward. The flow table format is shown in Table 1. Here, ID represents the flow table number, TABLE represents the table name, KEY represents the key of the key-value pair, ACTION represents the executed action, MATCH represents the user-defined field, and VALUE represents the field match value.
[0135] Table 1 Flow table format
[0136] The ASIC driver converts the flow table file and the programming instruction sequence into microcode instructions and sends the microcode instructions to the ASIC chip. The microcode instruction format is shown in Table 2. Among them, RULE represents the forwarding rule of the microcode instruction.
[0137] Table 2 Microcode instruction format
[0138] In one embodiment, using mobile-first network forwarding as an example, a multimodal network program is used to write a mobile-first network modality program, using a globally unique identifier (GUID) as its forwarding addressing flag. Figure 8 shows a schematic diagram of the packet format of this embodiment. As shown in Figure 8, the packet format includes the Ethernet destination address, source address, type 27c0 information, the identity type of the custom identifier, the source identifier (src_guid), the destination identifier (dest_guid), and the payload.
[0139] The front-end compiler converts the multimodal network program into a target-independent intermediate representation and passes the intermediate representation to the back-end compiler. The back-end compiler converts the intermediate representation into a programming instruction sequence based on user-defined fields and flexible programmability. When the back-end compiler extracts keywords such as the match field of the geographic identification mode: hdr.mf.dest_guid, the action field: change_mac, it converts it into a programming instruction sequence field:
[0140] "key":{"dest_guid":{"length":32,"offset":176,"priority":7,"start":"L2","value":"~ / "}},"action":{"change_mac":{"length":48,"offset":48,"priority":7,"start":"L2","value":"~ / "}}, where "length":16 indicates that the length of the change_mac field modified is 48 bits, "offset":48 indicates the offset is 48 bits, "priority":7 indicates the priority, "start":"L2" indicates the offset from the Layer 2 header field, and "value":"~ / " indicates that the modified value should be obtained from the flow table. Synchronize the programming instruction sequence to the ASIC management plane driver and write a flow table file to guide the ASIC chip forwarding. The flow table format is shown in Table 3:
[0141] Table 3 Flow table format
[0142] The ASIC driver sends the microcode instructions to the ASIC chip according to the flow table file and the programming instruction sequence. The microcode instruction format is shown in Table 4:
[0143] Table 4 Microcode instruction format
[0144] In conjunction with the multimodal network compilation method provided in the above embodiments, a storage medium may also be provided in this embodiment to implement the multimodal network compilation method. The storage medium stores a computer program; when the computer program is executed by a processor, any of the multimodal network compilation methods in the above embodiments is implemented.
[0145] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in Figure 9. The computer device 9 includes a processor 92, a memory 93, a communication interface 94, a display unit 95, and an input device 96 connected via a system bus 91. The processor 92 of the computer device 9 is used to provide computing and control capabilities. The memory 93 of the computer device 9 includes a non-volatile storage medium 931 and an internal memory 932. The non-volatile storage medium 931 stores an operating system and a computer program. The internal memory 932 provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium 931. The communication interface 94 of the computer device 9 is used to communicate with an external terminal in a wired or wireless manner. The wireless manner may be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor 92, a multimodal network compilation method is implemented. The display unit 95 of the computer device 9 may be a liquid crystal display or an electronic ink display. The input device 96 of the computer device 9 may be a touch screen covering the display unit 95, or may be a key, trackball, or touchpad provided on the housing of the computer device 9, or may be an external keyboard, touchpad, or mouse. The computer device 9 also includes an input / output interface 97, through which the communication interface 94, the display unit 95, and the input device 96 are connected to the system bus 91.
[0146] Those skilled in the art will understand that the structure shown in FIG9 is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0147] It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0148] Obviously, the accompanying drawings are merely examples or embodiments of the present application. A person skilled in the art can also apply the present application to other similar situations based on these drawings without inventive effort. Furthermore, it is understandable that, although the work involved in this development process may be complex and lengthy, certain design, manufacturing, or production changes based on the technical content disclosed in this application are merely routine technical means for a person skilled in the art and should not be considered to constitute a deficiency in the disclosure of the present application.
[0149] The term "embodiment" as used in this application refers to specific features, structures, or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily mean that the embodiment is the same, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is understood, either explicitly or implicitly, by those skilled in the art that the embodiments described in this application can be combined with other embodiments when there is no conflict.
[0150] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, storage, and display, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. The acquisition, storage, use, and processing of data involved in the embodiments of this application comply with the relevant provisions of national laws and regulations.
[0151] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0152] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0153] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A multimodal network compilation method, characterized in that: include: Obtaining an intermediate representation of a source program code of a multimodal network; wherein the intermediate representation is composed of a plurality of nodes, each node represents an intermediate representation element, and the node type includes at least one of the following: a packet header, a structure, a parser, an action, a matching action table, and a control program; Traversing the intermediate representation, and extracting node attributes according to the traversed node type; According to the user-defined fields, the node attributes are converted into a programming instruction sequence of a target network element device; wherein the target network element device supports user-defined fields and flexible programmable functions; The programming instruction sequence and the preset flow table file are converted into microcode instructions, and the microcode instructions are sent to the target network element device; wherein the preset flow table file carries indication information for forwarding the microcode instructions.
2. The multimodal network compilation method according to claim 1, wherein: The intermediate representation is traversed, and node attributes are extracted according to the traversed node type, including: Construct an abstract visitor and declare the interface method for accessing specific element classes; The abstract visitor is instantiated to obtain a specific implementation visitor, and the specific implementation visitor is used to implement the operation of accessing the specific element class.
3. The multimodal network compilation method according to claim 2, wherein: Construct an abstract visitor and declare the interface method for accessing specific element classes, including: Take each node as an abstract node and define a visitor acceptance method, wherein the visitor acceptance method represents that each node can be visited by a visitor; The constant representation of the node type is used as a specific element class, and a specific implementation for accessing the specific element class is provided.
4. The multimodal network compilation method according to claim 1, wherein: The intermediate representation is traversed, and node attributes are extracted according to the traversed node type, including: When traversing to the current node according to the preset search method, determining whether the current node already exists in a preset set; wherein the preset set stores the visited nodes; If so, visit the next node; If not, the current node is saved in the preset set, and the remaining nodes are accessed recursively.
5. The multimodal network compilation method according to claim 4, wherein: Traverse to the current node according to the preset search method, including: First traverse the root node, and then recursively traverse the child nodes of the root node; or, For each parent node, first traverse the child nodes of the parent node, and then traverse the parent node; or, The current node is moved into a preset queue. If the preset queue is not empty, the current node is moved out of the queue and the current node is accessed. If the current node has child nodes, the child nodes are moved into the preset queue in sequence.
6. The multimodal network compilation method according to claim 1, wherein: The intermediate representation includes: In the intermediate representation of the packet header, each node represents a packet header. The attributes of the node include Node_type, name, and fields. Node_type is the Type_Header constant, name is the packet header alias, and fields is a list set containing packet header attributes and attribute lengths. In the intermediate representation of the structure, each node represents a structure. The attributes of the node include Node_type, name, and fields. Node_type is the Type_Struct constant, name is the custom structure name, and fields is a list set containing the structure variable type, variable name, and variable length. Parser intermediate representation, the attributes of the root node include Node_type, name, applyParams, and state. Node_type is a PolymorphicParser constant, name is a custom parser name, the applyParams node is used to store parameter variables, each parameter is a child node, the state node is used to store parsed statements, each state statement is a child node, the Node_type of the state child node is the ParserState constant, the state child node contains the components child node and the selectExpression child node, the components child node is used to store the methods and parameters required for parsing the packet header, and the selectExpression child node is used to determine the next packet header to be parsed based on the currently parsed packet header; Action intermediate representation, node attributes include Node_type, name, parameters, body, Node_type is the PolymorphicAction constant, name is the custom action name, parameters node is used to store formal parameter variables, each formal parameter is a child node, body node is used to store action execution statements, each action is a child node; The intermediate representation of the matching action table. The attributes of the node include Node_type, name, and properties. Node_type is the TableProperties constant, name is the matching-action table name, and the properties node contains the condition matching node, action node, and default action node of the action table. Control program intermediate representation, the properties of the node include Node_type, components, Node_type is the BlockStatement constant, the components node is used to store judgment statements, each judgment condition is a child node, the Node_type of the components child node is the IfStatement constant, and the properties of components include the condition child node, ifTrue child node, and ifFalse child node.
7. The multimodal network compilation method according to claim 6, wherein: The action intermediate representation, the matching action table intermediate representation, and the control program intermediate representation have the same parent node, and the attributes of the parent node include Node_type, name, applyParams, controlLocals, and body. Node_type is a PolymorphicControl constant, name is a custom control pipeline name, and the applyParams node is used to store formal parameter variables, where each formal parameter is a child node. The controlLocals node is composed of an action intermediate representation node and a matching action table intermediate representation node, and the body node is composed of a control program intermediate representation node.
8. The multimodal network compilation method according to claim 7, wherein: The intermediate representation is traversed, and node attributes are extracted according to the traversed node type, including: When the Node_type of the traversed node is the Type_Header constant, extract the header attribute and attribute length information of the current node; When the Node_type of the traversed node is the Type_Struct constant, extract the structure variable type, variable name, and variable length information of the current node; When the Node_type of the traversed node is a PolymorphicParser constant, extract the parsing statement information of the current node; When the Node_type of the traversed node is the PolymorphicAction constant, extract the action execution information of the current node; When the Node_type of the traversed node is the TableProperties constant, extract the action table information of the current node; When the Node_type of the traversed node is the BlockStatement constant, extract the judgment statement information of the current node.
9. The multimodal network compilation method according to claim 1, wherein: The programming instruction sequence of the target network element device includes a key-value pair, wherein the user-defined field serves as the key of the key-value pair, and the length, offset, priority, and offset starting point of the user-defined field serve as the value of the key-value pair.
10. The multimodal network compilation method according to claim 9, wherein: Converting the programming instruction sequence and the preset flow table file into microcode instructions, and sending the microcode instructions to the target network element device, including: Extracting a field matching value of the user-defined field from the flow table file; The extracted field matching value is combined with the programming instruction sequence to generate the microcode instruction.
11. The multimodal network compilation method according to claim 1, wherein: The multimodal network includes at least one of the following: an IPV4 network, an IPV6 network, a mobile priority network, a named data network, a geographic identification network, and an industrial control protocol network.
12. A multimodal network compilation system, characterized in that: The multimodal network compilation system comprises: The front-end compiler is used to analyze the source code of the multimodal network and generate an intermediate representation; A back-end compiler, coupled to the front-end compiler, is used to receive the intermediate representation and execute the multimodal network compilation method according to any one of claims 1 to 11.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the multimodal network compilation method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Compilation method, device, and equipment based on heterogeneous system, and storage medium
CN113553054A
Network routing method, system and device, and electronic equipment
CN113765808A
Modal deployment method and modal deployment system of multi-modal network
CN116074208A
Method and system for realizing user-defined mode in multi-mode network
CN116366547A
Modal intermediate representation-oriented compiling method, system and equipment and storage medium
CN116737130A
Cited By
Code block segmentation method and device, program product, electronic equipment and storage medium
CN121579546A