Communication method, communication device, electronic device and computer storage medium
By establishing a routing table between electronic device modules and realizing data transit, the problems of communication circuit complexity and increase of flying lines caused by the separate setting of physical ports and connection lines between modules are solved, and communication efficiency is improved.
Patent Information
- Application Number
- CN202211370849.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-03
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2042-11-03
AI Technical Summary
The modules in the electronic device communicate with each other by setting up physical ports and connection lines separately, resulting in complex communication circuits and increasing number of flying lines.
By establishing a routing table between modules, the module can determine the port that forwards the data frame according to the target address, and sends the data frame through the port to realize data relay between modules.
It reduces the physical ports and connection lines required between modules, reduces the complexity of communication circuits and the number of flying lines, and improves communication efficiency.
Smart Images

Figure CN115801657B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic communications, and in particular to a communication method, a communication device, an electronic device, and a computer storage medium therefor. Background Art
[0002] Generally, there may be multiple modules in an electronic device that need to communicate with each other. At this time, if each module in the electronic device realizes communication by separately setting physical ports and connection lines, it is easy to make the communication circuit complex and increase the number of flying wires between modules. Summary of the Invention
[0003] In view of this, it is necessary to provide a communication method, a communication device, and an electronic device to solve the technical problem that each module in the electronic device realizes communication by separately setting physical ports and connection lines.
[0004] In a first aspect, the present application provides a communication method, including: when a target data frame is received through a first port, obtaining a first target address in the target data frame; if the first target address is the same as the address of the first module, obtaining the data in the target data frame; if the first target address is different from the address of the first module, determining a second port corresponding to the first target address according to a routing table, and sending the target data frame through the second port.
[0005] In the method provided in the embodiment of the present application, when the first module receives a first data frame, it can determine whether the module itself is the recipient of the first data frame according to the first target address in the first data frame. If the first module is not the recipient of the first data frame, the first module can determine a second port for forwarding the first data frame according to the first target address and the routing table, and pass the first data frame to the next module in the data transmission link through the second port. That is to say, each module in the electronic device does not need to separately set physical ports and connection lines with each other. When two modules are not directly connected, data can be relayed through other modules to achieve communication, thus solving to a certain extent the technical problems of complex communication circuits and increased flying wires caused by separately setting physical ports and connection lines between modules.
[0006] In an embodiment of the present application, the determining the second port corresponding to the first target address according to the routing table includes: obtaining routing tables corresponding to each port of the first module; determining the port corresponding to the routing table containing the first target address as the second port.
[0007] In the above method, determining the port corresponding to the routing table containing the first target address as the second port enables the first module to send the target data frame to the module at the first target address through the second port.
[0008] In an embodiment of the present application, the method further includes: receiving a first probe frame through the second port, where the source address in the first probe frame is the first target address; recording the first target address in the routing table corresponding to the second port; if the target address of the first probe frame is the same as the address of the first module, sending a first response frame through the second port; the source address of the first response frame is the address of the first module, and the target address of the first response frame is the first target address; if the target address of the first probe frame is different from the address of the first module, sending the first probe frame through a port other than the second port.
[0009] In the above method, if the target address of the first probe frame is the same as the address of the first module, that is, it is determined that the recipient of the first probe frame is the first module, then after receiving the first probe frame, the first module returns a first response frame to the sender of the first probe frame to indicate that the first module has received the first probe frame; if the target address of the first probe frame is different from the address of the first module, that is, it is determined that the recipient of the first probe frame is not the first module, then after receiving the first probe frame, the first module sends the first probe frame through a port other than the second port. In this way, it is convenient to establish the communication path between the modules of the electronic device.
[0010] In an embodiment of the present application, the method further includes: receiving a second response frame through the second port, where the source address in the second response frame is the first target address; recording the first target address in the routing table corresponding to the second port; if the target address of the second response frame is different from the address of the first module, determining a third port corresponding to the target address of the second response frame according to the routing tables corresponding to the respective ports of the first module; sending the second response frame through the third port.
[0011] In the above method, after the first module receives the second response frame through the second port, if the recipient of the second response frame is not the first module, the first module determines the third port corresponding to the routing table containing the target address of the second response frame as the port for forwarding the second response frame according to the routing tables corresponding to the respective ports of the first module, and sends the second response frame through the third port, thereby improving the efficiency of establishing communication between the first template and the module corresponding to the first target address.
[0012] In an embodiment of the present application, the method further includes: if the destination address of the second response frame is the same as the address of the first module, periodically sending a connection detection frame through the second port; the source address of the connection detection frame is the address of the first module, and the destination address of the connection detection frame is the first destination address; after sending the connection detection frame, if a connection response frame is not received within a preset time period, delete the first destination address from the routing table corresponding to the second port.
[0013] In the above method, if the first module establishes a communication connection with the module corresponding to the first destination address, the first module periodically sends a connection detection frame through the second port to the module corresponding to the first destination address to monitor whether the first module maintains the connection status with the module corresponding to the first destination address, and when a connection response frame is not received within a preset time period, delete the first destination address from the routing table corresponding to the second port. In this way, the maintenance of the routing table of the port of the first module is realized, and the continuous communication connection between the first module and the module corresponding to the first destination address is ensured.
[0014] In an embodiment of the present application, the method further includes: when detecting a preset operation event for establishing a communication connection, determining a second destination address according to the preset operation event; generating a second detection frame according to the address of the first module and the second destination address; the source address of the second detection frame is the address of the first module, and the destination address of the second detection frame is the second destination address; sending the second detection frame through each port of the first module.
[0015] In the above method, when detecting a preset operation event for establishing a communication connection, the first module sends a second detection frame through each port of the first module to establish communication between the first module and the module corresponding to the second destination address.
[0016] In a second aspect, an embodiment of the present application provides a communication device, where the device includes: an address acquisition module, configured to acquire a first destination address in the target data frame when receiving the target data frame through the first port; a data acquisition module, configured to acquire the data in the target data frame if the first destination address is the same as the address of the first module; a data frame sending module, configured to determine a second port corresponding to the first destination address according to the routing table and send the target data frame through the second port if the first destination address is different from the address of the first module.
[0017] In the above solution, the communication device further includes: a data frame receiving module, configured to receive a first detection frame through the second port, where the source address in the first detection frame is the first target address; an address recording module, configured to record the first target address into the routing table corresponding to the second port; a first response frame sending module, configured to send a first response frame through the second port if the target address of the first detection frame is the same as the address of the first module; the source address of the first response frame is the address of the first module, and the target address of the first response frame is the first target address; a first detection frame sending module, configured to send the first detection frame through a port other than the second port if the target address of the first detection frame is different from the address of the first module.
[0018] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, configured to store program instructions; and a processor, configured to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, cause the electronic device to execute the above communication method.
[0019] In a fourth aspect, an embodiment of the present application provides a computer storage medium, where the computer storage medium stores program instructions, and when the program instructions run on an electronic device, cause the electronic device to execute the above communication method.
[0020] In addition, for the technical effects brought by the second aspect to the fourth aspect, reference may be made to the descriptions related to the methods of each design in the above communication method part, and details are not described herein again.
[0021] In summary, in the method provided by the embodiment of the present application, when the first module receives the first data frame, it can determine whether the module itself is the receiving object of the first data frame according to the first target address in the first data frame. If the first module is not the receiving object of the first data frame, the first module can determine the second port for forwarding the first data frame according to the first target address and the routing table, and pass the first data frame to the next module in the data transmission link through the second port. That is to say, each module in the electronic device does not need to be separately provided with physical ports and connection lines. When two modules are not directly connected, data can be relayed through other modules to achieve communication, thereby solving to a certain extent the technical problems of complex communication circuits and increased flying wires caused by separately setting physical ports and connection lines between each module. Description of the Drawings
[0022] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on the provided drawings.
[0023] Figure 1 It is a scenario diagram of the communication method provided by the embodiment of the present application.
[0024] Figure 2 It is a flowchart of the communication method provided by the embodiment of the present application.
[0025] Figure 3 It is a schematic diagram of the connection of modules in an electronic device in an embodiment of the present application.
[0026] Figure 4 It is a schematic diagram of the structure of a preset data frame format in an embodiment of the present application.
[0027] Figure 5 It is a schematic diagram of the process of a first module receiving and processing a detection frame in an embodiment of the present application.
[0028] Figure 6 It is a schematic diagram of the process of a first module receiving and processing a second response frame in an embodiment of the present application.
[0029] Figure 7 It is a schematic diagram of the process of a first module sending a detection frame in an embodiment of the present application.
[0030] Figure 8 It is a schematic diagram of the structure of a communication device provided by an embodiment of the present application.
[0031] Figure 9 It is a schematic diagram of the structure of a communication device provided by another embodiment of the present application.
[0032] Figure 10 It is a schematic diagram of the structure of an electronic device provided by the embodiment of the present application.
[0033] The following specific embodiments will further illustrate the present application in combination with the above drawings. Specific Embodiments
[0034] In order to more clearly understand the above objects, features, and advantages of the present application, the present application will be described in detail below in combination with the drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other.
[0035] In the following description, numerous specific details are set forth to provide a thorough understanding of the present application. The described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the scope of protection of the present application.
[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used in the specification of this application herein are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0037] Reference Figure 1 As shown, it is an application scenario diagram of the communication method provided by the embodiment of the present application. The communication method is applied to multiple modules (11, 12, 13, 14, 15, 16) of the electronic device 10. Each module of the electronic device 10 is provided with a port, and adjacent two ports can be connected by wire through their respective ports.
[0038] For example, the module 11 is provided with a port 111, the module 12 is provided with a port 121 and a port 122. The module 11 is connected to the port 121 of the module 12 through the port 111, and the module 12 is connected to the module 13 through the port 122.
[0039] For another example, the module 13 is further provided with a port 131, a port 132, and a port 133. The module 13 is connected to the port 122 of the module 12 through the port 131, the module 13 is connected to the module 14 through the port 132, and the module 13 is connected to the module 15 through the port 133. The module 14 is provided with a port 141, the module 15 is provided with a port 151 and a port 152, and the module 16 is provided with a port 161. The module 14 is connected to the port 132 of the module 13 through the port 141. The module 15 is connected to the port 133 of the module 13 through the port 151. The module 16 is connected to the port 152 of the module 15 through the port 161.
[0040] In all embodiments of the present application, the port is associated with a corresponding routing table, and the routing table records the addresses of the modules that can communicate through this port. In an embodiment of the present application, the port includes one or more of types of ports such as a Controller Area Network (CAN) port, a Universal Asynchronous Receiver Transmitter (UART) port, a Serial Peripheral Interface (SPI), and a Bluetooth Low Energy (BLE) port.
[0041] In an embodiment of the present application, each module 11 in the electronic device 10 does not need to be separately provided with a physical port and a connection line to achieve communication. When two modules 11 are not directly connected, data can be relayed through other modules 11 to achieve communication, thereby solving to a certain extent the technical problems of complex communication circuits and increased flying wires caused by separately setting physical ports and connection lines between the modules 11.
[0042] It should be noted that Figure 1 the examples in are only for illustrative purposes, and are not limited to this in actual applications. It can be understood that the electronic device 10 can be any one of electronic devices such as mobile energy storage devices, home energy storage devices, mobile air conditioners, household air conditioners, lawn mowers, floor sweepers, intelligent distribution panels, mobile phones, laptop computers, tablet computers, and smart large screens. Exemplarily, when the electronic device 10 is an energy storage device, the module 11 of the energy storage device can be a screen control board, the module 12 of the energy storage device can be a battery control board, the module 13 of the energy storage device can be an inverter control board, and the modules 14, 15, 15 of the energy storage device can be any one or a combination of multiple types of modules such as a maximum power point tracking (MPPT) control board.
[0043] Refer to Figure 2 shown, which is a flowchart of the communication method provided by an embodiment of the present application. The above communication method can be applied to the electronic device 10 as shown in Figure 1 shown. As shown in Figure 2 shown, the communication method specifically includes the following steps. According to different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted. As shown in Figure 2 shown, the communication method in an embodiment of the present application includes steps 201-203.
[0044] Step 201, when a target data frame is received through the first port, obtain the first target address in the target data frame.
[0045] The communication method provided by the present application can be applied to the first module in the electronic device 10, and the first module can be any module in the electronic device 10.
[0046] In step 201, the first port generally refers to any physical port of the first module. Since in an electronic device, each module is at least provided with one physical port, and through this physical port, wired connection can be made with adjacent other modules, the target data frame is the data frame received by the first module through its physical port. The first target address is the target address of the above target data frame, and the first target address is used to identify the destination module that receives the target data frame, that is, to indicate the recipient of the target data frame.
[0047] Reference Figure 3 As shown, it is a schematic diagram of the connection of modules in an electronic device in an example of the present application. In Figure 3 , the electronic device includes three modules, namely Module 1, Module 2, and Module 3, where Module 1 is respectively connected to Module 2 and Module 3. Among them, Module 1 is connected to Port 2 of Module 2 through Port 1. When Module 2 sends a target data frame to Port 1 of Module 1 through Port 2, Module 1 can be understood as the above-mentioned first module, and Port 1 can be understood as the above-mentioned first port. Among them, the target data frame includes a first target address, and this first target address can be the address of Module 1 or the address of Module 3.
[0048] In an embodiment of the present application, the module that sends the target data frame encapsulates the target data frame according to a preset data packet format.
[0049] Reference Figure 4 As shown, it is a schematic structural diagram of a preset data frame format in an embodiment of the present application. The preset data frame may include a start header field, a frame type field, a source address field, a target address field, a data length field, a data content field, and a check field. Among them, the start header field is used to indicate the start position of the frame. The frame type field is used to indicate the type of the frame. In this embodiment, the frame types corresponding to the frame type field include a data frame, a probe frame, a response probe frame, a connection detection frame, and a response connection detection frame. The source address field represents the address information of the sender of the frame, and the target address field represents the address information of the receiver of the frame. The data length field represents the frame length. The data content field contains the data of the frame. The check field represents the check bit of the frame. In an embodiment of the present application, the frame type of the target data frame is a data frame, and the target address field in the target data frame includes a first target address.
[0050] The first module receives the target data frame through the first port, and obtains the first target address of the target data frame from the target address field of the target data frame.
[0051] Step 202, if the first target address is the same as the address of the first module, obtain the data in the target data frame.
[0052] In Step 202, since the first target address is used to identify the destination module that receives the target data frame, that is, to indicate the receiver of the target data frame, when any module in the electronic device receives the target data frame through the port, it can determine whether to obtain the data in the target data frame by comparing whether the first target address is the same as its own address.
[0053] In an embodiment of the present application, if the first target address is the same as the address of the first module, indicating that the recipient of the target data frame is the first module, the first module can obtain the data in the target data frame from the data content field of the target data frame.
[0054] Step 203, if the first target address is different from the address of the first module, determine the second port corresponding to the first target address according to the routing table, and send the target data frame through the second port.
[0055] In an embodiment of the present application, if the first target address is different from the address of the first module, indicating that the recipient of the target data frame is not the first module, the first module can determine the second port corresponding to the first target address according to the routing table, and send the target data frame through the second port.
[0056] In an embodiment of the present application, the first module determines the second port corresponding to the first target address according to the routing table, including: obtaining the routing tables corresponding to each port of the first module (for example, Figure 1 port 111 in); determining the port corresponding to the routing table containing the first target address as the second port.
[0057] In an embodiment of the present application, each port 111 of the first module may correspond to a different routing table. The routing table of port 111 records the addresses of the modules 11 that this port 111 can connect to. In the embodiments of the present application, the port corresponding to the routing table containing the first target address is determined as the second port. In this way, the first module can send the target data frame to the module corresponding to the first target address through the second port. For example, referring to Figure 3 the example shown, assume that the first target address is the same as the address of module 3, and port 3 of module 1 is connected to port 4 of module 3. At this time, since module 1 detects that the routing table corresponding to port 3 contains the address of module 3, module 1 can determine port 3 as the second port and forward the target data frame to module 3 through port 3.
[0058] In the method provided by the embodiments of the present application, when the first module receives a data frame, it can determine whether the first module is the recipient of the first data frame according to the first target address in the data frame. If the first module is not the recipient of the data frame, the first module can determine the second port for forwarding the first data frame according to the first target address and the routing table, and pass the first data frame to the next module in the data transmission link through the second port. Through the method of data transfer, it can effectively solve the technical problems that each module of the original electronic device needs to separately set physical ports and connection lines to achieve data transmission, resulting in a complex communication circuit and an increase in flying wires.
[0059] In an embodiment of the present application, when it is detected that the electronic device 10 is powered on or a module in the electronic device establishes a communication connection with other modules, each module 11 in the electronic device 10 sends a probe frame to other modules according to the corresponding module indicated by a pre-configured document, so as to establish a communication connection between the modules 11. The pre-configured document defines the communication requirements between each module 11 and other modules. When the first module receives a probe frame sent by other modules, it can reply an acknowledgment frame to the module corresponding to the source address of the probe frame or forward the probe frame to the next module according to the probe frame, so as to complete the process of establishing the communication connection between the modules 11 of the electronic device 10.
[0060] In addition, when the first module receives a probe frame from other modules, it can record the source address of the probe frame on the routing table corresponding to the port where the probe frame is received, so as to establish the routing table of each port of the first module. That is to say, the first target address recorded in the routing table of the second port may be that the first module records the first target address in the routing table of the second port after receiving the probe frame sent by the first target address through the second port.
[0061] Reference Figure 5 As shown, it is a schematic flowchart of the first module receiving and processing a probe frame in an embodiment of the present application, which specifically includes the following steps.
[0062] Step 501, the first module receives a first probe frame through the second port, where the source address in the first probe frame is the first target address.
[0063] In an embodiment of the present application, the first module receives a first probe frame sent by other modules through the second port. The first probe frame is encapsulated according to the preset data packet format. In the embodiment of the present application, the specific content of encapsulating the first probe frame according to the preset data packet format can refer to the content of encapsulating the target data frame described above, which will not be elaborated here. For example, referring to Figure 3 the example shown, assuming that module 1 receives a first probe frame sent by module 3 through port 4 through port 3, and the source address of the first probe frame is the first target address, that is, the address of module 3. At this time, port 3 can be understood as the above-mentioned second port.
[0064] Step 502, record the first target address in the routing table corresponding to the second port.
[0065] In an embodiment of the present application, the first module may record the first target address, that is, the source address of the first detection frame, into the routing table corresponding to the second port. It can be understood that since the first module receives the detection frame with the source address of the first target address through the second port, it indicates that the first module can communicate with the module corresponding to the first target address through the second port. Therefore, the first module may record the first target address in the routing table corresponding to the second port for subsequent communication with the module corresponding to the first target address through the second port.
[0066] It should be noted that in all embodiments of the present application, a corresponding routing table may be set for each physical port of each module, and the content in the routing table is used to describe the addresses of other physical ports that communicate with the physical port.
[0067] Step 503, if the target address of the first detection frame is the same as the address of the first module, send the first response frame through the second port, where the source address of the first response frame is the address of the first module, and the target address of the first response frame is the first target address.
[0068] In an embodiment of the present application, if the target address of the first detection frame is the same as the address of the first module, that is, it is determined that the receiver of the first detection frame is the first module, then after receiving the first detection frame, the first module returns the first response frame to the sender of the first detection frame to indicate that the first module has received the first detection frame. The source address of the first response frame is the address of the first module, indicating that the sender of the first response frame is the first module. The target address of the first response frame is the first target address, indicating that the receiver of the first response frame is the sender of the first detection frame. In the embodiments of the present application, the specific content of the first response frame encapsulated in accordance with the preset data packet format may refer to the content of the above-mentioned encapsulation of the target data frame, which will not be elaborated here.
[0069] Step 504, if the target address of the first detection frame is different from the address of the first module, send the first detection frame through a port other than the second port.
[0070] In an embodiment of the present application, if the target address of the first detection frame is different from the address of the first module, that is, it is determined that the receiver of the first detection frame is not the first module, then after receiving the first detection frame, the first module sends the first detection frame through a port other than the second port. Specifically, the first module uses the port corresponding to the routing table that includes the target address of the first detection frame except for the second port as the forwarding port, and sends the first detection frame through the forwarding port. In this way, it is convenient to establish the communication path between the modules 11 of the electronic device 10.
[0071] In this embodiment, step 503 and step 504 are parallel steps, that is, the execution of step 503 and step 504 has no sequence. After step 503 is executed, step 504 will no longer be executed. Correspondingly, after step 504 is executed, step 503 will no longer be executed until the first module receives other detection frames again through the second port.
[0072] In addition, when the first module receives an acknowledgment frame from another module, it can record the source address of the acknowledgment frame in the routing table corresponding to the port where the acknowledgment frame is received, thereby establishing the routing tables of the respective ports of the first module. That is to say, the first target address recorded in the routing table of the second port above can be that after the first module receives the acknowledgment frame sent by the first target address through the second port, the first target address is recorded in the routing table of the second port.
[0073] Reference Figure 6 As shown, it is a schematic flowchart of the first module receiving and processing the second acknowledgment frame in an embodiment of the present application, which specifically includes the following steps.
[0074] Step 701, the first module receives the second acknowledgment frame through the second port, where the source address in the second acknowledgment frame is the first target address.
[0075] In an embodiment of the present application, the first module receives the second acknowledgment frame sent by the module with the first target address through the second port. In the embodiment of the present application, the specific content of the second acknowledgment frame encapsulated according to the preset data packet format can refer to the content of encapsulating the target data frame above.
[0076] Step 702, the first module records the first target address in the routing table corresponding to the second port.
[0077] In an embodiment of the present application, regardless of whether the first target address is the address of the first module, the first module first records the first target address in the routing table corresponding to the second port of the first module to indicate that the first module can communicate with the module corresponding to the first target address through the second port.
[0078] Step 703, if the target address of the second acknowledgment frame is different from the address of the first module, the first module determines the third port corresponding to the target address of the second acknowledgment frame according to the routing tables corresponding to the respective ports of the first module, and sends the second acknowledgment frame through the third port.
[0079] In an embodiment of the present application, if the destination address of the second response frame is different from the address of the first module, that is, the recipient of the second response frame is not the first module, the first module determines, according to the routing table corresponding to each port of the first module, the third port corresponding to the routing table containing the destination address of the second response frame as the port for forwarding the second response frame, and sends the second response frame through the third port.
[0080] Step 704, if the destination address of the second response frame is the same as the address of the first module, the connection detection frame is periodically sent through the second port, where the source address of the connection detection frame is the address of the first module, and the destination address of the connection detection frame is the first destination address.
[0081] In an embodiment of the present application, if the destination address of the second response frame is the same as the address of the first module, that is, the recipient of the second response frame is the first module, it indicates that a communication connection is established between the first module and the module corresponding to the first destination address. To maintain the connection state between the first module and the module corresponding to the first destination address, the first module periodically sends a connection detection frame to the module corresponding to the first destination address through the second port to monitor whether the first module maintains the connection state with the module corresponding to the first destination address. In the embodiment of the present application, the specific content of the connection detection frame encapsulated according to the preset data packet format may refer to the content of encapsulating the target data frame above.
[0082] Step 705, after the first module sends the connection detection frame, if the connection response frame is not received within the preset duration, the first destination address is deleted from the routing table corresponding to the second port.
[0083] In an embodiment of the present application, after the first module sends the connection detection frame, if the connection response frame is not received within the preset duration, it indicates whether the first module maintains a disconnected state with the module corresponding to the first destination address. The first module modifies the routing table corresponding to the second port, for example, deletes the first destination address or the address of the module connected to the second port from the routing table corresponding to the second port, and resends the probe frame pointing to the first destination address. In this way, the maintenance of the routing table of the port of the first module is realized, and the continuous communication connection between the first module and the module corresponding to the first destination address is ensured.
[0084] In an embodiment of the present application, the first module can also send a probe frame to other modules of the electronic device 10 to complete the process of establishing the communication connection between the modules 11 of the electronic device 10. Refer to Figure 7 As shown, it is a schematic flow diagram of the first module sending a probe frame in an embodiment of the present application, which specifically includes the following steps.
[0085] Step 601, when a preset operation event for establishing a communication connection is detected, the first module determines a second target address according to the preset operation event.
[0086] In an embodiment of the present application, the preset operation event includes at least one of an operation to start the electronic device 10 to power on or an operation to trigger the modules of the electronic device 10 to establish a communication connection. For example, the user can press the power-on button of the electronic device 10 to input an operation to start the electronic device 10 to power on. For another example, the user can trigger the operation of the modules of the electronic device 10 to establish a communication connection by adding a new module or resetting the communication path between the modules in the electronic device 10. When a preset operation event for establishing a communication connection is detected, the first module determines the address of the module that needs to communicate with the first module, that is, the second target address, from a pre-configured document.
[0087] Step 602, the first module generates a second probe frame according to the address of the first module and the second target address. The source address of the second probe frame is the address of the first module, and the target address of the second probe frame is the second target address.
[0088] In an embodiment of the present application, the first module uses the address of the first module as the source address of the second probe frame and uses the second target address of the module that needs to establish a communication connection with the first module as the target address of the second probe frame. In the embodiment of the present application, the specific content of encapsulating the second probe frame according to a preset data packet format can refer to the content of encapsulating the target data frame above.
[0089] Step 603, the first module sends the second probe frame through each port of the first module.
[0090] In an embodiment of the present application, the first module sends the second probe frame through each port of the first module to establish communication between the first module and the module corresponding to the second target address.
[0091] Reference Figure 8 As shown, it is a schematic structural diagram of a communication device 100 provided by an embodiment of the present application. The communication device 100 can be used to implement the above communication method.
[0092] Specifically, the communication device 100 includes an address acquisition module 101, a data acquisition module 102, and a data frame sending module 103.
[0093] The address acquisition module 101 is configured to acquire a first target address in the target data frame when receiving the target data frame through the first port.
[0094] The data acquisition module 102 is configured to acquire the data in the target data frame when the first target address is the same as the address of the first module;
[0095] The data frame sending module 103 is configured to determine a second port corresponding to the first target address according to a routing table when the first target address is different from the address of the first module, and send the target data frame through the second port.
[0096] As an embodiment, the data frame sending module 103 is specifically configured to obtain routing tables corresponding to each port of the first module; and determine the port corresponding to the routing table including the first target address as the second port.
[0097] Reference Figure 9 As shown in the figure, it is a schematic structural diagram of a communication device 100' provided by another embodiment of the present application. The communication device 100' can be used to implement the above communication method.
[0098] Specifically, in addition to the address acquisition module 101, the data acquisition module 102, and the data frame sending module 103, the communication device 100' further includes a data frame receiving module 104, a first address recording module 105, a first response frame sending module 106, and a first probe frame sending module 107.
[0099] The data frame receiving module 104 is configured to receive a first probe frame through the second port, where the source address in the first probe frame is the first target address.
[0100] The first address recording module 105 is configured to record the first target address into the routing table corresponding to the second port.
[0101] The first response frame sending module 106 is configured to, if the target address of the first probe frame is the same as the address of the first module, send a first response frame through the second port; the source address of the first response frame is the address of the first module, and the target address of the first response frame is the first target address.
[0102] The first probe frame sending module 107 is configured to, if the target address of the first probe frame is different from the address of the first module, send the first probe frame through a port other than the second port.
[0103] As an embodiment, the communication device 100' further includes:
[0104] A second response frame receiving module, configured to receive a second response frame through the second port, where the source address in the second response frame is the first target address.
[0105] A second address recording module, configured to record the first target address into the routing table corresponding to the second port.
[0106] A port determination module, configured to, if the destination address of the second response frame is different from the address of the first module, determine a third port corresponding to the destination address of the second response frame according to the routing table corresponding to each port of the first module.
[0107] A second response frame sending module, configured to send the second response frame through the third port.
[0108] As an embodiment, the communication device 100' further includes:
[0109] A connection detection frame sending module, configured to, if the destination address of the second response frame is the same as the address of the first module, periodically send a connection detection frame through the second port; the source address of the connection detection frame is the address of the first module, and the destination address of the connection detection frame is the first destination address.
[0110] A connection response frame receiving module, configured to, after sending the connection detection frame, if a connection response frame is not received within a preset time period, delete the first destination address from the routing table corresponding to the second port.
[0111] As an embodiment, the communication device 100' further includes:
[0112] A destination address determination module, configured to, when detecting a preset operation event for establishing a communication connection, determine a second destination address according to the preset operation event.
[0113] A probe frame generation module, configured to generate a second probe frame according to the address of the first module and the second destination address; the source address of the second probe frame is the address of the first module, and the destination address of the second probe frame is the second destination address.
[0114] A second probe frame sending module, configured to send the second probe frame through each port of the first module.
[0115] This application also provides a computer-readable storage medium. The computer-readable storage medium stores multiple instructions, and the multiple instructions are suitable for being loaded and executed by a processor to implement the corresponding steps of the above communication method, such as steps 201-203, steps 501-504, steps 601-603, steps 701-705.
[0116] Please refer to Figure 10 As shown, it is a schematic structural diagram of an electronic device 10 provided by an embodiment of this application. The electronic device 10 may include at least one processor 17 and a memory 18. The memory 18 includes a computer-readable storage medium, and the computer-readable storage medium is used to store multiple logical instructions, and the processor 17 can run the logical instructions to execute the above communication method.
[0117] Among them, when the logic instructions in the above computer-readable storage medium can be implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
[0118] The computer-readable storage medium can be set to store software programs and computer-executable programs, such as the program instructions corresponding to the communication method in the embodiments of the present application or the modules in the communication device 100 or the communication device 100'. The processor 17 executes functional applications and image processing by running the software programs, instructions or modules stored in the computer-readable storage medium, that is, implements the communication method in the above embodiments.
[0119] In the embodiments of the present application, the computer-readable storage medium includes non-volatile computer-readable memories, such as magnetic disks, memories, etc. It can be understood that the computer-readable storage medium can also include other non-volatile computer-readable memories, such as plug-in hard disks, smart media cards (SMCs), secure digital (SD) cards, flash cards, at least one flash device and / or other non-volatile solid-state storage devices.
[0120] In the embodiments of the present application, the processor 17 can be a central processing unit (CPU), or can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 17 is the control center of the electronic device 10, and can use various interfaces and lines to connect to other devices and / or systems / modules / units to provide communication functions for the applications of other devices and / or systems / modules / units.
[0121] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously.
[0122] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A communication method, characterized in that, The first module applied to an electronic device includes: When receiving a target data frame through the first port, obtain the first target address in the target data frame; If the first target address is the same as the address of the first module, obtain the data in the target data frame; If the first target address is different from the address of the first module, determine the second port corresponding to the first target address according to the routing table, and send the target data frame through the second port; Before receiving the target data frame through the first port, it further includes: Receiving a first probe frame through the second port, where the source address in the first probe frame is the first target address; Record the first target address into the routing table corresponding to the second port; If the target address of the first probe frame is the same as the address of the first module, send a first response frame through the second port; the source address of the first response frame is the address of the first module, and the target address of the first response frame is the first target address; If the target address of the first probe frame is different from the address of the first module, send the first probe frame through a port other than the second port.
2. The communication method according to claim 1, characterized in that, The determining the second port corresponding to the first target address according to the routing table includes: Obtain the routing tables corresponding to each port of the first module; Determine the port corresponding to the routing table containing the first target address as the second port.
3. The communication method according to claim 1, characterized in that, The method further includes: Receiving a second response frame through the second port, where the source address in the second response frame is the first target address; Record the first target address into the routing table corresponding to the second port; If the target address of the second response frame is different from the address of the first module, determine the third port corresponding to the target address of the second response frame according to the routing tables corresponding to each port of the first module; Send the second response frame through the third port.
4. The communication method according to claim 3, characterized in that, The method further includes: If the target address of the second response frame is the same as the address of the first module, periodically send a connection detection frame through the second port; the source address of the connection detection frame is the address of the first module, and the target address of the connection detection frame is the first target address; After sending the connection detection frame, if a connection response frame is not received within a preset duration, delete the first target address from the routing table corresponding to the second port.
5. The communication method according to any one of claims 1 to 4, characterized in that, The method further includes: When detecting a preset operation event for establishing a communication connection, determine a second target address according to the preset operation event; Generate a second probe frame according to the address of the first module and the second target address; the source address of the second probe frame is the address of the first module, and the target address of the second probe frame is the second target address; Send the second probe frame through each port of the first module.
6. A communication device, characterized in that, The first module applied to an electronic device, the device includes: An address acquisition module, configured to obtain the first target address in the target data frame when receiving a target data frame through the first port; A data acquisition module, configured to acquire the data in the target data frame if the first target address is the same as the address of the first module; A data frame sending module, configured to determine a second port corresponding to the first target address according to a routing table and send the target data frame through the second port if the first target address is different from the address of the first module; A data frame receiving module, configured to receive a first probe frame through the second port, where the source address in the first probe frame is the first target address; An address recording module, configured to record the first target address into the routing table corresponding to the second port; A first response frame sending module, configured to send a first response frame through the second port if the target address of the first probe frame is the same as the address of the first module; the source address of the first response frame is the address of the first module, and the target address of the first response frame is the first target address; A first probe frame sending module, configured to send the first probe frame through a port other than the second port if the target address of the first probe frame is different from the address of the first module.
7. An electronic device, characterized in that: The electronic device includes a processor, and the processor is configured to implement the communication method according to any one of claims 1 to 5 when executing a computer program stored in a memory.
8. 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 processor is caused to implement the communication method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Communication method and device based on asymmetric binary tree link, equipment and medium
CN114866370A