CN113746714A - Communication method, communication system and communication device based on master station and slave station - Google Patents

Communication method, communication system and communication device based on master station and slave station Download PDF

Info

Publication number
CN113746714A
CN113746714A CN202111302948.9A CN202111302948A CN113746714A CN 113746714 A CN113746714 A CN 113746714A CN 202111302948 A CN202111302948 A CN 202111302948A CN 113746714 A CN113746714 A CN 113746714A
Authority
CN
China
Prior art keywords
ethernet
data frame
address
slave station
station
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111302948.9A
Other languages
Chinese (zh)
Other versions
CN113746714B (en
Inventor
冯江平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Ailing Network Co Ltd
Original Assignee
Shenzhen Ailing Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Ailing Network Co Ltd filed Critical Shenzhen Ailing Network Co Ltd
Priority to CN202111302948.9A priority Critical patent/CN113746714B/en
Publication of CN113746714A publication Critical patent/CN113746714A/en
Application granted granted Critical
Publication of CN113746714B publication Critical patent/CN113746714B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/403Bus networks with centralised control, e.g. polling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40228Modbus
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2212/00Encapsulation of packets

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)

Abstract

The application provides a communication method, a communication system and a communication device based on master and slave stations, and relates to the technical field of communication. The method applied to the master station serial communication agent module in the communication system comprises the following steps: the method comprises the following steps of packaging different types of original hardware data frames of a master station to obtain Ethernet data frames, wherein the source address of the Ethernet data frames is the Ethernet address of the master station, and the destination address of the Ethernet data frames is the Ethernet address of a slave station, and the types comprise: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address; and sending the Ethernet data frame to an Ethernet switching module, so that the Ethernet switching module sends the Ethernet data frame to a corresponding slave station serial communication agent module according to the slave station Ethernet address. According to the method and the device, the original hardware data frame is packaged, and unicast and broadcast can be realized through the Ethernet address of the slave station in the packaged Ethernet data frame.

Description

Communication method, communication system and communication device based on master station and slave station
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a communication method, a communication system, and a communication apparatus based on a master station and a slave station.
Background
The Modbus serial link protocol is a master-slave station communication protocol, a bus comprises a plurality of master stations and slave stations, Modbus communication is initiated by the master stations, and only one master station can communicate with the slave stations at the same time.
In the existing Modbus communication, Modbus data frames are packaged in TCP or UDP messages and sent to designated IP addresses and port numbers through a wireless network, and the wireless network extracts the Modbus data frames from the received TCP or UDP messages of the designated IP addresses and port numbers and sends the Modbus data frames out through a serial interface.
Because the Modbus data frame is not analyzed in the communication method and the destination station address of the Modbus data frame cannot be acquired, the master station can only simply send the received Modbus data frame to all slave stations connected with the master station, and unicast communication is realized in a broadcast communication mode, so that the waste of system bandwidth resources is caused.
Disclosure of Invention
In view of the above-mentioned deficiencies in the prior art, an object of the present invention is to provide a communication method, a communication system and a device based on master and slave stations, so as to implement unicast communication and broadcast communication by encapsulating original hardware data frames, thereby reducing waste of system bandwidth resources.
In order to achieve the above purpose, the technical solutions adopted in the embodiments of the present application are as follows:
in a first aspect, an embodiment of the present application provides a communication method based on master and slave stations, which is applied to a master station serial communication proxy module in a communication system, and the method includes:
encapsulating different types of original hardware data frames of a master station to obtain an Ethernet data frame, wherein a source address of the Ethernet data frame is an Ethernet address of the master station, and a destination address of the Ethernet data frame is an Ethernet address of a slave station, and the types comprise: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
and sending the Ethernet data frame to an Ethernet switching module, so that the Ethernet switching module sends the Ethernet data frame to a corresponding slave station serial communication agent module according to the slave station Ethernet address.
Optionally, the encapsulating the different types of original hardware data frames of the master station to obtain the ethernet data frame includes:
and converting the slave station hardware address carried by the original hardware data frame into a slave station Ethernet address according to the original hardware data frame and a prestored slave station mapping relation between the slave station hardware address and the Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame.
Optionally, the converting, according to the original hardware data frame and a slave station mapping relationship between a prestored slave station hardware address and an ethernet address, a slave station hardware address carried by the original hardware data frame into a slave station ethernet address, and encapsulating to obtain a corresponding ethernet data frame includes:
analyzing the original hardware data frame to obtain the type of the original hardware data frame;
and if the original hardware data frame is a broadcast data frame, converting the slave station hardware address of the original hardware data frame into a broadcast Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame.
Optionally, the converting, according to the original hardware data frame and a slave station mapping relationship between a slave station hardware address and a slave ethernet address stored in advance, the slave station hardware address carried by the original hardware data frame into a slave station ethernet address, and encapsulating to obtain a corresponding ethernet data frame includes:
analyzing the original hardware data frame to obtain the type of the original hardware data frame;
if the original hardware data frame is a unicast data frame, matching an Ethernet address corresponding to the slave station hardware address in the unicast data frame according to the original hardware data frame and a prestored slave station mapping relation between the slave station hardware address and the Ethernet address;
if the matching is achieved, converting the slave station hardware address carried by the original hardware data frame into a matched unicast Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame;
and if the matching is not achieved, converting the slave station hardware address carried by the original hardware data frame into a broadcast Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame.
Optionally, if the original hardware data frame is a unicast data frame, the method further includes:
receiving an ethernet response data frame forwarded by the ethernet switching module, wherein a source address of the ethernet response data frame is a corresponding slave station ethernet address, and a destination address of the ethernet response data frame is the master station ethernet address;
analyzing the Ethernet response data frame to obtain a source address of the Ethernet response data frame;
and updating a slave station mapping relation between a prestored slave station hardware address and the Ethernet address according to the source address of the Ethernet response data frame.
In a second aspect, an embodiment of the present application further provides a communication method based on a master station and a slave station, which is applied to a slave station serial communication proxy module in a communication system, and the method includes:
receiving an Ethernet data frame forwarded by an Ethernet switching module according to an analyzed slave station Ethernet address, wherein the Ethernet data frame is obtained by packaging different types of original hardware data frames according to a master station, and a source address of the Ethernet data frame is a master station Ethernet address and a destination address of the Ethernet data frame is a slave station Ethernet address; the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
analyzing the Ethernet data frame, and extracting the original hardware data frame;
and sending the original hardware data frame to a connected slave station.
Optionally, the method further includes:
and analyzing the Ethernet data frame, and extracting and storing the Ethernet address of the main station.
Optionally, if the type of the original hardware data frame is a unicast data frame, after the original hardware data frame is sent to a connected slave station, the method further includes:
receiving a response data frame sent by the slave station;
packaging the response data frame to obtain an Ethernet response data frame, wherein the source address of the Ethernet response data frame is the corresponding slave station Ethernet address, and the destination address of the Ethernet response data frame is the master station Ethernet address;
and sending the Ethernet response data frame to an Ethernet switching module.
In a third aspect, an embodiment of the present application further provides a communication system based on a master station and a slave station, including: the system comprises at least one master station, at least one master station serial communication agent module, an Ethernet switching module, at least one slave station serial communication agent module and at least one slave station;
each master station is connected with each corresponding master station serial communication agent module through a serial communication interface, and each slave station is connected with each corresponding slave station serial communication agent module through a serial communication interface;
each master station serial communication agent module is connected with the Ethernet switching module through an Ethernet interface, and each slave station serial communication agent module is connected with the Ethernet switching module through an Ethernet interface;
each master serial communication agent module is used for executing any master-slave station-based communication method applied to the master serial communication agent module, and each slave serial communication agent module is used for executing any master-slave station-based communication method applied to the slave serial communication agent module.
In a fourth aspect, an embodiment of the present application further provides a communication apparatus based on master and slave stations, which is applied to a master station serial communication proxy module in a communication system, where the apparatus includes:
a data frame encapsulation module, configured to encapsulate different types of original hardware data frames of a master station to obtain an ethernet data frame, where a source address of the ethernet data frame is an ethernet address of the master station, and a destination address of the ethernet data frame is an ethernet address of a slave station, where the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
and the Ethernet data frame sending module is used for sending the Ethernet data frame to an Ethernet switching module, so that the Ethernet switching module sends the Ethernet data frame to a corresponding slave station serial communication agent module according to the slave station Ethernet address.
Optionally, the data frame encapsulation module is specifically configured to convert a slave station hardware address carried by the original hardware data frame into a slave station ethernet address according to the original hardware data frame and a prestored slave station mapping relationship between the slave station hardware address and the ethernet address, and encapsulate to obtain a corresponding ethernet data frame.
Optionally, the data frame encapsulation module includes:
the data frame analyzing unit is used for analyzing the original hardware data frame to acquire the type of the original hardware data frame;
and the broadcast data frame encapsulating unit is used for converting the slave station hardware address of the original hardware data frame into a broadcast Ethernet address and encapsulating to obtain the corresponding Ethernet data frame if the original hardware data frame is the broadcast data frame.
Optionally, the data frame encapsulation module includes:
the data frame analyzing unit is used for analyzing the original hardware data frame to acquire the type of the original hardware data frame;
the matching unit is used for matching the Ethernet address corresponding to the slave station hardware address in the unicast data frame according to the original hardware data frame and a prestored slave station mapping relation between the slave station hardware address and the Ethernet address if the original hardware data frame is a unicast data frame;
the first encapsulation unit is used for converting the slave station hardware address carried by the original hardware data frame into a matched unicast Ethernet address and encapsulating to obtain a corresponding Ethernet data frame if the slave station hardware address is matched with the unicast Ethernet address;
and the second packaging unit is used for converting the slave station hardware address carried by the original hardware data frame into a broadcast Ethernet address and packaging to obtain a corresponding Ethernet data frame if the slave station hardware address is not matched with the broadcast Ethernet address.
Optionally, if the original hardware data frame is a unicast data frame, the apparatus further includes:
a response data frame receiving module, configured to receive an ethernet response data frame forwarded by the ethernet switching module, where a source address of the ethernet response data frame is a corresponding slave station ethernet address, and a destination address of the ethernet response data frame is the master station ethernet address;
the response data frame analysis module is used for analyzing the Ethernet response data frame to obtain a source address of the Ethernet response data frame;
and the mapping relation updating module is used for updating the slave station mapping relation between the prestored slave station hardware address and the Ethernet address according to the source address of the Ethernet response data frame.
In a fifth aspect, the present application further provides a communication apparatus based on master and slave stations, which is applied to a slave station serial communication proxy module in a communication system, and the method includes:
an ethernet data frame receiving module, configured to receive an ethernet data frame forwarded by the ethernet switching module according to the analyzed slave station ethernet address, where the ethernet data frame is obtained by encapsulating different types of original hardware data frames according to a master station, and a source address of the ethernet data frame is a master station ethernet address and a destination address is a slave station ethernet address; the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
the data frame analyzing and extracting module is used for analyzing the Ethernet data frame and extracting the original hardware data frame;
and the hardware data frame sending module is used for sending the original hardware data frame to a connected slave station.
Optionally, the data frame parsing and extracting module is further configured to parse the ethernet data frame, extract and store the ethernet address of the master station.
Optionally, if the type of the original hardware data frame is a unicast data frame, after the hardware data frame sending module, the apparatus further includes:
a response data frame receiving module, configured to receive a response data frame sent by the slave station;
a response data frame encapsulation module, configured to encapsulate the response data frame to obtain an ethernet response data frame, where a source address of the ethernet response data frame is a corresponding slave station ethernet address, and a destination address of the ethernet response data frame is the master station ethernet address;
and the data frame sending module is used for sending the Ethernet response data frame to the Ethernet switching module.
In a sixth aspect, an embodiment of the present application further provides a master station serial communication proxy module, including: the master-slave station-based communication method comprises a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, when the master station serial communication agent module runs, the processor and the storage medium communicate through the bus, and the processor executes the program instructions to execute the steps of any one of the master-slave station-based communication methods applied to the master station serial communication agent module.
In a seventh aspect, this application embodiment further provides a computer-readable storage medium, where the storage medium stores a computer program, and the computer program is executed by a processor to execute the steps of any of the master-slave station-based communication methods as applied to the master station serial communication proxy module.
In an eighth aspect, an embodiment of the present application further provides a slave station serial communication proxy module, including: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, when the slave serial communication proxy module is running, the processor and the storage medium communicate with each other through the bus, and the processor executes the program instructions to execute the steps of the master-slave based communication method as applied to any one of the slave serial communication proxy modules.
In a ninth aspect, the present application further provides a computer-readable storage medium, which stores thereon a computer program, which when executed by a processor performs the steps of the master-slave station-based communication method as described above for any one of the slave-station serial communication proxy modules.
The beneficial effect of this application is:
the application provides a communication method, a communication system and a device based on master and slave stations, wherein the method applied to a master station serial communication agent module in the communication system comprises the following steps: encapsulating an original hardware data frame of a master station to obtain an Ethernet data frame, wherein a source address of the Ethernet data frame is an Ethernet address of the master station, and a destination address of the Ethernet data frame is an Ethernet address of a slave station, and the type of the Ethernet data frame comprises the following steps: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address; sending the Ethernet data frame to an Ethernet switching module, so that the Ethernet switching module sends the Ethernet data frame to a corresponding slave station serial communication agent module according to the slave station Ethernet address and the corresponding type, wherein the type comprises: a broadcast data frame, a known destination unicast data frame, an unknown destination unicast data frame. According to the method and the device, different types of original hardware data frames are packaged into the Ethernet data frames with the broadcast Ethernet addresses or the unicast Ethernet addresses, so that unicast and broadcast can be realized according to the types of the data frames, the broadcast or unicast can be realized without configuring the unicast or broadcast communication address of the master station, the workload is simplified, and errors in the process of deploying the communication addresses of the master station and the slave station are avoided.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic structural diagram of a communication system based on master and slave stations according to an embodiment of the present application;
fig. 2(a) is a schematic deployment diagram of a first master station serial communication agent module according to an embodiment of the present application;
fig. 2(b) is a schematic deployment diagram of a second master serial communication agent module according to an embodiment of the present application;
fig. 3 is a flowchart of a first master-slave station-based communication method according to an embodiment of the present application;
fig. 4 is a flowchart illustrating a second master-slave station-based communication method according to an embodiment of the present application;
fig. 5 is a flowchart illustrating a third primary-secondary station-based communication method according to an embodiment of the present application;
fig. 6 is a schematic flowchart of a fourth master-slave station-based communication method according to an embodiment of the present application;
fig. 7 is a schematic flowchart of a fifth master-slave station-based communication method according to an embodiment of the present application;
fig. 8 is an interaction diagram of a broadcast communication method based on master and slave stations according to an embodiment of the present application;
fig. 9 is an interaction diagram of a unicast communication method based on unknown destinations of master and slave stations according to an embodiment of the present application;
fig. 10 is an interaction diagram of a unicast communication method based on known purposes of master and slave stations according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of a first primary-secondary station-based communication device according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of a second primary-secondary station-based communication device according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of a master station serial communication agent module according to an embodiment of the present application;
fig. 14 is a schematic structural diagram of a slave serial communication proxy module according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Furthermore, the terms "first," "second," and the like in the description and in the claims, as well as in the drawings, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that the features of the embodiments of the present application may be combined with each other without conflict.
Fig. 1 is a schematic structural diagram of a communication system based on master and slave stations provided in the embodiment of the present application; as shown in fig. 1, the system includes: at least one master station 10, at least one master station serial communication agent module 20, an ethernet switching module 30, at least one slave station serial communication agent module 40, and at least one slave station 50.
Wherein, each master station 10 and each master station serial communication agent module 20 are connected through a serial communication interface, each slave station serial communication agent module 40 and each slave station 50 are connected through a serial communication interface, each master station serial communication agent module 20 and the ethernet switching module 30 are connected through an ethernet interface, and each serial communication agent module 40 and the ethernet switching module 30 are connected through an ethernet interface.
The primary station 10 sends an original hardware data frame to the primary station serial communication agent module 20, the primary station serial communication agent module 20 analyzes the original hardware data frame to determine the type of the original hardware data frame, encapsulates the original hardware data frame into an ethernet data frame, and sends the ethernet data frame to the ethernet switching module 30 through an ethernet interface, the ethernet switching module 30 sends the ethernet data frame to the corresponding secondary station serial communication agent module 40 through the corresponding ethernet interface according to the ethernet address of the secondary station encapsulated in the ethernet data frame and the corresponding type, and the secondary station serial communication agent module 40 extracts the original hardware data frame from the ethernet data frame and sends the original hardware data frame to the corresponding secondary station 50 through the serial communication interface.
Optionally, the ethernet switching module 30 may be deployed in a User Plane Function (UPF) of the core network, or may be deployed separately from the User Plane Function, and when the ethernet switching module 30 is deployed in the User Plane Function of the core network, the forwarding of the ethernet data frame may be directly completed through the User Plane Function, and the ethernet data frame is not forwarded to the external data network; when the ethernet switching module 30 is deployed outside the user plane functionality of the core network, the user plane functionality forwards the ethernet data frames to the ethernet switching module 30 located in the external data network, typically via tunneling.
In an alternative embodiment, when the type of the original hardware data frame is a unicast data frame, the secondary station needs to reply based on the received data frame.
The slave station 50 transmits a response data frame to the slave station serial communication proxy module 40 based on the received original hardware data frame, the slave station serial communication proxy module 40 encapsulates the response data frame into an ethernet response data frame, transmits the ethernet response data frame to the ethernet switching module 30 through the ethernet interface, the destination address in the ethernet response data frame is the master ethernet address of the ethernet data frame received from the serial communication proxy module 40, the ethernet switching module 30 determines the code of the ethernet interface connected to the master serial communication agent module 20 according to the master ethernet address recorded in the destination address, and sending the Ethernet response data frame to the master station serial communication agent module 20 according to the serial number, wherein the master station serial communication agent module 20 extracts the response data frame from the Ethernet response data frame and sends the response data frame to the master station 10.
On the basis of the foregoing embodiments, fig. 2(a) is a schematic deployment diagram of a first master serial communication agent module provided in the embodiment of the present application, and fig. 2(b) is a schematic deployment diagram of a second master serial communication agent module provided in the embodiment of the present application.
As shown in fig. 2(a), the master serial communication agent module 20 is disposed in the terminal, and the ethernet interface of the master serial communication agent module 20 is communicatively connected to the ethernet interface of the ethernet switch module 30; as shown in fig. 2(b), the master serial communication agent module 20 is disposed outside the terminal, the ethernet interface of the master serial communication agent module 20 is communicatively connected to the terminal, and the terminal is communicatively connected to the ethernet interface of the ethernet switching module 30. It should be noted that the slave station, the slave station serial communication agent module, and the terminal may also adopt these two deployment manners, which are not described herein again.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a master-slave station-based communication method, which is applied to the master station serial communication proxy module 20 in the communication system shown in fig. 1, and fig. 3 is a flowchart of a first master-slave station-based communication method provided in the embodiment of the present application, and as shown in fig. 3, the method includes:
s21: and encapsulating different types of original hardware data frames of the master station to obtain the Ethernet data frames.
Specifically, the master station serial communication agent module is connected with the master station through a serial interface to receive an original hardware data frame sent by the master station, determine the type of the original hardware data frame according to a slave station hardware address carried in the original hardware data frame, determine a corresponding slave station ethernet address, and encapsulate the original hardware data frame of the master station to obtain the ethernet data frame, wherein a source address of the ethernet data frame is the master station ethernet address, a destination address is the slave station ethernet address, and the slave station ethernet address includes: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address.
It should be noted that, because the communication system provided in this embodiment of the present application is directly connected to the ethernet switch module by the master serial communication agent module and the slave serial communication agent module, rather than by the master station and the slave station, and each master station is correspondingly connected to one master serial communication agent module, and each slave station is also correspondingly connected to one slave serial communication agent module, when the master station communicates with the slave station, it only needs to know the address of the master serial communication agent module and the address of the slave serial communication agent module, so the ethernet addresses of the master station and the slave station in this embodiment of the present application are the ethernet addresses of the master serial communication agent module and the ethernet addresses of the slave station and the slave station, respectively, and the ethernet addresses of the slave station in this application are the ethernet addresses of the slave serial communication agent module and the ethernet addresses of the slave station, and the ethernet addresses of the master station represent the ethernet addresses of the master serial communication agent module in this application, and expressing the Ethernet address of the serial communication proxy module of the slave station by the Ethernet address of the slave station.
As an example, table 1 shows a format of an original hardware data frame provided in this embodiment of the present application, as shown in table 1, the original hardware data frame includes an address field, a function code field, a data field, and an error check field, where the address field only contains a slave hardware address, the master station has no address, and the slave hardware address is unique on the serial communication bus, a valid slave hardware address is 0-247, where 0 is a broadcast address, the master station addresses the slave station by encapsulating the slave hardware address in the address field of the original hardware data frame, and when the slave station responds to the master station, encapsulating the slave hardware address in the address field of the response data frame, so that the master station knows the slave station that responds.
TABLE 1 original hardware data frame Format
Address Function code Data of Error checking
For example, table 2 shows a format of an ethernet data frame provided in this embodiment, where the format of the ethernet data frame is: a destination address of 6 bytes, a source address of 6 bytes, a protocol type of 2 bytes, and an original hardware data frame of indefinite length, the protocol type field is identified by a fixed value to identify which protocol the data frame needs to be processed, e.g., 0x8888, the identified data frame is processed by the Modbus serial communication protocol, the master serial communication agent module 20 and the slave serial communication agent module 40 only process data frames of the protocol type, and data frames of other protocol types are discarded.
It should be noted that, the communication method provided in this embodiment of the present application is a Modbus-based communication method, where an original hardware data frame sent by a master station is a Modbus data frame, an address type of an address field of the Modbus data frame is a Modbus address, and address types of a destination address field and a source address field of an ethernet data frame are MAC (Media Access Control) addresses.
Table 2 format of ethernet data frame
Destination address Source address Type of protocol Data frame
In an optional implementation manner, according to an original hardware data frame and a slave station mapping relationship between a slave station hardware address and an ethernet address stored in advance, a slave station hardware address carried by the original hardware data frame is converted into a slave station ethernet address, and a corresponding ethernet data frame is obtained by encapsulation.
Specifically, the master station serial communication agent module receives an original hardware data frame sent by the master station, the original hardware data frame comprises slave station hardware addresses which are required by the master station to communicate, the master station serial communication agent module prestores slave station mapping relations between the slave station hardware addresses and Ethernet addresses in an autonomous learning mode, corresponding slave station Ethernet addresses are searched in the slave station mapping relations according to the slave station hardware addresses carried in an address field of the original hardware data frame, and the slave station Ethernet addresses, the master station Ethernet addresses of the master station serial communication agent module, protocol types and the original hardware data frame are packaged into the Ethernet data frame.
For example, if the slave station hardware address is 0, it indicates that the original hardware data frame is a broadcast data frame, if the slave station hardware address is not 0, it indicates that the original hardware data frame is a unicast data frame, if the slave station ethernet address corresponding to the slave station hardware address exists in the slave station mapping relationship, it indicates that the original hardware data frame is a known destination unicast data frame, and if the slave station ethernet address corresponding to the slave station hardware address does not exist in the slave station mapping relationship, it indicates that the original hardware data frame is an unknown destination unicast data frame.
S22: and sending the Ethernet data frame to the Ethernet switching module, so that the Ethernet switching module sends the Ethernet data frame to the corresponding slave station serial communication agent module according to the slave station Ethernet address.
Specifically, the master station serial communication agent module is connected with the ethernet switching module through an ethernet interface to send the ethernet data frame to the ethernet switching module, so that the ethernet switching module sends the ethernet data frame to the slave station serial communication agent module corresponding to the slave station ethernet address through the ethernet interface according to the slave station ethernet address, if the ethernet data frame is a broadcast data frame or an unknown-purpose unicast data frame and the destination address of the ethernet data frame is a broadcast ethernet address, the ethernet data frame is sent to all slave station serial communication agent modules, and if the ethernet data frame is a known-purpose unicast data frame and the destination address of the ethernet data frame is a unicast ethernet address, the ethernet data frame is sent to the only slave station serial communication agent module corresponding to the slave station ethernet address.
It should be noted that, the ethernet switching module stores in advance a mapping relationship between the slave station ethernet address and the slave station ethernet interface, and if the ethernet switching module does not find the corresponding slave station ethernet interface according to the unicast ethernet address in the ethernet data frame, the ethernet data frame is also sent to the slave station serial communication agent modules connected to all the slave station ethernet interfaces. Generally, after the ethernet switching module is initially started or restarted, the ethernet switching module has no mapping relationship between the slave station ethernet address and the slave station ethernet interface, and forwards the data frame of the slave station to the ethernet switching module through the slave station serial communication agent module, so that the ethernet switching module autonomously learns and stores the mapping relationship between the slave station ethernet address and the slave station ethernet interface.
In the communication method of the master and slave stations provided in the embodiment of the present application, an original hardware data frame of the master station is encapsulated to obtain an ethernet data frame, and the ethernet data frame is sent to an ethernet switching module, so that the ethernet switching module analyzes the ethernet data frame, determines an ethernet address of the slave station, and sends the ethernet data frame to a corresponding serial communication proxy module of the slave station according to the ethernet address of the slave station and a corresponding type, where the type includes: a broadcast data frame, a known destination unicast data frame, an unknown destination unicast data frame. According to the method and the device, the original hardware data frame of the broadcast or unicast type is packaged into the Ethernet data frame through the main station serial communication agent module, broadcast or unicast communication can be achieved through the Ethernet switching module, the broadcast or unicast communication mode of the main station does not need to be configured, the communication workload is simplified, and errors in the deployment process of the main station and the slave station are avoided.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a communication method based on a master station and a slave station, fig. 4 is a flowchart of a second communication method based on a master station and a slave station provided in the embodiment of the present application, and as shown in fig. 4, the process of encapsulating an ethernet data frame includes:
s211: and analyzing the original hardware data frame to acquire the type of the original hardware data frame.
Specifically, the master station serial communication agent module extracts the slave station hardware address from the address field of the original hardware data frame, and determines the type of the original hardware data frame according to the slave station hardware address. And if the slave station hardware address is the broadcast hardware address, the original hardware data frame is a broadcast data frame, and if the slave station hardware address is the unicast hardware address, the original hardware data frame is a unicast data frame.
S212: and if the original hardware data frame is a broadcast data frame, converting the slave station hardware address of the original hardware data frame into a broadcast Ethernet address, and encapsulating to obtain the corresponding Ethernet data frame.
Specifically, if the original hardware data frame is a broadcast data frame, it is determined that the slave station ethernet address corresponding to the slave station hardware address is a broadcast ethernet address, and the broadcast ethernet address is encapsulated as a destination address of the ethernet data frame. And the destination address of the Ethernet data frame analyzed by the Ethernet switching module is a broadcast Ethernet address, and the Ethernet data frame is sent to all slave station serial communication agent modules connected with the Ethernet switching module through Ethernet interfaces. For example, if the address field of the original hardware data frame is 0, the original hardware data frame is a broadcast data frame, and the destination address in the ethernet data frame obtained by encapsulation is a broadcast ethernet address, that is, 0 xfffffffffffff.
According to the communication method based on the master-slave station, the original hardware data frame is analyzed, the type of the original hardware data frame is obtained, if the original hardware data frame is a broadcast data frame, the slave station hardware address of the original hardware data frame is converted into a broadcast Ethernet address, and the corresponding Ethernet data frame is obtained through encapsulation. According to the embodiment of the application, the original hardware data frame is packaged into the broadcast Ethernet data frame through the main station serial communication agent module, so that broadcast communication can be realized through the Ethernet switching module, the broadcast communication mode of the main station is not required to be configured, the communication workload is simplified, and errors in the deployment process of the main station and the slave station are avoided.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a communication method based on a master station and a slave station, and as shown in fig. 4, the process of encapsulating an ethernet data frame further includes:
s213: and if the original hardware data frame is a unicast data frame, matching the Ethernet address corresponding to the slave station hardware address in the unicast data frame according to the original hardware data frame and a prestored slave station mapping relation between the slave station hardware address and the Ethernet address.
Specifically, if the original hardware data frame is a unicast data frame, the master station serial communication agent module matches the slave station ethernet address according to the slave station hardware address in the original hardware data frame and the slave station mapping relationship.
S214: and if the matching is successful, converting the slave station hardware address carried by the original hardware data frame into the matched unicast Ethernet address, and encapsulating to obtain the corresponding Ethernet data frame.
Specifically, if the master station serial communication agent module matches the slave station hardware address with the corresponding unicast ethernet address according to the slave station mapping relationship, the original hardware data frame is a known destination unicast data frame, the matched unicast ethernet address is used as the destination address of the ethernet data frame, the ethernet data frame is generated by encapsulation, and the ethernet switching module sends the ethernet data frame to the slave station serial communication agent module corresponding to the slave station ethernet address.
S215: and if the matching is not achieved, converting the slave station hardware address carried by the original hardware data frame into a broadcast Ethernet address, and encapsulating to obtain the corresponding Ethernet data frame.
Specifically, if the master station serial communication agent module does not match the slave station hardware address with the corresponding ethernet address according to the slave station mapping relationship, the original hardware data frame is an unknown-purpose unicast data frame, the broadcast ethernet address is used as the destination address of the ethernet data frame, the ethernet data frame is generated by encapsulation, and the ethernet switching module sends the ethernet data frame to all slave station serial communication agent modules in communication connection with the ethernet switching module.
For example, if the address field of the original hardware data frame is any one of 1 to 247, the original hardware data frame is a unicast data frame, table 3 is a slave station mapping relationship between a part of slave station hardware addresses and ethernet addresses provided in this embodiment, the slave station ethernet address corresponding to the slave station hardware address changes according to a change of a slave station serial communication proxy module connected to the slave station, and is not fixed, and table 3 is only an example provided in this embodiment and is easy to understand.
Table 3 slave station mapping relation of partial slave station hardware address and ethernet address
Slave station hardware address Slave station Ethernet address
1 8C-C6-81-6E-8E-76
2 48-2A-E3-91-7E-8D
3 00-E0-99-00-0F-51
It should be noted that although the destination addresses of the ethernet data frames encapsulated according to the broadcast data frame and the unknown destination unicast data frame are broadcast ethernet addresses, the data frame in the ethernet data frames encapsulated according to the broadcast data frame is a broadcast data frame, and the data frame in the ethernet data frames encapsulated according to the unknown destination unicast data frame is a unicast data frame.
The communication method based on the master-slave station provided by the embodiment of the application analyzes an original hardware data frame to obtain the type of the original hardware data frame, if the original hardware data frame is a unicast data frame, an Ethernet address corresponding to a slave station hardware address in the unicast data frame is matched according to the original hardware data frame and a prestored slave station hardware address and Ethernet address, if the original hardware data frame is matched with the Ethernet address, the slave station hardware address carried by the original hardware data frame is converted into the matched slave station Ethernet address, the corresponding Ethernet data frame is obtained by encapsulation, and if the original hardware data frame is not matched with the slave station hardware address, the slave station hardware address carried by the original hardware data frame is converted into a broadcast Ethernet address, and the corresponding Ethernet data frame is obtained by encapsulation. According to the embodiment of the application, the original hardware data frame can be identified to be a unicast data frame with a known purpose or a unicast data frame with an unknown purpose through the serial communication agent module of the main station, so that unknown unicast and known unicast can be realized through the Ethernet switching module, unicast configuration is not needed to be carried out on the main station, the workload of communication is simplified, and errors are avoided in the process of carrying out unicast communication deployment on the main station.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a communication method based on a master station and a slave station, and fig. 5 is a flowchart of a third communication method based on a master station and a slave station provided in the embodiment of the present application, and as shown in fig. 5, if an original hardware data frame is a unicast data frame, the method further includes:
s23: and receiving the Ethernet response data frame forwarded by the Ethernet switching module.
Specifically, the ethernet response data frame is obtained by encapsulating the slave station serial communication agent module based on the response data frame of the slave station, and the format of the ethernet response data frame is the same as that of the ethernet data frame, wherein the slave station ethernet address in the ethernet response data frame is the ethernet address of the slave station serial communication agent module correspondingly connected to the slave station responding to the response data frame, the destination address of the ethernet response data frame is the master station ethernet address, and the master station ethernet address is the master station ethernet address of the source address field extracted and stored from the ethernet data frame after the slave station serial communication agent module receives the ethernet data frame.
Based on the above description, after the ethernet switching module receives the ethernet data frame, it needs to parse the master ethernet address of the master serial communication agent module stored in the source address field from the ethernet data frame, store the mapping relationship between the master ethernet address and the ethernet interface connected between the ethernet switching module and the master serial communication agent module, after the ethernet switching module receives the ethernet response data frame transmitted from the station serial communication proxy module, according to the stored main station Ethernet address and the main station mapping relation of the Ethernet interface when receiving the Ethernet data frame, searching the Ethernet interface corresponding to the main station Ethernet address in the Ethernet response data frame from the main station mapping relation, after determining the Ethernet interface, the Ethernet exchange module forwards the Ethernet response data frame to the corresponding main station serial communication agent module through the Ethernet interface.
S24: and analyzing the Ethernet response data frame to obtain the source address of the Ethernet response data frame.
Specifically, the master station serial communication agent module acquires the slave station ethernet address stored in the source address field of the ethernet response data frame from the ethernet response data frame, extracts the response data frame from the data frame field of the ethernet response data frame, and acquires the slave station hardware address from the address field of the response data frame.
S25: and updating the pre-stored slave station mapping relation between the slave station hardware address and the Ethernet address according to the source address of the Ethernet response data frame.
Specifically, after the slave station ethernet address and the slave station hardware address are obtained based on the above S24, if the mapping relationship between the slave station hardware address and the slave station ethernet address does not exist in the pre-stored slave station mapping relationship, storing the mapping relationship between the slave station hardware address and the slave station ethernet address; and if the mapping relation between the slave station hardware address and the slave station Ethernet address is inconsistent with the preset and stored slave station mapping relation, replacing the slave station mapping relation stored in the master station serial communication agent module.
In the slave station response procedure of S23-S25, the broadcast data frame only needs to be transmitted to all slave stations according to the broadcast protocol specification, and the slave stations do not need to respond to the broadcast data frame, only when the original data frame is a unicast data frame. For an unknown destination unicast data frame, although the destination address of the corresponding ethernet data frame is the broadcast ethernet address, the slave station may still determine that the original hardware data frame is a unicast data frame in the original hardware data frame extracted from the serial communication agent module of the slave station, and the slave station needs to respond after receiving the original hardware data frame.
According to the communication method based on the master station and the slave station, if the original hardware data frame is a unicast data frame, the Ethernet response data frame forwarded by the Ethernet switching module is received, the Ethernet response data frame is analyzed, the source address of the Ethernet response data frame is obtained, and the slave station mapping relation between the slave station hardware address and the Ethernet address which are stored in advance is updated according to the source address of the Ethernet response data frame. By the aid of the method and the device, the master station serial communication agent module can independently learn the slave station mapping relation between the slave station hardware address and the Ethernet address, manual deployment of the slave station mapping relation on the master station is not needed, communication workload is simplified, and errors in the master station deployment process are avoided.
On the basis of the foregoing embodiments, an embodiment of the present invention further provides a master-slave station-based communication method, which is applied to the slave station serial communication agent module 40 in the communication system shown in fig. 1, and fig. 6 is a flowchart of a fourth master-slave station-based communication method provided in the embodiment of the present invention, and as shown in fig. 6, the method includes:
s41: and receiving the Ethernet data frame forwarded by the Ethernet switching module according to the analyzed slave station Ethernet address.
Specifically, the slave station serial communication agent module is connected with the ethernet switching module through an ethernet interface, and the ethernet switching module analyzes the ethernet data frame to obtain a slave station ethernet address carried by a destination address field of the ethernet data frame, so as to send the ethernet data frame to the corresponding slave station serial communication agent module according to the slave station ethernet address, wherein the ethernet data frame is obtained by packaging the original hardware data frame of the master station, and the source address of the ethernet data frame is the master station ethernet address and the destination address is the slave station ethernet address; the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address.
S42: and analyzing the Ethernet data frame and extracting an original hardware data frame.
Specifically, the original hardware data frame is a data frame to be sent by the master station to the slave station, in order to implement unicast and broadcast, the master station serial communication agent module encapsulates the original hardware data frame to encapsulate the original hardware data frame into an ethernet data frame capable of being broadcast and unicast, the ethernet switching module sends the ethernet data frame to the corresponding slave station serial communication agent module according to the slave station ethernet address in the ethernet data frame and the type of the data frame, the slave station serial communication agent module needs to analyze the ethernet data frame according to the format of the ethernet data frame, and the original hardware data frame encapsulated by the data frame field of the ethernet data frame is extracted.
In an optional implementation mode, the slave serial communication agent module further parses the ethernet data frame, and extracts and stores the master ethernet address.
Specifically, when the slave serial communication agent module analyzes the ethernet data frame, the slave serial communication agent module extracts the original hardware data frame from the data frame field of the ethernet data frame, and also needs to extract and store the master ethernet address from the source address field of the ethernet data frame, and the purpose of storing the master ethernet address is that when the slave station sends the response data frame, the slave serial communication agent module can determine to which master serial communication agent module the master serial communication agent module is connected with the master serial communication agent module, so as to implement unicast response through the slave serial communication agent module.
S43: and sending the original hardware data frame to the connected slave station.
Generally, a master station is directly connected with a slave station in a communication manner, and a unicast data frame sent by the master station is directly sent to all slave stations establishing connection with the master station, so that unicast communication is realized in a broadcast manner, and waste of system bandwidth resources is caused. In the embodiment of the application, the ethernet switching module sends the ethernet data frame to the specified slave station serial communication agent module, and each slave station serial communication agent module has a uniquely corresponding slave station, so that if the ethernet switching module sends the ethernet data frame to the plurality of slave station serial communication agent modules, the plurality of serial communication agent modules send the extracted original hardware data frame to the plurality of uniquely corresponding slave stations, and if the ethernet switching module sends the ethernet data frame to one slave station serial communication agent module, the serial communication agent module sends the extracted original hardware data frame to one uniquely corresponding slave station, so as to implement broadcast communication or unicast communication between the master station and the slave station.
The communication method based on the master station and the slave station, provided by the embodiment of the application, is applied to a slave station serial communication agent module, and is used for receiving an Ethernet data frame forwarded by an Ethernet switching module according to an analyzed slave station Ethernet address and a corresponding type, wherein the Ethernet data frame is obtained by packaging according to an original hardware data frame of a master station, and a source address of the Ethernet data frame is the Ethernet address of the master station, and a destination address of the Ethernet data frame is the Ethernet address of the slave station; the types include: a broadcast data frame, a known destination unicast data frame, and an unknown destination unicast data frame; analyzing the Ethernet data frame, and extracting an original hardware data frame; and sending the original hardware data frame to the connected slave station. According to the communication method based on the master station and the slave station, the slave station serial communication agent module receives and analyzes the Ethernet data frame, so that the extracted original hardware data frame is sent to the slave station, the broadcast communication and the unicast communication of the master station and the slave station are realized, the slave station does not need to be manually deployed, the workload of communication is simplified, and errors in the process of deploying the communication address of the slave station are avoided.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a communication method based on a master station and a slave station, and fig. 7 is a flowchart of a fifth communication method based on a master station and a slave station provided in the embodiment of the present application, and as shown in fig. 7, if a type of an original hardware data frame is a unicast data frame, the method further includes:
s44: and receiving the response data frame sent by the slave station.
Specifically, as described above, according to the rules of the broadcast protocol, the broadcast data frame only needs to be sent to all the slave stations, and there is no need for the slave stations to respond to the broadcast data frame, and for an unknown-purpose unicast data frame, although the destination address of the corresponding ethernet data frame is the broadcast ethernet address, the slave stations can still determine that the original hardware data frame is the unicast data frame in the original hardware data frame extracted from the slave station serial communication proxy module.
S45: and packaging the response data frame to obtain the Ethernet response data frame.
Specifically, the slave station serial communication agent module encapsulates the response data frame into an ethernet response data frame, the format of the ethernet response data frame is the same as that of the ethernet data frame, the source address of the ethernet response data frame is the corresponding slave station ethernet address, and the destination address of the ethernet response data frame is the master station ethernet address. The Ethernet address of the slave station is the Ethernet address of the serial communication proxy module of the slave station for packaging the response data frame, and the Ethernet address of the master station is the address carried by the source address field extracted and stored from the Ethernet data frame by the serial communication proxy module of the slave station.
S46: and sending the Ethernet response data frame to the Ethernet switching module.
Specifically, the slave serial communication agent module sends the encapsulated ethernet response data frame to the ethernet switching module, so that the ethernet switching module searches for an ethernet interface corresponding to the ethernet address of the master station in the master station mapping relationship according to the ethernet address of the master station stored in the destination address field, and sends the ethernet response data frame to the corresponding serial communication agent module of the master station through the ethernet interface, and the serial communication agent module of the master station sends the ethernet response data frame to the master station.
According to the communication method based on the master station and the slave station, if the type of the original hardware data frame is a unicast data frame, the response data frame sent by the slave station is received, the response data frame is encapsulated to obtain an Ethernet response data frame, and the Ethernet response data frame is sent to the Ethernet switching module. According to the embodiment of the application, response is carried out under the condition that the original hardware data frame is identified to be the unicast data frame, accurate unicast communication between the master station and the slave station is achieved, and bandwidth resource waste caused by response of all the slave stations due to the fact that the data frame is sent to all the slave stations in the communication process is avoided.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a communication method based on a master station and a slave station, and fig. 8 is an interaction schematic diagram of the broadcast communication method based on the master station and the slave station provided in the embodiment of the present application, and as shown in fig. 8, a master station 10 sends an original hardware data frame to a master station serial communication agent module 20, the master station serial communication agent module 20 analyzes a slave station hardware address in the original hardware data frame to be 0, encapsulates the original hardware data into an ethernet data frame whose destination address is a broadcast ethernet address, and sends the ethernet data frame to an ethernet switching module 30, the ethernet switching module 30 determines that the destination address of the ethernet data frame is the broadcast ethernet address, sends the ethernet data frame to all slave station serial communication agent modules 40 connected to the ethernet switching module 30, and the slave station serial communication agent module 40 saves the ethernet data frame from the master station ethernet data frame of the master station serial communication agent module 20 of a source address field in the ethernet data frame Address and extract the original hardware data frame to send to the slave station 50.
On the basis of the foregoing embodiment, an embodiment of the present application further provides a communication method based on a master-slave station, and fig. 9 is an interaction schematic diagram of a unicast communication method based on unknown destinations of the master-slave station provided in the embodiment of the present application, and as shown in fig. 9, a master station 10 sends an original hardware data frame to a master station serial communication proxy module 20, the master station serial communication proxy module 20 analyzes that a slave station hardware address in the original hardware data frame is not 0, but a slave station ethernet address corresponding to the slave station hardware address is not in a slave station mapping relationship, and encapsulates the original hardware data frame into an ethernet data frame whose destination address is a broadcast ethernet address, a subsequent sending process of the ethernet data frame is the same as the broadcast communication method, and no further description is given here, except that after the ethernet exchange module 30 receives the ethernet data frame, an ethernet address of the master station serial communication proxy module 20, which is carried in a source address field of the ethernet data frame, is stored, and the ethernet address of the ethernet data frame is the ethernet address of the ethernet network access point According to the mapping relation of the master station of the port, after the slave station 50 receives an original hardware data frame, the original hardware data frame is determined to be a unicast data frame from the address field of the original hardware data frame, the slave station 50 receiving the original hardware data frame sends a response data frame to the slave station serial communication agent module, the slave station serial communication agent module 40 encapsulates the response data frame into an Ethernet response data frame according to the stored Ethernet address of the master station and sends the Ethernet response data frame to the Ethernet switching module 30, the Ethernet switching module 30 determines a corresponding Ethernet interface from the mapping relation of the master station according to the Ethernet address of the master station and sends the Ethernet response data frame to the master station serial communication agent module 20 corresponding to the Ethernet interface, and the master station serial communication agent module 20 determines the Ethernet address of the slave station carried by the source address field of the Ethernet response data frame and the hardware address of the slave station carried by the address field in the response data frame, and updating the slave mapping relation between the slave Ethernet address and the slave hardware address, and sending the extracted response data frame to the master station 10.
On the basis of the above embodiments, the present application also provides a communication method based on the master station and the slave station, figure 10 is an interaction diagram of a unicast communication method based on the known purpose of the master station and the slave station provided by the embodiment of the application, as shown in fig. 10, the difference between the known destination unicast communication method and the unknown unicast communication method is that the master serial communication agent module 20 resolves that the slave hardware address in the original hardware data frame is not 0, the slave mapping relationship has the slave ethernet address corresponding to the slave hardware address, the original hardware data frame is encapsulated into an ethernet data frame whose destination address is the corresponding slave ethernet address, the subsequent ethernet data frame is only sent to the slave serial communication agent module 40 corresponding to the slave ethernet address, and the rest of the processes are the same as the unknown destination unicast communication method, and are not described herein again.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a master-slave station-based communication apparatus, which is applied to a master station serial communication proxy module in a communication system, and fig. 11 is a schematic structural diagram of a first master-slave station-based communication apparatus provided in the embodiment of the present application, and as shown in fig. 11, the apparatus includes:
a data frame encapsulation module 100, configured to encapsulate different types of original hardware data frames of a master station to obtain an ethernet data frame, where a source address of the ethernet data frame is an ethernet address of the master station, and a destination address of the ethernet data frame is an ethernet address of a slave station, where the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
an ethernet data frame sending module 200, configured to send the ethernet data frame to the ethernet switching module, so that the ethernet switching module sends the ethernet data frame to a corresponding slave station serial communication agent module according to the slave station ethernet address.
Optionally, the data frame encapsulation module 100 is specifically configured to convert a slave station hardware address carried by the original hardware data frame into a slave station ethernet address according to the original hardware data frame and a prestored slave station mapping relationship between the slave station hardware address and the ethernet address, and encapsulate to obtain a corresponding ethernet data frame.
Optionally, the data frame encapsulating module 100 includes:
the data frame analyzing unit is used for analyzing the original hardware data frame to acquire the type of the original hardware data frame;
and the broadcast data frame encapsulating unit is used for converting the slave station hardware address of the original hardware data frame into a broadcast Ethernet address and encapsulating to obtain the corresponding Ethernet data frame if the original hardware data frame is the broadcast data frame.
Optionally, the data frame encapsulating module 100 includes:
the data frame analyzing unit is used for analyzing the original hardware data frame to acquire the type of the original hardware data frame;
the matching unit is used for matching the Ethernet address corresponding to the slave station hardware address in the unicast data frame according to the original hardware data frame and a prestored slave station mapping relation between the slave station hardware address and the Ethernet address if the original hardware data frame is a unicast data frame;
the first encapsulation unit is used for converting the slave station hardware address carried by the original hardware data frame into the matched unicast Ethernet address and encapsulating to obtain the corresponding Ethernet data frame if the slave station hardware address is matched with the unicast Ethernet address;
and the second packaging unit is used for converting the slave station hardware address carried by the original hardware data frame into a broadcast Ethernet address and packaging to obtain the corresponding Ethernet data frame if the slave station hardware address is not matched with the broadcast Ethernet address.
Optionally, if the original hardware data frame is a unicast data frame, the apparatus further includes:
the response data frame receiving module is used for receiving the Ethernet response data frame forwarded by the Ethernet switching module, wherein the source address of the Ethernet response data frame is the corresponding slave station Ethernet address, and the destination address of the Ethernet response data frame is the master station Ethernet address;
the response data frame analysis module is used for analyzing the Ethernet response data frame to obtain a source address of the Ethernet response data frame;
and the mapping relation updating module is used for updating the pre-stored slave station mapping relation between the slave station hardware address and the Ethernet address according to the source address of the Ethernet response data frame.
In addition to the above embodiments, an embodiment of the present invention further provides a communication device based on a master station and a slave station, which is applied to a slave station serial communication proxy module in a communication system, and fig. 12 is a schematic structural diagram of a second communication device based on a master station and a slave station according to the embodiment of the present invention, and as shown in fig. 12, the communication device includes:
an ethernet data frame receiving module 300, configured to receive an ethernet data frame forwarded by the ethernet switching module according to the analyzed slave station ethernet address, where the ethernet data frame is obtained by encapsulating different types of original hardware data frames according to a master station, and a source address of the ethernet data frame is a master station ethernet address and a destination address is a slave station ethernet address; the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
a data frame parsing and extracting module 400, configured to parse the ethernet data frame and extract an original hardware data frame;
a hardware data frame sending module 500, configured to send the original hardware data frame to the connected slave station.
Optionally, the data frame parsing and extracting module 400 is further configured to parse the ethernet data frame, extract and store the ethernet address of the master station.
Optionally, if the type of the original hardware data frame is a unicast data frame, after the hardware data frame sending module 500, the apparatus further includes:
the response data frame receiving module is used for receiving a response data frame sent by the slave station;
the response data frame packaging module is used for packaging the response data frame to obtain an Ethernet response data frame, wherein the source address of the Ethernet response data frame is the corresponding slave station Ethernet address, and the destination address of the Ethernet response data frame is the master station Ethernet address;
and the data frame sending module is used for sending the Ethernet response data frame to the Ethernet switching module.
The above-mentioned apparatus is used for executing the method provided by the foregoing embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
These above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors, or one or more Field Programmable Gate Arrays (FPGAs), etc. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
On the basis of the foregoing embodiments, an embodiment of the present application further provides a master serial communication agent module, fig. 13 is a schematic structural diagram of the master serial communication agent module provided in the embodiment of the present application, and as shown in fig. 13, the master serial communication agent module 20 includes: the system comprises a processor 21, a storage medium 22 and a bus, wherein the storage medium 22 stores program instructions executable by the processor 21, when the master station serial communication agent module 20 runs, the processor 21 communicates with the storage medium 22 through the bus, and the processor 21 executes the program instructions to execute the above method embodiment applied to the master station serial communication agent module.
Optionally, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the method embodiment applied to the master station serial communication proxy module is executed.
On the basis of the foregoing embodiments, an embodiment of the present application further provides a slave serial communication proxy module, fig. 14 is a schematic structural diagram of the slave serial communication proxy module provided in the embodiment of the present application, and as shown in fig. 14, the slave serial communication proxy module 40 includes: processor 41, storage medium 42, and a bus, where the storage medium 42 stores program instructions executable by the processor 41, and when the slave serial communication agent module 40 runs, the processor 41 communicates with the storage medium 42 through the bus, and the processor 41 executes the program instructions to execute the above method embodiment applied to the ethernet switching module.
Optionally, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the method embodiment applied to the ethernet switching module is executed, and a specific implementation manner and a technical effect are similar, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and shall be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A communication method based on master and slave stations is characterized in that the method is applied to a master station serial communication agent module in a communication system, and comprises the following steps:
encapsulating different types of original hardware data frames of a master station to obtain an Ethernet data frame, wherein a source address of the Ethernet data frame is an Ethernet address of the master station, and a destination address of the Ethernet data frame is an Ethernet address of a slave station, and the types comprise: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
and sending the Ethernet data frame to an Ethernet switching module, so that the Ethernet switching module sends the Ethernet data frame to a corresponding slave station serial communication agent module according to the slave station Ethernet address.
2. The method of claim 1, wherein encapsulating the different types of raw hardware data frames at the primary station to obtain ethernet data frames comprises:
and converting the slave station hardware address carried by the original hardware data frame into a slave station Ethernet address according to the original hardware data frame and a prestored slave station mapping relation between the slave station hardware address and the Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame.
3. The method of claim 2, wherein the converting the slave station hardware address carried by the original hardware data frame into the slave station ethernet address according to the original hardware data frame and a prestored slave station mapping relationship between the slave station hardware address and the ethernet address, and encapsulating to obtain the corresponding ethernet data frame comprises:
analyzing the original hardware data frame to obtain the type of the original hardware data frame;
and if the original hardware data frame is a broadcast data frame, converting the slave station hardware address of the original hardware data frame into a broadcast Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame.
4. The method of claim 2, wherein the converting the slave station hardware address carried by the original hardware data frame into the slave station ethernet address and encapsulating and obtaining the corresponding ethernet data frame according to the original hardware data frame and a slave station mapping relationship between the slave station hardware address and the slave ethernet address stored in advance comprises:
analyzing the original hardware data frame to obtain the type of the original hardware data frame;
if the original hardware data frame is a unicast data frame, matching an Ethernet address corresponding to the slave station hardware address in the unicast data frame according to the original hardware data frame and a prestored slave station mapping relation between the slave station hardware address and the Ethernet address;
if the matching is achieved, converting the slave station hardware address carried by the original hardware data frame into a matched unicast Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame;
and if the matching is not achieved, converting the slave station hardware address carried by the original hardware data frame into a broadcast Ethernet address, and encapsulating to obtain a corresponding Ethernet data frame.
5. The method of claim 4, wherein if the original hardware data frame is a unicast data frame, the method further comprises:
receiving an ethernet response data frame forwarded by the ethernet switching module, wherein a source address of the ethernet response data frame is a corresponding slave station ethernet address, and a destination address of the ethernet response data frame is the master station ethernet address;
analyzing the Ethernet response data frame to obtain a source address of the Ethernet response data frame;
and updating a slave station mapping relation between a prestored slave station hardware address and the Ethernet address according to the source address of the Ethernet response data frame.
6. A communication method based on a master station and a slave station is applied to a slave station serial communication proxy module in a communication system, and the method comprises the following steps:
receiving an Ethernet data frame forwarded by an Ethernet switching module according to an analyzed slave station Ethernet address, wherein the Ethernet data frame is obtained by packaging different types of original hardware data frames according to a master station, and a source address of the Ethernet data frame is a master station Ethernet address and a destination address of the Ethernet data frame is a slave station Ethernet address; the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
analyzing the Ethernet data frame, and extracting the original hardware data frame;
and sending the original hardware data frame to a connected slave station.
7. The method of claim 6, wherein the method further comprises:
and analyzing the Ethernet data frame, and extracting and storing the Ethernet address of the main station.
8. The method of claim 7, wherein after sending the original hardware data frame to the connected secondary station if the type of the original hardware data frame is a unicast data frame, the method further comprises:
receiving a response data frame sent by the slave station;
packaging the response data frame to obtain an Ethernet response data frame, wherein the source address of the Ethernet response data frame is the corresponding slave station Ethernet address, and the destination address of the Ethernet response data frame is the master station Ethernet address;
and sending the Ethernet response data frame to an Ethernet switching module.
9. A master-slave station based communication system, comprising: the system comprises at least one master station, at least one master station serial communication agent module, an Ethernet switching module, at least one slave station serial communication agent module and at least one slave station;
each master station is connected with each corresponding master station serial communication agent module through a serial communication interface, and each slave station is connected with each corresponding slave station serial communication agent module through a serial communication interface;
each master station serial communication agent module is connected with the Ethernet switching module through an Ethernet interface, and each slave station serial communication agent module is connected with the Ethernet switching module through an Ethernet interface;
each master station serial communication agent module is used for executing the master-slave station based communication method of any one of claims 1 to 5, and each slave station serial communication agent module is used for executing the master-slave station based communication method of any one of claims 6 to 8.
10. A communication device based on master and slave stations is characterized in that the device is applied to a master station serial communication agent module in a communication system, and the device comprises:
a data frame encapsulation module, configured to encapsulate different types of original hardware data frames of a master station to obtain an ethernet data frame, where a source address of the ethernet data frame is an ethernet address of the master station, and a destination address of the ethernet data frame is an ethernet address of a slave station, where the types include: the Ethernet address of the slave station is a broadcast Ethernet address or a unicast Ethernet address;
and the Ethernet data frame sending module is used for sending the Ethernet data frame to an Ethernet switching module, so that the Ethernet switching module sends the Ethernet data frame to a corresponding slave station serial communication agent module according to the slave station Ethernet address.
CN202111302948.9A 2021-11-05 2021-11-05 Communication method, communication system and communication device based on master station and slave station Active CN113746714B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111302948.9A CN113746714B (en) 2021-11-05 2021-11-05 Communication method, communication system and communication device based on master station and slave station

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111302948.9A CN113746714B (en) 2021-11-05 2021-11-05 Communication method, communication system and communication device based on master station and slave station

Publications (2)

Publication Number Publication Date
CN113746714A true CN113746714A (en) 2021-12-03
CN113746714B CN113746714B (en) 2022-02-25

Family

ID=78727395

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111302948.9A Active CN113746714B (en) 2021-11-05 2021-11-05 Communication method, communication system and communication device based on master station and slave station

Country Status (1)

Country Link
CN (1) CN113746714B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113938350A (en) * 2021-12-17 2022-01-14 深圳艾灵网络有限公司 Master-slave station communication method and system
CN114390042A (en) * 2021-12-28 2022-04-22 深圳市汇川技术股份有限公司 Industrial communication method, industrial communication system, device, and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20030032172A (en) * 2001-10-16 2003-04-26 엘지전자 주식회사 Inter-Processor Communication Method In Ethernet System
US7325075B1 (en) * 2004-03-15 2008-01-29 Hewlett-Packard Development Company, L.P. Methods for address and name discovery for Ethernet entities
CN102420760A (en) * 2011-12-02 2012-04-18 盛科网络(苏州)有限公司 Method and device for realizing forwarding among chips through Internet encapsulation packet processing header
US20120177042A1 (en) * 2011-01-07 2012-07-12 Berman Stuart B Methods, systems and apparatus for the interconnection of fibre channel over ethernet devices using a fibre channel over ethernet interconnection apparatus controller
CN105847148A (en) * 2016-03-18 2016-08-10 上海斐讯数据通信技术有限公司 Data frame forwarding control method and system
WO2016187783A1 (en) * 2015-05-25 2016-12-01 华为技术有限公司 Data transmission method and device
CN106656714A (en) * 2017-02-10 2017-05-10 广东工业大学 Communication protocol method and system based on EtherCAT bus
CN110855582A (en) * 2019-12-02 2020-02-28 西安电子科技大学 Time-triggered Ethernet switching device compatible with SpaceWire bus

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20030032172A (en) * 2001-10-16 2003-04-26 엘지전자 주식회사 Inter-Processor Communication Method In Ethernet System
US7325075B1 (en) * 2004-03-15 2008-01-29 Hewlett-Packard Development Company, L.P. Methods for address and name discovery for Ethernet entities
US20120177042A1 (en) * 2011-01-07 2012-07-12 Berman Stuart B Methods, systems and apparatus for the interconnection of fibre channel over ethernet devices using a fibre channel over ethernet interconnection apparatus controller
CN102420760A (en) * 2011-12-02 2012-04-18 盛科网络(苏州)有限公司 Method and device for realizing forwarding among chips through Internet encapsulation packet processing header
WO2016187783A1 (en) * 2015-05-25 2016-12-01 华为技术有限公司 Data transmission method and device
CN105847148A (en) * 2016-03-18 2016-08-10 上海斐讯数据通信技术有限公司 Data frame forwarding control method and system
CN106656714A (en) * 2017-02-10 2017-05-10 广东工业大学 Communication protocol method and system based on EtherCAT bus
CN110855582A (en) * 2019-12-02 2020-02-28 西安电子科技大学 Time-triggered Ethernet switching device compatible with SpaceWire bus

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
任清荣等: "基于以太网的数控系统设计与实现", 《机械设计与制造》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113938350A (en) * 2021-12-17 2022-01-14 深圳艾灵网络有限公司 Master-slave station communication method and system
CN114390042A (en) * 2021-12-28 2022-04-22 深圳市汇川技术股份有限公司 Industrial communication method, industrial communication system, device, and storage medium

Also Published As

Publication number Publication date
CN113746714B (en) 2022-02-25

Similar Documents

Publication Publication Date Title
CN113746714B (en) Communication method, communication system and communication device based on master station and slave station
CN112995133B (en) Analysis method, device and system based on modbus protocol
CN109067617B (en) V2X protocol consistency test method, device and system
CN110380970B (en) Self-adaptive data message forwarding method and device suitable for heterogeneous network
CN112104654A (en) Multi-protocol automatic identification and conversion method and intelligent gateway
CN111031034A (en) Multi-protocol convergence edge computing gateway
EP3208974A1 (en) Power line carrier communication terminal control device, system and method
CN110635933B (en) Apparatus, control method, and recording medium for managing network of SDN
US20130268632A1 (en) Server assisted authenticated device
CN109729183B (en) Request processing method, device, equipment and storage medium
CN106330483B (en) Information acquisition method, client device and server device
EP3125471B1 (en) Communication device, integrated vehicle management system, and method for updating routing table
CN111294235A (en) Data processing method, device, gateway and readable storage medium
CN109474614B (en) Multi-protocol analysis method and system
CN114362885A (en) Internet of things data transmission method, device, equipment and medium
CN104412566A (en) Methodes and nodes for handling an address of a resource
CN111741538A (en) Communication link establishing method based on gateway, equipment control method and device
CN109922148B (en) Cross-platform service method, device and system
WO2021238741A1 (en) Message forwarding method, system, device, node device, and storage medium
CN113645135A (en) SID compression method, message forwarding method, message compression device and electronic equipment
CN108574637B (en) Address self-learning method and device and switch
CN113973111B (en) Data forwarding method, device, gateway equipment and computer readable storage medium
CN112910838B (en) Composite protocol analysis method, device, equipment, system and storage medium
CN113204683A (en) Information reconstruction method and device, storage medium and electronic equipment
US20190044911A1 (en) Communication device, control method for communication device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant