A BGP community attribute semantic inference method based on double-tower contrastive learning
By employing a dual-tower contrastive learning method, a community structure inference graph and an auxiliary topology graph are constructed. Combined with a graph-text encoder, this solves the problems of semantic inference and cross-modal retrieval of BGP community attributes, achieving efficient semantic inference and good generalization ability for community attributes lacking public descriptions.
Patent Information
- Application Number
- CN202611352606.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-02
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies struggle to uniformly cover approximately 90% of BGP community attributes that lack public descriptions. Closed-set classification paradigms cannot represent intents beyond the training categories, lack a searchable continuous representation from routing graphs to semantics, and the long-tail imbalance of categories leads to poor generalization ability of rare categories.
A dual-tower contrastive learning approach is adopted, which constructs a community structure inference graph and an auxiliary AS center topology graph, combines graph tower and text tower encoders, and uses the symmetric InfoNCE loss function for training to achieve alignment between graph embedding and text embedding, thus solving the problems of semantic inference and cross-modal retrieval of community attributes.
It achieves scalable semantic inference for approximately 90% of BGP community attributes that lack public descriptions, obtains 99.19% category-level Recall@1, maintains 94.79% generalization capability on unseen ASs, and provides a portable means of route security monitoring.
Smart Images

Figure CN123164047A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet routing security technology, and in particular to a BGP community attribute semantic inference method based on dual-tower contrastive learning. Background Technology
[0002] Border Gateway Protocol (BGP), as the fundamental routing protocol for interconnection between Autonomous Systems (AS) on the Internet, supports the operation of the entire routing system by enabling highly flexible and customizable routing policies. The BGP community attribute described in this invention is a standard BGP community, using a 32-bit a:c format, where 'a' is a 2-byte defined AS field and 'c' is a 2-byte local value field. Operators use the community attribute to convey policy intentions that the BGP protocol itself does not encode; the protocol propagates this value but does not interpret it; the semantic interpretation is established by the defining AS itself.
[0003] However, the lack of a unified and standardized semantic dictionary for BGP community attributes introduces critical security vulnerabilities. Community labels used by operators for route leakage mitigation and selective advertising can be abused by attackers, causing destructive consequences such as route oscillations, black hole routes, and network outages. Research indicates that approximately 90% of deployed community attribute values are not publicly described, resulting in a fundamental semantic gap: the intent of a community attribute lies within the definition of the AS, while external observers can only see the label and the routes it induces, without understanding the underlying policy implications. Even the most comprehensive dictionaries only cover about 11% of deployed community attributes.
[0004] In existing technologies, methods for inferring the semantics of BGP community attributes are mainly divided into three categories: The first category is measurement-based methods. Donnet and Bonaventure provided the first systematic overview of BGP community attribute usage, recording its usage through a manual classification system. This type of method records "what" community attributes are deployed, but does not provide automated means to interpret undescribed community attributes. The manual classification system requires operator involvement and is limited by dictionary coverage.
[0005] The second category is rule-based heuristics. Krenc et al. formalized action / information differentiation as a classification task, while Silva Jr. et al. designed specific heuristic rules for a single category or family. However, each set of rules is specifically designed for a single category or family and cannot be transferred across a complete classification system of nine categories; the accuracy drops sharply under distribution shifts; and methods relying on operator descriptions are limited by the approximately 11% dictionary coverage of the underlying corpus.
[0006] The third category is based on deep learning methods. Tan et al. applied graph neural networks to BGP community attribute classification, training a supervised model on AS-level topology. However, this method relies on rigid closed-set classification, making it unable to represent or recognize community attributes beyond its predefined training categories; for example, ordinal subclasses such as 1× / 2× / 3× in Prepend are collapsed into single labels, losing fine-grained semantic information; at the same time, AS-local sub-conventions are also forced into preset categories; the output is discrete labels rather than retrieveable representations, requiring retraining to extend to new intents.
[0007] In summary, the existing technologies have the following shortcomings: (1) Existing methods are difficult to uniformly cover about 90% of BGP community attributes that lack public descriptions; (2) Closed set classification paradigms cannot represent intentions outside of training categories; (3) There is a lack of searchable continuous representations from routing graphs to semantics; (4) The problem of poor generalization ability of rare categories caused by long-tail imbalance of categories has not been solved. Summary of the Invention
[0008] To address the aforementioned technical problems, this invention provides a BGP community attribute semantic inference method based on dual-tower contrastive learning, which solves technical issues such as semantic inference of community attributes without publicly available descriptions, semantic inference and localization of open sets with intentions outside the classification system, semantic ambiguity of route observations, and poor generalization of rare categories caused by long-tail imbalance of categories.
[0009] To address the aforementioned technical problems, this invention provides a technical solution: a BGP community attribute semantic inference method based on dual-tower contrastive learning, comprising the following steps: Step S1: Obtain BGP RIB snapshots and route update data, CAIDA AS topology and business relationship data, CAIDAASRank data, PeeringDB network metadata, geolocation data, and community attribute dictionary data.
[0010] Step S2: For the target community attribute (ASN,c) determined by the defined AS and its local community value, construct its community structure inference graph (CSIG) using the (ASN,c) pair as the representation unit. CSIG_c=(G_c, G_c^aux), where G_c is the path-induced routing graph (PRG) and G_c^aux is the auxiliary AS center topology graph (AEG). The PRG is constructed as follows: traversing the AS path in each BGP update message carrying the target community attribute c, extracting directed edges between adjacent ASs hop-by-hop from the end of the AS path to the beginning, and accumulating a dynamic counter. Specifically, for each BGP update message m containing the target community attribute c, traversing from the end of its AS path to the beginning, and extracting directed edges (u→v) sequentially; adding the extracted nodes to V_c, and adding the directed edges to... Based on the event type of the update message m, including notification events, explicit withdrawal events, and implicit withdrawal events, the count value of the dynamic counter δ[(u,v),event] is accumulated respectively.
[0011] The AEG is constructed as follows: An AS-level business relationship graph G_CAIDA inferred from CAIDA is obtained; using the defined AS as the central node v0, a 2-hop neighborhood is expanded in G_CAIDA, retaining all nodes reachable from the central node via no more than two edges and the edges between them; the expanded subgraph is used as the AEG, and a center-aware indication signal is constructed for each node v in the AEG. ,in This indicates the hop count category of node v relative to the center node.
[0012] Preferably, when the directed edge When the size exceeds the preset edge budget threshold K_max=1500, the first K_max directed edges are retained from high to low according to the cumulative value of the dynamic counter δ.
[0013] Step S3: During the training phase, for the described community attributes with operator descriptions, their CSIGs are... c Input the Tuta encoder to obtain the graph embedding Z g and the corresponding operator description T c Input text tower encoder to obtain text embedding Z t For queries without described community attributes, the query graph embedding is obtained solely through the Tuta encoder during the inference phase and matched against a pre-computed text library. Both towers project the input into an L2-normalized 256-dimensional embedding space.
[0014] The Tuta encoder encodes the PRG in the following manner: (1) For each node v in the PRG, construct a 54-dimensional node feature vector x_v, including graph theory descriptor, PeeringDB metadata, geolocation summary, ASRank statistics, center-aware indicator signal, and community attribute value encoding. The center-aware indicator signal is a 5-dimensional vector c_v = [I(v=v0), onehot(hop(v))], where hop∈{0,1,2,>2}. The community attribute value encoding is a 4-dimensional vector, including the magnitude at the original and logarithmic scales, as well as the high byte and low byte.
[0015] (2) For each directed edge e=(u,v) in the PRG, construct a 41-dimensional edge feature vector f_e, including AS business relationship encoding, dynamic counter, frequency statistics and infrastructure metadata.
[0016] (3) A three-layer Relational Graph Attention Network (RGAT) is used to perform message passing on the node features and edge features. Based on GATv2, each layer of RGAT sets up self-loop relationships for 5 AS business relationship types, maintaining attention vectors per relationship type and per attention head. The attention is calculated as follows: α^h_{uv}=softmax_{u'∈N(v)}a_r^T·σ_LR(W_lh_u+W_rh_v+W_e h^e_{uv}) Where σ_LR is the LeakyReLU activation function, a_r is the relation-specific attention vector, and W_l, W_r, and W_e are learnable weight matrices.
[0017] (4) After each RGAT layer, the hidden state is subjected to an affine transformation by FiLM modulation, conditioned on the community attribute value encoding:
[0018] γ^(l) and β^(l) are obtained by layer-by-layer MLP mapping from the community attribute values.
[0019] (5) Provide long-range context through a virtual node that connects all nodes, so that family-level signals can reach the central node without increasing the number of layers.
[0020] (6) In the multi-scale Jumping-Knowledge readout, the outputs of the three-layer RGAT are subjected to average pooling and max pooling respectively and then concatenated.
[0021] The Tuta encoder encodes AEG using a 2-layer GATv2 with a width of 256→1024→256 (4 heads first, then 1 head), followed by global attention pooling.
[0022] The Tuta encoder performs dual-view fusion through a bottleneck cross-attention block: K_b = 4 learnable bottleneck tokens are initialized; these learnable bottleneck tokens first focus on the output of the PRG encoder through a cross-attention mechanism to aggregate community-specific routing signals; then, they focus on the output of the AEG encoder through a cross-attention mechanism to absorb AS-level identity context; finally, the output of the bottleneck cross-attention block is projected and combined with the output of the PRG encoder through a learnable residual gate. z_g^raw=proj(z_bottleneck)+σ(θ_res)·z_primary Where σ is the logistic sigmoid function, and θ_res is a learnable gating parameter initialized to 0.
[0023] Tuta output and community attribute value encoding of the central node and 44-dimensional bypass vector After splicing, the vectors are projected onto a shared 256-dimensional space through two layers of MLP (structured as Linear-LN-GELU-Dropout-Linear) and L2 normalization is applied. The 44-dimensional bypass vectors include 8-dimensional activity normalization features, 4-dimensional route change statistics features, 24-dimensional path-level mechanism features, and 8-dimensional infrastructure metadata features.
[0024] The text tower encoder encodes operator descriptions in the following way: It acquires the original operator description text, standardizes different expressions into a unified standard sentence structure using a large language model, while retaining key information such as community attribute values, AS numbers, organization names, and semantic subtypes, and maintaining the differences in parameterized semantics; it uses MPNet-base-v2 as a pre-trained language model, which contains a 12-layer Transformer structure with a hidden layer width of 768; it freezes the parameters of the bottom 10 layers of MPNet-base-v2, fine-tuning only the parameters of the last 2 layers with a low learning rate; it performs masked mean pooling on the last hidden state to exclude padding tokens, obtaining a sentence-level representation; and it projects the representation onto a shared 256-dimensional space through two MLP layers and applies L2 normalization.
[0025] Step S4: Using the symmetric InfoNCE loss function, align the graph embedding z_g with the text embedding z_t in the shared embedding space, and train the parameters of the graph encoder and the text encoder. The symmetric InfoNCE loss function is:
[0026] Where S_ij=z_g^(i)^T z_t^(j) / τ is the similarity scaled by temperature, and the temperature τ is truncated to [0.01,0.5] by sigmoid with an initial value of 0.10; M is the matrix for implementing the false negative example mask; R is the matrix for implementing the weighting of semantic family perception-difficult negative samples.
[0027] Calculate the graph-to-text direction loss separately. Text-to-graph direction loss And perform symmetrical aggregation of losses in both directions:
[0028] The loss function introduces the following three mechanisms to address structural problems unique to BGP community attribute data, such as redundancy in community attribute descriptions, long tails in category distribution, and sharing of topology within the same AS: False negative example masking mechanism: For the i-th sample and the j-th sample in the batch, calculate the MPNet cosine similarity between their operator descriptions;
[0029] in In the InfoNCE loss calculation, the mask matrix M is used to exclude graph-text pairs that satisfy M_ij=0, neither as positive nor negative examples.
[0030] Inverse frequency and focus reweighting mechanism: Statistically calculate the empirical frequency f(T_i) of each operator's description text and the empirical frequency f_cat(cat_i) of its semantic category; calculate the inverse frequency weight of each sample as 1 / √(f(T_i)·f_cat(cat_i)); calculate the focus weight of each sample as max((1-p_pos^(i))^γ, 0.01), where p_pos^(i) is the masked positive probability, and γ=1.5 is the focus index; combine the inverse frequency weight and the focus weight to obtain the sample-by-sample triplet weight: w_i=[1 / √(f(T_i)·f_cat(cat_i))]·max((1-p_pos^(i))^γ,0.01) The symmetric InfoNCE loss is weighted by the sample-by-sample triplet weight w_i.
[0031] Semantic family perception difficulty negative sample weighting mechanism: Determine the semantic family to which the target community attribute c belongs, the semantic family includes action family and information family; for sample pairs from the same definition AS and i≠j, if they belong to different semantic families, then R ij =1.0; if both belong to the same semantic family, then R ij =0.3; the remaining samples for R ij =0; In the denominator of the InfoNCE loss, the similarity contribution of each negative sample is reweighted with the inter-group weight R_ij.
[0032] Preferably, the comparative training further includes a long-tail AS hierarchical sampling step: based on the number of known descriptive samples of each defined AS in the training corpus, all ASs are divided into a heavy AS layer (≥74 samples), a medium AS layer (samples between [13, 74)), and a light AS layer (<13 samples); when constructing each training batch, samples are extracted from the heavy AS layer, medium AS layer, and light AS layer in a ratio of 0.4N:0.4N:0.2N, where N is the batch size; the samples in the light AS layer are oversampled so that the corresponding rare category samples appear in each training batch.
[0033] Training was performed using the AdamW optimizer for 100 epochs with a batch size of 256. Tuta used a learning rate of 6.84 × 10⁻⁶. -4 Unfrozen MPNet layers use a learning rate of 2×10. -5 After linear preheating, cosine annealing is applied.
[0034] Step S5: Pre-compute the text embeddings of all known descriptions of community attributes in the training set, and construct the text library G_text={TextTower(T_c;θ_t*):c∈D_train}.
[0035] For an undescribed target community attribute c_query, its CSIG is input into the trained Tuta encoder to obtain the query graph embedding z_g^query. The cosine similarity between this query graph embedding and the text embeddings of each known descriptive community attribute in the pre-computed text library is calculated. The texts are sorted from high to low according to the cosine similarity and the Top-K known descriptive entries are returned. The semantic category ranked first among the returned entries is used as the inferred semantics of the undescribed target community attribute.
[0036] When the true intent of the query community attribute belongs to a category other than the known semantic category, its continuous embedding representation can form a semantic position in the shared embedding space that is distinct from the known category and located near the semantically closest known description category, thus achieving open set semantic localization.
[0037] The beneficial effects of this invention are as follows: Compared with existing technologies, the core of this invention lies in reformulating semantic inference from closed-set classification to cross-modal retrieval. It is the first to reconstruct BGP community attribute semantic inference into cross-modal retrieval, providing scalable semantic inference capabilities for approximately 90% of BGP community attributes lacking publicly available descriptions. Simultaneously, it achieves 99.19% category-level Recall@1 under inductive partitioning, and maintains 94.79% even when the defined AS is completely unseen during training. This generalization ability benefits from the transferable routing structure learned through dual-view graph representation and contrast alignment, rather than overfitting to AS identity. Furthermore, because this invention outputs a continuous embedding table... Instead of using discrete classification results with fixed categories, the intent outside the classification system can form a corresponding semantic position in the shared embedding space, and be located near the semantically closest known descriptive category. This provides open set expansion capability for the new community attribute values continuously introduced by operators. With the inverse frequency and focus reweighting mechanism and long-tail AS hierarchical sampling, rare categories (such as black hole routes, IXPs, and facilities) are no longer obscured by high-frequency categories, thereby achieving balanced retrieval performance across all nine semantic categories. Finally, this invention transforms opaque operator-private configurations into quantifiable security signals, providing a practical new technical means for BGP route security monitoring.
[0038] To make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in this invention or the prior art, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only eight of the drawings in this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0040] Figure 1 This is a schematic diagram of the overall process of the BGP community attribute semantic inference method based on dual-tower contrastive learning in this invention; Figure 2 A schematic diagram of the t-SNE projection of Source community attributes outside the classification system and their most recently known descriptive category Relationship; Figure 3 A schematic diagram illustrating the class separability of the Tuta embedding z_g under the t-SNE projection on the class-balanced subsamples; Figure 4 Heatmap of pairwise cosine distances between the centroids of the nine semantic categories; Figure 5 To preserve the pairwise graph-text embedding similarity distribution and the baseline of random permutation on the test set; Figure 6 Activate feature heatmaps based on class means across the 32 most discriminative embedding dimensions; Figure 7 Prepend 1× / 2× / 3× semantic gradient trajectory verification plot; Figure 8 A mean-connected dendrogram embedded over the nine category means. Detailed Implementation
[0041] Embodiments of the invention will now be described in detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the drawings and embodiments of the invention are for illustrative purposes only and are not intended to limit the scope of protection of the invention. Example
[0042] like Figure 1 As shown, the present invention provides a BGP community attribute semantic inference method based on dual-tower contrastive learning, comprising the following steps: Step S1: Obtain BGP RIB snapshots and route update data, CAIDA AS topology and business relationship data, CAIDAASRank data, PeeringDB network metadata, geolocation data, and community attribute dictionary data.
[0043] Step S2: For the target community attribute (ASN,c) determined by the defined AS and its local community value, construct its community structure inference graph (CSIG) using the (ASN,c) pair as the representation unit. CSIG_c=(G_c, G_c^aux), where G_c is the path-induced routing graph (PRG) and G_c^aux is the auxiliary AS center topology graph (AEG). The PRG is constructed as follows: traversing the AS path in each BGP update message carrying the target community attribute c, extracting directed edges between adjacent ASs hop-by-hop from the end of the AS path to the beginning, and accumulating a dynamic counter. Specifically, for each BGP update message m containing the target community attribute c, traversing from the end of its AS path to the beginning, and extracting directed edges (u→v) sequentially; adding the extracted nodes to V_c, and adding the directed edges to... Based on the event type of the update message m, including notification events, explicit withdrawal events, and implicit withdrawal events, the count value of the dynamic counter δ[(u,v),event] is accumulated respectively.
[0044] The AEG is constructed as follows: An AS-level business relationship graph G_CAIDA inferred from CAIDA is obtained; using the defined AS as the central node v0, a 2-hop neighborhood is expanded in G_CAIDA, retaining all nodes reachable from the central node via no more than two edges and the edges between them; the expanded subgraph is used as the AEG, and a center-aware indication signal is constructed for each node v in the AEG. ,in This indicates the hop count category of node v relative to the center node.
[0045] Preferably, when the directed edge When the size exceeds the preset edge budget threshold K_max=1500, the first K_max directed edges are retained from high to low according to the cumulative value of the dynamic counter δ.
[0046] Step S3: During the training phase, for the described community attributes with operator descriptions, their CSIGs are... c Input the Tuta encoder to obtain the graph embedding Z g and the corresponding operator description T c Input text tower encoder to obtain text embedding Z t For queries without described community attributes, the query graph embedding is obtained solely through the Tuta encoder during the inference phase and matched against a pre-computed text library. Both towers project the input into an L2-normalized 256-dimensional embedding space.
[0047] The Tuta encoder encodes the PRG in the following manner: (1) For each node v in the PRG, construct a 54-dimensional node feature vector x_v, including graph theory descriptor, PeeringDB metadata, geolocation summary, ASRank statistics, center-aware indicator signal, and community attribute value encoding. The center-aware indicator signal is a 5-dimensional vector c_v=[I(v=v0), onehot(hop(v))], where hop∈{0,1,2,>2}. The community attribute value encoding is a 4-dimensional vector, including the magnitude at the original and logarithmic scales, as well as the high byte and low byte.
[0048] (2) For each directed edge e=(u,v) in the PRG, construct a 41-dimensional edge feature vector f_e, including AS business relationship encoding, dynamic counter, frequency statistics and infrastructure metadata.
[0049] (3) A three-layer Relational Graph Attention Network (RGAT) is used to perform message passing on the node features and edge features. The RGAT is based on GATv2, where each layer sets up self-loop relationships for 5 AS business relationship types, maintaining attention vectors per relationship type and per attention head. The attention is calculated as follows: α^h_{uv}=softmax_{u'∈N(v)}a_r^T·σ_LR(W_lh_u+W_rh_v+W_e h^e_{uv}) Where σ_LR is the LeakyReLU activation function, a_r is the relation-specific attention vector, and W_l, W_r, and W_e are learnable weight matrices.
[0050] (4) After each RGAT layer, the hidden state is subjected to an affine transformation by FiLM modulation, conditioned on the community attribute value encoding:
[0051] γ^(l) and β^(l) are obtained by layer-by-layer MLP mapping from the community attribute values.
[0052] (5) Provide long-range context through a virtual node that connects all nodes, so that family-level signals can reach the central node without increasing the number of layers.
[0053] (6) In the multi-scale Jumping-Knowledge readout, the outputs of the three-layer RGAT are subjected to average pooling and max pooling respectively and then concatenated.
[0054] The Tuta encoder encodes AEG using a 2-layer GATv2 with a width of 256→1024→256 (4 heads first, then 1 head), followed by global attention pooling.
[0055] The Tuta encoder performs dual-view fusion through a bottleneck cross-attention block: K_b = 4 learnable bottleneck tokens are initialized; these learnable bottleneck tokens first focus on the output of the PRG encoder through a cross-attention mechanism to aggregate community-specific routing signals; then, they focus on the output of the AEG encoder through a cross-attention mechanism to absorb AS-level identity context; finally, the output of the bottleneck cross-attention block is projected and combined with the output of the PRG encoder through a learnable residual gate. z_g^raw=proj(z_bottleneck)+σ(θ_res)·z_primary∈
[0056] Where σ is the logistic sigmoid function, and θ_res is a learnable gating parameter initialized to 0.
[0057] Tuta output and community attribute value encoding of the central node and 44-dimensional bypass vector After splicing, the vectors are projected onto a shared 256-dimensional space through two layers of MLP (structured as Linear-LN-GELU-Dropout-Linear) and L2 normalization is applied. The 44-dimensional bypass vectors include 8-dimensional activity normalization features, 4-dimensional route change statistics features, 24-dimensional path-level mechanism features, and 8-dimensional infrastructure metadata features.
[0058] The text tower encoder encodes operator descriptions in the following way: It acquires the original operator description text, standardizes different expressions into a unified standard sentence structure using a large language model, while retaining key information such as community attribute values, AS numbers, organization names, and semantic subtypes, and maintaining the differences in parameterized semantics; it uses MPNet-base-v2 as a pre-trained language model, which contains a 12-layer Transformer structure with a hidden layer width of 768; it freezes the parameters of the bottom 10 layers of MPNet-base-v2, fine-tuning only the parameters of the last 2 layers with a low learning rate; it performs masked mean pooling on the last hidden state to exclude padding tokens, obtaining a sentence-level representation; and it projects the representation onto a shared 256-dimensional space through two MLP layers and applies L2 normalization.
[0059] Step S4: Using the symmetric InfoNCE loss function, align the graph embedding z_g with the text embedding z_t in the shared embedding space, and train the parameters of the graph encoder and the text encoder. The symmetric InfoNCE loss function is:
[0060] Where S_ij=z_g^(i)^T z_t^(j) / τ is the similarity scaled by temperature, and the temperature τ is truncated to [0.01,0.5] by sigmoid with an initial value of 0.10; M is the matrix for implementing the false negative example mask; R is the matrix for implementing the weighting of semantic family perception-difficult negative samples.
[0061] Calculate the graph-to-text direction loss separately. Text-to-graph direction loss And perform symmetrical aggregation of losses in both directions:
[0062] The loss function introduces the following three mechanisms: False negative example masking mechanism: For the i-th sample and the j-th sample in the batch, calculate the MPNet cosine similarity between their operator descriptions;
[0063] in In the InfoNCE loss calculation, the mask matrix M is used to exclude graph-text pairs that satisfy M_ij=0 as neither positive nor negative examples.
[0064] Inverse frequency and focus reweighting mechanism: Statistically calculate the empirical frequency f(T_i) of each operator's description text and the empirical frequency f_cat(cat_i) of its semantic category; calculate the inverse frequency weight of each sample as 1 / √(f(T_i)·f_cat(cat_i)); calculate the focus weight of each sample as max((1-p_pos^(i))^γ, 0.01), where p_pos^(i) is the masked positive probability, and γ=1.5 is the focus index; combine the inverse frequency weight and the focus weight to obtain the sample-by-sample triplet weight: w_i=[1 / √(f(T_i)·f_cat(cat_i))]·max((1-p_pos^(i))^γ,0.01) The symmetric InfoNCE loss is weighted by the sample-by-sample triplet weight w_i.
[0065] Semantic family perception difficulty negative sample weighting mechanism: Determine the semantic family to which the target community attribute c belongs, the semantic family includes action family and information family; for sample pairs from the same definition AS and i≠j, if they belong to different semantic families, then R ij =1.0; if both belong to the same semantic family, then R ij =0.3; the remaining samples for R ij =0; In the denominator of the InfoNCE loss, the similarity contribution of each negative sample is reweighted with the inter-group weight R_ij.
[0066] Preferably, the comparative training further includes a long-tail AS hierarchical sampling step: based on the number of known descriptive samples of each defined AS in the training corpus, all ASs are divided into a heavy AS layer (≥74 samples), a medium AS layer (samples between [13, 74)), and a light AS layer (<13 samples); when constructing each training batch, samples are extracted from the heavy AS layer, medium AS layer, and light AS layer in a ratio of 0.4N:0.4N:0.2N, where N is the batch size; the samples in the light AS layer are oversampled so that the corresponding rare category samples appear in each training batch.
[0067] Training was performed using the AdamW optimizer for 100 epochs with a batch size of 256. Tuta used a learning rate of 6.84 × 10⁻⁶. -4 Unfrozen MPNet layers use a learning rate of 2×10. -5 After linear preheating, cosine annealing is applied.
[0068] Step S5: Pre-compute the text embeddings of all known descriptions of community attributes in the training set, and construct the text library G_text={TextTower(T_c;θ_t*):c∈D_train}.
[0069] For an undescribed target community attribute c_query, its CSIG is input into the trained Tuta encoder to obtain the query graph embedding z_g^query. The cosine similarity between this query graph embedding and the text embeddings of each known descriptive community attribute in the pre-computed text library is calculated. The texts are sorted from high to low according to the cosine similarity and the Top-K known descriptive entries are returned. The semantic category ranked first among the returned entries is used as the inferred semantics of the undescribed target community attribute.
[0070] When the true intent of the query community attribute belongs to a category other than the known semantic category, its continuous embedding representation can form a semantic position in the shared embedding space that is distinct from the known category and located near the semantically closest known description category, thus achieving open set semantic localization.
[0071] The semantic categories refer to the well-known classification system in this field, including five categories of action families: Blackhole routing, Prepend, LocalPref, NoExport, and Export; and four categories of information families: Location, Internet Exchange Center (IXP), Facility, and AS Relationship.
[0072] The effectiveness of the technical solution disclosed in this application is verified.
[0073] Dataset: Public BGP data streams using RouteViews and RIPE RIS. A one-month observation window from 13 collectors in January 2026 generated 57,254,117 BGP update events, with notification paths involving 61,248 different ASs. CSIG construction (as described in step S2) yielded 9,003 (ASN, c) pairs with non-empty graphs, distributed across 423 defined ASs. A total of 46,987 dictionary records were bound to the observed pairs. The intersection of the two (i.e., pairs that simultaneously construct CSIGs and normalized operator descriptions) totaled 6,686 pairs, constituting the training and evaluation corpora for known descriptions. The median size of each CSIG was 36 nodes and 210 directed edges.
[0074] Data partitioning: The training and evaluation corpora with known descriptions are in... (ASN, c) The levels were divided into four disjoint subsets in a ratio of 70:10:10:10; compared to the training set. D_train(n = 4644 pairs); Validation set D_val (n=674); Cross-modal retrieval test set D_test (n=678); and a retention pool for closed-set comparisons. D_aux (n=690).
[0075] exist D_test Of the 678 pairs, 496 pairs simultaneously possess both a constructible CSIG and a standardized operator description. These 496 pairs define the evaluation sample. Stratified sampling was applied across nine semantic categories to extract this partition, drawing from the same... (ASN, c) All samples of a pair are kept in the same subset, thus eliminating intra-pair leakage. The same ASN may still appear in different subsets with different community attributes. Semantic category labels are used only as: ① stratified sampling keys; ② inputs to inverse frequency reweighting and inter-group hard negative sample weighting; ③ the basis for class-based reporting, and never as classification targets in the training loss. (Preserving the split...) D_test∪D_aux All 1,368 category labels were manually annotated and verified one by one by multiple cybersecurity experts based on standardized operator descriptions.
[0076] No AS partitioning was found: To conduct generalization testing, 30 ASs were pre-selected through category-aware stratified sampling covering all categories (including rare categories), and all of them were then used for generalization testing. (ASN, c) The remaining ASs are reserved for training and validation. Category-aware sampling ensures that its sample pairs, concentrated in a few ASs, represent rare classes (especially IXP and Facility). Otherwise, this run is completely consistent with the standard procedure: the same hyperparameters, number of epochs, and loss function.
[0077] Comparison Method: For BGP community attribute classification, the previously learned method is the closed-set GNN classifier by Tan et al. This will be compared to its retrieval performance. Existing rule-based heuristics (such as those proposed by Krenc et al. and Silva Jr. et al.) only target a single class or family (Location, Action), rather than the entire space of deployed community attributes. Therefore, their class-specific precision / recall will be cited in the class-specific discussion below, rather than as a head-to-head baseline comparison.
[0078] Evaluation Metrics: To quantitatively evaluate the method of this invention, a category-level Recall@1 is used, which measures cross-modal retrieval against a text corpus: a hit is counted when the retrieved text shares the same semantic category as the query, thus semantically equivalent terms (such as Blackhole and RTBH) are considered matches, rather than being penalized for differences in surface form. The category of the query is directly read from its top-ranked search description, whose standardized canonical form determines the category without requiring independent training of a classifier. Under this category-level scoring, R@1 is numerically consistent with category-level classification accuracy, so retrieval and classification results can be directly compared. Micro-average is reported per query, and macro-average is reported side-by-side in Table 1 and by category results to expose long-tail behavior. The category-level R@1 with Wilson 95% confidence intervals is more reliable than bootstrap on few-sample categories. This metric evaluates category-level semantic retrieval, rather than an accurate reconstruction of the operator's complete policy configuration, which cannot be identified from public routing observations.
[0079] Four assessments are reported based on the above categorization. The retrieval metrics are... D_test The above describes the category-level R@1 for graph-to-text retrieval from a text library, and compares the method of this invention with closed-set contrastive methods. The generalization metric is R@1 on unseen AS partitions, and semantic localization is performed on an out-of-class category relative to a known descriptive category. Ablation is performed by disabling one component at a time and retraining while keeping other configurations unchanged. Representation analysis examines the geometric structure of the embedding space and the class-wise activation structure. The results are analyzed below.
[0080] Retrieval Performance: Table 1 reports the cross-modal retrieval results on the retained test set (n=496) under strictly inductive (disjoint) partitioning. The difference between micro and macro is negligible, verifying that the performance is balanced across the nine semantic categories.
[0081] Table 1. Cross-modal retrieval (D_test query → D_train text library, n = 496)
[0082] In contrast, retrieval using random Gaussian embedding or shuffled labels remained near the random level. The retrieval accuracy of this invention significantly outperforms the random baseline, demonstrating a true graph-description mapping.
[0083] The category-by-category search results are shown in Table 2. Blackhole routing, path pre-location, local priority, selective advertising, restricted advertising, Internet Exchange Center, and hosting facilities all achieved 100% Recall@1; geolocation was 98.67% (Wilson 95% confidence interval [96.2%, 99.5%]); and AS relationship was 98.39% (Wilson 95% confidence interval [91.5%, 99.7%]). These results verify that the present invention has good search performance across all nine semantic categories, with minimal performance differences between categories.
[0084] Table 2. Class-by-class R@1 and Wilson 95% CI on the retained test set D_test (n = 496)
[0085] Generalization ability verification: Generalization ability has two axes: one is the generalization to the definition AS that has not been seen in training, and the other is the generalization to community attribute categories outside the trained classification system. The former tests whether the learned structure still holds after changing the operator; the latter tests whether it still holds after changing the intent.
[0086] Generalization ability of unseen ASs: Evaluation was conducted under the condition that 30 ASs were not used in training. The results showed that, on the evaluation of unseen ASs (n=403 retained sample pairs), five out of nine categories achieved 100% R@1 on completely unseen ASs (Blackhole n=10, LocalPref n=11, Prepend n=3, Facility n=10, Relationship n=128), and NoExport (n=65) reached 98.46%. Export (n=23, 91.30%) and Location (n=122, 93.44%) showed moderate decreases. IXP community attributes were particularly sensitive to AS retention: n=31, R@1 was 67.74%, and Wilson 95% CI was [50.1, 81.4]. The IXP category is particularly sensitive to AS reservations because IXP semantics depend on the facility affiliation of each AS on the PeeringDB. When an AS is defined as unseen, AEG cannot provide a profile to anchor it to a specific facility. These results demonstrate that routing structures conditioned on community attributes can migrate to unseen ASs, proving that the semantics learned in this invention originate from transferable signals at the topology level, rather than from overfitting to AS identities.
[0087] For Source intents outside the classification system (intents that mark the source of a route, such as customer / non-customer, public / private peers, entry regions, etc., whose semantics belong to the information family but do not match any known descriptive category): this invention places its centroid at a distance of 0.49 cosines from the Relationship category and at least 0.85 from each action class. For example... Figure 2 As shown, this demonstrates that the Source intent outside the classification system can form a semantic position in the embedding space that is distinct from the known categories and is located near the Relationship category that is semantically closest to it, thus verifying the open set semantic localization capability of the present invention.
[0088] Ablation experiments were conducted to verify the effectiveness of the invention. To quantify the contribution of each architectural component to the technical effect of the invention, each component was removed and the system was retrained with other configurations unchanged. The results are shown in Table 3. Table 3. Contribution of each component to Recall@1 (test set n=496)
[0089] Ablation experiments show that the dual-view design (PRG+AEG) is the core architectural contribution of this invention. Removing AEG resulted in the largest decrease in retrieval performance (-4.11 percentage points), indicating that AS-level context plays a crucial supplementary role in semantic inference.
[0090] Representation analysis: Examining the learned representations along two complementary axes: the global geometry of the embedding space and the class-wise activation features within the Tuta.
[0091] For the global geometry of the embedded space, see [link to documentation]. Figure 3 , Figure 4 and Figure 5 The three views make the structural fingerprint directly visible.
[0092] Category separability under t-SNE projection: On a known class-balanced subsample of the descriptive corpus, for z_g By performing a two-dimensional t-SNE projection, the nine semantic categories are resolved into compact, mutually separated regions. Figure 3 The action family and the information family occupy two non-intersecting sides of the plane, and each category forms an independent density modulus within its family.
[0093] Category centroid distance heatmap: A 9×9 heatmap showing pairwise cosine distances between category centroids ( Figure 4 This reveals the separability by category. The mean of each category is well separated from the other eight. The centroids of the information family (Location, IXP, Relationship, Facility) form a particularly compact subgroup.
[0094] Pair similarity distribution: On the retained test set, paired similarities... z_g, z_t The baseline values are concentrated around 0.40, while the baseline values for random permutations are concentrated around 0.03. Figure 5 The difference of 0.37 is close to the InfoNCE temperature. τ=0.10 The upper limit of geometric similarity is defined at this temperature, where R@1 saturates long before the cosine reaches 1.
[0095] For class-wise activation features: Figure 6 (Activation heatmap by category) Figure 7 (Prepend stair trajectory verification on the Prepend staircase) Figure 8 (Hierarchical clustering tree diagram), the three views reveal how Tuta infers the semantics of community attributes.
[0096] like Figure 6 As shown, within each family, individual categories concentrate their high-amplitude activations on non-overlapping dimensional blocks: Blackhole and NoExport peak on different Action dimensions, while Location and IXP peak on different Info dimensions. The class-specific features emerge from contrastive training without explicit class labels.
[0097] like Figure 7 As shown, (a) represents the class-wise density along the 1×→3× centroid axis; (b) represents the pairwise centroid cosine distance. The embeddings directly preserve the order from the contrastive training, a property that discrete classifiers cannot encode. The same continuity allows for class-wise subclass separability. For known descriptive corpora... z_g KMeans analysis on the t-SNE projection (K=3) yielded the following results: Export profile coefficient 0.598, Facility 0.613, IXP 0.570, Prepend 0.552, and all other categories ≥0.39. The three Export sub-regions were decomposed into three operator-consistent subclusters. The first is a flat, peer-to-peer namespace for a Tier-1 operator (accounting for 28.6% of Export pairs; only AS1299, targeting AS3356 / AS6453 / AS702). The second is a regional mid-sized operator ecosystem, a mix of AS-to-AS, IXP-to-IXP, and role-to-role targets (42.0%; 27 ASs, led by AS3491 / AS1764). The third is a constraint-oriented heterogeneous cluster (29.4%; 16 ASs, led by AS3216). The correspondence between these subclusters and their defined ASs is expected, not accidental. Because each operator develops its own community attribute scheme, the structure of the operator's internal structure represents the finest, semantically meaningful granularity for distinguishing Export categories. Closed-set classification methods cannot provide this fine-grained subclass separability.
[0098] Figure 8 As shown, the average connectivity dendrogram on the embeddings of the nine class means (cophenetic correlation c=0.75, which measures how faithfully the dendrogram maintains the pairwise distances between class means) demonstrates that hierarchical clustering recovers the family structure of the action family / information family as the main axis of variation.
[0099] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A BGP community attribute semantic inference method based on dual-tower contrastive learning, characterized in that, Includes the following steps: Step S1: Obtain BGP RIB snapshots and route update data, CAIDA AS topology and business relationship data, CAIDAASRank data, PeeringDB network metadata, geolocation data, and community attribute dictionary data; Step S2: For the target community attribute (ASN,c) determined by the defined AS and its local community value, a Community Structural Inference Graph (CSIG) _c=(G_c,G_c^aux) is constructed using the (ASN,c) pair as the representation unit. Here, G_c is the Path-induced Routing Graph (PRG), and G_c^aux is the Auxiliary AS Center Topology Graph (AEG). The PRG is constructed by traversing the AS paths in each BGP update message carrying the target community attribute c, extracting directed edges between adjacent ASs hop by hop from the end of the AS path to the beginning, and accumulating dynamic counters. The AEG is constructed by deriving a 2-hop AS center topology graph centered on the defined AS and derived from the AS relationships inferred by CAIDA. Step S3: During the training phase, for the described community attributes with operator descriptions, their CSIGs are... c Input the Tuta encoder to obtain the graph embedding Z g and the corresponding operator description T c Input text tower encoder to obtain text embedding Z t For undescribed community attributes, the query graph embedding is obtained only through the Tuta encoder during the inference phase and matched with a pre-computed text library. The Tuta encoder encodes the PRG through a relational graph attention network and the AEG through a lightweight graph attention network, and then fuses the outputs of the two views through a bottleneck cross attention block. The text tower encoder encodes the standardized operator description based on a pre-trained language model. Step S4: Using the symmetric InfoNCE loss function, the graph embedding z_g and the text embedding z_t are aligned in the shared embedding space to train the parameters of the graph encoder and the text encoder; the loss function introduces a false negative example masking mechanism, an inverse frequency and focus reweighting mechanism, and a semantic family perception difficult negative sample weighting mechanism; Step S5: For the undescribed target community attribute c_query, input its CSIG into the trained Tuta encoder to obtain the query graph embedding z_g^query. Calculate the similarity between the query graph embedding and the text embeddings of each known descriptive community attribute in the pre-calculated text library. Return the Top-K known descriptive entries in order of similarity. Use the semantic category ranked first among the returned entries as the inferred semantics of the undescribed target community attribute.
2. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, In step S2, the construction of the PRG specifically includes: Initialize the node set V_c and the directed edge set. The dynamic counter δ is empty; For each BGP update message m containing the target community attribute c, traverse from the end to the beginning of its AS path and extract the directed edges (u→v) in sequence. Add the extracted nodes to V_c, and add the directed edges to... ; Based on the event type of the update message m, including notification events, explicit withdrawal events, and implicit withdrawal events, the count value of the dynamic counter δ[(u,v), event] is incremented respectively. When the directed edge When the size exceeds the preset edge budget threshold K_max=1500, the first K_max directed edges are retained from high to low according to the cumulative value of the dynamic counter δ.
3. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 2, characterized in that, In step S2, the construction of the AEG specifically includes: Obtain the AS-level business relationship graph G_CAIDA inferred by CAIDA; Using the defined AS as the central node v0, expand a 2-hop neighborhood in the G_CAIDA, and retain all nodes reachable from the central node via no more than 2 edges and the edges between them; The unfolded subgraph is used as the AEG, and a center sensing indication signal is constructed for node v in the AEG. ,in This indicates the hop count category of node v relative to the center node.
4. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, In step S3, the encoding of the PRG by the Tuta encoder specifically includes: For each node v in the PRG, a 54-dimensional node feature vector x_v is constructed, including graph theory descriptor, PeeringDB metadata, geolocation summary, ASRank statistic, center-aware indication signal and community attribute value encoding; For each directed edge e=(u,v) in the PRG, construct a 41-dimensional edge feature vector f_e, which includes AS business relationship encoding, dynamic counter, frequency statistics and infrastructure metadata; A three-layer relation graph attention network RGAT is used to pass messages to the node features and edge features. Each layer sets up self-loop relationships for 5 types of AS business relationships and maintains attention vectors for each relationship type and each attention head. After each RGAT layer, the hidden state is affinely transformed by FiLM modulation, conditioned on the community attribute value encoding. A long-range context is provided by a virtual node that connects all nodes, enabling family-level signals to reach the central node without increasing the number of layers; In multi-scale Jumping-Knowledge readout, the outputs of the three-layer RGAT are subjected to average pooling and max pooling respectively and then concatenated. The Tuta encoder encodes AEG using a 2-layer GATv2 encoding method with a width of 256→1024→256, first with 4 headers and then with 1 header, followed by global attention pooling.
5. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, In step S3, the dual-view fusion of the bottleneck cross-attention block specifically includes: Initialize K_b = 4 learnable bottleneck tokens; The learnable bottleneck token first focuses on the output of the PRG encoder through a cross-attention mechanism to aggregate community-specific routing signals; The learnable bottleneck token then focuses on the output of the AEG encoder through a cross-attention mechanism to absorb AS-level identity context; The output of the bottleneck cross-attention block is projected and combined with the output of the PRG encoder through a learnable residual gate: z_g^raw=proj(z_bottleneck) +σ(θ_res)·z_primary Where σ is the logistic sigmoid function, and θ_res is a learnable gating parameter initialized to 0.
6. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, In step S3, the text tower encoder specifically includes: The original operator description text is obtained, and the different expressions are standardized into a unified standard sentence structure using a large language model. At the same time, key information such as community attribute values, AS number, organization name and semantic subtype are retained, and the differences in parameterized semantics are maintained. MPNet-base-v2 was used as the pre-trained language model. The model contains a 12-layer Transformer structure with a hidden layer width of 768. The parameters of the bottom 10 layers of the MPNet-base-v2 are frozen, and only the parameters of the last 2 layers are fine-tuned with a low learning rate, which is about 1 / 34 of the Tuta learning rate; The last hidden state is masked and averaged pooled to exclude padding tokens, resulting in a sentence-level representation. It is then projected onto a shared 256-dimensional space through two layers of MLP and subjected to L2 normalization.
7. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, In step S4, the false negative example masking mechanism specifically includes: For the i-th and j-th samples in the batch, calculate the MPNet cosine similarity between their operator descriptions; When i=j, M ij Set to 1; when i ≠ j and the cosine similarity exceeds a preset threshold. At that time, the mask matrix M ij Set M to 0; otherwise, set M to 0. ij Set to 1; In the InfoNCE loss calculation, the mask matrix M is used to exclude graph-text pairs that satisfy M_ij=0 as neither positive nor negative examples.
8. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, In step S4, the inverse frequency and focus reweighting mechanism specifically includes: Calculate the empirical frequency f(T_i) of the descriptive text for each operator and the empirical frequency f_cat(cat_i) of its semantic category; The inverse frequency weight for each sample is calculated as 1 / √(f(T_i)·f_cat(cat_i)); The focus weight for each sample is calculated as follows: max((1-p_pos^(i))^γ, 0.01) Where p_pos^(i) is the positive probability after masking, and γ=1.5 is the focal index; Combining the inverse frequency weights and the focal weights yields the sample-by-sample triplet weights: w_i = [1 / √(f(T_i)·f_cat(cat_i))]·max((1-p_pos^(i))^γ, 0.01) ; The symmetric InfoNCE loss is weighted by the sample-by-sample triplet weight w_i.
9. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, In step S4, the semantic family perception difficulty negative sample weighting mechanism specifically includes: Determine the semantic family to which the target community attribute c belongs, the semantic family including action families and information families; For a pair of samples from the same definition AS and i≠j, if they belong to different semantic families, then R ij =1.0; if both belong to the same semantic family, then R ij =0.3; the remaining samples for R ij =0; In the denominator of the InfoNCE loss, the similarity contribution of each negative sample is reweighted using the inter-group weight R_ij.
10. The BGP community attribute semantic inference method based on dual-tower contrastive learning according to claim 1, characterized in that, Step S5, the similarity calculation and ranking specifically includes: Pre-compute text embeddings for all known descriptions of community attributes in the training set, and construct a text library. G_text={TextTower (T_c;θ_t*):c∈D_train} ; For the query community attribute c_query, calculate the cosine similarity between the query graph embedding z_g^query and each text embedding in the text library; Sort the entries in the text library from high to low according to cosine similarity, and return the Top-K entries; The semantic category corresponding to the Top-1 entry is read as the inferred semantics of the query community attribute; When the true intent of the query community attribute belongs to a category other than the known semantic category, its continuous embedding representation can form a corresponding semantic position in the shared embedding space, and open set semantic positioning can be achieved based on its relative position with the known semantic anchor point; Top-K retrieval returns the known description entry that is closest to it.
