Method and device for transmitting Ethernet frame
By comparing the fields of the Ethernet frame with configuration information in the Ethernet frame transmission link, filtering marks are generated to determine the transmission content, the problem of low transmission efficiency in the prior art is solved, and more flexible and efficient data transmission is achieved.
Patent Information
- Application Number
- CN202410465089.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-17
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-04-17
AI Technical Summary
When transmitting Ethernet frames, the filtering dimension is solidified, which cannot meet the flexible requirements of the subsequent module for data, resulting in low efficiency in transmitting effective Ethernet frames to the subsequent module.
By obtaining the Ethernet frame and comparing its fields with the field configuration information in the non-limited delay link, a field comparison mark is generated, and then a filter mark is generated based on the filter configuration information to determine whether the fields of the Ethernet frame need to be transmitted, thereby improving transmission efficiency .
Based on the comparison results of the fields and configuration information of the Ethernet frame, the transmission content of the Ethernet frame is flexibly determined, which meets the requirements of the subsequent module for data format and type, and improves the flexibility and efficiency of data transmission.
Smart Images

Figure CN118233062B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet technology, and in particular to a method, an apparatus, a computer device, a storage medium and a program product for transmitting Ethernet frames. Background Art
[0002] In view of the rapid development of the current communication field, Ethernet, as the most common computer network, plays an important role in the communication field, and its related technologies have also flourished. In the communication field, it is often necessary to process the data content of Ethernet frames, and due to the diversity of application scenarios, there is a high demand for the versatility of data filtering processing.
[0003] In the prior art, the network information of the microprocessor system can be filtered by address filtering or port filtering. However, the filtering dimension of the network information transmitted to the subsequent module by address filtering or port filtering is fixed, which cannot meet the flexible requirements of the subsequent module for data, and the efficiency of transmitting valid Ethernet frames to the subsequent module is low. Summary of the invention
[0004] The present disclosure provides a method for transmitting Ethernet frames, which improves the efficiency of transmitting valid Ethernet frames to subsequent modules.
[0005] In a first aspect, the present disclosure provides a method for transmitting an Ethernet frame, the method comprising: obtaining an Ethernet frame when a transmission link of the Ethernet frame is a non-delay-limited link, comparing the fields of the Ethernet frame with field configuration information, generating a field comparison mark based on the field comparison mark and filter configuration information, generating a filter mark based on the filter mark, and determining the transmission of the fields of the Ethernet frame.
[0006] The method for transmitting Ethernet frames provided by the present disclosure generates a field comparison mark indicating whether the field of the Ethernet frame is consistent with the field configuration information according to the comparison result of the field of the Ethernet frame and the field configuration information for Ethernet frame information in a transmission link that is not sensitive to transmission delay, and then determines whether the mark in the field comparison mark hits the filtering configuration according to the filtering configuration information, and then generates a filtering mark for indicating whether to filter some fields or all fields of the Ethernet frame, and then determines whether to transmit some fields or all fields of the Ethernet frame according to the filtering mark, thereby improving the efficiency of transmitting valid Ethernet frames to subsequent modules.
[0007] In an optional embodiment, a filter flag is generated based on the field comparison flag and the filter configuration information, including: determining the target field type and / or format based on the field comparison flag, the target field type and / or format is the field type and / or format of the Ethernet frame that does not match the comparison result of the field configuration information; and performing at least one of the following according to the filter configuration information and the target field type and / or format: when the filter configuration information indicates that the target field type and / or format is a field type and / or format that is not filtered, generating a filter flag indicating that the field is not filtered; when the filter configuration information indicates that the target field type and / or format is a field type and / or format for filtering the corresponding field or the entire Ethernet frame, generating a filter flag indicating that the corresponding field or the entire Ethernet frame is filtered.
[0008] The method for generating a filter mark according to the field comparison mark and the filter configuration information in this embodiment can filter the field of the Ethernet frame or the entire Ethernet frame according to the configuration of the field configuration information when the field type and / or format in the field comparison mark does not match the field configuration information, thereby meeting the requirements of the subsequent module for the data format and / or type and enhancing the flexibility of data transmission.
[0009] In an optional implementation, the method further includes: if the target field type and / or format exists, using an indication signal of a non-storage mapping interface to send a field comparison mark to a lower-level module in the transmission link.
[0010] In the method for transmitting Ethernet frames in this embodiment, when some fields do not match, the entire Ethernet frame may not be filtered, and the type and / or format of the fields that do not match may be indicated to the lower-level module through the indication information of the non-storage mapping interface. The indication is transmitted to the lower-level module, thereby notifying the Ethernet frame that the Ethernet frame is a problematic data packet, improving the integrity of the information of the transmitted Ethernet frame, thereby providing an effective reference for the subsequent use of the Ethernet frame, and improving the efficiency of transmitting the Ethernet frame.
[0011] In an optional implementation, determining the transmission of the field of the Ethernet frame according to the filter indicator includes: writing the field of the Ethernet frame into a write address corresponding to the filter indicator in a random access memory according to the filter indicator.
[0012] The method for transmitting Ethernet frames in this embodiment writes the fields of the Ethernet frame into the write address corresponding to the filter mark in the random access memory, provides a specific transmission method for the transmission of the fields of the Ethernet frame, improves the certainty of the transmission, and thus improves the efficiency of transmitting Ethernet frames through the read-write characteristics of the transmission path at any time.
[0013] In an optional embodiment, the transmission of the fields of the Ethernet frame is determined according to the filter flag, including: when there is a filter flag corresponding to the filtering of the first field in the filter flag, writing the first field from the write address of the random access memory, and increasing the write address sequentially until the writing of the first field ends; rolling back the write address at the end of writing the first field to the jump address; wherein the jump address is the starting write address of writing the first field to the random access memory.
[0014] The method for transmitting Ethernet frames in this embodiment, when transmitting Ethernet frames, writes the Ethernet frame field that needs to be filtered into the random access memory, and then jumps the write address to the initial write address of the field, so that the subsequent write content overwrites the content of the Ethernet frame field that needs to be filtered that was written earlier, thereby filtering the field that needs to be filtered, thereby improving the accuracy of the data of the transmitted Ethernet frame, enhancing the flexibility of the transmitted data type and / or format, only transmitting the data that needs to be transmitted to the subsequent module, reducing the processing volume and processing complexity during the data transmission process, and has a wide range of application scenarios.
[0015] In an optional embodiment, the transmission of the field of the Ethernet frame is determined according to the filter flag, including: when there is a filter flag corresponding to not filtering the second field in the filter flag, the second field is written from the write address of the random access memory, and the write address is sequentially increased until the writing of the second field is completed.
[0016] The method for transmitting Ethernet frames in this embodiment, when there is no need to filter the second field, can normally write the second field from the write address of the random access memory, and increase the write address sequence until the writing of the second field is completed, thereby completing the writing of the second field. Together with the above-mentioned step of filtering the first field, the filtering of the field that needs to be filtered is implemented, and the normal writing of the field that does not need to be filtered is implemented, thereby improving the accuracy of the data of the transmitted Ethernet frame, enhancing the flexibility of the transmitted data type and / or format, only transmitting the data that needs to be transmitted to the subsequent module, reducing the processing amount and processing complexity during the data transmission process, and having a wide range of application scenarios.
[0017] In an optional embodiment, the transmission of the fields of the Ethernet frame is determined according to the filter flag, including: before the end of writing the Ethernet frame to the random access memory according to the filter flag, keeping the temporary address equal to the read address; and when receiving a read instruction for the Ethernet frame, if the temporary address is equal to the read address, preventing the reading of the Ethernet frame.
[0018] The method for transmitting Ethernet frames in this embodiment keeps the temporary address equal to the read address when the writing of the Ethernet frame is not completed, and prevents the reading of the Ethernet frame when the temporary address is equal to the read address, that is, the unfiltered Ethernet frame cannot be read, thereby achieving complete filtering of the Ethernet frame, improving the accuracy of the transmitted Ethernet frame, enhancing the flexibility of the fields of the transmitted Ethernet frame, only transmitting the data that needs to be transmitted to the subsequent module, reducing the processing volume and processing complexity during the data transmission process, and has a wide range of application scenarios.
[0019] In an optional embodiment, the transmission of the fields of the Ethernet frame is determined according to the filter flag, and the method also includes: when the Ethernet frame is finished being written to the random access memory according to the filter flag, jumping the temporary address to the write address corresponding to the end of writing the Ethernet frame; and when a read instruction for the Ethernet frame is received, if the temporary address is not equal to the read address, reading the Ethernet frame and increasing the read address sequentially until the read address is equal to the temporary address corresponding to the end of writing the Ethernet frame.
[0020] The method for transmitting Ethernet frames in this embodiment jumps the temporary address to be equal to the write address when writing the Ethernet frame is completed, and can read the Ethernet frame when the temporary address is not equal to the read address, thereby realizing smooth reading of the Ethernet frame at the end of writing the Ethernet frame, thereby realizing complete filtering of the Ethernet frame, improving the accuracy of the transmitted Ethernet frame, and enhancing the flexibility of the fields of the transmitted Ethernet frame.
[0021] In an optional implementation, the method further includes: when it is determined that the transmission link of the Ethernet frame is a delay-constrained link, directly transmitting the Ethernet frame via the multiplexer.
[0022] The method for transmitting Ethernet frames in this embodiment uses a delay-limited link that is sensitive to transmission delay and uses a link directly connected to a multiplexer, thereby not passing through a filtering functional module to meet the low delay requirements of Ethernet frames and improve the real-time performance of link transmission.
[0023] In a second aspect, the present disclosure provides a device for transmitting Ethernet frames, the device comprising: an acquisition module for acquiring Ethernet frames; a comparison module for comparing fields of Ethernet frames with field configuration information to generate a field comparison mark when the transmission link of the Ethernet frame is a non-limited delay link; a generation module for generating a filter mark based on the field comparison mark and the filter configuration information; and a determination module for determining the transmission of the fields of the Ethernet frame based on the filter mark.
[0024] In a third aspect, the present disclosure provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for transmitting Ethernet frames of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0025] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for transmitting Ethernet frames of the first aspect or any corresponding embodiment thereof.
[0026] In a fifth aspect, the present disclosure provides a computer program product, including computer instructions, where the computer instructions are used to enable a computer to execute the method for transmitting Ethernet frames of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0028] Figure 1a is a flow chart of a method for transmitting Ethernet frames according to an embodiment of the present disclosure;
[0029] Figure 1b is a schematic diagram of field comparison markings of a method for transmitting an Ethernet frame according to an embodiment of the present disclosure;
[0030] Figure 1c yes Figure 1a A flowchart of some optional implementations of step S102 in FIG.
[0031] Figure 2 is a flowchart of another method for transmitting Ethernet frames according to an embodiment of the present disclosure;
[0032] Figure 3 is a structural block diagram of an apparatus for transmitting Ethernet frames according to an embodiment of the present disclosure;
[0033] Figure 4 It is a schematic diagram of the hardware structure of the computer device of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0035] The Ethernet frame is the complete frame format of Ethernet transmission. It is a binary data packet from the line. The general structure generally includes the following parts:
[0036] Preamble: used to synchronize the clocks of the receiver and sender.
[0037] Delimiter (Start Frame Delimiter), marking the beginning of the Ethernet frame.
[0038] Destination MAC address, indicating the MAC address of the target receiver of the data frame.
[0039] Source MAC address, indicating the MAC address of the sender of the data frame.
[0040] Tag (optional), the first two bytes are the tag protocol identifier (TPID) value 0x8100. Ethernet type 0x8100 indicates a frame containing a tag, and the actual Ethernet type / length field is placed after the Q tag. TPID is followed by two bytes of tag control information (TCI). After the Q tag is the usual frame content.
[0041] Type / length field: In Ethernet II format, this field is used to identify the type of data; in IEEE802.3 format, it is used to indicate the length of the data.
[0042] Payload, the actual data content transmitted, has a different length depending on the two formats.
[0043] The frame check sequence (FCS) can be used to check the integrity of the data frame to detect whether an error occurs during the transmission process.
[0044] According to an embodiment of the present disclosure, a method embodiment for transmitting Ethernet frames is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0045] In this embodiment, a method for transmitting Ethernet frames is provided, which can be used in microprocessor systems, such as various types of computers, microcontrollers / single-chip microcomputers, etc. In the embodiment, it is possible to implement filtering of Ethernet frames in an Ethernet controller on a microprocessor system based on the verification results of the data format during Ethernet transmission, and filter the data type and format of the transmission. The Ethernet frame after this filtering process can determine the data type and format of the backward transmission, which can meet the requirements of the subsequent modules for the data format and type, enhance flexibility, reduce the processing volume and processing complexity during data transmission, and has a wide range of application scenarios. Figure 1a is a flow chart of a method for transmitting Ethernet frames according to an embodiment of the present disclosure, such as Figure 1a As shown, the process includes the following steps:
[0046] Step S101, obtaining an Ethernet frame.
[0047] In this embodiment, the execution subject of the present disclosure, such as a computer, a microcontroller / single-chip microcomputer, etc., can obtain data to be transmitted from the upper-level module as a processing node for data transmission during the data transmission process, and the data may include multiple Ethernet frames. In some specific examples, the above-mentioned execution subject can store the obtained data in the internal or external memory of the execution subject to execute subsequent operation steps.
[0048] Step S102: When the transmission link of the Ethernet frame is a non-delay-limited link, compare the fields of the Ethernet frame with the field configuration information to generate a field comparison mark.
[0049] In this embodiment, the above-mentioned execution entity can determine whether the transmission link of the currently acquired Ethernet frame is more sensitive to transmission delay. If it is not a delay-limited link that is more sensitive to transmission delay, the above-mentioned execution entity can compare the fields of the Ethernet frame with the field configuration information to generate a field comparison mark indicating whether the comparison result is consistent.
[0050] The field configuration information, which matches each transmission field of the Ethernet frame, is the configuration information used to filter the data type and format of the Ethernet frame, and can be preset by a person skilled in the art according to scenario requirements, experience or preset rules. For example, for the general structure of the Ethernet frame, the field configuration information can be the preset configuration information for the preamble, delimiter, source address, destination address, type / length, label, payload, frame check sequence (FCS) and other fields.
[0051] The field comparison mark is the result of comparing the field of the Ethernet frame with the field configuration information. Whether the field type and / or format corresponding to each field of the Ethernet frame is consistent with the field configuration information is indicated in the field comparison mark. Figure 1b As shown, Figure 1b A schematic diagram of field comparison marking is shown as an example.
[0052] In some specific examples, the field configuration information of the Ethernet frame preamble may be: a default byte value of 0x55, a default byte length of 7 bytes; or a preset byte value and byte length of the preamble. The above-mentioned execution subject generates a field comparison flag = 1 when the byte value and byte length of the Ethernet frame preamble match the field configuration information, otherwise flag = 0.
[0053] The field configuration information of the delimiter can be: the default value of the byte is 0xd5, or the preset byte value. If the received data field matches the configuration here, flag = 1, otherwise flag = 0.
[0054] The field configuration information of the destination address may be: configure a 6-byte local MAC address in the register, if the destination MAC address field of the received data matches the register configuration, flag = 1, otherwise flag = 0.
[0055] The field configuration information of the source address may be similar to that of the destination address, but in practice this is rarely judged.
[0056] The Ethernet type / length field configuration information can be: a 2-byte field after the source address, which is divided into two categories according to the value. If it is not less than 0x0600, it is considered to represent the type. Certain types of messages can be configured to be filtered, or certain types of messages cannot be filtered. At this time, the relationship between the field of the received data and the configuration affects the flag judgment; if it does not exceed 0x05dc, it is considered to represent the length. If the length of the subsequent received data payload matches this field, flag = 1, otherwise flag = 0.
[0057] The field configuration information of the data payload part (Payload) can be: in some special types of messages, some fields of the payload part may have special meanings, such as the opcode field of the 1588 message represents the sequence attribute. The payload can be configured for special types of messages, and whether the corresponding fields of the received data match affects the flag judgment. Of course, this is rarely used in actual scenarios and can be ignored.
[0058] The field configuration information of the frame check sequence can be: the frame check sequence is to perform a CRC32 check on the data frame starting from the destination MAC address to the end of the data frame payload part to ensure that there are no errors in the frame content during transmission. If the CRC recalculation of the data part by the receiving end is consistent with the received frame check field, flag = 1, otherwise flag = 0.
[0059] Step S103: Generate a filtering flag according to the field comparison flag and the filtering configuration information.
[0060] In this embodiment, the filtering configuration information is configuration information that indicates which fields will filter part or all of the Ethernet frame when they do not match. When the field comparison mark indicates that the comparison result is completely consistent, the filtering configuration information indicates not to filter the current Ethernet frame, so the generated filtering mark also indicates not to filter the current Ethernet frame.
[0061] When the field comparison mark indicates that the comparison result is not completely consistent, that is, there is a mark corresponding to the inconsistent field in the field comparison mark, the above-mentioned execution entity does not directly classify the Ethernet frame as an erroneous Ethernet frame and filter it, but determines which fields will filter the entire Ethernet frame when they do not match and which fields will filter part of the Ethernet frame when they do not match based on the comparison result of the field comparison mark and the filtering configuration information, thereby generating a filtering mark that can indicate the filtering content.
[0062] Step S104, determining the transmission of the fields of the Ethernet frame according to the filter mark.
[0063] In this embodiment, the execution subject can determine whether to filter some or all fields of the Ethernet frame according to the filtering content indicated by the filtering mark, thereby determining whether to transmit some or all fields of the Ethernet frame. For example, if it is determined to filter some fields of the Ethernet frame according to the filtering mark, the fields of the Ethernet frame after filtering the some fields are transmitted; if it is determined to filter all fields of the Ethernet frame according to the filtering mark, it is determined not to transmit all fields of the Ethernet frame.
[0064] The method for transmitting Ethernet frames provided in this embodiment generates a field comparison mark indicating whether the field of the Ethernet frame is consistent with the field configuration information according to the comparison result between the field of the Ethernet frame and the field configuration information for Ethernet frame information in a transmission link that is not sensitive to transmission delay, and then determines whether the mark in the field comparison mark hits the filtering configuration according to the filtering configuration information, thereby generating a filtering mark for indicating whether to filter some fields or all fields of the Ethernet frame, and then determines whether to transmit some fields or all fields of the Ethernet frame according to the filtering mark, thereby improving the efficiency of transmitting valid Ethernet frames to the subsequent modules.
[0065] In some optional implementations of the method for transmitting Ethernet frames provided in the above embodiments of the present disclosure, the method for transmitting Ethernet frames may further include:
[0066] Step S105: When it is determined that the transmission link of the Ethernet frame is a delay-constrained link, the Ethernet frame is directly transmitted via the multiplexer.
[0067] Specifically, in the above embodiment, some or all fields of the Ethernet frame are filtered, and a complete Ethernet frame check filtering is required before the Ethernet frame can be sent to the next-level module. Therefore, the delay in its transmission process is the transmission time of an entire Ethernet frame. In some links that are sensitive to transmission delays, such as links in precision clock networks, such delays are unacceptable. Therefore, data packets can be allowed to not be filtered to meet special needs of low latency.
[0068] In this implementation, a delay-limited link that is sensitive to transmission delay can be used, and a link directly connected to the multiplexer can be used without passing through a filtering functional module to meet the low-latency requirements of Ethernet frames and improve the real-time performance of link transmission.
[0069] In some optional implementations of the method for transmitting Ethernet frames provided in the above embodiments of the present disclosure, such as Figure 1c As shown, Figure 1c A specific implementation of step S102 in the above embodiment is shown. Step S102 may include:
[0070] Step S1021, determining the target field type and / or format based on the field comparison indicator.
[0071] The target field type and / or format is: the field type and / or format of the Ethernet frame that does not match the comparison result with the field configuration information.
[0072] Step S1022: at least one of the following may be performed according to the filtering configuration information and the target field type and / or format:
[0073] Step a1: when the filtering configuration information indicates that the target field type and / or format is a field type and / or format that is not to be filtered, generate a filtering mark indicating that the field is not to be filtered.
[0074] Step a2: when the filtering configuration information indicates that the target field type and / or format is the field type and / or format of filtering the corresponding field or the entire Ethernet frame, generate a filtering mark indicating filtering the corresponding field or the entire Ethernet frame.
[0075] Specifically, when generating a filter mark according to the filter configuration information and the target field type and / or format, if the situation of generating the filter mark meets the step a1, only the above step a1 is executed; if the situation of generating the filter mark meets the above step a2, only step a2 is executed; if the situation of generating the filter mark meets the step a1 and step a2, then steps a1 and a2 are executed.
[0076] In this implementation, when comparing the field comparison mark and the filtering configuration information, it is not the case that as long as there is a field that does not match the field comparison mark, the Ethernet frame will be classified as an error message and filtered. Therefore, the configuration here is used to indicate which fields will filter the data packet when they do not match. For example, it is acceptable for the preamble length to not match, and the type / length to not match, and the configuration is not to filter the packet due to the mismatch; while the frame check sequence mismatch is unacceptable, and the configuration is to filter the packet due to the mismatch.
[0077] The method for generating a filter mark according to the field comparison mark and the filter configuration information in the present implementation can filter the field of the Ethernet frame or the entire Ethernet frame according to the configuration of the field configuration information when the field type and / or format in the field comparison mark does not match the field configuration information, thereby meeting the requirements of the subsequent module for the data format and / or type and enhancing the flexibility of data transmission.
[0078] In the implementation of the above step S102, the following may also be included:
[0079] Step S1023: If the target field type and / or format exists, a non-storage mapping interface indication signal is used to send a field comparison mark to a lower-level module in the transmission link.
[0080] In this step, when some fields do not match, the execution subject may not filter the entire Ethernet frame, and indicate the type and / or format of the field that does not match to the lower-level module through the indication information of the non-storage mapping interface. The indication is transmitted to the lower-level module, thereby notifying the Ethernet frame that the Ethernet frame is a problematic data packet, improving the integrity of the information of the transmitted Ethernet frame, thereby providing an effective reference for the subsequent use of the Ethernet frame, and improving the efficiency of transmitting the Ethernet frame.
[0081] In some optional implementations of the method for transmitting Ethernet frames provided in the above embodiments of the present disclosure, the above step S104 may include: writing the fields of the Ethernet frame into a write address corresponding to the filter mark in the random access memory according to the filter mark.
[0082] Among them, random access memory (RAM), also called main memory, is the internal memory that directly exchanges data with the CPU. It can be read and written at any time (except when refreshed) and is very fast. It is usually used as a temporary data storage medium for operating systems or other running programs. RAM is used in computers and digital systems to temporarily store programs, data, and intermediate results.
[0083] Specifically, according to the filter mark, the write address in the RAM indicated by the filter mark can be determined, so that the field corresponding to the filter mark in the Ethernet frame is written into the RAM, so as to read the data and complete the transmission of the Ethernet frame.
[0084] In some specific examples, the filter flags may include filter flags corresponding to filter fields and filter flags corresponding to non-filter fields. The execution subject may only process the fields indicated by the filter flags corresponding to non-filter fields and write these fields into the RAM.
[0085] In the above optional implementation, the fields of the Ethernet frame are written to the write address corresponding to the filter mark in the random access memory, which provides a specific transmission method for the transmission of the fields of the Ethernet frame and improves the certainty of the transmission, thereby improving the efficiency of transmitting Ethernet frames through the read-write characteristics of the transmission path at any time.
[0086] In this embodiment, another method for transmitting Ethernet frames is provided, which can be used in the above-mentioned microprocessor system, such as various types of computers, microcontrollers / single-chip microcomputers, etc. Figure 2 is a flow chart of another method for transmitting Ethernet frames according to an embodiment of the present disclosure, such as Figure 2 As shown, the process includes the following steps:
[0087] Step S201, obtaining an Ethernet frame.
[0088] In this embodiment, the execution subject of the present disclosure, such as a computer, a microcontroller / single-chip microcomputer, etc., can obtain the Ethernet frame to be transmitted from the upper-level module as a processing node of data transmission during the data transmission process. In some specific examples, the above-mentioned execution subject can store the obtained Ethernet frame to the internal or external memory of the execution subject so as to execute subsequent operation steps.
[0089] Step S202: When the transmission link of the Ethernet frame is a non-delay-limited link, compare the fields of the Ethernet frame with the field configuration information to generate a field comparison mark.
[0090] In this embodiment, the above-mentioned execution entity can determine whether the transmission link of the currently acquired Ethernet frame is more sensitive to transmission delay. If it is not a delay-limited link that is more sensitive to transmission delay, the above-mentioned execution entity can compare the fields of the Ethernet frame with the field configuration information to generate a field comparison mark indicating whether the comparison result is consistent.
[0091] Step S203: Generate a filtering flag according to the field comparison flag and the filtering configuration information.
[0092] In this embodiment, the filtering configuration information is configuration information that indicates which fields will filter part or all of the Ethernet frame when they do not match. When the field comparison mark indicates that the comparison result is completely consistent, the filtering configuration information indicates not to filter the current Ethernet frame, so the generated filtering mark also indicates not to filter the current Ethernet frame.
[0093] Step S204, when there is a filter mark corresponding to the first filter field in the filter mark, write the first field from the write address of the random access memory, increase the write address sequence until the writing of the first field ends; roll back the write address at the end of writing the first field to the jump address.
[0094] In this embodiment, the jump address is the starting write address of the first field written into the random access memory. When the first field needs to be filtered, the first field can be normally written from the write address of the random access memory, and when the writing of the first field is completed, the write address is rolled back to the starting write address, so that the data written later covers the first field, thereby realizing the filtering of the written first field.
[0095] Step S205 , when there is a filter flag corresponding to not filtering the second field in the filter flag, write the second field from the write address of the random access memory, and increase the write address sequentially until the writing of the second field is completed.
[0096] In this embodiment, when the second field does not need to be filtered, the second field can be written normally from the write address of the random access memory, and the write address is sequentially increased until the writing of the second field is completed, thereby completing the writing of the second field. This step, together with the above-mentioned step of filtering the first field, implements the filtering of the field that needs to be filtered and the normal writing of the field that does not need to be filtered.
[0097] In this embodiment, the above steps S201 to S203, for details, please refer to Figure 1a The steps S101 to S103 of the illustrated embodiment will not be described in detail in this disclosure.
[0098] The method for transmitting Ethernet frames provided in this embodiment, when transmitting Ethernet frames, writes the Ethernet frame fields that need to be filtered into the random access memory, and then jumps the write address to the initial write address of the field, so that the subsequent write content overwrites the content of the Ethernet frame fields that need to be filtered written previously, thereby filtering the fields that need to be filtered and normally writing the fields that do not need to be filtered, thereby improving the accuracy of the data of the transmitted Ethernet frame, enhancing the flexibility of the data type and / or format of the transmitted, only transmitting the data that needs to be transmitted to the subsequent module, reducing the processing volume and processing complexity during the data transmission process, and having a wide range of application scenarios.
[0099] In some optional implementations of this embodiment, the method for transmitting an Ethernet frame may include:
[0100] Step S206, before writing the Ethernet frame to the random access memory according to the filter mark is completed, keep the temporary address equal to the read address; and when receiving a read instruction for the Ethernet frame, if the temporary address is equal to the read address, prevent reading the Ethernet frame.
[0101] In this optional implementation, the execution subject can only transmit the complete Ethernet frame to the lower-level module after filtering the content to be filtered in the complete Ethernet frame. The execution subject can keep the temporary address equal to the read address before filtering is completed to indicate that the filtering of the current Ethernet frame is not completed, and prevent the Ethernet frame from being read when the temporary address is equal to the read address.
[0102] The method for transmitting Ethernet frames in this embodiment keeps the temporary address equal to the read address when the writing of the Ethernet frame is not completed, and prevents the reading of the Ethernet frame when the temporary address is equal to the read address, that is, the unfiltered Ethernet frame cannot be read, thereby achieving complete filtering of the Ethernet frame, improving the accuracy of the transmitted Ethernet frame, enhancing the flexibility of the fields of the transmitted Ethernet frame, only transmitting the data that needs to be transmitted to the subsequent module, reducing the processing volume and processing complexity during the data transmission process, and has a wide range of application scenarios.
[0103] In some optional implementations of this embodiment, the method for transmitting an Ethernet frame may include:
[0104] Step S207, when the Ethernet frame is written to the random access memory according to the filter mark, the temporary address is jumped to the write address corresponding to the end of the written Ethernet frame; and when a read instruction for the Ethernet frame is received, if the temporary address is not equal to the read address, the Ethernet frame is read and the read address is sequentially increased until the read address is equal to the temporary address corresponding to the end of the written Ethernet frame.
[0105] In this optional implementation, when the writing of the Ethernet frame is completed, the above-mentioned execution body jumps the temporary address to the write address corresponding to the end of writing the Ethernet frame to indicate that the filtering of the current Ethernet frame has been completed, and when the temporary address is not equal to the read address, the Ethernet frame is read normally, and the read position change is indicated in a sequentially increasing manner of the read address, so that when the read address is equal to the write address at the end of writing the Ethernet frame, it indicates that the reading has been completed at this time.
[0106] In the method for transmitting Ethernet frames in the implementation mode, the above-mentioned execution subject jumps the temporary address to be equal to the write address at the end of writing the Ethernet frame, and can read the Ethernet frame when the temporary address is not equal to the read address, thereby realizing smooth reading of the Ethernet frame at the end of writing the Ethernet frame, protecting the unfiltered Ethernet frame from being read, thereby realizing complete filtering of the Ethernet frame, improving the accuracy of the transmitted Ethernet frame, enhancing the flexibility of the fields of the transmitted Ethernet frame, only transmitting the data that needs to be transmitted to the subsequent module, reducing the processing volume and processing complexity during the data transmission process, and having a wide range of application scenarios.
[0107] The following is combined with the above disclosure Figure 2 A specific application scenario of the embodiment shown in the figure illustrates the method for transmitting Ethernet frames disclosed in the present invention.
[0108] In this application scenario, the method for transmitting Ethernet frames is applied to FPGA (field programmable gate array), and Ethernet frames are filtered based on multiple judgment conditions such as preamble, delimiter, source address, destination address, type / length, tag, payload, FCS check result, etc., to filter the data type and / or format of the transmission. At the same time, the Block RAM cache is used in the FPGA to complete partial filtering of the frame content such as address, type, FCS check result, etc.
[0109] Specifically, after obtaining the Ethernet frame, when the transmission link of the Ethernet frame is an unrestricted delay link, the FPGA can compare the fields of the Ethernet frame such as the preamble, delimiter, source address, destination address, type, tag, payload, FCS check result, etc. with the field configuration information, and generate a field comparison mark corresponding to the comparison result - comparison flag.
[0110] In actual practice, it is not the case that as long as there is a mismatched comparison flag, the Ethernet frame is classified as an error message and filtered. A filter flag can be generated based on the comparison flag and the filter configuration information. The filter configuration information here is the configuration that specifies which fields will filter the data packet when they are mismatched. For example, mismatches in the preamble length and type / length are acceptable, and the entire Ethernet frame is not filtered due to the mismatch; mismatches in the frame check sequence are unacceptable, and the entire Ethernet frame is filtered due to the mismatch.
[0111] The filtering behavior here is not just the overall filtering of erroneous Ethernet frames. In actual applications, there is actually local filtering, such as filtering out the preamble and delimiter of the received Ethernet frame; filtering to the last frame check sequence; filtering all other fields except the data frame payload part, etc.
[0112] When there is a filter Flag corresponding to filtering the first field in the filter Flag, the first field is written from the write address wr_addr of the Block RAM of the FPGA, and the write address wr_addr is sequentially increased until the writing of the first field is completed; the write address wr_addr at the end of writing the first field is rolled back to the jump address; wherein the jump address is the starting write address of writing the first field into the random access memory.
[0113] Afterwards, when there is a filter Flag corresponding to not filtering the second field in the filter Flag, the second field is written from the write address wr_addr of the random access memory, and the write address wr_addr is sequentially increased until the writing of the second field is completed.
[0114] Before writing the Ethernet frame to the random access memory according to the filter mark, keep the temporary address temp_addr equal to the read address rd_addr until the writing of the Ethernet frame is completed, and jump the temporary address temp_addr to the write address wr_addr corresponding to the end of writing the Ethernet frame;
[0115] When receiving a read instruction for an Ethernet frame, if the temporary address temp_addr is equal to the read address rd_addr, it means that the filtering of the Ethernet frame has not been completed, and the reading of the Ethernet frame is blocked at this time; when receiving a read instruction for an Ethernet frame, if the temporary address temp_addr is not equal to the read address rd_addr, the Ethernet frame is read at this time, and the read address rd_addr is sequentially increased until the read address rd_addr is equal to the temporary address temp_addr corresponding to the end of writing the Ethernet frame.
[0116] In addition, based on the low latency requirements of certain application scenarios, a configuration can be added in which the data does not enter the Block RAM cache for filtering, but is directly transmitted as an Ethernet frame via the multiplexer.
[0117] In this embodiment, a device for transmitting Ethernet frames is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0118] This embodiment provides a device for transmitting Ethernet frames, such as Figure 3 As shown, including:
[0119] An acquisition module 301 is used to acquire an Ethernet frame;
[0120] A comparison module 302, for comparing the fields of the Ethernet frame with the field configuration information to generate a field comparison mark when the transmission link of the Ethernet frame is a non-limited delay link;
[0121] A generating module 303, used to generate a filtering mark according to the field comparison mark and the filtering configuration information;
[0122] The determination module 304 is used to determine the transmission of the field of the Ethernet frame according to the filter mark.
[0123] In some optional implementations, the generating module 303 includes:
[0124] a determining unit, configured to determine a target field type and / or format based on the field comparison indication, wherein the target field type and / or format is a field type and / or format of the Ethernet frame that does not match a comparison result of the field configuration information; and
[0125] An execution unit is used to execute at least one of the following according to the filtering configuration information and the target field type and / or format: when the filtering configuration information indicates that the target field type and / or format is a field type and / or format that is not filtered, generate a filtering mark indicating that the field is not filtered; when the filtering configuration information indicates that the target field type and / or format is a field type and / or format for filtering a corresponding field or an entire Ethernet frame, generate a filtering mark indicating that the corresponding field or the entire Ethernet frame is filtered.
[0126] In some optional embodiments, the above device further includes:
[0127] The sending module is used to send the field comparison mark to the lower-level module in the transmission link by using the indication signal of the non-storage mapping interface if the target field type and / or format exists.
[0128] In some optional implementations, the determination module 304 includes:
[0129] The writing unit is used to write the fields of the Ethernet frame into a writing address corresponding to the filtering mark in a random access memory according to the filtering mark.
[0130] In some optional implementations, the determination module 304 includes:
[0131] A first increasing unit is used for writing the first field from the write address of the random access memory when there is a filter mark corresponding to the first field in the filter mark, and sequentially increasing the write address until the writing of the first field is completed;
[0132] The address rollback unit is used to roll back the write address where writing of the first field ends to a jump address; wherein the jump address is the start write address of writing the first field into the random access memory.
[0133] In some optional implementations, the determination module 304 includes:
[0134] The second adding unit is used to write the second field from the write address of the random access memory when there is a filter mark corresponding to not filtering the second field in the filter mark, and sequentially increase the write address until the writing of the second field is completed.
[0135] In some optional implementations, the determination module 304 includes:
[0136] An address holding unit, used for keeping a temporary address equal to a read address before the end of writing the Ethernet frame into the random access memory according to the filter mark; and
[0137] The reading prevention unit is used to prevent the reading of the Ethernet frame if the temporary address is equal to the reading address when receiving a reading instruction for the Ethernet frame.
[0138] In some optional implementations, the determination module 304 includes:
[0139] An address jump unit, used for jumping the temporary address to a write address corresponding to the end of writing the Ethernet frame when writing the Ethernet frame to the random access memory ends according to the filtering mark;
[0140] The address increasing unit is used for, upon receiving a read instruction for the Ethernet frame, reading the Ethernet frame and sequentially increasing the read address if the temporary address is not equal to the read address until the read address is equal to the temporary address corresponding to the end of writing the Ethernet frame.
[0141] In some optional embodiments, the above device further includes:
[0142] The transmission module is used to directly transmit the Ethernet frame via a multiplexer when it is determined that the transmission link of the Ethernet frame is a delay-limited link.
[0143] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0144] See also Figure 4 , Figure 41 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present disclosure, and the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system).
[0145] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0146] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0147] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0148] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0149] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0150] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0151] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for transmitting an Ethernet frame, characterized in that: The method comprises: Get Ethernet frame; When the transmission link of the Ethernet frame is a non-delay-limited link, comparing the field of the Ethernet frame with the field configuration information to generate a field comparison mark, wherein the field comparison mark indicates whether the field type and / or format is consistent with the field configuration information; Generate a filter mark according to the field comparison mark and the filter configuration information, including: based on the field comparison mark, determine the target field type and / or format, the target field type and / or format is the field type and / or format of the Ethernet frame that does not match the comparison result of the field configuration information; and perform at least one of the following according to the filter configuration information and the target field type and / or format: when the filter configuration information indicates that the target field type and / or format is a field type and / or format that is not filtered, generate a filter mark indicating that the field is not filtered; when the filter configuration information indicates that the target field type and / or format is a field type and / or format for filtering a corresponding field or an entire Ethernet frame, generate a filter mark indicating that the corresponding field or the entire Ethernet frame is filtered; According to the filter flag, transmission of the field of the Ethernet frame is determined.
2. The method according to claim 1, characterized in that: The method further comprises: If the target field type and / or format exists, the field comparison mark is sent to the lower level module in the transmission link using an indication signal of a non-storage mapping interface.
3. The method according to claim 1, characterized in that Determining the transmission of the field of the Ethernet frame according to the filter indication includes: According to the filter mark, the field of the Ethernet frame is written into a write address corresponding to the filter mark in a random access memory.
4. The method according to claim 1, characterized in that: Determining the transmission of the field of the Ethernet frame according to the filter indication includes: When there is a filter mark corresponding to filtering the first field in the filter mark, writing the first field from the write address of the random access memory, and sequentially increasing the write address until the writing of the first field is completed; Rolling back the write address where writing of the first field ends to the jump address; The jump address is a starting write address for writing the first field into the random access memory.
5. The method according to any one of claims 1 or 4, characterized in that: Determining the transmission of the field of the Ethernet frame according to the filter indication includes: When there is a filter flag corresponding to not filtering the second field in the filter flag, the second field is written from the write address of the random access memory, and the write address is sequentially increased until the writing of the second field is completed.
6. The method according to claim 5, characterized in that Determining the transmission of the field of the Ethernet frame according to the filter indication includes: Before writing the end of the Ethernet frame to the random access memory according to the filter indication, keeping the temporary address equal to the read address; and When a read instruction for the Ethernet frame is received, if the temporary address is equal to the read address, the reading of the Ethernet frame is prevented.
7. The method according to claim 6, characterized in that Determining the transmission of the field of the Ethernet frame according to the filter indication further includes: When the Ethernet frame is finished being written to the random access memory according to the filter mark, the temporary address is jumped to the write address corresponding to the end of writing the Ethernet frame; When receiving a read instruction for the Ethernet frame, if the temporary address is not equal to the read address, the Ethernet frame is read and the read address is sequentially increased until the read address is equal to the temporary address corresponding to the end of writing the Ethernet frame.
8. The method according to claim 1, characterized in that: The method further comprises: When it is determined that the transmission link of the Ethernet frame is a delay-constrained link, the Ethernet frame is directly transmitted via the multiplexer.
9. A device for transmitting Ethernet frames, characterized in that: The device comprises: An acquisition module, used for acquiring Ethernet frames; A comparison module, used for comparing the fields of the Ethernet frame with the field configuration information when the transmission link of the Ethernet frame is a non-limited delay link, and generating a field comparison mark, wherein the field comparison mark indicates whether the field type and / or format is consistent with the field configuration information; A generating module, used to generate a filtering mark according to a field comparison mark and filtering configuration information, comprising: determining a target field type and / or format based on the field comparison mark, wherein the target field type and / or format is a field type and / or format of the Ethernet frame that does not match the comparison result of the field configuration information; and performing at least one of the following according to the filtering configuration information and the target field type and / or format: when the filtering configuration information indicates that the target field type and / or format is a field type and / or format that is not filtered, generating a filtering mark indicating that the field is not filtered; when the filtering configuration information indicates that the target field type and / or format is a field type and / or format for filtering a corresponding field or an entire Ethernet frame, generating a filtering mark indicating that the corresponding field or the entire Ethernet frame is filtered; The determination module is used to determine the transmission of the fields of the Ethernet frame according to the filter mark.
10. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for transmitting Ethernet frames according to any one of claims 1 to 8 by executing the computer instructions.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for transmitting Ethernet frames according to any one of claims 1 to 8.
12. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the method for transmitting Ethernet frames according to any one of claims 1 to 8.
Citation Information
Patent Citations
Message communication method and device, electronic equipment and storage medium
CN117579512A