A method for classifying encrypted traffic based on burst perception and multimodal feature fusion
By constructing hierarchical network flow samples, encoding the packet header and payload separately, extracting content features, and aggregating features within burst traffic and network flow, the problem of insufficient accuracy and generalization ability in encrypted traffic classification in existing technologies is solved, achieving more efficient encrypted traffic identification and anomaly detection.
Patent Information
- Application Number
- CN202611627257.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-21
- Publication Date
- 2026-11-17
AI Technical Summary
Existing encrypted traffic classification technologies fail to fully consider the differential feature extraction of packet headers and payloads, the relationship between packets within bursts, and the hierarchical relationship between bursts, resulting in insufficient classification accuracy and generalization ability in encrypted network environments.
By constructing hierarchical network flow samples, the packet header and payload are encoded separately, content features are extracted, and features are aggregated within burst traffic and network flow. Feature fusion is then performed by combining packet behavior information, and finally, prediction is made through a classification network.
It improves the accuracy, robustness, and generalization ability of encrypted traffic classification, and is suitable for application traffic identification and abnormal behavior analysis in complex network environments.
Smart Images

Figure CN123123039A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of network traffic classification technology, and relates to an encrypted traffic classification method based on burst perception and multimodal feature fusion. Background Technology
[0002] With the rapid development of cloud computing, mobile internet, the Internet of Things, and encryption technologies, encrypted communication protocols such as HTTPS, VPN, TLS, and DoH are widely used, and the proportion of encrypted traffic in network communication traffic continues to increase. Because encryption protocols encrypt data payloads, traditional traffic identification methods that rely on port numbers, fixed protocol fields, and plaintext content cannot directly obtain effective application semantic information, thus failing to meet the traffic identification needs in encrypted network environments. In encrypted communication scenarios, the information available for traffic identification mainly includes observable features such as packet length, packet arrival time interval, transmission direction, packet header, and encrypted payload bytes. Encrypted traffic from different applications or service types typically differs in packet composition, uplink / downlink interaction patterns, burst transmission behavior, time-series variation patterns, and session organization structures. Therefore, encrypted traffic classification not only requires extracting the content features contained in the packet header and encrypted payload but also requires comprehensive modeling of the temporal behavior features between packets, burst transmission features, and hierarchical structure features between packets, bursts, and sessions to improve the accuracy and robustness of encrypted traffic identification.
[0003] Current encrypted traffic classification technologies mostly rely on deep learning models, typically employing convolutional neural networks, recurrent neural networks, Transformer networks, or graph neural networks to extract features such as raw bytes, packet length, arrival time interval, and transmission direction, and then classify traffic through feature concatenation or attention mechanisms. However, most existing methods directly represent a network flow as a uniform byte sequence, statistical sequence, or feature matrix, failing to fully consider the differences between the header and payload within a data packet, as well as the hierarchical relationships between data packets, burst traffic, and complete network flows.
[0004] Chinese patent "CN112104570A Traffic Classification Method, Apparatus, Computer Equipment, and Storage Medium" proposes to reassemble data packets into sessions based on network flow quintuples, extracting temporal features, byte distribution features, and protocol field features of the data packets. It then uses convolutional neural networks, recurrent neural networks, and deep feature extraction networks to achieve multi-feature fusion and traffic classification. While this method can comprehensively utilize the temporal and byte distribution information of traffic, it primarily focuses on complete sessions as the basic processing object, failing to differentiate the header and payload bytes of data packets, and also not adequately modeling the local burst structure formed by consecutive data packets in the same direction.
[0005] Chinese patent "CN114818867A A Network Traffic Classification Method Based on Attention Mechanism" proposes using convolutional neural networks to extract spatial features of network traffic, long short-term memory networks to extract time-series features, and attention mechanisms to achieve multi-scale feature fusion and traffic classification. While this method can enhance key features using attention mechanisms, it primarily models spatial and temporal features for uniform traffic, failing to clearly distinguish between packet headers, payloads, relationships between packets within bursts, and hierarchical relationships between bursts. This makes it difficult to fully preserve the local content features and interactive behavior features of encrypted traffic.
[0006] In summary, while existing encrypted traffic classification technologies can achieve certain classification results using raw bytes, statistical sequences, or interaction structures, they still have shortcomings in areas such as extracting differentiated features from packet headers and payloads, identifying key packets within bursts, modeling temporal relationships between bursts, and fusing byte content features with packet-level behavioral features. Furthermore, some methods suffer from complex network structures and high feature redundancy, leading to significant computational overhead, insufficient generalization ability, and limited real-time classification performance in practical network traffic detection scenarios. Summary of the Invention
[0007] The purpose of this invention is to propose an encrypted traffic classification method based on burst perception and multimodal feature fusion to solve the problems of insufficient extraction of differential features of packet header and payload, insufficient modeling of the hierarchical relationship between packet-burst traffic-network flow, and limited ability to fuse byte content features and packet-level behavioral temporal features in the existing technology, thereby improving the accuracy, stability and generalization ability of traffic classification in complex encrypted network environments.
[0008] This invention provides a method for classifying encrypted traffic based on burst sensing and multimodal feature fusion, comprising:
[0009] Step 1: Obtain raw network traffic data and preprocess it to convert the raw network traffic data into a hierarchical structure consisting of network flow, burst traffic and data packets, and construct a structured network flow sample composed of content information and behavioral information.
[0010] Step 2: To distinguish between real data and padding data generated during the completion process, set valid data packet mask, valid burst traffic mask, and valid byte mask respectively;
[0011] Step 3: Construct a header-payload heterogeneous byte encoding module to encode and extract features from the header byte sequence and payload word sequence of data packets in the structured network flow sample, and perform feature fusion to obtain the content features of the data packets;
[0012] Step 4: Aggregate the content features of data packets within burst traffic to obtain burst-level features; perform context relationship modeling and feature aggregation on multiple burst traffic in the network flow to obtain hierarchical content features of the network flow.
[0013] Step 5: Remove padding packets from the network flow based on the packet validity mask and obtain the behavior information of the valid packets. Reconstruct the behavior information of all valid packets into a behavior sequence according to the original communication order of the valid packets in the network flow. Extract the communication behavior features of the network flow through the valid packet behavior sequence encoding module.
[0014] Step 6: Fuse the hierarchical content features and communication behavior features of the network flow to obtain the network flow content-behavior co-features, and output the predicted probabilities of each category through a classification network;
[0015] Step 7: Construct the cross-entropy loss function and use the Adam optimization algorithm to update the model parameters until the model converges.
[0016] This invention discloses an encrypted traffic classification method based on burst perception and multimodal feature fusion. Without decrypting the data payload, it can preserve local burst patterns formed by consecutive data packets traveling in the same direction. It extracts byte features from the packet header and payload, and models the importance differences of data packets within a burst and the temporal correlations between different bursts through packet-burst hierarchical feature aggregation. Simultaneously, it integrates communication behavior information such as packet length, arrival time interval, and transmission direction through effective packet behavior sequence encoding, thereby improving the accuracy, robustness, and generalization ability of encrypted traffic classification. This method is suitable for application traffic identification, malicious traffic detection, and abnormal behavior analysis in complex network environments. Attached Figure Description
[0017] Figure 1 This is a flowchart of an encrypted traffic classification method based on burst sensing and multimodal feature fusion according to the present invention;
[0018] Figure 2 This is a schematic diagram of the header heterogeneous byte encoding module of the present invention. Detailed Implementation
[0019] like Figure 1 The present invention provides an encrypted traffic classification method based on burst sensing and multimodal feature fusion, comprising:
[0020] Step 1: Obtain raw network traffic data and preprocess it, transforming the raw network traffic data into a hierarchical structure composed of network flows, burst traffic, and data packets, constructing a structured network flow sample composed of content information and behavioral information, specifically:
[0021] Step 1.1: Network Flow Reassembly and Packet Sorting. Obtain the raw PCAP network traffic data. Based on the source IP address, destination IP address, source port, destination port, and transport layer protocol, construct a five-tuple. Reassemble packets belonging to the same communication process into a network flow and sort them in ascending order according to the packet timestamps to obtain a time-ordered sequence of network flow packets.
[0022] Step 1.2: Data Packet Information Extraction and Address Anonymization. Each data packet in the reassembled network flow data packet sequence is parsed to extract the original bytes, packet length, arrival timestamp, and source IP address information. To reduce the impact of specific network address information on the classification results, the source and destination IP addresses in the data packets are anonymized, while other protocol structure information in the data packets is retained.
[0023] Step 1.3: Determining the communication direction of data packets. Using the source IP address of the first valid data packet in the network flow data packet sequence as the communication direction reference address, data packets in the network flow data packet sequence whose source IP address matches the reference address are marked as forward data packets, and data packets whose source IP address differs from the reference address are marked as reverse data packets, thereby determining the transmission direction of each data packet in the network flow.
[0024] Step 1.4: Directional Continuity-Driven Burst Flow Division. Based on the temporal order and transmission direction of data packets in the network flow data packet sequence, data packets that are temporally continuous and have the same transmission direction are divided into the same burst flow; when the transmission direction between adjacent data packets changes, the current burst flow ends and a new burst flow is established, thereby dividing a network flow into multiple burst flows with directional continuity.
[0025] Let the i-th network flow contain Data packets, and divided into A sudden surge in traffic is represented as:
[0026]
[0027] in, This represents the i-th network flow. This represents the nth data packet, where n = 1, 2, ..., N. i ; This represents the m-th burst flow, where m = 1, 2, ..., M. i .
[0028] Step 1.5: Construction of Data Packet Content and Behavior Information. For each data packet in a burst of traffic, the original bytes of the data packet are divided into a header byte sequence and a payload byte sequence to form the content information of the data packet; and the data packet length, data packet arrival time interval, and transmission direction are extracted to form the behavior information of the data packet; a structured network flow sample composed of content information and behavior information is constructed.
[0029] Step 1.6: Burst Flow Scale Control. To control the input scale of the control model, the preset burst flow quantity is [value missing]. If the actual number of bursts in the i-th network flow Greater than The earliest value is taken from each sample. A burst of traffic; if the actual number of bursts of traffic in the i-th network flow... Less than Then, fill the burst flow slots at the tail end to make the number of burst flows in the sample reach [a certain number]. .
[0030] Step 1.7: Let the original value of the m-th burst traffic retained after interception be... Data packets, when When, retain all packages; when At that time, keep the previous one One and after The data packets are placed into the first K packet slots of the burst traffic in their original time order, where K is the set packet quantity threshold.
[0031] Because only The first and last packets are selected, ensuring no duplicates. With K=3, if a burst contains more than 3 packets, the 1st, 2nd, and last packet are selected; if there are only 1 or 2 packets, they are retained in their original order, and the remaining slots are filled. The actual number of packets retained is denoted as . =min( ,K), filling the burst =0. The original packet indices corresponding to the first and last extractions are saved together.
[0032] Step 1.8: For each truly retained data packet, truncate the header byte sequence and payload byte sequence respectively. and The number of bytes is 1, and any insufficient part is padded with zeros at the end.
[0033] The header byte sequence, payload byte sequence, and behavior information of the padding data packet are all initialized to zero. The index of the padding data packet is an empty identifier. The padding data packet does not increase the actual number of data packets, nor does it change the time interval between the original data packets.
[0034] Through the above processing, the original PCAP network traffic is transformed into a hierarchical structure consisting of network flow, burst traffic and data packets, and information such as header bytes, payload bytes, data packet length, arrival time interval and transmission direction are obtained at the same time, providing a unified structured input for subsequent content feature and behavior feature extraction.
[0035] Step 2: To distinguish between real data and padding data generated during the completion process, set valid data packet mask, valid burst traffic mask, and valid byte mask respectively.
[0036] In practice, the same rules are used for the effective mask of data packets, the effective mask of burst traffic, and the effective mask of bytes: the actual reserved positions are set to 1, and the padding positions are set to 0; the mask is determined by the preprocessing process and does not need to be learned through model training.
[0037] For the k-th packet slot of the m-th burst in the i-th network flow, if the slot contains a packet that is actually reserved according to step 1.6, the effective mask of the packet is 1; if it is a padding packet, the effective mask of the packet is 0. As long as there is at least one actually reserved packet in a burst, the effective mask of the burst is 1; the effective mask of a burst consisting entirely of padding packets is 0.
[0038] For the header byte sequence and payload byte sequence, the byte validity mask corresponding to the actual reserved bytes is set to 1, and the zero padding position is set to 0; the header byte sequence and payload byte sequence of the padding data packet are both set to invalid, and the actual number of bytes is 0.
[0039] The mask is generated based on whether the data actually exists, not on whether the value is 0. Therefore, bytes with a real value of 0 or those set to zero due to address anonymization are still valid bytes. For data packets that are actually captured but have an empty payload, their data packet mask is still 1. In subsequent step 3, the payload byte encoding branch has a real byte count of 0 and a byte mask of all 0, while the header byte encoding branch still participates in feature extraction normally.
[0040] In the subsequent attention aggregation, the corresponding network first calculates the importance score of each position based on the input features, and then only performs Softmax normalization on the positions with a mask of 1 to obtain the attention weights; the weights of the positions with a mask of 0 are directly set to 0 and do not participate in the normalization calculation and weighted aggregation.
[0041] When valid positions exist, the sum of the attention weights at these positions is 1. If the mask for the entire sequence is 0, Softmax is not performed; instead, the attention weights and aggregation results are set to zero to avoid invalid computation. For example, when the mask for a burst packet is [1,1,0], only the first two packets participate in the weight calculation, and the weight of the third padding packet is always 0.
[0042] Step 3: Construct a header-payload heterogeneous byte encoding module to encode and extract features from the header byte sequence and payload word sequence of data packets in the structured network flow sample, and perform feature fusion to obtain the content features of the data packets.
[0043] like Figure 2 As shown, the header-payload heterogeneous byte encoding module in step 3 includes a header byte encoding branch, a payload byte encoding branch, and a feature fusion submodule. The header byte encoding branch and the payload byte encoding branch have the same network structure but different parameters. Each encoding branch includes byte embedding, one-dimensional convolution Conv1, GELU activation, mask batch normalization, one-dimensional convolution Conv2, GELU activation, mask batch normalization, BiLSTM, and mask attention aggregation, which are connected in sequence. Step 3 specifically involves:
[0044] Step 3.1: Input the header byte sequence and payload byte sequence of the data packet into the header byte encoding branch and payload byte encoding branch respectively to obtain the header byte feature sequence. and payload byte feature sequence .
[0045] Step 3.2: Byte Valid Masking and Attention Aggregation. The padding positions in the header byte feature sequence and payload byte feature sequence are masked, preventing padding bytes from participating in subsequent feature aggregation. For the k-th packet of the m-th burst in the i-th network flow, assume the byte sequence of the corresponding input coding branch contains... byte positions, of which , and , representing the header byte encoding branch and the payload byte encoding branch, respectively. This indicates the number of byte positions in the input header byte encoding branch, i.e., the number of byte positions in the header byte feature sequence; This represents the number of byte positions in the input payload byte encoding branch, i.e., the number of byte positions in the payload byte feature sequence; let the effective mask corresponding to the j-th byte position be denoted as . ,in A value of 1 indicates that the byte is valid, while a value of 0 indicates that the byte is a padding byte.
[0046] Calculate the importance score for each valid byte position:
[0047]
[0048] in, This represents the k-th data packet of the m-th burst in the i-th network flow. The importance score of each byte position Indicates the input corresponding to the coding branch number Byte characteristics at each byte position These are the trainable parameters for this encoding branch.
[0049] For an encoded branch containing at least one valid byte, the byte attention weight is calculated according to the following formula:
[0050]
[0051] in, The byte attention weight at the j-th byte position. The valid byte mask at the j-th byte position; Score the importance of the s-th byte position. is the byte effective mask at the s-th byte position; when the byte effective mask is 1, this position participates in normalization; when the byte effective mask is 0, the attention weight at this position is 0 and does not participate in the summation of the denominator; if all byte masks of this branch are 0, then the above formula is not calculated, and the attention weight and aggregation feature are directly set to zero.
[0052] Based on the byte attention weights, the corresponding byte feature sequences are weighted and aggregated to obtain the header byte aggregation features and the payload byte aggregation features, respectively denoted as:
[0053]
[0054]
[0055] in, This represents the feature at the j-th byte position in the header byte features. This represents the byte attention weight at the corresponding position in the header byte features; This represents the feature at the j-th byte position in the payload byte features. This represents the byte attention weight at the corresponding position in the payload byte features; and These represent the header aggregation feature and payload aggregation feature of the k-th data packet in the m-th burst of the i-th network flow, respectively.
[0056] Step 3.3: Merging Header and Load Features. Merging the header features... and payload aggregation features The data packets are concatenated, and the content features of the corresponding data packets are obtained through feature mapping, denoted as... It is represented as:
[0057]
[0058] in, This represents the fusion mapping function between header features and payload features. This represents the content characteristics of the k-th data packet in the m-th burst of the i-th network flow.
[0059] Step 4: Aggregate the content features of data packets within the burst traffic to obtain burst-level features; perform context relationship modeling and feature aggregation on multiple burst traffic events in the network flow to obtain hierarchical content features of the network flow, specifically:
[0060] Step 4.1: Burst Internal Packet Location Encoding. For the m-th burst in the i-th network flow, the content characteristics of each packet are added to the local location encoding according to the order of the packets in the burst.
[0061] The local position code corresponding to the k-th data packet is generated using a fixed sinusoidal position coding method. Then, the content characteristics of the data packet obtained after adding local location encoding are represented as follows:
[0062]
[0063] in, This represents the location-enhanced data packet content feature obtained after adding local location information to the k-th packet of the m-th burst traffic in the i-th network flow.
[0064] Step 4.2: Burst Internal Packet Attention Aggregation. Based on the packet validity mask, determine the valid packets in the m-th burst traffic of the i-th network flow. A mask of 1 indicates that the packet at that position is a truly reserved packet, and a mask of 0 indicates that the packet at that position is a padding packet. Based on the enhanced packet content characteristics... Calculate the importance score for each data packet:
[0065]
[0066] in, This represents the importance score of the k-th packet in the m-th burst of the i-th network flow. Trainable parameters are computed for packet attention.
[0067] Softmax normalization is performed only on the importance scores of valid packets with a mask of 1. The attention weights of padding packets are set to 0 and do not participate in the normalization calculation or weighted aggregation. The packet attention weights are calculated in conjunction with the valid packet masks.
[0068]
[0069] in, The effective mask for the k-th packet of the m-th burst in the i-th network flow; The effective mask for the z-th packet of the m-th burst in the i-th network flow; The importance score is given to the z-th packet of the m-th burst in the i-th network flow.
[0070] Based on the packet attention weights, the location-enhanced packet content features in burst traffic are weighted and aggregated to obtain burst-level features:
[0071]
[0072] in, Let K represent the burst level characteristic of the m-th burst in the i-th network flow, and K represent the maximum number of data packets in each burst. This represents the packet attention weight of the k-th packet in the m-th burst of the i-th network flow; if the burst consists entirely of padding packets, then its packet attention weight and burst level feature are both set to zero.
[0073] Step 4.3: Global Location Encoding of Burst Traffic. Based on the order of burst traffic in the network flow, add a global location code (generated using a fixed sinusoidal location code) to the burst-level features obtained in Step 4.2. This global location code is determined by the burst sequence number and is not randomly generated; its dimension is consistent with the burst-level features. Add the global location code to the burst-level features, and use an effective burst traffic mask to mask and fill in the burst traffic, obtaining the location-enhanced burst-level features:
[0074]
[0075] in, This represents the burst-level feature obtained after incorporating global location information from the network flow, resulting in enhanced location.
[0076] Step 4.4: Burst Sequence Context Relationship Encoding. The multiple enhanced burst-level features obtained in Step 4.3 are input into the sequence relation encoding network according to their original order in the network flow. This models the contextual dependencies between different burst flows, resulting in context-enhanced burst-level features:
[0077]
[0078] The burst sequence relation coding network employs a bidirectional long short-term memory (BiLSTM) network, which extracts contextual information between burst flows through forward and backward encoding. This represents a bidirectional long short-term memory network. This represents the m-th context-enhanced burst-level feature after context dependency modeling; during encoding, only the actual retained burst sequences are processed, and padding bursts do not participate in cyclic encoding.
[0079] Step 4.5: Network Flow Hierarchical Content Feature Aggregation. Based on the effective mask of burst traffic generated in Step 2. The burst-level features obtained in step 4.4 after context enhancement are then subjected to masked attention pooling to obtain the hierarchical content features of the complete network stream, denoted as... .
[0080] First, the importance score of each burst traffic is calculated based on the context-enhanced burst-level features:
[0081]
[0082] in, This represents the importance score of the m-th burst of traffic in the i-th network flow. The parameters for burst attention are trainable; the importance scores of each burst are normalized using Softmax, and the burst attention weights are calculated by combining the effective burst mask.
[0083]
[0084] in, It is the effective mask for the m-th burst of traffic in the i-th network flow; It is the effective mask for the d-th burst of traffic in the i-th network flow; This represents the importance score of the d-th burst of traffic in the i-th network flow.
[0085] The above formula applies to cases where there is at least one valid burst of traffic; the weight of the burst traffic is 0 and it is not included in the normalization; if all burst traffic is invalid, the weight and aggregation result are set to zero.
[0086] Weighted aggregation is performed based on the aforementioned burst attention weights:
[0087]
[0088] Where M represents the maximum number of bursts of network stream input. This represents the burst attention weight of the m-th burst traffic. This represents the hierarchical content features of the i-th network flow.
[0089] Step 5: Remove padding packets from the network flow based on the packet validity mask and obtain the behavioral information of the valid packets. Reconstruct the behavioral information of all valid packets into a behavioral sequence according to the original communication order of the valid packets in the network flow. Extract the communication behavioral features of the network flow through the valid packet behavioral sequence encoding module, specifically:
[0090] Step 5.1: Behavioral Feature Normalization. For the k-th packet of the m-th burst in the i-th network flow, normalize the behavior feature according to the packet length. arrival time interval and transmission direction Information on the behavior of constructing data packets :
[0091]
[0092] The packet length and arrival time interval are normalized to obtain normalized packet behavior information, denoted as . .
[0093] Step 5.2: Valid Packet Sequence Reconstruction. Using a valid packet mask, remove padding packets generated during the fixed-length input process, retaining only valid packets with a mask of 1. Rearrange the normalized packet behavior information corresponding to the valid packets according to their chronological order in the original network flow to obtain the valid packet behavior sequence corresponding to the i-th network flow, denoted as... .
[0094] in, This represents the number of valid data packets in the i-th network flow. This indicates the number of words arranged according to the original communication order. Normalized data packet behavior information corresponding to each valid data packet.
[0095] Step 5.3: Encoding the valid packet behavior sequence. Encode the valid packet behavior sequence... The input valid packet behavior sequence encoding module encodes the behavioral changes and temporal relationships between valid data packets to obtain the communication behavior characteristics of the network flow:
[0096]
[0097] in, This represents the communication behavior characteristics of the i-th network flow. This represents a valid packet behavior sequence encoding network. The valid packet behavior sequence encoding module includes an Embedding layer, a Norm layer, a Padding layer, a Sequence layer, and a BiLSTM connected in sequence. The Embedding layer maps the valid packet behavior sequence to a feature vector. The Padding layer is used for sequence padding, which fills in behavioral feature sequences of different lengths in the same batch to make them the same length for batch processing. The Sequence layer is used for sequence packing, which organizes the input according to the actual number of valid packets in each sequence, so that the subsequent BiLSTM only processes valid packets and avoids the padding position affecting the extraction of network flow behavior features. BiLSTM represents a bidirectional long short-term memory network, which extracts the temporal dependencies between valid packets from the forward and backward directions, and concatenates the final valid hidden states in the two directions to obtain the communication behavior features of the network flow.
[0098] Step 6: Fuse the hierarchical content features and communication behavior features of the network flow to obtain the network flow content-behavior co-features, and output the prediction rates for each category through a classification network, specifically:
[0099] Step 6.1: Content and Behavioral Feature Fusion. The hierarchical content features of the i-th network stream are fused. and communication behavior characteristics The features are concatenated and obtained through feature fusion mapping, denoted as . :
[0100]
[0101] in, This represents the fusion mapping function between content features and behavioral features. This represents the content-behavior co-feature of the i-th network flow.
[0102] Step 6.2: Classification Prediction. The content-behavior co-features obtained in Step 6.1 are then used for classification prediction. Input the classification network to obtain the predicted probabilities of the network flow belonging to each category:
[0103]
[0104]
[0105] in, , The trainable parameters for the classification network are: a fully connected layer with an output dimension of C, meaning the network stream classification task contains C categories; This indicates its unnormalized output; Let be the predicted probability that the i-th network flow belongs to the c-th category.
[0106]
[0107]
[0108] in, Probabilities of C categories Composition, with a probability sum of 1; online output predicts the category. And the corresponding predicted probability.
[0109] Step 7: Construct the cross-entropy loss function and use the Adam optimization algorithm to update the model parameters until the model converges. Specifically:
[0110] Step 7.1: Construct the cross-entropy loss function:
[0111]
[0112] Where B represents the actual number of network flow samples included in the current batch; Indicates the true category label of the i-th network flow; This represents the average classification loss for the current batch. Using this classification loss as the training objective, the model parameters are adjusted to reduce the loss and improve the model's prediction probability of the true class.
[0113] Step 7.2: After calculating the loss for each training batch, the adjustment direction of each trainable parameter is calculated through backpropagation, and the Adam optimization algorithm is used to update each trainable parameter to reduce the classification loss. The learning rate is set to 0.001.
[0114] The update scope includes the trainable parameters of both the header byte encoding branch and the payload byte encoding branch. Trainable parameters for packet attention computation Spontaneous attention is calculated using trainable parameters. The trainable parameters in the effective packet behavior sequence encoding module; and the trainable parameters when fusing hierarchical content features and communication behavior features for classification. The effective masks at each level are determined by the preprocessing process and are not updated as model parameters.
[0115] The above description is only a preferred embodiment of the present invention and is not intended to limit the ideas of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for classifying encrypted traffic based on burst sensing and multimodal feature fusion, characterized in that, include: Step 1: Obtain raw network traffic data and preprocess it to convert the raw network traffic data into a hierarchical structure consisting of network flow, burst traffic and data packets, and construct a structured network flow sample composed of content information and behavioral information. Step 2: To distinguish between real data and padding data generated during the completion process, set valid data packet mask, valid burst traffic mask, and valid byte mask respectively; Step 3: Construct a header-payload heterogeneous byte encoding module to encode and extract features from the header byte sequence and payload word sequence of data packets in the structured network flow sample, and perform feature fusion to obtain the content features of the data packets; Step 4: Aggregate the content features of data packets within burst traffic to obtain burst-level features; perform context relationship modeling and feature aggregation on multiple burst traffic in the network flow to obtain hierarchical content features of the network flow. Step 5: Remove padding packets from the network flow based on the packet validity mask and obtain the behavior information of the valid packets. Reconstruct the behavior information of all valid packets into a behavior sequence according to the original communication order of the valid packets in the network flow. Extract the communication behavior features of the network flow through the valid packet behavior sequence encoding module. Step 6: Fuse the hierarchical content features and communication behavior features of the network flow to obtain the network flow content-behavior co-features, and output the prediction rates of each category through the classification network; Step 7: Construct the cross-entropy loss function and use the Adam optimization algorithm to update the model parameters until the model converges.
2. The encrypted traffic classification method based on burst perception and multimodal feature fusion according to claim 1, characterized in that, Step 1 specifically involves: Step 1.1: Obtain the raw PCAP network traffic data, construct a five-tuple based on the source IP address, destination IP address, source port, destination port and transport layer protocol, reassemble data packets belonging to the same communication process into a network flow, and sort them in ascending order according to the data packet timestamp to obtain a network flow data packet sequence with time order; Step 1.2: Parse each data packet in the reassembled network flow data packet sequence, extract the original bytes, data packet length, arrival timestamp and source IP address information of the data packet, anonymize the source IP address and destination IP address in the data packet, and retain other protocol structure information in the data packet; Step 1.3: Using the source IP address of the first valid data packet in the network flow data packet sequence as the communication direction reference address, data packets in the network flow data packet sequence whose source IP address matches the reference address are marked as forward data packets, and data packets whose source IP address differs from the reference address are marked as reverse data packets, thereby determining the transmission direction of each data packet in the network flow; Step 1.4: Based on the time order and transmission direction of data packets in the network flow data packet sequence, data packets that are consecutive in time and have the same transmission direction are divided into the same burst flow; when the transmission direction between adjacent data packets changes, the current burst flow ends and a new burst flow is established, thereby dividing a network flow into multiple burst flows with directional continuity. Let the i-th network flow contain Data packets, and divided into A sudden surge in traffic is represented as: in, This represents the i-th network flow. This represents the nth data packet, where n = 1, 2, ..., N. i ; This represents the m-th burst flow, where m = 1, 2, ..., M. i ; Step 1.5: For each data packet in the burst traffic, divide the original bytes of the data packet into a header byte sequence and a payload byte sequence to form the content information of the data packet; and extract the data packet length, data packet arrival time interval and transmission direction to form the behavior information of the data packet; construct a structured network flow sample composed of content information and behavior information. Step 1.6: To control the input size of the model, the preset number of burst flows is [value missing]. If the actual number of bursts in the i-th network flow Greater than The earliest value is taken from each sample. A burst of traffic; if the actual number of bursts of traffic in the i-th network flow... Less than Then, fill the burst flow slots at the tail end to make the number of burst flows in the sample reach [a certain number]. ; Step 1.7: Let the original value of the m-th burst traffic retained after interception be... Data packets, when When, retain all packages; when At that time, keep the previous one One and after Data packets are placed into the first K packet slots of the burst traffic in their original time order, where K is the set packet quantity threshold. Step 1.8: For each truly retained data packet, truncate the header byte sequence and payload byte sequence respectively. and 1 byte, with zeros padded at the end if necessary; The header byte sequence, payload byte sequence, and behavior information of the padding data packet are all initialized to zero. The index of the padding data packet is an empty identifier. The padding data packet does not increase the actual number of data packets, nor does it change the time interval between the original data packets.
3. The encrypted traffic classification method based on burst perception and multimodal feature fusion according to claim 2, characterized in that, The data packet valid mask, burst traffic valid mask, and byte valid mask in step 2 all adopt the same rule: the actual reserved positions are set to 1, and the padded positions are set to 0. For the k-th packet slot of the m-th burst in the i-th network flow, if the slot contains a packet that is actually reserved according to step 1.6, the effective mask of the packet is 1; if it is a padding packet, the effective mask of the packet is 0; as long as there is at least one actually reserved packet in a burst, its effective mask of the burst is 1; the effective mask of a burst consisting entirely of padding packets is 0. For the header byte sequence and payload byte sequence, the byte validity mask corresponding to the actual reserved bytes is set to 1, and the zero padding position is set to 0; the header byte sequence and payload byte sequence of the padding data packet are both set to invalid, and the actual number of bytes is 0.
4. The encrypted traffic classification method based on burst perception and multimodal feature fusion according to claim 1, characterized in that, The header-payload heterogeneous byte encoding module in step 3 includes a header byte encoding branch, a payload byte encoding branch, and a feature fusion submodule. The header byte encoding branch and the payload byte encoding branch have the same network structure but different parameters. Each encoding branch includes byte embedding, one-dimensional convolution Conv1, mask batch normalization, GELU activation, one-dimensional convolution Conv2, mask batch normalization, GELU activation, BiLSTM, and mask attention aggregation, which are connected in sequence. Step 3 specifically involves: Step 3.1: Input the header byte sequence and payload byte sequence of the data packet into the header byte encoding branch and payload byte encoding branch respectively to obtain the header byte feature sequence and payload byte feature sequence; Step 3.2: Mask the padding positions in the header byte feature sequence and payload byte feature sequence so that the padding bytes do not participate in subsequent feature aggregation; for the k-th packet of the m-th burst traffic in the i-th network flow, suppose the byte sequence of the corresponding input encoding branch contains byte positions, of which , and , representing the header byte encoding branch and the payload byte encoding branch, respectively. This indicates the number of byte positions in the input header byte encoding branch, i.e., the number of byte positions in the header byte feature sequence; This represents the number of byte positions in the input payload byte encoding branch, i.e., the number of byte positions in the payload byte feature sequence; let the effective mask corresponding to the j-th byte position be denoted as . ,in 1 indicates that the byte is valid, while 0 indicates that the byte is a padding byte; Calculate the importance score for each valid byte position: in, This represents the k-th data packet of the m-th burst in the i-th network flow. The importance score of each byte position Indicates the input corresponding to the coding branch number Byte characteristics at each byte position These are the trainable parameters for this encoding branch; For an encoded branch containing at least one valid byte, the byte attention weight is calculated according to the following formula: in, The byte attention weight at the j-th byte position. The valid byte mask at the j-th byte position; Score the importance of the s-th byte position. Let be the byte effective mask at the s-th byte position; when the byte effective mask is 1, this position participates in normalization; when the byte effective mask is 0, the attention weight at this position is 0 and does not participate in the summation of the denominator; if all byte masks of this branch are 0, then the above formula is not calculated, and the attention weight and aggregation feature are directly set to zero. Based on the byte attention weights, the corresponding byte feature sequences are weighted and aggregated to obtain the header byte aggregation features and the payload byte aggregation features, respectively denoted as: in, This represents the feature at the j-th byte position in the header byte features. This represents the byte attention weight at the corresponding position in the header byte features; This represents the feature at the j-th byte position in the payload byte features. This represents the byte attention weight at the corresponding position in the payload byte features; and Let represent the header aggregation feature and payload aggregation feature of the k-th data packet in the m-th burst of the i-th network flow, respectively; Step 3.3: Aggregate the head features and payload aggregation features The data packets are concatenated, and the content features of the corresponding data packets are obtained through feature mapping, denoted as... It is represented as: in, This represents the fusion mapping function between header features and payload features. This represents the content characteristics of the k-th data packet in the m-th burst of the i-th network flow.
5. The encrypted traffic classification method based on burst perception and multimodal feature fusion according to claim 1, characterized in that, Step 4 specifically involves: Step 4.1: For the m-th burst of traffic in the i-th network flow, add the content features of each data packet to the local location code according to the order of the data packets in the burst; The local position code corresponding to the k-th data packet is generated using a fixed sinusoidal position coding method. Then, the content characteristics of the data packet obtained after adding local location encoding are represented as follows: in, This represents the location-enhanced data packet content feature obtained after adding local location information to the k-th data packet of the m-th burst in the i-th network flow; Step 4.2: Based on the packet validity mask, determine the valid packets in the m-th burst of the i-th network flow. A mask of 1 indicates that the packet at that position is a genuine reserved packet, and a mask of 0 indicates that the packet at that position is a padding packet; based on the enhanced packet content characteristics... Calculate the importance score for each data packet: in, This represents the importance score of the k-th packet in the m-th burst of the i-th network flow. Trainable parameters computed for packet attention; Softmax normalization is performed only on the importance scores of valid packets with a mask of 1. The attention weights of padding packets are set to 0 and do not participate in the normalization calculation or weighted aggregation. The packet attention weights are calculated in conjunction with the valid packet masks. in, The effective mask for the k-th packet of the m-th burst in the i-th network flow; The effective mask for the z-th packet of the m-th burst in the i-th network flow; The importance score of the z-th packet in the m-th burst of the i-th network flow; Based on the packet attention weights, the location-enhanced packet content features in burst traffic are weighted and aggregated to obtain burst-level features: in, Let K represent the burst level characteristic of the m-th burst in the i-th network flow, and K represent the maximum number of data packets in each burst. This represents the packet attention weight of the k-th packet in the m-th burst of the i-th network flow; if the burst consists entirely of padding packets, then its packet attention weight and burst level feature are both set to zero. Step 4.3: According to the order of burst traffic in the network flow, add global location coding to the burst-level features obtained in Step 4.2; add the global location coding to the burst-level features, and use the burst traffic effective mask to mask and fill the burst traffic to obtain the location-enhanced burst-level features: in, This represents the location-enhanced burst-level feature obtained after incorporating global location information from the network stream; Step 4.4: Input the multiple enhanced burst features obtained in Step 4.3 into the sequence relation encoding network according to their original order in the network flow to model the context dependencies between different burst flows, and obtain the context-enhanced burst features: The burst sequence relation coding network employs a bidirectional long short-term memory network, extracting contextual information between burst flows through forward and backward encoding. This represents a bidirectional long short-term memory network. This represents the m-th context-enhanced burst-level feature after context dependency modeling; during encoding, only the actual retained burst sequences are processed, and padding bursts do not participate in cyclic encoding; Step 4.5: Calculate the importance score of each burst traffic based on the context-enhanced burst-level features: in, This represents the importance score of the m-th burst of traffic in the i-th network flow. The parameters for burst attention are trainable; the importance scores of each burst are normalized using Softmax, and the burst attention weights are calculated by combining the effective burst mask. in, It is the effective mask for the m-th burst of traffic in the i-th network flow; It is the effective mask for the d-th burst of traffic in the i-th network flow; This represents the importance score of the d-th burst of traffic in the i-th network flow; The above formula applies to cases where there is at least one valid burst of traffic; the weight of the burst traffic is 0 and it is not included in the normalization; if all burst traffic is invalid, the weight and the aggregation result are set to zero. Weighted aggregation is performed based on the aforementioned burst attention weights: Where M represents the maximum number of bursts of network stream input. This represents the burst attention weight of the m-th burst traffic. This represents the hierarchical content features of the i-th network flow.
6. The encrypted traffic classification method based on burst perception and multimodal feature fusion according to claim 2, characterized in that, Step 5 specifically involves: Step 5.1: For the k-th packet of the m-th burst in the i-th network flow, based on the packet length... arrival time interval and transmission direction Information on the behavior of constructing data packets : The packet length and arrival time interval are normalized to obtain normalized packet behavior information, denoted as . ; Step 5.2: Using a packet validity mask, remove padding packets generated during the fixed-length input process, retaining only valid packets with a mask of 1; rearrange the normalized packet behavior information corresponding to the valid packets according to the chronological order of the packets in the original network flow to obtain the valid packet behavior sequence corresponding to the i-th network flow, denoted as . ; in, This represents the number of valid data packets in the i-th network flow. This indicates the number of words arranged according to the original communication order. Normalized data packet behavior information corresponding to each valid data packet; Step 5.3: Sequence of valid data packet behavior The input valid packet behavior sequence encoding module encodes the behavioral changes and temporal relationships between valid data packets to obtain the communication behavior characteristics of the network flow: in, This represents the communication behavior characteristics of the i-th network flow. This represents a valid packet behavior sequence encoding network. The valid packet behavior sequence encoding module includes an Embedding layer, a Norm layer, a Padding layer, a Sequence layer, and a BiLSTM connected in sequence. The Embedding layer maps the valid packet behavior sequence to a feature vector. The Padding layer is used for sequence padding, which fills in behavioral feature sequences of different lengths in the same batch to make them the same length for batch processing. The Sequence layer is used for sequence packing, which organizes the input according to the actual number of valid packets in each sequence, so that the subsequent BiLSTM only processes valid packets and avoids the padding position affecting the extraction of network flow behavior features. BiLSTM represents a bidirectional long short-term memory network, which extracts the temporal dependencies between valid packets from the forward and backward directions, and concatenates the final valid hidden states in the two directions to obtain the communication behavior features of the network flow.
7. The encrypted traffic classification method based on burst perception and multimodal feature fusion according to claim 1, characterized in that, Step 6 specifically involves: Step 6.1: Determine the hierarchical content features of the i-th network stream. and communication behavior characteristics The features are concatenated and obtained through feature fusion mapping, denoted as . : in, This represents the fusion mapping function between content features and behavioral features. This represents the content-behavior co-feature of the i-th network flow; Step 6.2: Obtain the content-behavior co-features Input the classification network to obtain the predicted probabilities of the network flow belonging to each category: in, , The trainable parameters for the classification network are: a fully connected layer with an output dimension of C, meaning the network stream classification task contains C categories; This indicates its unnormalized output; Let be the predicted probability that the i-th network flow belongs to the c-th category; in, Probabilities of C categories Composition, with a probability sum of 1; online output predicts the category. And the corresponding predicted probability.
8. The encrypted traffic classification method based on burst perception and multimodal feature fusion according to claim 7, characterized in that, Step 7 specifically involves: Step 7.1: Construct the cross-entropy loss function: Where B represents the actual number of network flow samples included in the current batch; Indicates the true category label of the i-th network flow; This represents the average classification loss for the current batch; using this classification loss as the training objective, the model parameters are adjusted to reduce the loss and improve the model's prediction probability of the true class. Step 7.2: After the loss calculation is completed for each training batch, the adjustment direction of each trainable parameter is calculated through backpropagation, and the Adam optimization algorithm is used to update each trainable parameter to reduce the classification loss.
Citation Information
Patent Citations
Traffic classification method and device, computer equipment and storage medium
CN112104570A
Network traffic classification method based on attention mechanism
CN114818867A
