Data transmission control method and system
By judging packet continuity at the receiving end and updating the frame ID and packet ID, the problem of errors and loss in image data transmission is solved, and efficient retransmission of image data is achieved, which is suitable for hardware-type receivers.
Patent Information
- Application Number
- CN202411901995.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-11
AI Technical Summary
In the process of image data transmission, the prior art causes errors in the image data, abnormal packet integrity and loss of image data during image data transmission, and the hardware-type receiver cannot meet the requirements of large-capacity cache and complex logical operations.
A data transmission control method and system are proposed, which can realize the retransmission of image data by judging whether the current data packet is continuous with the previous data packet, update the valid frame ID and the valid packet ID, and set a retransmission instruction based on the comparison results of the frame ID and packet ID to realize the retransmission of image data.
This method can realize effective retransmission of image data without requiring large-capacity cache space and complex logical operations, reduce the requirements for the hardware receiver, and improve the reliability and efficiency of image data transmission.
Smart Images

Figure CN119814235A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing, and in particular relates to a data transmission control method and system. Background Art
[0002] During the transmission of image data, due to external electromagnetic interference, bending of transmission cables and degradation of signal quality, the image data received by the processor (i.e., the receiving end for receiving image data) may have problems such as bit errors and abnormal data packet integrity, resulting in image data loss.
[0003] In the case of image data loss or discontinuous data packets, the existing processor stores all successfully received data packets in the cache array during the image data retransmission process, and does not need to retransmit the received data packets again to avoid wasting the transmission bus bandwidth. However, the above transmission process requires additional maintenance of the receiving status of each data packet, and complex logic is used to determine which data packets need to be retransmitted and how to aggregate the retransmission instructions.
[0004] It can be seen that the retransmission processing of image data in the prior art requires a large-capacity cache space and relatively complex logical operations to be realized. However, for some hardware-type receiving ends (for example, image acquisition cards), they often do not have a large-capacity cache space and cannot implement complex logical operations, and cannot meet the requirements of the above retransmission processing.
[0005] Therefore, a data transmission control solution is urgently needed to solve the above problems. Summary of the invention
[0006] The present application proposes a data transmission control method and system for use at a hardware-type receiving end to implement retransmission of image data.
[0007] To achieve the above objectives, this application proposes the following technical solutions: In a first aspect of the present application, a data transmission control method is provided, which is applied to a receiving end receiving image data, and the data transmission control method includes: Determine whether the current data packet is continuous with the previous data packet; wherein the current data packet represents the latest data packet currently received by the receiving end; If so, update the valid frame ID and valid packet ID to the current frame ID and current packet ID respectively, and continue to receive the next data packet; wherein the frame ID represents the serial number of the image frame to which the data packet belongs; the packet ID represents the serial number of the data packet within the data range corresponding to a frame of image; the valid frame ID represents the frame ID of the continuous data packet last received by the receiving end; the valid packet ID represents the packet ID of the continuous data packet last received by the receiving end; the current frame ID represents the frame ID of the current data packet; the current packet ID represents the packet ID of the current data packet; If not, discard the current data packet and do not update the valid frame ID and valid packet ID, and set the frame ID, the start packet ID and the end packet ID in the retransmission instruction according to the comparison result between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, and send the retransmission instruction to the sending end of the image data; Among them, when the missing data packet between the current data packet and the previous data packet cannot be retrieved using the retransmission instruction, and the current data packet is a frame header packet, the valid frame ID and valid packet ID are directly updated to the current frame ID and current packet ID respectively, and the next data packet is continued to be received.
[0008] Optionally, before determining whether the current data packet is continuous with the previous data packet, the data transmission control method further includes: Get the first data packet in the process of image data transmission; Determine whether the frame ID of the first data packet is the same as the preset initial frame ID, and whether the packet ID is a frame header packet; if both are the same, initialize the valid frame ID and valid packet ID to the frame ID and packet ID of the first data packet; if not, discard the first data packet and receive the next data packet as the first data packet.
[0009] Optionally, determining whether the current data packet is continuous with the previous data packet includes: Determine whether the current frame ID is the same as the valid frame ID; If yes, then continue to determine whether the current packet ID and the valid packet ID are increasing; if yes, then the two are continuous; if no, then the two are not continuous; If not, determine whether the current frame ID and the valid frame ID are increasing; if not, the two are not continuous; if so, continue to determine whether the current packet ID belongs to the frame header packet and whether the valid packet ID belongs to the frame tail packet; if both are, the two are continuous; if not, the two are not continuous.
[0010] Optionally, determining the frame ID, the start packet ID, and the end packet ID in the retransmission instruction according to the comparison result between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, includes: Compare the current frame ID with the valid frame ID; If it is less than, the current data packet is discarded, no retransmission instruction is sent to the sending end, and the image data is continued to be received; If they are equal, continue to compare the size of the current packet ID and the valid packet ID; if the current packet ID is equal to or less than the valid packet ID, discard the current data packet, do not send a retransmission instruction to the sender, and continue to receive image data; if the current packet ID is greater than the valid packet ID, set the frame ID in the retransmission instruction to the current frame ID, the starting packet ID to the valid packet ID plus one, and the ending packet ID to the current packet ID plus a first preset value O; wherein the ending packet does not exceed the maximum sequence number of the packet ID; the first preset value is not less than the total amount of data packets transmitted by the sender within a preset time period; the preset time period represents the time period from the issuance of the retransmission instruction to the sender to the start of retransmitting data packets at the sender.
[0011] Optionally, after comparing the current frame ID with the valid frame ID, the data transmission control method further includes: If the current frame ID is greater than the valid frame ID, continue to compare the size between the frame ID difference and the preset second preset value H; wherein the frame ID difference represents the difference between the current frame ID and the valid frame ID, and H is represented by an integer greater than 1; If the frame ID difference is greater than the second preset value H, continue to determine whether the current packet ID is a frame header packet; If yes, no retransmission instruction is set, and the valid frame ID and valid packet ID are updated to the current frame ID and packet ID respectively, and the next data packet is received; If not, the frame ID in the retransmission instruction is set to the current frame ID, the start packet ID is set to the frame header packet, and the end packet ID is set to the current packet ID plus the first preset value O.
[0012] Optionally, if the frame ID difference is 1, the data transmission control method further includes: Discard the current data packet, and set the frame ID, the start packet ID and the end packet ID in the transmission instruction according to a preset valid frame complete flag; The valid frame complete flag is used to indicate whether the data packet corresponding to the valid packet ID is a frame tail packet within a frame of image data; If the valid frame complete flag indicates a frame tail packet, the frame ID in the retransmission instruction is set to the current frame ID, the start packet ID is set to the frame header packet, and the end packet ID is set to the current packet ID plus the first preset value 0; If the valid frame integrity flag does not indicate a frame tail packet, the frame ID in the retransmission instruction is set to the valid frame ID, the start packet ID is the valid packet ID plus one, and the end packet ID is the maximum packet ID; the maximum packet ID represents the maximum sequence number of the packet ID in the image data corresponding to a frame of image.
[0013] Optionally, if the frame ID difference is greater than 1 and less than H, the data transmission control method further includes: The current data packet is discarded, and it is determined whether the preset valid frame complete flag indicates that the valid packet ID is a frame tail packet; if so, the frame ID in the retransmission instruction is set to the current frame ID plus one, the starting packet ID is the frame header packet, and the ending packet ID is the maximum packet ID; if not, the frame ID in the retransmission instruction is set to the valid frame ID, the starting packet ID is the valid packet ID plus one, and the ending packet ID is the maximum packet ID.
[0014] Optionally, the data transmission control method further includes: In the process of acquiring image data, it is determined whether the total amount of image data cached in the buffer in the receiving end exceeds a preset first threshold value A; if so, a first flow control instruction is sent to the sending end so that the sending end pauses the sending of image data within a preset time length T; wherein the first flow control instruction indicates a pause instruction including the time length T; Monitoring the total amount of the image data within the preset time length T, and if the total amount of the image data still exceeds the preset first threshold value A before the time length T ends, sending the first flow control instruction to the sending end again to refresh the pause time of the sending end; If the total amount of image data is lower than a preset second threshold B before the end of the time length T, a second flow control instruction is sent to the sending end to enable the sending end to directly send the image data again; wherein, B≤A, the second flow control instruction represents an instruction for restarting the sending end.
[0015] Optionally, after sending the first flow control instruction to the sending end, the data transmission control method further includes: The total amount of image data received by the buffer in the receiving end is monitored, and when the total amount of image data is higher than a preset third threshold C, the receiving end directly discards the subsequently received image data; wherein C>A.
[0016] In a second aspect of the present application, a data transmission control system is provided, the data transmission control system comprising: A sending end, used to send image data to a receiving end; The receiving end is used to determine whether the current data packet is continuous with the previous data packet; wherein the current data packet refers to the data packet currently received by the receiving end; If so, update the valid frame ID and valid packet ID to the current frame ID and packet ID respectively, and continue to receive the next data packet; wherein the frame ID represents the serial number of the image frame to which the data packet belongs; the packet ID represents the serial number of the data packet within the data range corresponding to a frame of image; the valid frame ID represents the frame ID of the continuous data packet last received by the receiving end; the valid packet ID represents the packet ID of the continuous data packet last received by the receiving end; the current frame ID represents the frame ID of the current data packet; the current packet ID represents the packet ID of the current data packet; If not, discard the current data packet and do not update the valid frame ID and valid packet ID, and set the frame ID, the start packet ID and the end packet ID in the retransmission instruction according to the comparison result between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, and send the retransmission instruction to the sending end of the image data; Among them, when the missing data packet between the current data packet and the previous data packet cannot be retrieved using the retransmission instruction, and the current data packet is a frame header packet, the valid frame ID and valid packet ID are directly updated to the current frame ID and current packet ID respectively, and the next data packet is continued to be received.
[0017] The beneficial effects of this application are as follows: The present application provides a data transmission control method, which is applied to a receiving end for receiving image data, and the data transmission control method includes: determining whether the current data packet is continuous with the previous data packet; if so, updating the valid frame ID and valid packet ID to be the current frame ID and packet ID respectively, and continuing to receive the next data packet; if not, discarding the current data packet without updating the valid frame ID and valid packet ID, and setting the frame ID, starting packet ID and ending packet ID in the retransmission instruction according to the comparison results between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, and sending the retransmission instruction to the sending end of the image data. Among them, when the missing data packet between the current data packet and the previous data packet cannot be retrieved using the retransmission instruction, and the current data packet is a frame header packet, the valid frame ID and valid packet ID are directly updated to be the current frame ID and current packet ID respectively, and continuing to receive the next data packet.
[0018] Based on the above processing, the present application can determine whether the image data is retransmitted only by detecting the continuity of a single data packet, without the need for complex logical operations. At the same time, the present application continuously updates the valid frame ID and valid packet ID to ensure that the valid frame ID and valid packet ID correspond to the latest continuous data packet received by the receiving end.
[0019] Furthermore, in the present application, the current data packet that does not meet the requirements is discarded, and there is no need to store it in the cache array, which reduces the requirement for cache space and can be directly applied to the hardware type receiving end. In addition, based on the comparison results of the frame ID and packet ID between the current data packet and the latest known continuous data packet, the frame ID, the start packet ID and the end packet ID in the retransmission instruction can be obtained, which reduces the complexity of the logical operation in the process of generating the retransmission instruction, and there is no need to maintain the arrival status of all data packets in one frame or even multiple frames, which is more suitable for hardware types with simple operation logic. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 It is a flow chart of a data transmission control method provided by the present application; Figure 2 is a flow chart of another data transmission control method provided by the present application; Figure 3 This is a module structure diagram of an image acquisition card provided by this application. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments.
[0022] In the prior art, the retransmission processing of image data often requires a large-capacity cache space and relatively complex logical operations. However, for some hardware-type receiving ends (for example, image acquisition cards), they often do not have a large-capacity cache space and cannot implement complex logical operations, and cannot meet the requirements of the above retransmission processing.
[0023] In order to solve the above problems, the present application proposes a data transmission control method, which is applied to a receiving end receiving image data, such as Figure 1 As shown, the data transmission control method includes the following steps: S1. Determine whether the current data packet is continuous with the previous data packet. If so, go to S2; if not, go to S3.
[0024] The current data packet refers to the latest data packet currently received by the receiving end, that is, the latest received data packet.
[0025] S2. Update the valid frame ID and valid packet ID to the current frame ID and current packet ID respectively, and continue to receive the next data packet.
[0026] Wherein, the frame ID represents the serial number of the image frame to which the data packet belongs, the packet ID represents the serial number of the data packet within the data range corresponding to a frame of the image; the valid frame ID represents the frame ID of the continuous data packet last received by the receiving end; the valid packet ID represents the packet ID of the continuous data packet last received by the receiving end; the current frame ID represents the frame ID of the current data packet; the current packet ID represents the packet ID of the current data packet; S3. Discard the current data packet and do not update the valid frame ID and valid packet ID, and set the frame ID, start packet ID and end packet ID in the retransmission instruction according to the comparison results between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, and send the retransmission instruction to the sending end of the image data.
[0027] Among them, when the missing data packet between the current data packet and the previous data packet cannot be retrieved using the retransmission instruction, and the current data packet is a frame header packet, the valid frame ID and valid packet ID are directly updated to the current frame ID and current packet ID respectively, and the next data packet is continued to be received.
[0028] Based on the above processing, the present application can determine whether the image data is retransmitted only by detecting the continuity of a single data packet, without the need for complex logical operations. At the same time, the present application continuously updates the valid frame ID and valid packet ID to ensure that the valid frame ID and valid packet ID correspond to the latest continuous data packet received by the receiving end.
[0029] Furthermore, in the present application, the current data packet that does not meet the requirements is discarded, and does not need to be stored in the cache array, which reduces the requirements for cache space and is easy to apply to the hardware type receiving end. In addition, based on the comparison results of the frame ID and packet ID between the current data packet and the latest known continuous data packet, the frame ID, the start packet ID and the end packet ID in the retransmission instruction can be obtained, which reduces the complexity of the logical operation in the process of generating the retransmission instruction, and is more suitable for hardware types with simple operation logic.
[0030] The sending end of image data refers to an electronic device that can send image data, such as a camera, scanner, etc. The receiving end that receives image data refers to an electronic device that can be used to receive image data, such as an image acquisition card, FPGA, etc. Taking the machine vision scenario as an example, the sending end can be an industrial camera and the receiving end can be an image acquisition card.
[0031] In one implementation, the image data sent by the transmitter includes a frame ID and a packet ID, and the first and last data packets of the data packets corresponding to each frame of the image are special packets, respectively represented as a frame header packet and a frame tail packet, which are used to mark the start and end of a frame of image data. Among them, the image data of a frame of image includes at least two data packets, namely a frame header packet and a frame tail packet. In addition, the retransmission instruction generated by the receiving end represents an instruction for controlling the sending end to resend certain data packets. In this application, image data cannot be retransmitted across frames, and the retransmission instruction includes the frame ID required for retransmission, the start packet ID of the retransmission, and the end packet ID.
[0032] With respect to step S1, by comparing the differences in frame ID and packet ID between the current data packet and the previous data packet, it can be determined whether the current data packet is continuous with the previous data packet.
[0033] Referring to the change rule of the ID identifier during the data packet transmission process, it can be known that within the image data of the same frame image, the packet ID starts from the packet ID corresponding to the frame header packet and increases continuously. Among them, the packet ID of the frame header packet is usually 0 or 1. In this application, the frame header packet is 0 as an example for explanation. When the receiving end receives the frame tail packet of the previous frame image, the next data packet should be the frame ID plus one (that is, it is understood as the value corresponding to the frame ID plus the value one).
[0034] Since the valid frame ID and valid packet ID are continuously updated to the latest continuous data packet, in the data transmission control scheme provided by the present application, the valid frame ID and valid packet ID correspond to the frame ID and packet ID of the previous data packet. In some embodiments, step S1 includes the following steps: S101, determine whether the current data packet is the same as the valid frame ID; if so, go to step S102; if not, go to step S103.
[0035] S102, continue to determine whether the sequence numbers of the current data packet and the valid packet ID are increasing; if so, the two are continuous; if not, the two are not continuous.
[0036] S103, determine whether the current data packet and the valid frame ID are incremented by one; if not, the two are discontinuous; if so, continue to determine whether the current packet ID is a frame header packet and whether the valid packet ID belongs to a frame tail packet; if so, the two are continuous; if not, the two are discontinuous.
[0037] When it is determined that the current data packet is discontinuous, it means that the receiving end has lost the data packet. At this time, the receiving end needs to generate a retransmission instruction to re-receive the lost data packet.
[0038] When the receiving end starts the data receiving state, it will inevitably receive the first data packet. In one implementation, the receiving end directly uses the first received data packet as the initial valid state, and uses the frame ID and packet ID of the first data packet as the valid frame ID and valid packet ID respectively.
[0039] In another implementation, the initial valid state of the receiving end is limited in advance, and the frame ID must be 0 or 1 (that is, the preset initial frame ID) and the packet ID of the frame header packet is 0, otherwise it is determined that the data packet is lost. Among them, the preset initial frame ID is usually 0 or 1, and 0 is used as an example for explanation in this application.
[0040] In some embodiments, the data transmission control method further includes the following steps: S4. Obtain the first data packet in the image data transmission process.
[0041] S5. Determine whether the frame ID of the first data packet is the same as the preset initial frame ID, and whether the packet ID is a frame header packet; if both are the same, initialize the valid frame ID and valid packet ID to the frame ID and packet ID of the first data packet; if not, discard the first data packet and receive the next data packet as the first data packet.
[0042] Among them, in step S5, after the first data packet is discarded, the next data packet is received again as the first data packet, and step S5 is repeated until the first data packet is the same as the preset initial frame ID, and the packet ID is a frame header packet.
[0043] When the first data packet in step S5 is the same as the preset initial frame ID and the packet ID is a frame header packet, the frame ID and packet ID of the first data packet are used as the first valid frame ID and the first packet ID in this image data transmission process.
[0044] A valid frame complete flag is set in the receiving end to indicate whether the received continuous data packets are frame tail packets. Specifically, the valid frame complete flag may include two states, low level and high level, to indicate whether the received continuous data packets are frame tail packets. When the latest data packet received by the receiving end is a frame header packet, the valid frame complete flag is set to a low level state, and the low level state is maintained during the process of receiving subsequent data packets until the continuous data packets received are frame tail packets, at which time the valid frame complete flag is set to a high level state. It should be noted that when the frame header packet of the next frame is received, the valid frame complete flag is set to a high level state again and continues to be maintained. Similarly, a frame tail packet can also be represented by a low level state, and a non-frame tail packet can be represented by a high level state.
[0045] After the receiving end receives the first data packet, it will judge whether the latest data packet (i.e., the current data packet) meets the continuity condition with the previous data packet according to the valid frame ID and valid packet ID according to the judgment content of step S1. For the data packet that meets the condition, it will go to step S2, that is, parse the data of the data packet as a valid data stream, update the valid frame ID and valid packet ID to the frame ID and packet ID of this data packet, and continue to receive the next data packet.
[0046] In some embodiments, in step S3, according to the comparison result between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, determining the frame ID, the start packet ID and the end packet ID in the retransmission instruction includes the following steps: S301, compare the current frame ID with the valid frame ID. If it is smaller, go to step S302; if it is equal, go to step S303; if it is larger, go to step S304.
[0047] S302: discard the current data packet, do not send a retransmission instruction to the sending end, and continue to receive image data.
[0048] S303, compare the current packet ID with the valid packet ID. If they are equal or less than, discard the current data packet, do not send a retransmission instruction to the sender, and continue to receive image data; if they are greater than, set the frame ID in the retransmission instruction to the current frame ID, the start packet ID to the valid packet ID plus one, and the end packet ID to the current packet ID plus a first preset value O. The end packet does not exceed the maximum sequence number of the packet ID; O represents a preset first preset value, and the first preset value is not less than the total amount of data packets transmitted by the sender within a preset time period; the preset time period represents the time period from the issuance of the retransmission instruction to the sender to the start of retransmission of data packets by the sender.
[0049] S304: If the current frame ID is greater than the valid frame ID, continue to compare the frame ID difference with a preset second preset value H. The frame ID difference represents the difference between the current frame ID and the valid frame ID.
[0050] For step S301, "less than" means that the current frame ID is less than the valid frame ID, and the same is true for "greater than". When the current data packet received is a discontinuous packet (i.e., not continuous with the previous data packet), if the current frame ID is less than the valid frame ID, it means that the current data packet is a data packet that has been received by the receiving end, i.e., an invalid old packet. In this case, it is directly discarded without modifying the valid frame ID and the valid packet ID. Similarly, when the current frame ID is equal to the valid frame ID, and the current packet ID is less than / equal to the valid packet ID, the current data packet is also an invalid old packet, and the processing process is as above.
[0051] For step S303, when the current data packet is a non-continuous packet and is not an invalid old packet, the retransmitted data is located at the frame ID of the current latest continuous data packet by setting the frame ID in the retransmission instruction to the current frame ID, and the starting packet ID is set to the valid packet ID plus one, thereby ensuring that the starting end of the retransmitted data is incrementally continuous with the original latest continuous data packet, preventing the existence of invalid old packets or omissions in the retransmitted data.
[0052] Furthermore, the end packet is set to the current packet ID plus a first preset value O, and O is not less than the total number of data packets transmitted by the sending end from the time the retransmission instruction is sent to the sending end to the time the sending end responds to the retransmission instruction and starts sending retransmission data packets according to the retransmission instruction. After the data is retransmitted, the missing data packets can be avoided as much as possible between the data sent again by the sending end and the last retransmitted data, thereby improving the accuracy of data retransmission.
[0053] In some embodiments, step S304 includes the following: S30401. If the frame ID difference is greater than the second preset value H, continue to determine whether the current packet ID is a frame header packet; if so, go to step S30402; if not, go to step S30403, where H represents an integer greater than 1.
[0054] S30402: Do not set a retransmission instruction, and update the valid frame ID and valid packet ID to the current frame ID and packet ID respectively, and continue to receive the next data packet.
[0055] S30403. Set the frame ID in the retransmission instruction to the current frame ID, the start packet ID to the frame header packet, and the end packet ID to the current packet ID plus the first preset value O.
[0056] For step S304, the preset second preset value H represents the image frame number difference corresponding to when the receiving end cannot retrieve the image data. In step S30401, when the current frame ID is greater than the valid frame ID by more than H, it means that between the latest data packet received by the receiving end and the last continuous data packet, due to transmission anomalies and other reasons, more data frames have been lost, and the lost image frames have been removed from the cache of the sending end device and cannot be retrieved.
[0057] Further, for step S30401, the data transmission control scheme provided by the present application determines that the lost image data cannot be retransmitted, and therefore no longer attempts to retrieve the lost data frame, but sets the receiving end to directly re-parse the data from the currently received data frame. At the same time, the receiving end generates a frame loss signal to record the image frame that cannot be retrieved during the image data transmission process, and uses the value obtained by "current frame ID-valid frame ID-1" as the count accumulation value of the lost image frame.
[0058] In addition, if the data packet in the last valid frame before the frame loss is incomplete, the present application outputs a frame incomplete flag, and as long as an incomplete data packet occurs, the present solution generates a packet discontinuity flag. Based on the setting of the above multiple flags, the user can monitor the transmission status of the image data.
[0059] For step S30402, when the current data packet is a frame header packet, the valid frame ID and valid packet ID are directly updated to the current frame ID and packet ID, and the content of the current data packet is parsed. Its data is transmitted to the back end as a valid data stream of a new frame to ensure the normal transmission of image data, so as to avoid sending invalid retransmission instructions and improve the efficiency of image transmission.
[0060] For step S30403, if the current data packet is not a frame header packet, the content of this data packet is not parsed, that is, the data packet is discarded, and a new retransmission instruction is generated. Among them, the retransmission instruction frame ID is set to the current frame ID, the retransmission instruction start packet ID is set to 0 (that is, the frame header packet), and the end packet ID is set to the current packet ID + 0. Based on the setting of the above retransmission instruction, the lost data in the image frame corresponding to the current data packet can be retrieved to ensure that each frame of the image received by the receiving end keeps the frame start boundary aligned.
[0061] In addition, for the end packet ID, for the end packet ID calculated based on the current packet ID+O, a level of judgment can be added to the data transmission control scheme provided by the present application. That is, if the calculated end packet ID exceeds the maximum possible packet ID of a preset frame of image data, it is forcibly set to the preset maximum packet ID. Or according to certain transmission protocols, the end packet can be set to all F, which is used to indicate that during the data retransmission process, it is directly retransmitted to the frame tail packet corresponding to the frame image. Among them, the maximum packet ID represents the maximum sequence number of the packet ID in the image data corresponding to a frame of image.
[0062] In some embodiments, step S304 further includes the following: S30404: If the frame ID difference is 1, set the frame ID, start packet ID and end packet ID in the transmission instruction according to a preset valid frame complete flag, wherein the valid frame complete flag is used to indicate whether the data packet is a frame tail packet in a frame of image data.
[0063] Step S30404 includes the following two steps: Step a: If the valid frame complete flag indicates a frame tail packet, set the frame ID in the retransmission instruction to the current frame ID, the start packet ID to the frame header packet, and the end packet ID to the current packet ID plus a first preset value O.
[0064] Step b: If the valid frame complete flag does not indicate a frame tail packet, the frame ID in the retransmission instruction is set to the valid frame ID, the start packet ID is set to the valid packet ID plus one, and the end packet ID is set to the maximum packet ID.
[0065] Based on the processing of steps a and b above, the valid frame complete flag is used to identify whether the valid packet ID is the frame tail packet, and different starting packet IDs are set in the retransmission instruction accordingly, ensuring that the starting packet in the retransmission data corresponding to the retransmission instruction is continuously incremented with the latest continuous data packet received by the receiving end, avoiding the existence of invalid old packets in the retransmission data, reducing the retransmission time, and improving the efficiency of image data retransmission.
[0066] At the same time, considering that the data transmission control scheme provided by the present application is applied to a hardware-type receiving end, by using the valid frame complete flag to identify whether the valid packet ID is a frame tail packet, compared with directly using the valid packet ID to identify whether it belongs to the frame tail packet, the comparison between the numerical values is converted into a judgment between high and low levels, which reduces the complexity of the logical operation process, making the present scheme more suitable for the hardware end and improving the efficiency of the image data retransmission process. In addition, if the logical operation capability allows, the data transmission control scheme provided by the present application can also directly identify whether it belongs to the frame tail packet through the valid packet ID.
[0067] In actual work, if the current data packet is a non-continuous packet and the current frame ID is equal to the valid frame ID+1, the current data packet is discarded and the valid frame complete flag is judged.
[0068] If the valid frame complete flag is high, the current packet ID must not be 0 (otherwise it is a continuous packet). Set the frame ID in the retransmission instruction to the current frame ID, the start packet ID to 0, and the end packet ID to the current packet ID + 0.
[0069] If the valid frame complete flag is low, the frame ID in the retransmission instruction is set to the valid frame ID, the starting packet ID is the valid packet ID+1, and the ending packet ID is the preset maximum packet ID (or it can also be set to all Fs).
[0070] In some embodiments, step S304 further includes the following: S30405. If the frame ID difference is greater than 1 and less than H, the current data packet is discarded, and a determination is made as to whether the preset valid frame complete flag indicates that the valid packet ID is a frame tail packet; if so, the frame ID in the retransmission instruction is set to the current frame ID plus one, the starting packet ID is the frame header packet, and the ending packet ID is the maximum packet ID; if not, the frame ID in the retransmission instruction is set to the valid frame ID, the starting packet ID is the valid packet ID plus one, and the ending packet ID is the maximum packet ID.
[0071] Similarly, according to the above settings, the valid frame complete flag is used to identify whether the valid packet ID is a frame tail packet, and a different starting packet ID is set in the retransmission instruction accordingly, thereby avoiding the existence of invalid old packets in the retransmitted data.
[0072] In actual operation, when the current data packet is a non-continuous packet, if the current frame ID is greater than the valid frame ID + 1, but less than the valid frame ID + H, it is determined that cross-frame packet loss has occurred at the receiving end, but the number of lost image frames is not large and can be recovered through retransmission. At this time, the current data packet is discarded and it is determined whether the valid frame complete flag is high.
[0073] If it is high, the frame ID in the retransmission instruction is set to the valid frame ID+1, the starting packet ID is 0, and the ending packet ID is the preset maximum packet ID, or is set to all Fs.
[0074] If it is low, the frame ID in the retransmission instruction is set to the valid frame ID, the starting packet ID is the valid packet ID+1, and the ending packet ID is the preset maximum packet ID, or is set to all Fs.
[0075] Reference Figure 2 , Figure 2 This is the overall flow chart of the data transmission control method provided in this application. Figure 2 The non-continuous packet refers to the current data packet that is not continuous with the previous data packet in this application.
[0076] In addition, a retransmission instruction module is usually provided in the receiving end, which is used to generate a retransmission instruction and send the retransmission instruction to the sending end of the image data. After the retransmission instruction module sends the retransmission instruction, it enters the retransmission waiting state and starts timing. The retransmission timeout time TO is preset, and the number of times a single retransmission instruction is sent is preset. When the timing reaches TO, and the number of times the retransmission instruction has been sent does not reach R, the retransmission instruction module is controlled to send the retransmission instruction again, and the timing is reset to zero and restarted.
[0077] When the timing reaches TO and the number of retransmission instructions sent reaches R, the retransmission is considered to have failed and the retransmission waiting state is exited; when valid continuous data packets are received again during the timing period, the lost data packets are considered to have been successfully retransmitted and the retransmission waiting state is exited.
[0078] Furthermore, during the waiting period for the execution of the retransmission instruction, no new retransmission instruction is issued, and unless continuous data packets are received, other data packets are discarded.
[0079] In some scenarios, both the frame ID and the packet ID have bit width restrictions, and there is a possibility of ID looping. At the same time, in some transmission protocols, 0 needs to be skipped when the frame ID or packet ID loops. In view of the above situation, when calculating the frame ID interval, if it is determined that a loop has occurred, 1 should be additionally subtracted from the original calculated interval.
[0080] In addition, due to the loopback characteristic, it is impossible to effectively compare the sizes between the current frame ID and the valid frame ID in step S301. At this time, it can be set that when the current frame ID - valid frame ID ≥ G (G > H), it means that the current packet ID is smaller than the valid frame ID. When the newly received current frame ID - valid frame ID < G and > 0, it means that the current frame ID is larger than the valid frame ID. In addition, the calculation of the packet ID is the same. Among them, the value G represents a preset value. For example, when the bit width of the frame ID is 16 bits, G can be set to 16’hF800, indicating that when the current frame ID is 0x800 smaller than the valid frame ID, the current data packet is considered an invalid old packet, otherwise it is considered a new packet larger than the valid frame ID.
[0081] As Figure 3 shown, when the image acquisition card (i.e., the receiving end) receives image data from the device end (i.e., the image acquisition device or the sending end), it unpacks according to the transmission protocol. According to the above data transmission control scheme, data packets with continuous frame IDs and packet IDs are recognized as reasonable data packets, and the valid data stream is parsed and written into the stream data FIFO. The data in the stream data FIFO will be output to the subsequent stage. For example, it is written into the computer end memory through the PCIe bus DMA.
[0082] To ensure the continuous transmission of the entire data stream, it is necessary to make the average bandwidth of the backend data output greater than the average bandwidth of the frontend valid data stream. However, due to factors such as multi-channel arbitration (a single acquisition card contains multiple above-mentioned process architectures, which are respectively used to connect multiple devices, and the backend output shares a single interface), output bus jitter, and CPU stuttering, its instantaneous bandwidth may fluctuate, and the output bandwidth may be less than the frontend data stream bandwidth during the fluctuation. At this time, data will accumulate in the stream data FIFO.
[0083] To avoid data loss and prevent the stream data FIFO from overflowing, the data transmission control scheme provided in this application also provides the following flow control steps, including the following content: S6. During the process of acquiring image data, determine whether the total amount of image data received by the buffer in the receiving end exceeds a preset first threshold A; if so, send a first flow control instruction to the sending end to cause the sending end to pause the sending of image data within a preset time length T.
[0084] S7. Monitor the total amount of image data within the preset time length T. If the total amount of image data still exceeds the preset first threshold A before the end of the time length T, send the first flow control instruction to the sending end again to refresh the pause time of the sending end. Among them, the first flow control instruction represents a pause instruction including the time length T.
[0085] S8. If the total amount of the image data is lower than the preset second threshold B before the time length T ends, send a second flow control instruction to the sending end so that the sending end directly sends the image data again. The second flow control instruction is an instruction for the sending end to restart.
[0086] In one implementation, the flow control step further includes the following: S9. If the sending end cannot receive or execute the flow control instruction, the total amount of image data received by the buffer in the receiving end is monitored. When the total amount of image data is higher than a preset third threshold C, the receiving end discards the subsequently received image data.
[0087] In actual work, Figure 3 As shown, when the amount of data in the stream data FIFO is detected to exceed the first threshold value A, the control flow control instruction module sends a flow control instruction to the device end (i.e., the image acquisition device or the sending end), suspends the device end from continuing to upload image data, and stops the data flow from the source. Among them, the flow control instruction contains a pause time T. After receiving this instruction, the device end will suspend data transmission according to the instruction time, and resume transmission after waiting for the pause time.
[0088] Based on the above processing, by adding a pause time T in the flow control instruction, there is no need to issue an instruction for canceling the pause instruction again, which reduces the bandwidth occupied during data transmission and can effectively avoid the risk of loss of the instruction for canceling the pause instruction, thereby ensuring that the data flow can be restored normally.
[0089] After the image acquisition card sends the first-stream control instruction, it also maintains a timer. When there is a certain margin S before the issued pause time, it monitors whether the data volume of the stream data FIFO still exceeds the threshold A. If so, it sends another first-stream control instruction to refresh the pause time of the device.
[0090] When it is detected that the amount of data in the stream data FIFO does not exceed the threshold value B (B≤A), it is determined whether the device is still in a paused state according to the timing state of the stream control instruction module. If so, a second stream control instruction is issued to cancel the paused state of the device and restart the image data transmission. In general, B is less than A, and the difference between B and A is adjusted according to the transmission speed of the image data. The faster the transmission speed, the greater the difference.
[0091] In the above flow control step, by setting two thresholds A and B with different values, compared with using a single threshold to judge the issuance and suspension of pause instructions, this scheme can set a buffer between the two states of pause and cancel pause, avoiding repeated switching of the pause state on the device side, and the difference between B and A is adjusted according to the transmission speed of the image data, that is, the length of the buffer area is adjusted according to the transmission speed. On the basis of reducing the number of times the pause instruction is issued, the bandwidth occupancy in the image data transmission and the processing pressure of the instructions in the sending end are reduced, and the stability and smoothness of the image data transmission are further improved.
[0092] In addition, due to the reasons that the device side or the protocol used does not support the flow control instruction, avoid the loss of the flow control instruction, and the device side has a slow response speed and the cache space margin is limited after exceeding the threshold A, the device side continues to upload image data after the flow control instruction is issued. When the data volume of the stream data FIFO is detected to exceed the third threshold C, the control data receiving module enters the packet loss state, and the valid data of the received data packet is no longer written to the stream data FIFO, but directly discarded to avoid overflow after the stream data FIFO is written. Among them, C>A and C≤D, D is represented by the capacity of the stream data FIFO D M-the maximum valid data volume P contained in a single data packet.
[0093] Based on the above processing, the data transmission control solution provided in this application can be applied to XGV acquisition cards, and is adaptable to various image transmission buses that support flow control and retransmission, and can realize flow control and retransmission of the transmission bus without the need for large-capacity off-chip cache.
[0094] When the image acquisition card sends a command to the device, the command needs to include a command ID, and each command ID is unique and incremented (the ID can be repeated after a loop). By including the ID in the command reply, the command and the command reply can be matched one by one to avoid omissions. When the command or command reply is abnormally lost, the image acquisition card resends the command and keeps the same command ID. The device recognizes the command with the same command ID and ignores it, which can avoid repeated processing.
[0095] However, in actual work, in addition to retransmission instructions and flow control instructions, the image acquisition card also needs to send other control instructions to the device end, and other control instructions are generally generated by the computer end. According to the transmission protocol, in addition to instruction retransmission, each control instruction should have a unique incremental instruction ID. Since there are multiple instruction modules, which may be scattered in the image acquisition card and the computer, the technical solution provided by this application adds an instruction ID distribution module in the receiving end to distribute the unique instruction ID.
[0096] When the image acquisition card and each instruction module in the computer are preparing to issue a new instruction that is not retransmitted, they first send a request instruction to the instruction ID distribution module. However, the instruction ID distribution module returns a unique instruction ID to the request source module and increments the instruction ID inside the instruction ID distribution module. The specific situation is as follows: When only one module sends a request instruction at the same time, the instruction distribution module sends the latest instruction ID back to the request source module and increases the internal latest instruction ID by 1.
[0097] When N modules send requests at the same time, the instruction distribution module sends the latest instruction ID currently stored back to module 1 of the request source, sends the latest instruction ID+1 back to module 2 of the request source, sends the latest instruction ID+N-1 back to module N of the request source, and accumulates the latest internal instruction ID by N. Wherein, N represents an integer greater than 1.
[0098] In addition, the instruction ID distribution module provided in the present application also has a reset function, which is used to reset the latest instruction ID to 0 or 1 when disconnecting, resetting or establishing a new device connection.
[0099] In some embodiments, the present application further provides a data transmission control system, including: A sending end, used to send image data to a receiving end; The receiving end is used to determine whether the current data packet is continuous with the previous data packet; wherein the current data packet refers to the data packet currently received by the receiving end; If so, update the valid frame ID and valid packet ID to the current frame ID and packet ID respectively, and continue to receive the next data packet; the frame ID represents the serial number of the image frame to which the data packet belongs, and the packet ID represents the serial number of the data packet within the data range corresponding to a frame of image; the valid frame ID represents If not, the current data packet is discarded and the valid frame ID and valid packet ID are not updated. Based on the comparison results between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, the frame ID, start packet ID and end packet ID in the retransmission instruction are set, and the retransmission instruction is sent to the sending end of the image data.
[0100] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned data transmission control methods are implemented.
[0101] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the steps of any of the data transmission control methods in the above embodiments.
[0102] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A data transmission control method, characterized in that: Applied to a receiving end receiving image data, the data transmission control method comprises: Determine whether the current data packet is continuous with the previous data packet; wherein the current data packet represents the latest data packet currently received by the receiving end; If so, update the valid frame ID and valid packet ID to the current frame ID and current packet ID respectively, and continue to receive the next data packet; wherein the frame ID represents the serial number of the image frame to which the data packet belongs; the packet ID represents the serial number of the data packet within the data range corresponding to a frame of image; the valid frame ID represents the frame ID of the continuous data packet last received by the receiving end; the valid packet ID represents the packet ID of the continuous data packet last received by the receiving end; the current frame ID represents the frame ID of the current data packet; the current packet ID represents the packet ID of the current data packet; If not, discard the current data packet and do not update the valid frame ID and valid packet ID, and set the frame ID, the start packet ID and the end packet ID in the retransmission instruction according to the comparison result between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, and send the retransmission instruction to the sending end of the image data; Among them, when the missing data packet between the current data packet and the previous data packet cannot be retrieved using the retransmission instruction, and the current data packet is a frame header packet, the valid frame ID and valid packet ID are directly updated to the current frame ID and current packet ID respectively, and the next data packet is continued to be received.
2. The data transmission control method according to claim 1, characterized in that: Before determining whether the current data packet is continuous with the previous data packet, the data transmission control method further includes: Get the first data packet in the process of image data transmission; Determine whether the frame ID of the first data packet is the same as the preset initial frame ID, and whether the packet ID is a frame header packet; if both are the same, initialize the valid frame ID and valid packet ID to the frame ID and packet ID of the first data packet; if not, discard the first data packet and receive the next data packet as the first data packet.
3. The data transmission control method according to claim 2, characterized in that: The determining whether the current data packet is continuous with the previous data packet comprises: Determine whether the current frame ID is the same as the valid frame ID; If yes, then continue to determine whether the current packet ID and the valid packet ID are increasing; if yes, then the two are continuous; if no, then the two are not continuous; If not, determine whether the current frame ID and the valid frame ID are increasing; if not, the two are not continuous; if so, continue to determine whether the current packet ID belongs to the frame header packet and whether the valid packet ID belongs to the frame tail packet; if both are, the two are continuous; if not, the two are not continuous.
4. The data transmission control method according to claim 1, characterized in that: Determining the frame ID, the start packet ID and the end packet ID in the retransmission instruction according to the comparison result between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, includes: Compare the current frame ID with the valid frame ID; If it is less than, the current data packet is discarded, no retransmission instruction is sent to the sending end, and the image data is continued to be received; If they are equal, continue to compare the size of the current packet ID and the valid packet ID; if the current packet ID is equal to or less than the valid packet ID, discard the current data packet, do not send a retransmission instruction to the sender, and continue to receive image data; if the current packet ID is greater than the valid packet ID, set the frame ID in the retransmission instruction to the current frame ID, the starting packet ID to the valid packet ID plus one, and the ending packet ID to the current packet ID plus a first preset value O; wherein the ending packet does not exceed the maximum sequence number of the packet ID; the first preset value is not less than the total amount of data packets transmitted by the sender within a preset time period; the preset time period represents the time period from the issuance of the retransmission instruction to the sender to the start of retransmitting data packets at the sender.
5. The data transmission control method according to claim 4, characterized in that: After comparing the current frame ID with the valid frame ID, the data transmission control method further includes: If the current frame ID is greater than the valid frame ID, continue to compare the size between the frame ID difference and the preset second preset value H; wherein the frame ID difference represents the difference between the current frame ID and the valid frame ID, and H is represented by an integer greater than 1; If the frame ID difference is greater than the second preset value H, continue to determine whether the current packet ID is a frame header packet; If yes, no retransmission instruction is set, and the valid frame ID and valid packet ID are updated to the current frame ID and packet ID respectively, and the next data packet is received; If not, the frame ID in the retransmission instruction is set to the current frame ID, the start packet ID is set to the frame header packet, and the end packet ID is set to the current packet ID plus the first preset value O.
6. The data transmission control method according to claim 5, characterized in that: If the frame ID difference is 1, the data transmission control method further includes: Discard the current data packet, and set the frame ID, the start packet ID and the end packet ID in the transmission instruction according to a preset valid frame complete flag; The valid frame complete flag is used to indicate whether the data packet corresponding to the valid packet ID is a frame tail packet within a frame of image data; If the valid frame complete flag indicates a frame tail packet, the frame ID in the retransmission instruction is set to the current frame ID, the start packet ID is set to the frame header packet, and the end packet ID is set to the current packet ID plus the first preset value 0; If the valid frame integrity flag does not indicate a frame tail packet, the frame ID in the retransmission instruction is set to the valid frame ID, the start packet ID is the valid packet ID plus one, and the end packet ID is the maximum packet ID; the maximum packet ID represents the maximum sequence number of the packet ID in the image data corresponding to a frame of image.
7. The data transmission control method according to claim 5, characterized in that: If the frame ID difference is greater than 1 and less than H, the data transmission control method further includes: The current data packet is discarded, and it is determined whether the preset valid frame complete flag indicates that the valid packet ID is a frame tail packet; if so, the frame ID in the retransmission instruction is set to the current frame ID plus one, the starting packet ID is the frame header packet, and the ending packet ID is the maximum packet ID; if not, the frame ID in the retransmission instruction is set to the valid frame ID, the starting packet ID is the valid packet ID plus one, and the ending packet ID is the maximum packet ID.
8. The data transmission control method according to claim 1, characterized in that: The data transmission control method further includes: In the process of acquiring image data, it is determined whether the total amount of image data cached in the buffer in the receiving end exceeds a preset first threshold value A; if so, a first flow control instruction is sent to the sending end so that the sending end pauses the sending of image data within a preset time length T; wherein the first flow control instruction indicates a pause instruction including the time length T; Monitoring the total amount of the image data within the preset time length T, and if the total amount of the image data still exceeds the preset first threshold value A before the time length T ends, sending the first flow control instruction to the sending end again to refresh the pause time of the sending end; If the total amount of image data is lower than a preset second threshold B before the end of the time length T, a second flow control instruction is sent to the sending end to enable the sending end to directly send the image data again; wherein, B≤A, the second flow control instruction represents an instruction for restarting the sending end.
9. The data transmission control method according to claim 8, characterized in that: After sending the first flow control instruction to the sending end, the data transmission control method further includes: The total amount of image data received by the buffer in the receiving end is monitored, and when the total amount of image data is higher than a preset third threshold C, the receiving end directly discards the subsequently received image data; wherein C>A.
10. A data transmission control system, characterized in that: The data transmission control system comprises: A sending end, used to send image data to a receiving end; The receiving end is used to determine whether the current data packet is continuous with the previous data packet; wherein the current data packet refers to the data packet currently received by the receiving end; If so, update the valid frame ID and valid packet ID to the current frame ID and packet ID respectively, and continue to receive the next data packet; wherein the frame ID represents the serial number of the image frame to which the data packet belongs; the packet ID represents the serial number of the data packet within the data range corresponding to a frame of image; the valid frame ID represents the frame ID of the continuous data packet last received by the receiving end; the valid packet ID represents the packet ID of the continuous data packet last received by the receiving end; the current frame ID represents the frame ID of the current data packet; the current packet ID represents the packet ID of the current data packet; If not, discard the current data packet and do not update the valid frame ID and valid packet ID, and set the frame ID, the start packet ID and the end packet ID in the retransmission instruction according to the comparison result between the current frame ID and the valid frame ID, and between the current packet ID and the valid packet ID, and send the retransmission instruction to the sending end of the image data; Among them, when the missing data packet between the current data packet and the previous data packet cannot be retrieved using the retransmission instruction, and the current data packet is a frame header packet, the valid frame ID and valid packet ID are directly updated to the current frame ID and current packet ID respectively, and the next data packet is continued to be received.