Home router data flow identification method and identification architecture based on federated learning
By extracting and marking traffic features in home routers, combined with the scheduling of federated learning and deep learning management platforms, the problem of data set tagging and resource consumption in encrypted traffic recognition is solved, and efficient traffic recognition and forwarding strategies are realized. Adapt to the needs of application updates.
Patent Information
- Application Number
- CN202210805410.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-08
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2042-07-08
AI Technical Summary
In the prior art, federated learning is difficult to automatically label data online to form data sets in the field of encrypted traffic recognition, resulting in a reduction in recognition accuracy, and the training process takes a long time and consumes a large amount of communication resources, making it difficult to actually apply to routers.
Extract domain names from the home router management platform, generate domain name configuration files, conduct federated training through deep learning management platform scheduling, generate initial data sets, and use hook functions and automated scripts to collect traffic features to reduce the number of global training nodes, and adopt federated aggregation algorithm Reduce computing and communication resource consumption.
It effectively solves the data set labeling problem, reduces the calculation amount and communication resource consumption, realizes the adaptability of real-time model updates and application updates, and improves the accuracy and efficiency of traffic recognition.
Smart Images

Figure CN115378881B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of encrypted traffic identification, and specifically but not limited to, to a home router data flow identification method and identification architecture based on federated learning. Background Art
[0002] Home wireless broadband has evolved from Wi-Fi 5 to Wi-Fi 6, and then to the future Wi-Fi 7, providing users with increasingly wider wireless data bandwidths. However, due to factors such as the complexity of home wireless network coverage, conflicts in priority of multiple concurrent services, and forwarding efficiency of routers, home wireless broadband still cannot meet the high-bandwidth and low-latency requirements of VR / AR games and online videos. Therefore, wireless routers should be able to analyze the type, classification, and specific service name of service flows based on the characteristics of data packets (flows), and then provide targeted network message forwarding strategies, giving priority to forwarding data flow messages that are sensitive to latency, and adopting a strategy of best-effort forwarding messages for data flow messages that are not sensitive to latency, thereby achieving the purpose of improving user experience.
[0003] However, training a deep learning traffic classification model requires collecting a large amount of raw data as a data set, and directly collecting data may cause privacy issues. Federated learning, as an effective solution to data privacy issues, enables joint modeling by multiple data owners while meeting user data security and government regulations, and has achieved many results in the financial and medical fields.
[0004] When applying federated learning to the field of encrypted traffic identification, the continuous upgrading of game and video services will cause the traffic characteristics to change continuously, and the pre-trained data flow identification model will have the problem of concept drift, resulting in reduced recognition accuracy. The current encrypted traffic federated learning identification method lacks the ability to automatically collect labeled data at the terminal and cannot cope with changes in data flow characteristics. At the same time, due to the large number of routers, there are too many rounds of federated learning training, and a global aggregation takes too long, consuming a lot of communication resources. Due to the above problems, federated learning is difficult to actually use for router-based encrypted traffic identification. Summary of the invention
[0005] In response to one or more problems in the prior art, the present invention proposes a home router data flow identification method and identification architecture based on federated learning, which effectively solves the problem that when federated learning is applied to the field of traffic identification, it is impossible to automatically label data online to form a data set. At the same time, the number of nodes participating in global training is reduced through node selection, which greatly reduces the amount of calculation and communication resource consumption.
[0006] The technical solution to achieve the purpose of the present invention is:
[0007] A method for identifying data flow of a home router based on federated learning, the method comprising the following steps:
[0008] Step 1: Extract the domain name of application traffic in the home router management platform and generate a domain name configuration file;
[0009] Step 2: In the home router, traffic is marked according to the domain name configuration file to generate the initial data set;
[0010] Step 3: Under the scheduling of the deep learning management platform, the home router performs federated training based on the initial model using the initial data set to generate a home router deep learning model;
[0011] Step 4: The home router management platform formulates and distributes a flow forwarding policy table based on the application type. The home router uses the home router deep learning model based on federated training to classify the collected traffic by application, and performs routing forwarding with different priorities based on the flow forwarding policy table and IP.
[0012] Furthermore, in the method for identifying home router data flow based on federated learning of the present invention, step 1 specifically includes:
[0013] Build a domain name extraction environment in a Linux-based Android emulator, install and start the application, perform application-specific operations on the application, generate traffic containing the application identification domain name, monitor the Android emulator's virtual network card and collect domain name traffic, wherein the application-specific operations refer to operations that users will perform when using the application, and the collected domain name traffic includes a request packet for asking the server for domain name resolution, and a reply packet returned by the domain name server containing the IP obtained through domain name resolution,
[0014] Use the first rrname identifier of the legal IP in the reply packet returned by the domain name server containing the IP obtained through domain name resolution as the domain name, and use all the legal IPs in the reply packet as the resolved IP array corresponding to the domain name, and write the domain name containing the resolved IP array into the same file as the domain name configuration file of the application.
[0015] Furthermore, the method for identifying home router data flow based on federated learning of the present invention automatically installs and starts the application that needs to extract the domain name in the Android simulator based on Linux by writing an automated script based on MonkeyRunner.
[0016] Furthermore, the method for identifying home router data flow based on federated learning of the present invention collects domain name traffic by writing traffic collection code to monitor the virtual network card of the Android simulator virtual machine.
[0017] Furthermore, in the method for identifying home router data flow based on federated learning of the present invention, step 2 specifically includes:
[0018] The home router obtains the domain name configuration file from the home router management platform. Before the collection, the router driver is modified and a hook function is embedded in its code. During the collection, the hook function in the driver is used to copy the data received by the network card driver to the ring buffer and then obtain the UDP data with the user datagram protocol as the carrier and the TCP data with the transmission control protocol as the carrier from the ring buffer;
[0019] Analyze the DNS reply packets in the UDP data one by one to check whether they contain a domain name consistent with the domain name configuration file. If so, generate a domain name resolution IP list for the domain name from all the legitimate IPs in the DNS reply packet and record the application name. If not, continue to analyze the next collected DNS reply packet until all acquired DNS reply packets are analyzed. A DNS reply packet refers to a reply packet returned by a domain name server that contains the IP obtained through domain name resolution. DNS refers to a domain name resolution service.
[0020] Parse UDP data and TCP data, check whether the source IP and destination IP of the IP layer in the collected UDP and TCP data packets are in the above domain name resolution IP list. If so, extract all the traffic of the source and destination IP to form an upstream / downstream bidirectional data flow, extract flow features from these data flows and add corresponding application labels to form an initial data set; if not, continue to check the next received data.
[0021] Furthermore, in the method for identifying home router data flow based on federated learning of the present invention, the method for extracting flow features from the data flow is:
[0022] Extract flow features for TCP data and UDP data: First, use the five-tuple to identify the data packet, extract the upstream / downstream data flow, and then calculate the features of the upstream / downstream data flow respectively. The proposed method has the following characteristics:
[0023] (1) The five-tuple is used as a flow tag and saved in a hash table. It also saves the timestamp of the first and last data packets of the flow. If a flow lasts for more than 120 seconds, the flow is truncated, the features are output once, and the information in the hash table is cleared. Subsequent data packets are used as new flow features. A hash table is a data structure in the form of key-value pairs that can speed up retrieval.
[0024] (2) The FIN flag of the TCP data packet is used as the end flag of the flow. After the FIN flag appears, the AI features of the flow are immediately output and the information in the hash table is cleared. The FIN flag is the Finish flag, which is a flag in the TCP protocol and means to actively disconnect the connection.
[0025] (3) In the calculation of indicators, the data packets that conform to the src IP–>dst IP direction of the TCP SYN packet are called "forward", and the reverse direction is called "reverse". For flows without TCP SYN packets, the src IP–>dst IP direction of the first data packet is called "forward", and the reverse direction is called "reverse".
[0026] (4) Each stream outputs 20 features, and the output features are converted into 8 bits according to the input requirements of the AI chip.
[0027] Furthermore, in the method for identifying home router data flow based on federated learning of the present invention, a federated aggregation algorithm is used in step 3, and only some nodes are selected to participate in each global aggregation. The specific steps include:
[0028] ① Collect the amount of data and training loss of each node used for training, and form a loss array L = [l0,l1,l2...l n ] and data array D = [D0, D1, D2...D n ], the loss array and the data amount array respectively store the final training loss of the 0th node to the nth node and the amount of data used for training;
[0029] ② The training loss and data volume are processed in a unified dimension, and the larger the value, the more positive the impact on the result, which is convenient for subsequent calculations. The training loss is processed using formula (1), and the data volume is processed using formula (2):
[0030]
[0031]
[0032] ③According to step ②, the loss value and data volume of each node are obtained to form a new loss array L′=[l′0,l′1,l′2……l′ n ], and the new data array D′=[d′0,d′1,d′2……d′ n ], and use formula (3) to calculate the evaluation value T:
[0033] T i = l′ i *d′ i ,i=1,2,…,n (3)
[0034] ④ Sort the evaluation value of each node from small to large, and get the node IDs of the first M models to participate in the aggregation of the model;
[0035] ⑤ Aggregate the selected M models using the Fed-Avg algorithm;
[0036] ⑥When the global loss value changes less than the set threshold compared with the previous round, stop model training.
[0037] A home router data flow identification architecture based on federated learning, based on any of the above-mentioned home router data flow identification methods based on federated learning, the identification architecture includes:
[0038] The smart home infrastructure layer includes several home smart devices;
[0039] At the home router node layer, during the training phase, the home router uses the domain name configuration file issued by the home router management platform to collect traffic data in real time to form an initial data set, and trains the federated model based on the initial data set under the scheduling of the deep learning management platform; during the identification phase, the home router first obtains the flow forwarding policy table (the policy table records the priority levels of different applications) through the home router management platform, and matches the flow forwarding policy table according to the flow classification results of the federated model, and preferentially forwards the traffic packets of high-priority applications to the destination IP of their data packets, and queues low-priority traffic. This ensures the QOS of the application. ;
[0040] The cloud platform layer includes a home router management platform and a deep learning management platform. The home router management platform is used to generate and send domain name configuration files and traffic forwarding policy tables to the home router node layer; the deep learning management platform is used to manage the distribution and training scheduling of the federated models of each home router, and adjust the federated models in real time.
[0041] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects:
[0042] 1. The home router data flow identification method based on federated learning of the present invention can effectively solve the problem that when federated learning is applied to the field of traffic identification, data cannot be automatically labeled online to form a data set.
[0043] 2. The home router data flow identification method based on federated learning of the present invention reduces the number of nodes participating in global training through node selection, greatly reducing the amount of calculation and communication resource consumption.
[0044] 3. The method provided by the present invention can be used to perform data labeling tasks on the terminal at any time, and the labeled data can be used to retrain the model at any time, which effectively solves the problem of application updates causing flow feature changes and thus causing model failure. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings are used to provide a further understanding of the present invention and are used together with the description to explain the embodiments of the present invention, but do not constitute a limitation of the present invention. In the accompanying drawings:
[0046] Figure 1 This is a diagram of the home router data flow identification architecture based on federated learning of the present invention.
[0047] Figure 2 It is a schematic diagram of the DNS request packet, DNS reply packet and IP resolved by the domain name involved in the present invention.
[0048] Figure 3 It is a schematic diagram of a domain name configuration file and a domain name-resolution IP list generated by the present invention.
[0049] Figure 4 It is a schematic diagram of the federated model training of the home router data flow identification method based on federated learning of the present invention.
[0050] Figure 5 It is a flow identification and forwarding schematic diagram of the home router data flow identification method based on federated learning of the present invention.
[0051] Figure 6 It is a schematic diagram of a method for constructing a ring buffer of a home router data flow identification method based on federated learning of the present invention.
[0052] Figure 7 It is a flow chart of router internal traffic identification of the method for identifying home router data flow based on federated learning of the present invention. DETAILED DESCRIPTION
[0053] In order to further understand the present invention, preferred embodiments of the present invention are described below in conjunction with examples. However, it should be understood that these descriptions are only for further illustrating the features and advantages of the present invention, rather than limiting the claims of the present invention.
[0054] The description in this section is only for several typical embodiments, and the present invention is not limited to the scope of the embodiments. The combination of different embodiments, the mutual replacement of some technical features in different embodiments, and the mutual replacement of the same or similar prior art means with some technical features in the embodiments are also within the scope of the description and protection of the present invention.
[0055] A data flow identification architecture for home routers based on federated learning, such as Figure 1 As shown, including:
[0056] The smart home infrastructure layer includes several home smart devices;
[0057] The home router node layer mainly includes HGU, i.e., home router. In the training stage, the home router uses the domain name configuration file issued by the home router management platform to collect traffic data in real time to form an initial data set, and trains the federated model based on the initial data set under the scheduling of the deep learning management platform; in the identification stage, the home router first obtains the flow forwarding policy table (the policy table records the priority levels of different applications) through the home router management platform, and matches the flow forwarding policy table according to the flow classification results of the federal model, and preferentially forwards the traffic packets of high-priority applications to the destination IP of their data packets, and queues the low-priority traffic, thereby achieving QOS guarantee for the application.
[0058] The cloud platform layer includes a home router management platform and a deep learning management platform. The home router management platform is used to generate and send domain name configuration files and traffic forwarding policy tables to the home router node layer; the deep learning management platform is used to manage the delivery and training scheduling of the federated models of each home router, and adjust the federated models in real time for continuous updating and iteration.
[0059] A method for identifying data flow of home routers based on federated learning includes two processes: federated model training and traffic identification and forwarding, wherein, Figure 2 As shown, the federated model training process includes:
[0060] Step 1: Generate domain name configuration file.
[0061] The domain name of the application traffic is extracted on the home router management platform to generate a domain name configuration file. Specifically, it includes:
[0062] A domain name extraction environment is built in an Android emulator anbox based on Linux, an application is installed and started, operations with application characteristics are performed on the application, traffic containing application identification domain name is generated, the virtual network card of the Android emulator anbox is monitored and domain name traffic is collected; wherein, the operations with application characteristics refer to operations that users will perform when using the application, and the collected domain name traffic includes a request packet for asking the server for domain name resolution, and a reply packet returned by the domain name server containing the IP obtained through domain name resolution, the first rrname identifier of a valid IP in the reply packet returned by the domain name server containing the IP obtained through domain name resolution is used as the domain name, and all valid IPs in the reply packet are used as the resolved IP array corresponding to the domain name, and the domain name containing the resolved IP array is written into the same file as the domain name configuration file of the application.
[0063] Preferably, by writing an automated script based on monkeyrunner, the application that needs to extract the domain name is automatically installed and started in the Android simulator based on Linux.
[0064] Preferably, the domain name traffic is collected by writing traffic collection code to monitor the virtual network card of the Android simulator anbox virtual machine.
[0065] The operations with application characteristics refer to operations that will be performed when using the application, such as a long video application, randomly playing movies and variety shows multiple times, with each playback lasting no less than 10 minutes; a short video application browsing no less than 10 different short videos; a shopping application, browsing different product details no less than 10 times, etc.
[0066] Step 2: Initial dataset generation.
[0067] In the home router, traffic is marked according to the domain name configuration file to generate the initial data set. Specifically, it includes:
[0068] The home router obtains the domain name configuration file from the home router management platform, such as Figure 6 As shown in the figure, before collecting, the router driver is modified and a hook function is embedded in its code. During the collection, the hook function is used to copy the data received by the network card driver to the ring buffer, and then UDP data and TCP data are obtained from the ring buffer; UDP data and TCP data are data packets with User Datagram Protocol and Transmission Control Protocol as carriers respectively.
[0069] First, analyze the DNS reply packets in the UDP data one by one to check whether they contain a domain name consistent with the domain name configuration file. If so, generate a domain name resolution IP list for the domain name using all the legitimate IPs in the DNS reply packet and record the application name. If not, continue to analyze the next collected DNS reply packet until all acquired DNS reply packets are analyzed.
[0070] Then, parse the UDP data and TCP data, and check whether the source IP and destination IP of the IP layer in the collected UDP and TCP data packets are in the above-mentioned domain name resolution IP list. If so, extract all the traffic packets of the source and destination IP to form an upstream / downstream bidirectional data stream, extract the flow features of these data streams and add corresponding application labels to form an initial data set; if not, continue to check the subsequent captured packets.
[0071] In one embodiment, the flow feature extraction method is:
[0072] Extract flow features for TCP and UDP data: First, use the five-tuple to identify the data packet (the data packet here is the data packet whose source IP, destination IP, and IP in the domain name resolution IP list in the above-collected UDP and TCP data packets match), extract the upstream / downlink data flow, and use the five-tuple as the flow tag (key) and save it in the hash table. At the same time, the timestamp of the first data packet and the timestamp of the last data packet of the flow are saved. If the duration of a flow exceeds 120 seconds, the flow is truncated, the features are output once, and the information in the hash table is cleared. The subsequent data packets are used as new flow features for calculation.
[0073] The FIN mark of the TCP data packet is used as the end mark of the flow. After the FIN mark appears, the AI features of the flow are output immediately and the information in the hash table is cleared;
[0074] In the indicator calculation, the data packets that conform to the src IP–>dst IP direction of the TCP SYN packet are called "forward", and the reverse direction is called "reverse". For flows without TCP SYN packets, the src IP–>dst IP direction of the first data packet is called "forward", and the reverse direction is called "reverse".
[0075] Each stream outputs 20 features, and the output features are converted into 8 bits (int8_t type in C language) according to the input requirements of the AI chip.
[0076] In this embodiment, the specific calculation method of the flow features of 20 features is:
[0077] (1) Total number of bytes in the forward packet header: the sum of the sizes of all forward packet headers. Let b be the number of bytes in the packet header, and the range of b is {b1, b2, b3, …, bn}, then S(b) = b1+b2+b3+ …+bn.
[0078] (2) Total number of bytes in the reverse packet header: Use the direction data packet for statistics, the method is the same as above.
[0079] (3) Number of packets sent per second: Let s represent the number of data packets in a flow, s1 is the timestamp of the first packet, and s2 is the timestamp of the last packet.
[0080] (4) Number of packets sent forward per second: The calculation method is the same as above, where s is the number of forward packets.
[0081] (5) Number of packets sent in the reverse direction per second: The calculation method is the same as above, where s is the number of packets sent in the reverse direction.
[0082] (6) Minimum flow length. The flow length is the valid bytes of each data packet. Let the valid bytes be L. A flow includes {l1, l2, l3, ..., ln}, a total of n. Then the minimum flow length is MIN(L) = min(l1, l2, l3, ..., ln).
[0083] (7) Maximum flow length: The definition of variables is the same as above, and MAX(L) = max(l1, l2, l3, ..., ln) is calculated.
[0084] (8) Average flow length: The definition of variables is the same as above.
[0085] (9) Flow length standard deviation: The definition of the variable is the same as above, and the calculation
[0086] (10) Flow length variance: The definition of the variable is the same as above, and VAR(L) = (STA(L)) is calculated 2 .
[0087] (11) Number of packets with FIN labels: The number of packets with FIN labels in the statistical flow.
[0088] (12) Number of packets with SYN labels: This counts the number of packets with SYN labels in the flow.
[0089] (13) Number of packets with RST labels: This counts the number of packets in the flow that contain RST labels.
[0090] (14) Number of packets with PSH labels: This counts the number of packets with PSH labels in the flow.
[0091] (15) Number of packets with ACK labels: This counts the number of packets with ACK labels in the flow.
[0092] (16) Number of packets with URG label: The number of packets with URG label in the statistical flow.
[0093] (17) Number of packets with CWE labels: This counts the number of packets in the flow that contain CWE labels.
[0094] (18) Number of packets with ECE labels: This counts the number of packets with ECE labels in the flow.
[0095] (19) Forward initial window number: records the window value of the first forward data packet of the flow.
[0096] (20) Backward window number: records the window value of the last reverse data packet of the flow.
[0097] Step 3: Federated model training.
[0098] Under the scheduling of the deep learning management platform, federated training is performed on the home router based on the initial model using the initial dataset.
[0099] Under the scheduling of the deep learning management platform, federated training is performed based on the initial data set continuously collected and generated in step 2. During federated training, a federated aggregation algorithm based on node model selection is adopted. Only some nodes are selected for participation in each global aggregation, which greatly reduces the amount of computing and the consumption of communication resources. The specific steps are as follows:
[0100] ① Collect the amount of data and training loss of each node used for training, and form a loss array L = [l0,l1,l2...l n ] and data array D = [D0, D1, D2...D n ], the loss array and the data amount array respectively store the final training loss of the 0th node to the nth node and the amount of data used for training.
[0101] ② The training loss and data volume are processed in a unified dimension, and the larger the value, the more positive the impact on the result, which is convenient for subsequent calculations. The training loss is processed using formula (1), and the data volume is processed using formula (2).
[0102]
[0103]
[0104] ③According to step ②, the loss value and data volume of each node are obtained to form a new loss array L′=[l′0,l′1,l′2……l′ n ], and the new data array D′=[d′0,d′1,d′2……d′ n ], and use formula (3) to calculate the evaluation value T.
[0105] T i = l′ i *d′ i ,i=1,2,…,n (3)
[0106] ④ Sort the evaluation value of each node from small to large, and obtain the node IDs of the top M models to participate in the aggregation of the models.
[0107] ⑤Use the Fed-Avg algorithm to aggregate the selected M models.
[0108] ⑥When the global loss value changes less than the set threshold compared with the previous round, stop model training.
[0109] like Figure 3 As shown, the flow identification and forwarding process includes:
[0110] Step 4: Traffic identification and forwarding.
[0111] like Figure 6 As shown, a flow forwarding strategy table is formulated according to the application type, and the flow forwarding strategy table is issued using the home router management platform.
[0112] The router uses zero-copy-based high-speed packet caching technology to replicate real-time traffic and extract features from the acquired traffic to form input features for the deep learning model.
[0113] The router uses a deep learning model based on federated training to classify the collected traffic, and performs routing forwarding with different priorities based on IP and OpenWRT according to the flow forwarding policy table.
[0114] The description and application of the present invention here are illustrative, and it is not intended to limit the scope of the present invention to the above-mentioned embodiments. The effects or advantages involved in the specification may not be reflected in the actual experimental examples due to the uncertainty of specific condition parameters or other factors, and the effects or advantages are not used to limit the scope of the invention. The deformation and change of the embodiments disclosed here are possible, and the replacement of the embodiments and the various equivalent parts are well known to those of ordinary skill in the art. It should be clear to those skilled in the art that the present invention can be implemented in other forms, structures, arrangements, proportions, and with other components, materials and parts without departing from the spirit or essential features of the present invention. Other deformations and changes can be made to the embodiments disclosed here without departing from the scope and spirit of the present invention.
Claims
1. A method for identifying home router data flow based on federated learning, characterized in that: include: Step 1: Extract the domain name of application traffic in the home router management platform and generate a domain name configuration file; Step 2: In the home router, traffic is marked according to the domain name configuration file to generate the initial data set; Specifically include: The home router obtains the domain name configuration file from the home router management platform. Before the collection, the router driver is modified and a hook function is embedded in its code. During the collection, the hook function in the driver is used to copy the data received by the network card driver to the ring buffer, and then the UDP data with the user datagram protocol as the carrier and the TCP data with the transmission control protocol as the carrier are obtained from the ring buffer. Analyze the DNS reply packets in the UDP data one by one to check whether they contain a domain name consistent with the domain name configuration file. If so, generate a domain name resolution IP list for the domain name from all the legitimate IPs in the DNS reply packet and record the application name. If not, continue to analyze the next collected DNS reply packet until all the acquired DNS reply packets are analyzed. Parse UDP data and TCP data, check whether the source IP and destination IP of the IP layer in the collected UDP and TCP data packets are in the above domain name resolution IP list. If so, extract all the traffic packets of the source and destination IP to form an upstream / downstream bidirectional data flow, extract flow features from these data flows and add corresponding application tags to form an initial data set; if not, continue to check the next received data; the flow feature extraction method is: To extract flow features for TCP and UDP data, first use the five-tuple to identify the data packet, extract the upstream / downstream data flow, and then calculate the features of the upstream / downstream data flow respectively: (1) The five-tuple is used as a flow tag and saved in a hash table. It also saves the timestamp of the first and last data packets of the flow. If a flow lasts for more than 120 seconds, the flow is truncated, the features are output once, and the information in the hash table is cleared. Subsequent data packets are used as new flow features for calculation. (2) The FIN mark of the TCP data packet is used as the end mark of the flow. After the FIN mark appears, the AI features of the flow are immediately output and the information in the hash table is cleared; (3) In the calculation of indicators, the data packets that conform to the src IP–>dst IP direction of the TCP SYN packet are called "forward", and the reverse direction is called "reverse". For flows without TCP SYN packets, the src IP–>dst IP direction of the first data packet is called "forward", and the reverse direction is called "reverse". (4) Each stream outputs 20 features, and the output features are converted into 8 bits according to the input requirements of the AI chip; Step 3: Under the scheduling of the deep learning management platform, the home router performs federated training based on the initial model using the initial data set to generate a home router deep learning model; Step 4: The home router management platform formulates and distributes a flow forwarding policy table based on the application type. The home router uses the home router deep learning model based on federated training to classify the collected traffic by application, and performs routing forwarding with different priorities based on the flow forwarding policy table and IP.
2. The method for identifying home router data flow based on federated learning according to claim 1, characterized in that: The step 1 specifically includes: A domain name extraction environment is built in a Linux-based Android emulator, an application is installed and started, and operations with application characteristics are performed on the application to generate traffic containing an application identification domain name. The virtual network card of the Android emulator is monitored and domain name traffic is collected, wherein the operations with application characteristics refer to operations that users will perform when using the application. The collected domain name traffic includes a request packet for asking the server for domain name resolution, and a reply packet returned by the domain name server containing an IP obtained through domain name resolution. The first rrname identifier of a legitimate IP in the reply packet returned by the domain name server containing an IP obtained through domain name resolution is used as the domain name, and all legitimate IPs in the reply packet are used as the resolved IP array corresponding to the domain name. The domain name containing the resolved IP array is written into the same file as the domain name configuration file of the application.
3. The method for identifying home router data flow based on federated learning according to claim 2, characterized in that: By writing an automated script based on monkeyrunner, the application that needs to extract the domain name is automatically installed and started in the Linux-based Android emulator.
4. The method for identifying home router data flow based on federated learning according to claim 2, characterized in that: By writing traffic collection code to monitor the virtual network card of the Android emulator virtual machine, domain name traffic is collected.
5. The method for identifying home router data flow based on federated learning according to claim 1, characterized in that: In step 3, a federated aggregation algorithm is used. Each time global aggregation is performed, only some nodes are selected to participate. The specific steps include: ① Collect the amount of data and training loss of each node used for training, and form a loss array L = [l0,l1,l2...l n ] and data array D = [D0, D1, D2...D n ], the loss array and the data amount array respectively store the final training loss of the 0th node to the nth node and the amount of data used for training; ② The training loss and data volume are processed in a unified dimension, and the larger the value, the more positive the impact on the result, which is convenient for subsequent calculations. The training loss is processed using formula (1), and the data volume is processed using formula (2): ③According to step ②, we get the loss value and data volume of each node and form a new loss array L ′ =[l ′ 0,l ′ 1,l ′ 2……l ′ n ], and the new data array D ′ =[d ′ 0,d ′ 1,d ′ 2……d ′ n ], and use formula (3) to calculate the evaluation value T: T i =l i ′ *d i ′ ,i=1,2,…,n (3) ④ Sort the evaluation value of each node from small to large, and get the node IDs of the first M models to participate in the aggregation of the model; ⑤ Aggregate the selected M models using the Fed-Avg algorithm; ⑥When the global loss value changes less than the set threshold compared with the previous round, stop model training.
6. A home router data flow identification architecture based on federated learning, characterized in that: Based on the method for identifying home router data flow based on federated learning according to any one of claims 1 to 5, the identification architecture includes: The smart home infrastructure layer includes several home smart devices; At the home router node layer, in the training phase, the home router uses the domain name configuration file issued by the home router management platform to collect traffic data in real time to form an initial data set, and trains the federated model based on the initial data set under the scheduling of the deep learning management platform; in the identification phase, the home router first obtains the flow forwarding policy table through the home router management platform, which records the priority levels of different applications, and then matches the flow forwarding policy table according to the flow classification results of the federated model, and preferentially forwards the traffic packets of high-priority applications to the destination IP of their data packets, and queues the traffic of low-priority applications; The cloud platform layer includes a home router management platform and a deep learning management platform. The home router management platform is used to generate and send domain name configuration files and traffic forwarding policy tables to the home router node layer; the deep learning management platform is used to manage the distribution and training scheduling of the federated models of each home router, and adjust the federated models in real time.
