A method, apparatus and electronic device for network type identification

By generating VLAN identifiers and switch trunk interface data frames that carry network type information in the network, the problem of low efficiency and adaptability of network type identification in the existing technology is solved, and the effect of automatic identification and dynamic adaptation to network changes is achieved.

CN120658642BActive Publication Date: 2026-04-03GONGSHU DISTRICT BRANCH OF HANGZHOU PUBLIC SECURITY BUREAU
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

The current network type identification relies on manual planning and configuration, which makes it difficult to dynamically adapt to network changes, resulting in low efficiency and adaptability.

Method used

By combining the Virtual Local Area Network (VLAN) identifier and the network type identifier to generate the target data frame, and by using the switch's Trunk interface to forward the data frame to explicitly carry the network type information, the switch can automatically identify the network type without manual configuration.

Benefits of technology

It improves the efficiency and adaptability of network type identification, can dynamically adapt to network changes, simplifies the network configuration process, and enhances the intelligence and policy-driven capabilities of network communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120658642B_ABST
    Figure CN120658642B_ABST
Patent Text Reader

Abstract

This application provides a network type identification method, apparatus, and electronic device. The method includes: a data transmitter acquiring a Virtual Local Area Network (VLAN) identifier and generating a target data frame based on the VLAN identifier and a pre-set network type identifier; the data transmitter sending the target data frame to a target switch, causing the target switch to forward the target data frame when the VLAN identifier configured on the Trunk interface is the VLAN identifier; and a data receiver receiving the target data frame from the target switch and parsing the network type identifier from the target data frame. The network type identifier is used to identify the network type to which the data receiver corresponding to the data transmitter belongs. By dynamically binding the network type identifier to the VLAN identifier during the generation of the target data frame, the target switch automatically identifies the network type during forwarding without requiring additional configuration on the switch, thereby improving the efficiency of network type identification and adaptability to network changes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical fields of computer networks, network communications, and network security, and more specifically, to a network type identification method, apparatus, and electronic device. Background Technology

[0002] Currently, network type identification primarily relies on manual planning and configuration, such as through IP address allocation, subnetting, or upper-layer application protocols (e.g., public security networks, railway private networks, or public networks). In actual network operation and maintenance, if the network environment changes (e.g., equipment migration or the addition of a subnet), organizations needing network access must manually consult the network operations department to determine the network type to avoid incorrectly connecting to the internet or unauthorized private networks. Therefore, current network type identification methods, dependent on manual planning and configuration, struggle to dynamically adapt to network changes, resulting in low efficiency and adaptability. Summary of the Invention

[0003] The purpose of this application is to provide a network type identification method, apparatus, and electronic device to improve the efficiency and adaptability of network type identification.

[0004] This application provides a network type identification method, comprising: a data transmitter obtaining a Virtual Local Area Network (VLAN) identifier and generating a target data frame based on the VLAN identifier and a pre-set network type identifier; the data transmitter sending the target data frame to a target switch, so that the target switch forwards the target data frame when the VLAN identifier configured on the Trunk interface is the VLAN identifier; and a data receiver receiving the target data frame from the target switch and parsing the network type identifier from the target data frame, wherein the network type identifier is used to identify the network type to which the data receiver corresponding to the data transmitter belongs. In the implementation of the above scheme, by combining the Virtual Local Area Network (VLAN) identifier and the network type identifier to generate the target data frame, the network type identifier and the VLAN identifier are effectively dynamically bound. Furthermore, by utilizing the mechanism of explicitly carrying network type information in the data frame forwarded by the Trunk interface of the switch, the target switch automatically identifies the network type during forwarding without requiring additional configuration on the switch, thereby improving the efficiency of network type identification and adaptability to network changes.

[0005] Optionally, in this embodiment, before generating the target data frame based on the VLAN ID and a pre-set network type identifier, the method further includes: the data transmitter receiving a network type identifier value sent by the network setting device, wherein the network type identifier value is obtained after a physical button on the network setting device is pressed; and the data transmitter setting the network type identifier value as the network type identifier. In the implementation of the above scheme, by introducing a mechanism for obtaining and setting the network type identifier value triggered by a physical button, users can directly set the network type identifier using a physical button, making network configuration exceptionally simple and intuitive. This scheme allows the data transmitter to receive and apply new network type identifier values ​​instantly, thereby improving adaptability to different network environment requirements.

[0006] Optionally, in this embodiment, the target switch is an aggregation switch or a core switch; the data transmitter obtains the VLAN identifier, including: the data transmitter listens to the trunk link of the aggregation switch or core switch to obtain the data link frames passing through the trunk link; the data transmitter obtains the VLAN identifier from the data link frames. In the implementation of the above scheme, by having the data transmitter actively listen to the trunk link traffic of the aggregation switch or core switch and extract the VLAN identifier from it, an intelligent identification mechanism that can automatically perceive the network VLAN structure without manual configuration or reliance on control protocols is realized. This enables the data transmitter to dynamically and in real time adapt to VLAN configuration changes in complex network environments, avoiding communication failures caused by manual configuration errors or configuration delays in traditional methods. At the same time, since aggregation and core switches typically carry traffic from multiple VLANs, this method has good generalization ability and is suitable for large-scale network scenarios with multiple VLANs coexisting and frequent topology changes, significantly improving the intelligence level of device access and network adaptability.

[0007] Optionally, in this embodiment, the data transmitter obtains the VLAN ID by: acquiring all trunk interface numbers of the target switch and a historical link dataset; performing an initial prediction of the VLAN ID value configured for all trunk interface numbers based on the historical link dataset to obtain an initial predicted VLAN ID value; and performing a second prediction of the initially predicted VLAN ID value based on the historical link dataset to obtain the VLAN ID number. In the implementation of the above scheme, the data transmitter obtains all trunk interface numbers of the target switch and a historical link dataset, and performs an initial and second prediction of the VLAN ID value based on this dataset to obtain the final VLAN ID number. This method overcomes the limitations of traditional methods that rely on static configuration or control protocols (such as LLDP and CDP) to obtain VLAN information, achieving automatic and intelligent identification of the VLAN ID actually carried in the network without relying on device management permissions and the control plane. By introducing a "two-stage prediction mechanism" based on historical link data, not only is the accuracy of VLAN identification improved, but the system's adaptability to dynamic network changes (such as VLAN drift and trunk configuration changes) is also enhanced.

[0008] Optionally, in this embodiment, re-predicting the initially predicted VLAN identifier value based on the historical link dataset includes: randomly generating a VLAN identifier population within a preset range of VLAN identifier values, the VLAN identifier population including multiple candidate VLAN identifiers; updating the VLAN identifier population based on the initially predicted VLAN identifier value to obtain an updated numerical population; calculating the fitness value of each candidate VLAN identifier in the updated numerical population based on the historical link dataset; determining the optimal VLAN identifier value from the multiple candidate VLAN identifiers in the updated numerical population based on the fitness value of each candidate VLAN identifier; iteratively calculating the updated numerical population based on the optimal VLAN identifier value until the fitness value of the optimal VLAN identifier value is less than a preset threshold, thus obtaining the VLAN identifier. In the implementation of the above scheme, a trunk interface may carry multiple VLANs. The initial prediction may be inaccurate, but through multiple iterations and fitness evaluations, even if there are misconfigurations or VLAN drift, the final result can be ensured to have a high degree of confidence. Therefore, by combining the initial prediction and the fitness of multiple iterations for re-prediction, the optimal VLAN ID number that is "most frequently occurring" or "most representative" can be dynamically adjusted and locked.

[0009] Optionally, in this embodiment, generating a target data frame based on the VLAN identifier and a pre-set network type identifier includes: constructing a standard Ethernet frame, adding a four-byte VLAN tag field between the source address field and the protocol type field of the standard Ethernet frame, and writing the VLAN identifier into the VLAN tag field; and writing the network type identifier into the data field of the standard Ethernet frame. In the implementation of the above scheme, by inserting a VLAN tag field between the source address and protocol type fields of the standard Ethernet frame and writing the VLAN identifier, while embedding the network type identifier into the data field, a lightweight, highly compatible data frame encapsulation mechanism with semantic extension capabilities is achieved. This mechanism effectively reuses the blank areas and data fields in the existing frame structure, enabling the target switch to identify the logical network type to which the data frame belongs while forwarding VLAN traffic normally. This achieves implicit transmission and automatic parsing of information such as device identity, network policy, and quality of service, greatly enhancing the intelligence and policy-driven capabilities of network communication.

[0010] Optionally, in this embodiment, generating a target data frame based on the VLAN identifier and a pre-set network type identifier includes: determining whether the target switch is multiple switches, where the target switches are all switches connected by the trunk link in the current network; if so, setting the destination MAC address of the target data frame to a pre-built multicast MAC address so that multiple switches can receive the target data frame. In the implementation of the above scheme, by determining whether there are multiple target switches when generating the target data frame and setting the destination MAC address to a multicast MAC address based on the determination result, an intelligent broadcast-style network detection and information synchronization mechanism is implemented. This enables simultaneous communication with all connected switches on the trunk link without relying on control protocols or a centralized controller, utilizing the standard Ethernet frame structure and multicast mechanism. This ensures that multiple devices in the network can synchronously receive and process key information containing the VLAN identifier and network type identifier, improving network discovery and configuration efficiency and enhancing network topology awareness.

[0011] This application embodiment also provides a network type identification device, including: a target data frame generation module, used by a data transmitter to obtain a Virtual Local Area Network (VLAN) identifier and generate a target data frame based on the VLAN identifier and a pre-set network type identifier; a target data frame sending module, used by the data transmitter to send the target data frame to a target switch, so that the target switch forwards the target data frame when the VLAN identifier configured on the Trunk interface is the VLAN identifier; and a target data frame receiving module, used by a data receiver to receive the target data frame from the target switch and parse the network type identifier from the target data frame, the network type identifier being used to identify the network type to which the data receiver corresponding to the data transmitter belongs.

[0012] Optionally, in this embodiment of the application, the network type identification device further includes: a network type identifier receiving module, used for the data transmitter to receive a network type identifier value sent by the network setting device, wherein the network type identifier value is obtained after a physical button on the network setting device is pressed; and a network type identifier setting module, used for the data transmitter to set the network type identifier value as a network type identifier.

[0013] Optionally, in this embodiment of the application, the target switch is an aggregation switch or a core switch; the target data frame generation module includes: a Trunk link monitoring submodule, used by the data transmitter to monitor the Trunk link of the aggregation switch or the core switch and obtain the data link frames passing through the Trunk link; and a VLAN identifier acquisition submodule, used by the data transmitter to obtain the VLAN identifier from the data link frame.

[0014] Optionally, in this embodiment, the target data frame generation module includes: a link dataset acquisition submodule, used by the data transmitter to acquire all Trunk interface numbers of the target switch and historical link datasets; a VLAN identifier prediction submodule, used by the data transmitter to perform an initial prediction of the VLAN identifier values ​​configured for all Trunk interface numbers based on the historical link datasets, and obtain an initial predicted VLAN identifier value; and a VLAN identifier acquisition submodule, used by the data transmitter to perform a second prediction of the initially predicted VLAN identifier value based on the historical link datasets, and obtain a VLAN identifier number.

[0015] Optionally, in this embodiment, the VLAN identifier acquisition submodule includes: an identifier population generation unit, configured to randomly generate a VLAN identifier population within a preset range of VLAN identifier values, the VLAN identifier population including multiple candidate VLAN identifiers; an identifier population update unit, configured to update the VLAN identifier population based on the initially predicted VLAN identifier value to obtain an updated numerical population; a fitness value calculation unit, configured to calculate the fitness value of each candidate VLAN identifier in the updated numerical population based on a historical link dataset; an optimal identifier determination unit, configured to determine the optimal VLAN identifier value from the multiple candidate VLAN identifiers in the updated numerical population based on the fitness value of each candidate VLAN identifier; and a VLAN identifier acquisition unit, configured to iteratively calculate the updated numerical population based on the optimal VLAN identifier value until the fitness value of the optimal VLAN identifier value is less than a preset threshold, and then obtain the VLAN identifier.

[0016] Optionally, in this embodiment, the identifier population update unit includes: an identifier population mutation subunit, used to mutate the VLAN identifier population within a preset range of VLAN identifier values ​​to obtain multiple mutated VLAN identifier values; an identifier set filtering subunit, used to filter out the optimal VLAN identifier value from the set of the initially predicted VLAN identifier value and the multiple mutated VLAN identifier values; and an identifier cross-learning subunit, used to cross-learn the optimal VLAN identifier value and each mutated VLAN identifier value among the multiple mutated VLAN identifier values.

[0017] Optionally, in this embodiment, the optimal identifier determination unit includes: a fitness value judgment subunit, used to determine whether the fitness value of each candidate VLAN identifier in the updated numerical population is greater than the fitness value of the optimal VLAN identifier calculated in the previous iteration; and an optimal identifier determination subunit, used to determine the candidate VLAN identifier as the optimal VLAN identifier if the fitness value of the candidate VLAN identifier is greater than the fitness value of the optimal VLAN identifier calculated in the previous iteration, and to determine the optimal VLAN identifier calculated in the previous iteration as the optimal VLAN identifier if the fitness value of the candidate VLAN identifier is less than or equal to the fitness value of the optimal VLAN identifier calculated in the previous iteration.

[0018] Optionally, in this embodiment of the application, the target data frame generation module includes: an Ethernet frame construction submodule, used to construct a standard Ethernet frame, and a VLAN identifier writing submodule, used to add a four-byte VLAN tag field between the source address field and the protocol type field of the standard Ethernet frame, and write the VLAN identifier number into the VLAN tag field; and a type identifier writing submodule, used to write the network type identifier into the data field of the standard Ethernet frame.

[0019] Optionally, in this embodiment of the application, the target data frame generation module includes: a target switch determination submodule, used to determine whether the target switch is multiple switches, wherein the target switches are all switches connected by the trunk link in the current network; and a data frame generation and transmission submodule, used to set the destination MAC address of the target data frame to a pre-built multicast MAC address if the target switch is multiple switches, so that multiple switches can receive the target data frame.

[0020] This application also provides an electronic device, including a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the machine-readable instructions are executed by the processor to perform the methods described above.

[0021] This application also provides a computer-readable storage medium storing a computer program, which is executed by a processor to perform the methods described above.

[0022] This application also provides a computer program product, including: a computer program or computer instructions, which are executed by a processor to perform the method described above. Attached Figure Description

[0023] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 The diagram shown is a flowchart of the network type identification method provided in an embodiment of this application;

[0025] Figure 2 The diagram shown is a schematic representation of the field structure of the target data frame provided in an embodiment of this application.

[0026] Figure 3 The diagram shown is a structural schematic of the network type identification device provided in an embodiment of this application;

[0027] Figure 4 The diagram shows a structural schematic of an electronic device provided in an embodiment of this application. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in the embodiments of this application are for illustrative and descriptive purposes only and are not intended to limit the protection scope of the embodiments of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in the embodiments of this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of the embodiments of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0029] Furthermore, the described embodiments are merely a part of the embodiments of this application, and not all of them. The components of the embodiments of this application described and illustrated herein can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed embodiments of this application, but merely to illustrate selected embodiments of this application.

[0030] It is understood that the terms "first" and "second" in the embodiments of this application are used to distinguish similar objects. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different. In the description of the embodiments of this application, the term "and / or" is merely a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship. The term "multiple" refers to two or more (including two), and similarly, "multiple groups" refers to two or more groups (including two groups).

[0031] It should be noted that the network type identification method provided in this application embodiment can be executed by an electronic device. Here, electronic device refers to a device terminal with the function of executing computer programs or the aforementioned server. Device terminals include, for example, smartphones, personal computers, tablets, personal digital assistants, or mobile internet devices. Servers refer to devices that provide computing services through a network. Servers include, for example, x86 servers and non-x86 servers. Non-x86 servers include, for example, mainframes, minicomputers, and UNIX servers.

[0032] Currently, network type identification primarily relies on manual planning and configuration. This is achieved through methods such as IP address allocation, subnetting, or upper-layer application protocols. For example, a separate IP address range might be allocated to the public security network (10.1.0.0 / 16), the railway private network (10.2.0.0 / 16), and the audio / video private network (192.168.1.0 / 24). To differentiate between these private networks (such as public security, railway, and general public networks), network administrators need to pre-plan subnets for these IP address ranges based on the organization's needs and configure corresponding routing rules to ensure they don't conflict. This requires specialized network knowledge to correctly configure subnets on routers and switches. However, in actual network operation and maintenance, changes to the network environment (such as equipment migration or the addition of a subnet) necessitate adjustments to the existing IP address allocation scheme, including updating the DHCP server configuration and modifying the routing tables of routers and switches. If an organization needs to access a network, it must consult with the network operations and maintenance administrator to determine the network type in order to avoid accidentally connecting to the internet or an unauthorized private network. Therefore, current network type identification relies on manual planning and configuration, and is difficult to dynamically adapt to network changes, resulting in low efficiency and adaptability.

[0033] To improve the above issues, please see Figure 1 The illustrated flowchart illustrates the network type identification method provided in this application embodiment. The main idea of ​​this method is to generate a target data frame by combining a Virtual Local Area Network (VLAN) identifier and a network type identifier. This effectively and dynamically binds the network type identifier to the VLAN identifier. Furthermore, by utilizing the mechanism of explicitly carrying network type information in the data frame forwarded via the trunk interface of the switch, the target switch automatically identifies the network type during forwarding. This eliminates the need for manual IP subnet planning or additional switch configuration. The network type identifier can be used to display the network type at the data receiving end, thereby improving the efficiency of network type identification and its adaptability to network changes. The implementation of the above-described network type identification method may include:

[0034] Step S110: The data transmitter obtains the VLAN ID and generates a target data frame based on the VLAN ID and the pre-set network type identifier.

[0035] A data transmitter is a device in a network that is responsible for generating and sending data frames in a preset format. For example, a data transmitter set in the core layer or aggregation layer of the network can be used to broadcast data frames containing specific information (such as VLAN ID and network type identifier) ​​to the entire network.

[0036] A Virtual Local Area Network (VLAN) is a communication technology that logically divides a physical LAN into multiple broadcast domains. Each VLAN is a broadcast domain. Hosts within a VLAN can communicate directly, but hosts in different VLANs cannot communicate directly with each other, thus restricting broadcast messages to a single VLAN.

[0037] A VLAN ID (VID) is a number used to uniquely identify a virtual local area network. In VLAN configuration, each VLAN has a unique VID to identify the identity and attributes of that VLAN.

[0038] A network type identifier is a symbol used to identify a specific network (such as a public security network, a railway private network, or a social network). It's understandable that this network type identifier can be defined according to specific circumstances. For example, in the data field of a network packet (i.e., the Data field in the diagram), a string like `deviceType:1\r\n` can be added to represent the network type, thus enabling the marking of various network types such as public security networks, railway private networks, and social networks. Here, `deviceType:1\r\n` represents a public security network, `deviceType:2\r\n` represents a railway private network, `deviceType:3\r\n` represents a social network, and so on.

[0039] Step S120: The data transmitter sends a target data frame to the target switch so that the target switch forwards the target data frame when the VLAN identifier configured on the Trunk interface is the VLAN identifier number.

[0040] The target switch refers to the switch that needs to identify the network type, such as a core layer switch or an aggregation layer switch deployed in the network, and can decide whether to forward the frame to the corresponding VLAN based on the VLAN ID in the received data frame.

[0041] A Trunk interface is a special network interface configuration that allows multiple VLANs of data traffic to be transmitted simultaneously over a single physical link, whereas the core layer switches or aggregation layer switches mentioned above typically allow data frames to be forwarded across multiple VLANs.

[0042] Step S130: The data receiving end receives the target data frame from the target switch and parses the network type identifier from the target data frame. The network type identifier is used to identify the network type to which the data receiving end belongs, corresponding to the data transmitting end.

[0043] A data receiver is a device in a network that is responsible for receiving and parsing target data frames. It can typically be an end-user device, a monitoring system, or other application that needs to know the current network type.

[0044] Because VLANs inherently possess network isolation capabilities, by combining the Virtual Local Area Network (VLAN) identifier and the network type identifier to generate target data frames, the network type identifier and the VLAN identifier can be dynamically bound. This ensures that the target switch will only forward data frames when a specific VLAN configuration is matched, thereby achieving fine-grained access control based on VLANs. Furthermore, it can prevent unauthorized devices from accessing the network through incorrect VLAN interfaces, ultimately improving the protection capabilities for sensitive network areas (such as public security private networks or government intranets).

[0045] In the implementation of the above scheme, the target data frame is generated by combining the Virtual Local Area Network (VLAN) identifier and the network type identifier, so as to effectively bind the network type identifier with the VLAN identifier dynamically. The mechanism of explicitly carrying network type information in the data frame forwarding by the trunk interface of the switch is utilized, so that the target switch can automatically identify the network type when forwarding without additional configuration on the switch, thereby improving the efficiency of network type identification and adaptability to network changes.

[0046] As an optional implementation of the above-mentioned network type identification method, before generating the target data frame based on the VLAN ID and the pre-set network type identifier, the network type identifier can also be set via a physical button. This implementation may include:

[0047] Step S101: The data transmitter receives the network type identifier value sent by the network setting device. The network type identifier value is obtained after the physical button on the network setting device is pressed.

[0048] An example implementation of step S101 above is as follows: After a user presses a physical button labeled with the network type on the network setting device, the network setting device, in response to the user's press operation, can first obtain the network type identifier value corresponding to the physical button, and then send the network type identifier value corresponding to the physical button to the data transmitter. The data transmitter and the network setting device can communicate via an RS-485 interface or a serial port, and the data transmitter can receive the network type identifier value sent by the network setting device via an RS-485 interface or a serial port. The network type identifier value is obtained after the physical button on the network setting device is pressed. This method of inputting the network type identifier using a physical button can, to some extent, prevent unauthorized network type modification. Since physical buttons typically have high security (e.g., concealed location, requiring physical contact), this provides an additional layer of security for network access.

[0049] Step S102: The data transmitter sets the network type identifier value to the network type identifier.

[0050] For example, in step S102, after receiving the network type identifier value sent by the network setting device via an RS-485 interface or serial port, the data transmitter can set the received network type identifier value as a network type identifier and store it in a configuration file or configuration database. In this implementation, the user only needs to press the corresponding physical button to quickly complete the network type setting. Furthermore, when the working environment changes, the network type can be updated simply by pressing a button, which helps improve the device's compatibility and adaptability to different network conditions. This method is particularly suitable for environments requiring frequent network environment adjustments or temporary network deployment scenarios, greatly simplifying the network management process and lowering the operational threshold.

[0051] As an optional implementation of step S110 above, the target switch can be an aggregation switch or a core switch; the implementation of the data transmitter obtaining the VLAN identifier can include:

[0052] Step S111: The data transmitter listens to the trunk link of the aggregation switch or core switch to obtain the data link frames passing through the trunk link.

[0053] An example implementation of step S111 above is as follows: A data transmitter is deployed on the trunk link of the aggregation switch or core switch. The data transmitter can use packet capture software tools such as Wireshark or Tcpdump to monitor the trunk link of the aggregation switch or core switch and obtain the data link frames passing through the trunk link. Taking the Tcpdump software tool as an example, the command `tcpdump -i eth0 -w trunk_traffic.pcap` can be used to monitor the trunk link of the aggregation switch or core switch.

[0054] Step S112: The data transmitter obtains the VLAN identifier from the data link frame.

[0055] For example, in the implementation of step S112 above, the data transmitter extracts the 802.1Q VLAN tag from the data link frame and extracts the VLAN identifier (i.e., the VID value) from the 802.1Q VLAN tag.

[0056] As an optional implementation of step S110 above, the implementation method for the data transmitter to obtain the VLAN identifier may include:

[0057] Step S113: The data transmitter obtains all Trunk interface numbers of the target switch, as well as the historical link dataset.

[0058] For example, in the implementation of step S113 above: after the data transmitter listens to a segment of data on the trunk link of the aggregation switch or core switch, it can obtain the historical link dataset and all trunk interface numbers of the target switch. Here, the all trunk interface numbers of the target switch can be pre-configured, or they can be analyzed and extracted from the historical link dataset.

[0059] Step S114: The data transmitter performs an initial prediction of the VLAN identifier value configured for all Trunk interface numbers based on the historical link dataset, and obtains the initial predicted VLAN identifier value.

[0060] Initial prediction refers to the data transmitter making a preliminary estimate of the set of VLAN IDs that may be carried on a certain Trunk interface based on information such as traffic patterns, protocol types, and source / destination MAC address distribution observed in historical link data.

[0061] For example, if Trunk interface A has transmitted a large number of ARP requests (MAC address 00:11:22:33:44:55) from a private network system in the past week's historical link dataset, analyzing this historical link dataset using a large language model can infer that the initial predicted VLAN ID value for Trunk interface A is VLAN 10. This large language model is a deep learning network model fine-tuned using the historical link dataset.

[0062] Step S115: The data transmitter re-predicts the initially predicted VLAN identifier value based on the historical link dataset to obtain the VLAN identifier number.

[0063] As an optional implementation of step S115 above, since the initial prediction may contain errors, such as multiple VLANs sharing the same trunk port, device misconfiguration, or VLAN drift, it is necessary to re-predict the initially predicted VLAN identifier value based on historical link datasets. The above-mentioned implementation of re-predicting the initially predicted VLAN identifier value based on historical link datasets may include:

[0064] Step S115a: Randomly generate a VLAN identifier population within a preset range of VLAN identifier values. The VLAN identifier population includes multiple candidate VLAN identifiers.

[0065] For example, the implementation of step S115a above is as follows: Since the VLAN ID range is usually 1~4094, multiple VLAN ID groups can be randomly generated within the range of 1~4094. Each VLAN ID group can include multiple candidate VLAN ID numbers. For example, one of the VLAN ID groups can include [1003, 3021, 456, 2100, 789, 100, 3999, 2000, 150, 888].

[0066] Step S115b: Update the VLAN identifier population based on the initial predicted VLAN identifier value to obtain the updated value population.

[0067] An optional implementation of step S115b above includes, for example: using the initially predicted VLAN identifier value as a seed for mutation, and mutating the VLAN identifier population within a preset range of VLAN identifier values ​​to obtain multiple mutated VLAN identifier values. Then, selecting the optimal VLAN identifier value from the set of the initially predicted VLAN identifier value and the multiple mutated VLAN identifier values. Finally, performing cross-learning on the optimal VLAN identifier value and each of the multiple mutated VLAN identifier values.

[0068] Step S115c: For each candidate VLAN ID in the updated numerical population, calculate the fitness value of the candidate VLAN ID based on the historical link dataset.

[0069] An optional implementation of step S115c above is as follows: For each candidate VLAN ID in the updated numerical population, the frequency of occurrence of each VLAN ID is calculated using historical link data. Then, each candidate VLAN ID is weighted and sampled according to its frequency of occurrence to obtain its fitness value. It is understood that the fitness value is typically derived from a weighted calculation of VLAN occurrence frequency, communication mode, device behavior, and other information in the historical link data. The specific weighting metric can be set based on the network communication data in the historical link data. Therefore, a VLAN ID with high fitness is more likely to represent the "mainstream VLAN" carried on the current Trunk interface, thereby improving prediction accuracy.

[0070] Step S115d: Determine the optimal VLAN ID value from multiple candidate VLAN IDs in the updated numerical population based on the fitness value of each candidate VLAN ID.

[0071] An optional implementation of step S115d above is as follows: Multiple candidate VLAN IDs in the updated numerical population are sorted from highest to lowest fitness value, and the VLAN ID with the highest fitness value is selected as the "optimal VLAN ID value" in the current iteration. It can be understood that the goal of step S115d is to find the candidate value most likely to represent the true target VLAN ID from the current population; this is the core step in implementing the "survival of the fittest" mechanism in the entire genetic algorithm process. A higher fitness value indicates that the candidate VLAN ID more closely matches the traffic characteristics in the historical link dataset, and therefore is more likely to be the correct VLAN ID.

[0072] Step S115e: Iteratively calculate the updated numerical population based on the optimal VLAN identifier value until the fitness value of the optimal VLAN identifier value is less than a preset threshold, and then obtain the VLAN identifier number.

[0073] An optional implementation of step S115e above is as follows: For each candidate VLAN ID in the updated numerical population, determine whether the fitness value of the candidate VLAN ID is greater than the fitness value of the optimal VLAN ID calculated in the previous iteration. If the fitness value of the candidate VLAN ID is greater than the fitness value of the optimal VLAN ID calculated in the previous iteration, then the candidate VLAN ID is determined as the optimal VLAN ID. If the fitness value of the candidate VLAN ID is less than or equal to the fitness value of the optimal VLAN ID calculated in the previous iteration, then the optimal VLAN ID calculated in the previous iteration is determined as the optimal VLAN ID.

[0074] In implementing the above scheme, by combining the initial prediction with the fitness of multiple iterations for further prediction, the "most frequently occurring" or "most representative" VLAN ID can be dynamically adjusted and locked. Because in a real network, a trunk interface may carry multiple VLANs, the initial prediction may be inaccurate. However, through multiple iterations and fitness evaluations, even with misconfigurations or VLAN drift, the final result can be ensured to have a high degree of confidence. Therefore, by combining the initial prediction with the fitness of multiple iterations for further prediction, the optimal VLAN ID that is "most frequently occurring" or "most representative" can be dynamically adjusted and locked.

[0075] Please see Figure 2The diagram illustrates the field structure of a target data frame provided in this embodiment of the application. The target data frame is a data frame (e.g., an Ethernet frame) constructed by the data transmitter based on the VLAN ID and network type identifier. While conforming to the IEEE 802.1Q standard, this target data frame may insert a 4-byte VLAN tag (i.e., the 802.1Q Tag in the diagram) between the source address and protocol type. The target data frame may include: a 6-byte destination address, a 6-byte source address, a 4-byte VLAN tag (802.1Q Tag), a 2-byte length / type field, a 42-1500-byte data field, and a 4-byte Frame Check Sequence (FCS). The FCS provides a method for the receiving network card to determine if a transmission error has occurred. If an error is detected, the frame is discarded. Specifically, a Cyclic Redundancy Check (CRC) can be used, such as the CRC-32 algorithm, for frame verification. The VLAN tags mentioned above may include: Tag Protocol Identifier (TPID), frame priority (PRI), Canonical Format Indicator (CFI), and VLAN ID (VID).

[0076] As an optional implementation of step S110 above, the implementation of generating the target data frame based on the VLAN identifier and the pre-set network type identifier may include:

[0077] Step S116: Construct a standard Ethernet frame, add a four-byte VLAN tag field between the source address field and the protocol type field of the standard Ethernet frame, and write the VLAN identifier into the VLAN tag field.

[0078] For example, the implementation of step S116 above involves constructing an Ethernet frame that conforms to the IEEE 802.1Q standard, and then adding a four-byte VLAN tag (i.e., the 802.1Q Tag in the figure) between the source address field (i.e., the Source Address in the figure) and the protocol type (i.e., the Length / Type in the figure) field of the standard Ethernet frame. This VLAN tag is used to identify the VLAN logical area type in which different networks are located.

[0079] Step S117: Write the network type identifier into the data field of the standard Ethernet frame.

[0080] For example, step S117 can be implemented as follows: Taking the network type identifier as a string like `deviceType:1\r\n`, the string can be written into the data field of a standard Ethernet frame (i.e., the Data field in the diagram). The "1" in `deviceType:1\r\n` can represent a public security network, or it can be replaced with `deviceType:2\r\n`. The "2" in `deviceType:2\r\n` can represent a railway private network, or it can be replaced with `deviceType:3\r\n`, where "3" can represent a social network, etc. Then, the VLAN identifier is written into the VLAN tag field.

[0081] As an optional implementation of step S110 above, the implementation of generating the target data frame based on the VLAN identifier and the pre-set network type identifier may include:

[0082] Step S118: Determine whether the target switch is multiple switches. The target switch is all switches connected by trunk links in the current network.

[0083] Understandably, since Trunk links encapsulate and forward multi-VLAN data through the IEEE 802.1Q standard, Trunk link channels can carry multicast packets. Thus, the 802.1Q tagging mechanism ensures that the network type identifier in the multicast packet is transmitted across network segments in a multi-VLAN environment. This combination of the VLAN tag of the multicast frame and the custom network type field breaks through the limitation of traditional multicast packets propagating in a single broadcast domain, thereby realizing the function of transmitting the network type identifier across multiple VLANs.

[0084] Step S119: If the target switch is multiple switches, set the destination MAC address of the target data frame to the pre-built multicast MAC address so that multiple switches can receive the target data frame.

[0085] An example implementation of step S119 above is as follows: For multiple switches, multicast addresses are constructed (e.g., destination MAC addresses in the range 01:00:5E:xx:xx:xx). Then, when generating target data frames based on the VLAN ID and a pre-set network type identifier, a target data frame needs to be generated for each VLAN ID in each of the multiple switches, based on that VLAN ID and the network type identifier. This results in multiple target data frames, where each target data frame corresponds to a VLAN ID. Finally, the destination MAC address of each target data frame is set to the multicast MAC address, enabling the target data frames containing the network type identifier to propagate to the multiple switches in the network. This ensures that all switches can receive the target data frames, thus identifying the network type of the current network based on the target data frames containing the network type identifier.

[0086] As an optional implementation of step S120 above, for example: assuming that two private network VLANs, VLAN 10 and VLAN 20, are configured in the network, and the VLAN identifier value configured on the trunk interface of the target switch is VLAN 10, if the VLAN identifier in the target data frame sent by the data transmitter to the target switch is VLAN 10, then the target switch can determine that the VLAN identifier value configured on the trunk interface is VLAN 10 in the target data frame, and therefore should forward the target data frame. Similarly, if the VLAN identifier in the target data frame sent by the data transmitter to the target switch is VLAN 20, then the target switch can determine that the VLAN identifier value configured on the trunk interface is VLAN 10 in the target data frame, not VLAN 20, and therefore should not forward the target data frame, but should discard it. In the implementation of the above scheme, a target data frame containing a network type identifier is generated by the data transmitter, so that the data receiver can determine the "network identity" of the data source based on the network type identifier. This lightweight device identity authentication mechanism can be used for device classification and service distribution in scenarios such as edge computing and the Internet of Things, so as to achieve basic-level trusted device access without introducing a complex encryption system, and effectively build a network identity authentication mechanism for cross-switch device collaboration.

[0087] As an optional implementation of step S130 above, for example: the data receiving end receives the target data frame from the target switch through the User Datagram Protocol (UDP), parses the network type identifier "deviceType:1\r\n" from the data field of the target data frame, and can use the network type identifier "deviceType:1\r\n" to identify that the network type of the data receiving end corresponding to the data transmitting end is 1, where "1" in "deviceType:1\r\n" can represent the public security network.

[0088] Optionally, after parsing the network type identifier, the data receiving end can also trigger preset network service policies accordingly, such as: directing traffic from the "public security network" to the firewall for deep inspection, or restricting traffic or forcing portal authentication for the "guest network", thereby realizing the linkage control between network type and service quality policies.

[0089] It is understandable that the aforementioned data transmitter and data receiver together constitute a portable network environment detection tool. The data transmitter and data receiver of this tool can be developed based on a customized embedded platform, such as customizing an open-source operating system to obtain a customized operating system. Then, the customized operating system is run in a microcontroller so that the tool can efficiently send and receive data frames.

[0090] In the specific use of the aforementioned portable network environment detection tool, the tool's data transmitter can be directly deployed at the trunk interface of a network switching node (such as an aggregation switch or a core switch). The data transmitter periodically sends (multicast or broadcast) target data frames carrying VLAN identifiers and network type identifiers. This allows for quick and portable network type identification without requiring IP address configuration, subnet planning, or complex debugging. When network type identification is needed, the user simply uses the tool's data receiver to receive the target data frame at the network interface of a terminal device (e.g., a personal computer). The network type identifier is then parsed from the target data frame, allowing identification of the accessed network type without IP address configuration or complex debugging. This reduces reliance on professional network administrators. This plug-and-play feature without IP configuration and the dynamic VLAN matching mechanism significantly improve the efficiency and adaptability of network type identification.

[0091] Optionally, in some public security private network scenarios requiring protection against malicious interference, since the VID field of the VLAN tag (802.1QTag) is publicly available (12 bits, range 1~4094), attackers can directly construct frames with the same VID without cracking the protocol. In this case, an attacker might construct a VLAN tag identical to that of a legitimate packet (VID=100), thus forging a legitimate identity to send interference frames. The switch will forward the data frame to the corresponding VLAN port based on the same VLAN tag (VID=100). Therefore, the attacker's interference frame will be forwarded normally to the target VLAN, making it impossible for the receiving end to distinguish between legitimate and illegitimate traffic. Furthermore, if an attacker sends a large number of forged (VID=100) data frames, the receiving end may experience a flooding or dropping of legitimate data frames due to processing priority issues (such as HMAC verification delays).

[0092] To address the aforementioned issues, if it's necessary to prevent attackers from forging interference frames with the same VID but different network type identifiers, dynamic frequency hopping can be used to set VLAN IDs. This replaces the method of sending multicast packets with fixed VLAN tags (e.g., VID=100), enhancing the security of this network type identification method in public security network scenarios. The core idea of ​​dynamic frequency hopping is that, with clocks aligned, all three components of the network—the switch, the transmitter, and the receiver—are pre-configured with the same non-contiguous VID sequence. The receiver calculates the start of the frequency hopping period using the transmission timestamp and determines the true VID used by the transmitter based on the hopping period, effectively filtering out delayed or forged interference frames. The transmitter and receiver can be clock-aligned using a high-precision time synchronization protocol (such as PTP or NTP).

[0093] For example, assuming the frequency hopping period is 10 seconds, and the data transmitter and receiver are clock-aligned, the transmitter determines the current frequency hopping period to be 1 based on the current time (e.g., 5 seconds). Then, based on the current frequency hopping period, it can determine the currently used VID as 1003 from a pre-set sequence of identical non-contiguous VIDs, such as [1003, 3021, 456, 2100, 789, 100, 3999, 2000, 150, 888]. Then, based on the currently used VID (1003) and the pre-set network type identifier "deviceType:1\r\n", a target data frame is generated and sent to the target switch. Since the target switch has already pre-set the same non-contiguous VID sequence, it will directly forward the target data frame to the data receiver. When the data receiver receives the target data frame, it first generates a received timestamp for the target data frame and calculates the start time of the frequency hopping period as 0 seconds based on this timestamp. Then, based on the start time of the frequency hopping period being 0 seconds, it determines that the current frequency hopping period is 1. Finally, based on the current frequency hopping period, it determines the currently used VID as 1003 from a pre-set identical non-contiguous VID sequence such as [1003, 3021, 456, 2100, 789, 100, 3999, 2000, 150, 888]. The aforementioned non-contiguous VID sequence can be generated using encryption algorithms (such as AES), and the length of the VID sequence can be set according to security requirements.

[0094] It's easy to understand that the principle of the next frequency hopping cycle is similar. The data transmitter determines the current frequency hopping cycle as 2 based on the current time point (e.g., 14 seconds). Then, based on the current frequency hopping cycle, it determines the currently used VID as 3021 from a pre-set sequence of identical non-contiguous VIDs, such as [1003, 3021, 456, 2100, 789, 100, 3999, 2000, 150, 888]. Then, based on the currently used VID (3021) and the pre-set network type identifier "deviceType:1\r\n", it generates a target data frame and sends the target data frame to the target switch. This allows the target switch to forward the target data frame when the VLAN identifier is included in the pre-set sequence of identical non-contiguous VIDs. Optionally, after the data receiver calculates the start time of the frequency hopping period as 10 seconds based on the received timestamp, it can also filter out delayed or forged interference frames based on the difference between the received timestamp and the start timetamp. For example, if the difference between the received timestamp and the start timetamp is greater than a preset threshold (such as 100 milliseconds), the target data frame is discarded, thereby filtering out delayed or forged interference frames.

[0095] In the above scheme, since attackers cannot know the next hop in advance without obtaining a non-continuous VID sequence, they need to monitor multiple VLAN channels in real time in order to carry out attack plans or interference operations. This dynamic frequency hopping method can effectively increase the difficulty for attackers, thereby enhancing the security of this network type identification method in public security private network scenarios.

[0096] Optionally, to further enhance the security of this network type identification method in public security network scenarios, the data sender can add an HMAC signature to the data field of the network packet (i.e., the Data field in the diagram). This HMAC signature ensures the integrity of the packet's origin and content, preventing attackers from forging a legitimate signature even if the packet is intercepted. Specifically, the data sender obtains its private key and uses it to sign the VLAN ID and network type identifier to obtain an HMAC signature. Then, it generates a target data frame based on the HMAC signature, the VLAN ID, and a pre-set network type identifier. Finally, it sends the target data frame to the target switch, causing the target switch to forward the target data frame when the VLAN ID configured on the Trunk interface is the VLAN ID. The data receiver receives the target data frame from the target switch, parses the HMAC signature from it, and verifies the signature using the data sender's public key. If the HMAC signature verification fails, the target data frame is discarded. If the HMAC signature verification succeeds, the network type identifier is parsed from the target data frame.

[0097] Furthermore, to further enhance the security of this network type identification method in public security network scenarios, the aforementioned data receiver can also determine blockage when no packets are received for a preset number of consecutive cycles (e.g., 3 cycles), and update the aforementioned discontinuous VID sequence through a physically isolated or encrypted independent channel, thereby eliminating the attacked VID. This self-healing mechanism of updating the frequency hopping sequence through a physically isolated or encrypted independent channel can effectively avoid cycle misalignment caused by a single error, and realize adaptive recovery of communication between the data transmitter and the data receiver, thereby improving the adaptability and robustness of this network type identification method.

[0098] Please see Figure 3 The diagram shown is a structural schematic of the network type identification device provided in an embodiment of this application; this embodiment of the application provides a network type identification device 200, including:

[0099] The target data frame generation module 210 is used by the data transmitter to obtain the VLAN identifier of the virtual local area network and generate the target data frame according to the VLAN identifier and the pre-set network type identifier.

[0100] The target data frame sending module 220 is used by the data transmitter to send target data frames to the target switch so that the target switch forwards the target data frames when the VLAN identifier configured on the Trunk interface is the VLAN identifier number.

[0101] The target data frame receiving module 230 is used for the data receiving end to receive target data frames from the target switch and to parse the network type identifier from the target data frame. The network type identifier is used to identify the network type to which the data receiving end belongs, corresponding to the data transmitting end.

[0102] As an optional implementation of the above-mentioned device, the network type identification device further includes:

[0103] The network type identifier receiving module is used by the data transmitter to receive the network type identifier value sent by the network setting device. The network type identifier value is obtained after a physical button on the network setting device is pressed.

[0104] The network type identifier setting module is used by the data transmitter to set the network type identifier value to the network type identifier.

[0105] As an optional implementation of the above-mentioned device, the target switch is an aggregation switch or a core switch; the target data frame generation module includes:

[0106] The Trunk link monitoring submodule is used by the data transmitter to monitor the Trunk links of the aggregation switch or core switch and obtain the data link frames passing through the Trunk link.

[0107] The VLAN ID acquisition submodule is used by the data transmitter to obtain the VLAN ID from the data link frame.

[0108] As an optional implementation of the above-mentioned device, the target data frame generation module includes:

[0109] The link dataset acquisition submodule is used by the data transmitter to obtain all Trunk interface numbers of the target switch, as well as historical link datasets.

[0110] The VLAN identifier prediction submodule is used by the data transmitter to make an initial prediction of the VLAN identifier value configured for all Trunk interface numbers based on the historical link dataset, and obtain the initial predicted VLAN identifier value.

[0111] The VLAN ID acquisition submodule is used by the data transmitter to re-predict the initially predicted VLAN ID value based on the historical link dataset to obtain the VLAN ID number.

[0112] As an optional implementation of the above-mentioned device, the VLAN identifier acquisition submodule includes:

[0113] The identifier population generation unit is used to randomly generate a VLAN identifier population within a preset range of VLAN identifier values. The VLAN identifier population includes multiple candidate VLAN identifiers.

[0114] The identifier population update unit is used to update the VLAN identifier population based on the initially predicted VLAN identifier value to obtain the updated numerical population.

[0115] The fitness value calculation unit is used to calculate the fitness value of each candidate VLAN ID in the updated numerical population based on the historical link dataset.

[0116] The optimal identifier determination unit is used to determine the optimal VLAN identifier value from multiple candidate VLAN identifiers in the updated numerical population based on the fitness value of each candidate VLAN identifier.

[0117] The VLAN ID acquisition unit is used to iteratively calculate the updated numerical population based on the optimal VLAN ID value until the fitness value of the optimal VLAN ID value is less than a preset threshold, and then obtain the VLAN ID number.

[0118] As an optional implementation of the above-mentioned device, the population renewal unit is identified, including:

[0119] The identifier population mutation subunit is used to mutate the VLAN identifier population within a preset range of VLAN identifier values ​​to obtain multiple mutated VLAN identifier values.

[0120] The identifier set filtering subunit is used to filter out the optimal VLAN identifier value from the set of the initial predicted VLAN identifier value and multiple variant VLAN identifier values.

[0121] The cross-learning subunit is used to cross-learn the optimal VLAN identifier value with each of the multiple variant VLAN identifier values.

[0122] As an optional implementation of the above-mentioned device, the optimal identifier determination unit includes:

[0123] The fitness value judgment subunit is used to determine whether the fitness value of each candidate VLAN ID in the updated numerical population is greater than the fitness value of the optimal VLAN ID calculated in the previous iteration.

[0124] The optimal identifier determination subunit is used to determine the candidate VLAN identifier as the optimal VLAN identifier if the fitness value of the candidate VLAN identifier is greater than the fitness value of the optimal VLAN identifier calculated in the previous iteration, and to determine the optimal VLAN identifier calculated in the previous iteration as the optimal VLAN identifier if the fitness value of the candidate VLAN identifier is less than or equal to the fitness value of the optimal VLAN identifier calculated in the previous iteration.

[0125] As an optional implementation of the above-mentioned device, the target data frame generation module includes:

[0126] The Ethernet frame construction submodule is used to construct a standard Ethernet frame.

[0127] The VLAN tag writing submodule is used to add a four-byte VLAN tag field between the source address field and the protocol type field of a standard Ethernet frame, and write the VLAN tag number into the VLAN tag field.

[0128] The type identifier writing submodule is used to write the network type identifier into the data field of a standard Ethernet frame.

[0129] As an optional implementation of the above-mentioned device, the target data frame generation module includes:

[0130] The target switch determination submodule is used to determine whether there are multiple target switches.

[0131] The data frame generation and transmission submodule is used to generate the multicast address of the target data frame based on the media access control MAC address of the multiple switches if the target switch is multiple switches, and to generate the target data frame to be transmitted in multicast mode based on the multicast address, VLAN ID and network type identifier.

[0132] It should be understood that this device corresponds to the network type identification method embodiment described above and is capable of performing the various steps involved in the above method embodiment. The specific functions of this device can be found in the description above, and detailed descriptions are appropriately omitted here. The device includes at least one software functional module that can be stored in memory or embedded in the device's operating system (OS) in the form of software or firmware.

[0133] Please see Figure 4 The diagram shows a structural schematic of an electronic device provided in an embodiment of this application. An electronic device 300 provided in this application includes a processor 310 and a memory 320. The memory 320 stores machine-readable instructions executable by the processor 310. When the machine-readable instructions are executed by the processor 310, the method described above is performed.

[0134] This application embodiment also provides a computer-readable storage medium 330, on which a computer program is stored. This computer program is executed by a processor 310 to perform the methods described above. The computer-readable storage medium 330 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0135] This application also provides a computer program product, including: a computer program or computer instructions, which are executed by a processor to perform the method described above.

[0136] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For apparatus embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0137] It should be understood that the disclosed apparatus and methods can also be implemented in other ways, as provided in the embodiments of this application. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending primarily on the functions involved.

[0138] Furthermore, the functional modules of each embodiment in this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part. In addition, in the description of this specification, the reference to terms such as "one embodiment," "some embodiments," "example," "specific example," "some examples," etc., means that the specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0139] The above description is only an optional implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application.

Claims

1. A method for identifying network types, characterized in that, include: The data transmitter obtains the VLAN identifier of the virtual local area network; Construct a standard Ethernet frame, add a four-byte VLAN tag field between the source address field and the protocol type field of the standard Ethernet frame, write the VLAN identifier into the VLAN tag field, and write the pre-set network type identifier into the data field of the standard Ethernet frame to generate the target data frame; The data transmitter sends the target data frame to the target switch so that the target switch forwards the target data frame when the VLAN identifier configured on the Trunk interface is the VLAN identifier number. The data receiving end receives the target data frame from the target switch and parses the network type identifier from the target data frame. The network type identifier is used to identify the network type to which the data receiving end corresponding to the data transmitting end belongs.

2. The method according to claim 1, characterized in that, Before generating the target data frame, the method further includes: The data transmitter receives a network type identifier value sent by the network setting device. The network type identifier value is obtained after a physical button on the network setting device is pressed. The data transmitter sets the network type identifier value to the network type identifier.

3. The method according to claim 1, characterized in that, The target switch is an aggregation switch or a core switch; the data transmitter obtains the VLAN identifier, including: The data transmitter listens to the trunk link of the aggregation switch or the core switch to obtain the data link frames passing through the trunk link; The data transmitter obtains the VLAN identifier from the data link frame.

4. The method according to claim 1, characterized in that, The data transmitter obtains the Virtual Local Area Network (VLAN) identifier, including: The data transmitter obtains all Trunk interface numbers of the target switch, as well as the historical link dataset; The data transmitting end performs an initial prediction of the VLAN identifier value configured for all Trunk interface numbers based on the historical link dataset, and obtains the initial predicted VLAN identifier value. The data transmitting end re-predicts the initially predicted VLAN identifier value based on the historical link dataset to obtain the VLAN identifier number.

5. The method according to claim 4, characterized in that, The step of re-predicting the initially predicted VLAN identifier value based on the historical link dataset includes: Within a preset range of the VLAN identifier value, a VLAN identifier population is randomly generated, and the VLAN identifier population includes multiple candidate VLAN identifiers. The VLAN identifier population is updated based on the initial predicted VLAN identifier value to obtain the updated numerical population; For each candidate VLAN ID in the updated numerical population, the fitness value of the candidate VLAN ID is calculated based on the historical link dataset; The optimal VLAN ID value is determined from multiple candidate VLAN IDs in the updated numerical population based on the fitness value of each candidate VLAN ID. The updated numerical population is iteratively calculated based on the optimal VLAN identifier value until the fitness value of the optimal VLAN identifier value is less than a preset threshold, at which point the VLAN identifier number is obtained.

6. The method according to any one of claims 1-5, characterized in that, After generating the target data frame, the following is also included: Determine whether the target switch is multiple switches, wherein the target switch is all switches connected by trunk links in the current network; If so, the destination MAC address of the target data frame is set to a pre-built multicast MAC address so that all the multiple switches can receive the target data frame.

7. A network type identification device, characterized in that, include: The target data frame generation module is used to control the data transmitter to obtain the VLAN identifier of the virtual local area network; A standard Ethernet frame is constructed by adding a four-byte VLAN tag field between the source address field and the protocol type field of the standard Ethernet frame, writing the VLAN identifier into the VLAN tag field, and writing the pre-set network type identifier into the data field of the standard Ethernet frame to generate the target data frame. The target data frame sending module is used to control the data transmitter to send the target data frame to the target switch, so that the target switch forwards the target data frame when the VLAN identifier value configured on the Trunk interface is the VLAN identifier number; The target data frame receiving module is used to control the data receiving end to receive the target data frame from the target switch, and to parse the network type identifier from the target data frame. The network type identifier is used to identify the network type to which the data receiving end corresponding to the data transmitting end belongs.

8. An electronic device, characterized in that, include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, the machine-readable instructions being executed by the processor to perform the method of any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Home NB local network type processing method and device

    CN101873649A

  • Network configuration method of switch and computing device

    CN119094333A