Network type identification method and device and electronic equipment

By generating target data frames carrying network type information and utilizing the switch's Trunk interface forwarding mechanism, automatic identification of network types is achieved, solving the problems of low efficiency and adaptability in existing technologies for network type identification and improving the flexibility and intelligence of network configuration.

CN120658642AActive Publication Date: 2025-09-16GONGSHU DISTRICT BRANCH OF HANGZHOU PUBLIC SECURITY BUREAU
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510839393.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2025-09-16
Estimated Expiration
2045-06-23

AI Technical Summary

Technical Problem

Existing 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) identification number and the network type identifier to generate the target data frame, and using the switch's Trunk interface to forward the data frame with the network type information explicitly carried in it, the switch can automatically identify the network type without manual configuration.

Benefits of technology

It improves the efficiency of network type identification and adaptability to network changes, simplifies the network configuration process, and enhances the intelligence level of device access and network adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120658642A_ABST
    Figure CN120658642A_ABST
Patent Text Reader

Abstract

The invention provides a network type identification method and device and electronic equipment, and the method comprises the steps: a data transmitting end obtains a virtual local area network (VLAN) identification number, and generates a target data frame according to the virtual local area network (VLAN) identification number and a preset network type identifier; the data transmitting end sends the target data frame to the target switch, so that the target switch forwards the target data frame when the VLAN identification value configured by the Trunk interface is the VLAN identification number; and the data receiving end receives the target data frame from the target switch and analyzes the network type identifier from the target data frame, and the network type identifier is used for identifying the network type to which the data receiving end corresponding to the data transmitting end belongs. The network type identifier and the VLAN identification number are dynamically bound in the process of generating the target data frame, so that the target switch automatically identifies the network type during forwarding, additional configuration does not need to be performed on the switch, and the efficiency of network type identification and the adaptability to network change are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical fields of computer networks, network communications, and network security, and in particular to a network type identification method, device, and electronic device. Background Art

[0002] Currently, network type identification primarily relies on manual planning and configuration, such as through IP address allocation, subnet division, or identification of network types (e.g., public security network, railway private network, or public network) through upper-layer application protocols. During actual network operation and maintenance, if the network environment changes (such as equipment migration or the addition of a new subnet), organizations that need to access the network must manually consult the network operations department to determine the network type to avoid accidentally connecting to the internet or unauthorized private networks. Therefore, current network type identification relies on manual planning and configuration, and is difficult to dynamically adapt to network changes. This approach is inefficient and inflexible. Summary of the Invention

[0003] The purpose of the embodiments of the present application is to provide a network type identification method, device and electronic device, which are used to improve the problem of low efficiency and adaptability of network type identification.

[0004] An embodiment of the present application provides a network type identification method, comprising: a data transmitter obtaining a virtual local area network (VLAN) identification number and generating a target data frame based on the virtual local area network (VLAN) identification number 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 identification value configured on the Trunk interface is the VLAN identification number; a data receiver receiving the target data frame from the target switch and parsing the target data frame to extract a network type identifier, the network type identifier being used to identify the network type to which the data receiver corresponding to the data transmitter belongs. In the implementation of the above scheme, the target data frame is generated by combining the virtual local area network (VLAN) identification number and the network type identifier to effectively dynamically bind the network type identifier to the VLAN identification number, and a mechanism for explicitly carrying network type information in data frames forwarded by the switch's Trunk interface is utilized, so that the target switch automatically identifies the network type when forwarding, without requiring additional configuration on the switch, thereby improving the efficiency of network type identification and adaptability to network changes.

[0005] Optionally, in an embodiment of the present application, before generating a target data frame based on the virtual local area network (VLAN) identification number and a pre-set network type identifier, the method further includes: the data transmitter receives a network type identifier value sent by a network setting device, the network type identifier value being obtained after a physical button on the network setting device is pressed; and the data transmitter sets 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, the user can directly set the network type identifier using the physical button, making network configuration extremely simple and intuitive. This scheme allows the data transmitter to instantly receive and apply new network type identifier values, thereby improving adaptability to different network environment requirements.

[0006] Optionally, in an embodiment of the present application, the target switch is an aggregation switch or a core switch; the data transmitter obtains the virtual local area network VLAN identification number, including: the data transmitter monitors the Trunk link of the aggregation switch or the core switch to obtain the data link frame passing through the Trunk link; the data transmitter obtains the VLAN identification number from the data link frame. In the implementation process of the above scheme, by allowing the data transmitter to actively monitor the Trunk link traffic of the aggregation switch or the core switch and extract the VLAN identification number from it, an intelligent recognition mechanism that can automatically perceive the network VLAN structure without manual configuration or reliance on control protocols is realized, so that the data transmitter can dynamically and in real time adapt to VLAN configuration changes in complex network environments, avoiding the communication failure problem caused by manual configuration errors or configuration delays in traditional methods; at the same time, since aggregation and core switches usually carry traffic of multiple VLANs, this method has good generalization capabilities and is suitable for large-scale network scenarios where multiple VLANs coexist and topology changes frequently, significantly improving the intelligence level of device access and network adaptability.

[0007] Optionally, in an embodiment of the present application, the data transmitter obtains the virtual local area network (VLAN) ID number, including: obtaining all trunk interface numbers and a historical link dataset of the target switch; performing an initial prediction of the VLAN ID values ​​configured for all trunk interface numbers based on the historical link dataset to obtain an initial predicted VLAN ID value; and performing a secondary prediction of the initial predicted VLAN ID value based on the historical link dataset to obtain the VLAN ID number. In implementing this solution, the data transmitter obtains all trunk interface numbers and a historical link dataset of the target switch, and performs both an initial and secondary prediction of the VLAN ID value based on this dataset to obtain the final VLAN ID number. This approach overcomes the limitations of traditional reliance on static configuration or control protocols (such as LLDP and CDP) for obtaining VLAN information, achieving automatic and intelligent identification of the actual VLAN ID carried on the network without relying on device management permissions or the control plane. By introducing a "double prediction mechanism" based on historical link data, the accuracy of VLAN identification is improved while also enhancing the system's adaptability to dynamic network changes (such as VLAN drift and trunk configuration changes).

[0008] Optionally, in an embodiment of the present application, the initially predicted VLAN ID value is re-predicted based on the historical link data set, including: randomly generating a VLAN ID population within a preset range of the VLAN ID value, the VLAN ID population including multiple candidate VLAN ID numbers; updating the VLAN ID population based on the initially predicted VLAN ID value to obtain an updated value population; for each candidate VLAN ID number in the updated value population, calculating the fitness value of the candidate VLAN ID number based on the historical link data set; determining the optimal VLAN ID value from the multiple candidate VLAN ID numbers in the updated value population based on the fitness value of each candidate VLAN ID number; and iteratively calculating the updated value population based on the optimal VLAN ID value until the fitness value of the optimal VLAN ID value is less than a preset threshold, thereby obtaining the VLAN ID number. During the implementation of the above solution, a trunk interface may carry multiple VLANs, and the initial prediction may not be accurate. However, through multiple iterations and fitness evaluation, even if there is misconfiguration or VLAN drift, the final result can be ensured to have a high degree of confidence. Therefore, by combining the initial prediction with multiple iterations of fitness prediction, the "most frequently occurring" or "most representative" optimal VLAN ID can be dynamically adjusted and locked.

[0009] Optionally, in an embodiment of the present application, a target data frame is generated based on a virtual local area network (VLAN) identification number and a pre-set network type identifier, including: 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 identification number 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 the VLAN tag field between the source address and the protocol type field of the standard Ethernet frame and writing the VLAN identification number, and embedding the network type identifier into the data field, a lightweight, highly compatible, and semantically extensible data frame encapsulation mechanism is implemented. This mechanism effectively reuses the blank areas and data fields in the existing frame structure, allowing the target switch to identify the logical network type to which the data frame belongs while normally forwarding VLAN traffic, thereby achieving 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 an embodiment of the present application, a target data frame is generated based on a virtual local area network VLAN identification number and a pre-set network type identifier, including: determining whether the target switch is multiple switches, the target switch being all switches connected to 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 process of the above scheme, by determining whether the target switch is multiple 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 network detection and information synchronization mechanism is implemented, so that without relying on a control protocol or a centralized controller, the standard Ethernet frame structure and multicast mechanism are used to achieve simultaneous communication with all connected switches on the Trunk link, ensuring that multiple devices in the network can synchronously receive and process key information including the VLAN identification number and the network type identifier, which not only improves the efficiency of network discovery and configuration, but also enhances the network topology perception capability.

[0011] An embodiment of the present application also provides a network type identification device, including: a target data frame generation module, used by a data transmitting end to obtain a virtual local area network VLAN identification number, and generate a target data frame based on the virtual local area network VLAN identification number and a pre-set network type identifier; a target data frame sending module, used by the data transmitting end to send a target data frame to a target switch, so that the target switch forwards the target data frame when the VLAN identification value configured on the Trunk interface is the VLAN identification number; a target data frame receiving module, used by a data receiving end to receive the target data frame from the target switch, and parse the network type identifier from the target data frame, where the network type identifier is used to identify the network type to which the data receiving end corresponding to the data transmitting end belongs.

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

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

[0014] Optionally, in an embodiment of the present application, the target data frame generation module includes: a link data set acquisition submodule, which is used by the data transmitting end to obtain all Trunk interface numbers of the target switch and a historical link data set; a VLAN ID prediction submodule, which is used by the data transmitting end to perform an initial prediction of the VLAN ID values ​​configured for all Trunk interface numbers based on the historical link data set to obtain an initial predicted VLAN ID value; and a VLAN ID acquisition submodule, which is used by the data transmitting end to perform a re-prediction of the initial predicted VLAN ID value based on the historical link data set to obtain a VLAN ID number.

[0015] Optionally, in an embodiment of the present application, 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 identifier numbers; an identifier population update unit, configured to update the VLAN identifier population according to an initially predicted VLAN identifier value to obtain an updated value population; a fitness value calculation unit, configured to calculate, for each candidate VLAN identifier number in the updated value population, a fitness value of the candidate VLAN identifier number based on a historical link data set; an optimal identifier determination unit, configured to determine an optimal VLAN identifier value from multiple candidate VLAN identifier numbers in the updated value population according to the fitness value of each candidate VLAN identifier number; and a VLAN identifier acquisition unit, configured to iteratively calculate the updated value population according to the optimal VLAN identifier value until the fitness value of the optimal VLAN identifier value is less than a preset threshold, thereby obtaining the VLAN identifier number.

[0016] Optionally, in an embodiment of the present application, 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 variant VLAN identifier values; an identifier set screening subunit, used to screen out the optimal VLAN identifier value from the initial predicted VLAN identifier value and the set of multiple variant VLAN identifier values; and an identifier cross-learning subunit, used to cross-learn the optimal VLAN identifier value with each variant VLAN identifier value in the multiple variant VLAN identifier values.

[0017] Optionally, in an embodiment of the present application, the optimal identifier determination unit includes: a fitness value judgment subunit, used to judge whether the fitness value of each candidate VLAN identification number in the updated numerical population is greater than the fitness value of the optimal VLAN identification number calculated after the last iterative calculation; an optimal identifier determination subunit, used to determine the candidate VLAN identification number as the optimal VLAN identification number if the fitness value of the candidate VLAN identification number is greater than the fitness value of the optimal VLAN identification number calculated after the last iterative calculation; if the fitness value of the candidate VLAN identification number is less than or equal to the fitness value of the optimal VLAN identification number calculated after the last iterative calculation, determine the optimal VLAN identification number calculated after the last iterative calculation as the optimal VLAN identification number.

[0018] Optionally, in an embodiment of the present application, the target data frame generation module includes: an Ethernet frame construction submodule, which is used to construct a standard Ethernet frame, and a VLAN identifier writing submodule, which is 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, which is used to write the network type identifier into the data field of the standard Ethernet frame.

[0019] Optionally, in an embodiment of the present application, the target data frame generation module includes: a target switch judgment submodule, used to determine whether the target switch is multiple switches, and the target switch is all switches connected by Trunk links in the current network; 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 all receive the target data frame.

[0020] An embodiment of the present application further 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 execute the method described above when executed by the processor.

[0021] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described above is executed.

[0022] An embodiment of the present application further provides a computer program product, including: a computer program or computer instructions, which executes the method described above when the computer program or computer instructions are executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only illustrate certain embodiments of the embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0024] Figure 1 A schematic diagram showing a flow chart of a network type identification method provided in an embodiment of the present application is shown; Figure 2 A schematic diagram of the field structure of a target data frame provided in an embodiment of the present application is shown; Figure 3 A schematic diagram of the structure of a network type identification device provided in an embodiment of the present application is shown; Figure 4A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the embodiments of the present application only serve the purpose of illustration and description and are not intended to limit the scope of protection of the embodiments of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in the embodiments of the present application illustrate the operations implemented according to some embodiments of the embodiments of the present application. It should be understood that the operations of the flowcharts can be implemented out of sequence, and steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art, guided by the contents of the embodiments of the present application, can add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0026] In addition, the described embodiments are only a portion of the embodiments of the present application, rather than all embodiments. The components of the embodiments of the present application generally described and shown in the accompanying drawings can be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed embodiments of the present application, but rather merely represents selected embodiments of the embodiments of the present application.

[0027] It is understandable that the "first" and "second" in the embodiments of the present application are used to distinguish similar objects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit differences. In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the previous and subsequent associated objects are in an "or" relationship. The term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two (including two).

[0028] It should be noted that the network type identification method provided in the embodiments of the present application can be executed by electronic devices. The electronic devices herein refer to device terminals capable of executing computer programs or the aforementioned servers. Examples of device terminals include smartphones, personal computers, tablet computers, personal digital assistants, or mobile internet devices. A server refers to a device that provides computing services over a network. Examples of servers include x86 servers and non-x86 servers. Non-x86 servers include mainframes, minicomputers, and UNIX servers.

[0029] Currently, network type identification relies primarily on manual planning and configuration, such as through IP address allocation, subnetting, or identifying network types through upper-layer application protocols. For example, consider allocating a separate IP address range of 10.1.0.0 / 16 for the public security network, 10.2.0.0 / 16 for the railway private network, and 192.168.1.0 / 24 for the audio and video private network. To distinguish between different private networks (such as the public security network, railway private network, and social network), network operations administrators must pre-plan these IP address subnets based on organizational needs and configure corresponding routing rules to ensure they do not conflict. This requires specialized networking knowledge to correctly configure subnets on routers and switches. However, in the actual operation and maintenance of a network environment, changes (such as device migration or the addition of a new subnet) require adjustments to the existing IP address allocation scheme, including updating DHCP server configurations and modifying routing tables on routers and switches. At this time, organizations seeking network access must consult with network administrators within the network operations department to determine the network type, preventing them from accidentally connecting to the internet or unauthorized private networks. Therefore, current network type identification relies on manual planning and configuration, making it difficult to dynamically adapt to network changes. This approach is inefficient and inflexible.

[0030] To improve the above problem, please see Figure 1 The flowchart of the network type identification method provided by the embodiment of the present application is shown; the main idea of ​​the network type identification method is to generate a target data frame by combining the virtual local area network (VLAN) identification number and the network type identifier to effectively dynamically bind the network type identifier to the VLAN identification number, and use the switch's Trunk interface to forward the data frame to explicitly carry the network type information mechanism, so that the target switch automatically identifies the network type when forwarding. Without the need for manual IP subnet planning or additional configuration on the switch, the network type to which the data belongs can be displayed at the data receiving end through the network type identifier, thereby improving the efficiency of network type identification and adaptability to network changes. The implementation of the above-mentioned network type identification method may include: Step S110: the data transmitting end obtains the virtual local area network VLAN identification number, and generates a target data frame according to the virtual local area network VLAN identification number and a preset network type identifier.

[0031] A data transmitter is a device in the network that is responsible for generating and sending data frames in a preset format. For example, a data transmitter located 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.

[0032] 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 between VLANs cannot communicate directly with each other, thus limiting broadcast packets to a single VLAN.

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

[0034] The network type identifier is a symbol used to identify a network (such as the public security network, railway dedicated network, or social network). It's understood that the network type identifier can be defined based on specific circumstances. For example, a string like "deviceType:1\r\n" can be added to the data field of a network message (the "Data" field in the figure) to indicate the network type. This allows for identification of various network types, such as the public security network, railway dedicated network, and social network. Here, "deviceType:1\r\n" represents the public security network, "deviceType:2\r\n" represents the railway dedicated network, "deviceType:3\r\n" represents the social network, and so on.

[0035] Step S120: the data transmitting end sends a target data frame to the target switch, so that the target switch forwards the target data frame when the VLAN ID value configured on the Trunk interface is the VLAN ID number.

[0036] The target switch refers to a switch that needs to identify the network type, for example, it can be a core layer switch or 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.

[0037] A trunk interface is a special network interface configuration that allows data traffic from multiple VLANs to be transmitted simultaneously over a single physical link. The aforementioned core layer switches or aggregation layer switches usually allow data frames to be forwarded across multiple VLANs.

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

[0039] The data receiver refers to the device in the network that is responsible for receiving and parsing the target data frame. It can usually be an end-user device, a monitoring system, or other applications that need to understand the current network type.

[0040] Since VLAN itself has network isolation function, by combining the virtual local area network (VLAN) identification number and the network type identifier to generate the target data frame, the network type identifier can be dynamically bound to the VLAN identification number, so that the target switch will forward the data frame only when it matches the specific VLAN configuration, thereby realizing VLAN-based fine-grained access control and preventing illegal devices from accessing the network through the wrong VLAN interface, ultimately improving the protection capability of sensitive network areas (such as public security networks or government intranets).

[0041] In the implementation process of the above solution, the target data frame is generated by combining the virtual local area network (VLAN) identification number and the network type identifier to effectively dynamically bind the network type identifier to the VLAN identification number, and the network type information is explicitly carried in the data frame forwarded by the switch's Trunk interface. This allows the target switch to automatically identify the network type when forwarding, without the need for additional configuration on the switch, thereby improving the efficiency of network type identification and adaptability to network changes.

[0042] As an optional implementation of the above-mentioned network type identification method, before generating the target data frame according to the virtual local area network VLAN identification number and the preset network type identifier, the network type identifier can also be set by a physical button. This implementation may include: Step S101: The data transmitting end receives a network type identification value sent by a network setting device. The network type identification value is obtained after a physical button on the network setting device is pressed.

[0043] For example, in step S101, after a user presses a physical button on the network setup device that identifies the network type, the network setup device, in response to the user's pressing action, may first obtain the network type identification value corresponding to the physical button and then transmit the network type identification value corresponding to the physical button to the data transmitter. The data transmitter and the network setup device may communicate via an RS-485 interface or serial port, and the data transmitter may receive the network type identification value sent by the network setup device via the RS-485 interface or serial port. The network type identification value is obtained after the physical button on the network setup device is pressed. This method of inputting the network type identifier using a physical button can, to a certain extent, prevent unauthorized changes to the network type. Because physical buttons are generally highly secure (e.g., concealed locations and requiring physical contact), this provides an additional layer of security for network access.

[0044] Step S102: The data transmitting end sets the network type identification value as the network type identifier.

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

[0046] As an optional implementation of step S110, the target switch may be an aggregation switch or a core switch. The implementation of the data transmitting end obtaining the virtual local area network VLAN identification number may include: Step S111: The data transmitting end monitors the Trunk link of the aggregation switch or the core switch to obtain the data link frame passing through the Trunk link.

[0047] For example, in step S111, a data transmitter is deployed on a Trunk link of an aggregation switch or a core switch. The data transmitter can monitor the Trunk link of the aggregation switch or the core switch using a packet capture software tool such as Wireshark or Tcpdump to obtain data link frames passing through the Trunk link. For example, using the Tcpdump software tool, the command tcpdump -i eth0 -w trunk_traffic.pcap can be used to monitor the Trunk link of the aggregation switch or the core switch.

[0048] Step S112: The data transmitting end obtains the VLAN identification number from the data link frame.

[0049] For example, the implementation of the above step S112 is as follows: the data transmitting end extracts the 802.1Q VLAN tag from the data link frame, and extracts the VLAN identification number (ie, the value of VID) from the 802.1Q VLAN tag.

[0050] As an optional implementation of step S110, the data transmitting end may obtain the virtual local area network VLAN identification number in the following manner: Step S113: The data transmitting end obtains all Trunk interface numbers of the target switch and a historical link data set.

[0051] In the implementation of step S113, for example, after the data transmitter monitors a period of data on a Trunk link of an aggregation switch or a core switch, it can obtain a historical link data set and all Trunk interface numbers of the target switch. The all Trunk interface numbers of the target switch can be pre-configured or analyzed and extracted from the historical link data set.

[0052] Step S114: The data transmitting end performs an initial prediction on the VLAN ID values ​​configured for all Trunk interface numbers based on the historical link data set to obtain an initial predicted VLAN ID value.

[0053] Initial prediction means that the data transmitter makes a preliminary estimate of the set of VLAN IDs that may be carried on a trunk interface based on information such as traffic patterns, protocol types, and source / destination MAC address distribution observed in historical link data sets.

[0054] For example, in step S114, if Trunk interface A transmits a large number of ARP requests from a private network system (MAC address 00:11:22:33:44:55) in the past week's historical link dataset, using a large language model to analyze this historical link dataset, it can be inferred that the initial predicted VLAN ID value for Trunk interface A is VLAN 10. The large language model is a deep learning network model that has been fine-tuned using the historical link dataset.

[0055] Step S115: The data transmitting end re-predicts the initially predicted VLAN ID value based on the historical link data set to obtain a VLAN ID number.

[0056] As an optional implementation of step S115, 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 ID value based on the historical link data set. The above implementation of re-predicting the initially predicted VLAN ID value based on the historical link data set may include: Step S115a: randomly generating a VLAN ID population within a preset range of VLAN ID values, where the VLAN ID population includes a plurality of candidate VLAN ID numbers.

[0057] For example, in step S115a, since the VLAN ID range is usually 1-4094, multiple VLAN ID populations may be randomly generated within the range of 1-4094. Each of the multiple VLAN ID populations may include multiple candidate VLAN ID numbers. For example, one of the VLAN ID populations may include [1003, 3021, 456, 2100, 789, 100, 3999, 2000, 150, 888].

[0058] Step S115b: updating the VLAN ID population according to the initially predicted VLAN ID value to obtain an updated value population.

[0059] An alternative implementation of step S115b, for example, involves using the initially predicted VLAN ID value as a mutation seed and mutating the VLAN ID population within a preset range of VLAN ID values ​​to obtain multiple variant VLAN ID values. An optimal VLAN ID value is then selected from the set of the initially predicted VLAN ID value and the multiple variant VLAN ID values. Finally, cross-learning is performed between the optimal VLAN ID value and each of the multiple variant VLAN ID values.

[0060] Step S115c: For each candidate VLAN ID in the updated value population, calculate the fitness value of the candidate VLAN ID according to the historical link data set.

[0061] An optional implementation of step S115c, for example, involves calculating the frequency of occurrence of each candidate VLAN ID in the updated population using the historical link dataset. Then, a weighted sampling calculation is performed on each candidate VLAN ID based on the frequency of occurrence, thereby obtaining a fitness value (Fitness Value) for the candidate VLAN ID. It will be appreciated that the fitness value is typically derived from a weighted calculation of information such as VLAN occurrence frequency, communication mode, and device behavior in the historical link dataset. The specific weighting index used in this weighting can be set based on the network communication data in the specific historical link dataset. Therefore, VLAN IDs with high fitness are more likely to represent the "mainstream VLAN" currently carried on the trunk interface, thereby improving prediction accuracy.

[0062] Step S115d: Determine the optimal VLAN ID value from the multiple candidate VLAN IDs in the updated value population according to the fitness value of each candidate VLAN ID.

[0063] An alternative implementation of step S115d is to sort the candidate VLAN IDs in the updated population by fitness value from highest to lowest, and select the VLAN ID with the highest fitness value as the "optimal VLAN ID" for the current iteration. It should be understood that the goal of step S115d is to identify the candidate value from the current population that is most likely to represent the true target VLAN ID, a core component of the "survival of the fittest" mechanism within the genetic algorithm. 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.

[0064] Step S115e: performing iterative calculation on the updated value population according to the optimal VLAN ID value until the fitness value of the optimal VLAN ID value is less than a preset threshold, thereby obtaining the VLAN ID number.

[0065] An optional implementation of step S115e is, for example, to determine, for each candidate VLAN ID in the updated value population, whether the fitness value of the candidate VLAN ID is greater than the fitness value of the optimal VLAN ID calculated in the previous iterative calculation. If the fitness value of the candidate VLAN ID is greater than the fitness value of the optimal VLAN ID calculated in the previous iterative calculation, 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 iterative calculation, then the optimal VLAN ID calculated in the previous iterative calculation is determined as the optimal VLAN ID.

[0066] In the implementation of the above solution, by combining the initial prediction with multiple iterations of fitness to perform re-prediction, the "most frequently occurring" or "most representative" VLAN ID can be dynamically adjusted and locked. Because in real networks, a trunk interface may carry multiple VLANs, the initial prediction may be inaccurate. However, through multiple iterations and fitness evaluation, the final result can be highly confident even in the presence of misconfigurations or VLAN drift. Therefore, by combining the initial prediction with multiple iterations of fitness to perform re-prediction, the "most frequently occurring" or "most representative" optimal VLAN ID can be dynamically adjusted and locked.

[0067] See Figure 2The following diagram illustrates the field structure of a target data frame provided by an embodiment of the present application. The target data frame is a data frame (e.g., an Ethernet frame) constructed by a data transmitter based on a VLAN ID and a network type identifier. This target data frame may, in compliance with the IEEE 802.1Q standard, include a 4-byte VLAN tag (i.e., the 802.1Q Tag in the diagram) between the source address and the 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 (Length / Type), 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 whether a transmission error has occurred. If an error is detected, the frame is discarded. Specifically, a cyclic redundancy check (CRC) may be used, such as the CRC-32 algorithm, for frame check. The VLAN tag may include: a tag protocol identifier (TPID), a frame priority (PRI), a canonical format indicator (CFI), and a VLAN ID (VID).

[0068] As an optional implementation of the above step S110, the above implementation of generating the target data frame according to the virtual local area network VLAN identification number and the preset network type identifier may include: 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 identification number into the VLAN tag field.

[0069] An example implementation of step S116 is as follows: an Ethernet frame compliant with the IEEE 802.1Q standard is constructed, and then a four-byte VLAN tag (i.e., 802.1Q Tag in the figure) field is added between the source address field (i.e., Source Address in the figure) and the protocol type (i.e., Length / Type in the figure) field of the standard Ethernet frame. The VLAN tag is used to identify the type of VLAN logical area in which different networks are located.

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

[0071] For example, in step S117, the network type identifier is represented by a string such as deviceType:1\r\n. This string can be written into the data field (i.e., the Data field in the figure) of a standard Ethernet frame. The "1" in "deviceType:1\r\n" can represent the public security network, or it can be replaced with "deviceType:2\r\n." The "2" in "deviceType:2\r\n" can represent the railway network, or it can be replaced with "deviceType:3\r\n," where "3" can represent the public network. The VLAN ID is then written into the VLAN tag field.

[0072] As an optional implementation of the above step S110, the above implementation of generating the target data frame according to the virtual local area network VLAN identification number and the preset network type identifier may include: Step S118: Determine whether the target switch is multiple switches. The target switch is all switches connected by the Trunk link in the current network.

[0073] It is understandable that since the Trunk link implements the encapsulation and forwarding of multi-VLAN data through the IEEE 802.1Q standard, the Trunk link channel can carry multicast messages, thereby ensuring that the network type identifier in the multicast message is transmitted across network segments in a multi-VLAN environment through the 802.1Q tag mechanism. This combination of the VLAN tag and the custom network type field of the multicast frame breaks through the limitation of traditional multicast messages propagating in a single broadcast domain, thereby realizing the function of transmitting the network type identifier across multiple VLANs.

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

[0075] For example, in step S119, a multicast address is constructed for multiple switches (e.g., a destination MAC address in the range of 01:00:5E:xx:xx:xx). Then, when generating a target data frame based on the virtual local area network (VLAN) ID and a pre-set network type identifier, a target data frame is generated for each VLAN ID in each of the multiple switches based on the VLAN ID and the network type identifier, thereby generating multiple target data frames. Specifically, each target data frame corresponds to the VLAN ID. Finally, the destination MAC address of each target data frame is set to the multicast MAC address, so that the target data frame containing the network type identifier can be propagated to multiple switches in the network. Specifically, the target data frame containing the network type identifier can be received by all switches, thereby identifying the network type of the current network based on the target data frame containing the network type identifier.

[0076] As an optional implementation of step S120, for example, assuming that two private networks, VLAN 10 and VLAN 20, are configured in the network, and the VLAN ID value configured on the Trunk interface of the target switch is VLAN 10, if the VLAN ID in the target data frame sent by the data transmitter to the target switch is VLAN 10, the target switch can determine that the VLAN ID 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 ID in the target data frame sent by the data transmitter to the target switch is VLAN 20, the target switch can determine that the VLAN ID 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. During the implementation of the above solution, 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 access to devices without introducing a complex encryption system, and effectively build a network identity authentication mechanism that collaborates across switch devices.

[0077] As an optional implementation of the above step S130, 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 the "1" in "deviceType:1\r\n" can represent the public security network.

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

[0079] It can be understood that the above-mentioned data transmitter and data receiver together constitute a portable network environment detection tool. The data transmitter and data receiver of the tool can be developed based on a customized embedded platform. For example, an open source operating system is customized and developed to obtain a customized operating system. Then, the customized operating system is run in a microcontroller so that the tool can realize the function of efficiently sending and receiving data frames.

[0080] In the specific use of the 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 core switch). The tool's data transmitter periodically transmits (multicast or broadcast) target data frames carrying the VLAN ID and network type identifier, thereby quickly and portablely implementing network type identification without the need to configure IP addresses, subnet planning, or perform complex debugging. When the network type needs to be identified, the user simply uses the tool's data receiver to receive the target data frame at the network interface of a terminal device (such as a personal computer) and then parses the network type identifier from the target data frame. This allows the user to identify the connected network type without configuring IP addresses or performing complex debugging, thereby reducing reliance on professional network operations and maintenance administrators. This plug-and-play feature, which requires no IP configuration and a dynamic VLAN matching mechanism, significantly improves the efficiency and adaptability of network type identification.

[0081] Alternatively, in some public security network scenarios where protection against malicious interference is crucial, the VID field of the VLAN tag (802.1QTag) is public (12 bits, range 1-4094), allowing attackers to construct frames with the same VID without having to crack the protocol. In this scenario, an attacker might construct a VLAN tag (VID=100) identical to a legitimate packet, thereby posing as a legitimate identity and sending interference frames. The switch, however, will forward the frames to the port corresponding to the VLAN with the same VLAN tag (VID=100). Consequently, the attacker's interference frames will be forwarded to the target VLAN, rendering the receiver unable to distinguish between legitimate and illicit traffic. Furthermore, if an attacker sends a large number of forged frames (VID=100), the receiver may overwhelm or discard legitimate frames due to processing priority issues (such as HMAC verification delays).

[0082] To address the aforementioned issues, if it's necessary to prevent attackers from forging interfering frames with the same VID but different network type identifiers, dynamic frequency hopping can be used to set the VLAN ID, replacing the fixed VLAN tag (e.g., VID = 100) used to send multicast packets. This enhances the security of this network type identification method in public security networks. The core concept of dynamic frequency hopping is that, with the clocks of the data transmitter and receiver aligned, the same non-contiguous VID sequence is pre-set on all three network switches, the data transmitter, and the data receiver. The data receiver uses the transmitted timestamp to infer the start of the frequency hopping cycle and, based on the frequency hopping period, determines the true VID used by the data transmitter, effectively filtering out delayed or forged interfering frames. The clocks of the transmitter and receiver can be aligned using a high-precision time synchronization protocol (such as PTP or NTP).

[0083] For example, assuming a 10-second frequency hopping period, and the data transmitter and receiver are clock-aligned, they determine the current frequency hopping period to be 1 based on the current time point (e.g., 5 seconds). Based on the current frequency hopping period, they can determine the currently used VID as 1003 from a pre-set, identical, non-contiguous VID sequence (e.g., [1003, 3021, 456, 2100, 789, 100, 3999, 2000, 150, 888]. Then, they generate a target data frame based on the currently used VID (1003) and the pre-set network type identifier "deviceType:1\r\n" and send it to the target switch. Since the target switch has already been pre-set with the same non-contiguous VID sequence, it forwards the target data frame directly to the data receiver. When the data receiver receives the target data frame, it first generates a receipt timestamp for the target data frame and uses the received timestamp to calculate the start time of the frequency hopping period as 0 seconds. It then determines the current frequency hopping period as 1 based on the start time of the frequency hopping period being 0 seconds. 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 non-contiguous VID sequence can be generated using an encryption algorithm (such as the AES algorithm), and the length of the VID sequence can be set based on security requirements.

[0084] It is easy to understand that the principle of the next frequency hopping cycle is similar. The data transmitter will determine that the current frequency hopping cycle is 2 based on the current time point (such as 14 seconds). Then, based on the current frequency hopping cycle, it can determine that the currently used VID is 3021 from the preset identical non-continuous VID sequence such as [1003, 3021, 456, 2100, 789, 100, 3999, 2000, 150, 888]. Then, based on the currently used VID (3021) and the preset network type identifier "deviceType:1\r\n", the target data frame is generated and sent to the target switch, so that the target switch forwards the target data frame when the preset identical non-continuous VID sequence contains the VLAN identification number. Optionally, after the data receiving end calculates that the starting time point of the frequency hopping cycle is 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 timestamp of the starting time point. For example, if the difference between the received timestamp and the timestamp of the starting time point is greater than a preset threshold (such as 100 milliseconds), the target data frame is discarded, thereby filtering out delayed or forged interference frames.

[0085] In the above scheme, since the attacker cannot know the next hop in advance without obtaining a non-continuous VID sequence, he needs to monitor multiple VLAN channels in real time to implement the attack plan or interference operation. This dynamic frequency hopping method can effectively increase the difficulty for the attacker, thereby enhancing the security of this network type identification method in the public security dedicated network scenario.

[0086] Optionally, to further enhance the security of this network type identification method in public security network scenarios, the data transmitter can also add an HMAC signature to the data field of the network message (i.e., the Data field in the figure). This HMAC signature ensures the authenticity of the message source and the integrity of the content, ensuring that the message has not been tampered with. Even if an attacker intercepts the message, they cannot forge a legitimate signature. For example, the data transmitter obtains its own private key and uses it to sign the virtual local area network (VLAN) ID and the network type identifier to obtain an HMAC signature. The data transmitter then generates a target data frame based on the HMAC signature, the virtual local area network (VLAN) ID, and a pre-set network type identifier. Finally, the target data frame is sent to the target switch, causing the target switch to forward the target data frame if the VLAN ID value configured on the trunk interface is the VLAN ID. The data receiver receives the target data frame from the target switch, extracts the HMAC signature from the target data frame, and verifies the HMAC signature using the data transmitter's public key. If the HMAC signature verification fails, the target data frame is discarded. If the HMAC signature verification passes, the network type identifier is extracted from the target data frame.

[0087] In addition, to further enhance the security of this network type identification method in public security dedicated network scenarios, the above-mentioned data receiving end can also determine that it is blocked if no packets are received for a preset number of consecutive cycles (such as three cycles), and update the above-mentioned non-continuous 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 realizes adaptive recovery of communication between the data transmitting end and the data receiving end, thereby improving the adaptability and robustness of the network type identification method.

[0088] See Figure 3 FIG2 shows a schematic diagram of the structure of a network type identification device provided in an embodiment of the present application. The embodiment of the present application provides a network type identification device 200, comprising: The target data frame generating module 210 is used for the data transmitting end to obtain the virtual local area network VLAN identification number and generate a target data frame according to the virtual local area network VLAN identification number and a preset network type identifier.

[0089] The target data frame sending module 220 is used for the data transmitting end to send the target data frame to the target switch, so that the target switch forwards the target data frame when the VLAN ID value configured on the Trunk interface is the VLAN ID number.

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

[0091] As an optional implementation of the above device, the network type identification device further includes: The network type identification receiving module is used for the data transmitting end to receive the network type identification value sent by the network setting device. The network type identification value is obtained after a physical button on the network setting device is pressed.

[0092] The network type identification setting module is used for the data transmitting end to set the network type identification value as the network type identifier.

[0093] As an optional implementation manner of the above device, the target switch is an aggregation switch or a core switch; the target data frame generation module includes: The Trunk link monitoring submodule is used for the data transmitter to monitor the Trunk link of the aggregation switch or core switch and obtain the data link frames passing through the Trunk link.

[0094] The VLAN identification acquisition submodule is used for the data transmitting end to obtain the VLAN identification number from the data link frame.

[0095] As an optional implementation of the above device, the target data frame generation module includes: The link data set acquisition submodule is used by the data transmitter to obtain all Trunk interface numbers of the target switch and historical link data sets.

[0096] The VLAN ID prediction submodule is used for the data transmitting end to make an initial prediction of the VLAN ID values ​​configured for all Trunk interface numbers according to the historical link data set to obtain an initial predicted VLAN ID value.

[0097] The VLAN identification acquisition submodule is used by the data transmitting end to re-predict the initially predicted VLAN identification value based on the historical link data set to obtain the VLAN identification number.

[0098] As an optional implementation manner of the above device, the VLAN identifier obtaining submodule includes: The identifier population generating unit is used to randomly generate a VLAN identifier population within a preset range of VLAN identifier values, wherein the VLAN identifier population includes a plurality of candidate VLAN identifiers.

[0099] The identifier population updating unit is used to update the VLAN identifier population according to the initially predicted VLAN identifier value to obtain an updated value population.

[0100] The fitness value calculation unit is used to calculate the fitness value of each candidate VLAN identification number in the updated value population according to the historical link data set.

[0101] The optimal identifier determining unit is used to determine the optimal VLAN identifier value from multiple candidate VLAN identifiers in the updated value population according to the fitness value of each candidate VLAN identifier.

[0102] The VLAN identification obtaining unit is used to iteratively calculate the updated numerical population according to the optimal VLAN identification value until the fitness value of the optimal VLAN identification value is less than a preset threshold value, thereby obtaining the VLAN identification number.

[0103] As an optional implementation of the above device, the identification population updating unit includes: 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.

[0104] The identifier set screening subunit is used to screen out the optimal VLAN identifier value from the set of the initially predicted VLAN identifier value and the multiple variant VLAN identifier values.

[0105] The identifier cross-learning subunit is used to cross-learn the optimal VLAN identifier value and each variant VLAN identifier value in a plurality of variant VLAN identifier values.

[0106] As an optional implementation manner of the above device, the optimal identification determination unit includes: The fitness value judgment subunit is used to judge, for each candidate VLAN ID in the updated value population, whether the fitness value of the candidate VLAN ID is greater than the fitness value of the optimal VLAN ID calculated after the last iterative calculation.

[0107] The optimal identification determination subunit is configured to determine the candidate VLAN identification number as the optimal VLAN identification number if the fitness value of the candidate VLAN identification number is greater than the fitness value of the optimal VLAN identification number calculated in the previous iterative calculation; and to determine the optimal VLAN identification number calculated in the previous iterative calculation as the optimal VLAN identification number if the fitness value of the candidate VLAN identification number is less than or equal to the fitness value of the optimal VLAN identification number calculated in the previous iterative calculation.

[0108] As an optional implementation of the above device, the target data frame generation module includes: The Ethernet frame construction submodule is used to construct a standard Ethernet frame.

[0109] The VLAN identification writing submodule is 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 identification number into the VLAN tag field.

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

[0111] As an optional implementation of the above device, the target data frame generation module includes: The target switch determination submodule is used to determine whether the target switch is multiple switches.

[0112] The data frame generation and transmission submodule is used to generate a multicast address for the target data frame based on the media access control MAC addresses of the multiple switches if the target switch is multiple switches, and to generate a target data frame for transmission in a multicast manner based on the multicast address, VLAN identification number and network type identifier.

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

[0114] See Figure 4 The electronic device 300 provided in the embodiment of the present application includes a processor 310 and a memory 320, wherein the memory 320 stores machine-readable instructions executable by the processor 310, and when the machine-readable instructions are executed by the processor 310, the method described above is performed.

[0115] The embodiment of the present application further provides a computer-readable storage medium 330, on which a computer program is stored, and the computer program executes the above method when executed by the processor 310. 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 memory, flash memory, magnetic disk, or optical disk.

[0116] An embodiment of the present application further provides a computer program product, including: a computer program or computer instructions, which executes the method described above when the computer program or computer instructions are executed by a processor.

[0117] 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. Similarities between the various embodiments can be referred to in conjunction with each other. For device embodiments, since they are generally similar to method embodiments, their description is relatively simple, and for relevant details, reference can be made to the description of the method embodiments.

[0118] In the several embodiments provided in the embodiments of the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are only schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible implementation architectures, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and a module, a program segment or a part of a code 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 box can also be different from the order of occurrence marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which is mainly based on the functions involved.

[0119] In addition, the functional modules of each embodiment in the embodiments of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. In addition, in the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "example", "specific example", "some examples", etc. mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of the present application. In this specification, the schematic representations 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 an appropriate manner in any one or more embodiments or examples. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.

[0120] The above description is only an optional implementation method of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited to this. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in the embodiment of the present application, and they should all be covered by the protection scope of the embodiment of the present application.

Claims

1. A network type identification method, characterized in that: include: The data transmitting end obtains the virtual local area network VLAN identification number, and generates a target data frame according to the virtual local area network VLAN identification number and a preset network type identifier; The data transmitting end sends the target data frame to the target switch, so that the target switch forwards the target data frame when the VLAN ID value configured for the Trunk interface is the VLAN ID number; The data receiving end receives the target data frame from the target switch, and parses the target data frame to obtain the network type identifier, where 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 according to the virtual local area network VLAN identification number and the preset network type identifier, the method further includes: The data transmitting end receives a network type identification value sent by a network setting device, where the network type identification value is obtained after a physical button on the network setting device is pressed; The data transmitting end sets the network type identification value as 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 transmitting end obtains the virtual local area network VLAN identification number, including: The data transmitting end monitors the Trunk link of the aggregation switch or the core switch to obtain the data link frame passing through the Trunk link; The data transmitting end obtains the VLAN identification number from the data link frame.

4. The method according to claim 1, wherein The data transmitting end obtains the virtual local area network VLAN identification number, including: The data transmitting end obtains all Trunk interface numbers of the target switch and a historical link data set; The data transmitting end performs an initial prediction on the VLAN ID values ​​configured for all the Trunk interface numbers according to the historical link data set to obtain an initial predicted VLAN ID value; The data transmitting end re-predicts the initially predicted VLAN identification value according to the historical link data set to obtain the VLAN identification number.

5. The method according to claim 4, characterized in that The re-predicting the initially predicted VLAN ID value based on the historical link data set includes: Randomly generating a VLAN identifier population within a preset range of the VLAN identifier value, the VLAN identifier population including a plurality of candidate VLAN identifier numbers; updating the VLAN identifier population according to the initially predicted VLAN identifier value to obtain an updated value population; For each candidate VLAN ID in the updated value population, calculating a fitness value of the candidate VLAN ID according to the historical link data set; Determine an optimal VLAN ID value from a plurality of candidate VLAN IDs in the updated value population according to the fitness value of each candidate VLAN ID; The updated value population is iteratively calculated according to the optimal VLAN identification value until the fitness value of the optimal VLAN identification value is less than a preset threshold, thereby obtaining the VLAN identification number.

6. The method according to any one of claims 1 to 5, characterized in that: Generating a target data frame according to the virtual local area network VLAN identification number and a preset 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 identification number into the VLAN tag field; The network type identifier is written into the data field of the standard Ethernet frame.

7. The method according to any one of claims 1 to 5, characterized in that: After generating the target data frame according to the virtual local area network VLAN identification number and the preset network type identifier, the method further includes: Determine whether the target switch is multiple switches, where the target switches are 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 the multiple switches can all receive the target data frame.

8. A network type identification device, characterized in that: include: A target data frame generating module is used for the data transmitting end to obtain the virtual local area network VLAN identification number and generate a target data frame according to the virtual local area network VLAN identification number and a preset network type identifier; A target data frame sending module, configured for a data transmitting end to send the target data frame to a target switch, so that the target switch forwards the target data frame when the VLAN ID value configured on the Trunk interface is the VLAN ID number; The target data frame receiving module is used for the data receiving end to receive the target data frame from the target switch, and parse the network type identifier from the target data frame, where the network type identifier is used to identify the network type to which the data receiving end corresponding to the data transmitting end belongs.

9. An electronic device, characterized in that: include: 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 method according to any one of claims 1 to 7.

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

Citation Information

Patent Citations

  • Home NB local network type processing method and device

    CN101873649A

  • Customer service access method and system and access equipment

    CN102710468A

  • Network creating method, related device and system

    CN108768692A

  • Hybrid network configuration method and device, network structure and electronic equipment

    CN109756431A

  • Static vehicle-mounted Ethernet switch message forwarding method, system and computer

    CN113595914A