Online dynamic programming method, system and storage medium for programmable network devices
By inserting custom protocol headers into IP packets and parsing network service instructions in programmable network devices, the problems of insufficient high performance and online programming flexibility in existing technologies are solved, realizing efficient and scalable online dynamic programming and avoiding business interruption and performance degradation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2026-04-14
AI Technical Summary
Existing programmable network technologies cannot simultaneously meet the requirements of high performance and online programming flexibility, which means that programs need to be recompiled every time network service functions are added or removed, resulting in service interruptions and performance degradation.
By inserting custom protocol headers into IP packets, containing sequences of network service instructions, and parsing and executing these instructions in programmable network devices, network services can be dynamically adjusted, and a recycle processing mechanism can be supported to handle instruction sequences of arbitrary length.
It achieves a balance between high performance and online programming flexibility, avoids business interruption, ensures high throughput and low latency network services, supports network service command sequences of arbitrary length, and enables efficient and scalable online dynamic programming.
Smart Images

Figure CN120602572B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication network technology, and in particular to an online dynamic programming method, system, and storage medium for programmable network devices. Background Technology
[0002] With the continuous development of internet services, the scale and number of data centers are constantly increasing, leading to increased complexity in network management and operation. To address this challenge, Software-Defined Networking (SDN) was proposed. Its core concept is to separate the data forwarding plane from the control plane, enabling more granular control of network resources and greater service flexibility. With the development of SDN, the data forwarding plane has become more flexible, giving rise to programmable network technologies, including key achievements such as network programming languages (e.g., P4), network programming models, and programmable network devices. The importance of programmable network technology lies in its ability to not only simplify network configuration and management processes but also endow networks with a higher level of intelligence, enabling them to meet complex business needs. Therefore, programmable network technology is a core element in building efficient, intelligent, and flexible network infrastructure.
[0003] However, current programmable network technologies cannot simultaneously satisfy both high performance and the flexibility of online programming. Specifically, programming programmable network devices, especially programmable switches, requires recompiling the entire program every time a network service function is added or removed. This interrupts the programmable network device's service, necessitates redeploying the program, resulting in significant application traffic interruptions and severely impacting service quality. While software switches like Click Router support flexible online adjustments to avoid service interruptions, they run on general-purpose servers, and their hardware and software are not specifically designed for network processing, limiting their performance. Limited CPU processing power, coupled with significant latency from the operating system and protocol stack, leads to low forwarding efficiency. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide an online dynamic programming method, system, and storage medium for programmable network devices to eliminate or improve one or more defects existing in the prior art. This addresses the problem that existing programmable network technologies cannot simultaneously satisfy high performance and online programming flexibility.
[0005] One aspect of the present invention provides an online dynamic programming method for a programmable network device, used in a control terminal, comprising:
[0006] Based on the network service functions specified by the user configuration or application requirements, the corresponding network service function definitions are invoked to generate the corresponding network service instruction sequence;
[0007] A custom protocol header is constructed based on a network service instruction sequence and a custom protocol structure and inserted into the IP packet. The custom protocol structure includes the protocol type, the number of instructions, and the instruction sequence. The instruction sequence contains the instruction type and instruction data.
[0008] The type field of the IP packet indicates whether the current packet belongs to a regular packet or contains a custom protocol header.
[0009] IP packets are sent to the programmable network device so that the programmable network device can forward the packet directly when the flag value of the type field indicates that the current packet belongs to a normal packet; when the flag value indicates that the current packet contains a custom protocol header, the programmable network device can parse the custom protocol header, execute and remove the network service instruction sequence one by one, and dynamically adjust the network service of the programmable network device.
[0010] In some embodiments of the present invention, a custom protocol header is constructed based on a network service instruction sequence and a custom protocol structure and inserted into the IP data packet, including:
[0011] Mark the forwarding protocol type recorded in the original type field of the IP packet to the protocol type;
[0012] The number of instructions, the type of instructions, and the data of the network service instruction sequence are sequentially filled into the custom protocol structure to obtain the custom protocol header;
[0013] Insert a custom protocol header after the IP header in the IP packet.
[0014] In some embodiments of the present invention, network service functions are pre-stored in a preset network service function library;
[0015] Based on the network service functions specified by the user configuration or application requirements, the corresponding network service function definitions are invoked to generate the corresponding network service instruction sequence, including:
[0016] Based on the network service function, select and call the corresponding network service function from the network service function library;
[0017] Based on the function definition of the called network service function, generate at least one network service instruction;
[0018] All network service commands are sorted according to a preset execution order to obtain a network service command sequence.
[0019] In some embodiments of the present invention, the network service function library is deployed in the control terminal and interacts with the control terminal through a unified library interface;
[0020] In cases where calling a function from the network service function library fails, the following are also included:
[0021] Generate and output prompt messages; these messages prompt the user to add the corresponding network service functions to the network service function library.
[0022] Upon receiving new network service function code uploaded by a user or external development tool, perform syntax verification, security checks, and compatibility verification with the network service function library on the new network service function, and obtain the verification results.
[0023] If the verification result indicates that the verification is successful, the new network service function is registered to the network service function library, and a mapping relationship with the corresponding network service function is established.
[0024] Update the function call list and metadata index in the library interface.
[0025] Another aspect of the present invention provides an online dynamic programming method for a programmable network device, comprising:
[0026] In response to a received IP packet, the flag value of the type field in the IP packet is parsed. The flag value indicates whether the IP packet contains a custom protocol header or belongs to a regular packet. The custom protocol header includes the protocol type, the number of instructions, and the instruction sequence. The protocol type records the forwarding protocol type of the IP packet. The instruction sequence contains the instruction type and instruction data.
[0027] If the flag indicates that the IP packet contains a custom protocol header, the custom protocol header is parsed, network service instructions in the instruction sequence are executed and removed sequentially, and the instruction count is updated until the instruction count is 0, thus completing the execution of all network service instructions.
[0028] In some embodiments of the present invention, when the number of instructions is 0, the method further includes:
[0029] Mark the forwarding protocol type in the type field;
[0030] Remove the custom protocol header and forward the IP packets.
[0031] In some embodiments of the present invention, the programmable network device includes at least one instruction function module; each instruction function module is responsible for processing network service instructions of a specified type.
[0032] Execute and remove network service commands in the command sequence in order, including:
[0033] Extract a network service instruction from the instruction sequence in sequence and remove it from the instruction sequence; the extracted network service instruction includes the corresponding instruction type and instruction data;
[0034] Based on the preset mapping relationship between the extracted instruction type and instruction function module, the corresponding instruction function module is queried and determined as the target instruction function module;
[0035] The extracted instruction data is sent to the target instruction function module for execution.
[0036] In some embodiments of the present invention, when the flag value indicates that the IP packet is a normal packet, the method further includes: directly forwarding the IP packet.
[0037] Another aspect of the present invention provides an online dynamic programming system for a programmable network device, including a processor, a memory, and a computer program / instructions stored in the memory. The processor is used to execute the computer program / instructions. When the computer program / instructions are executed, the system implements the steps of the online dynamic programming method for a programmable network device as described above.
[0038] Another aspect of the present invention provides a computer-readable storage medium storing a program that, when executed by a processor, is used to implement the steps of the online dynamic programming method for a programmable network device as described above.
[0039] The beneficial effects of the present invention include at least the following:
[0040] The present invention discloses an online dynamic programming method and system for programmable network devices. A control terminal, based on network service functions specified by user configuration or application requirements, calls corresponding network service function definitions to generate a corresponding network service instruction sequence. A custom protocol header is constructed based on the network service instruction sequence and a custom protocol structure and inserted into IP packets. The type field of the IP packets is marked with a flag indicating whether the current packet belongs to a normal packet or contains network service instructions. The custom protocol structure includes a protocol type, a number of instructions, and an instruction sequence. The instruction sequence includes instruction types and instruction data. The programmable network device receives IP packets sent by the control terminal. When the type field of the IP packet indicates that the current packet belongs to a normal packet, it is forwarded directly. When the type field of the IP packet indicates that the current packet contains network service instructions, the custom protocol header is parsed, and the network service instruction sequence is executed and removed one by one, dynamically adjusting the network services of the programmable network device. This addresses the shortcomings of existing programmable network technologies. This addresses the challenge of simultaneously achieving high performance and flexible online programming. By focusing on the hardware design and implementation of programmable network devices, reliance on software switches and general-purpose servers can be avoided, ensuring superior performance with high throughput and low latency, fully meeting the requirements of high-performance network services. Simultaneously, the control terminal generates corresponding network service instruction sequences by calling network service functions, inserting them into IP packets and modifying the IP packet type field to mark the packets. In the programmable network device, if the mark value in the received packet indicates that the current packet contains a network service instruction sequence, the sequence is parsed and executed sequentially; otherwise, the packet is forwarded directly. In this way, developers only need to write or extend the corresponding network service functions on the control terminal side, without modifying the program on the programmable network device or stopping the programmable network device's services, to complete online updates and deployments of network service functions, achieving efficient and dynamic network programming.
[0041] Furthermore, programmable network devices support a re-loop processing mechanism. After each network service instruction is executed, if the data packet still contains unexecuted instructions, it is sent back to the program entry point for the next round of processing until all instructions have been executed and the data packet is forwarded. This mechanism enables the system to support network service instruction sequences of arbitrary length, thereby achieving efficient and scalable online dynamic programming capabilities.
[0042] Additional advantages, objects, and features of the invention will be set forth in part in the description which follows, and will also become apparent in part to those skilled in the art upon studying the text, or may be learned by practice of the invention. The objects and other advantages of the invention can be realized and obtained by means of the structures specifically pointed out in the description and drawings.
[0043] Those skilled in the art will understand that the objectives and advantages achievable with the present invention are not limited to those specifically described above, and that the above and other objectives achievable with the present invention will become clearer from the following detailed description. Attached Figure Description
[0044] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, are not intended to limit the scope of the invention. In the drawings:
[0045] Figure 1 This is a schematic diagram of the structure of an online dynamic programming system for a programmable network device provided in an embodiment of the present invention.
[0046] Figure 2 This is a schematic diagram of the structure of a custom protocol header provided in an embodiment of the present invention.
[0047] Figure 3 This is a schematic diagram illustrating the process of a programmable network device processing IP packets according to an embodiment of the present invention.
[0048] Figure 4 This is a schematic diagram illustrating the online dynamic programming process of a programmable network device according to another embodiment of the present invention. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.
[0050] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.
[0051] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.
[0052] It should also be noted that, unless otherwise specified, the term "connection" in this article can refer not only to a direct connection, but also to an indirect connection involving an intermediary.
[0053] In the following description, embodiments of the invention will be illustrated with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar parts, or the same or similar steps.
[0054] This embodiment provides a schematic diagram of the structure of an online dynamic programming system for a programmable network device. (See diagram below.) Figure 1 As shown, the online dynamic programming system for programmable network devices includes at least: a control terminal 110 and a programmable network device 120.
[0055] like Figure 1 As shown, the description assumes that there is one control terminal 110 and one programmable network device 120. In actual implementation, there is at least one control terminal 110 and one programmable network device 120.
[0056] In some embodiments of the present invention, the control terminal 110 refers to an electronic device that can communicate with the programmable network device 120 (including wired or wireless communication connection) to configure and manage the network service functions of the programmable network device 120, including but not limited to mobile phones or tablet computers.
[0057] Programmable network device 120 refers to a network device that can be flexibly configured and dynamically adjusted for network services through programming, including but not limited to programmable switches or programmable routers. The network service functions include various network services provided by the programmable network device 120, such as traffic management, security policy enforcement, and Quality of Service (QoS) guarantees.
[0058] In some embodiments of the present invention, an encapsulation mechanism based on a custom protocol structure is employed. This mechanism constructs a custom protocol header through a sequence of network service instructions and a custom protocol structure, which carries the network service instructions and their related parameters, thereby enabling the transmission of network service instructions.
[0059] Specifically, the control terminal 110 is used to call the corresponding network service function definition to generate the corresponding network service instruction sequence according to the network service function indicated by the user configuration or application requirements; construct a custom protocol header based on the network service instruction sequence and the custom protocol structure and insert it into the IP data packet; mark the current data packet as a normal data packet or a tag value containing network service instructions in the type field of the IP data packet; and send the IP data packet to the programmable network device 120.
[0060] User configuration refers to the parameter information input by the user through an input module (such as a keyboard, mouse, touch screen, or remote management interface) connected to the control terminal 110, which is used to instruct the programmable network device 120 to perform specific network service functions. This parameter information includes, but is not limited to: the name, identifier, priority, scope, and related policy rules of the network service to be enabled, modified, or deleted.
[0061] Application requirements refer to the objective demands placed on the network environment by applications running on the network, based on their own characteristics. Different applications have significantly different requirements for network service quality. For example, real-time audio and video applications (such as video conferencing and online games) typically require a network environment with high bandwidth, low latency, and low jitter; while background tasks such as data synchronization and file backup are more concerned with the reliability and integrity of transmission and are not sensitive to latency.
[0062] IP packets are the basic units of transmission in the Internet Protocol (IP) at the network layer. They are used to transmit information between different hosts and consist of two parts: the IP header and the data / payload.
[0063] In some embodiments of the present invention, the control terminal 110 can automatically identify or be manually specified by the user for network service requirements corresponding to different applications, and accordingly call the corresponding network service functions to realize the deployment of application-oriented network service functions.
[0064] In this context, network service functions refer to code modules or program units used to define and implement specific network functions in a programmable network environment.
[0065] In some embodiments of the present invention, network service functions are stored in a preset network service function library and are implemented based on custom protocol fields, including instruction types and instruction data corresponding to network service instructions.
[0066] In the network service function library, each network service function corresponds to a specific network service processing function. The network service functions in the library can be accessed and called through the library interface provided by the library, and then combined and sorted according to specific needs to obtain a sequence of network service instructions.
[0067] Specifically, based on the network service functions indicated by user configuration or application requirements, the corresponding network service functions are invoked, and a corresponding network service instruction sequence is generated according to the function definition of the network service functions. This includes: selecting and invoking the corresponding network service functions from the network service function library according to the network service functions; generating at least one network service instruction based on the function definition of the invoked network service functions; and sorting all network service instructions according to a preset execution order to obtain a network service instruction sequence.
[0068] In some embodiments of the present invention, the network service function library is deployed in the control terminal 110 and interacts with the control terminal 110 through a unified library interface.
[0069] Specifically, the network service function library is a functional module located on the control terminal 110 side. It stores and manages multiple network service functions and provides a unified calling interface, allowing applications or users to dynamically select and call the corresponding network service functions according to actual needs. Users call the required network service functions through the library interface provided by the network service function library. The library interface automatically generates the corresponding network service instruction sequence and inserts it into the IP data packet.
[0070] In other embodiments of the present invention, the system further includes a cloud server; a network service function library is deployed in the cloud server; and the control terminal 110 has a communication connection with the cloud server.
[0071] In addition, when new network services need to be developed, the corresponding network service functions only need to be written on the control terminal 110 side, and then called and integrated through the library interface of the network service functions, thereby realizing the online dynamic programmability of the system.
[0072] If the control terminal 110 fails to automatically identify or the automatic identification result indicates that the corresponding network service function is missing from the network service function library, resulting in the failure to call the network service function, the control terminal 110 is also used to generate and output a prompt message. This prompt message is used to remind the user to add the network service function corresponding to the network service function in the network service function library.
[0073] Specifically, the control terminal 110 is also used to receive new network service function code uploaded by users or external development tools; perform syntax verification, security testing, and compatibility verification with the network service function library on the new network service function, and obtain the verification result; if the verification result indicates that the verification is successful, register the new network service function to the network service function library and establish a mapping relationship with the corresponding network service function; and update the function call list and metadata index in the library interface.
[0074] like Figure 2 As shown, in some embodiments of the present invention, the custom protocol structure includes a protocol type, a number of instructions, and an instruction sequence; the instruction sequence includes an instruction type and instruction data.
[0075] The protocol type is used to mark the forwarding protocol type (such as TCP / UDP) recorded in the original type field of the IP packet, to avoid affecting the parsing of the original IP packet information after inserting a custom protocol header into the IP packet. The instruction number records the total number of network service instructions. The instruction type specifies the specific operation type of the network service instruction. The instruction data corresponds to the operation parameters of each instruction, such as the target port, priority, and action parameters.
[0076] In the process of generating a custom protocol header, firstly, the forwarding type recorded in the original type field of the IP packet is marked as the protocol type in the custom protocol structure. Then, the number of instructions, the instruction type of each network service instruction, and the instruction data are sequentially filled into the corresponding fields to obtain the custom protocol header, which is then inserted after the IP header. Finally, the value of the original protocol field in the IP header is modified to the preset custom protocol type value (e.g., 145) to indicate that the packet contains a sequence of network service instructions.
[0077] Specifically, in the control terminal 110, a custom protocol header is constructed based on the network service instruction sequence and the custom protocol structure and inserted into the IP data packet. This includes: marking the forwarding protocol type recorded in the original protocol field of the IP data packet to the protocol type field; filling the instruction quantity, instruction type and instruction data of the network service instruction sequence into the custom protocol structure in sequence to obtain the custom protocol header; and inserting the custom protocol header after the IP header in the IP data packet.
[0078] After receiving a data packet sent by the control terminal 110, the programmable network device 120 determines whether the currently received data packet is a normal data packet that needs to be forwarded directly or a data packet containing a custom protocol header based on the tag value of the protocol field in the IP data packet.
[0079] Specifically, the programmable network device 120 is used to receive IP data packets sent by the control terminal 110, parse the data packets to obtain the tag value of the type field in the IP data packets; when the tag value indicates that the current data packet belongs to a normal data packet, it is forwarded directly; when the tag value indicates that the current data packet contains a custom protocol header, the custom protocol header is parsed, network service instructions in the instruction sequence are executed and removed in sequence, and the instruction count is updated until the instruction count is 0, thus completing the execution of all network service instructions and dynamically adjusting the network services of the programmable network device.
[0080] In some embodiments of the present invention, a program written in a network programming language runs in the programmable network device 120. This program refers to a set of general programs that can be implemented on the programmable network device 120 (e.g., a programmable switch). The key is the general program control flow, which includes multiple key operations such as field updates, memory access, forwarding, and re-looping.
[0081] Here, network programming language refers to network data plane programming language, including Protocol for Packet Parsing and Processing (P4) or Behavioral Model Language (BMv2). In actual implementation, network programming language can also be a network programming and verification language based on Kleene algebra (NetKAT). This embodiment does not limit the type of network programming language.
[0082] Traditional network data processing typically includes three key modules: a protocol parser, a matching execution pipeline, and a reverse parser. Incoming data packets first enter the protocol parser, where they are parsed according to state transition diagrams defined by network programming languages such as P4, extracting and storing packet fields into predefined structures. Subsequently, they enter the matching execution pipeline, where field matching and action execution are performed sequentially to determine, modify, and control the forwarding of data packets. Finally, the reverse parser encapsulates the packets back into a standard format.
[0083] However, the current usage model of network programming languages such as P4 is an integrated "write-compile-deploy" process. All functions (such as basic forwarding, firewall, load balancing, etc.) must be integrated into a single program. Since hardware resources are statically allocated at compile time, adding any new function requires readjusting the entire program, resulting in high development costs and poor flexibility. At the same time, P4 programs are compiled and deployed as a whole, and updates require replacing the original program, which can cause service interruptions on programmable network devices, affecting business continuity and severely impacting service quality.
[0084] To address the problems of traditional technologies, a re-loop processing feature is introduced into the program control flow of the programmable network device 120. The program parses the network service instructions carried in the data packets to sequentially execute the necessary network processing. This allows for the implementation of an extended dynamic programming mechanism, supporting network service instructions of varying lengths based on a concise and general-purpose network programming language.
[0085] like Figure 3 As shown, the program control flow of the programmable network device 120 can be divided into three parts: instruction parsing, instruction processing, and branch decision-making.
[0086] In the instruction parsing process, in order to avoid parsing ordinary data packets that do not carry custom protocol headers, when the programmable network device 120 receives a data packet, it is necessary to first parse the protocol field of the IP header in the IP data packet.
[0087] If the flag value of the protocol field in the IP header indicates that the packet contains a custom protocol header (e.g., 145), proceed to the next instruction processing step; otherwise, forward normally (e.g., if the flag value is TCP or UDP).
[0088] In the instruction processing flow, a network service instruction is extracted sequentially from the instruction sequence of the custom protocol header, and the instruction type and instruction data corresponding to the network service instruction are removed from the field. At the same time, the instruction count value in the custom protocol header is decremented by 1. Then, the parsed network service instruction is executed, and it is determined whether the instruction count value in the custom protocol header is 0. If it is not 0, it means that there are still network service instructions in the instruction sequence that have not been executed, and the branch decision process is entered.
[0089] In the branch decision-making process, all network service instructions are executed sequentially through re-loop processing. After processing one network service instruction, the process re-enters the handler entry point through the re-loop port to process the next jump command, until all network service instructions in the instruction sequence are completed.
[0090] If the number of instructions is 0, it means that the execution has been completed. The value of the type field in the IP header (such as TCP or UDP) is restored, the custom protocol header is deleted, and the data packet is forwarded.
[0091] Specifically, when the number of instructions is 0, it also includes: marking the forwarding protocol type in the type field; deleting the custom protocol header and forwarding the IP packet.
[0092] In addition, in some embodiments of the present invention, the programmable network device 120 includes at least one instruction function module.
[0093] Each instruction module is responsible for handling specific types of network service instructions. For example: the encryption module handles encryption-related instructions, such as encrypting or decrypting data packets; the Quality of Service (QoS) module handles instructions related to traffic priority, such as setting the priority or bandwidth limit of data packets; and the routing module handles routing-related instructions, such as specifying the next-hop address or path of data packets.
[0094] After parsing the instruction type from the custom protocol header, the programmable network device 120 locates the corresponding instruction function module according to a predefined mapping relationship. The parsed instruction data is then passed to the selected instruction function module, which performs the corresponding operation. For example, if the instruction type is "encryption," the encryption module is selected for processing; if the instruction type is "QoS," the quality of service module is selected for processing.
[0095] Specifically, in the programmable network device 120, network service instructions in the instruction sequence are executed and removed sequentially, including: extracting a network service instruction from the instruction sequence in sequence and removing it from the instruction sequence; the extracted network service instruction includes the corresponding instruction type and instruction data; according to the preset mapping relationship between the extracted instruction type and the instruction function module, the corresponding instruction function module is queried and determined as the target instruction function module; and the extracted instruction data is sent to the target instruction function module for execution.
[0096] In summary, the online dynamic programming system for programmable network devices provided in this embodiment includes a control terminal and a programmable network device. The programmable network device runs a program written in a network programming language. The control terminal is used to call the corresponding network service function definition to generate a corresponding network service instruction sequence according to the network service function indicated by the user configuration or application requirements. A custom protocol header is constructed based on the network service instruction sequence and a custom protocol structure and inserted into the IP data packet. The type field of the IP data packet is marked with a flag value indicating whether the current data packet belongs to a normal data packet or contains a network service instruction. The custom protocol structure includes a protocol type, the number of instructions, and an instruction sequence. The instruction sequence includes an instruction type and instruction data. The programmable network device is used to receive IP data packets sent by the control terminal. When the type field of the IP data packet marks that the current data packet belongs to a normal data packet, it is forwarded directly. When the type field of the IP data packet marks that the current data packet contains a network service instruction, the custom protocol header is parsed, the network service instruction sequence is executed one by one and removed, and the programmable network device is dynamically adjusted. This technology enables network services for programmable network devices, addressing the challenge that existing programmable network technologies cannot simultaneously meet the demands of high performance and flexible online programming. By focusing on the hardware design and implementation of programmable network devices, it avoids reliance on software switches and general-purpose servers, ensuring superior performance with high throughput and low latency, fully meeting the requirements of high-performance network services. Simultaneously, the control terminal generates corresponding network service instruction sequences by calling network service functions, inserting them into IP packets and modifying the type field of the IP packets to mark them. Within the programmable network device, if the mark value in the received packet indicates that the current packet includes a custom protocol header, the instruction sequence in the custom protocol header is parsed and executed sequentially; otherwise, the packet is forwarded directly. In this way, developers only need to write or extend the corresponding network service functions on the control terminal side, without modifying the program on the programmable network device or stopping the programmable network device's services, to complete online updates and deployment of network service functions, achieving efficient and dynamic network programming.
[0097] Furthermore, programmable network devices support a re-loop processing mechanism. After each network service instruction is executed, if the data packet still contains unexecuted instructions, it is sent back to the program entry point for the next round of processing until all instructions have been executed and the data packet is forwarded. This mechanism enables the system to support network service instruction sequences of arbitrary length, thereby achieving efficient and scalable online dynamic programming capabilities.
[0098] The online dynamic programming method for programmable network devices provided in this application will be described in detail below.
[0099] like Figure 4 As shown, embodiments of this application provide an online dynamic programming method for a programmable network device. This embodiment uses this method for... Figure 1 Taking the system shown as an example, this method includes at least the following steps:
[0100] Step S401: The control terminal calls the corresponding network service function definition to generate the corresponding network service instruction sequence according to the network service function indicated by the user configuration or application requirements.
[0101] User configuration refers to the parameter information input by the user through an input module (such as a keyboard, mouse, touch screen, or remote management interface) connected to the control terminal, which is used to instruct the programmable network device to perform specific network service functions. This parameter information includes, but is not limited to: the name, identifier, priority, scope, and related policy rules of the network service to be enabled, modified, or deleted.
[0102] Application requirements refer to the objective demands placed on the network environment by applications running on the network, based on their own characteristics. Different applications have significantly different requirements for network service quality. For example, real-time audio and video applications (such as video conferencing and online games) typically require a network environment with high bandwidth, low latency, and low jitter; while background tasks such as data synchronization and file backup are more concerned with the reliability and integrity of transmission and are not sensitive to latency.
[0103] IP packets are the basic units of transmission in the Internet Protocol (IP) at the network layer. They are used to transmit information between different hosts and consist of two parts: the IP header and the data / payload.
[0104] In some embodiments of the present invention, network service functions are stored in a preset network service function library and are implemented based on custom protocol fields, including instruction types and instruction data corresponding to network service instructions.
[0105] In the network service function library, each network service function corresponds to a specific network service processing function. The network service functions in the library can be accessed and called through the library interface provided by the library, and then combined and sorted according to specific needs to obtain a sequence of network service instructions.
[0106] Specifically, based on the network service functions indicated by user configuration or application requirements, the corresponding network service functions are invoked, and a corresponding network service instruction sequence is generated according to the function definition of the network service functions. This includes: selecting and invoking the corresponding network service functions from the network service function library according to the network service functions; generating at least one network service instruction based on the function definition of the invoked network service functions; and sorting all network service instructions according to a preset execution order to obtain a network service instruction sequence.
[0107] In some embodiments of the present invention, the network service function library is deployed in the control terminal and interacts with the control terminal through a unified library interface.
[0108] Specifically, the network service function library is a functional module located on the control terminal side. It stores and manages multiple network service functions and provides a unified calling interface, allowing applications or users to dynamically select and call the corresponding network service functions according to actual needs. Users call the required network service functions through the library interface provided by the network service function library. The library interface automatically generates the corresponding network service instruction sequence and inserts it into the IP data packet.
[0109] In other embodiments of the present invention, the network service function library is deployed on a cloud server; the control terminal establishes a communication connection with the cloud server.
[0110] In addition, when new network services need to be developed, the corresponding network service functions only need to be written on the control terminal side, and then called and integrated through the library interface of the network service functions, thereby realizing the system's online dynamic programmability.
[0111] If the control terminal fails to automatically identify or the automatic identification result indicates that the corresponding network service function is missing from the network service function library, resulting in the failure to call the network service function, the control terminal 110 is also used to generate and output a prompt message. This prompt message is used to remind the user to add the network service function corresponding to the stated network service function to the network service function library.
[0112] Specifically, the control terminal is also used to receive new network service function code uploaded by users or external development tools; perform syntax verification, security checks, and compatibility verification with the network service function library on the new network service functions, and obtain verification results; if the verification result indicates that the verification is successful, register the new network service function to the network service function library and establish a mapping relationship with the corresponding network service function; and update the function call list and metadata index in the library interface.
[0113] In step S402, the control terminal constructs a custom protocol header based on the network service instruction sequence and the custom protocol structure and inserts it into the IP data packet.
[0114] like Figure 2 As shown, in some embodiments of the present invention, the custom protocol structure includes a protocol type, a number of instructions, and an instruction sequence; the instruction sequence includes an instruction type and instruction data.
[0115] The protocol type is used to mark the forwarding protocol type (such as TCP / UDP) recorded in the original type field of the IP packet, to avoid affecting the parsing of the original IP packet information after inserting a custom protocol header into the IP packet. The instruction number records the total number of network service instructions. The instruction type specifies the specific operation type of the network service instruction. The instruction data corresponds to the operation parameters of each instruction, such as the target port, priority, and action parameters.
[0116] In the process of generating a custom protocol header, firstly, the forwarding type recorded in the original type field of the IP packet is marked as the protocol type in the custom protocol structure. Then, the number of instructions, the instruction type of each network service instruction, and the instruction data are sequentially filled into the corresponding fields to obtain the custom protocol header, which is then inserted after the IP header. Finally, the value of the original protocol field in the IP header is modified to the preset custom protocol type value (e.g., 145) to indicate that the packet contains a sequence of network service instructions.
[0117] Specifically, a custom protocol header is constructed based on the network service instruction sequence and the custom protocol structure and inserted into the IP packet. This includes: marking the forwarding protocol type recorded in the original protocol field of the IP packet to the protocol type field; filling the instruction quantity, instruction type and instruction data of the network service instruction sequence into the custom protocol structure in sequence to obtain the custom protocol header; and inserting the custom protocol header after the IP header in the IP packet.
[0118] In steps S203 and S403, the control terminal marks the current data packet in the type field of the IP data packet as either a normal data packet or a packet containing a custom protocol header.
[0119] In steps S204 and S404, the control terminal sends IP data packets to the programmable network device.
[0120] In steps S205 and S405, the programmable network device responds to the received IP data packet by parsing the tag value of the type field in the IP data packet.
[0121] After receiving an IP data packet from a control terminal, a programmable network device determines whether the received data packet is a regular data packet that needs to be forwarded directly or a data packet containing a custom protocol header based on the tag value of the protocol field in the IP data packet.
[0122] In steps S206 and S406, when the flag value indicates that the IP packet contains a custom protocol header, the programmable network device parses the custom protocol header, executes and removes network service instructions in the instruction sequence in order, and updates the instruction count until the instruction count is 0, thus completing the execution of all network service instructions.
[0123] When the number of instructions is 0, it also includes: marking the forwarding protocol type to the type field; deleting the custom protocol header and forwarding the IP packet.
[0124] In some embodiments of the present invention, the programmable network device includes at least one instruction function module.
[0125] Each instruction module is responsible for handling specific types of network service instructions. For example: the encryption module handles encryption-related instructions, such as encrypting or decrypting data packets; the Quality of Service (QoS) module handles instructions related to traffic priority, such as setting the priority or bandwidth limit of data packets; and the routing module handles routing-related instructions, such as specifying the next-hop address or path of data packets.
[0126] After parsing the instruction type from the custom protocol header, the programmable network device locates the corresponding instruction function module according to a predefined mapping relationship. The parsed instruction data is then passed to the selected instruction function module, which performs the corresponding operation. For example, if the instruction type is "encryption," the encryption module is selected for processing; if the instruction type is "QoS," the quality of service module is selected for processing.
[0127] Specifically, the network service instructions in the instruction sequence are executed and removed sequentially, including: extracting a network service instruction from the instruction sequence in sequence and removing it from the instruction sequence; the extracted network service instruction includes the corresponding instruction type and instruction data; based on the preset mapping relationship between the extracted instruction type and the instruction function module, the corresponding instruction function module is queried and determined as the target instruction function module; and the extracted instruction data is sent to the target instruction function module for execution.
[0128] In summary, the online dynamic programming method for programmable network devices provided in this embodiment generates a corresponding network service instruction sequence by calling the corresponding network service function definition based on the network service function indicated by the user configuration or application requirements through the control terminal; a custom protocol header is constructed based on the network service instruction sequence and a custom protocol structure and inserted into the IP data packet, and the type field of the IP data packet is marked with a flag value indicating whether the current data packet belongs to a normal data packet or contains a network service instruction; the custom protocol structure includes a protocol type, the number of instructions, and an instruction sequence; the instruction sequence includes instruction type and instruction data; the programmable network device receives IP data packets sent by the control terminal; when the type field of the IP data packet indicates that the current data packet belongs to a normal data packet, it is forwarded directly; when the type field of the IP data packet indicates that the current data packet contains a network service instruction, the custom protocol header is parsed, the network service instruction sequence is executed one by one and removed, and the network service of the programmable network device is dynamically adjusted; this method can solve the problems of existing methods. Programmable network technology cannot simultaneously satisfy the challenges of high performance and online programming flexibility. By focusing on the hardware design and implementation of programmable network devices, reliance on software switches and general-purpose servers can be avoided, ensuring superior performance with high throughput and low latency, fully meeting the requirements of high-performance network services. Simultaneously, by calling network service functions through the control terminal, corresponding network service instruction sequences are generated and inserted into IP packets, and the type field of the IP packets is modified to mark the packets. If the programmable network device receives a packet and the marking value indicates that the current packet contains a custom protocol header, it sequentially parses and executes the instruction sequence in the custom protocol header; otherwise, the packet is forwarded directly. In this way, developers only need to write or extend the corresponding network service functions on the control terminal side, without modifying the program on the programmable network device or stopping the programmable network device's services, to complete online updates and deployments of network service functions, achieving efficient and dynamic network programming.
[0129] Furthermore, programmable network devices support a re-loop processing mechanism. After each network service instruction is executed, if the data packet still contains unexecuted instructions, it is sent back to the program entry point for the next round of processing until all instructions have been executed and the data packet is forwarded. This mechanism enables the system to support network service instruction sequences of arbitrary length, thereby achieving efficient and scalable online dynamic programming capabilities.
[0130] This application also provides an online dynamic programming system for a programmable network device, including a processor, a memory, and a computer program / instructions stored in the memory. The processor is used to execute the computer program / instructions. When the computer program / instructions are executed, the system implements the online dynamic programming method for the programmable network device described in the above method embodiments.
[0131] This application also provides a computer-readable storage medium storing a program that, when executed by a processor, is used to implement an online dynamic programming method for a programmable network device according to the above method embodiments.
[0132] Those skilled in the art will understand that the exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Whether implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention. When implemented in hardware, it can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this invention are programs or code segments used to perform the desired tasks. The programs or code segments can be stored in a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried in a carrier wave.
[0133] It should be clarified that the present invention is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of the present invention.
[0134] In this invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or in place of features of other embodiments.
[0135] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations of the embodiments of the present invention are possible. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An online dynamic programming method for a programmable network device, characterized in that, For use in a control terminal, the method includes: Based on the network service functions specified by the user configuration or application requirements, the corresponding network service function definitions are invoked to generate the corresponding network service instruction sequence; A custom protocol header is constructed based on the network service instruction sequence and the custom protocol structure and inserted into the IP packet; the custom protocol structure includes the protocol type, the number of instructions, and the instruction sequence; the instruction sequence contains the instruction type and instruction data. The type field of the IP packet indicates whether the current packet belongs to a normal packet or contains a custom protocol header. The IP data packet is sent to the programmable network device, so that when the flag value of the type field indicates that the current data packet belongs to a normal data packet, the programmable network device forwards it directly; when the flag value indicates that the current data packet contains the custom protocol header, the custom protocol header is parsed, the network service instruction sequence is executed and removed one by one, and the network service of the programmable network device is dynamically adjusted.
2. The online dynamic programming method for a programmable network device according to claim 1, characterized in that, The step of constructing a custom protocol header based on the network service instruction sequence and the custom protocol structure and inserting it into the IP packet includes: Mark the forwarding protocol type recorded in the original type field of the IP packet to the protocol type; The number of instructions, the type of instructions, and the data of the network service instruction sequence are sequentially filled into the custom protocol structure to obtain the custom protocol header; The custom protocol header is inserted after the IP header in the IP packet.
3. The online dynamic programming method for a programmable network device according to claim 1, characterized in that, The network service functions are pre-stored in a preset network service function library; The process of calling the corresponding network service function definition to generate the corresponding network service instruction sequence based on the network service function indicated by the user configuration or application requirements includes: Based on the network service function, select and call the corresponding network service function from the network service function library; Based on the function definition of the called network service function, generate at least one network service instruction; All network service instructions are sorted according to a preset execution order to obtain the network service instruction sequence.
4. The online dynamic programming method for a programmable network device according to claim 3, characterized in that, The network service function library is deployed in the control terminal and interacts with the control terminal through a unified library interface; In the event that calling a function from the network service function library fails, the method further includes: Generate and output a prompt message; the prompt message is used to prompt the user to add the network service function corresponding to the network service function in the network service function library; Upon receiving new network service function code uploaded by a user or external development tool, the new network service function is subjected to syntax verification, security testing, and compatibility verification with the network service function library to obtain the verification results. If the verification result indicates that the verification is successful, the new network service function is registered to the network service function library, and a mapping relationship with the corresponding network service function is established. Update the function call list and metadata index in the library interface.
5. An online dynamic programming method for a programmable network device, characterized in that, For use in programmable network devices, the method includes: In response to a received IP packet, a flag value for the type field in the IP packet is parsed; the flag value indicates whether the IP packet contains a custom protocol header or belongs to a regular packet; the custom protocol header includes a protocol type, a number of instructions, and an instruction sequence; the protocol type records the forwarding protocol type of the IP packet; the instruction sequence includes an instruction type and instruction data; If the flag value indicates that the IP packet contains a custom protocol header, the custom protocol header is parsed, network service instructions in the instruction sequence are executed and removed sequentially, and the instruction count is updated until the instruction count is 0, thus completing the execution of all network service instructions.
6. The online dynamic programming method for a programmable network device according to claim 5, characterized in that, When the number of instructions is 0, the method further includes: Mark the forwarding protocol type in the type field; Delete the custom protocol header and forward the IP packet.
7. The online dynamic programming method for a programmable network device according to claim 5, characterized in that, The programmable network device includes at least one instruction function module; each instruction function module is responsible for processing network service instructions of a specified type. The step of sequentially executing and removing network service instructions in the instruction sequence includes: One network service instruction is extracted sequentially from the instruction sequence and then removed from the instruction sequence; the extracted network service instruction includes the corresponding instruction type and instruction data; Based on the preset mapping relationship between the extracted instruction type and instruction function module, the corresponding instruction function module is queried and determined as the target instruction function module; The extracted instruction data is sent to the target instruction function module for execution.
8. The online dynamic programming method for a programmable network device according to claim 5, characterized in that, When the flag value indicates that the IP packet is a normal packet, the method further includes: directly forwarding the IP packet.
9. An online dynamic programming system for a programmable network device, comprising a processor, a memory, and a computer program / instructions stored in the memory, characterized in that, The processor is used to execute the computer program / instructions, and when the computer program / instructions are executed, the system implements the steps of the online dynamic programming method for a programmable network device as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, The storage medium stores a program that, when executed by a processor, is used to implement the steps of the online dynamic programming method for a programmable network device as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Method and device for encoding and decoding Internet of Things equipment protocol adaptive to micro-service architecture
CN112291235A
Protocol analysis method and system of programmable network and readable storage medium
CN114885047A