Data forwarding method and device
By specifying data forwarding rules through configuration files, the data forwarding logic is decoupled from the software code, solving the problem of high development costs in traditional embedded data forwarding methods and achieving low-cost data forwarding adaptability and device stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-12
- Publication Date
- 2026-03-10
AI Technical Summary
Traditional embedded data forwarding methods require the development of different codes to implement different data forwarding functions, resulting in high software development and maintenance costs.
By specifying the data forwarding rules of the data forwarding device through the configuration file, and setting the forwarding path between the input port and the output port, the data forwarding logic and software code are decoupled. Only the configuration file needs to be adjusted to adapt to different data forwarding scenarios.
It reduced software development and maintenance costs, improved the stability and reliability of data forwarding equipment, and simplified testing workload.
Smart Images

Figure CN121644552A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of communication technology, and in particular relates to a data forwarding method and apparatus. Background Technology
[0002] With the development of data bus technology, the amount of data in bus communication is gradually increasing, and the need for data distribution across multiple buses is becoming more and more common. Typically, within a communication system, multiple data forwarding devices are deployed to meet various data distribution needs, and different data forwarding devices perform different data forwarding functions.
[0003] Traditional embedded data forwarding methods involve deploying corresponding software within the data forwarding device, embedding code related to data forwarding functions into the software, and then implementing the corresponding data forwarding functions based on this code. This approach requires developing different codebases to implement different data forwarding functions, resulting in high software development and maintenance costs. Summary of the Invention
[0004] This application provides a data forwarding method, apparatus, device, computer storage medium, and program product, which enables the data forwarding device to forward data based on a configuration file, effectively reducing software development and maintenance costs.
[0005] In a first aspect, embodiments of this application provide a data forwarding method applied to a data forwarding device, the data forwarding device including an input port and an output port, the method comprising: Obtain the configuration file corresponding to the data forwarding device. The configuration file is used to indicate the data forwarding rules of the data forwarding device. Configure the forwarding path between the input and output ports based on the configuration file; Based on the forwarding path, the input data received by the input port is output through the output port.
[0006] Secondly, embodiments of this application provide a data forwarding device applied to a data forwarding equipment. The data forwarding equipment includes an input port and an output port. The device includes: The acquisition module is used to acquire the configuration file corresponding to the data forwarding device. The configuration file is used to indicate the data forwarding rules of the data forwarding device. The configuration module is used to set the forwarding path between the input port and the output port based on the configuration file; The forwarding module is used to output the input data received from the input port through the output port based on the forwarding path.
[0007] Thirdly, embodiments of this application provide an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the data forwarding method as described in the first aspect.
[0008] Fourthly, embodiments of this application provide a computer storage medium storing computer program instructions, which, when executed by a processor, implement the data forwarding method as described in the first aspect.
[0009] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform the data forwarding method as described in the first aspect.
[0010] The data forwarding method, apparatus, device, storage medium, and program product of this application implement the data forwarding-related functions in the data forwarding device using configuration files, decoupling the data forwarding logic from the software code implementation. This allows developers or maintainers to quickly adapt to different data forwarding scenarios by simply adjusting the configuration files without modifying the underlying software program, thereby reducing software development and maintenance costs. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a flowchart illustrating the data forwarding method provided in an embodiment of this application; Figure 2 This is a logical schematic diagram of the data forwarding method provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the data forwarding device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0013] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0014] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0015] Before providing a more detailed description of the embodiments of the present invention, the data forwarding methods in the related technologies will be introduced. As mentioned above, in the related technologies, different data forwarding functions are implemented by developing different codes. This requires the development of a large amount of differentiated code for different data forwarding functions, resulting in code redundancy between different data forwarding functions, high complexity of software modification, and a large number of variables and data transfers which are not conducive to code management and problem localization. The development and maintenance costs are both high.
[0016] In view of this, and in order to solve the problems of the prior art, embodiments of this application provide a data forwarding method, apparatus, device, computer storage medium, and computer program product. The data forwarding method provided in the embodiments of this application will be described first below.
[0017] The data forwarding method provided in this application can be applied to communication scenarios, such as bus communication scenarios. The data forwarding device provided in this application can be executed by a data forwarding device. The data forwarding device includes, but is not limited to, devices such as gateways, routers, and switches. For example, in a bus communication scenario, the data forwarding device is a gateway.
[0018] See Figure 1 This is a flowchart illustrating a data forwarding method provided in an embodiment of this application. This method is applied to, for example... Figure 2 The data forwarding device shown, such as Figure 2 As shown, the data forwarding device includes at least one input port and at least one output port. Both the input and output ports are physical ports. The input port is used to receive data sent by the input device, and the output port is used to output the data received by the input port to the output device. The input and output devices are different devices, thus realizing data forwarding. It should be noted that the number of input and output ports in the data forwarding device is determined according to the actual design. Figure 2 The number of ports shown is just an example.
[0019] like Figure 1 As shown, the method includes steps S110-S130, which will be described in detail below.
[0020] S110. Obtain the configuration file corresponding to the data forwarding device. The configuration file is used to indicate the data forwarding rules of the data forwarding device.
[0021] As one implementation of this application, the configuration file is used to indicate the data forwarding rules of the data forwarding device, which defines how the data forwarding device processes and transmits data. In this embodiment, the data forwarding device implements the corresponding data forwarding function based on the corresponding configuration file.
[0022] As one implementation of this application, the configuration file can be a file independently stored in the non-volatile memory of the data forwarding device. Based on this, in step S110 above, the configuration file corresponding to the data forwarding device can be obtained from the non-volatile memory of the data forwarding device.
[0023] In other embodiments of this application, the configuration file may be an array compiled together with the program files of the data processing software. The data processing software is software embedded in the data forwarding device. When the instructions in the data processing software are executed by the data forwarding device, the data forwarding device performs the steps S110-S130 described above.
[0024] As one implementation of this application, in a communication system, multiple data forwarding devices are set up to meet various data distribution needs. Different data forwarding devices are used to implement different data forwarding functions. In view of this, multiple different configuration files can be set in advance, and the association between the configuration files and the device number can be established. Different configuration files are used to implement different data forwarding functions. Based on this, in the above step S110, the configuration file corresponding to the data forwarding device can be obtained through the following steps S111-S113.
[0025] S111. Obtain the location number of the data forwarding device.
[0026] The rack number is a number used to identify the installation location of the data forwarding equipment. Different locations correspond to different rack numbers. The data forwarding equipment can read its own rack number after power-on.
[0027] In one implementation of this application, the location number of the data forwarding device is issued to the data forwarding device by a higher-level device, such as a PLC, based on the installation location of the data forwarding device. The data forwarding device includes hardware pins for receiving the location number. Based on this, when the data forwarding device obtains its own location number, it can collect the pin signals of the hardware pins and determine the location number corresponding to the collected pin signals based on a pre-established mapping rule of "pin signal → location number". This location number is then identified as the location number of the data forwarding device.
[0028] As one implementation of this application, in order to reduce the impact of noise, the acquired pin signals are filtered, and then the station number is identified based on the filtered pin signals.
[0029] S112. Obtain the configuration file corresponding to the machine stand number from multiple preset configuration files.
[0030] After obtaining the location number of the data forwarding device, the configuration file corresponding to the current location number is obtained from multiple configuration files based on the preset correspondence between the location number and the configuration file.
[0031] S113. The configuration file corresponding to the machine position number is determined as the configuration file corresponding to the data forwarding device.
[0032] By binding configuration files to server slot numbers using the above method, configuration files can be organized by server slot number, facilitating batch deployment and version control. Furthermore, even if the installation location of the data forwarding device changes, the accurate configuration file can still be obtained, ensuring the accuracy of data forwarding.
[0033] S120. Based on the configuration file, set the forwarding path between the input port and the output port.
[0034] As one implementation of this application, the forwarding path between the input port and the output port indicates the complete path of data from the input port into the data forwarding device, through a series of processes, and finally output from the output port. The forwarding path includes information such as the connection relationship between the input port and the output port, the protocol processing inside the data forwarding device, the forwarding strategy, and the forwarding mechanism.
[0035] As one implementation of this application, before step S120, the configuration file can be verified for integrity. If the configuration file passes the integrity verification, then step S120 can be executed. This can improve the stability, security, and reliability of the data forwarding device.
[0036] As one implementation of this application, a CRC (Cyclic Redundancy Check) check code is set at the end of the configuration file, and the integrity of the configuration file is checked based on the CRC check code.
[0037] S130. Based on the forwarding path, output the input data received from the input port through the output port.
[0038] In one implementation of this application, after determining the forwarding path between the input port and the output port, in response to the input port receiving input data sent by the input device, the data forwarding device transmits and processes the input data based on the forwarding path within the data forwarding device, and finally outputs the input data to the output device through the corresponding output port, thereby completing the forwarding of the input data. Here, the input device is an external device that communicates with the input port, and the output device is an external device that communicates with the output port. Taking a bus communication scenario as an example, the data forwarding device is the gateway in the bus communication system, the input device refers to the device connected to the gateway's input port through the input bus, and the output device refers to the device connected to the gateway's input port through the output bus. The input bus and output bus can use different bus protocols.
[0039] The data forwarding method provided in this embodiment implements data forwarding-related functions in the data forwarding device using configuration files, decoupling the data forwarding logic from the software code implementation. This allows developers or maintainers to quickly adapt to different data forwarding scenarios simply by adjusting the configuration files, without modifying the underlying software program, thus reducing software development and maintenance costs. Furthermore, parameterizing the operations that the software needs to perform through configuration files reduces the workload of testing.
[0040] In some embodiments, the configuration file includes definitions of ports and message storage spaces, and the configuration file is parsed in the form of ports and message storage spaces in step S120 above.
[0041] The definitions of port, message storage space, and parameter storage space are as follows: A port is an external physical port instantiated by a data forwarding device, used for the configuration, operation, and data buffering of external ports. Physical ports include input ports and output ports.
[0042] The message storage space is used to store valid data transmitted through the port. The message storage space is divided into input storage space and output storage space. The input storage space is used to store valid data received from the input port, and to forward this data to the output storage space and / or decompose it to the parameter storage space. The output storage space is used to store valid data that needs to be sent from the output port, and its data comes from the input storage space and / or parameter storage space.
[0043] Based on the above design, in some embodiments, the configuration file includes port configuration information, the mapping relationship between spaces and ports, and the mapping relationship between spaces. Therefore, in step S120 above, steps S121-S123 are used to set the forwarding path.
[0044] S121. Configure each physical port based on the port configuration information.
[0045] As one implementation of this application, the port configuration information includes the configuration information of each physical port in the data forwarding device. This configuration information comprises relevant information used to configure the performance, rules, etc., of the physical ports. The physical ports are configured based on this port configuration information to ensure they operate according to the expected rules and performance parameters, thereby guaranteeing the accuracy, stability, and efficiency of data forwarding.
[0046] In one implementation of this application, the port configuration information includes at least two configuration pieces, each including {port number, port configuration function pointer, configuration data pointer, and space matching function pointer}. The port number is the physical port number, with different physical ports corresponding to different numbers. The port configuration function pointer is a pointer to a function used to configure the physical port. Different physical ports may have different configuration information and logic. The port configuration function pointer allows the invocation of the port configuration logic corresponding to the current port number for port configuration. The configuration data pointer is a variable pointing to the address storing the physical port configuration data. Physical port configuration may involve multiple parameters; all parameters can be encapsulated in a structure, and the structure address can be passed through the configuration data pointer, eliminating the need to pass parameters individually and reducing function call overhead. The space matching function pointer is a pointer to a space matching function, defined in this embodiment, used to determine the input storage space corresponding to the output and input. The space matching function pointer allows the invocation of the space matching function for space matching.
[0047] As one implementation of this application, when configuring a physical port, the operation handle of the physical port is initialized to establish a secure connection between the data processing software and the physical port, complete resource allocation and configuration, and lay the foundation for subsequent data interaction. The operation handle of the physical port is an identifier assigned to the physical port by the data forwarding device. The data processing software interacts with the physical port through the operation handle, such as reading and writing data, configuring parameters, and monitoring status, without directly manipulating the underlying hardware or complex memory addresses.
[0048] S122. Based on the mapping relationship between space and port, set up an input storage space for each input port and an output storage space for each output port. The input storage space is used to store the data transmitted by the input port, and the output storage space is used to store the data transmitted by the output port.
[0049] In one implementation of this application, the mapping relationship between space and port is used to indicate the message storage space corresponding to each physical port. For ease of distinction, the message storage space corresponding to the input port is called the input storage space, and the message storage space corresponding to the output port is called the output storage space. Based on this, according to the mapping relationship between space and port, the message storage space corresponding to each physical port is set respectively, thereby obtaining the input storage space corresponding to each input port and the output storage space corresponding to each output port.
[0050] As one implementation of this application, one or more corresponding message storage spaces can be configured for a single physical port. For example, such as Figure 2 As shown, input port 1 corresponds to two message storage spaces, namely input storage space 1-1 and input storage space 1-2; input port 2 corresponds to four message storage spaces, namely input storage space 2-1, input storage space 2-2, input storage space 2-3, and input storage space 2-4; input port N corresponds to one message storage space, namely input storage space N-1; output port 1 corresponds to three message storage spaces, namely output storage space 1-1, output storage space 1-2, and output storage space 1-3; output port 2 corresponds to three message storage spaces, namely output storage space 2-1, output storage space 2-2, and output storage space 2-3; and output port N corresponds to two message storage spaces, namely output storage space N-1 and output storage space N-2. Different message storage spaces are used to store different data. In a communication system, different data corresponds to different identifiers. Based on this, different identifiers can be set for different message storage spaces. Thus, the data stored in a message storage space can be determined according to its identifier. The identifier corresponding to a message storage space can be contained within a space pointer.
[0051] As one implementation of this application, when a physical port corresponds to multiple message storage spaces, different message storage spaces are used to store different data. In order to ensure that the data can be accurately stored in the corresponding message storage space, and to facilitate the management of the message storage space corresponding to the physical port, a message linked list can be set up for each physical port, and the space pointer of the message storage space corresponding to the physical port can be added to the message linked list of the physical port.
[0052] As one implementation of this application, the mapping relationship between space and port can include at least two first mapping information entries. Each first mapping information entry includes {port number, space pointer, space length}, where the space pointer indicates the starting position of the message storage space corresponding to the physical port, and the space length indicates the size of the message storage space corresponding to the physical port. Based on this, a message storage space for a physical port can be set up based on one first mapping information entry. For each physical port, when setting its corresponding message storage space, the first mapping information corresponding to it in the space-port mapping relationship can be determined. Based on the space pointer and space length in the first mapping information, the corresponding memory space can be allocated, and the allocated memory space can be initialized to obtain the message storage space corresponding to that physical port.
[0053] S123. Based on the mapping relationship between spaces, establish the connection relationship between the input storage space and the output storage space.
[0054] As one implementation of this application, the mapping relationship between spaces is used to indicate the mapping relationship between the input storage space and the output storage space. Based on this, a connection relationship between the input storage space and the output storage space is established. Data in the input storage space can be copied to the output storage space with which it has a storage connection.
[0055] As one implementation of this application, an input storage space can be connected to one or more output storage spaces, and similarly, an output storage space can be connected to one or more input storage spaces. For example, as Figure 2 As shown, input storage space 1-2 is connected to both output storage space 1-1 and output storage space 1-2, and output storage space 1-2 is connected to both input storage space 1-1 and input storage space 1-2. For each input storage space, the stored data can be copied to each output storage space connected to it. Similarly, for each output storage space, data copied from each input storage space connected to it can be stored.
[0056] As one implementation of this application, to facilitate determining the connection relationship between the input storage space and the output storage space, a message list can be set up for each output storage space. For each output storage space, the space pointers of the output storage spaces that have a connection relationship with that output storage space are added to the message list of the output storage space. For example, Figure 2As shown, both input storage space 1-1 and input storage space 1-2 are connected to output storage space 1-2. Therefore, the space pointers of input storage space 1-1 and input storage space 1-2 are added to the message chain list of output storage space 1-2.
[0057] As one implementation of this application, the mapping relationship between spaces includes one or more second mapping information entries. Each second mapping information entry includes {space x pointer, space x data start position, space m pointer, space m data start position, data length}. Here, the space x pointer refers to the space pointer of the input storage space x, the space m pointer refers to the space pointer of the output storage space m which is connected to the input storage space x, the space x data start position refers to the starting position of the data in the input storage space x that needs to be copied to the output storage space m, the space m data start position refers to the starting position of the data copied from the input storage space x in the output storage space m, and the data length refers to the length of the data copied from the input storage space x. A connection relationship between an input storage space x and an output storage space m can be established based on one second mapping information entry. Here, x and m are message storage space numbers. Different second mapping information entries have different x and / or m entries, and different connection relationships between input and output storage spaces can be established based on different second mapping information entries.
[0058] When setting the forwarding path based on the above steps S121-S123, the forwarding path includes relevant information of the message storage space corresponding to each physical port and the connection relationship between the input storage space and the output storage space, which is used to perform data forwarding in step S130.
[0059] In some embodiments, when the forwarding path is set through the above steps S121-S123, in the above step S130, the following steps S131-S134 can be performed on each input port to realize the corresponding data forwarding.
[0060] S131. When input data is received at the input port, the input data is stored in the target input storage space corresponding to the input port.
[0061] As one implementation of this application, the input data is the complete data received by the input port. When the input port receives the input data, the input data is stored in the target input storage space corresponding to the input port.
[0062] As one implementation of this application, considering that the external device may transmit data in segments to the input port, a corresponding buffer is set for each input interface. The data forwarding device traverses all input ports and stores the input received from the external device into the corresponding buffer. It traverses the buffers of all input ports and performs the above step S131 for the input port whose buffer contains complete input data, copying the input data in the buffer of the input port to the target input storage space corresponding to the input port.
[0063] As one implementation of this application, when the input port corresponds to only one input storage space, that input storage space is used as the target input storage space.
[0064] As one implementation of this application, when the input port corresponds to at least two input storage spaces, the space matching function can be called based on the space matching function pointer, and the target input storage space can be determined based on the following steps S210-S220.
[0065] S210. Determine the input storage space that matches the identifier of the input data from at least two input storage spaces corresponding to the input port.
[0066] As one implementation of this application, as described above, each physical port corresponds to a message list. The message list contains space pointers to all message storage spaces corresponding to that physical port, and each space pointer contains an identifier corresponding to the message storage space. Based on this, in step S210 above, the message list of the input port can be traversed to determine the target space pointer containing the identifier of the input data, and the input storage space corresponding to the target space pointer is determined as the input storage space matching the input data. For example, if input port 1 receives input data, the message list corresponding to input port 1 is traversed based on the identifier of the input data. The message list contains space pointers to input storage space 1-1 and input storage space 1-2. If the identifier contained in the space pointer of input storage space 1-2 is consistent with the identifier of the input data, then input storage space 1-2 is determined as the input storage space matching the input data.
[0067] S220. The input storage space that matches the identifier of the input data is determined as the target input storage space.
[0068] As one implementation of this application, the input storage space that matches the identifier of the input data is used to store the input data. In this way, the input storage space that matches the identifier of the input data is determined as the target input storage space.
[0069] S132. Determine the first target output storage space that has a connection relationship with the target input storage space.
[0070] As one implementation of this application, as described above, to facilitate the connection between input storage space and output storage space, a message list is set up for each output storage space. The message list stores space pointers of input storage spaces that are connected to the output storage space. Based on this, in step S132 above, the data forwarding device can traverse the message list of each output storage space to determine the output storage space containing the space pointer of the target input storage space in the message list. The output storage space containing the space pointer of the target input storage space in the message list is then determined as the first target output storage space connected to the target input storage space. For example, if the target input storage space is input storage space 1-1, by traversing the message lists of all output storage spaces, it is determined that the message list of output storage space 1-2 contains the space pointer of input storage space 1-1. Therefore, output storage space 1-2 is determined as the first target output storage space connected to input storage space 1-1.
[0071] S133. Copy the data in the target input storage space to the first target output storage space.
[0072] S134. Generate first output data based on the data in the first target output storage space.
[0073] As one implementation of this application, when the first target output storage space is only connected to the target input storage space, after copying the data in the target input storage space to the target output storage space, the first output data can be directly generated based on the copied data.
[0074] As one implementation of this application, if the first target output storage space is connected to at least two input storage spaces, and the at least two input storage spaces include the target input storage space, after copying the data in the target input storage space to the first target output storage space, it is determined whether the first target output storage space contains data copied from all the input storage spaces connected to it. If it contains data copied from all the input storage spaces connected to it, the first output data is generated based on all the data stored in the first target output storage space. If it does not contain data copied from all the input storage spaces connected to it, the first output data is generated based on all the data stored in the first target output storage space after all the input storage spaces connected to the first target output storage space have copied their corresponding data to the first target output storage space.
[0075] As one implementation of this application, when the first target output storage space contains data from different input storage spaces, output data is generated by concatenating the data from the different input storage spaces.
[0076] S135. Output the first output data through the output port corresponding to the first target output storage space.
[0077] As one implementation of this application, each output port is also provided with a corresponding buffer. Based on this, in the above step S135, the first output data can be stored in the buffer of the output port corresponding to the first target output storage space, and then the first output data in the buffer can be sent to the external device connected to it by the output port corresponding to the first target output storage space, thereby realizing data forwarding.
[0078] For an example, see Figure 2 Taking the forwarding of input data received by input port 1 as an example: After receiving the input data, input port 1 buffers the input data into its buffer. The data in the buffer of input port 1 is read sequentially, and the target input storage space corresponding to the data is determined based on the identifier in the data. Assuming the target input storage space corresponding to the data is input storage space 1-1, the data is copied to input storage space 1-1. The message list of all output storage spaces is traversed sequentially. The first target output storage space that is connected to input storage space 1-1 is determined as output storage space 1-2. The data in input storage space 1-1 is copied to output storage space 1-2. Output storage space 1-2 is connected to both input storage space 1-1 and input storage space 1-2. After output storage space 1-2 receives the data copied from input storage space 1-1 and input storage space 1-2 respectively, the first output data is generated based on the data stored in output storage space 1-2. The first output data is written into the buffer of output port 1 corresponding to output storage space 1-2. Output port 1 sends the data in the buffer to the external device that is connected to it. Thus, the forwarding of the input data received by input port 1 is completed.
[0079] In some embodiments, in addition to data forwarding functionality, the data forwarding device also possesses hardware-related data processing functions, such as initialization, fault detection and storage, time management, and task scheduling. To link the data forwarding function with the local data processing functions of the data forwarding device, the configuration file defines an input parameter storage space and an output parameter storage space. The input parameter storage space stores input parameters extracted from the input storage space that need to be processed in the data forwarding device. The output parameter storage space stores the data obtained after processing the input parameters through the data forwarding device. Correspondingly, the configuration file also includes a mapping relationship between spaces and parameters. Based on this, in step S120 above, when setting the forwarding path, in addition to executing steps S121-S123 above, steps S124-S125 are also executed.
[0080] S124. Based on the mapping relationship between space and parameters, determine the first storage space and the second storage space. The first storage space is the input storage space used to store the input parameters, and the second storage space is the output storage space used to store the output parameters.
[0081] As one implementation of this application, the input parameters are related to the input data received by the input interface. The input parameters may be different in different input data. The output parameters are related to the input parameters and the preset data processing logic in the data forwarding device.
[0082] As one implementation of this application, not all data received by the input interface includes input parameters that require local processing, nor do all output storage spaces store output parameters. The mapping relationship between space and parameter only includes the mapping relationship between the input storage space used to store input parameters and the corresponding input parameters, and the mapping relationship between the output storage space used to store output parameters and the corresponding output parameters. Based on this, the input storage space used to store input parameters and the output storage space used to store output parameters can be determined based on the mapping relationship between space and parameter. For ease of distinction, the input storage space used to store input parameters is referred to as the first storage space, and the output storage space used to store output parameters is referred to as the second storage space.
[0083] It should be noted that the first storage space can store other data besides input parameters, and the second storage space can store other data besides output parameters.
[0084] S125. Set the input parameter storage space for each first storage space and the output parameter storage space for each second storage space respectively.
[0085] The input parameter storage space is dedicated to storing input parameters, and the output parameter storage space is dedicated to storing output parameters.
[0086] As one implementation of this application, an input parameter storage space is used to store one input parameter, and an output parameter storage space is used to store one output parameter. A first storage space may include one or more input parameters, and a second storage space may store one or more output parameters. Therefore, a first storage space may correspond to one or more input parameter storage spaces, and a second storage space may correspond to one or more output parameter storage spaces. As an exemplary implementation of this application, see [link to relevant documentation]. Figure 2 The input storage space N-1 is the first storage space, which corresponds to an input parameter storage space N-1, and the output storage space N-2 is the second storage space, which corresponds to an output parameter storage space N-1.
[0087] As one implementation of this application, to facilitate the management of input parameters in the first storage space, a message list is set up for each first storage space, and the space pointer of the input parameter storage space corresponding to the first storage space is added to the message list. Similarly, to facilitate the management of output parameters in the second storage space, a message list is set up for each second storage space, and the space pointer of the output parameter storage space corresponding to the second storage space is added to the message list.
[0088] As one implementation of this application, the mapping relationship between space and parameters includes one or more third mapping information. Each third mapping information includes {space pointer, parameter start position, parameter pointer, data length}, where the space pointer is a pointer to the input storage space or the output storage space, the parameter start position is the starting position of the input parameter in the input storage space or the starting position of the output parameter in the output storage space, the parameter pointer is a pointer to the input parameter storage space corresponding to the input parameter or the output parameter storage space corresponding to the output parameter, and the data length is the length of the input parameter or the output parameter. Based on one third mapping information, an input parameter storage space corresponding to a first storage space or an output parameter storage space corresponding to a second storage space can be set.
[0089] When setting the forwarding path based on step S124 above, the forwarding path also includes relevant information about the input parameter storage space corresponding to each first storage space and relevant information about the output parameter storage space corresponding to each second storage space. Therefore, in step S130 above, if the target input storage space is a storage space to be processed, after step S131 above, steps S135-S139 can also be executed.
[0090] S135. Extract the input parameters from the target input storage space.
[0091] S136. Store the input parameters in the input parameter storage space corresponding to the target input storage space.
[0092] S137. Based on the preset data processing logic in the data forwarding device, the data in the input parameter storage space is processed to obtain the output parameters.
[0093] As one implementation of this application, the data processing logic in the data forwarding device is based on the local processing function settings supported by the data forwarding device, and this embodiment does not specifically limit it.
[0094] S138. Store the output parameters to the corresponding output parameter storage space.
[0095] S139. Copy the data in the output parameter storage space to the second target output storage space corresponding to the output parameter storage space.
[0096] In one implementation of this application, each second storage space corresponds to a message linked list, and the message linked list stores the space pointers of the corresponding output parameter storage space. Based on this, the message linked lists of all second storage spaces can be traversed to determine the second storage space containing the space pointer of the current output parameter storage space, and this second storage space is determined as the second target output storage space.
[0097] S1310. Generate second output data based on the data in the second target output storage space.
[0098] S1311. Output the second output data through the output port corresponding to the second target output storage space. This is one implementation of the present application, realizing communication between the data processing function and the data forwarding function in the data forwarding device.
[0099] For an example, see Figure 2Taking the forwarding of input data received at input port N as an example: After receiving input data, input port N buffers the input data into its buffer. The data in the buffer of input port N is read sequentially, and the target input storage space corresponding to the data is determined as input storage space N-1 based on the identifier in the data. The data is then copied to input storage space N-1. The message chain of all output storage spaces is traversed sequentially, and the output storage space connected to input storage space N-1 is determined as output storage space N-1. Output storage space N-1 is designated as the first target output storage space. The data in input storage space N-1 is copied to output storage space N-1. Based on the data stored in output storage space N-1, first output data is generated and written to the buffer of output port 1 corresponding to output storage space N-1. like Figure 2 As shown, input storage space N-1 is also the first storage space. Based on this, the input parameters stored in input storage space N-1 are extracted and stored in the input parameter storage space N-1 corresponding to input storage space N-1. The data stored in input parameter storage space N-1 is processed based on the preset data processing function to obtain output parameters. The output parameters are stored in the corresponding output parameter storage space N-1. The message chain of all second storage spaces is traversed to determine the output storage space corresponding to output parameter storage space N-1 as output storage space N-2. Output storage space N-2 is determined as the second target output storage space. The data in output parameter storage space N-1 is copied to output storage space N-2. The second output data is generated based on the data in output storage space N-2. The second output data is written into the buffer of output port 1 corresponding to output storage space N-2. Output port 1 sends the data in the buffer to the external device connected to it. Thus, the forwarding of the input data received by input port N is completed.
[0100] Based on the data forwarding method provided in the above embodiments, this application also provides specific implementations of a data forwarding device. Please refer to the following embodiments.
[0101] See Figure 3 This is a schematic diagram of a data forwarding device provided in an embodiment of this application. The method is applied to, for example... Figure 2 The aforementioned data forwarding device. For example... Figure 3 As shown, the device 300 includes the following modules: The acquisition module 301 is used to acquire the configuration file corresponding to the data forwarding device. The configuration file is used to indicate the data forwarding rules of the data forwarding device. The configuration module 301 is used to configure the forwarding path between the input port and the output port based on the configuration file; The forwarding module 303 is used to output the input data received by the input port through the output port based on the forwarding path.
[0102] The data forwarding device provided in this embodiment implements data forwarding-related functions using configuration files, decoupling the data forwarding logic from the software code implementation. This allows developers or maintainers to quickly adapt to different data forwarding scenarios simply by adjusting the configuration files, without modifying the underlying software program, thus reducing software development and maintenance costs. Furthermore, parameterizing the operations the software needs to perform through configuration files reduces the workload of testing.
[0103] As one implementation of this application, the configuration file includes port configuration information, the mapping relationship between space and port, and the mapping relationship between spaces; Setting module 301 includes: The port configuration unit is used to configure each physical port based on port configuration information; The first space configuration unit is used to set up an input storage space for each input port and an output storage space for each output port based on the mapping relationship between space and port. The input storage space is used to store the data transmitted by the input port, and the output storage space is used to store the data transmitted by the output port. The connection configuration unit is used to establish the connection relationship between the input storage space and the output storage space based on the mapping relationship between spaces.
[0104] As one implementation of this application, the connection relationship configuration unit is used for: Based on the mapping relationship between spaces, determine the input storage space corresponding to each output storage space; Add the space pointer of the input storage space corresponding to the output storage space to the message chain of the output storage space.
[0105] Forwarding module 303 includes: The first copying unit is used to store the input data to the target input storage space corresponding to the input port when the input port receives the input data; The first output space determination unit is used to determine the first target output storage space that has a connection relationship with the target input storage space. The second copying unit is used to copy data from the target input storage space to the first target output storage space; The first generation unit is used to generate first output data based on the data in the first target output storage space; The first output unit is used to output the first output data through the output port corresponding to the first target output storage space.
[0106] As one implementation of this application, the input port corresponds to at least two input storage spaces, and different input storage spaces correspond to different identifiers. The forwarding module 303 also includes an input space determination unit, used for: Identify the input storage space that matches the identifier of the input data among at least two input storage spaces corresponding to the input port; The input storage space that matches the identifier of the input data is determined as the target input storage space.
[0107] As one implementation of this application, the configuration file also includes a mapping relationship between space and parameters. The parameters include input parameters and output parameters. The input parameters are the data that needs to be processed in the data forwarding device, and the output parameters are the data obtained after the input parameters are processed by the data forwarding device. The setting module 302 also includes: The determining unit is used to determine a first storage space and a second storage space based on the mapping relationship between space and parameters. The first storage space is an input storage space used to store input parameters, and the second storage space is an output storage space used to store output parameters. The second space configuration unit is used to set the input parameter storage space corresponding to each first storage space and the output parameter storage space corresponding to each second storage space.
[0108] As one implementation of this application, the target input storage space is the first storage space, and the forwarding module 303 further includes: The extraction unit is used to extract the input parameters from the target input storage space after storing the input data into the target input storage space corresponding to the input port. The third copying unit is used to store the input parameters into the input parameter storage space corresponding to the target input storage space; The processing unit is used to process the data in the input parameter storage space based on the preset data processing logic in the data forwarding device to obtain the output parameters; The fourth copying unit is used to store the output parameters into the corresponding output parameter storage space; The fifth copying unit is used to copy the data in the output parameter storage space to the second target output storage space corresponding to the output parameter storage space; The second generation unit is used to generate second output data based on the data in the second target output storage space; The second output unit is used to output the second output data through the output port corresponding to the second target output storage space.
[0109] As one implementation of this application, the acquisition module 301 includes: The stand number acquisition unit is used to acquire the stand number of the data forwarding device; The matching unit is used to obtain the configuration file corresponding to the stand number from a set of multiple preset configuration files; The determination unit is used to determine the configuration file corresponding to the machine position number as the configuration file corresponding to the data forwarding device.
[0110] As one implementation of this application, the device 300 further includes: a verification module, used for: Before setting the forwarding path between the input and output ports based on the configuration file, the integrity of the configuration file is verified. Setting module 302 is used for: If the configuration file passes integrity verification, the forwarding path between the input and output ports is set based on the configuration file.
[0111] Figure 4 A schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application is shown.
[0112] An electronic device may include a processor 401 and a memory 402 storing computer program instructions.
[0113] Specifically, the processor 401 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0114] Memory 402 may include mass storage for data or instructions. For example, and not limitingly, memory 402 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 402 may include removable or non-removable (or fixed) media. Where appropriate, memory 402 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 402 is non-volatile solid-state memory.
[0115] In specific embodiments, the memory 402 can be implemented as ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 402 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 402 and executed by the processor 401. The processor 401 reads and executes the computer program instructions stored in the memory 402 to implement any of the data forwarding methods in the above embodiments.
[0116] In one example, the electronic device may also include a communication interface 403 and a bus 410. For example, Figure 4 As shown, the processor 401, memory 402, and communication interface 403 are connected through bus 410 and complete communication with each other.
[0117] The communication interface 403 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0118] Bus 410 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 410 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0119] The electronic device can execute the data forwarding method in the embodiments of this application based on the configuration file, thereby achieving a combination Figure 1 and Figure 2 Describes the data forwarding method.
[0120] Furthermore, in conjunction with the data forwarding methods described in the above embodiments, this application embodiment can provide a computer storage medium for implementation. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the data forwarding methods described in the above embodiments.
[0121] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0122] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to execute the data forwarding method as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0123] This application also provides a computer program product, including a computer program, which, when executed, implements any of the data forwarding methods described in the above embodiments.
[0124] It should be clarified that this application 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 this application 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 this application.
[0125] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they 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 application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0126] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0127] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0128] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A data forwarding method, characterized by, The method is applied to a data forwarding device, the data forwarding device comprising an input port and an output port, and the method comprises: obtaining a configuration file corresponding to the data forwarding device, the configuration file being used to indicate a data forwarding rule of the data forwarding device; based on the configuration file, setting a forwarding path between the input port and the output port; based on the forwarding path, outputting input data received by the input port through the output port.
2. The method of claim 1, wherein, The configuration file comprises port configuration information, a mapping relationship between a space and a port, and a mapping relationship between spaces. The setting of the forwarding path between the input port and the output port based on the configuration file comprises: configuring the input port and the output port based on the port configuration information; based on the mapping relationship between the space and the port, setting an input storage space corresponding to the input port and an output storage space corresponding to the output port respectively, the input storage space being used to store data transmitted by the input port, and the output storage space being used to store data transmitted by the output port; based on the mapping relationship between the spaces, establishing a connection relationship between the input storage space and the output storage space.
3. The method of claim 2, wherein, The establishing of the connection relationship between the input storage space and the output storage space based on the mapping relationship between the spaces comprises: based on the mapping relationship between the spaces, determining an input storage space corresponding to each output storage space; adding a space pointer of the input storage space corresponding to the output storage space to a message chain table of the output storage space.
4. The method according to claim 2 or 3, characterized in that, The outputting of the input data received by the input port through the output port based on the forwarding path comprises: for the input port, the following steps are performed: in a case where the input port receives input data, storing the input data to a target input storage space corresponding to the input port; determining a first target output storage space having a connection relationship with the target input storage space; copying data in the target input storage space to the first target output storage space; generating first output data based on the data in the first target output storage space; outputting the first output data through an output port corresponding to the first target output storage space.
5. The method of claim 4, wherein, The input port corresponds to at least two input storage spaces, different input storage spaces correspond to different identifiers, and before the input data is stored to a target input storage space corresponding to the input port, the method further comprises: determining an input storage space matching an identifier of the input data among the at least two input storage spaces corresponding to the input port; determining the input storage space matching the identifier of the input data as the target input storage space.
6. The method of claim 4, wherein, The configuration file further comprises a mapping relationship between a space and a parameter, the parameter comprising an input parameter and an output parameter, the input parameter being data that needs to be processed in the data forwarding device, and the output parameter being data obtained by processing the input parameter through the data forwarding device. The method further comprises: determining a first storage space and a second storage space based on the mapping relationship between the space and the parameter, the first storage space being an input storage space for storing the input parameter, and the second storage space being an output storage space for storing the output parameter; respectively setting an input parameter storage space corresponding to each of the first storage spaces and an output parameter storage space corresponding to each of the second storage spaces.
7. The method of claim 6, wherein, The target input storage space is the first storage space, and after storing the input data in the target input storage space corresponding to the input port, the method further comprises: extracting the input parameter in the target input storage space; storing the input parameter in the input parameter storage space corresponding to the target input storage space; processing the data in the input parameter storage space based on a preset data processing logic in the data forwarding device to obtain an output parameter; storing the output parameter in the corresponding output parameter storage space; copying the data in the output parameter storage space to a second target output storage space corresponding to the output parameter storage space; generating second output data based on the data in the second target output storage space; outputting the second output data through the output port corresponding to the second target output storage space.
8. The method according to any one of claims 1 to 3, characterized in that, The method further comprises: obtaining a configuration file corresponding to the data forwarding device, the configuration file being used to indicate a data forwarding rule of the data forwarding device; obtaining a location number of the data forwarding device; obtaining a configuration file corresponding to the location number from a plurality of preset configuration files; 9. The method according to any one of claims 1 to 3, characterized in that, determining the configuration file corresponding to the location number as the configuration file corresponding to the data forwarding device. Before the step of setting the forwarding path between the input port and the output port based on the configuration file, the method further comprises: performing integrity verification on the configuration file; The step of setting the forwarding path between the input port and the output port based on the configuration file comprises:
10. A data forwarding apparatus, characterized by comprising: in a case where the configuration file passes the integrity verification, setting the forwarding path between the input port and the output port based on the configuration file. The device is applied to a data forwarding device, and the data forwarding device comprises an input port and an output port, and the device comprises: an obtaining module, configured to obtain a configuration file corresponding to the data forwarding device, the configuration file being used to indicate a data forwarding rule of the data forwarding device; a setting module, configured to set a forwarding path between the input port and the output port based on the configuration file; a forwarding module, configured to output input data received by the input port through the output port based on the forwarding path.