Method for realizing open source monsoon software bus communication based on TAP device
By launching the application on the open-source HarmonyOS terminal, obtaining the address and connecting to the server using the cellular network, managing terminal information and configuring the network card, the problem of communication between devices in different physical locations is solved, and stable and reliable multi-device collaborative work is achieved.
Patent Information
- Application Number
- CN202510251020.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-03-04
AI Technical Summary
The existing open-source HarmonyOS distributed soft bus technology cannot achieve effective communication between devices across physical locations, resulting in limited multi-device collaboration functions and the inability to transmit data and collaborate between devices at long distances or in different physical locations.
By launching a specific application on the open-source HarmonyOS terminal, a network identifier is generated using the device's unique identifier, a network address is obtained through the cellular network, a connection is established with the server, the server manages terminal information and assigns group codes, the terminal configures the network card and builds a forwarding mapping, enabling device communication across physical locations.
It breaks through the limitations of near-field communication, realizes effective data transmission between devices in different physical locations and multi-device collaborative work, and ensures the stability and reliability of the communication system.
Smart Images

Figure CN120281595B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of network communication, and in particular to a method for realizing open source Hongmeng soft bus communication based on a TAP device. BACKGROUND
[0002] With the popularization of intelligent devices, people's demand for device collaboration is growing, and the distributed soft bus technology of open source Hongmeng system appears. It forms a local area network by means of WLAN or Bluetooth, and realizes the unified communication management of "discovery, networking and transmission" between near-field devices.
[0003] However, the current technology has obvious limitations. Device discovery needs to be in the same layer 2 local area network. For example, multiple open source Hongmeng mobile phones are often in different physical locations, which is difficult to meet this condition, resulting in the inability to realize mutual communication through near-field communication, and the multi-device collaboration function relying on it cannot be effectively carried out, which greatly limits the application of open source Hongmeng in cross-regional and long-distance device collaboration scenarios. Overcome the dependence on near-field communication.
[0004] From the above, how to reduce the dependence on near-field communication while realizing the communication of devices across physical locations still needs to be solved. SUMMARY
[0005] In order to reduce the dependence on near-field communication while realizing the communication of devices across physical locations, the present application provides a method for realizing open source Hongmeng soft bus communication based on a TAP device.
[0006] In the first aspect, the present application provides a method for realizing open source Hongmeng soft bus communication based on a TAP device, which adopts the following technical scheme:
[0007] A method for implementing open source Hongmeng soft bus communication based on a TAP device, comprising: starting a specific application program in an open source Hongmeng terminal, generating a network identifier based on device unique identification information, obtaining corresponding network port listening permission and a network address, establishing a connection with a server using a transmission control protocol, and periodically sending an information message containing terminal key information to the server; the server receives the information message, and the server manages terminal information records according to the terminal identifier after analyzing the information message, responds to the terminal's request for obtaining a group code, and returns an existing group code or generates a new unique group code to the terminal; the terminal sends a join request to the server after obtaining the group code confirmed by the user, the server updates the terminal group information, allocates network address resources to the terminal and generates corresponding related network parameter information, and simultaneously sends the group terminal information to each terminal, and the terminal creates and configures a network card based on the group terminal information using a virtual network device; the terminal constructs a forwarding mapping according to the received group terminal information, and in the process of soft bus data transmission, the terminal queries the mapping according to the soft bus data destination identifier to forward the data packet, and simultaneously performs legality verification and processing on the received data packet according to the mapping; and determining whether the terminal state changes, if the terminal state changes, the server collects related information and updates the terminal state in the group, and each terminal updates the local state information according to the feedback of the server.
[0008] By adopting the above technical solution, the terminal and the server are connected and information interaction is completed by starting a specific application program in an open source Hongmeng terminal, the server manages terminal information and allocates a group code, the terminal configures a network card and constructs a forwarding mapping after joining a group, accurate data forwarding and legality verification are realized, and related information can be updated according to terminal state changes, so that in terms of reducing dependence on near field communication, the method is no longer limited to WLAN or Bluetooth near field communication mode in the same layer LAN, but uses a cellular network to obtain a network address, manages through interaction between the server and the terminal, and realizes device communication across physical locations by means of a virtual network device and a forwarding mapping mechanism, so that open source Hongmeng devices in different physical locations can break through the limitation of near field communication and effectively perform data transmission and multi-device collaborative work.
[0009] Optionally, the method further comprises: in the terminal initialization and server association, the device unique identification information is a device unique serial number SN, a MAC address is generated by calculating a hash mapping, the network address is a dynamic IPv6 address allocated by an operator obtained through cellular network dialing, the key information includes the SN, the MAC address, the IPv6 address, a UDP port and a heartbeat interval, and a virtual local area network application program uses a TCP protocol to establish a connection with the server and send a "heartbeat message".
[0010] By adopting the technical scheme, the MAC address is generated by using the device unique serial number SN through the virtual local area network application program, the dynamic IPv6 address is obtained through the cellular network, the key information is integrated to form the heartbeat message, and the TCP protocol is used to establish the connection with the server and periodically send the heartbeat message, so that the stable association between the terminal and the server is realized, the real-time monitoring of the terminal state by the server, the information management, and the cross-physical location communication related operation based on the same are provided, and the server can continuously obtain the terminal state and accurately identify the terminal in the non-near field communication environment, so that the communication process is smoothly promoted.
[0011] Optionally, in the server information management and group code processing step, the server performs the following operation: maintaining a group code usage record list; when receiving the "group code acquisition message" of the terminal and the corresponding terminal entry has no group code, generating a new group code, and checking whether the new group code is in the usage record list in the generation process, if yes, re-generating until a unique and unused group code is obtained and returned to the terminal.
[0012] By adopting the technical scheme, in the server information management and group code processing step, the server maintains the group code usage record list, and generates a new group code for the terminal without the group code and repeatedly checks the uniqueness of the group code when processing the group code acquisition request of the terminal, so that the uniqueness and effectiveness of the group code in the system are ensured, the group code conflict is avoided, the terminal is accurately added to the specific group, the orderliness of the group management in the virtual local area network and the accuracy of the communication are ensured, different terminals can realize effective group communication based on the unique group code, and the stability and reliability of the cross-physical location device communication system are improved.
[0013] Optionally, in the terminal group joining and network adaptation step, the server performs the following operation: after receiving the "group joining request message" of the terminal, searching for the corresponding entry in the "terminal information data table" through the SN and updating the group code; when allocating the idle IP address from the IP address pool in the group, using a conflict detection algorithm to detect each candidate IP address, if the IP address is occupied, selecting the next one until an unoccupied IP address is found; generating the "terminal network parameter information message" of the allocated IP address, the subnet mask and the broadcast address and returning the message to the terminal; generating the "group terminal list message" of the multiple terminals with the same group code and sending the message to all terminals in the group.
[0014] By adopting the technical solution, when the terminal requests to join the group, the server accurately updates the terminal group code, allocates a unique IP address to the terminal by using the conflict detection algorithm, and generates key network parameters and a group terminal list and sends them to the related terminal. This series of operations builds the network identity and communication environment of the terminal in the group, ensures that each terminal has a unique and non-conflicting network address, enables them to know each other according to the group terminal list, and lays a solid foundation for smooth communication of devices across physical locations in the same virtual local area network, and ensures the orderly progress of subsequent data transmission and interaction.
[0015] Optionally, in the mapping-based data forwarding and communication control step, the terminal performs the following operations: after receiving the "group terminal list message", the SN, MAC, IPv6 address and UDP port information of each terminal are parsed, and a "local forwarding mapping table" is generated using a hash table data structure; when the distributed soft bus sends a message to the tap network card through the Linux kernel network protocol stack, the "soft bus data message" is received, encapsulated into a UDP packet, and the destination MAC address is obtained by parsing the Ethernet two-layer header; the "local forwarding mapping table" is queried; if there is a corresponding entry, the UDP packet is sent to the IPv6 address and UDP port of the entry, and if there is no corresponding entry, the UDP packet is broadcasted to the addresses and ports of other entries except the local machine; when a message is received through the monitored UDP port, the IPv6 address and UDP port of the opposite end of the message are obtained, and the "local forwarding mapping table" is queried; if there is no corresponding entry, the message is discarded, and if there is, the source MAC address is obtained by parsing the Ethernet two-layer message, and compared with the MAC address of the corresponding entry in the mapping table; if they are equal, the UDP data message is submitted to the Linux kernel through the tap network card for processing by the network protocol stack and submitted to the distributed soft bus, and if they are not equal, the message is discarded.
[0016] By adopting the technical solution, in the mapping-based data forwarding and communication control step, the terminal generates a mapping table by parsing the group terminal information, and accurately matches and decides based on the mapping table when data is transmitted and received. When transmitting data, it can accurately forward or broadcast according to the destination address; when receiving data, it strictly verifies the legality of the source and only processes legal messages. This ensures that data is efficiently, accurately and securely transmitted between devices across physical locations, effectively avoids illegal data interference, and ensures the stable operation of the open-source Hongmeng soft bus communication system and the reliability of data interaction.
[0017] Optionally, in the terminal state management and system maintenance step, the server and the terminal perform the following operations: when the user closes the virtual local area network function in the terminal interface, the terminal application program carries the SN and the group code to send a "request to leave the group message" to the server; after the server receives the "request to leave the group message", the terminal information in the group is sorted, and arranged according to the alphabetical order of the SN or the time order of joining the group; the server generates a "group terminal list message" excluding the terminal information and sends it to all terminals in the group; after each terminal receives the "group terminal list message", the "local forwarding mapping table" is updated; the server monitors the "heartbeat message" sent by the terminal for N heartbeat cycles, and if the "heartbeat message" of a certain terminal is not received within the cycle, the above-mentioned operation of sorting the terminal information in the group, generating and sending the "group terminal list message" is performed, and each terminal updates the "local forwarding mapping table".
[0018] By adopting the above technical scheme, in the terminal state management and system maintenance process, the server and the terminal cooperate, the terminal actively reports the leaving request, the server reorganizes the terminal information in the group according to this, generates an updated list and pushes it to each terminal, and at the same time, the server actively discovers the abnormal offline terminal through heartbeat monitoring, and also performs the updating operation. This series of operations can timely perceive the change of the terminal state, dynamically adjust the group information, ensure that the local forwarding mapping table of each terminal always matches the actual member composition of the group, maintain the stable operation of the cross-physical-location device communication system, ensure that the data transmission is always based on accurate terminal relationship, and improve the reliability and adaptability of the whole system.
[0019] In a second aspect, the application provides a device for implementing open source Hongmeng soft bus communication based on a TAP device, which adopts the following technical scheme:
[0020] A device for implementing open source Hongmeng soft bus communication based on a TAP device, comprising:
[0021] A network identifier generation module, which, when a specific application program of the open source Hongmeng terminal is started, generates a network identifier based on device unique identifier information, acquires corresponding network port listening permission and a network address, establishes a connection with a server by using a transmission control protocol, and periodically sends an information message containing terminal key information to the server;
[0022] The server receives the information message, and after analyzing the information message, manages terminal information records according to the terminal identifier; in response to a terminal request for obtaining a group code, the server returns an existing group code or generates a new unique group code for the terminal;
[0023] The terminal sends a joining request to the server after obtaining the group code confirmed by the user, the server updates the terminal group information, the server allocates network address resources to the terminal and generates corresponding related network parameter information, and meanwhile, the server sends the group terminal information to each terminal, and the terminal creates and configures a network card based on the group terminal information by using a virtual network device;
[0024] The terminal constructs a forwarding mapping according to the received group terminal information, and in the process of soft bus data transmission, the terminal queries the mapping according to a soft bus data destination identifier to perform data packet forwarding, and meanwhile, the terminal performs legitimacy verification and processing on the received data packet according to the mapping;
[0025] The terminal state judgment module is used to judge whether the terminal state is changed, and if the terminal state is changed, the server collects related information and updates the terminal state in the group, and each terminal updates the local state information according to the feedback of the server.
[0026] In a third aspect, the application provides a system for implementing open-source Hongmeng soft bus communication based on a TAP device, and the following technical scheme is adopted:
[0027] A system for implementing open-source Hongmeng soft bus communication based on a TAP device, comprising a processor, and the processor runs a program of the method for implementing open-source Hongmeng soft bus communication based on a TAP device according to any one of the above.
[0028] In a fourth aspect, the application provides a storage medium, and the following technical scheme is adopted:
[0029] A storage medium, which stores a program of the method for implementing open-source Hongmeng soft bus communication based on a TAP device according to any one of the above.
[0030] In summary, the application has at least one of the following beneficial technical effects:
[0031] Firstly, by starting a specific application on the open-source Hongmeng terminal, a network address is obtained by means of a cellular network, so that the terminal establishes a connection with the server and interacts with the server. The server manages and allocates group codes to the terminal, and the terminal configures a network card and constructs a forwarding mapping after joining the group, thereby realizing communication between devices in different physical locations. This breaks through the limitation of the open-source Hongmeng soft bus relying on near field communication, and enables devices in different locations to effectively transmit data and work cooperatively.
[0032] Secondly, in the terminal initialization and server association, server information management and group code processing, terminal group joining and network adaptation, mapping-based data forwarding and communication management, and terminal state management and system maintenance, through a series of orderly operations, from building stable connection, ensuring group code uniqueness, allocating network resources, ensuring accurate and safe data transmission to dynamically adjusting group information, it provides comprehensive foundation for cross-physical-location device communication, and ensures stable, efficient and reliable operation of the communication system. BRIEF DESCRIPTION OF DRAWINGS
[0033] Figure 1 is a flow chart of a method for implementing open source Hongmeng soft bus communication based on a TAP device according to an exemplary embodiment. DETAILED DESCRIPTION
[0034] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings.
[0035] In the description of the present specification, the description of the terms "certain embodiments", "one embodiment", "some embodiments", "illustrative embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in connection with the described embodiments or examples are included in at least one embodiment or example of the present application. In the present specification, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0036] The embodiments of the present application disclose a method for implementing open source Hongmeng soft bus communication based on a TAP device, referring to Figure 1 , comprising:
[0037] S100, when a specific application program of the open source Hongmeng terminal is started, the specific application program generates a network identifier based on device unique identification information, acquires corresponding network port listening permission and network address, establishes a connection with a server by using a transmission control protocol, and periodically sends an information message containing terminal key information to the server.
[0038] Among them, the user manually starts the virtual local area network application program specially developed in the terminal interface of the open source Hongmeng system, and the virtual local area network application program is the key entrance to realize cross-region device communication. The start of the virtual local area network application program marks the start of the entire communication process. After the virtual local area network application program is started, the unique serial number (SN) given during the production of the device is used to convert the SN into a MAC address through a specific hash mapping algorithm. In a local area network environment, the MAC address is like the identity card of the device, and the network device identifies and distinguishes different terminals according to it, ensuring that the data is accurately sent to the target device.
[0039] To meet the specific data receiving needs, the virtual local area network application program randomly selects a UDP port for listening, wherein the UDP protocol is simple and efficient, and does not require a complex connection establishment and maintenance process, and is suitable for scenarios with high real-time requirements and little impact of data loss. Subsequent data transmission will take advantage of its characteristics to achieve fast communication. Due to the dramatic increase in the number of Internet of Things devices, the traditional IPv4 address resources are exhausted, and the virtual local area network application program dials through the cellular network to obtain a dynamically allocated IPv6 address from the operator network. This dynamic allocation method enables devices to flexibly obtain available network addresses in different network environments, laying a foundation for device access to the Internet and the construction of a virtual local area network.
[0040] The virtual local area network application program uses the TCP protocol to establish a stable and reliable communication link with the server. The TCP protocol ensures accurate and complete data transmission through three-way handshake. After connection is established, the application program periodically sends a "heartbeat message" to the server, which contains information such as the local SN, generated MAC address, obtained IPv6 address, listened UDP port, and set heartbeat interval. The server can determine the online status of the device and obtain the latest network status information by continuously receiving the heartbeat message, in order to facilitate subsequent management and coordination.
[0041] S110, the server receives the information message, and the server parses the information message and manages the terminal information record according to the terminal identifier. In response to the terminal's request for obtaining a group code, the server returns an existing group code or generates a new unique group code to the terminal.
[0042] Among them, after the server receives the "heartbeat message" sent by the terminal, according to the pre-defined message format, the SN, MAC address, IPv6 address, UDP port and heartbeat interval are accurately extracted. The server uses the extracted SN to search for the corresponding entry in the "terminal information data table". If not found, it indicates that it is a new access terminal, and the server immediately creates a new entry, fills in the parsed MAC address, IPv6 address, UDP port, heartbeat interval and other information, and records the current time as the initial last heartbeat time. If there is an existing corresponding entry, update the MAC address (to prevent the device MAC address from changing), IPv6 address (considering dynamic IP address change), UDP port (if the port changes), heartbeat interval (if the terminal resets), and last heartbeat time. In this way, the latest status and network-related information of each access terminal can be mastered in real time, providing accurate data support for subsequent group management and communication coordination.
[0043] The terminal virtual local area network application program completes the preliminary initialization and information reporting, and carries the device SN to send a "get group code message" to the server for joining a specific virtual local area network group. After the server receives the request, it looks up the corresponding entry in the "terminal information data table" according to the SN. If the entry already has a group code, it is directly returned to the terminal; if the group code is not found, the server randomly generates a group code that has not been used in the entire system from the internally maintained available group code resource pool and returns it to the terminal, avoiding group code conflicts.
[0044] After the terminal receives the group code returned by the server, it is displayed to the user on the terminal interface. The user can directly confirm the group code to join the group, or manually input other group codes according to actual needs; multiple terminals join the same virtual local area network with the same group code to realize mutual communication and collaborative work.
[0045] S120, after the terminal obtains the user-confirmed group code, it initiates a join request to the server, the server updates the terminal group information, the server allocates network address resources to the terminal and generates corresponding related network parameter information, and simultaneously sends the group terminal information to each terminal, and the terminal creates and configures a network card based on the group terminal information using a virtual network device.
[0046] Among them, after the terminal user confirms or manually inputs the group code, the terminal virtual local area network application program combines the device SN and the determined group code into a "request to join the group message" and sends it to the server, indicating the terminal's willingness to join a specific group. After the server receives the "request to join the group message", it finds the corresponding terminal entry in the "terminal information data table" through the SN, updates the group code of the entry to the group code that the terminal requests to join, and records that the terminal has joined the specified group.
[0047] To enable the newly joined terminal to communicate normally within the group, the server calculates the hash mapped to the free IP address in the IP address pool maintained for each group through the SN, and uses a specific algorithm and detection mechanism to ensure that the allocated IP address is free and not occupied by other terminals. After determining the free IP address, the corresponding subnet mask and broadcast address are generated according to the network configuration rules, and the allocated IP address, subnet mask, and broadcast address are combined into a "terminal network parameter information message" and returned to the terminal.
[0048] In order to let all the terminals in the group know the new member, the server collects the information of multiple terminals with the same group code, including the SN, MAC address, IPv6 address, UDP port of the terminal, etc., sorts and generates a "group terminal list message" and sends it to all terminals in the group, preparing for subsequent data forwarding and communication interaction. After receiving the "terminal network parameter information message" returned by the server, the terminal virtual local area network application program uses the tun / tap device provided by the operating system, creates a virtual tap type network card by calling the corresponding system interface, and provides a basic network interface for communication in the virtual local area network.
[0049] After creating the tap type network card, the application program configures the network card in detail according to the IP address, subnet mask, broadcast address allocated by the server in the "terminal network parameter information message", and the MAC address generated before. The IP address determines the network position of the terminal in the virtual local area network, the subnet mask helps to determine the network range, the broadcast address supports broadcast communication, and the MAC address ensures the uniqueness of the network card in the network. After the configuration is completed, the open source open source distributed bus can use the network card to send and receive messages, realize the functions of "discovery, networking and transmission", and lay the network foundation for multi-device collaborative communication.
[0050] S130, the terminal constructs a forwarding mapping according to the received group terminal information. In the data transmission process of the soft bus, the mapping is queried according to the soft bus data destination identifier for data packet forwarding, and the received data packet is verified and processed according to the mapping.
[0051] Among them, after receiving the "group terminal list message" sent by the server, the terminal virtual local area network application program extracts the SN, MAC address, IPv6 address, UDP port and other key information of all terminals in the group according to the specific format analysis rule. The application program generates a "local forwarding mapping table" according to the extracted terminal information. The local forwarding mapping table plays a navigation role in the terminal data forwarding process, establishes the correspondence between the terminal information and the network address, and facilitates the terminal to quickly find the IPv6 address and UDP port corresponding to the target terminal, improves the data transmission accuracy and efficiency, and ensures the orderly communication in the group.
[0052] When the distributed soft bus of open source open source sends a message and routes it to the previously configured tap type network card through the Linux kernel network protocol stack, the terminal virtual local area network application program receives the "soft bus data message". Since the subsequent data transmission needs to use the UDP feature, it encapsulates it into a UDP data packet to meet the real-time requirements of fast communication.
[0053] After encapsulation, the application parses the Ethernet layer 2 header information in the UDP packet, extracts the destination MAC address, and then queries the "local forwarding mapping table" to determine whether there is an entry with the MAC address as the destination MAC address. If a corresponding entry is found in the mapping table, the application sends the UDP packet to the IPv6 address and UDP port recorded in the entry, so that the data accurately reaches the target terminal; if no matching entry is found, the application sends the UDP packet to the IPv6 addresses and UDP ports of all entries in the "local forwarding mapping table" except the local IPv6 address and UDP port, ensuring that the data can be widely spread within the group when the location of the unknown target terminal is unknown, and ensuring communication reliability.
[0054] When the terminal receives a message through the previously monitored UDP port, it first obtains the IPv6 address and UDP port information of the sender of the message to identify the source of the message. After obtaining the source address information, the application immediately queries the "local forwarding mapping table" to determine whether there is an entry matching the IPv6 address and UDP port. For messages from addresses and ports not in the table, the application considers the source to be unreliable or invalid and directly discards the message, ensuring system security and data transmission accuracy.
[0055] If a matching entry is found in the mapping table, the application treats the received UDP data as a "soft bus datagram" and further parses its Ethernet layer 2 message to extract the source MAC address, which is compared with the MAC address of the corresponding entry in the mapping table. If the two are not equal, it indicates that the data source is abnormal and may be tampered with or disguised, and the message is discarded; if they are equal, it indicates that the data source is reliable, and the application submits the UDP data packet to the Linux kernel through the tap type network card, which is processed by the network protocol stack and then submitted to the distributed soft bus, completing the data reception and processing process.
[0056] S140, determine whether the terminal state has changed, if the terminal state has changed, the server collects relevant information and updates the terminal state in the group, and each terminal updates the local state information according to the server feedback.
[0057] When the user performs a virtual local area network closing function operation on the open source Hongmeng terminal interface, the terminal virtual local area network application combines the device SN and the current group code into a "request to leave the group message" and sends it to the server, informing the server that the terminal wants to leave the current virtual local area network group. After receiving the "request to leave the group message", the server organizes the information of multiple terminals with the same group code, generates a "group terminal list message" containing the information of all terminals in the group except the terminal that is about to leave, and sends it to all terminals in the group. After receiving the message, each terminal updates its "local forwarding mapping table" according to the information in it to adjust the communication and data forwarding strategy, ensuring stable and efficient communication within the group.
[0058] The server continuously monitors the "heartbeat message" sent by each terminal during operation, and sets a preset N heartbeat period for each terminal. If the "heartbeat message" of a certain terminal is not received within the period, the server considers that the terminal has been offline, i.e., has left the group, because the heartbeat message is an important indicator for the terminal and the server to maintain online connection. Once the server determines that a certain terminal has been offline, the processing flow is similar to the terminal actively requesting to leave the group. The server organizes the information of multiple terminals with the same group code to generate a "group terminal list message" that excludes the offline terminal information, and sends it to all terminals in the group. After receiving the message, each terminal updates its own "local forwarding mapping table" according to the information in the message, ensuring the accuracy of the communication status and data forwarding information in the group, timely removing offline terminal information, and improving the efficiency and stability of virtual local area network communication.
[0059] Suppose there is a scenario: a certain enterprise has multiple office locations distributed in different cities, and employees of the enterprise use open source Hongmeng system smart devices (such as mobile phones, tablets, etc.) for multi-device collaborative office in daily work; in the traditional open source Hongmeng system distributed soft bus technology, because device discovery needs to be in the same layer 2 local area network, like these devices in different physical locations, they cannot communicate with each other through near field communication (such as WLAN or Bluetooth), resulting in the inability to effectively carry out multi-device collaboration functions that rely on near field communication. For example, employee A located in city A wants to share data and collaborate with the device used by employee B located in city B, which cannot be achieved according to the traditional technology, because their devices are not in the same layer 2 local area network.
[0060] The method for implementing open source Hongmeng soft bus communication based on TAP devices according to the present application can well solve this problem. Employee A and employee B manually start the virtual local area network application program on their respective open source Hongmeng terminals. The application program generates a MAC address using the device serial number (SN), obtains a dynamically allocated IPv6 address through cellular network dialing, randomly listens to a UDP port, and establishes a connection with the server using the TCP protocol, and periodically sends "heartbeat messages" containing device key information. In this way, the server can real-time master the online status and network information of the devices of employee A and employee B.
[0061] The devices of employee A and employee B request the server to obtain a group code, and the server allocates the same group code to them (assuming they join the enterprise office group). Then, the devices of employee A and employee B send a request to join the group to the server, and the server updates the group information, allocates a unique IP address and other network parameters to them, and sends the information of all terminals in the group to them. Their devices create and configure tap type network cards according to this information, and prepare for communication.
[0062] When employee A wants to share a file with employee B, the open source Hongmeng distributed soft bus sends a message through the Linux kernel network protocol stack to the tap card, the device encapsulates the message into a UDP data packet, queries the network address of employee B's device according to the 'local forwarding mapping table', and accurately sends the data packet to employee B's device. After receiving the data packet, the device of employee B verifies the legitimacy and submits the data to the distributed soft bus for processing, thereby successfully receiving the file.
[0063] If employee A temporarily closes the virtual local area network function, the device will send a'request to leave the group message' to the server, the server updates the group information and notifies other terminals (including employee B's device), and employee B's device updates the 'local forwarding mapping table' to ensure that subsequent communication is not affected. Or if employee B's device is offline due to network failure or other reasons, the server will find out by monitoring the 'heartbeat message', and will also update the group information and notify employee A's device, and employee A's device will update the 'local forwarding mapping table' to avoid sending data to the offline device.
[0064] Through the above operation, the scheme of the application overcomes the dependence of the open source Hongmeng system on near field communication, realizes communication between devices across physical locations, enables devices used by employees in different cities to effectively transmit data and work collaboratively, meets the office needs of enterprises in cross-regional scenarios, and improves work efficiency and collaborative ability of devices.
[0065] The device for realizing open source Hongmeng soft bus communication based on a TAP device comprises:
[0066] A network identifier generation module, when a specific application program is started on an open source Hongmeng terminal, the specific application program is used to generate a network identifier based on device unique identifier information, obtain corresponding network port listening permissions and a network address, establish a connection with a server using a transmission control protocol, and periodically send information messages containing terminal key information to the server;
[0067] The server receives the information messages, and after analyzing the information messages, the server manages terminal information records according to terminal identifiers, responds to terminal group code acquisition requests, and returns existing group codes or generates new unique group codes to the terminals;
[0068] After the terminal acquires the group code confirmed by the user, the terminal initiates a joining request to the server, the server updates the terminal group information, the server allocates network address resources to the terminal and generates corresponding related network parameter information, and simultaneously sends group terminal information to each terminal, and the terminal creates and configures a network card based on the group terminal information using a virtual network device;
[0069] The terminal constructs a forwarding map according to the received group terminal information, and in the soft bus data transmission process, forwards a data packet according to the map according to a soft bus data destination identifier, and meanwhile, verifies and processes the received data packet according to the map.
[0070] The terminal state judgment module is used for judging whether the terminal state is changed, if the terminal state is changed, the server collects relevant information and updates the terminal state in the group, and each terminal updates the local state information according to the feedback of the server.
[0071] The embodiment of the application further discloses a system for realizing open source Hongmeng soft bus communication based on a TAP device, comprising a processor, and a program of the method for realizing open source Hongmeng soft bus communication based on the TAP device in any one of the above methods is run in the processor.
[0072] The embodiment of the application further discloses a storage medium, and the program of the method for realizing open source Hongmeng soft bus communication based on the TAP device in any one of the above methods is stored in the storage medium.
[0073] Although the embodiments of the application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the application, and those skilled in the art can make changes, modifications, replacements and variations to the above embodiments within the scope of the application.
Claims
1. A method for implementing open source HongMeng soft bus communication based on a TAP device, characterized in that, Comprise: In the open source terminal starts a specific application, the specific application generates a network identifier based on device unique identifier information, obtains corresponding network port listening permission and network address, establishes a connection with the server using the transmission control protocol, and periodically sends information messages containing terminal key information to the server; The server receives the information message, and the server manages the terminal information record after analyzing the information message according to the terminal identifier, responds to the terminal group code request, and returns the existing group code or generates a new unique group code to the terminal; The terminal obtains the group code confirmed by the user and initiates a join request to the server, the server updates the terminal group information, the server allocates network address resources to the terminal and generates corresponding related network parameter information, and simultaneously sends the group terminal information to each terminal, and the terminal creates and configures a network card based on the group terminal information using a virtual network device; The terminal constructs a forwarding mapping according to the received group terminal information, and in the soft bus data transmission process, the data packet is forwarded according to the soft bus data destination identifier query mapping, and the received data packet is verified and processed according to the mapping; Determine whether the terminal state changes, if the terminal state changes, the server collects related information and updates the terminal state in the group, and each terminal updates the local state information according to the server feedback.
2. The method for realizing open source Hongmeng software bus communication based on a TAP device according to claim 1, characterized in that, The method further comprises: In the terminal initialization and server association, the device unique identifier information is a device unique serial number SN, a MAC address is generated by calculating a hash mapping, the network address is a dynamic IPv6 address allocated by the operator through cellular network dialing, the key information includes SN, MAC address, IPv6 address, UDP port and heartbeat interval, and the virtual local area network application program uses the TCP protocol to establish a connection with the server and sends a "heartbeat message".
3. The method for realizing open source Hongmeng software bus communication based on TAP device according to claim 1, characterized in that, In the server information management and group code processing step, the server performs the following operations: Maintain a group code usage record list; When receiving the "get group code message" of the terminal and there is no group code in the corresponding terminal entry, generate a new group code, and check whether the new group code is in the usage record list during generation, if it is, regenerate until a unique and unused group code is obtained and returned to the terminal.
4. The method for realizing open source Hongmeng software bus communication based on TAP device according to claim 1, characterized in that, In the terminal group joining and network adaptation step, the server performs the following operations: After receiving the "request to join the group message" of the terminal, find the corresponding entry in the "terminal information data table" through the SN and update the group code; When allocating a free IP address from the group IP address pool, a conflict detection algorithm is used to detect each candidate IP address, if it has been occupied, select the next one, until an unoccupied IP address is found; Generate a "terminal network parameter information message" containing the allocated IP address, subnet mask and broadcast address and return it to the terminal; Generate a "group terminal list message" containing the information of multiple terminals with the same group code and send it to all terminals in the group.
5. The method for realizing open source Hongmeng software bus communication based on TAP device according to claim 1, characterized in that, The terminal performs the following operations: After receiving the "group terminal list message", the SN, MAC, IPv6 address, and UDP port information of each terminal are parsed, and a hash table data structure is used to generate a "local forwarding mapping table"; When the distributed soft bus sends a message to the tap network card through the Linux kernel network protocol stack, the "soft bus data message" is received, encapsulated into a UDP packet, and the destination MAC address is obtained by parsing the Ethernet two-layer header. The "local forwarding mapping table" is queried; If there is a corresponding entry, the UDP packet is sent to the IPv6 address and UDP port of the entry. If there is no corresponding entry, it is broadcasted to other entry addresses and ports except the local machine; When a message is received through the monitored UDP port, the IPv6 address and UDP port of the message are obtained, and the "local forwarding mapping table" is queried; If there is no corresponding entry, the message is discarded. If there is, the source MAC address is obtained by parsing the Ethernet two-layer message, and compared with the MAC address of the corresponding entry in the mapping table. If they are equal, the UDP data message is submitted to the Linux kernel through the tap network card for processing by the network protocol stack and submission to the distributed soft bus. If they are not equal, the message is discarded.
6. The method for realizing open source Hongmeng soft bus communication based on a TAP device according to claim 1, characterized in that, In the terminal state management and system maintenance step, the server and the terminal perform the following operations: When the user closes the virtual local area network function on the terminal interface, the terminal application program carries the SN and group code to send a "request to leave the group message" to the server; After the server receives the "request to leave the group message", the terminal information in the group is sorted according to the alphabetical order of SN or the time order of joining the group; The server generates a "group terminal list message" that excludes the terminal information and sends it to all terminals in the group; After each terminal receives the "group terminal list message", the "local forwarding mapping table" is updated; The server monitors the "heartbeat message" sent by the terminal for N heartbeat periods. If the "heartbeat message" of a certain terminal is not received within the period, the above operations of sorting the terminal information in the group, generating and sending the "group terminal list message" are performed, and each terminal updates the "local forwarding mapping table".
7. An apparatus for implementing open source HONIC software bus communication based on TAP device, characterized in that, It includes: A network identifier generation module, which starts a specific application program on an open source Hongmeng terminal, generates a network identifier based on device unique identifier information, obtains corresponding network port listening permission and network address, establishes a connection with a server using the Transmission Control Protocol, and periodically sends an information message containing terminal key information to the server; The server receives the information message, and the server parses the information message and manages terminal information records according to the terminal identifier. In response to a terminal request for a group code, the server returns an existing group code or generates a new unique group code for the terminal; After the terminal obtains the user-confirmed group code, it initiates a join request to the server. The server updates the terminal group information, allocates network address resources to the terminal and generates corresponding related network parameter information, and simultaneously sends group terminal information to each terminal. The terminal creates and configures a network card based on the group terminal information using a virtual network device; The terminal constructs a forwarding map according to the received group terminal information, and in the soft bus data transmission process, the terminal queries the map according to a soft bus data destination identifier to forward a data packet, and meanwhile, the terminal verifies and processes the received data packet according to the map. The terminal state judgment module is used for judging whether the terminal state is changed, and if the terminal state is changed, the server collects relevant information and updates the terminal state in the group, and each terminal updates the local state information according to the feedback of the server.
8. A system for implementing open source HONIC software bus communication based on TAP device, characterized in that, The processor has a program of the method for realizing the open source Hongmeng soft bus communication based on the TAP device as claimed in any one of claims 1-6 running therein.
9. A storage medium, characterized by The program of the method for realizing the open source Hongmeng soft bus communication based on the TAP device as claimed in any one of claims 1-6 is stored.
Citation Information
Patent Citations
Data query method, electronic equipment, server, storage equipment and gateway equipment
CN112804377A
Redundant network communication method and device based on virtual network card and terminal equipment
CN113794618A