CN112887277B - Conversion method and device of field bus and Ethernet and computer storage medium - Google Patents

Conversion method and device of field bus and Ethernet and computer storage medium Download PDF

Info

Publication number
CN112887277B
CN112887277B CN202110036404.6A CN202110036404A CN112887277B CN 112887277 B CN112887277 B CN 112887277B CN 202110036404 A CN202110036404 A CN 202110036404A CN 112887277 B CN112887277 B CN 112887277B
Authority
CN
China
Prior art keywords
frame
ethernet
frame length
receiving
length
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.)
Active
Application number
CN202110036404.6A
Other languages
Chinese (zh)
Other versions
CN112887277A (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.)
Kungao New Core Microelectronics Jiangsu Co ltd
Original Assignee
Kungao New Core Microelectronics Jiangsu 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 Kungao New Core Microelectronics Jiangsu Co ltd filed Critical Kungao New Core Microelectronics Jiangsu Co ltd
Priority to CN202110036404.6A priority Critical patent/CN112887277B/en
Publication of CN112887277A publication Critical patent/CN112887277A/en
Application granted granted Critical
Publication of CN112887277B publication Critical patent/CN112887277B/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
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0006Systems modifying transmission characteristics according to link quality, e.g. power backoff by adapting the transmission format
    • H04L1/0007Systems modifying transmission characteristics according to link quality, e.g. power backoff by adapting the transmission format by modifying the frame length
    • H04L1/0008Systems modifying transmission characteristics according to link quality, e.g. power backoff by adapting the transmission format by modifying the frame length by supplementing frame payload, e.g. with padding bits
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The invention discloses a conversion method, a device and a computer storage medium of a field bus and an Ethernet, wherein the method comprises the following steps: acquiring a field bus message; carrying out protocol conversion on the field bus message to obtain an Ethernet frame; acquiring a preset frame length required by the transmission of an Ethernet frame in an Ethernet link, wherein the preset frame length is obtained according to a transmission frame length required by a transmitting end of the Ethernet frame when transmitting a data frame and a receiving frame length required by a receiving end when receiving the data frame; judging whether the frame length of the Ethernet frame is smaller than a preset frame length; and if so, byte filling is carried out on the Ethernet frame to obtain the filled Ethernet frame so as to take the filled Ethernet frame as a final conversion result of the field bus message, and the frame length of the filled Ethernet frame is equal to the preset frame length. The invention can ensure that the frame length of the filled Ethernet frame is not greater than the minimum frame length of the sending end and the receiving end, thereby avoiding the increase of extra network bandwidth and forwarding time delay.

Description

Conversion method and device of field bus and Ethernet and computer storage medium
Technical Field
The invention relates to the technical field of industrial field bus transmission, in particular to a conversion method and a conversion device of a field bus and an Ethernet and a computer storage medium.
Background
The ethernet is widely used in the industrial field as a widely supported and used standard, and by performing format conversion between the industrial field bus message and the ethernet frame, the ethernet can be used as a bridge to realize intercommunication between bus networks, and by performing interconversion between the ethernet and the ethernet, the industrial field bus can also cross the internet to realize real remote control and monitoring.
At present, the minimum frame length of an ethernet frame is 64 bytes, and the message length of many field buses is much smaller than the length, so when conversion is performed, fields are often required to be filled in the converted message to achieve the minimum frame length standard of the ethernet; actually, some current network devices can support frames smaller than 64 bytes, which results in that the number of bytes of a message is greater than the minimum frame length that can be actually supported by the device, resulting in a larger frame length of an ethernet frame to be transmitted, and additionally increasing network bandwidth and delay for forwarding the message (for example, the minimum frame length supported by a sending device is 50 bytes, and the minimum frame length supported by a receiving device is 40 bytes, so that only 50 bytes are required to meet the transmission requirements of a sending end and a receiving end, and if the ethernet frame is filled with 64 bytes, 14 bytes are added, thereby adding 14 bytes of network bandwidth and transmission delay).
Disclosure of Invention
In order to solve the problem that when the existing field bus is converted into an ethernet frame, the frame is often filled to 64 bytes, which results in extra network bandwidth and message forwarding delay, the invention aims to provide a conversion method, a conversion device and a computer storage medium, which can fill the ethernet frame according to the minimum frame length supported by an ethernet frame sending device and an ethernet frame receiving device for transmission, so that the frame length of the ethernet frame obtained by filling is equal to the minimum frame length, and the frame length does not need to be filled to 64 bytes, thereby avoiding the increase of extra network bandwidth and forwarding delay.
In a first aspect, the present invention provides a conversion method between a fieldbus and an ethernet, including:
acquiring a field bus message;
carrying out protocol conversion on the field bus message to obtain an Ethernet frame;
acquiring a preset frame length required by the transmission of the Ethernet frame in an Ethernet link, wherein the preset frame length is obtained according to a transmission frame length required by a transmitting end of the Ethernet frame when transmitting a data frame and a receiving frame length required by a receiving end when receiving the data frame;
judging whether the frame length of the Ethernet frame is smaller than the preset frame length;
and if so, byte filling is carried out on the Ethernet frame to obtain the filled Ethernet frame, so that the filled Ethernet frame is used as a final conversion result of the fieldbus message, and the filled Ethernet frame is sent to the receiving end by the sending end, wherein the frame length of the filled Ethernet frame is equal to the preset frame length.
Based on the above disclosure, in the invention, firstly, the protocol conversion is performed on the fieldbus message to obtain the ethernet frame, and the step is as follows: converting the field bus message into an Ethernet frame (the Ethernet frame obtained in the step is not subjected to byte filling); then, according to the sending frame length of the sending end of the ethernet frame and the receiving frame length of the receiving end, a preset frame length required by the transmission of the ethernet frame in the ethernet link is obtained, and the essence of the step is as follows: according to the minimum frame length (namely the sending frame length and the receiving frame length) supported by the sending end and the receiving end during transmission, the frame length after the Ethernet frame is filled (namely the minimum frame length required during transmission) is obtained; and finally, judging whether the frame length of the Ethernet frame is smaller than a preset frame length, if so, indicating that the frame length of the Ethernet frame cannot meet the minimum frame length for data transmission of a transmitting end and a receiving end, and filling bytes, wherein the frame length after filling is the preset frame length.
Through the design, the minimum frame length after byte filling can be determined according to the minimum frame lengths supported by the transmitting end and the receiving end of the Ethernet frame, so that the frame length of the Ethernet frame after field bus message conversion and filling is not larger than the minimum frame lengths of the transmitting end and the receiving end, and the problems of extra network bandwidth and forwarding time delay caused by filling the Ethernet frame into 64 bytes by a traditional conversion method are solved.
In one possible design, taking a preset frame length required for the ethernet frame to be transmitted in the ethernet link includes:
acquiring the length of a sending frame required by the sending end when the sending end sends a data frame, wherein the length of the sending frame is determined according to the hardware structure of the sending end;
acquiring a receiving frame length required by the receiving end when receiving a data frame, wherein the receiving frame length is determined according to a hardware structure of the receiving end;
and taking the largest one of the sending frame length and the receiving frame length as the preset frame length.
Based on the above disclosure, the present invention discloses a specific obtaining method of a preset frame length, that is, a sending frame length required when a sending end sends a data frame and a receiving frame length required when a receiving end receives the data frame (both are determined by the hardware structure of the terminal) are obtained first, and then the largest frame length of the two is taken as the preset frame length (for example, the sending frame length is 40 bytes, the receiving frame length is 50 bytes, and the preset frame length is 50 bytes); by the design, after the Ethernet frames are filled, the obtained frame length simultaneously meets the requirements of the data transmission frame length of the transmitting end and the receiving end.
In one possible design, the method further includes:
and if not, taking the Ethernet frame as a final conversion result of the field bus message.
Based on the above disclosure, the present invention discloses a processing step when the frame length of the ethernet frame is greater than or equal to the preset frame length, that is, if the frame length is greater than or equal to the preset frame length, it indicates that the ethernet frame meets the minimum frame length required by the transmitting end and the receiving end, and the transmission can be directly performed without performing byte stuffing.
In one possible design, performing protocol conversion on the fieldbus message to obtain an ethernet frame, including:
and packaging the field bus message, and obtaining the Ethernet frame after the packaging is finished, wherein the packaging comprises: adding an Ethernet header before the header of the fieldbus message, and adding a cyclic redundancy check code after the tail of the fieldbus message.
Based on the above disclosure, the present invention discloses a specific method for performing protocol conversion on a fieldbus message, namely, encapsulating, adding an ethernet header before the header of the fieldbus message, and adding a cyclic redundancy check code after the tail of the fieldbus message, thereby completing encapsulation and obtaining an ethernet frame.
In one possible design, byte padding is performed on the ethernet frame to obtain a padded ethernet frame, including:
and adding null bytes between the tail part of the field bus message in the Ethernet frame and the cyclic redundancy check code until the frame length of the Ethernet frame is increased to the preset frame length, and obtaining the filled Ethernet frame after the addition is finished.
Based on the disclosure, the invention discloses a specific method for byte filling of an ethernet frame, namely, a null byte (usually 0) is filled between the tail of a fieldbus message in the ethernet frame and a cyclic redundancy check code until the frame length of the ethernet frame is increased to a preset frame length, and the filled ethernet frame can be obtained after the filling is finished.
In one possible design, the ethernet header includes: an ethernet frame header.
In a second aspect, the present invention provides a conversion apparatus for a fieldbus and an ethernet, including: the device comprises a first acquisition unit, a conversion unit, a second acquisition unit, a judgment unit and a filling unit;
the first acquisition unit is used for acquiring a field bus message;
the conversion unit is used for carrying out protocol conversion on the field bus message to obtain an Ethernet frame;
the second obtaining unit is configured to obtain a preset frame length required for transmission of the ethernet frame in an ethernet link, where the preset frame length is obtained according to a sending frame length required by a sending end of the ethernet frame when sending a data frame and a receiving frame length required by a receiving end when receiving the data frame;
the judging unit is used for judging whether the frame length of the Ethernet frame is smaller than the preset frame length;
and the filling unit is configured to perform byte filling on the ethernet frame to obtain a filled ethernet frame when the judgment unit judges that the ethernet frame is yes, so that the filled ethernet frame is used as a final conversion result of the fieldbus message, and the filled ethernet frame is sent to the receiving end by the sending end, where a frame length of the filled ethernet frame is equal to the preset frame length.
In one possible design, the second obtaining unit includes: a sending frame length obtaining subunit, a receiving frame length obtaining subunit and a preset frame length generating subunit;
the sending frame length acquiring subunit is configured to acquire a sending frame length required by the sending end when sending a data frame, where the sending frame length is determined according to a hardware structure of the sending end;
the receiving frame length acquiring subunit is configured to acquire a receiving frame length required by the receiving end when receiving a data frame, where the receiving frame length is determined according to a hardware structure of the receiving end;
and the preset frame length generation subunit is configured to use the largest one of the sending frame length and the receiving frame length as the preset frame length.
In one possible design:
the determining unit is further configured to use the ethernet frame as a final conversion result of the fieldbus packet when it is determined that the frame length of the ethernet frame is greater than or equal to the preset frame length.
In one possible design:
the conversion unit is specifically configured to encapsulate the fieldbus packet, and obtain the ethernet frame after the encapsulation is completed, where the encapsulation includes: adding an Ethernet header before the header of the fieldbus message, and adding a cyclic redundancy check code after the tail of the fieldbus message.
In one possible design;
the filling unit is specifically configured to add a null byte between the tail of the fieldbus packet in the ethernet frame and the cyclic redundancy check code until the frame length of the ethernet frame is increased to the preset frame length, and obtain the filled ethernet frame after the addition is completed.
In a third aspect, the present invention provides a second converting apparatus for converting a fieldbus and an ethernet network, including a memory, a processor and a transceiver, which are communicatively connected in sequence, where the memory is used to store a computer program, the transceiver is used to transmit and receive a message, and the processor is used to read the computer program and execute the converting method for converting the fieldbus and the ethernet network as may be designed in any one of the first aspect or the first aspect.
In a fourth aspect, the present invention provides a computer storage medium, which stores instructions for executing the method for converting a fieldbus and an ethernet network as described in the first aspect or any one of the possible designs of the first aspect when the instructions are run on a computer.
In a fifth aspect, the present invention provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the method for converting a fieldbus to an ethernet as described in the first aspect or any one of the possible designs of the first aspect.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart of a conversion method between a fieldbus and an ethernet according to the present invention.
Fig. 2 is a schematic diagram of conversion when byte stuffing is not required in the field bus packet and ethernet frame forward conversion provided by the present invention.
Fig. 3 is a schematic conversion diagram of byte stuffing required in conversion between the fieldbus message and the ethernet frame according to the present invention.
Fig. 4 is a schematic structural diagram of a first field bus and ethernet conversion device provided in the present invention.
Fig. 5 is a schematic structural diagram of a second field bus and ethernet conversion device provided in the present invention.
Detailed Description
The invention is further described with reference to the following figures and specific embodiments. It should be noted that the following examples are provided to aid understanding of the present invention, but are not intended to limit the present invention. Specific structural and functional details disclosed herein are merely illustrative of example embodiments of the invention. This invention may, however, be embodied in many alternate forms and should not be construed as limited to the embodiments set forth herein.
It will be understood that, although the terms first, second, etc. may be used herein to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another. For example, a first element could be termed a second element, and, similarly, a second element could be termed a first element, without departing from the scope of example embodiments of the present invention.
It should be understood that, for the term "and/or" as may appear herein, it is merely an associative relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, B exists alone, and A and B exist at the same time; for the term "/and" as may appear herein, which describes another associative object relationship, it means that two relationships may exist, e.g., a/and B, may mean: a exists independently, and A and B exist independently; in addition, for the character "/" that may appear herein, it generally means that the former and latter associated objects are in an "or" relationship.
It will be understood that when an element is referred to herein as being "connected," "connected," or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Conversely, if a unit is referred to herein as being "directly connected" or "directly coupled" to another unit, it is intended that no intervening units are present. In addition, other words used to describe the relationship between elements should be interpreted in a similar manner (e.g., "between … …" versus "directly between … …", "adjacent" versus "directly adjacent", etc.).
It is to be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments of the invention. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises," "comprising," "includes" and/or "including," when used herein, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, numbers, steps, operations, elements, components, and/or groups thereof.
It should also be noted that, in some alternative implementations, the functions/acts noted may occur out of the order noted in the figures. For example, two figures shown in succession may, in fact, be executed substantially concurrently, or the figures may sometimes be executed in the reverse order, depending upon the functionality/acts involved.
It should be understood that specific details are provided in the following description to facilitate a thorough understanding of example embodiments. However, it will be understood by those of ordinary skill in the art that the example embodiments may be practiced without these specific details. For example, systems may be shown in block diagrams in order not to obscure the examples in unnecessary detail. In other instances, well-known processes, structures and techniques may be shown without unnecessary detail in order to avoid obscuring example embodiments.
Examples
As shown in fig. 1, the method for converting a fieldbus and an ethernet provided in the first aspect of this embodiment is suitable for converting a fieldbus message and an ethernet frame; the invention can determine the minimum frame length (namely the preset frame length) of the transmission after converting the field bus message into the Ethernet frame according to the minimum frame lengths supported by the transmitting end and the receiving end on the Ethernet link (namely the minimum frame length supported by the transmitting end for transmitting data and the minimum frame length supported by the receiving end for receiving data); finally, judging whether the Ethernet frame is smaller than a preset frame length, namely determining whether the Ethernet frame carries out byte filling; if the frame length is smaller than the preset frame length, the current frame length of the Ethernet frame is smaller than the minimum frame length supported by the sending end and the receiving end for data sending, byte filling is needed, and the frame length after the filling is equal to the preset frame length; through the design, the frame length of the Ethernet frame obtained after the field bus message is converted and filled is not required to be larger than the minimum frame length of the transmitting end and the receiving end, and the problems that the Ethernet frame is filled into 64 bytes by a traditional conversion method, so that extra network bandwidth is increased and forwarding delay is delayed are solved.
In this embodiment, the conversion between the fieldbus message and the ethernet frame can be implemented in, but not limited to, a conversion device, such as a gateway or a router.
The method for converting the fieldbus and the ethernet provided by this embodiment may include, but is not limited to, the following steps S101 to S105.
S101, acquiring a field bus message.
And S102, carrying out protocol conversion on the field bus message to obtain an Ethernet frame.
Step S101 and step S102 are processes in which the conversion device receives the fieldbus message, performs protocol conversion on the fieldbus message, and converts the fieldbus message into an ethernet frame. For example, a fieldbus port of the gateway receives the fieldbus, performs protocol conversion on fieldbus messages inside the fieldbus port to obtain an ethernet frame, and finally transmits the ethernet frame to a transmitting end from the ethernet port, thereby implementing transmission of the ethernet frame.
In this embodiment, the protocol conversion is performed on the fieldbus message to obtain the ethernet frame, which can be implemented by, but is not limited to, the following step S102a.
S102a, packaging the field bus message, and obtaining the Ethernet frame after the packaging is finished, wherein the packaging comprises: adding an Ethernet header before the header of the fieldbus message, and adding a cyclic redundancy check code after the tail of the fieldbus message.
In this embodiment, the field bus packet is converted into an ethernet frame by using an encapsulation method, which substantially includes: the method is characterized in that the field bus message is embedded into an Ethernet frame, and the method comprises the steps of adding an Ethernet header before the head of a field message bus, and adding a cyclic redundancy check code after the tail of the field message bus, thereby realizing the encapsulation of the field bus message in an original state; that is, in this embodiment, the ethernet frame includes a complete fieldbus message, so that the content included in the fieldbus message is not changed.
In this embodiment, the example ethernet header may include, but is not limited to: an Ethernet frame header; the ethernet frame header uses the MAC (Media Access Control) address to describe the destination address and the source address; the cyclic redundancy check code is used for checking whether the data transmission is damaged.
In this embodiment, when the field bus message is subjected to Protocol conversion and encapsulation, other Protocol headers such as an IP (Internet Protocol) or a UDP (User Datagram Protocol) may be added before the header of the field message bus; of course, regardless of the protocol conversion encapsulation, the following steps S103 to S105 are required for byte stuffing.
Through the steps, the Ethernet conversion of the field bus message can be realized, and the transmission based on the Ethernet link is realized; since step S102 is only the ethernet frame obtained by encapsulation, and byte padding is not yet performed, in this embodiment, it is determined whether the ethernet frame is byte-padded according to the minimum frame length of data transmission supported by the transmitting end and the receiving end on the ethernet link, that is, as shown in step S103, step S104, and step S105.
S103, acquiring a preset frame length required by the transmission of the Ethernet frame in an Ethernet link, wherein the preset frame length is obtained according to a transmission frame length required by a transmitting end of the Ethernet frame when transmitting a data frame and a receiving frame length required by a receiving end when receiving the data frame.
Step S103 is a process of obtaining the minimum frame lengths of data transmission supported by the transmitting end and the receiving end, and obtaining a preset frame length according to the minimum frame lengths of the transmitting end and the receiving end.
Colloquially understood as follows: when a sending end sends a data frame, the minimum frame length of a required data frame (in this embodiment, the sending frame length refers to the minimum frame length of the sending end, for example, the sending end can only send a data frame whose frame length is greater than or equal to 50 bytes, then the minimum frame length of the sending end is 50 frames), and when a receiving end receives a data frame, the minimum frame length of a required data frame (similarly, the receiving frame length refers to the minimum frame length of the receiving end, for example, the receiving end can only support a data frame whose receiving frame length is greater than or equal to 40 bytes, then the minimum frame length of the receiving end is 40 bytes), and the preset frame length is determined according to the minimum frame lengths of the sending end and the receiving end.
In the present embodiment, the obtaining of the preset frame length may be implemented by, but is not limited to, the following steps S103a to S103c.
S103a, obtaining a sending frame length required by the sending end when sending the data frame, wherein the sending frame length is determined according to a hardware structure of the sending end.
S103b, acquiring a receiving frame length required by the receiving end when receiving the data frame, wherein the receiving frame length is determined according to a hardware structure of the receiving end.
And S103c, taking the largest one of the length of the sending frame and the length of the receiving frame as the length of the preset frame.
In the present embodiment, the principle of steps S103a to S103c is: the minimum frame lengths (i.e., the transmission frame length of the transmitting end and the receiving frame length of the receiving end) supported by the transmitting end and the receiving end are obtained first, and then the maximum one of the frame lengths is used as a preset frame length. Through the design, the invention can ensure the frame length of the Ethernet frame after byte filling, can simultaneously meet the transmission requirements of a transmitting end and a receiving end, and simultaneously can not be larger than the minimum frame length of the transmitting end and the receiving end, thereby avoiding the problems of network bandwidth and transmission delay increase caused by filling extra byte number.
For example, the length of a transmission frame of a transmitting end is 50 bytes, that is, the minimum frame length supported by the transmitting end for data frame transmission is 50 bytes; the receiving frame length of the receiving end is 40 bytes, namely the minimum frame length supported by the receiving end when transmitting the data frame is 40 bytes; then according to step S103 c: the preset frame length is 50 bytes, that is, the minimum frame length required for transmitting the ethernet frame over the ethernet link is 50 bytes.
In this embodiment, the minimum frame lengths of the transmitting end and the receiving end are determined by respective hardware structures (i.e., hardware configurations), that is, the minimum frame lengths of the transmitting end and the receiving end are determined as long as the transmitting end and the receiving end leave the factory.
And S104, judging whether the frame length of the Ethernet frame is smaller than the preset frame length.
And S105, if yes, byte filling is carried out on the Ethernet frame to obtain the filled Ethernet frame, so that the filled Ethernet frame is used as a final conversion result of the field bus message, and the filled Ethernet frame is sent to the receiving end by the sending end, wherein the frame length of the filled Ethernet frame is equal to the preset frame length.
Step S104 and step S105 are processes of byte stuffing, and in this embodiment, before byte stuffing, the size relationship between the frame length of the ethernet frame and the preset frame length needs to be determined; if the frame length of the ethernet frame obtained through the protocol conversion is greater than or equal to the frame length of the ethernet frame obtained through the protocol conversion, the frame length of the ethernet frame obtained through the protocol conversion meets the minimum frame length required by transmission in the ethernet link, byte stuffing is not required, the ethernet frame can be directly used as a final conversion result of the fieldbus message and sent to the receiving end by the sending end, and a conversion schematic diagram can be shown in fig. 2.
As shown in fig. 3, if the frame length of the ethernet frame is smaller than the preset frame length, it indicates that the frame length of the ethernet frame cannot meet the minimum frame length required for transmission in the ethernet link, and the ethernet frame can be transmitted only after being filled; at this time, byte padding is required to be performed on the ethernet frame, so as to enable the frame length of the padded ethernet frame to reach a preset frame length.
For example, on the basis of the above example, the frame length is preset to be 50 bytes; the Ethernet frame is 20 bytes, and the frame length is smaller than the preset frame length; therefore, the ethernet frame needs to be padded with bytes until the frame length of the ethernet frame is equal to 50 bytes after padding, that is, 30 bytes need to be padded in the ethernet frame to reach the length of 50 bytes.
In this embodiment, the example of byte stuffing the ethernet frame may be, but is not limited to: adding null bytes between the tail part of the field bus message in the Ethernet frame and the cyclic redundancy check code until the frame length of the Ethernet frame is increased to a preset frame length, and obtaining the filled Ethernet frame after the addition is finished; that is, as shown in fig. 3, a dummy byte (typically 0) is filled between the tail of the fieldbus message and the cyclic redundancy check code.
In this embodiment, the frame length of the filled ethernet frame can be controlled to the minimum frame length commonly supported by the transmitting end and the receiving end, so that the frame length of the filled ethernet frame is not greater than the minimum frame length of the transmitting end and the receiving end, thereby avoiding the filling of redundant bytes and achieving the purpose of reducing network bandwidth and transmission delay.
The following example is provided to illustrate the difference between the conversion method provided in this embodiment and the conventional conversion method:
the traditional conversion method comprises the following steps: as long as the frame length of the ethernet frame is less than 64 bytes, when byte stuffing is performed, no matter whether the minimum frame length supported by the transmitting end and the receiving end is less than 64, the frame length is stuffed to 64 bytes (for example, the minimum frame length of the transmitting end is 50 bytes, the receiving end is 40 bytes, and the transmission frame length of the transmitted data is greater than or equal to 50 bytes, which can meet the transmission requirement of the transmitting end and the transmitting end); the method results in 14 bytes being redundant, and the additional network bandwidth and transmission delay of 14 bytes are increased.
The conversion method provided in this embodiment may first obtain the minimum frame lengths of the transmitting end and the receiving end, and use the larger frame length of the two as the preset frame length, that is, the frame length obtained after the ethernet frame is filled, so that after the ethernet frame is filled, the obtained frame length simultaneously satisfies the minimum frame lengths of the transmitting end and the receiving end (that is, the preset frame length), and does not need to fill extra bytes, thereby achieving the purpose of reducing the network bandwidth and the transmission delay (for example, the minimum frame lengths of the transmitting end and the receiving end are both 50 bytes, and then the frame length of the ethernet frame after filling in this embodiment is 50 bytes, compared with the conventional conversion method, the obtained final conversion result reduces 14 bytes, thereby reducing the network bandwidth and the transmission delay required by the 14 bytes).
Therefore, by the method for converting the fieldbus and the ethernet described in detail in the foregoing steps S101 to S105, the present invention can determine the minimum frame length after byte stuffing according to the minimum frame lengths supported by the sending end and the receiving end of the ethernet frame, so that the frame length of the ethernet frame obtained by converting and stuffing the fieldbus packet is not necessarily greater than the minimum frame lengths of the sending end and the receiving end, and the problem of adding extra network bandwidth and forwarding delay due to stuffing the ethernet frame into 64 bytes by the conventional conversion method is avoided.
As shown in fig. 4, a second aspect of this embodiment provides a hardware device for implementing the method for converting a fieldbus and an ethernet network in the first aspect of the embodiment, including: the device comprises a first acquisition unit, a conversion unit, a second acquisition unit, a judgment unit and a filling unit.
The first obtaining unit is used for obtaining the field bus message.
And the conversion unit is used for carrying out protocol conversion on the field bus message to obtain an Ethernet frame.
The second obtaining unit is configured to obtain a preset frame length required by the ethernet frame when the ethernet frame is transmitted in an ethernet link, where the preset frame length is obtained according to a sending frame length required by a sending end of the ethernet frame when the sending end sends a data frame, and a receiving frame length required by a receiving end when the receiving end receives the data frame.
The judging unit is configured to judge whether the frame length of the ethernet frame is smaller than the preset frame length.
And the filling unit is configured to perform byte filling on the ethernet frame to obtain a filled ethernet frame when the judgment unit judges that the ethernet frame is yes, so that the filled ethernet frame is used as a final conversion result of the fieldbus message, and the filled ethernet frame is sent to the receiving end by the sending end, where a frame length of the filled ethernet frame is equal to the preset frame length.
In one possible design, the second obtaining unit includes: a sending frame length obtaining sub-unit, a receiving frame length obtaining sub-unit and a preset frame length generating sub-unit.
The sending frame length acquiring subunit is configured to acquire a sending frame length required by the sending end when sending a data frame, where the sending frame length is determined according to a hardware structure of the sending end.
The receiving frame length acquiring subunit is configured to acquire a receiving frame length required by the receiving end when receiving a data frame, where the receiving frame length is determined according to a hardware structure of the receiving end.
And the preset frame length generation subunit is configured to use the largest one of the sending frame length and the receiving frame length as the preset frame length.
In one possible design:
the determining unit is further configured to use the ethernet frame as a final conversion result of the fieldbus packet when it is determined that the frame length of the ethernet frame is greater than or equal to the preset frame length.
In one possible design:
the conversion unit is specifically configured to encapsulate the fieldbus packet, and obtain the ethernet frame after encapsulation is completed, where the encapsulation includes: adding an Ethernet header before the header of the fieldbus message, and adding a cyclic redundancy check code after the tail of the fieldbus message.
In one possible design;
the filling unit is specifically configured to add a null byte between the tail of the fieldbus packet in the ethernet frame and the cyclic redundancy check code until the frame length of the ethernet frame is increased to the preset frame length, and obtain the filled ethernet frame after the addition is completed.
For the working process, the working details, and the technical effects of the hardware apparatus provided in this embodiment, reference may be made to the first aspect of the embodiment, which is not described herein again.
As shown in fig. 5, a third aspect of this embodiment provides a second hardware device for implementing the method for converting a fieldbus into an ethernet described in the first aspect of this embodiment, including a memory, a processor, and a transceiver, which are communicatively connected in sequence, where the memory is used to store a computer program, the transceiver is used to transmit and receive messages, and the processor is used to read the computer program and execute the method for converting a fieldbus into an ethernet described in the first aspect of this embodiment.
For example, the Memory may include, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Flash Memory (Flash Memory), a First In First Out (FIFO), and/or a First In Last Out (FILO), and the like; the processor may not be limited to a microprocessor of a model number STM32F105 series, a reduced instruction set computer (RSIC) microprocessor, an architecture processor such as X86, or a processor integrated with a neural-Network Processing Unit (NPU); the transceiver may be, but is not limited to, a wireless fidelity (WIFI) wireless transceiver, a bluetooth wireless transceiver, a General Packet Radio Service (GPRS) wireless transceiver, a ZigBee wireless transceiver (ieee802.15.4 standard-based low power local area network protocol), a 3G transceiver, a 4G transceiver, and/or a 5G transceiver, etc. In addition, the device may also include, but is not limited to, a power module, a display screen, and other necessary components.
For the working process, the working details, and the technical effects of the hardware apparatus provided in this embodiment, reference may be made to the first aspect of the embodiment, which is not described herein again.
A fourth aspect of the present embodiment provides a computer storage medium storing instructions including the fieldbus conversion method according to the first aspect of the present invention, that is, the computer storage medium stores instructions that, when executed on a computer, perform the fieldbus conversion method according to the first aspect of the present invention. The computer storage medium refers to a carrier for storing data, and may include, but is not limited to, a floppy disk, an optical disk, a hard disk, a flash Memory, a flash disk and/or a Memory Stick (Memory Stick), and the like, and the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
For the working process, the working details, and the technical effects of the computer storage medium provided in this embodiment, reference may be made to the first aspect of the embodiment, which is not described herein again.
A fifth aspect of the present embodiment provides a computer program product comprising instructions for causing a computer, which may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus, to perform the method for converting fieldbus and ethernet according to the first aspect of the present embodiment when the instructions are run on the computer.
The embodiments described above are merely illustrative, and 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 modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device to perform the methods described in the embodiments or some parts of the embodiments.
The invention is not limited to the above alternative embodiments, and any other various forms of products can be obtained by anyone in the light of the present invention, but any changes in shape or structure thereof, which fall within the scope of the present invention as defined in the claims, fall within the scope of the present invention.

Claims (10)

1. A conversion method of a field bus and an Ethernet is characterized by comprising the following steps:
acquiring a field bus message;
carrying out protocol conversion on the field bus message to obtain an Ethernet frame;
acquiring a preset frame length required by the transmission of the Ethernet frame in an Ethernet link, wherein the preset frame length is obtained according to a transmission frame length required by a transmitting end of the Ethernet frame when transmitting a data frame and a receiving frame length required by a receiving end when receiving the data frame;
judging whether the frame length of the Ethernet frame is smaller than the preset frame length or not;
and if so, byte filling is carried out on the Ethernet frame to obtain the filled Ethernet frame so as to take the filled Ethernet frame as a final conversion result of the fieldbus message, and the filled Ethernet frame is sent to the receiving end by the sending end, wherein the frame length of the filled Ethernet frame is equal to the preset frame length.
2. The method of claim 1, wherein obtaining a preset frame length required for the transmission of the ethernet frame over the ethernet link comprises:
acquiring the length of a sending frame required by the sending end when the sending end sends a data frame, wherein the length of the sending frame is determined according to the hardware structure of the sending end;
acquiring a receiving frame length required by the receiving end when receiving a data frame, wherein the receiving frame length is determined according to a hardware structure of the receiving end;
and taking the largest one of the sending frame length and the receiving frame length as the preset frame length.
3. The method of claim 1, wherein the method further comprises:
and if not, taking the Ethernet frame as a final conversion result of the field bus message.
4. The method of claim 1, wherein performing protocol conversion on the fieldbus message to obtain an ethernet frame comprises:
and packaging the field bus message, and obtaining the Ethernet frame after the packaging is finished, wherein the packaging comprises: adding an Ethernet header before the header of the fieldbus message, and adding a cyclic redundancy check code after the tail of the fieldbus message.
5. The method of claim 4, wherein byte stuffing the Ethernet frame to obtain a stuffed Ethernet frame comprises:
and adding null bytes between the tail part of the field bus message in the Ethernet frame and the cyclic redundancy check code until the frame length of the Ethernet frame is increased to the preset frame length, and obtaining the filled Ethernet frame after the addition is finished.
6. The method of claim 4, wherein the Ethernet header comprises: an ethernet frame header.
7. A field bus to ethernet conversion apparatus, comprising: the device comprises a first acquisition unit, a conversion unit, a second acquisition unit, a judgment unit and a filling unit;
the first acquisition unit is used for acquiring the field bus message;
the conversion unit is used for carrying out protocol conversion on the field bus message to obtain an Ethernet frame;
the second obtaining unit is configured to obtain a preset frame length required by the ethernet frame when the ethernet frame is transmitted in an ethernet link, where the preset frame length is obtained according to a sending frame length required by a sending end of the ethernet frame when sending a data frame and a receiving frame length required by a receiving end when receiving the data frame;
the judging unit is used for judging whether the frame length of the Ethernet frame is smaller than the preset frame length;
and the filling unit is configured to perform byte filling on the ethernet frame to obtain a filled ethernet frame when the judgment unit judges that the ethernet frame is a frame with a length equal to the preset frame length, so that the filled ethernet frame is used as a final conversion result of the fieldbus message, and the sending end sends the filled ethernet frame to the receiving end.
8. The apparatus of claim 7, wherein the second obtaining unit comprises: a sending frame length obtaining subunit, a receiving frame length obtaining subunit and a preset frame length generating subunit;
the sending frame length acquiring subunit is configured to acquire a sending frame length required by the sending end when sending a data frame, where the sending frame length is determined according to a hardware structure of the sending end;
the receiving frame length acquiring subunit is configured to acquire a receiving frame length required by the receiving end when receiving a data frame, where the receiving frame length is determined according to a hardware structure of the receiving end;
and the preset frame length generation subunit is configured to use the largest one of the sending frame length and the receiving frame length as the preset frame length.
9. A conversion device of a field bus and an Ethernet, which comprises a memory, a processor and a transceiver connected in sequence, wherein the memory is used for storing a computer program, the transceiver is used for transmitting and receiving messages, and the processor is used for reading the computer program and executing the conversion method of the field bus and the Ethernet according to any one of claims 1 to 6.
10. A computer storage medium having stored thereon instructions which, when run on a computer, cause the computer to perform the method of converting a fieldbus of any one of claims 1 to 6 to an ethernet network.
CN202110036404.6A 2021-01-12 2021-01-12 Conversion method and device of field bus and Ethernet and computer storage medium Active CN112887277B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110036404.6A CN112887277B (en) 2021-01-12 2021-01-12 Conversion method and device of field bus and Ethernet and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110036404.6A CN112887277B (en) 2021-01-12 2021-01-12 Conversion method and device of field bus and Ethernet and computer storage medium

Publications (2)

Publication Number Publication Date
CN112887277A CN112887277A (en) 2021-06-01
CN112887277B true CN112887277B (en) 2022-07-08

Family

ID=76044282

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110036404.6A Active CN112887277B (en) 2021-01-12 2021-01-12 Conversion method and device of field bus and Ethernet and computer storage medium

Country Status (1)

Country Link
CN (1) CN112887277B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115529106A (en) * 2021-06-25 2022-12-27 华为技术有限公司 Communication method and related equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1953416A (en) * 2006-09-16 2007-04-25 华为技术有限公司 A method, system and device to transport the IPv6 message of Ethernet
CN105162734A (en) * 2015-08-05 2015-12-16 武汉森岩科技有限公司 Multi-source data transmission system based on Zigbee network
CN106528486A (en) * 2016-11-09 2017-03-22 湖南戈人自动化科技有限公司 Method for exchanging serial port data
CN108011797A (en) * 2017-12-14 2018-05-08 天津津航计算技术研究所 A kind of ethernet communication system based on 1553B agreements

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190044657A1 (en) * 2018-09-28 2019-02-07 Intel Corporation Method and apparatus to manage undersized network packets in a media access control (mac) sublayer

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1953416A (en) * 2006-09-16 2007-04-25 华为技术有限公司 A method, system and device to transport the IPv6 message of Ethernet
CN105162734A (en) * 2015-08-05 2015-12-16 武汉森岩科技有限公司 Multi-source data transmission system based on Zigbee network
CN106528486A (en) * 2016-11-09 2017-03-22 湖南戈人自动化科技有限公司 Method for exchanging serial port data
CN108011797A (en) * 2017-12-14 2018-05-08 天津津航计算技术研究所 A kind of ethernet communication system based on 1553B agreements

Also Published As

Publication number Publication date
CN112887277A (en) 2021-06-01

Similar Documents

Publication Publication Date Title
US10341230B2 (en) Techniques for forwarding or receiving data segments associated with a large data packet
US8891554B2 (en) Method for data transmission in an automation system using dynamic frame packing
CN107079017B (en) Message conversion method and device
CN111083161A (en) Data transmission processing method and device and Internet of things equipment
WO2017088557A1 (en) Processing method and apparatus for sending and receiving data packet
JP2015089092A (en) Method of packaging packet, method of unpackaging packet, and apparatuses using the same
EP3073698A1 (en) Method for processing address resolution protocol message, forwarder and controller
EP3820110A1 (en) Data sending method, data receiving method, device, and system
AU2016202660B2 (en) Techniques for forwarding or receiving data segments associated with a large data packet
WO2021088813A1 (en) Packet encapsulating method and apparatus, and packet decapsulating method and apparatus
CN104378315B (en) A kind of method and device of CAPWAP tunnel packet transmission
CN112887277B (en) Conversion method and device of field bus and Ethernet and computer storage medium
CN109218154A (en) A kind of converting system based on the gigabit Ethernet of FPGA to SLIP
WO2011137648A1 (en) Download method and system based on management data input/output interface
CN114301576A (en) Method and communication device for generating and transmitting acknowledgement frame in IEEE802.15.4 network
EP2201740B1 (en) High speed packet processing in a wireless network
WO2018137218A1 (en) Data transmission method, data receiving device, and data sending device
CN109067922A (en) A kind of data transmission method and device
US8583822B2 (en) Method and system for minimum frame size support for a communication protocol encapsulated over Ethernet
JP2008236217A (en) Flexray network connecting method, flexray network and electronic control unit for flexray network
CN111327575B (en) Communication method and device based on Ethernet in train
CN109495371A (en) Network connectivity devices towards DTN/IP protocol stack
WO2020192940A1 (en) Compressed transmission of ethernet traffic through a wireless link
US9661110B2 (en) System and method for enabling channel access enhancements in existing communication networks
CN105407084B (en) A kind of network transmission device, method and system

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