A file transfer method, system, electronic device, and storage medium

By using a sliding window mechanism and dynamically updating an ordered sending queue, the problem of network congestion and resource waste caused by data loss during file transfer in POS terminals is solved, achieving efficient and stable file transfer.

CN123123328APending Publication Date: 2026-11-17SHENZHEN XINGUODU TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611092787.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-22
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing file transfer solutions are prone to transmission lag and connection interruption in the mobile network environment of POS terminals due to packet loss. Furthermore, they lack precise error recovery strategies, resulting in wasted bandwidth resources and additional memory and processing resource consumption, leading to low transmission efficiency.

Method used

A sliding window mechanism is used to construct an ordered sending queue of data blocks. Missing data blocks are accurately located and retransmitted through checksums and ACK responses. The sending queue is dynamically updated, and only truly lost data blocks are retransmitted to avoid full retransmission.

Benefits of technology

This technology reduces unnecessary bandwidth consumption and signaling overhead during file transfers on POS terminals, lowers CPU processing resource consumption, and improves transmission efficiency and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123123328A_ABST
    Figure CN123123328A_ABST
Patent Text Reader

Abstract

This application discloses a file transfer method, system, electronic device, and storage medium to improve transfer efficiency. The file transfer method includes: dividing the file to be transferred into blocks to obtain multiple data blocks; constructing an ordered transmission queue of the multiple data blocks based on a preset sliding window mechanism, and sending the multiple data blocks to a POS terminal according to the ordered transmission queue; during the transmission of multiple data blocks to the POS terminal, receiving an ACK response returned by the POS terminal based on a checksum, the ACK response containing an offset list containing information about missing data blocks, which are data blocks that the POS terminal failed to receive; updating the ordered transmission queue according to the missing data blocks and the remaining data blocks to be sent, and continuing to send the missing data blocks and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all data blocks in the ordered transmission queue.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of file transfer technology, and in particular to a file transfer method, system, electronic device and storage medium. Background Technology

[0002] Currently, POS terminals widely rely on file transfer functionality in scenarios such as firmware upgrades, advertising resource downloads, and transaction voucher uploads. Common file transfer solutions mainly fall into three categories: first, a transfer solution based on the standard TCP protocol, which relies on the protocol's built-in acknowledgment and retransmission mechanisms to ensure reliable data delivery; second, a lightweight transfer solution based on the UDP protocol, which reduces transmission latency through a simplified ACK acknowledgment mechanism; and third, a transfer solution based on HTTP chunked upload, which splits the file into multiple independent requests to achieve segmented transmission.

[0003] However, in the actual use environment of POS terminals, due to the characteristics of mobile networks and other weak signal factors, TCP solutions are prone to triggering congestion control due to packet loss, leading to transmission lag or even connection interruption, resulting in a significant increase in transmission time. UDP and HTTP solutions, on the other hand, lack precise error recovery strategies, often resorting to full retransmission or indiscriminate retries to handle data loss. This not only wastes bandwidth resources but also exacerbates network congestion due to excessive retransmission data, while also consuming additional memory and processing resources of the POS terminal. Therefore, the file transfer efficiency of the aforementioned existing solutions is relatively low. Summary of the Invention

[0004] To address the aforementioned technical problems, this application provides a file transfer method, system, electronic device, and storage medium to improve transfer efficiency.

[0005] The technical solution provided in this application is described below:

[0006] The first aspect of this application provides a file transfer method, including: The file to be transmitted is divided into blocks to obtain multiple data blocks, and each data block is appended with a check value. An ordered sending queue of multiple data blocks is constructed based on a preset sliding window mechanism, and multiple data blocks are sent to the POS terminal according to the ordered sending queue. During the process of sending multiple data blocks to the POS terminal, an ACK response is received from the POS terminal based on the check value. The ACK response contains an offset list, which contains information about missing data blocks. The missing data blocks are the data blocks that the POS terminal failed to receive. The ordered transmission queue is updated based on the missing data block and the remaining data blocks to be sent. The missing data block and the remaining data blocks to be sent are then sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all the data blocks in the ordered transmission queue.

[0007] Optionally, updating the ordered transmission queue based on the missing data block and the remaining data blocks to be sent, and continuing to send the missing data block and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue, until the POS terminal successfully receives all the data blocks in the ordered transmission queue, includes: When sending each data block, the reception timeout status of each data block is detected synchronously; If the detection result indicates that the POS terminal has timed out of receiving the data block, then the data block is marked as a timeout retransmission data block; The ordered transmission queue is updated based on the missing data block, the timed-out retransmission data block, and the remaining data blocks to be sent. The missing data block, the timed-out retransmission data block, and the remaining data blocks to be sent are then sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all the data blocks in the ordered transmission queue. The transmission priority of the timed-out retransmission data block is lower than that of the missing data block but higher than that of the remaining data blocks to be sent.

[0008] Optionally, the step of dividing the file to be transmitted into blocks to obtain multiple data blocks includes: Read the total size of the file to be transmitted, and divide the file to be transmitted evenly according to a preset reference block to obtain multiple data blocks; If the last data block after segmentation is smaller than the preset reference block, then the last data block is subjected to boundary alignment processing; Assign a globally unique consecutive sequence number to each data block and record the offset address of each data block in the file to be transmitted, wherein the consecutive sequence numbers are arranged in ascending order; Establish a bidirectional mapping table between the consecutive sequence numbers and the offset addresses; A corresponding checksum is appended to each of the data blocks.

[0009] Optionally, the range of the sliding window under the sliding window mechanism is a preset number of data blocks. The step of constructing an ordered sending queue of multiple data blocks based on the preset sliding window mechanism, and sending multiple data blocks to the POS terminal according to the ordered sending queue, includes: An ordered sending queue is constructed based on the range of the sliding window and the ascending order of the consecutive sequence numbers; According to the ordered sending queue, the preset number of data blocks are sent to the POS terminal via the UDP protocol.

[0010] Optionally, after receiving the ACK response returned by the POS terminal based on the check value, the method further includes: If the integrity verification of the ACK response passes, then the offset address of the missing data block and the total number of missing data blocks in the offset list are parsed. The offset address of the missing data block is converted into a corresponding consecutive sequence number using the bidirectional mapping table.

[0011] Optionally, updating the ordered transmission queue based on the missing data block and the remaining data blocks to be sent includes: If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is greater than the range of the sliding window, then n data blocks are selected from the remaining data blocks to be sent according to the consecutive sequence numbers from smallest to largest, where n = the range of the sliding window - the total number of missing data blocks; The missing data blocks are arranged in the ordered transmission queue in ascending order of their consecutive sequence numbers. The n data blocks are arranged in the ordered transmission queue in ascending order of their consecutive sequence numbers, and the order of the n data blocks is after the missing data block. If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is less than or equal to the range of the sliding window, then the missing data blocks are directly arranged in the ordered sending queue in ascending order of the consecutive sequence numbers; The remaining data blocks to be sent are arranged in the ordered sending queue in ascending order of their consecutive sequence numbers, and the sending order of the remaining data blocks to be sent is after the missing data blocks.

[0012] Optionally, appending a corresponding checksum to each data block includes: The original data of each data block is preprocessed to remove redundancy, and the effective business data segment of each data block is extracted. The preset CRC32 check algorithm is used to calculate the valid service data segment, the consecutive sequence number and the offset address to generate the original check value corresponding to each data block; The original verification value is subjected to lightweight XOR encryption to obtain an encrypted verification value; The encrypted verification value is written into the fixed field of the header of the corresponding data block, and the storage offset and byte length identifier of the encrypted verification value are marked at the end of the corresponding data block.

[0013] A second aspect of this application provides a file transfer system, comprising: The block processing unit is used to divide the file to be transmitted into blocks to obtain multiple data blocks, each of which is appended with a check value. The sending unit is used to construct an ordered sending queue of multiple data blocks based on a preset sliding window mechanism, and send multiple data blocks to the POS terminal according to the ordered sending queue; The receiving unit is configured to receive an ACK response returned by the POS terminal based on the check value during the process of sending multiple data blocks to the POS terminal. The ACK response contains an offset list, which contains information about missing data blocks. The missing data blocks are the data blocks that the POS terminal failed to receive. The update unit is configured to update the ordered transmission queue according to the missing data block and the remaining data blocks to be sent, and continue to send the missing data block and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue, until the POS terminal successfully receives all the data blocks in the ordered transmission queue.

[0014] A third aspect of this application provides an electronic device, the electronic device comprising: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to execute the first aspect and any optional file transfer method of the first aspect.

[0015] A fourth aspect of this application provides a computer-readable storage medium storing a program that, when executed on a computer, performs the file transfer method of the first aspect and any optional method of the first aspect.

[0016] As can be seen from the above technical solutions, this application has the following beneficial effects: This application provides a file transfer method that constructs an ordered sending queue of multiple data blocks using a sliding window mechanism. This locks the memory usage during transmission within the sending range of the ordered sending queue, thereby stabilizing the concurrent traffic in the network within a controllable threshold and avoiding network congestion caused by sudden data injection. Simultaneously, the ordered sending queue ensures that data blocks are sent in a predetermined order, facilitating subsequent missing data detection and queue updates. Upon receiving an ACK response carrying information about missing data blocks, the missing data blocks are merged and rearranged with the remaining unsent data blocks to dynamically generate an updated ordered sending queue. This achieves precise location of data loss and simplifies the transmission state management logic. Only the truly lost data blocks are retransmitted, rather than the entire dataset, significantly reducing unnecessary bandwidth consumption and avoiding the additional signaling overhead and waiting delays caused by separate retransmissions. This reduces the consumption of CPU processing resources and ultimately improves the overall efficiency of file transfer. Attached Figure Description

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

[0018] Figure 1 A schematic flowchart of an embodiment of the file transfer method provided in this application; Figure 2 A schematic flowchart of another embodiment of the file transfer method provided in this application; Figure 3 A schematic flowchart of another embodiment of the file transfer method provided in this application; Figure 4 A schematic flowchart of another embodiment of the file transfer method provided in this application; Figure 5 A schematic flowchart of another embodiment of the file transfer method provided in this application; Figure 6 A schematic flowchart of another embodiment of the file transfer method provided in this application; Figure 7 A schematic flowchart of another embodiment of the file transfer method provided in this application; Figure 8 A schematic diagram of an embodiment of the file transfer system provided in this application; Figure 9 A schematic diagram of an embodiment of the electronic device provided in this application. Detailed Implementation

[0019] This application provides a file transfer method, system, electronic device, and storage medium for improving transfer efficiency.

[0020] It should be noted that the file transfer method provided in this application can be applied to terminals, systems, and servers. For ease of explanation, the following description will focus on the system as the execution subject.

[0021] Please see Figure 1 This application first provides an embodiment of a file transfer method, which includes: Step S101: The file to be transmitted is divided into blocks to obtain multiple data blocks, each of which is appended with a checksum. Step S102: Construct an ordered sending queue of multiple data blocks based on a preset sliding window mechanism, and send multiple data blocks to the POS terminal according to the ordered sending queue; Step S103: During the process of sending multiple data blocks to the POS terminal, receive the ACK response returned by the POS terminal based on the check value. The ACK response contains an offset list, which contains information about missing data blocks. The missing data blocks are the data blocks that the POS terminal failed to receive. Step S104: Update the ordered transmission queue according to the missing data blocks and the remaining data blocks to be sent, and continue to send the missing data blocks and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all data blocks in the ordered transmission queue.

[0022] In step S101 of this embodiment, the system first obtains the total size of the file to be transmitted and determines a reasonable block size based on the available memory capacity of the POS terminal and the reliability requirements of network transmission. For example, in an embedded RTOS environment, to balance memory usage and retransmission granularity, the block size can be fixed at 512KB. By using a modular block method, the large-volume complete file is broken down into multiple independent, uniformly sized small data units, completely avoiding the problems of excessive memory usage, insufficient computing power, and transmission lag caused by loading the entire file at once in the POS terminal, thus adapting to the low-resource operation characteristics of embedded terminals. Through the file block preprocessing method, the large-granular data transmitted in a single transmission is transformed into small-granular data that can be batch-scheduled.

[0023] Next, a checksum is independently calculated for each data block for integrity verification by the POS terminal upon receipt. A unique checksum identifier is generated for each data block, enabling independent verification of the authenticity and integrity of each block. This accurately identifies distortion, missing data, and tampering issues that may occur in any single data block during transmission. After calculating the checksum for each data block, the system binds and appends the generated checksum to its corresponding data block, ensuring that each transmitted data block carries its own independent verification credential. This one-to-one binding and encapsulation of checksums and data blocks enables synchronous transmission of data and checksum information, guaranteeing that the POS terminal can independently verify data integrity block by block, thus ensuring the reliability of individual data blocks from the source of transmission.

[0024] In step S102 of this embodiment, a sliding window transmission mechanism with application-layer autonomous control is adopted. The window capacity is pre-set to rigidly constrain the total amount of currently schedulable and transmittable data blocks, achieving autonomous control over transmission traffic. This embodiment limits the queue data size by limiting the window range, avoiding network congestion and packet accumulation caused by excessive data transmission in weak network environments. Based on the sliding window capacity constraint rules, the transmission order of all data blocks to be transmitted is organized, generating a logically ordered transmission queue. Data blocks within the window are transmitted sequentially according to the preset queue order, achieving stable, efficient, and low-resource-consumption block data transmission.

[0025] In step S103 of this embodiment, the system continuously monitors the response messages from the POS terminal to obtain real-time transmission status feedback information. Abandoning the coarse feedback mode of traditional transmission schemes that only provide simple confirmation commands, the ACK response in this embodiment no longer merely confirms the overall transmission but also includes a structured offset list specifically for finely recording abnormal data information in the current transmission. Thus, the POS terminal accurately records the location information of all failed-to-receive data blocks in the current transmission using the offset list, marking abnormalities based on the offset dimension of the data block in the original file, clearly distinguishing between normally received data blocks and missing data blocks. The aforementioned failure to receive refers to the POS terminal receiving the data block but failing to verify it, thus failing to store the data block normally. This fine-grained feedback mechanism can accurately locate each abnormal data block, avoiding the problem of traditional schemes being unable to accurately trace faulty data.

[0026] In step S104 of the embodiment, after receiving and parsing the offset list of the ACK response, the system integrates two types of data objects to be transmitted: missing data blocks that have failed to be transmitted and remaining new data blocks that have not yet been transmitted locally. Abandoning the traditional fixed-order, unchanging sending queue mode, the system dynamically reconstructs and iteratively updates the ordered sending queue based on the actual transmission failure state and remaining transmission tasks, adapting to the real-time network transmission state. The system continuously executes UDP transmission tasks based on the updated ordered sending queue, looping through the closed-loop process of sending data blocks, receiving ACK feedback, and updating the ordered sending queue, continuously supplementing missing data and sending new data blocks. Through a dynamically adaptive queue update mechanism, the closed-loop iteration of the transmission process is achieved, eliminating the need for full retransmission of file data and continuously advancing the transmission progress until the POS terminal confirms that all data blocks have been successfully received, completing the reliable transmission of the complete file.

[0027] The file transfer method of this application constructs an ordered sending queue of multiple data blocks through a sliding window mechanism, locking the memory usage during transmission within the sending range of the ordered sending queue. This stabilizes the concurrent traffic in the network within a controllable threshold, avoiding network congestion caused by sudden data injection. At the same time, the ordered sending queue ensures that data blocks are sent in a predetermined order, facilitating subsequent missing data detection and queue updates. Upon receiving an ACK response carrying information about missing data blocks, the missing data blocks are merged and rearranged with the remaining data blocks to be sent, dynamically generating an updated ordered sending queue. This achieves precise location of data loss and simplifies the transmission state management logic. Only the truly lost data blocks are retransmitted, rather than the entire data, significantly reducing unnecessary bandwidth consumption and avoiding the additional signaling overhead and waiting delay caused by separate retransmissions. This reduces the consumption of CPU processing resources and ultimately improves the overall efficiency of file transfer.

[0028] Reference Figure 2 According to some embodiments of this application, step S104, which updates the ordered transmission queue based on the missing data blocks and the remaining data blocks to be sent, and continues to send the missing data blocks and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue, until the POS terminal successfully receives all data blocks in the ordered transmission queue, may specifically include, but is not limited to, the following: Step S201: When sending each data block, synchronously detect the reception timeout status of each data block; Step S202: If the detection result indicates that the POS terminal has timed out of receiving the data block, then mark the data block as a timed-out retransmission data block. Step S203: Update the ordered transmission queue according to the missing data blocks, timed-out retransmission data blocks, and remaining data blocks to be sent. Continue to send the missing data blocks, timed-out retransmission data blocks, and remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all data blocks in the ordered transmission queue. The transmission priority of the timed-out retransmission data blocks is lower than the transmission priority of the missing data blocks but higher than the transmission priority of the remaining data blocks to be sent.

[0029] In steps S201 to S203 of the embodiment, an independent parallel timeout monitoring mechanism is established for each sent data block. The monitoring task and the data sending task are executed synchronously and in parallel, without blocking the normal data sending process. The preset fixed timeout judgment threshold can be 3 seconds, which is suitable for the high latency and high jitter transmission scenarios of the mobile network where the POS terminal is located. Whenever the system pushes out a complete data block, it immediately records the accurate sending timestamp of the data block as the benchmark for subsequent timeout judgment. The system adopts a detection mode of independent timing and polling comparison for each block. For data blocks sent at different times within the sliding window, the timing variables are maintained independently, and there will be no situation where the timings of data blocks overlap or interfere with each other. For example, the first data block in the window is sent at 1000ms, the tenth data block is sent at 1800ms, and the 32nd data block is sent at 2600ms. The three data blocks are timed independently, and the time difference between the current system time and the sending time of each data block is compared in real time to realize the real-time capture of timeout abnormal states.

[0030] The system compares the transmission time of each data block with the preset timeout threshold in real time to accurately determine timeout anomalies. If the transmission time difference of any data block exceeds the 3-second threshold, and no ACK confirmation message is received from the POS terminal during this period, the data block is considered to have a transmission anomaly, indicating data packet loss or reverse ACK packet loss. Next, data blocks that have reached the timeout determination are given a dedicated status classification mark. A separate "Timeout Retransmission Data Block" attribute is defined in the local transmission status space, clearly isolating this type of data block from normally transmitted data blocks, missing data blocks with ACK feedback, and remaining data blocks to be sent. This mark is only used to identify timeout-type abnormal data, distinguishing it from missing offset list data blocks explicitly reported as lost by the POS terminal, thus achieving classified management of these two types of abnormal data.

[0031] Subsequently, the ordered transmission queue is reconstructed by integrating the three data dimensions to be transmitted. This involves considering missing data blocks in the offset list actively fed back by the POS terminal, timed-out retransmission data blocks detected locally, and remaining data blocks to be transmitted locally. The queue size is dynamically adapted based on the maximum capacity of the sliding window. For example, with a maximum window capacity of 32 data blocks, if the current offset list indicates 6 missing data blocks, the system detects 2 timed-out retransmission data blocks, and there are 48 remaining data blocks to be transmitted, the system prioritizes including all 8 abnormal data blocks and then adds 24 remaining data blocks to fill the window quota and complete queue initialization. The system strictly follows hierarchical priority scheduling rules to reconstruct the ordered transmission queue, forming a fixed transmission hierarchy order. The priority, from highest to lowest, is: missing data blocks in the offset list, timed-out retransmission data blocks, and remaining data blocks to be transmitted. Continuing with the example above, the 6 missing data blocks are arranged at the front of the queue to prioritize the rapid recovery of accurately known lost data; the 2 timeout retransmission data blocks are arranged in the middle as a backup for abnormal data; and the 24 remaining data blocks to be sent are arranged at the end of the queue to continuously iterate and advance the transmission progress until the POS terminal reports that all data blocks have been received.

[0032] Steps S201 to S203 supplement the original accurate ACK retransmission with a fallback error correction capability for timeout anomalies, solving the technical defects of ACK packet loss and the inability to identify and handle implicit data packet loss. By distinguishing the three-level sending priority of missing data blocks, timeout retransmission data blocks, and remaining non-occurring data blocks, it ensures that missing data blocks that are clearly reported by the POS terminal are repaired first, and also reasonably handles timeout retransmission data blocks without feedback. At the same time, it avoids blindly sending remaining non-occurring data blocks and crowding out retransmission resources. Without additionally occupying the computing power and bandwidth resources of the POS terminal, it significantly improves the fault tolerance and stability of file transmission in weak network environments and effectively reduces the frequency of data retransmission and invalid bandwidth consumption.

[0033] Reference Figure 3 According to some embodiments of this application, step S101, which involves dividing the file to be transmitted into blocks to obtain multiple data blocks, may specifically include, but is not limited to, the following: Step S301: Read the total size of the file to be transmitted, and divide the file to be transmitted evenly according to the preset reference block to obtain multiple data blocks; Step S302: If the last data block after segmentation is smaller than the preset reference block, then perform boundary alignment processing on the last data block. Step S303: Assign a globally unique consecutive sequence number to each data block and record the offset address of each data block in the file to be transmitted. The consecutive sequence numbers are arranged in ascending order. Step S304: Establish a bidirectional mapping table between consecutive sequence numbers and offset addresses; Step S305: Append a corresponding check value to each data block.

[0034] In steps S301 to S305 of the embodiment, when initializing the file transfer task, the total byte size of the firmware file and resource file to be transferred is read first, and uniform block processing is carried out using a preset benchmark block size as a unified segmentation benchmark unit. This preset benchmark block size is adapted to the memory read / write threshold of the POS terminal's embedded hardware, avoiding read / write lag and memory fragmentation problems caused by irregular data blocks, ensuring that each data block has a uniform data volume and consistent transmission overhead, laying a standardized foundation for subsequent sliding window equal-size scheduling and uniform-speed transmission. Specifically, standardized data blocks are generated in batches by performing an integer division operation based on the total file size and the benchmark block size. Taking a POS firmware file with a total size of 2.8MB as an example, 1MB = 1024KB, and 2.8MB totals 2867.2KB. If the preset base block size is 512KB, based on the 512KB single block capacity, it can be completely divided into 5 standard 512KB data blocks, occupying a total of 2560KB of file space. The remaining 307.2KB of file tail data is stored separately, completing the uniform block splitting of the entire file.

[0035] After uniformly dividing the data into blocks, the capacity of each last data block is checked to determine whether its actual data size meets the preset baseline block size. Since the total number of bytes in most files cannot be completely divided by the preset baseline block size, the last data blocks generally have insufficient capacity. Directly transmitting non-standard sized data blocks can lead to problems such as POS terminal parsing errors, window queue sorting errors, and verification matching failures. Therefore, a standardized boundary alignment operation must be performed. For last data blocks that are smaller than the preset baseline block size, blank bytes are used to pad them to the preset baseline block size, achieving uniform data block boundaries.

[0036] For all standardized data blocks that have completed segmentation and alignment, a globally consecutive numerical sequence number is uniformly assigned. The sequence number strictly follows an ascending rule, with no repetition, gaps, or skips. This global sequence number serves as a unique identifier for the data block, used for sliding window sorting, sending queue scheduling, and abnormal data location, achieving ordered and standardized management of all data blocks. Simultaneously, the offset address of each data block in the original file to be transmitted is calculated and recorded block by block, accurately marking the storage location range of each data block. Continuing with the example of a preset base block size of 512KB, sequence number 0 corresponds to the file offset range of 0KB to 512KB, sequence number 1 corresponds to the offset range of 512KB to 1024KB, sequence number 2 corresponds to the offset range of 1024KB to 1536KB, and so on. Each sequence number precisely corresponds to a unique file offset range, achieving precise binding between the data block sequence number and the file location.

[0037] Based on the assigned global sequence number and corresponding file offset address, a structured bidirectional associative mapping relationship is constructed, generating a lightweight local mapping table. Unlike a single unidirectional index record, this bidirectional mapping table supports bidirectional retrieval and querying, breaking the traditional limitation of only being able to find data location by sequence number. This adapts to subsequent error correction scenarios in POS terminals based on offset feedback anomalies and system reverse location of data blocks. Specifically, the consecutive sequence number + start point + end point of the offset address of all data blocks are entered into the bidirectional mapping table in a three-element structured form, and then stored in the terminal's local memory as a lightweight array, consuming extremely low resources and adapting to the low-memory operating environment of POS terminals. In actual operation, users can quickly query the file offset range of the corresponding data block by entering the sequence number, or reverse match the corresponding unique data block sequence number by entering an abnormal offset address, achieving bidirectional second-level location querying with no retrieval delay.

[0038] Next, the system independently calculates a checksum for each data block for integrity verification by the POS terminal upon receiving the data block. Specifically, the system extracts the original valid data (without any additional header information) from the data block and generates a 32-bit checksum using the CRC32 algorithm. The CRC32 algorithm is fast and has a low probability of collision, making it suitable for the limited CPU processing power of the POS terminal. During the calculation process, in addition to the content of the data block itself, the sequence number of the data block and its offset address in the file can be used as auxiliary inputs to participate in the verification operation, thereby enhancing the ability to detect data block misalignment or mismatch. After obtaining the checksum, the system appends the checksum to the corresponding data block in a fixed format. One appending method is to reserve a 4-byte field in the header of the data block to store the CRC32 checksum, and store control information such as the sequence number and offset after the checksum field; another method is to append the checksum to the tail of the data block and use specific flag bits in the header of the data block to indicate the position and length of the checksum. In this way, when the POS terminal receives a data block, it can first extract the checksum from the header information, then recalculate the CRC32 for the data portion, and compare the results to determine whether bit errors or sequence errors have occurred during data transmission. The process of appending the checksum does not change the semantics of the original file data; it is merely part of the transmission protocol.

[0039] Steps S301 to S305, through fixed 512KB base blocks and boundary alignment, unify the size specifications of all transmitted data blocks, completely avoiding transmission scheduling disorder and terminal parsing anomalies caused by irregular data blocks. Simultaneously, through global continuous sequence number encoding and bidirectional mapping table construction, a precise correspondence between data block sequence numbers and file physical locations is established, improving the accuracy and stability of file transmission in weak network environments. Furthermore, the lightweight storage structure does not consume excessive hardware resources in the POS terminal. Further, a checksum is independently generated for each data block and appended to it, enabling the receiving end to perform independent integrity verification of each data block at the application layer. This effectively detects bit errors, data tampering, or sequence errors caused by network interference during transmission, ensuring that only correct data blocks are stored and acknowledged.

[0040] Reference Figure 4 According to some embodiments of this application, the range of the sliding window under the sliding window mechanism is a preset number of data blocks. Step S102, which constructs an ordered sending queue of multiple data blocks based on the preset sliding window mechanism and sends multiple data blocks to the POS terminal according to the ordered sending queue, may specifically include, but is not limited to, the following: Step S401: Construct an ordered sending queue based on the range of the sliding window and the ascending order of the consecutive sequence numbers; Step S402: Send a preset number of data blocks to the POS terminal via UDP protocol according to the ordered sending queue.

[0041] In steps S401 to S402 of the embodiment, the range of a pre-set sliding window is first read to define the upper limit of the number of data blocks to be sent. Then, units that have not yet been sent are selected from all local data blocks to be transmitted. Using the globally consecutive sequence numbers assigned to each data block as a sorting benchmark, the data blocks are ordered according to ascending numerical values ​​to ensure that the data block arrangement logic is consistent with the storage order of the original file. For example, if the preset number is 32 (i.e., the sliding window is set to hold a maximum of 32 data blocks), and data blocks with sequence numbers 0 to 15 have already been transmitted, then this round will select data blocks to be transmitted starting from sequence number 16. Strictly adhering to the upper limit of the window capacity to fill the queue prevents the number of data blocks from exceeding the limit. Simultaneously, the selected data blocks are sequentially entered into the queue storage unit according to the ascending sequence number, forming a linear first-in-first-out queue structure. This queue only records the sequence number and index information corresponding to the data block, rather than copying the complete data content, thereby controlling memory usage. Continuing with the example above, this round sequentially enters 32 data blocks with sequence numbers 16, 17, 18...47 into the queue. The order of elements within the queue completely matches the ascending sequence number arrangement rule, thus completing the construction of the ordered sending queue.

[0042] Next, the connectionless transmission mode of the UDP protocol is enabled for data push. This connectionless transmission mode does not require multiple handshakes to establish a dedicated link with the POS terminal beforehand; it can directly call the communication interface to read data from the queue. Following the basic first-in-first-out (FIFO) rule of the queue, data block indices are extracted one by one starting from the head of the queue. Complete data blocks are retrieved from local storage based on the index, encapsulated into standard UDP packets, and then sent. Continuing the previous example, the data block with sequence number 16 at the head of the queue is retrieved first, encapsulated, and sent. After this data block is transmitted, the next element in the queue is processed, without arbitrarily changing the sending order. During the process of sending data blocks in the queue one by one, the system continuously maintains the normal operation of the communication port, continuously executing packet sending actions until all data blocks in the entire queue corresponding to the current window have been pushed. The entire sending process is logically simple, without temporarily inserting other new data blocks during queue transmission or changing the original queue order. For a queue containing 32 data blocks, the system will sequentially complete the UDP packet sending of all data blocks with sequence numbers 16 to 47. After the sending action is completed, it enters the stage of waiting for the POS terminal to provide an ACK response.

[0043] Steps S401 to S402, on the one hand, limit the amount of data sent concurrently in a single transaction by utilizing window capacity, thus preventing network congestion caused by a surge of packets from the POS terminal in weak network environments. On the other hand, they rely on consecutive sequence number sorting to ensure that the data block transmission order is consistent with the original file, allowing the POS terminal to successfully complete file reassembly and avoid content corruption. Simultaneously, the UDP protocol eliminates redundant logic such as connection handshakes and congestion callbacks, and, coupled with a well-organized queue sending mechanism, effectively reduces the consumption of terminal CPU and network resources.

[0044] Reference Figure 5 According to this application Figure 3 and Figure 4 In the illustrated embodiment, after receiving the ACK response returned by the POS terminal based on the verification value, the relevant content in the ACK response should also be parsed. Specifically, this may include, but is not limited to, the following: Step S501: If the integrity verification of the ACK response passes, then parse the offset address of the missing data block and the total number of missing data blocks in the offset list. Step S502: Convert the offset address of the missing data block into the corresponding consecutive sequence number using a bidirectional mapping table.

[0045] In steps S501 to S502 of the embodiment, after receiving the ACK response message from the POS terminal, a message integrity verification process is first executed to identify whether the message has been damaged, truncated, or tampered with during network transmission. The verification work revolves around protocol-specified fields such as the overall message length and built-in verification identifier. Only when all verification items conform to the preset communication specifications and the current ACK response is confirmed as a valid message will the internal business data of the message be parsed, thus preventing errors in the output status information of abnormal messages from causing deviations in subsequent retransmission scheduling. After confirming that the ACK response is complete and valid, the area in the message that specifically records the offset list of transmission anomalies is located, and the address data stored in the offset list is read line by line. During the reading process, on the one hand, the starting offset address of each failed data block in the original file is extracted separately, and on the other hand, the valid address entries in the list are accumulated and counted, finally calculating the total number of missing data blocks that occurred in this round of transmission.

[0046] After reading, the pre-built bidirectional mapping table between sequence numbers and offset addresses is retrieved locally. Using the offset address parsed by S501 as the retrieval basis, a reverse matching query operation is performed. This mapping table pre-inputs the positional relationship corresponding to each data block, eliminating the need for the terminal to perform real-time byte operations to deduce the data block number. Matching can be completed solely through index retrieval, significantly reducing the computational burden on the embedded POS terminal and adapting to the limited computing resources of the device. Then, the conversion and matching are performed one by one according to the order of the offset address list, converting each file offset address into a globally consecutive sequence number of the data block. For example, the bidirectional mapping table pre-sets a 512KB offset address corresponding to sequence number 1, a 2048KB offset address corresponding to sequence number 4, and a 12800KB offset address corresponding to sequence number 25. After completing the conversion of the three sets of addresses in sequence, a list of sequence numbers of the missing data blocks in this round is obtained, clearly marking the target data block numbers that need to be retransmitted.

[0047] Steps S501 to S502 first filter invalid data through ACK message integrity verification to ensure the basic reliability of subsequent parsing work. Then, the location information and quantity of missing data are accurately extracted. Relying on the bidirectional mapping table, the file offset address is quickly converted to the data block sequence number, realizing the accurate location of abnormal data blocks and solving the problem that traditional solutions cannot quickly lock faulty data.

[0048] Reference Figure 6 According to this application Figures 3 to 5 In the embodiment shown, based on the above, step S104, which updates the ordered transmission queue according to the missing data blocks and the remaining data blocks to be sent, may specifically include, but is not limited to, the following: Step S601: If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is greater than the range of the sliding window, then n data blocks are selected from the remaining data blocks to be sent in ascending order of consecutive sequence numbers, where n = the range of the sliding window - the total number of missing data blocks; Step S602: Arrange the missing data blocks in an ordered transmission queue according to their consecutive sequence numbers in ascending order; Step S603: Arrange the n data blocks in an ordered transmission queue according to their consecutive sequence numbers in ascending order, and ensure that the order of the n data blocks is after the missing data block. Step S604: If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is less than or equal to the range of the sliding window, then the missing data blocks are directly arranged in the ordered sending queue in ascending order of their consecutive sequence numbers. Step S605: Arrange the remaining data blocks to be sent in an ordered sending queue according to the consecutive sequence number from smallest to largest, and send the remaining data blocks after the missing data blocks.

[0049] In steps S601 to S605 of the embodiment, the total number of missing data blocks that need to be retransmitted and the total number of remaining data blocks to be sent are first counted. Then, the two values ​​are added together and compared with the maximum capacity of the sliding window. In this scheme, the range of the sliding window can be set to 32 data blocks. The purpose of this judgment logic is to strictly adhere to the upper limit of the window capacity, prevent the number of data blocks in a single queue from exceeding the limit, and thus avoid network congestion caused by the concentrated transmission of a large number of packets in a short period of time, while also matching the memory allocation rules of the POS terminal queue management. When the total number of the two types of data exceeds the sliding window capacity, the system starts the data truncation calculation logic, using the formula n = sliding window range. The total number of missing data blocks determines the number of remaining data blocks to be sent. For example, if there are currently 5 missing data blocks and 40 remaining data blocks to be sent, the sum is 45, which is significantly greater than the window limit of 32. Calculation shows n = 32 - 5 = 27. The system then selects the first 27 data blocks from the 40 remaining data blocks to be sent, following the rule of global consecutive sequence numbers from smallest to largest.

[0050] For all the missing data blocks identified in the previous step, an ascending sort operation is performed based on the global consecutive sequence number carried by each missing data block. Since the sequence number of each data block corresponds one-to-one with the storage location of the original file, sorting by sequence number from smallest to largest ensures that the order of the retransmitted data remains consistent with the original file data layout. This effectively avoids content corruption and fragment misalignment issues during file reconstruction by the POS terminal, ensuring the integrity of the file structure. Referring to the previous example, the sequence numbers corresponding to the missing data blocks that need to be retransmitted this time are 2, 7, 11, 18, and 22. The system sorts them according to the rule of ascending values, ultimately forming a sequence of missing data blocks in the order of 2, 7, 11, 18, and 22. This ordered data is then written sequentially into an ordered transmission queue. At this point, the queue only contains the sorted missing data blocks, serving as the initial component of the transmission queue for this round.

[0051] After all missing data blocks are enqueued, the system sorts and enqueues the previously selected n remaining data blocks to be sent. This embodiment clearly defines the data transmission priority; retransmitted missing data blocks have a higher priority than remaining data blocks to be sent. Therefore, all remaining data blocks to be sent are arranged after the missing data blocks to prioritize the retransmission progress of lost data blocks and prevent the continuous transmission of remaining data blocks from causing the missing data blocks to be unable to be retransmitted for an extended period. Continuing with the previous calculations, 27 remaining data blocks to be sent are selected. These data blocks are also sorted according to their global consecutive sequence numbers from smallest to largest, and then appended to the end of the existing queue. At this point, the queue contains 5 missing data blocks and 27 remaining data blocks to be sent, totaling 32 data blocks, which exactly fills the sliding window's capacity limit. The overall queue structure is complete and the order is standardized, allowing direct entry into the data transmission phase.

[0052] When the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is less than or equal to the maximum capacity of the sliding window, there is no need to truncate the remaining data blocks. This scenario mostly occurs in the later stages of file transfer, where the size of the remaining data to be sent is small, and the capacity of the sliding window is sufficient to accommodate all abnormal and new data. Therefore, all data to be transmitted can be fully included, simplifying the queue construction process. For example, if the sliding window capacity is still 32 data blocks, and there are currently 3 missing data blocks and 12 remaining data blocks to be sent, the total number of these two types of data is 15, which does not exceed the window limit. All 3 missing data blocks are directly retrieved and sorted according to their global consecutive sequence numbers from smallest to largest. For example, if the sequence numbers of the missing data blocks are 5, 9, and 14, the sorted data forms a fixed sequence, preparing for the next enqueue operation. For all remaining data blocks to be sent, the ascending sequence number rule is continued to be used to organize them, ensuring that the sending order of the remaining data blocks is consistent with the original file order. The entire sorting logic is consistent throughout and will not change due to different stages of transmission. For example, three missing data blocks (5, 9, and 14) are already at the front of the queue, and the 12 remaining data blocks to be sent correspond to sequence numbers 25 to 36. The system arranges these 12 data blocks sequentially after the missing data blocks. The final queue contains a total of 15 data blocks, far less than the window capacity limit of 32. Once the queue is constructed, the data sending process can begin in the predetermined order.

[0053] Steps S601 to S605 strictly adhere to the capacity limit of the sliding window, ensuring precise control over the size of data blocks sent in a single transmission regardless of whether the data volume is large in the middle of the transmission or small at the end, thus avoiding congestion caused by excessive packets in a weak network environment from the source. On the other hand, they consistently adhere to the scheduling rule of prioritizing the retransmission of missing data blocks, combined with the unified sorting of consecutive sequence numbers. This not only enables rapid retransmission of lost data blocks but also ensures that the transmission order of all data blocks is consistent with the original file, facilitating normal file reassembly by the POS terminal.

[0054] Reference Figure 7 According to this application Figure 3 In the illustrated embodiment, based on the above, the step S101 of attaching a corresponding check value to each data block may specifically include, but is not limited to, the following: Step S701: Perform redundancy removal preprocessing on the original data of each data block and extract the valid business data segment of each data block. Step S702: The preset CRC32 check algorithm is used to calculate the valid service data segment, consecutive sequence number and offset address to generate the original check value corresponding to each data block. Step S703: Perform lightweight XOR encryption on the original verification value to obtain the encrypted verification value; Step S704: Write the encrypted verification value into the fixed field of the header of the corresponding data block, and mark the storage offset and byte length identifier of the encrypted verification value at the end of the corresponding data block.

[0055] In steps S701 to S704 of the embodiment, after completing file segmentation and boundary alignment, the entire data block is not directly used for verification calculation. Instead, redundant data identification and cleanup are performed on individual blocks of original data. Firmware, advertising resources, transaction vouchers, and other files transmitted by the POS terminal may contain redundant content such as format reservation bits, boundary padding bytes, and invalid placeholder characters after segmentation and alignment. Using this type of data for verification calculation will only increase terminal computing power consumption and prolong calculation time; therefore, redundancy identification needs to be completed first. According to the pre-agreed data format specifications between the sending and receiving ends, the entire data block is traversed byte by byte to distinguish between the actual business content and various types of invalid redundant data. After identifying all redundant content, only the portion carrying core information is divided and extracted from the original data to form an independent, valid business data segment. This preprocessing only performs logical area division and does not delete any bytes within the original data block. The overall data block maintains a standard size of 512KB to ensure the uniformity of subsequent UDP encapsulation and queue scheduling formats.

[0056] Next, the CRC32 cyclic redundancy check algorithm is used for integrity verification. Instead of verifying the business data separately, three types of core information are combined as input to the algorithm: the extracted valid business data segment, the unique continuous sequence number of the data block, and the absolute offset address of the data block in the original file. This multi-dimensional information joint verification method can detect whether the data content itself has been tampered with or lost, and can also identify anomalies such as disordered data block sequence numbers and incorrect file position matching, thus compensating for the shortcomings of single data verification. Furthermore, the CRC32 algorithm has fewer computational steps, adapting to the limited computing power of embedded devices in POS terminals. Following preset concatenation rules, the valid business data, sequence number, and offset address are sequentially integrated into a continuous computational data stream, which is then fed into the CRC32 algorithm module for iterative computation, ultimately generating a fixed 32-bit binary value, which is the original checksum of the corresponding data block. Each data block completes the computation independently; different combinations of content, sequence number, and offset will generate differentiated verification results, enabling accurate verification of single data blocks.

[0057] The original checksum obtained after CRC32 operation is a publicly available standard format value. If transmitted directly with data blocks, it is at risk of being illegally read or maliciously tampered with in complex mobile network environments, leading to distorted POS terminal verification results and inaccurate data status determination. Therefore, this embodiment employs a lightweight bitwise XOR encryption method to perform secondary processing on the original checksum. This encryption logic only performs basic bitwise operations, resulting in simple code implementation, minimal hardware resource consumption, and no computational burden from complex encryption algorithms, perfectly suited to the operating characteristics of POS terminals. A fixed key is pre-stored locally on the device as a globally unified computational benchmark; all data block checksums are encrypted using this key. The XOR operation follows the basic rule of "outputting 0 if the corresponding bit values ​​are the same, and outputting 1 if the corresponding bit values ​​are different." The system compares the 32-bit original checksum with the 32-bit fixed key bit by bit, generating a new 32-bit value—the encrypted checksum—after the operation.

[0058] During the overall data block format planning phase, the sending and receiving ends pre-agree on the field layout of the standard data block. A dedicated storage area with a fixed location and byte length is allocated at the header of each 512KB data block specifically for storing the encrypted verification value. After writing the header fields, the reserved identifier area at the tail of the data block is located, and two key parameters are marked sequentially: the starting storage offset of the encrypted verification value within the current data block and the actual byte length occupied by the encrypted verification value.

[0059] Steps S701 to S704 effectively reduce the amount of data computation in the verification process and lower the CPU resource consumption of the POS terminal by removing invalid data through redundancy preprocessing; multi-dimensional anomaly detection is achieved by using valid data, serial number, offset address and CRC32 verification, which improves the ability to distinguish the authenticity and integrity of data; lightweight encryption is achieved by bitwise XOR, which prevents the verification information from being maliciously tampered with without increasing the burden on the device; finally, the standardized design of fixed field storage in the header and parameter labeling in the tail ensures accurate reading, writing and parsing of the verification information at both ends of the transmission and reception.

[0060] The above embodiments illustrate the file transfer method provided in this application. The file transfer system, electronic device, and storage medium provided in this application are described below: Please see Figure 8 This application provides an embodiment of a file transfer system, the system comprising: The block processing unit 801 is used to perform block processing on the file to be transmitted to obtain multiple data blocks, each data block having an appended check value. The sending unit 802 is used to construct an ordered sending queue of multiple data blocks based on a preset sliding window mechanism, and send multiple data blocks to the POS terminal according to the ordered sending queue; The receiving unit 803 is used to receive an ACK response returned by the POS terminal based on a check value during the process of sending multiple data blocks to the POS terminal. The ACK response contains an offset list, which contains information about missing data blocks. The missing data blocks are data blocks that the POS terminal failed to receive. The update unit 804 is used to update the ordered transmission queue according to the missing data blocks and the remaining data blocks to be sent, and to continue sending the missing data blocks and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue, until the POS terminal successfully receives all data blocks in the ordered transmission queue.

[0061] Optionally, update unit 804 is specifically used for: When sending each data block, the receive timeout status of each data block is checked synchronously; If the detection result indicates that the POS terminal has timed out of receiving the data block, then the data block will be marked as a timed-out retransmission data block. The ordered transmission queue is updated based on the missing data blocks, timed-out retransmission data blocks, and remaining data blocks to be sent. The missing data blocks, timed-out retransmission data blocks, and remaining data blocks to be sent are then sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all data blocks in the ordered transmission queue. The transmission priority of timed-out retransmission data blocks is lower than that of missing data blocks but higher than that of remaining data blocks to be sent.

[0062] Optionally, the block processing unit 801 is specifically used for: Read the total size of the file to be transferred, and divide the file into multiple data blocks according to a preset base block. If the last data block after segmentation is smaller than the preset reference block, then the last data block is subjected to boundary alignment processing; Assign a globally unique consecutive sequence number to each data block and record the offset address of each data block in the file to be transmitted. The consecutive sequence numbers are arranged in ascending order. Establish a bidirectional mapping table between consecutive sequence numbers and offset addresses; Attach a corresponding checksum to each data block.

[0063] Optionally, the sliding window in the sliding window mechanism has a range of a preset number of data blocks, and the sending unit 802 is specifically used for: Construct an ordered sending queue based on the range of the sliding window and the ascending order of the consecutive sequence numbers; A preset number of data blocks are sent to the POS terminal via the UDP protocol according to an ordered sending queue.

[0064] Optionally, after the receiving unit 803, the following may also be included: The parsing unit 805 is used to parse the offset address of the missing data block and the total number of missing data blocks in the offset list if the integrity verification of the ACK response passes. The conversion unit 806 is used to convert the offset address of the missing data block into the corresponding consecutive sequence number through a bidirectional mapping table.

[0065] Optionally, update unit 804 is specifically used for: If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is greater than the range of the sliding window, then n data blocks are selected from the remaining data blocks to be sent in ascending order of their consecutive sequence numbers, where n = the range of the sliding window - the total number of missing data blocks; The missing data blocks are arranged in an ordered transmission queue in ascending order of their consecutive sequence numbers. Arrange n data blocks in an ordered transmission queue in ascending order of their consecutive sequence numbers, and ensure that the order of the n data blocks is after the missing data block. If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is less than or equal to the range of the sliding window, then the missing data blocks are directly arranged in the ordered sending queue in ascending order of their consecutive sequence numbers. The remaining data blocks to be sent are arranged in an ordered sending queue in ascending order of their consecutive sequence numbers, and the sending order of the remaining data blocks to be sent is after the missing data blocks.

[0066] Optionally, the block processing unit 801 is specifically used for: The raw data of each data block is preprocessed to remove redundancy, and the valid business data segments of each data block are extracted. The preset CRC32 check algorithm is used to calculate the valid business data segment, consecutive sequence number and offset address to generate the original check value corresponding to each data block; The original verification value is subjected to lightweight XOR encryption to obtain the encrypted verification value. Write the encrypted verification value into a fixed field at the header of the corresponding data block, and mark the storage offset and byte length of the encrypted verification value at the tail of the corresponding data block.

[0067] Please see Figure 9 This application also provides an electronic device, including: Processor 901, memory 902, input / output unit 903, bus 904; The processor 901 is connected to the memory 902, the input / output unit 903, and the bus 904; The memory 902 stores a program, and the processor 901 calls the program to execute it, such as... Figures 1 to 7The file transfer method shown in any of the embodiments.

[0068] This application also relates to a computer-readable storage medium on which a program is stored, which, when run on a computer, causes the computer to perform actions such as... Figures 1 to 7 The file transfer method shown in any of the embodiments.

[0069] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0070] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.

[0071] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0072] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0073] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A file transfer method, characterized in that, The file transfer method includes: The file to be transmitted is divided into blocks to obtain multiple data blocks, and each data block is appended with a check value. An ordered sending queue of multiple data blocks is constructed based on a preset sliding window mechanism, and multiple data blocks are sent to the POS terminal according to the ordered sending queue. During the process of sending multiple data blocks to the POS terminal, an ACK response is received from the POS terminal based on the check value. The ACK response contains an offset list, which contains information about missing data blocks. The missing data blocks are the data blocks that the POS terminal failed to receive. The ordered transmission queue is updated based on the missing data block and the remaining data blocks to be sent. The missing data block and the remaining data blocks to be sent are then sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all the data blocks in the ordered transmission queue.

2. The file transfer method according to claim 1, characterized in that, The step of updating the ordered transmission queue based on the missing data block and the remaining data blocks to be sent, and continuing to send the missing data block and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue, until the POS terminal successfully receives all the data blocks in the ordered transmission queue, includes: When sending each data block, the reception timeout status of each data block is detected synchronously; If the detection result indicates that the POS terminal has timed out of receiving the data block, then the data block is marked as a timeout retransmission data block; The ordered transmission queue is updated based on the missing data block, the timed-out retransmission data block, and the remaining data blocks to be sent. The missing data block, the timed-out retransmission data block, and the remaining data blocks to be sent are then sent to the POS terminal according to the updated ordered transmission queue until the POS terminal successfully receives all the data blocks in the ordered transmission queue. The transmission priority of the timed-out retransmission data block is lower than that of the missing data block but higher than that of the remaining data blocks to be sent.

3. The file transfer method according to claim 1, characterized in that, The file to be transmitted is divided into blocks to obtain multiple data blocks, including: Read the total size of the file to be transmitted, and divide the file to be transmitted evenly according to a preset reference block to obtain multiple data blocks; If the last data block after segmentation is smaller than the preset reference block, then the last data block is subjected to boundary alignment processing; Assign a globally unique consecutive sequence number to each data block and record the offset address of each data block in the file to be transmitted, wherein the consecutive sequence numbers are arranged in ascending order; Establish a bidirectional mapping table between the consecutive sequence numbers and the offset addresses; A corresponding checksum is appended to each of the data blocks.

4. The file transfer method according to claim 3, characterized in that, The sliding window mechanism described above has a range of a preset number of data blocks. The process of constructing an ordered sending queue of multiple data blocks based on the preset sliding window mechanism, and sending multiple data blocks to the POS terminal according to the ordered sending queue, includes: An ordered sending queue is constructed based on the range of the sliding window and the ascending order of the consecutive sequence numbers; According to the ordered sending queue, the preset number of data blocks are sent to the POS terminal via the UDP protocol.

5. The file transfer method according to claim 4, characterized in that, After receiving the ACK response returned by the POS terminal based on the verification value, the method further includes: If the integrity verification of the ACK response passes, then the offset address of the missing data block and the total number of missing data blocks in the offset list are parsed. The offset address of the missing data block is converted into a corresponding consecutive sequence number using the bidirectional mapping table.

6. The file transfer method according to claim 5, characterized in that, The step of updating the ordered transmission queue based on the missing data block and the remaining data blocks to be sent includes: If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is greater than the range of the sliding window, then n data blocks are selected from the remaining data blocks to be sent according to the consecutive sequence numbers from smallest to largest, where n = the range of the sliding window - the total number of missing data blocks; The missing data blocks are arranged in the ordered transmission queue in ascending order of their consecutive sequence numbers. The n data blocks are arranged in the ordered transmission queue in ascending order of their consecutive sequence numbers, and the order of the n data blocks is after the missing data block. If the sum of the total number of missing data blocks and the total number of remaining data blocks to be sent is less than or equal to the range of the sliding window, then the missing data blocks are directly arranged in the ordered sending queue in ascending order of the consecutive sequence numbers; The remaining data blocks to be sent are arranged in the ordered sending queue in ascending order of their consecutive sequence numbers, and the sending order of the remaining data blocks to be sent is after the missing data blocks.

7. The file transfer method according to claim 3, characterized in that, The step of appending a corresponding checksum to each data block includes: The original data of each data block is preprocessed to remove redundancy, and the effective business data segment of each data block is extracted. The preset CRC32 check algorithm is used to calculate the valid service data segment, the consecutive sequence number and the offset address to generate the original check value corresponding to each data block; The original verification value is subjected to lightweight XOR encryption to obtain an encrypted verification value; The encrypted verification value is written into the fixed field of the header of the corresponding data block, and the storage offset and byte length identifier of the encrypted verification value are marked at the end of the corresponding data block.

8. A file transfer system, characterized in that, The system includes: The block processing unit is used to divide the file to be transmitted into blocks to obtain multiple data blocks, each of which is appended with a check value. The sending unit is used to construct an ordered sending queue of multiple data blocks based on a preset sliding window mechanism, and send multiple data blocks to the POS terminal according to the ordered sending queue; The receiving unit is configured to receive an ACK response returned by the POS terminal based on the check value during the process of sending multiple data blocks to the POS terminal. The ACK response contains an offset list, which contains information about missing data blocks. The missing data blocks are the data blocks that the POS terminal failed to receive. The update unit is configured to update the ordered transmission queue according to the missing data block and the remaining data blocks to be sent, and continue to send the missing data block and the remaining data blocks to be sent to the POS terminal according to the updated ordered transmission queue, until the POS terminal successfully receives all the data blocks in the ordered transmission queue.

9. An electronic device, characterized in that, The electronic device includes: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to execute the file transfer method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains a program that, when executed on a computer, performs the file transfer method as described in any one of claims 1 to 7.