Data processing method and apparatus, storage medium and electronic device
By deploying the trained data parsing model in the switch, undefined message protocol data frames are parsed and processed, which solves the problem of being unable to parse and determine policies in the existing technology, and improves the applicability and processing of data frames. efficiency.
Patent Information
- Application Number
- PCT/CN2023/104557
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-20
- Filing Date
- 2023-06-30
- Publication Date
- 2024-08-29
AI Technical Summary
Existing switches cannot parse data frames of undefined message protocols, which makes it difficult to determine processing strategies and reduces the applicability of data frames.
Deploy a data parsing model in the switch, and parse the data frames through a model trained on data frames randomly generated and transmitted by network devices, and determine processing strategies based on the parsing results to improve the processing capabilities of data frames of different message protocols.
Through the use of data parsing models, switches can quickly identify and process data frames of different message protocols, improving the applicability and processing efficiency of data frames.
Smart Images

Figure CN2023104557_29082024_PF_FP_ABST
Abstract
Description
Data processing method, device, storage medium and electronic equipment
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Chinese patent application No. 202310178066.9, filed on February 20, 2023, which is incorporated herein by reference. Technical Field
[0003] The present disclosure relates to the field of network communication technology, and in particular to a data processing method, device, storage medium, and electronic device. Background Art
[0004] During the data processing process, the data can be forwarded through the switch at the data link layer.
[0005] In the existing technology, the traditional switching chip in the switch can parse the received data frame based on the inherent message protocol. If the switching chip cannot parse the data frame, the data frame will be sent to the data processing unit, and the data frame will be parsed through the pre-defined message protocol in the data processing unit to obtain the parsing result, and the processing strategy for the data frame will be determined based on the parsing result.
[0006] However, the message protocols of the data frames that can be parsed by the data processing unit are predefined. For data frames with undefined message protocols, no parsing results can be obtained, and thus no processing strategy can be determined, which reduces the applicability of the switch in processing data frames.
[0007] Summary of the Invention
[0008] The embodiments of the present disclosure provide a data processing method, apparatus, storage medium, and electronic device to partially solve the problems existing in the above-mentioned prior art.
[0009] The embodiments of the present disclosure adopt the following technical solutions:
[0010] The present disclosure provides a data processing method, which is applied to a switch. The switch includes at least: a switching chip and a data processing unit deployed with a data parsing model. The method includes:
[0011] Receiving a data frame to be processed through the switching chip;
[0012] Sending the data frame to the data processing unit, wherein the data parsing model is trained by randomly generated data frames and data frames transmitted between network devices;
[0013] Parsing the data frame using the data parsing model to obtain a parsing result, and determining a processing strategy for the data frame based on the parsing result;
[0014] Encapsulating the identification information corresponding to the processing strategy into the data frame through the data processing unit to obtain a target data frame, and sending the target data frame to the switching chip;
[0015] The target data frame is parsed by the switching chip to obtain the processing strategy, and the target data frame is processed according to the processing strategy.
[0016] Optionally, the switch further includes: a control unit;
[0017] Before sending the data frame to the data processing unit, the method further includes:
[0018] Obtaining, by the control unit, data frames transmitted between network devices and randomly generated data frames as data samples, and determining processing tags corresponding to the data samples;
[0019] The data samples are randomly divided into two sets, the data samples in one set are used as training data, and the data samples in the other set are used as test data;
[0020] Building a data parsing model based on the training data;
[0021] Inputting the test data into a data parsing model to be trained, parsing each of the test data using the data parsing model to obtain a parsing result corresponding to the test data, and predicting a processing strategy to be optimized corresponding to the test data based on the parsing result corresponding to the test data;
[0022] The data parsing model is trained with the goal of minimizing the difference between each corresponding processing strategy to be optimized and the corresponding processing label of the test data.
[0023] Optionally, constructing a data parsing model based on the training data includes:
[0024] For each of the training data, segment the training data based on a preset byte length to obtain byte segments;
[0025] Parsing the byte segments to obtain a parsing result for each byte segment;
[0026] For each of the byte segments, construct a decision tree for the byte segment with the parsing result of the byte segment as a node, wherein the decision tree includes the parsing result of at least one data sample located in the byte segment, the processing label corresponding to each of the at least one data sample, and the cumulative amount corresponding to each of the at least one processing label;
[0027] A data parsing model is constructed based on the decision tree constructed for each byte segment.
[0028] Optionally, parsing the test data to obtain a parsing result corresponding to the test data includes:
[0029] Based on the preset byte length, the test data is segmented to obtain byte segments;
[0030] Parsing the byte segments to obtain a parsing result for each byte segment;
[0031] Based on the analysis results corresponding to the test data, the optimization strategy corresponding to the test data is predicted, including:
[0032] For each of the byte segments of the test data, matching the parsing result of the byte segment with a node in a decision tree for the byte segment, and determining a node that matches the parsing result of the byte segment as a target node; wherein the decision tree for the byte segment includes the parsing result of at least one data sample located in the byte segment, a processing label corresponding to the at least one data sample, and a cumulative amount corresponding to each of the at least one processing labels;
[0033] Using the processing label stored in the target node and the cumulative amount corresponding to the processing label as the output result of the decision tree of the byte segment;
[0034] According to the output results of the decision tree for each of the byte segments in the test data, the processing label with the largest cumulative amount is determined as the processing strategy to be optimized corresponding to the test data.
[0035] Optionally, the data parsing model is trained with the goal of minimizing the difference between each corresponding processing strategy to be optimized in the test data and the corresponding processing label, including:
[0036] Determine the difference between the processing strategy to be optimized corresponding to each test data and the corresponding processing label;
[0037] Determining, based on the differences, an accuracy rate of the data analysis model in predicting each processing strategy for the test data;
[0038] With the goal of maximizing the accuracy, the cumulative amount corresponding to each processing label in each decision tree included in the data parsing model is adjusted to train the data parsing model.
[0039] Optionally, the method further includes:
[0040] After training the data parsing model, sending a connection request to the data processing unit through the control unit, so that the data processing unit establishes a connection with the control unit based on the connection request;
[0041] After the data processing unit establishes a connection with the control unit, the trained data parsing model is sent to the data processing unit through the control unit, so that the data processing unit deploys the received data parsing model.
[0042] Optionally, the method further includes:
[0043] After the data processing unit deploys the data parsing model, returning deployment success information to the control unit through the data processing unit;
[0044] After the control unit receives the deployment success information, the control unit sends configuration information to the switching chip so that the switching chip configures the two data channels between the switching chip and the data processing unit within different virtual local area networks (VLANs) based on the received configuration information, and configures a port for forwarding data frames under each VLAN information.
[0045] Optionally, parsing the data frame to obtain a parsing result, and determining a processing strategy for the data frame based on the parsing result, includes:
[0046] Inputting the data frame into the data parsing model, so that the data parsing model divides the data frame based on a preset byte length to obtain byte segments, and parsing the byte segments to obtain parsing results corresponding to each byte segment;
[0047] For each byte segment, the parsing result of the byte segment is matched with each node in the decision tree of the byte segment, and the node that matches the parsing result of the byte segment is determined as the matching node; wherein each node in the decision tree of the byte segment stores the parsing result, the processing strategy, and the cumulative amount of the processing strategies for the byte segment, and for each node, the cumulative amount of the processing strategies stored in the node represents the number of times the processing strategy corresponding to the parsing result stored in the node appears in all training data when training the data parsing model;
[0048] Using the processing strategy stored in the matching node and the cumulative amount corresponding to the processing strategy as the output result of the decision tree of the byte segment;
[0049] According to the output results of the decision tree of each byte segment, the processing strategy with the largest cumulative amount is determined as the processing strategy of the data frame.
[0050] Optionally, the processing strategy includes: discarding, redirecting and forwarding.
[0051] Optionally, encapsulating identification information corresponding to the processing strategy into the data frame by the data processing unit to obtain a target data frame specifically includes:
[0052] If a processing strategy for the data frame is determined by the data parsing model, the data processing unit encapsulates identification information corresponding to the processing strategy into the data frame to obtain a target data frame;
[0053] If no processing strategy for the data frame is determined by the data parsing model, the data frame is discarded by the data processing unit.
[0054] Optionally, encapsulating identification information corresponding to the processing strategy into the data frame includes:
[0055] Add identification information corresponding to the processing strategy in a designated field of the data frame.
[0056] Optionally, the method further includes:
[0057] The redirected VLAN information is added to a designated field of the data frame.
[0058] Optionally, the designated field includes: a VLAN field.
[0059] Optionally, adding identification information corresponding to the processing strategy in a designated field of the data frame includes:
[0060] The identification information corresponding to the processing strategy is added to the upper four bits of the VID in the VLAN field of the data frame.
[0061] Optionally, adding redirected virtual local area network VLAN information in a designated field of the data frame specifically includes:
[0062] The redirected VLAN information is added to the lower eight bits of the VID in the VLAN field of the data frame.
[0063] Optionally, processing the target data frame according to the processing strategy specifically includes:
[0064] If the processing strategy is discard, discard the target data frame;
[0065] If the processing strategy is forwarding, the target data frame is sent to a pre-configured designated port;
[0066] If the processing strategy is redirection, the target data frame is sent to the port corresponding to the redirected VLAN information.
[0067] The present disclosure provides a data processing device, comprising:
[0068] A receiving module, used for receiving data frames to be processed through a switching chip;
[0069] a sending module, configured to send the data frame to a data processing unit deployed with a data parsing model, wherein the data parsing model is trained by randomly generated data frames and data frames transmitted between network devices;
[0070] a determination module, configured to parse the data frame using the data parsing model to obtain a parsing result, and determine a processing strategy for the data frame based on the parsing result;
[0071] an encapsulation module, configured to encapsulate the identification information corresponding to the processing strategy into the data frame through the data processing unit, obtain a target data frame, and send the target data frame to the switching chip;
[0072] The processing module is used to parse the target data frame through the switching chip to obtain the processing strategy and process the target data frame according to the processing strategy.
[0073] The present disclosure provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned data processing method is implemented.
[0074] The present disclosure provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data processing method when executing the program.
[0075] At least one of the above technical solutions adopted in the embodiments of the present disclosure can achieve the following beneficial effects:
[0076] In the disclosed embodiments, after a switch chip receives a data frame, it parses the frame using a data parsing model deployed in the data processing unit. Based on the parsing results, a processing strategy for the frame is determined, and the switch chip processes the frame in accordance with the processing strategy. Because the data parsing model is trained using randomly generated data frames and data frames transmitted between network devices, it can learn to parse data frames of different message protocols and quickly determine processing strategies for data frames of different message protocols, thereby improving the switch's applicability in processing data frames. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:
[0078] FIG1 is a flow chart of a data processing method according to an embodiment of the present disclosure;
[0079] FIG2 is a schematic diagram of the structure of a switch provided in an embodiment of the present disclosure;
[0080] FIG3 is a schematic diagram of a frame structure of a data frame provided by an embodiment of the present disclosure;
[0081] FIG4 is a schematic diagram of the corresponding relationship between the processing strategy, identification information, and data samples provided by an embodiment of the present disclosure;
[0082] FIG5 is a schematic diagram of a decision tree for a first byte segment provided by an embodiment of the present disclosure;
[0083] FIG6 is a schematic structural diagram of a data processing device provided by an embodiment of the present disclosure;
[0084] FIG7 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0085] The data processing method provided in the present disclosure aims to parse data frames of different message protocols through a data parsing model and determine processing strategies for data frames of different message protocols so that a switching chip processes the data frames according to the processing strategies.
[0086] To make the objectives, technical solutions, and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present disclosure.
[0087] The technical solutions provided by various embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0088] FIG1 is a flow chart of a data processing method provided by an embodiment of the present disclosure. The data processing method shown in FIG1 can be applied to a switch. The data processing method includes steps S100 - S108 .
[0089] S100: Receive a data frame to be processed through a switching chip in the switch.
[0090] In the disclosed embodiment, a switch comprises at least a switching chip, a control unit, and a data processing unit. The switching chip is used to forward, discard, redirect, and perform other processing on data frames. The control unit is used to train a data parsing model and send configuration information to the switching chip for establishing communication with the data processing unit. This configuration information includes at least virtual local area network (VLAN) information. The data processing unit is used to deploy the data parsing model, parse data frames based on the data parsing model, and determine a processing strategy for the data frames.
[0091] In addition, there is a first control channel between the switching chip and the control unit for transmitting configuration information, a second control channel between the control unit and the data processing unit for transmitting the data parsing model, and two data channels between the switching chip and the data processing unit for transmitting data frames, wherein one data channel is used to transmit data from the switching chip to the data processing unit, and the other data channel is used to transmit data from the data processing unit to the switching chip.
[0092] Based on the above description of the connection structure between the switching chip, the control unit and the data processing unit, an embodiment of the present disclosure provides a structural diagram of a switch, as shown in FIG2 .
[0093] It should be noted that the control unit in the switch can run the SONiC system, the switching chip can be a CTC8180 switching chip, the data processing unit can adopt the central processing unit (CPU) of the Zhaoxin COMe core board, and the data processing unit can run the Ubuntu system. When the control unit runs the SONiC system, the control unit can send control information to the switching chip through the first control channel using SONiC_CLI, REDIS-CLI, CTC_SHELL, etc., and the control information carries configuration information. The way in which the control unit and the data processing unit communicate through the second control channel includes at least: Socket communication, HTTP (Hypertext Transfer Protocol) communication, JMS (Java Message Service), WebService, etc.
[0094] In the disclosed embodiments, while a user is executing a service, a switching chip in a switch may receive data frames to be processed. The received data frames to be processed may be data frames of a traditional message protocol or data frames of a custom message protocol. A data frame of a custom message protocol refers to a data frame whose fields are user-defined.
[0095] S102: Send the data frame to a data processing unit in the switch that is equipped with a data parsing model, wherein the data parsing model is trained by randomly generated data frames and data frames transmitted between network devices.
[0096] In an embodiment of the present disclosure, after a switching chip receives a data frame to be processed, the data frame to be processed can be sent to the data processing unit via a data channel between the switching chip and the data processing unit. The data processing unit includes a data parsing model, which is trained using randomly generated data frames and data frames transmitted between various network devices. Network devices include at least switches, routers, and hosts. The data parsing model can be a support vector machine, a decision tree, a random forest model, or the like. Data frames can be randomly generated by a traffic meter.
[0097] In addition to sending the data frame to be processed directly to the data processing unit, after the switching chip receives the data frame to be processed, it can be determined whether the switching chip can parse the data frame to be processed. If the switching chip cannot parse the received data frame, the data frame to be processed can be sent to the data processing unit through the data channel between the switching chip and the data processing unit.
[0098] S104: Parsing the data frame using the data parsing model to obtain a parsing result, and determining a processing strategy for the data frame based on the parsing result.
[0099] After receiving the data frame to be processed from the switching chip, the data processing unit can parse the data frame to be processed using the data parsing model deployed in the data processing unit to obtain a parsing result. Based on the parsing result, a processing strategy corresponding to the data frame to be processed is determined. The processing strategy includes at least: discard, forward, redirect, etc.
[0100] Specifically, a data frame to be processed is input into a data parsing model. The data parsing model then segments the data frame to be processed based on a preset byte length to obtain byte segments. The byte segments are then parsed to obtain parsing results corresponding to each byte segment. Based on the parsing results for each byte segment in the data frame to be processed, a processing strategy corresponding to the data frame to be processed is determined. The preset byte length may be 2 bytes. The parsing result may be a string consisting of binary data format.
[0101] When determining the processing strategy corresponding to the data frame to be processed, the parsing result of the byte segment can be matched with the node in the decision tree of the byte segment for each byte segment of the data frame to be processed, and the node that matches the parsing result of the byte segment can be determined as the matching node. The processing strategy stored in the matching node and the cumulative amount corresponding to the processing strategy are used as the output result of the decision tree of the byte segment. Each node in the decision tree of the byte segment stores the parsing result, processing strategy and cumulative amount of processing strategy located in the byte segment. For each node, the cumulative amount of processing strategies stored in the node can represent the number of times the processing strategy corresponding to the parsing result stored in the node appears in all training data when training the data parsing model. The larger the cumulative amount of the processing strategy, the more credible the processing strategy.
[0102] According to the output result of the decision tree of each byte segment, the processing strategy with the largest cumulative amount is determined as the processing strategy corresponding to the data frame to be processed.
[0103] When matching the parsing result of the byte segment with the nodes in the decision tree for the byte segment, for each node in the decision tree for the byte segment, the parsing result of the byte segment can be compared with the parsing result stored in the node in the decision tree for the byte segment. If the parsing result stored in the node in the decision tree for the byte segment is the same as the parsing result of the byte segment, the node in the decision tree for the byte segment is selected as a candidate node. Then, based on the cumulative amount of processing strategies stored in each candidate node, the node with the largest cumulative amount of processing strategies is selected from the candidate nodes as the matching node that matches the parsing result of the byte segment.
[0104] When the processing strategy with the largest cumulative amount is determined as the processing strategy corresponding to the data frame to be processed based on the output results of the decision tree of each byte segment, the output results of the decision tree of each byte segment can be statistically analyzed to determine the comprehensive cumulative amount corresponding to each processing strategy, and the processing strategy with the largest comprehensive cumulative amount can be determined as the processing strategy corresponding to the data frame to be processed.
[0105] For example: the total bytes of the data frame are 10 bytes, and the preset byte length is 2 bytes. The data frame can be divided into 5 byte segments. For each byte segment, the byte segment is parsed to obtain the parsing result corresponding to the byte segment. If the parsing result of the first byte segment is A, the parsing result of the second byte segment is B, the parsing result of the third byte segment is C, the parsing result of the fourth byte segment is D, and the parsing result of the fifth byte segment is E. Taking the first byte segment as an example, the nodes of the decision tree for the first byte segment are determined to be: node 1, node 2, and node 3. Node 1 stores a parsing result of A, a processing strategy of discarding, and a cumulative amount of 3 times. Node 2 stores a parsing result of F, a processing strategy of forwarding, and a cumulative amount of 2 times. Node 3 stores a parsing result of A, a processing strategy of forwarding, and a cumulative amount of 5 times. The candidate nodes corresponding to the parsed result A of the first byte segment are node 1 and node 3. Since the cumulative amount of the processing strategy in node 3 is larger than that in node 1, the matching node that matches the parsed result of the first byte segment is node 3. The output result of the decision tree for the first byte segment is forwarding, and the cumulative amount of forwarding is 5 times. If the output result of the decision tree for the second byte segment is forwarding, and the cumulative amount of forwarding is 3 times, the output result of the decision tree for the third byte segment is discarding, and the cumulative amount of discarding is 2 times, the output result of the decision tree for the fourth byte segment is discarding, and the cumulative amount of discarding is 1 time, and the output result of the decision tree for the fifth byte segment is forwarding, and the cumulative amount of forwarding is 2 times, then for the forwarding processing strategy, the comprehensive cumulative amount of forwarding is 10 times, and for the discarding processing strategy, the comprehensive cumulative amount of discarding is 3 times, then it is determined that the final processing strategy corresponding to the data frame to be processed is forwarding.
[0106] It should be noted that when parsing a data frame using the data parsing model, it is not necessary to identify the specific meaning of each field in the data frame. Instead, the data frame processing strategy can be determined based on the parsed binary string. The specific meaning of each field includes at least: message type, source address, destination address, frame length, etc.
[0107] In addition, if the data parsing model in the data processing unit cannot determine the processing strategy for the data frame to be processed, the data processing unit may discard the data frame to be processed.
[0108] In addition, if the data analysis model in the data processing unit determines that the processing strategy for the data frame to be processed is discard, the data processing unit can directly discard the data frame to be processed, or return the data frame to the switching chip, which will discard the data frame.
[0109] S106: Encapsulate the identification information corresponding to the processing strategy into the data frame through the data processing unit to obtain a target data frame, and send the target data frame to the switching chip.
[0110] S108: parsing the target data frame through the switching chip to obtain the processing strategy, and processing the target data frame according to the processing strategy.
[0111] In the disclosed embodiment, after determining the processing strategy corresponding to the data frame to be processed, the data processing unit can repackage the data frame based on the determined processing strategy to obtain the repackaged data frame as the target data frame. The target data frame is then sent to the switching chip, which parses the target data frame and obtains the processing strategy for the data frame. The switching chip then processes the target data frame according to the processing strategy.
[0112] When re-encapsulating the data frame, the identification information corresponding to the processing strategy may be encapsulated into the data frame to obtain the target data frame.
[0113] Specifically, identification information corresponding to the determined processing policy can be added to a designated field of the data frame to be processed. The designated field can be a VLAN field. Furthermore, each processing policy corresponds to unique identification information, for example, a discard processing policy corresponds to identification information 0, a forward processing policy corresponds to identification information 1, and a redirect processing policy corresponds to identification information 2.
[0114] When the processing strategy is redirection, identification information corresponding to the determined processing strategy and redirection VLAN information may be added to a designated field of the data frame to be processed. The VLAN information may refer to a VLAN value.
[0115] When the designated field is a VLAN field, identification information corresponding to the determined processing strategy can be added to the upper four bits of the VID (Virtual Local Area Network Identifier) in the VLAN field of the data frame, and redirected VLAN information can be added to the lower eight bits of the VID.
[0116] The embodiment of the present disclosure provides a schematic diagram of a frame structure for a data frame, as shown in Figure 3. In Figure 3, the upper four bits of the VID in the VLAN field of the frame structure are used to indicate the processing strategy, and the lower eight bits of the VID are used to indicate the redirection VLAN information.
[0117] After the data processing unit sends the target data frame to the switching chip through the data channel, the switching chip receives the target data frame and parses the target data frame to obtain a processing strategy for the target data frame. Then, the switching chip processes the target data frame according to the parsed processing strategy.
[0118] Specifically, the switching chip parses the VID in the VLAN field of the target data frame. If the upper four bits of the VID are 0, the processing strategy is discard. If the upper four bits of the VID are 1, the processing strategy is forward. If the upper four bits of the VID are 2, the processing strategy is redirect. When the processing strategy is redirect, the information parsed from the lower eight bits of the VID is used as the VLAN information to be redirected.
[0119] Furthermore, if the processing strategy is to discard, the target data frame is discarded through the switching chip.
[0120] If the processing strategy is forwarding, the target data frame is sent to a pre-configured designated port. A designated port can be a port used to forward the target data frame to another network device. Furthermore, the designated port is pre-configured by the switch chip based on configuration information sent by the control unit to the switch chip.
[0121] If the processing strategy is redirection, the target data frame is sent to the port corresponding to the redirected VLAN information.
[0122] When the switching chip configures the port based on the configuration information, the preset port for forwarding data frames when the processing strategy is forwarding contained in the configuration information can be used as the designated port, or the port corresponding to each VLAN information contained in the configuration information can be used as the designated port for forwarding data frames when data frames are transmitted based on the VLAN information.
[0123] In the second case, if the switching chip parses the processing strategy as forwarding, it is necessary to first determine the VLAN information based on which the target data frame is transmitted between the switching chip and the data processing unit, and then use the port corresponding to the determined VLAN information as the designated port and send the target data frame to the designated port.
[0124] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0125] As can be seen from the method shown in FIG1 above, after the switching chip receives a data frame, the present disclosure parses the data frame using a data parsing model deployed in a data processing unit, and determines a processing strategy for the data frame based on the parsing results. The switching chip then processes the data frame in accordance with the processing strategy. Because the data parsing model is trained using randomly generated data frames and data frames transmitted between various network devices, the data parsing model can learn the ability to parse data frames of different message protocols, and the data parsing model can quickly determine processing strategies for data frames of different message protocols, thereby improving the applicability of the switch in processing data frames.
[0126] Furthermore, before using the data parsing model, the data parsing model needs to be trained.
[0127] Before training the data parsing model, you need to prepare the data frames for training and label each data frame.
[0128] The control unit obtains data frames transmitted between network devices and randomly generated data frames as data samples, and determines processing labels corresponding to the data samples.
[0129] Furthermore, packet capture tools can be used to capture data frames transmitted between network devices, as well as randomly generated data frames, as data samples. Packet capture tools include at least WireShark and Microsoft Network Monitor. Alternatively, a traffic meter can be used to randomly generate data frames. Specifically, the specific meaning of each field in a randomly generated data frame is random. For example, bytes 12-13 in randomly generated data frame 1 represent the message type, while bytes 12-13 in randomly generated data frame 2 represent the destination address. Traffic meter devices include at least Spirent, IXIA, and Xena network performance testers.
[0130] Furthermore, after capturing each data frame using a packet capture tool, at least some of the data frames can be filtered out based on preset filtering conditions, and the remaining data frames can be used as data samples. The preset filtering conditions include at least one of filtering out data frames whose lengths do not meet a preset length, filtering out data frames with empty mandatory fields, and filtering out duplicate data frames.
[0131] After acquiring data samples, the correspondence between the data sample and the processing strategy can be determined for each data sample, and the identification information corresponding to the processing strategy can be used as the processing label of the data sample. This is shown in Figure 4. In Figure 4, Table 1 in Figure 4 shows the correspondence between each processing strategy and identification information in a tabular storage format, and Table 2 in Figure 4 shows the mapping relationship between each data sample and the identification information of the processing strategy.
[0132] Next, the data parsing model is trained.
[0133] First, the data samples can be randomly divided into two sets, with the data samples in one set used as training data and the data samples in the other set used as test data. Among them, 80% of the data samples can be used as training data and 20% of the data samples can be used as test data.
[0134] Then, based on the training data, a data parsing model is built.
[0135] Specifically, for each iterative training, a portion of training data can be randomly selected from the set used to train the data parsing model. Then, for each piece of training data in the selected portion, the training data is segmented based on a preset byte length to obtain byte segments. The byte segments are parsed to obtain parsing results for each byte segment. Subsequently, for each byte segment, a decision tree is constructed with the parsing results of the byte segment as nodes. The decision tree includes the parsing results of at least one data sample located in the byte segment, at least one processing label corresponding to the data sample, and the cumulative amount corresponding to each of the at least one processing labels. The cumulative amount corresponding to a processing label can represent the number of times the processing label appears.
[0136] When constructing a decision tree for the byte segment, for each training data, an association relationship is established between the parsing result of the training data in the byte segment and the processing label corresponding to the training data, as the mapping relationship of the training data in the byte segment. If the mapping relationship of the training data in the byte segment matches the mapping relationship stored in the existing node in the decision tree of the byte segment, the cumulative amount of the processing label stored in the node matching the training data in the decision tree of the byte segment is increased by one. If the mapping relationship of the training data in the byte segment does not match the mapping relationship stored in the existing node in the decision tree of the byte segment, a new node is added to the decision tree of the byte segment, and the new node stores the mapping relationship of the training data in the byte segment and the cumulative amount of the processing label corresponding to the training data, and the cumulative amount of the processing label corresponding to the training data is accumulated from one. Wherein, each node in the decision tree of the byte segment stores the mapping relationship between the parsing result of the training data in the byte segment and the processing label corresponding to the training data, as well as the cumulative amount corresponding to the processing label, as shown in Figure 5.
[0137] In Figure 5, the decision tree for the first byte segment is used as an example. There are training data 1, training data 2, and training data 3. The parsing result for training data 1 in the first byte segment is a, and the processing label for training data 1 is discard. The parsing result for training data 2 in the first byte segment is a, and the processing label for training data 2 is discard. The parsing result for training data 3 in the first byte segment is b, and the processing label for training data 3 is forward. If the decision tree for the first byte segment initially has no nodes, when training data 1 is input, node A is directly constructed under the decision tree for the first byte segment. Node A stores the parsing result a, discard, and the cumulative amount of discards as 1. When training data 2 is input, since training data 2 matches node A, the cumulative amount of discards stored in node A is increased by one, that is, the cumulative amount of discards is 2. When training data 3 is input, since training data 3 does not match node A, node B is added to the decision tree. Node B stores the parsing result b, forward, and the cumulative amount of forwards as 1.
[0138] After constructing a decision tree for each byte segment, a data parsing model may be constructed based on the constructed decision tree for each byte segment, wherein the data parsing model may be a random forest model.
[0139] After building the data parsing model, each test data set is input into the data parsing model to be trained. The data parsing model parses each test data set, obtains the parsing result corresponding to the test data set, and determines the corresponding processing strategy to be optimized based on the parsing result. The data parsing model is iteratively trained with the goal of minimizing the difference between the processing strategy to be optimized and the corresponding processing label for each test data set.
[0140] When determining the processing strategy to be optimized corresponding to the test data, the test data can be segmented based on a preset byte length to obtain byte segments. The byte segments are parsed to obtain the parsing results of each byte segment. Then, for each byte segment of the test data, the parsing results of the byte segment are matched with the nodes in the decision tree of the byte segment, and the node that matches the parsing result of the byte segment is determined as the target node. Thereafter, the processing label stored in the target node and the cumulative amount corresponding to the processing label are used as the output result of the decision tree of the byte segment. Based on the output result of the decision tree for each byte segment in the test data, the processing label with the largest cumulative amount is determined as the processing strategy to be optimized corresponding to the test data.
[0141] When iteratively training the data parsing model with the goal of minimizing the difference between the processing strategy to be optimized and the corresponding processing label for each test data point, the difference between the processing strategy to be optimized and the corresponding processing label for each test data point can be first determined. Then, based on the difference between the processing strategy to be optimized and the corresponding processing label for each test data point, the accuracy of the processing strategy predicted by the data parsing model for each test data point can be determined. With the goal of maximizing the accuracy, the cumulative amount corresponding to each processing label in each decision tree included in the data parsing model is adjusted to train the data parsing model.
[0142] Among them, if the accuracy rate is greater than the preset threshold, it is determined that the data analysis model training is completed; if the preset accuracy rate is not greater than the preset threshold, the data analysis model continues to be iteratively trained.
[0143] Iteratively train the data parsing model: randomly select part of the training data from the set used to train the data parsing model, continue to build the data parsing model based on the selected part of the training data, and test the continued data parsing model.
[0144] After the data parsing model is trained, a connection request may be sent to the data processing unit via the second control channel between the control unit and the data processing unit. The data processing unit establishes a connection with the control unit based on the received connection request.
[0145] For example, when the IP address of the data processing unit is configured as "0.0.0.0" and the external service port is configured as 8001, the data processing unit can establish a connection with the control unit normally.
[0146] After the data processing unit establishes a connection with the control unit, the trained data parsing model is sent to the data processing unit through the second control channel between the control unit and the data processing unit, so that the data processing unit deploys the received data parsing model.
[0147] Since the data processing unit and the control unit can both be written in Python, the data processing unit and the control unit can reference Python's built-in json library and socket library.
[0148] Specifically, the control unit can first convert the model parameters of the data parsing model into a specified data format to obtain the converted parameters. The specified data format is JSON, and the model parameters can be stored as objects. Specifically, the model parameters can include the parsing results, processing strategies, cumulative values corresponding to the processing strategies, and the parent node corresponding to each node stored in the data parsing model.
[0149] For example, the control unit can call the json.dumps() interface to convert the model parameter para_result_dict into the JSON format para_result_json.
[0150] Then, after the data processing unit establishes a connection with the control unit, the control unit calls a specified function and sends the converted parameters to the data processing unit. The specified function may be a Socket function. Socket communication is a binary communication method based on TCP / UDP that has the advantages of fast data transmission time, high performance, and strong data security.
[0151] After receiving the converted parameters, the data processing unit can call the target function to restore the converted parameters to obtain the model parameters of the data parsing model, and deploy the data parsing model based on the model parameters. The target function can be a json function.
[0152] Since the received model parameter para_result_json is in JSON format, you need to call json.loads(para_result_json) to convert the para_result_json model parameter in JSON format to para_result_dict.
[0153] After the data processing unit deploys the data parsing model, a deployment success message is returned to the control unit via the data processing unit. After the control unit receives the deployment success message, the control unit sends configuration information to the switching chip via the control unit, so that the switching chip, based on the received configuration information, configures the two data channels between the switching chip and the data processing unit within different VLAN ranges, and configures a port for forwarding data frames under each VLAN information. The configuration information at least includes: instructing the switching chip to configure the data channel for transmitting data frames from the switching chip to the data processing unit and the port for receiving data frames to the same VLAN information; instructing the switching chip to configure the data channel for transmitting data frames from the data processing unit to the switching chip and the port for forwarding data frames to the same VLAN information; instructing the switching chip to monitor the data channel for transmitting data frames from the data processing unit to the switching chip; and instructing the switching chip to configure a port for forwarding data frames when the processing strategy is forwarding. It should be noted that the data channel for transmitting data frames from the switching chip to the data processing unit and the port for receiving data frames to the same VLAN information do not overlap with the data channel for transmitting data frames from the data processing unit to the switching chip and the port for forwarding data frames to the same VLAN information.
[0154] After receiving the configuration information, the switch chip configures pre-emphasis on the data channel between the switch chip and the data processing unit. Pre-emphasis is a signal processing method that compensates for the high-frequency components of the input signal at the transmitting end, which can improve the stability of the channel link signal.
[0155] Then, turn on the enable of the data channel to put the data channel into the open state.
[0156] Afterwards, the internal management port of the data channel through which the switching chip transmits data frames to the data processing unit can be configured within the first specified VLAN range, such as 1-100. For the internal management port of this data channel, a corresponding port for receiving data frames is configured for each VLAN information within the first specified VLAN range, and the configured port is added to the corresponding VLAN information. That is, for each VLAN information, the correspondence between the VLAN information, the port for receiving data frames, and the data channel is saved. For example: the internal management port of the data channel through which the switching chip transmits data frames to the data processing unit and port 1 for receiving data frames are configured under VLAN1, and the internal management port of the data channel through which the switching chip transmits data frames to the data processing unit and port 2 for receiving data frames are configured under VLAN2.
[0157] Similarly, the internal management port of the data channel through which the data processing unit transmits data frames to the switching chip can be configured within the second specified VLAN range, such as 101-200. The first specified VLAN range and the second specified VLAN range do not overlap. For the internal management port of this data channel, a corresponding port for forwarding data frames is configured for each VLAN information within the second specified VLAN range, and the configured port is added to the corresponding VLAN information. That is, for each VLAN information, the correspondence between the VLAN information, the port for forwarding data frames, and the data channel is saved. For example: the internal management port of the data channel through which the data processing unit transmits data frames to the switching chip and port 5 for forwarding data frames are configured under VLAN 105, and the internal management port of the data channel through which the data processing unit transmits data frames to the switching chip and port 6 for forwarding data frames are configured under VLAN 106.
[0158] In this way, when the user performs a service, the port for forwarding the data frame can be determined according to the VLAN information based on which the target data frame is transmitted between the data processing unit and the switching chip, and the target data frame can be sent to the port.
[0159] The above is the data processing method provided by the embodiment of the present disclosure. Based on the same idea, the present disclosure also provides corresponding devices, storage media and electronic devices.
[0160] FIG6 is a schematic diagram of the structure of a data processing device provided by an embodiment of the present disclosure, wherein the device includes:
[0161] The receiving module 601 is used to receive the data frame to be processed through the switching chip;
[0162] A sending module 602 is configured to send the data frame to a data processing unit deployed with a data parsing model, wherein the data parsing model is trained by randomly generated data frames and data frames transmitted between network devices;
[0163] The determination module 603 is configured to parse the data frame using the data parsing model to obtain a parsing result, and determine a processing strategy for the data frame based on the parsing result;
[0164] The encapsulation module 604 is configured to encapsulate the identification information corresponding to the processing strategy into the data frame through the data processing unit to obtain a target data frame, and send the target data frame to the switching chip;
[0165] The processing module 605 is configured to parse the target data frame through the switching chip, obtain the processing strategy, and process the target data frame according to the processing strategy.
[0166] Optionally, the apparatus further includes: a training module 606, a deployment module 607, and a configuration module 608;
[0167] Optionally, the switch further includes: a control unit;
[0168] The training module 606 is used to obtain, through the control unit, data frames transmitted between network devices and randomly generated data frames as data samples, and determine the processing labels corresponding to each of the data samples before sending the data frames to the data processing unit deployed with the data parsing model; randomly divide the data samples into two sets, with the data samples in one set serving as training data and the data samples in the other set serving as test data; construct a data parsing model based on the training data; input each test data into the data parsing model to be trained, so as to parse the test data for each test data through the data parsing model to obtain the parsing result corresponding to the test data, and predict the processing strategy to be optimized corresponding to the test data based on the parsing result corresponding to the test data; and train the data parsing model with the goal of minimizing the difference between the processing strategy to be optimized corresponding to each test data and the corresponding processing label.
[0169] Optionally, the training module 606 is specifically used to, for each training data, split the training data based on a preset byte length to obtain byte segments; parse the byte segments to obtain the parsing results of each byte segment; for each byte segment, use the parsing results of the byte segment as nodes to construct a decision tree for the byte segment, the decision tree including the parsing results of at least one data sample located in the byte segment, the processing label corresponding to the at least one data sample, and the cumulative amount corresponding to each of the at least one processing labels; and construct a data parsing model based on the constructed decision tree for each byte segment.
[0170] Optionally, the training module 606 is specifically used to, based on a preset byte length, split the test data to obtain byte segments; parse the byte segments to obtain parsing results for each byte segment; for each byte segment of the test data, match the parsing result of the byte segment with the nodes in the decision tree of the byte segment, and determine the node that matches the parsing result of the byte segment as the target node; use the processing label stored in the target node and the cumulative amount corresponding to the processing label as the output result of the decision tree of the byte segment; and based on the output result of the decision tree of each byte segment in the test data, determine the processing label with the largest cumulative amount as the processing strategy to be optimized corresponding to the test data.
[0171] Optionally, the training module 606 is specifically used to determine the difference between the processing strategy to be optimized corresponding to each test data and the corresponding processing label; based on the difference, determine the accuracy of the data analysis model in predicting the processing strategy for each test data; with the goal of maximizing the accuracy, adjust the cumulative amount corresponding to each processing label in each decision tree contained in the data analysis model to train the data analysis model.
[0172] The deployment module 607 is used to send a connection request to the data processing unit through the control unit after the data parsing model is trained, so that the data processing unit establishes a connection with the control unit based on the connection request; after the data processing unit establishes a connection with the control unit, the trained data parsing model is sent to the data processing unit through the control unit, so that the data processing unit deploys the received data parsing model.
[0173] Configuration module 608 is used to return deployment success information to the control unit through the data processing unit after the data processing unit deploys the data parsing model; after the control unit receives the deployment success information, send configuration information to the switching chip through the control unit, so that the switching chip configures the two data channels between the switching chip and the data processing unit within different virtual local area network VLAN ranges based on the received configuration information, and configures a port for forwarding data frames under each VLAN information.
[0174] Optionally, the determination module 603 is specifically used to input the data frame into the data parsing model, so as to segment the data frame based on a preset byte length through the data parsing model to obtain byte segments, parse the byte segments, and obtain parsing results corresponding to each byte segment; for each byte segment, match the parsing result of the byte segment with the nodes in the decision tree of the byte segment, and determine the node that matches the parsing result of the byte segment as the matching node; use the processing strategy stored in the matching node and the cumulative amount corresponding to the processing strategy as the output result of the decision tree of the byte segment; and according to the output result of the decision tree of each byte segment, determine the processing strategy with the largest cumulative amount as the processing strategy of the data frame.
[0175] Optionally, the processing strategy includes: discarding, redirecting and forwarding.
[0176] Optionally, the encapsulation module 604 is specifically used to, if a processing strategy for the data frame is determined through the data analysis model, encapsulate the identification information corresponding to the processing strategy into the data frame through the data processing unit to obtain a target data frame; if a processing strategy for the data frame is not determined through the data analysis model, discard the data frame through the data processing unit.
[0177] Optionally, the encapsulation module 604 is specifically configured to add identification information corresponding to the processing strategy to a designated field of the data frame.
[0178] Optionally, the encapsulation module 604 is specifically configured to add redirected VLAN information to a designated field of the data frame.
[0179] Optionally, the designated field includes: a VLAN field.
[0180] Optionally, the encapsulation module 604 is specifically configured to add identification information corresponding to the processing strategy to the upper four bits of the VID in the VLAN field of the data frame.
[0181] Optionally, the encapsulation module 604 is specifically configured to add redirected VLAN information to the lower eight bits of the VID in the VLAN field of the data frame.
[0182] Optionally, the processing module 605 is specifically used to discard the target data frame if the processing strategy is discard; send the target data frame to a pre-configured designated port if the processing strategy is forwarding; and send the target data frame to a port corresponding to the redirected VLAN information if the processing strategy is redirection.
[0183] The present disclosure also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can be used to execute the data processing method provided in FIG. 1 above.
[0184] Based on the data processing method shown in Figure 1, the present disclosure also provides a schematic diagram of the structure of an electronic device as shown in Figure 7. As shown in Figure 7, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the data processing method described in Figure 1.
[0185] Of course, in addition to software implementation, this disclosure does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0186] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0187] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
[0188] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0189] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing the present disclosure, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0190] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0191] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, 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, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0192] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0193] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0194] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0195] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0196] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The 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 technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0197] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0198] Those skilled in the art will appreciate that embodiments of the present disclosure may be provided as methods, systems, or computer program products. Thus, the present disclosure may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0199] The present disclosure may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present disclosure may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0200] The various embodiments of this disclosure are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so their description is relatively simple. For relevant portions, refer to the description of the method embodiments.
[0201] The foregoing is merely an embodiment of the present disclosure and is not intended to limit the present disclosure. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure are intended to be included within the scope of the claims of the present disclosure.
Claims
1. A data processing method, the method being applied to a switch, the switch at least include: A switching chip and a data processing unit equipped with a data parsing model, the method comprising: Receiving a data frame to be processed through the switching chip; Sending the data frame to the data processing unit, wherein the data parsing model is obtained by training the randomly generated data frames and the data frames transmitted between the network devices; Parsing the data frame through the data parsing model to obtain a parsing result, and determining a processing strategy for the data frame according to the parsing result; By means of the data processing unit, the identification information corresponding to the processing strategy is encapsulated into the data frame to obtain a target data frame, and the target data frame is sent to the switching chip; The target data frame is parsed by the switching chip to obtain the processing strategy, and the target data frame is processed according to the processing strategy.
2. The method according to claim 1, It is characterized in that The switch further comprises: a control unit; Before sending the data frame to the data processing unit, the method further includes: By means of the control unit, data frames transmitted between the network devices and randomly generated data frames are obtained as data samples, and processing tags corresponding to the data samples are determined; The data samples are randomly divided into two sets, the data samples in one set are used as training data, and the data samples in the other set are used as test data; Based on the training data, construct a data parsing model; The test data is input into the data analysis model to be trained, so that the data analysis model analyzes each of the test data to obtain the analysis result corresponding to the test data, and predicts the processing strategy to be optimized corresponding to the test data according to the analysis result corresponding to the test data; The data parsing model is trained with the goal of minimizing the difference between each corresponding processing strategy to be optimized and the corresponding processing label of the test data.
3. The method according to claim 2, It is characterized in that Based on the training data, a data parsing model is constructed, including: For each of the training data, segment the training data based on a preset byte length to obtain byte segments; Parsing the byte segments to obtain a parsing result for each of the byte segments; For each of the byte segments, a decision tree for the byte segment is constructed with the parsing result of the byte segment as a node, wherein the decision tree includes the parsing result of at least one data sample located in the byte segment, the processing label corresponding to each of the at least one data sample, and the cumulative amount corresponding to each of the at least one processing label; A data parsing model is constructed based on the decision tree constructed for each byte segment.
4. The method according to claim 2, It is characterized in that The test data is parsed to obtain the parsing results corresponding to the test data, including: Based on a preset byte length, the test data is segmented to obtain byte segments; Parsing the byte segments to obtain a parsing result for each of the byte segments; According to the analysis results corresponding to the test data, the processing strategy to be optimized corresponding to the test data is predicted, including: For each of the byte segments of the test data, the parsing result of the byte segment is matched with the nodes in the decision tree of the byte segment, and the node matching the parsing result of the byte segment is determined as the target node; wherein the decision tree of the byte segment includes the parsing result of at least one data sample located in the byte segment, the processing label corresponding to the at least one data sample, and the cumulative amount corresponding to each of the at least one processing label; The processing tag stored in the target node and the accumulated amount corresponding to the processing tag are used as the byte segment The output of the decision tree; According to the output result of the decision tree of each of the byte segments in the test data, the processing label with the largest cumulative amount is determined as the processing strategy to be optimized corresponding to the test data.
5. The method according to claim 4, It is characterized in that The data parsing model is trained with the goal of minimizing the difference between each corresponding processing strategy to be optimized and the corresponding processing label of the test data, including: Determine the difference between each corresponding processing strategy to be optimized in the test data and the corresponding processing label; Determining, based on the differences, the accuracy of the data analysis model in predicting each processing strategy of the test data; With the goal of maximizing the accuracy, the cumulative amount corresponding to each processing label in each decision tree included in the data parsing model is adjusted to train the data parsing model.
6. The method according to claim 2, It is characterized in that The method further comprises: After the data parsing model is trained, a connection request is sent to the data processing unit through the control unit, so that the data processing unit establishes a connection with the control unit based on the connection request; After the data processing unit establishes a connection with the control unit, the trained data parsing model is sent to the data processing unit through the control unit, so that the data processing unit deploys the received data parsing model.
7. The method according to claim 6, It is characterized in that The method further comprises: After the data processing unit deploys the data parsing model, returning deployment success information to the control unit through the data processing unit; After the control unit receives the deployment success information, the control unit sends configuration information to the switching chip so that the switching chip, based on the received configuration information, configures the two data channels between the switching chip and the data processing unit within different virtual local area networks (VLANs) respectively, and configures ports for forwarding data frames under each VLAN information.
8. The method according to claim 1, It is characterized in that Parsing the data frame to obtain a parsing result, and determining a processing strategy for the data frame according to the parsing result, including: Inputting the data frame into the data parsing model, so as to segment the data frame based on a preset byte length through the data parsing model to obtain byte segments, and parsing the byte segments to obtain a parsing result corresponding to each byte segment; For each byte segment, the parsing result of the byte segment is matched with each node in the decision tree of the byte segment, and the node matching the parsing result of the byte segment is determined as the matching node; wherein each node in the decision tree of the byte segment stores the parsing result, the processing strategy and the cumulative amount of the processing strategy located in the byte segment, and for each node, the cumulative amount of the processing strategy stored in the node represents the number of times the processing strategy corresponding to the parsing result stored in the node appears in all training data when training the data parsing model; Using the processing strategy stored in the matching node and the cumulative amount corresponding to the processing strategy as the output result of the decision tree of the byte segment; According to the output result of the decision tree of each byte segment, the processing strategy with the largest cumulative amount is determined as the processing strategy of the data frame.
9. The method according to claim 1, It is characterized in that The processing strategies include: discard, redirect and forward.
10. The method according to claim 1, It is characterized in that By means of the data processing unit, the identification information corresponding to the processing strategy is encapsulated into the data frame to obtain a target data frame, including: If a processing strategy for the data frame is determined by the data analysis model, the identification information corresponding to the processing strategy is encapsulated into the data frame by the data processing unit to obtain a target data frame; If the processing strategy for the data frame is not determined by the data analysis model, the data frame is discarded by the data processing unit.
11. The method according to claim 10, It is characterized in that Encapsulating identification information corresponding to the processing strategy into the data frame includes: Add identification information corresponding to the processing strategy in a designated field of the data frame.
12. The method according to claim 11, It is characterized in that The method further comprises: The redirected VLAN information is added in the designated field of the data frame.
13. The method according to claim 11 or 12, It is characterized in that The designated field includes: a VLAN field.
14. The method according to claim 13, It is characterized in that Adding identification information corresponding to the processing strategy in a specified field of the data frame includes: The identification information corresponding to the processing strategy is added to the upper four bits of the VID in the VLAN field of the data frame.
15. The method of claim 13, It is characterized in that Adding redirected VLAN information in a specified field of the data frame includes: The redirected VLAN information is added to the lower eight bits of the VID in the VLAN field of the data frame.
16. The method of claim 1, It is characterized in that Processing the target data frame according to the processing strategy includes: If the processing strategy is discard, discard the target data frame; If the processing strategy is forwarding, the target data frame is sent to a pre-configured designated port; If the processing strategy is redirection, the target data frame is sent to the port corresponding to the redirected VLAN information.
17. A data processing device, include: A receiving module, used for receiving data frames to be processed through a switching chip; A sending module, used for sending the data frame to a data processing unit deployed with a data parsing model, wherein the data parsing model is obtained by training the randomly generated data frames and the data frames transmitted between the network devices; A determination module, used to parse the data frame through the data parsing model to obtain a parsing result, and determine a processing strategy for the data frame according to the parsing result; An encapsulation module, used to encapsulate the identification information corresponding to the processing strategy into the data frame through the data processing unit, obtain a target data frame, and send the target data frame to the switching chip; The processing module is used to parse the target data frame through the switching chip to obtain the processing strategy, and process the target data frame according to the processing strategy.
18. A computer-readable storage medium storing a computer program, wherein the computer program implements the method according to any one of claims 1 to 16 when executed by a processor.
19. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the method described in any one of claims 1 to 16 is implemented.
Citation Information
Patent Citations
Method and device for sending messages
CN104601467A
Network message processing strategy generation method and system, and medium
CN111277612A
Data analysis method and device, storage medium and electronic equipment
CN112579401A
Data processing method and device, storage medium and electronic equipment
CN115842792A
Method and apparatus for forwarding heterogeneous protocol message and network switching device
US20190327345A1
Cited By
Networking equipment communication data supervision method, device, equipment and medium
CN120547206A
