A communication method and related apparatus

By configuring the target switching port inside the communication equipment and using the idle Ethernet port to build a virtual switching network, the problems of complex and costly wiring between communication equipment are solved, and efficient communication between devices is achieved.

CN122268831APending Publication Date: 2026-06-23SUNGROW POWER SUPPLY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SUNGROW POWER SUPPLY CO LTD
Filing Date
2024-12-23
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In the existing technology, communication between communication devices requires the use of switches, which leads to complex wiring and increased costs.

Method used

By configuring the target switching port inside the communication equipment, a virtual switching network can be built using the idle Ethernet ports to achieve packet forwarding and reduce dependence on physical switches.

Benefits of technology

It simplifies the wiring between communication devices, reduces costs, and enables efficient communication between devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122268831A_ABST
    Figure CN122268831A_ABST
Patent Text Reader

Abstract

The application provides a communication method and related device, and relates to the field of communication.In the application, a target switching network port is configured based on an Ethernet port in a first communication device, so that when a communication message is received in the target switching network port, the communication message is parsed to obtain a target address, a target network port corresponding to the target address in the target switching network port is called, and the communication message is forwarded to a target device corresponding to the target address.In other words, in the application, the forwarding operation of the communication message is performed through the target switching network port, so that the communication between the first communication devices is realized.Because the target switching network port is configured, a switch is no longer needed, the wiring between the first communication devices can be reduced, and the cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and more specifically, to a communication method and related apparatus. Background Technology

[0002] With the continuous development of energy storage systems, the communication needs between communication devices are also increasing. Taking LC (Local Controller) as an example, there are usually multiple LCs, and each LC is equipped with multiple Ethernet ports.

[0003] For communication devices equipped with Ethernet ports, how to enable communication is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] In view of this, this application provides a communication method and related apparatus to solve the problem of the urgent need to realize communication of communication devices.

[0005] To solve the above-mentioned technical problems, this application adopts the following technical solution:

[0006] In a first aspect, this application discloses a communication method applied to a first communication device, wherein the first communication device is internally configured with a target switching network port based on an Ethernet port configuration, and the communication method includes:

[0007] When a communication message is received at the target switching network port, the communication message is parsed to obtain the target address;

[0008] The target network port corresponding to the target address in the target switching network port is invoked, and the communication message is forwarded to the target device corresponding to the target address.

[0009] Optionally, the target switching port includes a first port and a second port; the first port of the first communication device is connected to the first port or the second port of the preceding communication device, and the second port of the first communication device is connected to the first port or the second port of the following communication device.

[0010] Optionally, the configuration process of the target switching port includes:

[0011] Perform database initialization and interface initialization operations;

[0012] Configure the operating modes of the first network port and the second network port to the preset modes;

[0013] Configure the operation modes of the first network port and the second network port;

[0014] Configure the first network port and the second network port as the target switching network ports.

[0015] Optionally, configuring the first network port and the second network port as target switching ports includes:

[0016] Configure the first network port and the second network port as independent network ports;

[0017] The first network port and the second network port are configured as switching ports using a preset command set to obtain the target switching port;

[0018] Configure the address information of the target switching port;

[0019] Configure the automatic switching function for the first and second ports in the target switching network interface.

[0020] Optionally, calling the target network port corresponding to the target address in the target switching network port to forward the communication packet to the target device corresponding to the target address includes:

[0021] Obtain address mapping information, wherein the address mapping information stores the mapping relationship between the device media access control address (MAC address) of a non-first communication device and the network port in the first communication device;

[0022] If the address mapping information includes the mapping relationship of the target address, and the target address is not the MAC address of the first communication device, the target network port corresponding to the target address is queried from the address mapping information;

[0023] The communication message is forwarded to the target device corresponding to the target address using the target network port.

[0024] Optionally, forwarding the communication packet to the target device corresponding to the target address using the target network port includes:

[0025] The target network port is controlled to forward the communication message to the communication device connected to the target network port, so that the communication message is forwarded to the target device corresponding to the target address through the communication device connected to the target network port according to the cascaded communication link between the communication devices.

[0026] Optionally, after obtaining the address mapping information, the following may also be included:

[0027] If the address mapping information includes the mapping relationship of the target address, and the target address is the MAC address of the first communication device, the communication message is sent to the processing end of the first communication device for processing.

[0028] Optionally, after obtaining the address mapping information, the following may also be included:

[0029] If the address mapping information does not include the mapping relationship of the target address, the target address is broadcast to determine the target device corresponding to the target address;

[0030] The address mapping information includes a mapping relationship between the MAC address of the target device and the network port in the first communication device.

[0031] Optionally, it also includes:

[0032] Upon receiving a response message from a third communication device to a specified address broadcast by a second communication device, if it is determined that no specified mapping relationship exists in the address mapping information, then the specified mapping relationship is added to the address mapping information; the specified mapping relationship is the mapping relationship between the specified address of the third communication device and the network port in the first communication device.

[0033] Secondly, this application discloses a communication device applied to a first communication equipment, wherein the first communication equipment is internally configured with a target switching network port based on an Ethernet port configuration, and the communication device includes:

[0034] The message parsing module is used to parse the communication message to obtain the target address when the target switching network port receives the communication message;

[0035] The message forwarding module is used to call the target network port corresponding to the target address in the target switching network port and forward the communication message to the target device corresponding to the target address.

[0036] Thirdly, this application discloses a communication device, which is any first communication device, and the first communication device is used to perform the above-described communication method.

[0037] Fourthly, this application discloses a communication system, including an energy management system and a plurality of the aforementioned communication devices;

[0038] The network port of the energy management system is connected to a network port of the first communication device via a switch.

[0039] This application provides a communication method and related apparatus. Within a first communication device, a target switching port is configured based on an Ethernet port. When a communication packet is received at the target switching port, the packet is parsed to obtain a target address. The target switching port corresponding to the target address is then invoked to forward the communication packet to the target device corresponding to that address. In other words, this application achieves communication between first communication devices by forwarding communication packets through the target switching port. Because a target switching port is configured, a switch is no longer needed, reducing cabling between the first communication devices and lowering costs. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0041] Figure 1 A schematic diagram of LC communication provided in an embodiment of this application;

[0042] Figure 2 Another LC communication schematic diagram provided for an embodiment of this application;

[0043] Figure 3 A flowchart illustrating the configuration of a target switching network port, as provided in an embodiment of this application;

[0044] Figure 4 A flowchart illustrating a communication method provided in an embodiment of this application;

[0045] Figure 5 A message forwarding flowchart is provided for an embodiment of this application;

[0046] Figure 6 A flowchart illustrating another communication method provided in an embodiment of this application;

[0047] Figure 7 This is a schematic diagram of the structure of a communication device provided in an embodiment of this application. Detailed Implementation

[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0049] With the continuous development of energy storage systems, the communication needs between communication devices are also increasing. Taking LC as an example, there are usually multiple LCs, and each LC is equipped with multiple Ethernet ports.

[0050] like Figure 1 As shown, the LC in the current 200CS industrial and commercial energy storage unit displays four Ethernet ports: ETH1 (ETH: Ethernet), ETH2, ETH3, and ETH4. Of these four Ethernet ports, only ETH1 and ETH2 are actually used. ETH1 is typically connected to other Ethernet devices, such as a PCS (Power Conversion System, energy storage converter). ETH2 is connected to a switch to expand the number of ports. ETH3 and ETH4 are currently unused. It should be noted that... Figure 1 In the diagram, only ETH1 is drawn in LC1. ETH1 is not drawn in the other LCs, namely LC2 to LC6. However, the structure of LC2 and LC6 is the same as that of LC1, and also includes ETH1, ETH2, ETH3 and ETH4.

[0051] Figure 1 Although ETH3 and ETH4 are not currently in use, the 200CS individual energy storage units for industrial and commercial applications are connected in a daisy-chain configuration below the EMS (Energy Management System) controller. This networking method requires external switches. In this case, the ETH2 pins of the EMS are connected to the corresponding switches, as are the ETH2 pins of LC1, LC2, LC3, LC4, LC5, and LC6. This daisy-chain connection inevitably increases the overall cost and complicates the wiring layout within the energy storage cabinets.

[0052] Therefore, this embodiment improves the communication method by eliminating the use of a switch and instead utilizing idle ETH ports to construct the target switching port. In a real-world scenario, since ETH2 is no longer connected to a switch and is idle, and since ETH1 is already connected to other Ethernet devices, its purpose remains unchanged. At this point, ETH2, ETH3, and ETH4 are all idle and underutilized. Therefore, two ports can be selected from ETH2, ETH3, and ETH4. These ports can be used for both receiving and sending messages. Using these two ports to construct the target switching port for message exchange eliminates the need for a switch, thus reducing cabling and costs.

[0053] In one implementation, the unused ETH3 and ETH4 ports in the LC can be used to simulate a switch, thus obtaining the target switching port. Specifically, the ETH3 and ETH4 ports are bound together by configuration to form a transparent Layer 2 network bridge, which can be called the virtual switching network veth0. From the application layer perspective of the communication devices, the bound ETH3 and ETH4 ports will present a veth0 device node. veth0 can forward network traffic at the data frame level below the network layer. Ethernet devices connected to it are as if they are connected to the same switch and can perform packet forwarding operations. Since no switch is needed to forward data frames, cabling between communication devices is simplified, and costs are reduced. In another implementation, veth0 can self-learn MAC (Media Access Control Address) addresses and forward traffic based on MAC addresses. During forwarding, ETH3 or ETH4 forwards according to the address, preventing random forwarding and thus avoiding network storms.

[0054] Based on the above, one embodiment of this application provides a communication method, wherein the executing entity can be a first communication device, and the first communication device can be any communication device, such as any one of LC1, LC2, LC3, etc. mentioned above.

[0055] The first communication device has a target switching port configured based on an Ethernet port. This target switching port is used for packet forwarding.

[0056] Specifically, such as Figure 2 As shown, since ETH2, ETH3, and ETH4 are all idle and underutilized, two network ports can be selected from ETH2, ETH3, and ETH4 to construct the target switching network port. For example, ETH3 and ETH4 can be used to construct the target switching network port, while ETH2 can be used for other purposes. In this case, by cascading the ETH3 and ETH4 Ethernet ports of each LC, each LC can communicate with the EMS. In this networking method, each LC can operate independently without affecting others. In another embodiment, ETH2 and ETH3 or ETH2 and ETH4 can also be used to construct the target switching network port. The specific choice depends on the actual purpose of the network ports.

[0057] In a real-world scenario, the target switching port includes a first port and a second port. In one embodiment, the first port can be an ETH3 port and the second port can be an ETH4 port.

[0058] In one implementation, target switching ports of different first communication devices are cascaded. Specifically, when the target switching port includes a first port and a second port, the first port of the first communication device is connected to the first port or the second port of the preceding communication device, and the second port of the first communication device is connected to the first port or the second port of the following communication device.

[0059] like Figure 2 As shown, taking LC2 as an example, LC1 is the preceding device of LC2, and LC3 is the following device of LC2. Taking the construction of a target switching interface between ETH3 and ETH4 as an example, the first interface is either ETH3 or ETH4, and the second interface is the other interface between ETH3 and ETH4.

[0060] In practical scenarios, the ETH4 of the preceding communication device can be connected to the ETH3 of the following communication device. Furthermore, arbitrary connections are possible, such as connecting the ETH4 of the preceding communication device to the ETH3 of the following communication device, or connecting the ETH3 of the following communication device to the ETH3 of the next communication device. The specific connection method can be determined based on the actual configuration. However, it must be ensured that for the same communication network controller (LC), one of its two switching ports is connected to the preceding communication device of that LC, and the other is connected to the following communication device of that LC.

[0061] One type of connection is as follows Figure 2 As shown, the ETH2 port of EMS is connected to one end of the switch via a network cable. The other end of the switch is connected to the ETH3 port of LC1 via a network cable. The ETH4 port of LC1 is connected to the ETH4 port of LC2 via a network cable. The ETH3 port of LC2 is connected to the ETH3 port of LC3 via a network cable. The ETH4 port of LC3 is connected to the ETH3 port of LC4 via a network cable. The ETH4 port of LC4 is connected to the ETH4 port of LC5 via a network cable. The ETH3 port of LC5 is connected to the ETH3 port of LC6 via a network cable.

[0062] Based on the above structure, in another implementation of the present invention, taking the construction of ETH3 and ETH4 as the target switching interface as an example, the configuration process of the target switching interface is introduced.

[0063] Reference Figure 3 The configuration process for the target switching port includes:

[0064] S11. Perform database initialization and interface initialization operations.

[0065] In this embodiment, when configuring the target switching network, the initialization configuration is first performed. The initialization configuration mainly involves performing a series of initialization configuration actions such as database initialization, configuring promiscuous mode, and binding operation method set.

[0066] Specifically, database initialization and interface initialization operations are performed first.

[0067] To elaborate, LC boots up the operating system kernel, the kernel driver initializes the critical database, and initializes the MAC address learning table exchange interface, which facilitates the subsequent configuration of ETH3 and ETH4 as switching network ports.

[0068] S12. Configure the operating mode of the first network port and the second network port to the preset mode.

[0069] Specifically, the default mode is generally promiscuous mode. In real-world scenarios, network interface cards (NICs) mainly operate in the following modes:

[0070] 1) Broadcast mode: In this mode, the network card receives all broadcast frames sent to the physical address (i.e., MAC address) 0xffffff.

[0071] 2) Multicast mode: The network card receives frames sent to the multicast address. These frames can be received simultaneously by other hosts in the group, but cannot be received by hosts outside the group.

[0072] 3) Direct mode: In this mode, the network card only receives frames whose destination address is itself.

[0073] 4) Promiscuous mode: In this mode, the network card receives all frames that pass through it, not just those with the destination address or broadcast address.

[0074] 5) Listening mode: In listening mode, the network card passes all data packets in the wireless signal to the operating system for processing. It is commonly used for wireless network analysis and packet capture.

[0075] 6) Tunnel mode: In this mode, the network card encapsulates data packets into packets of other protocols for transmission. It is commonly used in Virtual Private Networks (VPNs) and tunneling protocols.

[0076] In order for the LC to function as a switch, it needs to be able to receive various data frames passing through it. That is, the driver needs to be configured to put the ETH3 and ETH4 network ports in promiscuous mode.

[0077] S13. Configure the operation mode of the first network port and the second network port.

[0078] Specifically, the operation mode refers to the set of operation methods for the switch interface. Configuring the operation modes for the first and second network interfaces means binding the operation method sets of the switch interfaces to the upper-layer application, so that the operation method sets of the switch interfaces can be called by the upper-layer application. A specific example of a call could be:

[0079] The upper-layer application calls the switch port according to the operation method set, obtains the communication messages received by the switch port, and performs parsing operations on the messages.

[0080] After the above steps, the initial configuration can be completed. After the initial configuration is completed, the first network port and the second network port are configured as the target switching network ports.

[0081] S14. Configure the first network port and the second network port as target switching ports.

[0082] In practice, the first and second network ports are configured to enable them to function as target switching ports.

[0083] In one implementation, when configuring the first and second network ports, they are first configured as independent network ports. Specifically, the operating system kernel driver needs to load the regular network port driver first to ensure that ETH3 and ETH4 are used as independent network ports, providing a foundation for subsequently configuring these two ports as switching ports.

[0084] Then, the first and second network ports are configured as switching ports using a preset command set to obtain the target switching port. In practical scenarios, a preset command set needs to be configured in advance. The preset command set can be the brctl command set, which is a command-line tool for managing Linux virtual Ethernet bridges. It can create, maintain, and check bridge configurations in the kernel. To use the brctl command set, this embodiment of the application needs to port the brctl command set to the LC file system in advance. In this embodiment, during the target switching port configuration process, the brctl command set is used to configure ETH3 and ETH4 as switching ports in the system startup script. In practical scenarios, after loading the ordinary network port driver, the kernel will mount the file system, thereby running the brctl command set to configure ETH3 and ETH4 as switching ports, thus obtaining the target switching port.

[0085] Next, configure the address information of the target switching port. The address information can be an IP (Internet Protocol) address. Specifically, in this embodiment, ETH3 and ETH4 are configured as a single target switching port, which is a virtual device node, named target switching port veth0. Target switching port veth0 needs a corresponding IP address. When configuring the IP address of target switching port veth0, this can be done at the end of the startup script by specifying a command, such as the `ifconfig` command for network interface configuration. After configuring the IP address of target switching port veth0, it can be accessed through that IP address.

[0086] Finally, the automatic switching function of the first and second network ports in the target switching network ports is set to configure the first and second network ports as the target switching network ports.

[0087] The automatic switching function refers to the automatic signal switching (Auto MDI / MDI-X) function, which means that the network card can automatically recognize and adapt to straight-through or crossover network cables, thus eliminating the need to manually change the cable connection method. The software configures automatic signal switching upon startup, enabling the LC to communicate with external Ethernet devices.

[0088] After configuring ETH3 and ETH4 as switching ports, before the switching port driver is officially loaded, the startup script will first set up automatic switching of Ethernet signals for these two switching ports (ETH3 and ETH4). After the setting is completed, the switching port driver will be loaded. Once the switching port driver is loaded and running, two switching ports, namely ETH3 and ETH4, are connected to the target switching port veth0 for interconnection with the upper and lower level LCs and the top-level EMS.

[0089] like Figure 2 As shown, for LC1, after setting ETH3 and ETH4 inside LC1 as the target switching interface veth0, ETH3 can be used to communicate with EMS through the switch, and ETH4 can be used to communicate with ETH3 of LC2.

[0090] In this embodiment of the application, ETH3 and ETH4 are configured as a target exchange interface veth0. Subsequent operation instructions for the target exchange interface veth0 are operation instructions for ETH3 and / or ETH4.

[0091] It should be noted that for a single LC, if the LC is configured with a large number of Ethernet ports, such as adding other Ethernet ports in addition to ETH1-ETH4, then other ports can be used to build another target switching port, which can be called veth1. veth2, veth3, etc., can be configured later as needed.

[0092] The above embodiments describe the configuration process of the target switching port. After the target switching port is configured, it can receive communication packets. Specifically, refer to... Figure 4 The communication methods include:

[0093] S21. If a communication message is received at the target switching network port, the communication message is parsed to obtain the target address.

[0094] like Figure 2 As shown, taking LC2 as an example, ETH3 of LC2 can receive communication messages sent by LC3, and ETH4 can receive communication messages sent by LC1.

[0095] If the target switching port veth0 of LC2 receives a communication message, the communication message can be an Ethernet message, or specifically an energy storage system communication message. The content of the communication message can be configured according to actual conditions, such as a message to issue control commands or a message to upload operating information.

[0096] In one implementation, when the veth0 of the LC2 receives a message, it can be either the first network port or the second network port that receives the communication message. That is, both the first and second network ports have the capability to receive messages, and one can be chosen for message reception and forwarding.

[0097] After receiving a communication message on one of the first and second network ports, the running driver will unpack the communication message to obtain the target address in the communication message. This target address is the communication address of the target device to which the communication message needs to be sent. Specifically, the target address can be a MAC address.

[0098] S22. Call the target network port corresponding to the target address in the target switching network port, and forward the communication message to the target device corresponding to the target address.

[0099] After resolving the MAC address, the LC needs to send the packet to the communication device corresponding to the MAC address. In the LC, since the target switching port includes two switching ports, the key is which switching port to use to output the communication packet.

[0100] Therefore, in one embodiment of this application, address mapping information can be pre-configured. This address mapping information can be in the form of a MAC address learning table, or other mapping methods. The address mapping information stores the mapping relationship between MAC addresses of non-first communication devices and network ports in the first communication device, such as storing the mapping relationship between ETH3 or ETH4 in the first communication device and the MAC addresses of other communication devices.

[0101] Generally, there are many mapping relationships in the address mapping information. Once the device MAC address is fixed, it will not change subsequently.

[0102] For example, one mapping relationship is: LC4's MAC address is mapped to LC1's ETH4, and another mapping relationship is: LC3's MAC address is mapped to LC2's ETH3.

[0103] If the mapping relationship is that the MAC address of LC4 is mapped to ETH4 of LC1, it means that if a communication message is to be sent to LC4, then ETH4 of LC1 needs to be used for message output.

[0104] Similarly, since the MAC address of LC3 is mapped to ETH3 of LC2, it means that if a communication message is to be sent to LC3, then the message output needs to be performed using ETH3 of LC2.

[0105] In one implementation of the present invention, address mapping information can be established for each first communication device, and this address mapping information can be stored in a corresponding database. This address mapping relationship can be accessed by the first communication device. In another implementation, a master address mapping information can be established, which includes the address mapping information of each first communication device. Each first communication device can only access its own address mapping information.

[0106] As shown above, the address mapping information stores the mapping relationship between the LC's MAC address and the network port in the target switching network port of the first communication device. Therefore, through this target switching network port, packets can be transmitted to the LC's MAC address in the mapping relationship. At this time, based on the mapping relationship in the address mapping information, the target network port corresponding to the target address in the target switching network port can be called to forward the communication packet to the target device corresponding to the target address.

[0107] In this embodiment, within the first communication device, a target switching port is configured based on the Ethernet port. When a communication packet is received at the target switching port, the packet is parsed to obtain a target address. The target switching port corresponding to the target address is then called to forward the communication packet to the target device corresponding to that address. In other words, this application achieves communication between the first communication devices by forwarding communication packets through the target switching port. Because a target switching port is configured, a switch is no longer needed, reducing cabling between the first communication devices and lowering costs.

[0108] In another implementation of this application, the mapping relationship in the address mapping information is learned continuously. When the packet is forwarded for the first time, there is no corresponding mapping relationship in the address mapping information. At this time, the mapping relationship can be generated by broadcasting and stored in the address mapping information.

[0109] Specifically, when the target switching port of the first communication device receives a communication message for the first time, after parsing the communication message to obtain the target address, since it is the first time the communication message has been received, there is no mapping relationship for the target address in the address mapping information. Therefore, the target address is broadcast to determine the target device corresponding to the target address, and the mapping relationship between the MAC address of the target device and the network port in the first communication device is added to the address mapping information.

[0110] To elaborate, the first communication device can send a broadcast message to query the MAC addresses of other communication devices to determine the target device corresponding to the target address. The queried target address (e.g., MAC address) of the communication device is then bound to the corresponding network port of the target switching network (i.e., the network port that sends messages to the target device, such as ETH3 or ETH4) to obtain a mapping relationship. This mapping relationship is stored in address mapping information, and subsequently, the network port can be used for message forwarding based on the mapping relationship.

[0111] More specifically, the broadcast message sent by the first communication device is to broadcast the target address to determine the target device corresponding to the target address. Taking LC2 as the first communication device, if LC2 receives a communication message and its address mapping information does not store the mapping relationship of the target address of the communication message, LC2 cannot know which communication device the message should be sent to. In this case, LC2 can broadcast the target address in the communication message, such as asking LC3 whether the target address is LC3's MAC address. If it is not LC3's MAC address, LC3 continues to ask LC4 whether the target address is LC4's MAC address. If it is not LC4's MAC address, LC4 continues to ask LC5 whether the target address is LC5's MAC address, and so on, until asking the last communication device, such as LC6, whether the target address is LC6's MAC address. If none of them are LC6's MAC address, since the MAC addresses of all communication devices have been queried, it means that there is no communication device corresponding to the target address in the current communication link, and the communication message can be discarded.

[0112] If the target address is determined to be the MAC address of LC4, LC4 can send a message to LC3 indicating that the target address is LC4's MAC address. Upon receiving this message, LC3 sends a message to LC2 indicating that the target address is LC4's MAC address. When LC2 receives this message, since it receives it through LC2's ETH3, LC2 can determine that ETH3 is the network port that sends communication messages to LC4. Therefore, a mapping relationship can be added to the address mapping information between the MAC address of the target device (e.g., LC4's MAC address) and the corresponding network port in the target switching network port of the first communication device (e.g., LC2). This network port is determined through the cascading communication link between the communication devices, such as ETH3. Once this mapping relationship is established, it generally will not change. However, if the cascading communication link changes, such as changing the connection from LC2's ETH3 to LC3's ETH3 to LC2's ETH4 to LC3's ETH3, meaning the communication network port used for communication changes, the mapping relationship needs to be adjusted accordingly.

[0113] In another implementation of the present invention, when forwarding messages, there are two communication directions. Taking the first communication device as LC2 as an example, the forward direction is to forward messages to LC1, and the backward direction is to forward messages to LC3. Therefore, when LC2 learns address mapping information in the present invention, it will perform mapping relationship learning operations in both directions to ensure that LC2 can forward messages from both directions in the future.

[0114] In this embodiment, by continuously learning address mapping information during the communication process, the target network interface can be quickly determined using the content of the address mapping information during subsequent message forwarding, so as to use the target network interface for message transmission.

[0115] In another implementation of this application, the first communication device may also learn address mapping information during the process of broadcasting addresses by other communication devices.

[0116] Specifically, upon receiving a response message from a third communication device to a specified address broadcast by a second communication device, if it is determined that no specified mapping relationship exists in the address mapping information, then the specified mapping relationship is added to the address mapping information; the specified mapping relationship is the mapping relationship between the specified address of the third communication device and the network port in the first communication device.

[0117] Taking LC2 as the first communication device, LC1 as the second communication device, and LC4 as the third communication device as an example, we will introduce the learning process of LC2's address mapping information.

[0118] Specifically, if LC1 receives a communication message from EMS or LC2 and determines that the address in the message is not stored in its own address mapping information, it will broadcast a query to find the LC device corresponding to the specified address in the received message (i.e., the target address in the message received by LC1). The broadcast process is as follows: LC1 queries LC2 to see if the specified address is LC2's MAC address. If it is not LC2's MAC address, LC2 continues to query LC3 to see if the specified address is LC3's MAC address, and so on. Refer to the corresponding content above for the specific broadcast process. If LC4 receives the broadcast message and determines that the target address in the broadcast message is LC4's MAC address, LC4 will not continue broadcasting. Instead, it will send a response message to LC1 through LC3 and LC2, informing LC1 that the address is LC4's address. Because... Figure 2 In the cascaded communication link, when LC4 transmits a response message to LC1, it passes through LC3 and LC2. If LC2 finds that its address mapping information does not contain a mapping relationship for LC4's MAC address, it can establish such a mapping relationship. In this embodiment, this mapping relationship is called a designated mapping relationship, which is the mapping relationship between a designated address of the third communication device (such as the MAC address of LC4) and the network port in the target switching network port of the first communication device (this network port is used to transmit information to LC4, such as ETH3 of LC2). Subsequently, if LC2 needs to send a communication message to LC4, it can query the communication network port as ETH3 from the designated mapping relationship, and then send the communication message to LC3 through ETH3, which will then forward the communication message to LC4.

[0119] In this embodiment, when the second communication device queries a certain MAC address, and the third communication device corresponding to that MAC address sends a response message to the second communication device, if the first communication device, which is located between the cascaded communication link of the third and second communication devices, determines that its own address mapping information does not contain a specified mapping relationship for the MAC address of the third communication device, then the specified mapping relationship is added to its own address mapping information. This saves the first communication device from the process of subsequently broadcasting addresses to learn the mapping relationship and simplifies the process of constructing address mapping information.

[0120] After obtaining the address mapping information, subsequent packet forwarding can be performed based on the address mapping information through the aforementioned cascaded communication links. This allows the target switching port veth0 to function similarly to a switch. At this point, veth0 parses and judges the received packets before routing and forwarding them, thus eliminating the need to install a switch, simplifying cabling and saving costs. Specifically, in another implementation of this application, refer to... Figure 5 Step S22 may specifically include the following sub-steps:

[0121] S31. Obtain address mapping information.

[0122] The address mapping information stores the mapping relationship between the MAC address of a device other than the first communication device and the network port in the first communication device. For a detailed explanation of the address mapping information, please refer to the corresponding description above.

[0123] S32. If the address mapping information includes the mapping relationship of the target address and the target address is not the MAC address of the first communication device, query the target network port corresponding to the target address from the address mapping information.

[0124] The mapping relationships in the address mapping information are continuously learned by the LC. When the LC is first set up and put into use, the address mapping information is empty. If a communication message is received, since the address mapping information is empty, there is no mapping relationship for the target address of the communication message. Therefore, the LC needs to query the LC device corresponding to the target address through a broadcast message. Based on the cascaded communication link between devices, it determines that the message can be output to the network port of the LC device, and then establishes the mapping relationship between the target address of the LC device and the network port. Through continuous learning, the mapping relationships in the address mapping information become more and more numerous. The specific learning process is explained in the corresponding description above.

[0125] In practical applications, the target address to be sent in this communication message may or may not exist in the address mapping information. Subsequently, after receiving a communication message, the target address is obtained by parsing the message. The system then checks if a mapping relationship exists for that target address in the address mapping information. If such a mapping relationship exists, it further determines whether the target address is the MAC address of the first communication device. If the target address is not the MAC address of the first communication device, it indicates that the target address is not the local address, and the communication message needs to be forwarded to another communication device. At this point, based on the mapping relationship, the network port corresponding to the target address in the target switching network port can be queried; this queried network port can be called the target network port.

[0126] For example, such as Figure 2 As shown, if LC2 receives a communication message and the destination address in the communication message is the MAC address of LC4, then it queries the address mapping information. This address mapping information stores the mapping relationship corresponding to the MAC address of LC4. Further querying this mapping relationship determines that the network interface corresponding to the MAC address of LC4 is ETH3 of LC2. This means that the communication message needs to be output from ETH3 of LC2 until the communication message reaches LC4.

[0127] S33. Use the target network port to forward the communication message to the target device corresponding to the target address.

[0128] Specifically, the first communication device will output communication messages through the target network port, and the communication messages will be transmitted through the network cable between the communication devices.

[0129] In one implementation, the target network port is controlled to forward the communication message to the communication device connected to the target network port, so that the communication message is forwarded to the target device corresponding to the target address through the communication device connected to the target network port according to the cascaded communication link between the communication devices.

[0130] like Figure 2 As shown, taking the case where LC2 receives a communication message and the destination address in the message is the MAC address of LC4 as an example, the cascaded communication link between LC2 and LC4 is as follows:

[0131] The ETH3 port of LC2 is connected to the ETH3 port of LC3 via a network cable, and the ETH4 port of LC3 is connected to the ETH3 port of LC4 via a network cable.

[0132] Then LC2 controls LC2's ETH3 to output the communication message. The communication message is output from LC2's ETH3 to LC3's ETH3 via the network cable. Subsequently, LC3's ETH4 transmits the communication message to LC4's ETH3 network port. After receiving the communication message, LC4's ETH3 network port reports it to LC4's processing end, such as the kernel network protocol stack, which processes the communication message.

[0133] For example, if LC2 receives a communication message, and the destination address in that message is the MAC address of LC1, the cascaded communication link between LC2 and LC1 is as follows:

[0134] The ETH4 network port of LC1 is connected to the ETH4 network port of LC2 via a network cable.

[0135] Then LC2 controls LC2's ETH4 to output the communication message. The communication message is output from LC2's ETH4 to LC1's ETH4 via the network cable. After receiving the communication message, LC1's ETH4 network port reports it to LC1's processing end, such as the kernel network protocol stack, which processes the communication message.

[0136] In this embodiment, the forwarding operation of communication messages between any two communication devices is realized through the cascaded communication link between communication devices, thus meeting the actual message forwarding requirements.

[0137] In another implementation of this application, if the address mapping information includes the mapping relationship of the target address and the target address is the MAC address of the first communication device, it indicates that the current communication message needs to be processed locally, that is, the first communication device that received the communication message needs to process the message. In this case, the communication message will be sent to the processing end of the first communication device for processing. The processing end can be, for example, a kernel network protocol stack. The kernel network protocol stack can perform corresponding operations based on the content of the communication message, such as executing corresponding instructions or providing feedback on the running status.

[0138] In another implementation of this application, if the address mapping information does not include the mapping relationship of the target address, it indicates that the first communication device has not yet learned the mapping relationship of the target address. In this case, the target address is broadcast to determine the target device corresponding to the target address, and the mapping relationship between the MAC address of the target device and the network port in the first communication device is added to the address mapping information. The specific implementation process is described above.

[0139] In another implementation of this application, a complete embodiment of a communication process is provided. (Refer to...) Figure 6 It can include:

[0140] S41, The target switching port receives a communication message.

[0141] Specifically, after performing the above initialization configuration and configuring the first network port and the second network port as the target switching network port, the target switching network port driver is run. After successful execution, the target switching network port can then receive communication packets.

[0142] S42. Determine whether the MAC address in the communication message is located in the address mapping information; if yes, proceed to step S43; if no, proceed to step S45.

[0143] In this embodiment, the address mapping information can be queried to see if the MAC address in the communication packet is included. If it is included, the system continues to determine whether to process the packet locally or forward it to another device. If the address mapping information does not include the MAC address in the communication packet, an address learning operation is required.

[0144] S43. Determine whether the communication message is a local message; if it is a local message, proceed to step S44; if it is not a local message, proceed to step S47.

[0145] Specifically, after determining that the address mapping information includes the MAC address in the communication packet, it is determined whether the communication packet is a local packet. If the MAC address in the communication packet is the MAC address of the current communication device, it is determined to be a local packet and needs to be processed locally. If the MAC address in the communication packet is not the MAC address of the current communication device, it is determined not to be a local packet and needs to be forwarded to other communication devices for processing.

[0146] S44. The message is reported to the local kernel network protocol stack for processing.

[0147] Specifically, if the MAC address in the address mapping information is the local address, the message will be reported to the local kernel network protocol stack for processing.

[0148] S45. Send a broadcast message to query the MAC address.

[0149] S46. Bind the MAC address to the network port in the target switch.

[0150] If the MAC address in the communication message is not in the address mapping information, it is necessary to query the device corresponding to the MAC address through broadcast, then establish the mapping relationship between the MAC address of the device and the corresponding network port in the target switching network port, and add it to the address mapping information.

[0151] S47. Communication messages are forwarded from the corresponding network port.

[0152] If the communication message is not a local message, the communication message will be forwarded from the corresponding network port according to... Figure 2The cascaded communication link shown forwards the communication message to the corresponding device. Furthermore, if the MAC address in the communication message is not found in the address mapping information, the mapping relationship for that MAC address is obtained through broadcasting, and the message is forwarded according to that mapping relationship.

[0153] by Figure 2 Using network topology as an example, let's introduce the communication packet processing process. When LC2's switching port receives a communication packet, such as an Ethernet packet, LC2 first parses the MAC address information in the packet. If the parsed MAC address is the switching port's own MAC address, LC2 will not forward the packet but will report it to its own application for processing. If it is not LC2's own MAC address, LC2 will compare this MAC address information with its maintained address mapping information, such as a MAC address learning table. If the MAC address is in the learning table, it will retrieve the Ethernet port mapped to that MAC address. For example, if the mapped Ethernet port is ETH3, LC2 will forward the Ethernet packet from ETH3, and LC3 will receive the packet. LC3 will also repeat the LC2's actions of checking and forwarding the Ethernet packet. Similarly, if the mapped Ethernet port is ETH4, LC2 will forward the Ethernet packet from ETH4, and LC1 will receive the packet. LC1 will also repeat the LC2's actions of checking and forwarding the Ethernet packet. The entire process does not require the involvement of a hardware switch, yet it fully realizes the routing and forwarding functions of a hardware switch.

[0154] In this embodiment, the two unused independent network ports ETH3 and ETH4 of the local controller LC in the 200CS energy storage unit are configured as switching ports. The software driver simulates them as switches, which simplifies the wiring complexity inside the unit and reduces the cost budget of one finished switch in each 200CS unit, greatly improving the competitiveness of similar products. This has reference value for the optimization of Ethernet ports of other industrial and commercial energy storage products and large-scale energy storage products.

[0155] Based on the embodiments of the above communication methods, another embodiment of this application provides a communication device applied to a first communication device, wherein the first communication device is internally configured with a target switching port based on an Ethernet port configuration, referring to... Figure 7 The communication device includes:

[0156] The message parsing module 11 is used to parse the communication message to obtain the target address when the target switching network port receives the communication message;

[0157] The message forwarding module 12 is used to call the target network port corresponding to the target address in the target switching network port and forward the communication message to the target device corresponding to the target address.

[0158] In one implementation, the target switching port includes a first port and a second port; the first port of the first communication device is connected to the first port or the second port of the preceding communication device, and the second port of the first communication device is connected to the first port or the second port of the following communication device.

[0159] In one implementation, a configuration module is further included, the configuration module comprising:

[0160] The initialization submodule is used to perform database initialization operations and interface initialization operations;

[0161] The mode adjustment submodule is used to configure the operating mode of the first network port and the second network port to a preset mode;

[0162] The operation mode configuration submodule is used to configure the operation mode of the first network port and the second network port;

[0163] The network port configuration submodule is used to configure the first network port and the second network port as target switching network ports.

[0164] In one implementation, the network port configuration submodule includes:

[0165] The first network port configuration unit is used to configure the first network port and the second network port as independent network ports;

[0166] The second network port configuration unit is used to configure the first network port and the second network port as switching ports using a preset command set to obtain the target switching port;

[0167] The address configuration unit is used to configure the address information of the target switching port;

[0168] The function setting unit is used to set the automatic switching function of the first and second network ports in the target switching network ports.

[0169] In one implementation, the message forwarding module 12 includes:

[0170] The information acquisition submodule is used to acquire address mapping information, wherein the address mapping information stores the mapping relationship between the device media access control address (MAC address) of a device other than the first communication device and the network port in the first communication device.

[0171] The query submodule is used to query the target network port corresponding to the target address from the address mapping information when the address mapping information includes the mapping relationship of the target address and the target address is not the MAC address of the first communication device.

[0172] The forwarding submodule is used to forward the communication packets to the target device corresponding to the target address using the target network port.

[0173] In one implementation, the forwarding submodule is specifically used for:

[0174] The target network port is controlled to forward the communication message to the communication device connected to the target network port, so that the communication message is forwarded to the target device corresponding to the target address through the communication device connected to the target network port according to the cascaded communication link between the communication devices.

[0175] One implementation also includes:

[0176] The reporting module is used to send the communication message to the processing end of the first communication device for processing when the address mapping information includes the mapping relationship of the target address and the target address is the MAC address of the first communication device.

[0177] One implementation also includes:

[0178] A broadcast module is used to broadcast the target address when the address mapping information does not include the mapping relationship of the target address, so as to determine the target device corresponding to the target address;

[0179] The first adding module is used to add a mapping relationship between the MAC address of the target device and the network port in the first communication device in the address mapping information.

[0180] One implementation also includes:

[0181] The second adding module is used to add the specified mapping relationship to the address mapping information if, upon receiving a response message from the third communication device to the specified address broadcast by the second communication device, it is determined that no specified mapping relationship exists in the address mapping information; the specified mapping relationship is the mapping relationship between the specified address of the third communication device and the network port in the first communication device.

[0182] In this embodiment, within the first communication device, a target switching port is configured based on the Ethernet port. When a communication packet is received at the target switching port, the packet is parsed to obtain a target address. The target switching port corresponding to the target address is then called to forward the communication packet to the target device corresponding to that address. In other words, this application achieves communication between the first communication devices by forwarding communication packets through the target switching port. Because a target switching port is configured, a switch is no longer needed, reducing cabling between the first communication devices and lowering costs.

[0183] It should be noted that the working process of each module, submodule and unit in this embodiment is described in the corresponding description in the above embodiment, and will not be repeated here.

[0184] This application also provides a communication device, which is any first communication device, and the first communication device is used to perform the above-described communication method.

[0185] This application also provides a communication system, including an energy management system and multiple communication devices;

[0186] The network port of the energy management system is connected to one of the network ports of the first communication device via a switch. For the specific connection structure, please refer to [reference needed]. Figure 2 As shown.

[0187] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the communication methods provided in this application.

[0188] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the communication methods provided in this application.

[0189] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A communication method, characterized in that, Applied to a first communication device, the first communication device having a target switching port configured based on an Ethernet port, the communication method includes: When a communication message is received at the target switching network port, the communication message is parsed to obtain the target address; The target network port corresponding to the target address in the target switching network port is invoked, and the communication message is forwarded to the target device corresponding to the target address.

2. The communication method according to claim 1, characterized in that, The target switching port includes a first port and a second port; the first port of the first communication device is connected to the first port or the second port of the preceding communication device, and the second port of the first communication device is connected to the first port or the second port of the following communication device.

3. The communication method according to claim 2, characterized in that, The configuration process for the target switching port includes: Perform database initialization and interface initialization operations; Configure the operating modes of the first network port and the second network port to the preset modes; Configure the operation modes of the first network port and the second network port; Configure the first network port and the second network port as the target switching network ports.

4. The communication method according to claim 3, characterized in that, Configuring the first network port and the second network port as target switching ports includes: Configure the first network port and the second network port as independent network ports; The first network port and the second network port are configured as switching ports using a preset command set to obtain the target switching port; Configure the address information of the target switching port; Configure the automatic switching function for the first and second ports in the target switching network interface.

5. The communication method according to claim 1, characterized in that, Calling the target network port corresponding to the target address in the target switching network port, and forwarding the communication packet to the target device corresponding to the target address, includes: Obtain address mapping information, wherein the address mapping information stores the mapping relationship between the device media access control address (MAC address) of a non-first communication device and the network port in the first communication device; If the address mapping information includes the mapping relationship of the target address, and the target address is not the MAC address of the first communication device, the target network port corresponding to the target address is queried from the address mapping information; The communication message is forwarded to the target device corresponding to the target address using the target network port.

6. The communication method according to claim 5, characterized in that, Forwarding the communication packet to the target device corresponding to the target address using the target network port includes: The target network port is controlled to forward the communication message to the communication device connected to the target network port, so that the communication message is forwarded to the target device corresponding to the target address through the communication device connected to the target network port according to the cascaded communication link between the communication devices.

7. The communication method according to claim 5, characterized in that, After obtaining the address mapping information, the following is also included: If the address mapping information includes the mapping relationship of the target address, and the target address is the MAC address of the first communication device, the communication message is sent to the processing end of the first communication device for processing.

8. The communication method according to claim 5, characterized in that, After obtaining the address mapping information, the following is also included: If the address mapping information does not include the mapping relationship of the target address, the target address is broadcast to determine the target device corresponding to the target address; The address mapping information includes a mapping relationship between the MAC address of the target device and the network port in the first communication device.

9. The communication method according to any one of claims 5-8, characterized in that, Also includes: Upon receiving a response message from a third communication device to a specified address broadcast by a second communication device, if it is determined that no specified mapping relationship exists in the address mapping information, then the specified mapping relationship is added to the address mapping information; the specified mapping relationship is the mapping relationship between the specified address of the third communication device and the network port in the first communication device.

10. A communication device, characterized in that, Applied to a first communication device, the first communication device having a target switching port configured based on an Ethernet port, the communication device includes: The message parsing module is used to parse the communication message to obtain the target address when the target switching network port receives the communication message; The message forwarding module is used to call the target network port corresponding to the target address in the target switching network port and forward the communication message to the target device corresponding to the target address.

11. A communication device, characterized in that, The communication device is any first communication device, and the first communication device is used to execute the communication method as described in any one of claims 1 to 9.

12. A communication system, characterized in that, Includes an energy management system and multiple communication devices as described in claim 11; The network port of the energy management system is connected to a network port of the first communication device via a switch.