CN113972962B - Buffer management method and related device - Google Patents

Buffer management method and related device Download PDF

Info

Publication number
CN113972962B
CN113972962B CN202110832128.4A CN202110832128A CN113972962B CN 113972962 B CN113972962 B CN 113972962B CN 202110832128 A CN202110832128 A CN 202110832128A CN 113972962 B CN113972962 B CN 113972962B
Authority
CN
China
Prior art keywords
buffer
terminal
data
rate
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110832128.4A
Other languages
Chinese (zh)
Other versions
CN113972962A (en
Inventor
王皓
张志军
胡征
许辰人
姚松平
郭兴民
李锋
顾燕杰
杨卓卿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Peking University
Huawei Technologies Co Ltd
Original Assignee
Peking University
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Peking University, Huawei Technologies Co Ltd filed Critical Peking University
Priority to PCT/CN2021/108275 priority Critical patent/WO2022022429A1/en
Publication of CN113972962A publication Critical patent/CN113972962A/en
Application granted granted Critical
Publication of CN113972962B publication Critical patent/CN113972962B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0015Systems modifying transmission characteristics according to link quality, e.g. power backoff characterised by the adaptation strategy
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/16Threshold monitoring
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]

Abstract

The application discloses a buffer area management method and a related device. The terminal can adjust the size of the first buffer area according to the buffered data, the available memory, the network card receiving rate, the disk writing rate, the available memory and the frequency of receiving the user interactive operation of the first buffer area. Therefore, the overflow probability of the buffer area in the terminal during high-speed file data transmission can be reduced, and the packet loss rate is reduced.

Description

Buffer management method and related device
The present application claims priority of chinese patent applications, including chinese patent office, application number 202010726657.1, application name "a buffer management method and related apparatus", filed on 25/07/2020, chinese patent office, application number 202010726671.1, application name "a data transmission method and related apparatus", filed on 25/07/2020, chinese patent office, application number 202010726638.9, application name "a data storage method and related apparatus", filed on 27/07/2020, chinese patent office, application number 202010734674.x, application name "a data prefetching method and related apparatus", which are filed on 25/07/25/2020, and the entire contents of which are incorporated herein by reference.
Technical Field
The present application relates to the field of communications technologies, and in particular, to a buffer management method and a related apparatus.
Background
With the development of mobile terminal technology and the diversification of mobile terminal functions, a mobile terminal can receive file data transmitted by other mobile terminals or a server.
With the development of mobile terminal technology and the diversification of mobile terminal functions, the mobile terminal can transmit files with other mobile terminals so as to meet the requirement of a user on file sharing (such as photos, audios and videos).
Currently, a mobile terminal may transmit file data to an opposite terminal based on a Transmission Control Protocol (TCP) or a User Datagram Protocol (UDP). Conventional TCP transport protocols are designed for low speed, low latency networks. In a close-range transmission scene from end to end, because two mobile terminals do not need to forward data through an intermediate node, a network between the two mobile terminals basically has no jitter, when a TCP is used for transmitting file data, a sending end and a receiving end need to establish connection firstly, and a window congestion control mechanism is introduced to ensure reliability and orderliness, so that the file transmission rate is influenced. When the UDP is used to transmit the file data, although the transmission rate of the file may be increased, the UDP cannot ensure reliable data transmission, which may result in incomplete files received by the receiving end. Therefore, in a large file data transmission scenario in an end-to-end close distance, the conventional transmission protocol cannot meet the requirements of high transmission rate and reliability at the same time.
Disclosure of Invention
The application provides a buffer area management method and a related device, which can realize that the size of a buffer area is adjusted according to the buffered data, the available memory, the network card receiving rate, the disk writing rate, the available memory of the buffer area and the frequency degree of receiving user interaction operation in the process of receiving file data by a terminal. Therefore, the overflow probability of the buffer area in the terminal during high-speed file data transmission can be reduced, and the packet loss rate is reduced.
In a first aspect, the present application provides a buffer management method, including: and the terminal receives the data of the first file, stores the data of the first file into a first buffer area, and writes the data in the first buffer area into a magnetic disk. The terminal monitors the buffered data volume of the first buffer area, the data volume to be transmitted of the first file, the buffer data growth rate of the first buffer area and the available memory capacity. If the increase rate of the buffered data of the first buffer area is greater than 0, the terminal determines the required total capacity value of the first buffer area according to the buffered data volume of the first buffer area, the data volume to be transmitted of the first file, the increase rate of the buffered data of the first buffer area and the network card receiving rate. If the required total capacity value of the first buffer area is greater than or equal to a second value and less than or equal to a first value, and the remaining buffer capacity of the first buffer area is less than the data volume to be transmitted of the first file, the terminal adjusts the size of the first buffer area to the required total capacity value of the first buffer area, wherein the first value is greater than the second value.
By the buffer area management method, the size of the buffer area can be adjusted according to factors such as buffered data, available memory, network card receiving rate, disk writing rate and available memory capacity of the buffer area and the frequency degree of receiving user interaction operation in the process of receiving file data by the terminal. Under different scenes, the size of the buffer area is adjusted, and more storage space is applied for the buffer area as much as possible. Therefore, the overflow probability of the buffer area during high-speed file data transmission can be reduced, and the packet loss rate is reduced.
In a possible implementation manner, if the required total capacity value of the first buffer is greater than the first value, the terminal adjusts the size of the first buffer to a first buffer capacity, where a ratio of the first buffer capacity to the available memory capacity is a first value.
In a possible implementation manner, if the required total capacity value of the first buffer is smaller than the second value, the terminal adjusts the size of the first buffer to the required total capacity value of the first buffer.
In one possible implementation manner, after the terminal adjusts the size of the first buffer to the required total capacity value of the first buffer, the method further includes: if the number of times that the terminal receives user input in a specified time period is larger than a number threshold, and the buffered data amount of the first buffer area is smaller than or equal to a second buffer capacity, the terminal determines a safe sending rate according to the second buffer capacity, the buffered data amount of the first buffer area, the remaining data amount of the first file, and the buffered data growth rate of the first buffer area, and the ratio of the second buffer capacity to the available memory capacity is the second value. The terminal sends first rate information to a sending end of the first file, wherein the first rate information is used for indicating the sending end to adjust the sending rate of the first file to be the safe sending rate. The terminal receives the confirmation information sent by the sending end. In response to the acknowledgement information, the terminal adjusts the size of the first buffer to the second buffering capacity.
In a possible implementation manner, if the total required capacity of the first buffer is greater than or equal to a second value and less than or equal to the first value, where the second value is less than the first value, after the terminal adjusts the size of the first buffer to the total required capacity of the first buffer, the method further includes: if the number of times that the terminal receives user input in a specified time period is larger than a number threshold and the buffered data volume of the first buffer area is larger than a second buffer capacity, the terminal sends second rate information to the sending end, the second rate information is used for indicating the sending end to adjust the sending rate of the first file to be smaller than or equal to the rate threshold, and the ratio of the second buffer capacity to the available memory capacity is the second value. If the buffered data amount of the first buffer area is smaller than the second buffer capacity, the terminal adjusts the size of the first buffer area to the second buffer capacity.
In a possible implementation manner, after the terminal adjusts the size of the first buffer area to the second buffering capacity, the method further includes: and the terminal determines a safe sending rate according to the residual buffer capacity of the first buffer area, the residual data volume of the first file and the buffer data growth rate of the first buffer area. The terminal sends first rate information to a sending end of the first file, wherein the first rate information is used for indicating the sending end to adjust the sending rate of the first file to be the safe sending rate.
In one possible implementation manner, after the terminal adjusts the size of the first buffer area to the first buffer capacity, the method further includes: if the number of times that the terminal receives the user input in the specified time period is larger than the number threshold, and the buffered data amount of the first buffer area is smaller than or equal to a second buffer capacity, the terminal determines a safe sending rate according to the second buffer capacity, the buffered data amount of the first buffer area, the remaining data amount of the first file, and the buffered data growth rate of the first buffer area, and the ratio of the second buffer capacity to the available memory capacity is the second value. The terminal sends first rate information to a sending end of the first file, wherein the first rate information is used for indicating the sending end to adjust the sending rate of the first file to be the safe sending rate. The terminal receives the acknowledgement message sent by the sending terminal. In response to the confirmation information, the terminal adjusts the size of the first buffer area to the second buffer capacity.
In one possible implementation manner, after the terminal adjusts the size of the first buffer area to the first buffer capacity, the method further includes: if the number of times that the terminal receives user input in a specified time period is larger than a number threshold and the buffered data volume of the first buffer area is larger than a second buffer capacity, the terminal sends second rate information to the sending end, the second rate information is used for indicating the sending end to adjust the sending rate of the first file to be smaller than or equal to the rate threshold, and the ratio of the second buffer capacity to the available memory capacity is the second value. If the buffered data amount of the first buffer area is smaller than the second buffer capacity, the terminal adjusts the size of the first buffer area to the second buffer capacity.
In one possible implementation manner, after the terminal adjusts the size of the first buffer area to the first buffer capacity, the method further includes: if the number of times that the terminal receives user input in a specified time period is larger than a number threshold and the buffered data volume of the first buffer area is larger than a second buffer capacity, the terminal sends second rate information to the sending end, the second rate information is used for indicating the sending end to adjust the sending rate of the first file to be smaller than or equal to the rate threshold, and the ratio of the second buffer capacity to the available memory capacity is the second value. If the buffered data amount of the first buffer area is smaller than the second buffer capacity, the terminal adjusts the size of the first buffer area to the second buffer capacity.
In one possible implementation, after the terminal adjusts the size of the first buffer to the required total capacity value of the first buffer, the method further includes: when the terminal determines that the buffered data growth rate of the first buffer is less than 0, the terminal reduces the size of the first buffer by a specified capacity.
In one possible implementation manner, the terminal determines the required capacity value of the first buffer according to the following formula:
c*(H-W)/A-FLS/rateNet=0
Wherein c is a conservative coefficient, c is more than 0 and less than or equal to 1, H is a required total capacity value of the first buffer area, W is a buffered data volume of the first buffer area, A is a buffered data growth rate of the first buffer area, FLS is a to-be-transmitted data volume of the first file, and rateNet is a receiving rate of the network card.
In a possible implementation manner, the terminal determines the safe sending rate according to the following formula:
c*(X-W)/A-FLS/V1=0
wherein c is a conservative coefficient, c is more than 0 and less than or equal to 1, X is the second buffer capacity, W is the buffered data volume of the first buffer area, A is the buffered data growth rate of the first buffer area, FLS is the data volume to be transmitted of the first file, and V1 is the safe transmission rate.
In a possible implementation manner, the determining, by the terminal, a secure transmission rate according to the remaining buffer capacity of the first buffer, the remaining data amount of the first file, and the buffered data growth rate of the first buffer specifically includes:
the terminal determines the safe sending rate according to the following formula:
c*P/A-FLS/V1=0
c is a conservative coefficient, c is more than 0 and less than or equal to 1, P is the residual buffer capacity of the first buffer area, A is the buffer data growth rate of the first buffer area, FLS is the data volume to be transmitted of the first file, and V1 is the safe sending rate.
In a possible implementation manner, if a ratio of the amount of data to be transmitted of the first file to the total amount of data of the first file is smaller than a specified ratio value, the terminal adjusts the size of the first buffer area to a third buffer capacity, a ratio of the third buffer capacity to the available memory capacity is a third value, and the third value is larger than the first value.
In a possible implementation manner, the acquiring, by the terminal, the buffered data rate increase rate of the first buffer area specifically includes:
the terminal acquires the increase rate of the buffered data in the first buffer area by monitoring the change of the buffered data amount in the first buffer area.
In a possible implementation manner, the acquiring, by the terminal, the buffered data rate increase rate of the first buffer area specifically includes: and the terminal acquires the writing rate of the data of the first file written into the disk. And the terminal determines the buffer data growth rate of the first buffer area according to the network card receiving rate and the writing rate.
In a second aspect, the present application provides a data transmission method, including: the first terminal and the second terminal establish a file transmission connection, and the file transmission connection is used for transmitting the first file. The first terminal obtains the upper limit of the physical layer sending rate of the network card. And the first terminal determines a first rate according to the upper limit of the physical layer sending rate. The first terminal writes the first data of the first file into the transmission buffer qdisk _ buffer of the MAC layer at the first speed, and sends the first data of the first file in the transmission buffer of the MAC layer to the second terminal through the network card. When the first terminal determines that the buffered data volume of the MAC layer sending buffer zone is larger than or equal to a first early warning waterline, the first terminal writes second data of the first file into the MAC layer sending buffer zone at a second speed, and sends the second data of the first file in the MAC layer sending buffer zone to the second terminal through the network card, wherein the first speed is larger than the second speed.
By the data transmission method provided by the embodiment of the application, the buffer capacity and the first early warning water level line of the MAC layer transmission buffer (qdisk _ buffer) of the transmitting end 210 can be set, and the transmission rate at which the transmitting end 210 writes the data of the first file into the MAC layer transmission buffer is determined according to the buffered data amount of the MAC layer transmission buffer (qdisk _ buffer), so that the transmission speed of the file approaches the limit rate of the physical channel and the packet loss rate is reduced.
In a possible implementation manner, the first terminal obtains first water level line information reported by the MAC layer, where the first water level line information is used to indicate that a buffered data amount of the MAC layer sending buffer is greater than or equal to the first early warning water level line. Therefore, when the buffered data volume of the MAC layer sending buffer zone exceeds the first early warning waterline, the MAC layer can actively report warning information and reduce the speed of writing the data of the first file into the MAC layer sending buffer zone in time.
In a possible implementation manner, when the first terminal determines that the buffered data amount of the MAC layer transmission buffer is greater than or equal to the first early warning waterline and the remaining capacity of the MAC layer transmission buffer is smaller than the data amount to be transmitted of the first file, the first terminal writes the second data of the first file into the MAC layer transmission buffer at the second rate, and transmits the second data of the first file in the MAC layer transmission buffer to the second terminal through the network card.
In a possible implementation manner, after the first terminal writes the first data of the first file into the MAC layer transmission buffer at the first rate, and sends the first data of the first file in the MAC layer transmission buffer to the second terminal through the network card, the method further includes: when the first terminal determines that the buffered data volume of the MAC layer sending buffer area is greater than or equal to the first early warning waterline and the residual capacity of the MAC layer sending buffer area is greater than or equal to the to-be-sent data volume of the first file, the first terminal writes the second data of the first file into the MAC layer sending buffer area at the first speed, and sends the second data of the first file in the MAC layer sending buffer area to the second terminal through the network card. Thus, when the remaining capacity of the MAC layer transmission buffer is sufficient to accommodate the remaining transmission data of the first file, the first terminal transmits the data of the first file at a high rate, increasing the file transmission rate.
In a possible implementation manner, after the first terminal writes the second data of the first file into the MAC layer transmission buffer at the second rate, and sends the second data of the first file in the MAC layer transmission buffer to the second terminal through the network card, the method further includes: when the first terminal determines that the amount of buffered data in the first buffer area is smaller than or equal to a first designated threshold value, the first terminal writes third data of the first file into the MAC layer sending buffer area at the first speed, and sends the third data of the first file in the MAC layer sending buffer area to the second terminal through the network card, wherein the first designated threshold value is smaller than the first early warning waterline. Thus, when the amount of buffered data in the MAC layer transmission buffer is reduced to be below the first specified threshold, the first terminal can transmit the data of the first file at a large rate, and the file transmission rate is improved.
In a possible implementation manner, in the first terminal, the data of the first file is written into the MAC layer transmission buffer at a first rate, and the data of the first file in the MAC layer transmission buffer is sent to the second terminal through the network card, and the method further includes: the first terminal receives first feedback information sent by the second terminal when the buffer water level line of the first buffer area on the second terminal is determined to be larger than or equal to the second early warning water level line. Responding to the first feedback information, the first terminal writes fourth data of the first file into the MAC layer sending buffer zone at a third speed, and sends the fourth data of the first file in the MAC layer sending buffer zone to the second terminal through the network card, wherein the first speed is greater than the third speed.
In one possible implementation, the first buffer includes: any one of the IP fragment reassembly buffers IP _ defrag _ buffer and write buffer on the second terminal.
In this way, the sending rate of the first terminal can be further determined by monitoring the buffered data amount of the IP fragment reassembly buffer (IP _ defrag _ buffer) of the second terminal and the write buffer (write _ buffer) of the second terminal, so that the file transmission speed approaches to the physical channel limit rate and the packet loss rate is reduced.
In a possible implementation manner, after the first terminal writes the fourth data of the first file into the MAC layer send buffer at the third rate, and sends the data of the first file in the MAC layer send buffer to the second terminal through the network card, the method further includes: and the first terminal receives second feedback information sent by the second terminal when the buffered data volume of the first buffer area is determined to be smaller than or equal to a second specified threshold value, wherein the second specified threshold value is smaller than the second early warning waterline. Responding to the second feedback information, the first terminal writes the fifth data of the first file into the MAC layer sending buffer zone at the first rate, and sends the fifth data of the first file in the MAC layer sending buffer zone to the second terminal through the network card, wherein the first rate is greater than the third rate. In this way, when the amount of buffered data in the first buffer decreases below the second specified threshold, the first terminal can transmit the data of the first file at a large rate, increasing the file transmission rate.
In one possible implementation manner, before the first terminal writes the data of the first file into the MAC layer transmission buffer at the first rate, the method further includes: the first terminal obtains a measurement data packet reported by an MAC layer, wherein the measurement data packet comprises the time for reporting the measurement data packet by the MAC layer. And the first terminal determines the feedback time of the MAC layer according to the time when the MAC layer reports the measurement data packet and the time when the first terminal acquires the measurement data packet. And the first terminal determines the buffer capacity of the MAC layer sending buffer zone and the first early warning waterline according to the upper limit of the physical layer sending rate and the feedback time of the MAC layer.
Wherein, the formula that the first terminal determines the buffer capacity of the MAC layer sending buffer zone and the first early warning water level line is as follows:
((1-A)*M)/Vmax≥Ts
(A*M)/Vmax≥2*Ts
wherein, M is the buffer capacity of the MAC layer transmission buffer, a is the early warning waterline, vmax is the physical layer transmission rate upper limit, ts is the feedback time, and M is the minimum value satisfying the formula.
In one possible implementation, the file transfer connection includes: any one of Wi-Fi direct, wi-FisoftAP, ultra-wideband communication connection, and Bluetooth connection.
In a possible implementation manner, the second terminal determines the buffer capacity of the first buffer and the second early warning waterline according to the upper limit of the sending rate of the physical layer and the round trip delay on the file transfer connection.
Wherein, the second terminal determines that the buffer capacity of the first buffer area and the formula of the second early warning water level line are as follows:
((1-a)*m)/Vmax≥0.5*RTT
(a*m)/Vmax≥0.5*RTT+0.5*RTT
wherein, m is the buffer capacity of the MAC layer transmission buffer, a is the early warning waterline, vmax is the physical layer transmission rate upper limit, RTT is the round trip delay, and m is the minimum value satisfying the formula.
In a third aspect, the present application provides a data storage method, including: and the terminal receives the data of the first file and stores the data of the first file into a network protocol stack receiving buffer area. The terminal takes out the data of the first file from the network protocol stack receiving buffer zone and directly writes the data into a disk. The terminal obtains the residual buffer capacity of the network protocol stack receiving buffer area, the data volume to be transmitted of the first file and the buffer data growth rate of the network protocol stack receiving buffer area. If the buffer data rate increase of the network protocol stack receiving buffer area is larger than 0, the terminal determines the overflow time of the network protocol stack receiving buffer area and the remaining transmission time of the first file according to the remaining buffer capacity of the network protocol stack receiving buffer area, the data volume to be transmitted of the first file, the buffer data rate increase of the network protocol stack receiving buffer area and the network card receiving rate. If the overflow time of the network protocol stack receiving buffer is less than the remaining transmission time of the first file and the buffered data amount of the network protocol stack receiving buffer is greater than a first threshold, the terminal transfers the data stored in the network protocol stack receiving buffer to a user mode buffer and writes the data in the user mode buffer into the disk through a kernel mode writing buffer.
According to the data storage method, after the terminal receives the file data, the terminal can adopt different data storage paths through the water level line in the kernel-state network protocol stack receiving buffer area, so that packet loss caused by overflow in the network protocol stack receiving buffer area can be avoided, and the packet loss rate is reduced while the file data is transmitted at a high speed.
In a possible implementation manner, the terminal determines the overflow time of the network protocol stack receiving buffer according to the buffered data growth rate of the network protocol stack receiving buffer and the remaining buffer capacity of the network protocol stack receiving buffer. And the terminal determines the residual transmission time of the first file according to the data volume to be transmitted of the first file and the receiving rate of the network card.
In a possible implementation manner, after the terminal transfers the buffered data in the network protocol stack receiving buffer to the user mode buffer, and takes out the data of the first file from the user mode buffer and writes the data into the disk through the kernel mode writing buffer, the method further includes: and the terminal determines the overflow time of the user state buffer area according to the increase rate of the buffer data of the user state buffer area and the residual buffer capacity of the user state buffer area. And if the overflow time of the user mode buffer area is less than the remaining transmission time of the first file, the terminal sends buffering information to a sending end of the first file, and the buffering information is used for indicating the sending end to reduce the sending rate of the first file. Therefore, when the overflow time of the user mode buffer area is less than the remaining transmission time of the first file, the sending end can be timely enabled to reduce the sending rate, and the overflow of the user mode buffer area is prevented.
In a possible implementation manner, if the overflow time of the user mode buffer is greater than or equal to the remaining transmission time of the first file, the method further includes: and if the buffered data volume of the network protocol stack receiving buffer is lower than a second threshold value, the terminal determines the maximum overflow time of the network protocol stack receiving buffer according to the total buffer capacity of the network protocol stack receiving buffer and the buffer data growth rate of the user mode buffer. If the maximum overflow time of the network protocol stack receiving buffer zone is larger than or equal to the remaining transmission time of the first file, the terminal takes out the data of the first file from the network protocol stack receiving buffer zone and directly writes the data into the disk. Therefore, when the spare capacity of the network protocol stack receiving buffer area is large, the data of the first file is directly written into the disk from the network protocol stack receiving buffer area, and the processing power consumption of the processor is saved.
In a possible implementation manner, the transferring, by the terminal, the data stored in the network protocol stack receiving buffer to the user mode buffer specifically includes: the terminal transfers all the data stored in the network protocol stack receiving buffer to the user mode buffer.
In a possible implementation manner, the transferring, by the terminal, the data stored in the network protocol stack receiving buffer to the user mode buffer specifically includes: the terminal transfers the first part of data stored in the network protocol stack receiving buffer to the user mode buffer. The method further comprises the following steps: and the terminal directly writes the second part of data stored in the receiving buffer of the network protocol stack into the disk.
In a possible implementation manner, the acquiring, by the terminal, the buffered data growth rate of the network protocol stack receiving buffer specifically includes: the terminal acquires the buffer data growth rate of the network protocol stack receiving buffer area by monitoring the change of the buffered data volume in the network protocol stack receiving buffer area.
In a possible implementation manner, the acquiring, by the terminal, the buffered data growth rate of the network protocol stack receiving buffer specifically includes: and the terminal acquires the writing rate of the data of the first file written into the disk. And the terminal determines the buffer data growth rate of the network protocol stack receiving buffer area according to the network card receiving rate and the writing rate.
In one possible implementation, the network protocol stack receiving buffer includes: a user datagram protocol UDP receive buffer.
In a fourth aspect, the present application provides a multi-path data prefetching method, including: the terminal acquires a first HTTP request initiated by a first application of the terminal aiming at the first URI, wherein the first HTTP request is used for requesting first data from the server. The terminal generates L second HTTP requests, the L second HTTP requests are used for requesting second data from the server, the second data comprise the first data, the data volume of the second data is larger than that of the first data, and L is a positive integer. And the terminal sends the L second HTTP requests to the server through L network paths respectively. The terminal receives L first HTTP responses sent by the server on the L network paths, wherein the L first HTTP responses comprise the second data. The terminal takes the first data out of the second data and returns the first data to the first application through an HTTP response. The terminal receives a third HTTP request initiated by the first application for the first URI, the third HTTP request being used for requesting third data from the server. And if the second data comprises the third data, the terminal takes out the third data from the second data and returns the third data to the first application through an HTTP response.
By the multipath data prefetching method, when the application service requests data of a first data volume, the terminal can prefetch data of a second data volume to the server, wherein the second data volume is larger than the first data volume. Then, after receiving the data of the second data volume returned by the server, the terminal may first return the data of the first data volume in the second data volume to the application. Then, the remaining (second amount of data — first amount of data) is stored to the prefetch buffer. When the application requests the next time the remaining (second amount of data-first amount of data) bytes of data, the terminal may directly fetch the remaining (second amount of data-first amount of data) bytes of data from the pre-fetch buffer to the application. The bandwidth utilization rate of the network path between the terminal and the server is improved, and when the application frequently accesses data in different ranges on the same URI address, the time for the application to acquire the data can be saved.
In a possible implementation manner, if the byte range of the third data is not within the byte range of the second data, the terminal generates S fourth HTTP requests, where the S fourth HTTP requests are used to request fourth data from the server, and a set of the fourth data and the second data includes the third data, and S is a positive integer. The terminal receives S second HTTP responses sent by the server over the S network paths, where the S second HTTP responses include the fourth data. The terminal takes the third data out of the fourth data and the second data, and returns the third data to the first application through an HTTP response. Therefore, when the data volume prefetched by the terminal last time is not enough to meet the data volume of the current application, more data can be requested from the server.
In a possible implementation manner, before the terminal receives a third HTTP request initiated by the first application for the first URI, the method further includes: and the terminal stores the residual data in the second data except the first data into a first pre-fetching buffer area corresponding to the first URI. If the second data includes the third data, the terminal extracts the third data from the second data, and returns the third data to the first application through an HTTP response, specifically including: and if the second data comprises the third data, the terminal fetches the third data from the first pre-fetching buffer area and returns the third data to the first application through an HTTP response. Therefore, the terminal can store the data which are prefetched for a plurality of times into the buffer area, and can return the data to the application in time when the application requests the data for the next time.
In a possible implementation manner, before the terminal generates L second HTTP requests, the method further includes: and the terminal determines the byte range of the second data according to the byte range of the resource corresponding to the first URI requested by the first application last time.
In a possible implementation manner, the determining, by the terminal, a byte range of second data according to a byte range of a resource to which the first URI is requested last time by the first application specifically includes: and the terminal acquires the last request data volume and the last request tail end byte position of the resource corresponding to the first URI requested by the first application last time from the byte range of the resource corresponding to the first URI requested by the first application last time. When the last request data volume of the specified multiple is less than or equal to the residual buffer capacity in the first pre-fetching buffer area, the terminal determines that the current request data volume is the last request data volume of the specified multiple. And the terminal determines the byte range of the second data according to the data volume of the current request and the last request terminal byte position. In this way, the terminal 100 can determine the amount of data to be prefetched to the server each time.
In one possible implementation, the method further includes: when the specified multiple of the last requested data amount is larger than the remaining buffer capacity in the first prefetch buffer, the terminal determines the current requested data amount as the last requested data amount.
In a possible implementation manner, the determining, by the terminal, the byte range of the second data according to the byte range of the resource corresponding to the first URI requested by the first application last time specifically includes: and the terminal acquires the last request data volume and the last request tail byte position of the resource corresponding to the first URI requested by the first application last time from the byte range of the resource corresponding to the first URI requested by the first application last time. The terminal determines the first total bandwidth utilization rate of N available network paths on the terminal when the requested data volume is the last requested data volume of the specified multiple according to the bandwidth and the round-trip delay of the N available network paths, wherein N is more than or equal to L, and N is a positive integer. And when the first total bandwidth utilization rate is less than or equal to a specified threshold and the last request data volume of the specified multiple is less than or equal to the residual buffer capacity in the first pre-fetching buffer area, the terminal determines the current request data volume of the specified multiple as the last request data volume. And the terminal determines the byte range of the second data according to the data volume of the current request and the terminal byte position of the last request.
The determination of the data volume requested this time may be as follows:
1. and when the first total bandwidth utilization rate is less than or equal to the specified threshold and the last requested data volume of the specified multiple is larger than the residual buffer capacity in the first pre-fetching buffer area, the terminal determines the current requested data volume as the last requested data volume.
2. And when the first total bandwidth utilization rate is greater than the specified threshold, the terminal determines a corresponding first pre-fetching data volume when the total bandwidth utilization rate of the N available network paths is the specified threshold according to the bandwidth and the time delay of the N available networks. When the terminal determines that the first pre-fetching data volume is less than or equal to the residual buffer capacity in the first pre-fetching buffer area, the terminal determines that the data volume requested this time is the first pre-fetching data volume.
3. When the terminal determines that the first prefetch data volume is larger than the remaining buffer capacity in the first prefetch buffer, the terminal determines that the current request data volume is the last request data volume.
In a possible implementation manner, the terminal generates the L second HTTP requests according to bandwidths and round trip delays of L network paths between the terminal and the server, IP addresses of the server on the L network paths, and byte ranges of the second data. Therefore, the terminal can determine the data quantity requested on each network path according to the network performance of each network path, improve the bandwidth utilization rate of the network paths and reduce the data transmission time.
In a possible implementation manner, before the terminal acquires the first HTTP request initiated by the first application for the first URI, the method further includes: the terminal acquires an initial HTTP request initiated by the first application for the first URI, wherein the initial HTTP request is used for requesting fifth data. And the terminal generates N fifth HTTP requests according to the byte range of the fifth data, wherein the request ranges in the N fifth HTTP requests have the same length, and N is greater than or equal to L. And the terminal sends the N fifth HTTP requests to the server through N available network paths respectively. And the terminal receives fifth data sent by the server on the N available network paths and returns the fifth data to the first application. The terminal obtains round trip delays and throughputs over the N available network paths. And the terminal determines the bandwidths of the N available network paths according to the round trip delay and the throughput on the N available network paths and the data volume respectively requested by the N fifth HTTP requests. In this way, the terminal can acquire the network performance information on each network path.
After the terminal acquires an initial HTTP request initiated by the first application for the first URI, the terminal creates the first prefetch buffer corresponding to the first URI.
The terminal determines the bandwidths of the N available network paths by the following formula:
Figure BDA0003175853830000091
Figure BDA0003175853830000092
TransTime i =max{U i /Z i ,0.5*RTT i }
wherein the content of the first and second substances,
Figure BDA0003175853830000093
represents the theoretical bandwidth utilization, Z, of the ith available network path i Representing the true bandwidth, X, of the ith network path i Represents the throughput of the ith network path, transTime i Indicating that the data transmission on the ith available network path is time consuming, U i Represents the amount of data requested by a corresponding fifth HTTP request over the ith available network path, RTT i Representing the round trip delay on the ith available network path, i ≦ N.
In a possible implementation manner, before the terminal obtains the initial HTTP request initiated by the first application for the first URI, the terminal sends DNS requests on all network paths according to the domain name of the first URI. The terminal receives N DNS responses over the N available network paths. And the terminal acquires the IP address of the server corresponding to each network path in the N available network paths from the N DNS responses. Thus, the terminal can acquire the IP address of the server on each network path.
In a possible implementation manner, the terminal determines the requested data amount corresponding to each of L network paths between the terminal and the server according to bandwidths and round trip delays of the L network paths and a byte range of the second data. And the terminal determines the request range corresponding to each of the L second HTTP requests according to the request data volume corresponding to each of the L network paths and the byte range of the second data. And the terminal generates the L second HTTP requests according to the IP address of the server and the request range corresponding to each of the L second HTTP requests.
Before the terminal generates L second HTTP requests according to bandwidths and round-trip delays of L network paths between the terminal and the server, the IP address of the server on the L network paths, and the byte range of the second data, the terminal establishes TCP connections with the server on the L network paths, respectively.
The terminal determines the requested data volume corresponding to each of the L network paths by using the following formula:
Figure BDA0003175853830000094
FCT i =U i /Z i +0.5*RTT i
FCT i =c
wherein M is the data amount of the second data, U i Is used for representing the sub-request data volume, FCT, corresponding to the ith network path in the L network paths i For indicating the transmission completion U of the ith network path in the L network paths i Length of data. Z is a linear or branched member i C is a fixed value, and i is greater than or equal to 1 and less than or equal to L.
In a possible implementation manner, after the terminal generates L second HTTP requests according to bandwidths and round trip delays of L network paths between the terminal and the server, the IP address of the server on the L network paths, and the byte range of the second data, the terminal establishes TCP connections with the server on the L network paths, respectively.
The terminal determines the requested data volume corresponding to each of the L network paths by using the following formula:
Figure BDA0003175853830000101
FCT i =U i /Z i +2*RTT i
FCT i =c
Wherein M is the data amount of the second data, U i Is used for representing the sub-request data volume, FCT, corresponding to the ith network path in the L network paths i For indicating the transmission completion U of the ith network path in the L network paths i Length of data. Z i C is a fixed value, and i is greater than or equal to 1 and less than or equal to L.
In a possible implementation manner, before the terminal generates L second HTTP requests according to bandwidths and round trip delays of L network paths between the terminal and the server, the IP address of the server on the L network paths, and the byte range of the second data, the terminal selects the L network paths from N available network paths.
In a possible implementation manner, when the terminal determines that the number of times that the first application requests the resource corresponding to the first URI in a specified time period is greater than a specified number threshold, the terminal generates the L second HTTP requests.
In a possible implementation manner, when the terminal determines that the number of times that the first application requests the resource corresponding to the first URI in a specified time period is greater than a specified number threshold and the first data is not included in the first prefetch buffer corresponding to the first URI, the terminal generates the L second HTTP requests.
In a fifth aspect, the present application provides a terminal comprising one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are configured to store computer program code comprising computer instructions that, when executed by the one or more processors, cause the terminal to perform a buffer management method or a data transmission method or a data storage method or a multi-path data pre-fetching method in any one of the possible implementations of the foregoing aspects.
In a sixth aspect, an embodiment of the present application provides a computer storage medium, which includes computer instructions, and when the computer instructions are executed on a terminal, the terminal executes a buffer management method, a data transmission method, a data storage method, or a multi-path data prefetching method in any one of the possible implementations of any one of the foregoing aspects.
In a seventh aspect, an embodiment of the present application provides a computer program product, which, when run on a computer, causes the computer to execute a buffer management method, a data transmission method, a data storage method, or a multi-path data prefetching method in any one of the possible implementations of the foregoing aspect.
In an eighth aspect, the present application provides a terminal, including: one or more functional modules configured to perform a buffer management method or a data transmission method or a data storage method or a multi-path data prefetching method in any one of the possible implementations of any one of the above aspects.
Drawings
Fig. 1 is a schematic view of a data transmission scenario provided in the first part of the embodiment of the present application;
fig. 2 is a schematic diagram illustrating a relationship between a memory occupancy rate and a user interaction frequency according to the first embodiment of the present application;
FIG. 3 is a diagram illustrating a buffer management policy provided in the first part of the embodiment of the present application;
fig. 4 is a schematic hardware structure diagram of a terminal provided in the first part of the embodiment of the present application;
fig. 5 is a schematic flowchart of a buffer management method according to a first embodiment of the present disclosure;
fig. 6 is a schematic architecture diagram of a data transmission system provided in the second part of the present application;
fig. 7 is a schematic diagram of a buffer of a data transmission system according to a second embodiment of the present application;
fig. 8 is a schematic flowchart of a data transmission method provided in the second part of the embodiment of the present application;
FIG. 9 is a schematic diagram of a buffer model provided in the second part of the embodiment of the present application;
fig. 10 is a schematic flowchart of a data transmission method provided in the second part of the embodiment of the present application;
fig. 11 is a schematic diagram illustrating a variation of a buffer water level line of a MAC layer transmission buffer provided in the second part of the embodiment of the present application;
fig. 12 is a schematic diagram of the basic logic of a congestion control mechanism in the transmission control protocol TCP provided in the third part of the embodiment of the present application;
fig. 13 is a schematic diagram illustrating a problem of a congestion control mechanism in a transmission control protocol TCP provided in the third part of the embodiment of the present application;
FIG. 14 is a block diagram illustrating an architecture of a data storage system provided in the third part of the present application;
FIG. 15 is a schematic flowchart of a data storage method provided in the third part of the embodiments of the present application;
fig. 16 is a schematic diagram of a multipath tcp provided in the fourth part of the embodiment of the present application;
FIG. 17 is a schematic diagram illustrating a multi-path hypertext transfer protocol MPHTTP protocol provided in the fourth part of the embodiment of the present application;
fig. 18 is a system architecture diagram of multipath transmission provided in the fourth part of the embodiment of the present application;
fig. 19 is a schematic flowchart of a multipath transmission based on the multi-path hypertext transfer protocol http in the fourth part of the embodiment of the present application;
Fig. 20 is a timing diagram illustrating a terminal requesting data from a server through an HTTP request according to a fourth aspect of the embodiment of the present application;
fig. 21 is a schematic diagram illustrating a relationship between bandwidth utilization and a slice size and a network bandwidth provided in the fourth part of the embodiment of the present application;
FIG. 22A is a schematic diagram illustrating a multi-path data prefetching method according to a fourth embodiment of the present application;
FIG. 22B is a schematic diagram illustrating another multi-path data prefetching method according to the fourth embodiment of the present application;
fig. 23 is a schematic software architecture diagram of a terminal according to a fourth aspect of the present application;
fig. 24 is a flowchart illustrating a method for a first application to obtain data on a server for a first time according to a fourth embodiment of the present application;
fig. 25 is a flowchart illustrating a method for the first application to obtain data again from the server according to the fourth embodiment of the present application;
FIG. 26 is a flowchart illustrating a multi-path data prefetching method according to the fourth embodiment of the present application;
fig. 27 is an interaction flow diagram of a multi-path data prefetching method according to the fourth aspect of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described in detail and clearly with reference to the accompanying drawings. In the description of the embodiments herein, "/" means "or" unless otherwise specified, for example, a/B may mean a or B; the "and/or" in the text is only an association relation describing the association object, and indicates that three relations may exist, for example, a and/or B may indicate: three cases of a alone, a and B both, and B alone exist, and in addition, "a plurality" means two or more than two in the description of the embodiments of the present application.
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as implying or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of embodiments of the application, unless stated otherwise, "plurality" means two or more.
A buffer management method and related contents provided in the first part of the embodiments of the present application are described below with reference to fig. 1 to 5.
The ordinal numbers of some of the nouns in the first portion of the embodiments of the present application do not continue in the order in which they were recited in other portions of the embodiments of the present application, and the nouns in the first portion of the embodiments of the present application are used only in the first portion of the embodiments of the present application.
In a large bandwidth transmission scenario, the main contradiction of high speed transmission is that the channel limit rate does not match the terminal internal processing rate. When a sending end transmits file data to a receiving end, if the sending end transmits the file data to the receiving end too fast, data packets are easy to lose, and if the sending end transmits the file data to the receiving end too slow, the file transmission rate cannot approach the channel limit rate, bandwidth is wasted, and the requirements of users cannot be met. For example, a terminal adopting the Universal Flash Storage (UFS) 3.0 standard may achieve a sequential write rate of 2.4Gbps when idle. The terminal adopting the Universal Flash Storage (UFS) 2.0 standard can achieve a sequential write rate of 1.2Gbps at idle. The sequential write rate of the mechanical hard disk 7200 at idle may be up to 1.2Gbps. The sequential write rate of a Solid State Disk (SSD) at idle time can reach 3Gbps. The channel transmission rate of the terminal configured with a 2x2 multiple-input multiple-output (MIMO) antenna based on a wireless fidelity (Wi-Fi) 5 wireless local area network can reach 1.7Gbps, and the channel transmission rate of the WiFi 6 based wireless local area network can reach 2.4Gbps.
Wherein, there is static mismatch between the channel limit sending rate and the terminal internal processing rate. When the computation power of Central Processing Units (CPUs) or the input/output (I/O) of a memory of a transmitting end and a receiving end is asymmetric, when a transmitting device with high I/O or CPU computation power transmits data to a receiving device with low I/O or CPU computation power at a high speed, a kernel mode receiving buffer of the receiving device with low I/O or CPU computation power is easy to overflow, thereby causing packet loss. This may result in a slow rate for transmitting file data by the transmitting end in a large bandwidth transmission scenario at a close distance from end to end.
There is also a dynamic mismatch between the channel limit transmission rate and the terminal internal processing rate. When the load of the receiving end changes dynamically, the dynamic change of the I/O computing power or the CPU computing power is caused, thereby affecting the rate at which the receiving end takes out data from the kernel mode receiving buffer, and possibly causing the packet loss rate to increase.
As shown in fig. 1, a packet sender (packet sender) may send file data to a packet receiver (packet receiver) through a network. After receiving the data packet, the data packet receiving end may store the data packet into the buffer area, and then a data packet processing module (packet handler) of the data packet receiving end may sequentially take out the data packet from the buffer area for processing, and release a storage space occupied by the taken-out data in the buffer area. For example, assuming that the buffer may be a user mode buffer, the processing rate Vsrv of the packet processing module to fetch data from the user mode buffer is related to the computation power of the CPU and the computation power of the I/O, and the receiving rate Vrerv of the user mode buffer is related to the channel. The default user mode buffer has a capacity of only 131Kb, assuming Vsrv is 1% less than the instantaneous rate of Vrerv, for a 1Gbps transmission link, it will take only about 0.1s for the user mode buffer to overflow from empty, and all packets that overflow will have to be discarded altogether. Therefore, the sending end sends the data packet too fast, the packet loss rate is too high, the sending end sends the data packet too slow, and the high-speed transmission requirement of an end-to-end short-distance large-bandwidth transmission scene is not met.
Fig. 2 is a diagram illustrating a relationship between a memory occupancy rate and a frequency of user interaction operations provided in the first part of the embodiment of the present application. As shown in fig. 2, when the terminal frequently receives the user interaction operation, it indicates that the terminal needs to occupy a higher memory, and responds to the user interaction operation to process the function items corresponding to the user interaction operation. Therefore, when the terminal frequently receives the user interaction operation, the memory occupancy rate (the ratio of the used memory to the total memory) of the terminal is high.
Fig. 3 shows a schematic diagram of a buffer management policy provided in the first part of the embodiment of the present application. As shown in fig. 3, after determining the buffer capacity of the buffer area, the terminal may determine which value range of the ratio of the buffer capacity of the buffer area to the available memory is in the risk area, the security area, and the critical area. The risk zone is greater than a first value (for example, 50%), the critical zone is less than or equal to the first value and greater than or equal to a second value (for example, 20%), the safety zone is less than the second value, and the first value is greater than the second value. When the buffer capacity of the buffer area is in the safe area, the terminal can rapidly apply for the buffer area a storage space with the buffer capacity in the available memory at one time, and then when the terminal determines that the buffer capacity of the buffer area is too large, the terminal can reduce the buffer capacity of the buffer area to a specified value for multiple times. When the buffer capacity of the buffer area is in the critical area and the risk area, the terminal can rapidly apply for the buffer area to the storage space of the buffer capacity in the available memory at one time, and then when the terminal determines that an interactive scene exists, the terminal can reduce the buffer capacity of the buffer area to a specified value at one time. Therefore, more storage space is applied for the buffer area as much as possible to ensure high-speed transmission of file data, but in a user interaction scene, the storage space of the buffer area can be released in time, and more available memory is provided for the terminal to process the corresponding functional items of user interaction.
Therefore, a first part of the embodiments of the present application provides a buffer management method, which can adjust the size of a buffer according to buffered data, an available memory, a network card receiving rate, a disk writing rate, an available memory of the buffer, and a frequency of receiving user interaction operations in a process of receiving file data by a receiving terminal, manage the size of the buffer in different scenarios, and apply for more storage space for the buffer as much as possible. Therefore, the overflow probability of the buffer area during high-speed file data transmission can be reduced, and the packet loss rate is reduced.
Fig. 4 shows a schematic configuration of the terminal 100.
The following describes an embodiment specifically by taking the terminal 100 as an example. It should be understood that the terminal 100 shown in fig. 4 is merely an example, and that the terminal 100 may have more or fewer components than shown in fig. 4, may combine two or more components, or may have a different configuration of components. The various components shown in fig. 4 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
The terminal 100 may include: the mobile terminal includes a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, a Subscriber Identity Module (SIM) card interface 195, and the like. The sensor module 180 may include one or more of a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It is to be understood that the illustrated structure of the embodiment of the present invention does not specifically limit the terminal 100. In other embodiments of the present application, terminal 100 may include more or fewer components than shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Processor 110 may include one or more processing units, such as: the processor 110 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a memory, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), etc. The different processing units may be separate devices or may be integrated into one or more processors.
The controller may be, among other things, a neural center and a command center of the terminal 100. The controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of instruction fetching and instruction execution.
A memory may also be provided in processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Avoiding repeated accesses reduces the latency of the processor 110, thereby increasing the efficiency of the system.
In some embodiments, processor 110 may include one or more interfaces. The interface may include an integrated circuit (I2C) interface, an integrated circuit built-in audio (I2S) interface, a Pulse Code Modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose-input/output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and/or a Universal Serial Bus (USB) interface, etc.
The charging management module 140 is configured to receive charging input from a charger.
The wireless communication function of the terminal 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in terminal 100 may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The mobile communication module 150 may provide a solution including wireless communication of 2G/3G/4G/5G, etc. applied on the terminal 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a Low Noise Amplifier (LNA), and the like. The mobile communication module 150 may receive the electromagnetic wave from the antenna 1, filter, amplify, etc. the received electromagnetic wave, and transmit the electromagnetic wave to the modem processor for demodulation. The mobile communication module 150 may also amplify the signal modulated by the modem processor, and convert the signal into electromagnetic wave through the antenna 1 to radiate the electromagnetic wave. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the same device as at least some of the modules of the processor 110.
The modem processor may include a modulator and a demodulator. The modulator is used for modulating a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used for demodulating the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then passes the demodulated low frequency baseband signal to a baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and then transferred to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.) or displays an image or video through the display screen 194. In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be provided in the same device as the mobile communication module 150 or other functional modules, independent of the processor 110.
The wireless communication module 160 may provide solutions for wireless communication applied to the terminal 100, including Wireless Local Area Networks (WLANs) (e.g., wireless fidelity (Wi-Fi) networks), bluetooth (BT), global Navigation Satellite System (GNSS), frequency Modulation (FM), near Field Communication (NFC), infrared (IR), and the like. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, perform frequency modulation and amplification on the signal, and convert the signal into electromagnetic waves through the antenna 2 to radiate the electromagnetic waves.
In some embodiments, the antenna 1 of the terminal 100 is coupled to the mobile communication module 150 and the antenna 2 is coupled to the wireless communication module 160 so that the terminal 100 can communicate with a network and other devices through a wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general Packet Radio Service (GPRS), code Division Multiple Access (CDMA), wideband Code Division Multiple Access (WCDMA), time division code division multiple access (time-division multiple access, TD-SCDMA), long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technologies, etc. The GNSS may include a Global Positioning System (GPS), a global navigation satellite system (GLONASS), a beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS), and/or a Satellite Based Augmentation System (SBAS).
The terminal 100 implements a display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
The display screen 194 is used to display images, video, and the like. The display screen 194 includes a display panel. The display panel may be a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a miniature, a Micro-oeld, a quantum dot light-emitting diode (QLED), or the like. In some embodiments, the terminal 100 may include 1 or N display screens 194, N being a positive integer greater than 1.
The terminal 100 may implement a photographing function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to extend the memory capability of the terminal 100. The internal memory 121 may be used to store computer-executable program code, which includes instructions. The processor 110 executes various functional applications of the terminal 100 and data processing by executing instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. The storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, and the like) required by at least one function, and the like. The storage data area may store data (e.g., audio data, a phonebook, etc.) created during use of the terminal 100, and the like. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (UFS), and the like.
The terminal 100 may implement an audio function through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. The audio module 170 is used to convert digital audio information into an analog audio signal output and also to convert an analog audio input into a digital audio signal. The speaker 170A, also called a "horn", is used to convert the audio electrical signal into an acoustic signal. The terminal 100 can listen to music through the speaker 170A or listen to a handsfree call. The receiver 170B, also called "earpiece", is used to convert the electrical audio signal into an acoustic signal. The microphone 170C, also referred to as a "microphone," is used to convert sound signals into electrical signals. The earphone interface 170D is used to connect a wired earphone. The pressure sensor 180A is used for sensing a pressure signal, and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display screen 194. The gyro sensor 180B may be used to determine a motion attitude of the terminal 100. The air pressure sensor 180C is used to measure air pressure. The magnetic sensor 180D includes a hall sensor. The acceleration sensor 180E may detect the magnitude of acceleration of the terminal 100 in various directions (generally, three axes). A distance sensor 180F for measuring a distance. The terminal 100 may measure the distance by infrared or laser. The proximity light sensor 180G may include, for example, a Light Emitting Diode (LED) and a light detector, such as a photodiode. The ambient light sensor 180L is used to sense the ambient light level. The fingerprint sensor 180H is used to collect a fingerprint. The temperature sensor 180J is used to detect temperature. The touch sensor 180K is also referred to as a "touch panel". The touch sensor 180K may be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, which is also called a "touch screen". The touch sensor 180K is used to detect a touch operation applied thereto or nearby. The touch sensor can communicate the detected touch operation to the application processor to determine the touch event type. Visual output associated with the touch operation may be provided through the display screen 194. In other embodiments, the touch sensor 180K may be disposed on the surface of the terminal 100 at a different position than the display screen 194. The bone conduction sensor 180M may acquire a vibration signal. The keys 190 include a power-on key, a volume key, and the like. The motor 191 may generate a vibration cue. Indicator 192 may be an indicator light that may be used to indicate a state of charge, a change in charge, or a message, missed call, notification, etc. The SIM card interface 195 is used to connect a SIM card.
The terminal 100 may be a mobile phone, a television, a tablet computer, a sound box, a watch, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), an Augmented Reality (AR) \ Virtual Reality (VR) device, and the like, and the specific type of the terminal is not particularly limited in the embodiments of the present application.
A first part of the embodiments of the present application introduces a buffer management method, and provides a buffer management method, including: and the terminal receives the data of the first file, stores the data of the first file into a first buffer area, and writes the data in the first buffer area into a magnetic disk. The terminal monitors the buffered data volume of the first buffer area, the data volume to be transmitted of the first file, the buffer data growth rate of the first buffer area and the available memory capacity. If the increase rate of the buffered data in the first buffer area is greater than 0, the terminal determines the required total capacity value of the first buffer area according to the buffered data volume of the first buffer area, the data volume to be transmitted of the first file, the increase rate of the buffered data in the first buffer area and the receiving rate of the network card. If the required total capacity value of the first buffer area is greater than or equal to a second value and less than or equal to a first value, and the remaining buffer capacity of the first buffer area is less than the data volume to be transmitted of the first file, the terminal adjusts the size of the first buffer area to the required total capacity value of the first buffer area, wherein the first value is greater than the second value.
With the buffer management method provided in the first part of the embodiment of the present application, in the process of receiving file data by a terminal, the size of the buffer can be adjusted according to factors such as buffered data, available memory, network card receiving rate, disk writing rate, available memory capacity, and the like of the buffer and the frequency of receiving user interaction operations. Under different scenes, the size of the buffer area is adjusted, and more storage space is applied for the buffer area as much as possible. Therefore, the overflow probability of the buffer area during high-speed file data transmission can be reduced, and the packet loss rate is reduced.
Referring to fig. 5, fig. 5 is a flowchart illustrating a buffer management method according to an embodiment of the present disclosure. As shown in fig. 5, the method may include:
s501, the terminal 100 may establish a file transmission connection with a sending end of the first file, and set the size of the first buffer area as a default value.
The sender of the first file may be another terminal or a server. When the sender of the first file is another terminal, the terminal 100 may transmit data of the first file with the other terminal through a Wi-Fi direct connection (e.g., a wireless fidelity peer to peer (Wi-Fi P2P)), a Wi-Fi softAP, an ultra-wideband (UWB), or other communication technologies. When the transmitting end is a server, the terminal 100 may receive data of the server transmission first file through the internet.
After the terminal 100 establishes the file transmission connection with the transmitting end of the first file, the terminal 100 may receive the total data amount of the first file transmitted by the transmitting end. The terminal 100 may set the size of the first buffer to a default value. Illustratively, the total data size of the first file may be 3000 Megabytes (MB), and the default value may be 20MB. The examples are merely illustrative of the present application and should not be construed as limiting.
S502, the terminal 100 receives the data of the first file, stores the data of the first file in the first buffer, and writes the data in the first buffer into the disk.
In some embodiments, the terminal 100 may retrieve the data of the first file from the first buffer and write the data directly to the disk, and in other embodiments, the terminal 100 may retrieve the data of the first file from the first buffer and write the data of the first file indirectly to the disk through the other buffer.
S503, the terminal 100 may monitor the buffered data amount of the first buffer, the data amount to be transmitted of the first file, the network card receiving rate, the buffered data growth rate of the first buffer, and the available memory capacity.
The terminal 100 may periodically obtain the buffered data amount of the first buffer, the data amount to be transmitted of the first file, and the increase rate of the buffered data amount of the first buffer. In the whole subsequent file transmission process, the buffered data volume of the first buffer, the data volume to be transmitted of the first file, the increase rate of the buffered data volume of the first buffer and the available memory capacity are all changed continuously. Therefore, before the terminal 100 uses the buffered data amount of the buffer, the data amount to be transmitted of the first file, and the buffer data amount increase rate of the buffer each time, the buffered data amount of the first buffer, the data amount to be transmitted of the first file, the buffer data amount increase rate of the first buffer, and the available memory capacity need to be obtained again.
The total memory capacity on the terminal 100 is fixed, e.g., 8 Gigabytes (GB), and the terminal 100 can monitor the occupied memory capacity. Then, the terminal 100 may determine the available memory capacity according to the total memory capacity and the occupied memory capacity. For example, the available memory capacity is the difference between the total memory capacity and the occupied memory capacity.
S504, when the increase rate of the buffered data in the first buffer is greater than 0, the terminal 100 determines the required total capacity value of the first buffer according to the buffered data amount (at this time, the value is W1) in the first buffer, the data amount to be transmitted (at this time, the value is FLS 1) in the first file, and the buffer data increase rate (at this time, the value is rateNet 1) in the first buffer (at this time, the value is A1).
The terminal 100 may obtain the buffered data growth rate of the first buffer by monitoring the buffered water level line change in the first buffer.
In one possible implementation, the terminal 100 may monitor the network card receiving rate and the disk writing rate of the first file. The terminal 100 may determine the buffered data growth rate of the first buffer area according to the network card receiving rate and the disk writing rate of the first file. The buffer data growth rate of the first buffer area may be a difference between a receiving rate of the network card and a disk writing rate of the first file.
Illustratively, the receiving rate of the network card may be 100 megabytes per second (MBps), the disk writing rate of the first file may be 90MBps, and the terminal 100 may determine that the buffer data growth rate of the first buffer is 10MBps. The examples are merely illustrative of the present application and should not be construed as limiting.
Wherein, the terminal 100 determines the required total capacity value of the first buffer by the following formula:
c (H-W)/a-FLS/rateNet =0 equation (1)
In the above formula (1), 0 < c ≦ 1, and c is a conservative coefficient, and c < 1 may be set to prevent the first buffer from actually overflowing, so that the terminal 100 may predict the overflow time of the first buffer to be earlier than the actual overflow time. H is the required total capacity value of the first buffer, W may refer to the buffered data amount of the first buffer, a may refer to the buffered data growth rate of the first buffer, FLS refers to the pending data amount of the first file, and rateNet may refer to the network card receiving rate.
When the terminal 100 executes the step S504, the value of the buffered data volume of the first buffer area is measured to be W1, the value of the buffered data growth rate of the first buffer area may be A1, the value of the data volume to be transmitted of the first file is FLS1, and the value of the network card receiving rate is rateNet1.
For example, the conservative coefficient c may be 0.8, the value W1 of the buffered data amount of the first buffer may be 12.5MB, the value A1 of the buffered data growth rate of the first buffer may be 17MBps, the value FLS1 of the data amount to be transmitted of the first file may be 2000MB, and the value rateNet1 of the network card receiving rate may be 200MBps. Therefore, the terminal 100 can determine the required total capacity value H of the first buffer to be 200MB by the above equation (1). The above examples are merely illustrative of the present application and should not be construed as limiting.
S505, the terminal 100 determines whether a ratio of the total capacity value required by the first buffer to the available memory capacity (in this case, R1) of the terminal 100 is smaller than a second value.
When the terminal 100 executes the step S504, it may be measured that the value of the available memory capacity on the terminal 100 is R1. Illustratively, the second value may be 0.2.
S506, when the ratio of the required total capacity value of the first buffer to the available memory capacity (in this case, R1) of the terminal 100 is smaller than the second value, the terminal 100 may immediately adjust the size of the first buffer to the required total capacity value.
For example, the second value may be 0.2, and the terminal 100 may determine that the required total capacity value of the first buffer is 200MB, in this case, the value R1 of the available memory capacity may be 2000MB, and the ratio of the required total capacity value to the available memory capacity may be 0.1 (less than 0.2). Therefore, the terminal 100 may set the size of the first buffer to 200MB, i.e., the terminal 100 applies for a storage space of 200MB for the first buffer from the available memory. The examples are merely illustrative of the present application and should not be construed as limiting.
S507, the terminal 100 may determine whether the increase rate of the buffered data in the buffer area is less than or equal to 0, if so, execute S508, and the terminal 100 may slowly decrease the size of the first buffer area.
After the ratio of the total capacity value required by the first buffer to the available memory capacity (R1 at this time) of the terminal 100 is smaller than the second value (e.g., 0.2), and the terminal 100 immediately adjusts the size of the first buffer to the total capacity value required, the terminal 100 may periodically (e.g., the period may be 2 ms) determine whether the increase rate of the buffered data in the first buffer is smaller than or equal to 0, and if so, the terminal 100 may slowly decrease the size of the first buffer; if not, the terminal 100 may re-execute the step S504.
In one possible implementation, the terminal 100 slowly decreasing the size of the first buffer may include decreasing the size of the first buffer by a designated capacity each time the terminal 100 determines that the buffered data growth rate of the first buffer is equal to or less than 0.
For example, the terminal 100 determines that the required total capacity of the first buffer may be 200MB, in this case, the value R1 of the available memory capacity may be 2000MB, and the terminal 100 applies for a storage space of 200MB from the available memory for the first buffer. Then, the terminal 100 periodically determines whether the increase rate of the buffered data in the first buffer is less than or equal to 0, and may decrease the size of the first buffer by 10MB each time the terminal 100 determines that the increase rate of the buffered data in the first buffer is less than or equal to 0, that is, each time the terminal releases the storage space of the first buffer by 10 MB. The examples are merely illustrative of the present application and should not be construed as limiting.
S509, when the terminal 100 determines that the ratio of the total capacity value required by the first buffer to the available memory capacity of the terminal 100 is greater than or equal to the second value, the terminal 100 may determine whether the ratio of the required buffer capacity of the first buffer to the available memory capacity of the terminal 100 is greater than the first value.
S510, when a ratio of the total required buffering capacity of the first buffer to the available memory capacity of the terminal 100 is greater than a first value, the terminal 100 may determine whether the remaining buffering capacity of the first buffer is less than the pending transmission data amount of the first file.
S511, when the remaining buffer capacity of the first buffer is smaller than the data to be transmitted of the first file, S511, the terminal 100 may set the size of the first buffer to be the first buffer capacity, and a ratio of the first buffer capacity to the available memory capacity is a first value.
Wherein the first value (e.g., 0.5) is greater than the second value (e.g., 0.2).
For example, the first value may be 0.5, the terminal 100 may determine that the value of the required total capacity of the first buffer is 200MB, at this time, the value R1 of the available memory capacity may be 300MB, the value FLS1 of the amount of data to be transmitted of the first file is 2000MB, the value P1 of the remaining buffer capacity of the first buffer is 7.5MB, the terminal 100 may determine that the ratio of the value of the required total capacity of the first buffer to the available memory capacity may be 2/3 (greater than 0.5), the remaining buffer capacity of the first buffer is smaller than the amount of data to be transmitted of the first file, and the first buffer capacity is 150MB. The terminal 100 can immediately adjust the size of the first buffer to 150MB. The above examples are merely illustrative of the present application and should not be construed as limiting.
S512, when the ratio of the total capacity of the first buffer to the available memory capacity of the terminal 100 is smaller than or equal to the first value and greater than or equal to the second value, the terminal 100 may set the size of the first buffer to the total capacity of the first buffer.
For example, the first value may be 0.5, the second value may be 0.2, the terminal 100 may determine that the required total capacity value of the first buffer is 200MB, in this case, the value R1 of the available memory capacity may be 500MB, and the terminal 100 may determine that the ratio of the required total capacity value of the first buffer to the available memory capacity may be 0.4 (greater than or equal to 0.2 and less than or equal to 0.5). The terminal 100 can immediately adjust the size of the first buffer to 200MB. The above examples are merely illustrative of the present application and should not be construed as limiting.
S513, when the ratio of the total capacity value required by the first buffer to the available memory capacity of the terminal 100 is greater than the first value, and the terminal 100 immediately adjusts the size of the first buffer, the terminal 100 may determine whether the number of times of receiving the user input in the specified time period is greater than the number threshold.
The user input may include one or more of a touch input to a touch screen, an input to a physical key, a voice input, and the like. The length of the specified time period may refer to a certain time period (e.g., 3 seconds) after the terminal 100 receives a certain user input, for example, the terminal 100 receives a user's continuous input, and the terminal 100 may determine whether the terminal 100 receives the user input more than 5 times within 3 seconds of the continuous input.
S514, when the threshold of the number of times that the terminal 100 receives the user input in the specified time period is greater than the threshold of times, the terminal 100 may determine whether the buffered data amount of the first buffer area is less than or equal to a second buffer capacity, where a ratio of the second buffer capacity to the available memory capacity (in this case, R2) is a second value.
S515, when the buffered data amount (W2 in this case) of the first buffer is less than or equal to the second buffer capacity, the terminal 100 may determine the safe sending rate according to the second buffer capacity, the buffered data amount (W2 in this case) of the first buffer, the data amount to be transmitted (FLS 2 in this case) of the first file, and the buffered data increase rate (A2 in this case) of the first buffer.
S516, the terminal 100 may send the first rate information to the sending end of the first file, so as to instruct the sending end to immediately adjust the sending rate of the first file to a safe sending rate.
When the threshold of the times that the terminal 100 receives the user input in the specified time period is greater than the threshold of the times, and the value W2 of the buffered data amount of the first buffer is less than or equal to the second buffer capacity, the terminal 100 may determine the secure transmission rate according to the second buffer capacity, the buffered data amount of the first buffer (W2 at this time), the data amount to be transmitted of the first file (FLS 2 at this time), and the buffered data amount increase rate of the first buffer (A2 at this time).
The terminal 100 can determine the safe transmission rate according to the following equation (2).
c (X1-W2)/A2-FLS 2/V1=0 formula (2)
Wherein, in the above formula (2), c is more than 0 and less than or equal to 1, and c is a conservative coefficient, and c can be less than 1 to prevent the first buffer from actually overflowing, so that the terminal 100 can predict the overflow time of the first buffer to be earlier than the actual overflow time. X1 is the second buffer capacity, W2 refers to the buffered data amount of the first buffer, A2 is the buffered data growth rate of the first buffer, FLS2 refers to the pending data amount of the first file, and V1 may refer to the secure sending rate. The above formula (2) is only used for explaining the present application and should not be construed as limiting.
In one possible implementation manner, the terminal 100 may monitor the network card receiving rate and the disk writing rate of the first file. The terminal 100 may determine the increase rate of the buffered data in the first buffer according to the network card receiving rate and the disk writing rate of the first file. Therefore, the above formula (2) may be replaced with the following formula (3):
c (X1-W2)/(Vt-rateIO 1) -FLS2/V1=0 equation (3)
Wherein, the rate IO1 is the disk writing rate of the first file. The above formula (3) is only for explaining the present application and should not be construed as limiting.
Illustratively, the threshold of the number of times is 5, the threshold of the number of times that the terminal 100 receives the user input within the specified time period is 8, c may be 0.8, the value W2 of the buffered data amount of the first buffer may be 100MB, the value R2 of the available memory capacity may be 1000MB, the second value may be 0.2, the value FLS2 of the data amount to be transmitted of the first file may be 1000MB, and the disk write rate rating io1 may be 180MBps. The terminal 100 may determine that the second buffering capacity may be 200MB. Wherein the threshold of the number of times of receiving user input within the specified time period is greater than the threshold of times and the amount of buffered data of the first buffer is less than the second buffer capacity. Therefore, the terminal 100 can determine that the secure transmission rate V1 is 195.65MBps. The above examples are merely illustrative of the present application and should not be construed as limiting.
The terminal 100 may transmit the first rate information to the transmitting end of the first file after determining the safe transmission rate. The first rate information is used for indicating the sending end to immediately adjust the sending rate of the first file to the safe sending rate.
S517, the terminal 100 receives the acknowledgement information returned from the sending end, and sets the size of the first buffer area to the second buffer capacity (with a value of X1) in response to the acknowledgement information.
The sending end may send the confirmation information to the terminal 100 after adjusting the sending rate of the first file to the secure sending rate. After the terminal 100 receives the acknowledgement information, the size of the first buffer may be set to the second buffer capacity (with a value of X1) in response to the acknowledgement information.
S518, when the buffered data amount (W2 in this case) of the first buffer is greater than the second buffer capacity (X1 in this case), the terminal 100 may send second rate information to the sending end of the first file, where the second rate information is used to instruct the sending end to adjust the sending rate of the first file to be less than or equal to the rate threshold.
S519, the terminal 100 may determine whether the buffered data amount of the first buffer is smaller than the second buffer capacity. If so, S520, the terminal 100 immediately adjusts the size of the first buffer to the second buffer capacity (this value is X2).
After sending the second rate information to the sender of the first file, the sender may reduce the sending rate of the first file according to the second rate information. In this way, the amount of buffered data in the first buffer on the terminal 100 will gradually decrease. After transmitting the second rate information to the transmitting end of the first file, the terminal 100 may always monitor whether the buffered data amount of the first buffer area is less than the second buffer capacity. When the buffered data amount of the first buffer is smaller than the second buffer capacity, the terminal 100 may immediately adjust the size of the first buffer to the second buffer capacity (this value is X2).
S521, after the terminal 100 immediately adjusts the size of the first buffer to the second buffer capacity, the terminal 100 determines the safe sending rate according to the remaining buffer capacity of the first buffer, the buffered data amount of the first buffer (at this time, the value is W3), the data amount to be transmitted of the first file (at this time, FLS 3), and the buffered data amount increase rate of the first buffer (at this time, the value is A3).
S522, the terminal 100 sends the first rate information to the sending end of the first file, where the first rate information is used to instruct the sending end to immediately adjust the sending rate of the first file to a safe sending rate.
The terminal 100 can determine the secure transmission rate according to the following equation (4).
c P/A3-FLS3/V2=0 formula (4)
Wherein, in the above formula (4), c is more than 0 and less than or equal to 1, c is a conservative coefficient, and c can be less than 1 in order to prevent the first buffer from actually overflowing, so that the terminal 100 can predict the overflow time of the first buffer to be earlier than the actual overflow time. X2 is the second buffer capacity, W3 refers to the buffered data amount of the first buffer, A3 is the buffered data growth rate of the first buffer, FLS3 refers to the pending data amount of the first file, and V2 may refer to the safe sending rate. The above formula (4) is only for explaining the present application and should not be construed as limiting.
In one possible implementation, the terminal 100 may monitor the network card receiving rate and the disk writing rate of the first file. The terminal 100 may determine the buffered data growth rate of the first buffer area according to the network card receiving rate and the disk writing rate of the first file. Therefore, the above formula (4) may be replaced with the following formula (5):
c P/(V2-rateIO 2) -FLS3/V2=0 equation (5)
Wherein, the rate IO2 is the disk writing rate of the first file. The above formula (5) is only for explaining the present application and should not be construed as limiting.
For example, after the terminal 100 adjusts the size of the first buffer to the second buffer capacity, the value P of the remaining buffer capacity of the first buffer may be 100MB, the value FLS3 of the amount of data to be transmitted of the first file may be 800MB, and the disk write rate rating io2 may be 150MBps. Therefore, the terminal 100 can determine that the secure transmission rate V2 is 166.67MBps. The above examples are merely illustrative of the present application and should not be construed as limiting.
The terminal 100 may transmit the first rate information to the transmitting end of the first file after determining the secure transmission rate. The first rate information is used for indicating the sending end to adjust the sending rate of the first file to the safe sending rate.
In some embodiments, when the ratio of the amount of data to be transmitted of the first file to the total amount of data of the first file is smaller than a specified ratio value (e.g., 0.1), the terminal 100 may immediately adjust the size of the first buffer to a third buffer capacity, where a ratio of the third buffer capacity to the available memory capacity is a third value, and the third value is greater than the first value and greater than the second value. When the amount of data to be transmitted of the first file is greater than 0 after the terminal 100 adjusts the size of the first buffer to the specified time (e.g., 3 seconds) of the third buffer capacity, the terminal 100 may re-execute the step S513.
For example, the specified ratio value may be 0.1, the total data amount of the first file may be 3000MB, the data amount to be transmitted of the first file may be 100MB, the third value may be 0.8, and the available memory capacity may be 1000MB. The terminal 100 may determine that the ratio of the amount of data to be transmitted of the first file to the total amount of data of the first file is 0.03 (less than 0.1), and then the terminal 100 may immediately adjust the size of the first buffer to be 800MB. After the terminal 100 adjusts the size of the first buffer to be 3 seconds of 800MB, and the amount of data to be transmitted of the first file is still greater than 0, the terminal 100 may re-execute the step S513. The above examples are merely illustrative of the present application and should not be construed as limiting.
The embodiment 1 of the present application provides a buffer management method, which can adjust the size of a buffer according to factors such as buffered data of the buffer, an available memory, a network card receiving rate, a disk writing rate, an available memory capacity, and the like, and a frequency of receiving user interaction operations in a process of receiving file data by a terminal. Under different scenes, the size of the buffer area is adjusted, and more storage space is applied for the buffer area as much as possible. Therefore, the overflow probability of the buffer area during high-speed file data transmission can be reduced, and the packet loss rate is reduced.
A data transmission method and related contents provided in the second part of the embodiment of the present application are described below with reference to fig. 6 to 11.
The ordinal numbers of some of the terms in the second portion of the embodiments of the present application do not continue in the order in which they are used in other portions of the embodiments of the present application, and the terms in the second portion of the embodiments of the present application are used only in the second portion of the embodiments of the present application.
A second part of the embodiments of the present application provides a data transmission method, including: the first terminal and the second terminal establish a file transmission connection, and the file transmission connection is used for transmitting the first file. The first terminal acquires the upper limit of the physical layer sending rate of the network card. And the first terminal determines a first rate according to the upper limit of the physical layer sending rate. The first terminal writes the first data of the first file into the transmission buffer qdisk _ buffer of the MAC layer at the first speed, and sends the first data of the first file in the transmission buffer of the MAC layer to the second terminal through the network card. When the first terminal determines that the buffered data volume of the MAC layer sending buffer zone is larger than or equal to a first early warning waterline, the first terminal writes second data of the first file into the MAC layer sending buffer zone at a second speed, and sends the second data of the first file in the MAC layer sending buffer zone to the second terminal through the network card, wherein the first speed is larger than the second speed.
By the method for data transmission provided in the second part of the embodiment of the present application, the buffer capacity and the first early warning water line of the MAC layer transmission buffer (qdisk _ buffer) of the transmission end 210 may be set, and the transmission rate at which the transmission end 210 writes the data of the first file into the MAC layer transmission buffer is determined according to the buffered data amount of the MAC layer transmission buffer (qdisk _ buffer), so that the transmission speed of the file approaches the limit rate of the physical channel and the packet loss rate is reduced.
Fig. 6 shows an architectural schematic of the system 20.
As shown in fig. 6, the system 20 includes a transmitting terminal 210 and a receiving terminal 220. Wherein, the sending terminal 210 and the receiving terminal 220 can transmit the file data point to point through the wireless network. The transmitting terminal 210 and the receiving terminal 220 may transmit the file data through Wi-Fi direct (e.g., wireless fidelity peer to peer, wi-Fi P2P)), wi-Fi softAP, ultra-wideband (UWB), and other communication technologies. The device types of the sending terminal 210 and the receiving terminal 220 may include a mobile phone, a television, a tablet computer, a sound box, a watch, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), an Augmented Reality (AR) \ Virtual Reality (VR) device, and the like, and the specific type of the terminal is not particularly limited in the embodiments of the present application.
An architecture diagram of a data transmission system provided in the second part of the embodiments of the present application is described below.
Referring to fig. 7, fig. 7 is a diagram illustrating an architecture of a data transmission system 400 provided in the second part of the embodiment of the present application. The data transmission system 400 may include a transmitting terminal 210 and a receiving terminal 220. In the embodiment of the present application, the transmitting terminal 210 may be referred to as a first terminal, and the receiving terminal 220 may be referred to as a second terminal. The software systems on the sending terminal 210 and the receiving terminal 220 may adopt a layered architecture, and the layered architecture divides the software into a plurality of layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. The software system of the sending terminal 210 and the receiving terminal 220 may include a user mode, a kernel mode, and a hardware layer. The user mode may include an application layer and a minimalist protocol layer. The kernel states may include a Socket abstraction layer, a user data protocol layer (UDP layer)/network layer (IP layer), and a MAC layer. The hardware layer may include a Network Interface Controller (NIC).
The application layer of the transmitting terminal 210 may include one or more applications. For example, the application 211 may be a data sharing application such as huawei share (huawei share).
The minimalist protocol layer of the transmitting terminal 210 may include a transmission rate scheduling module 212 and a read buffer 213. The read buffer 213 can be used to buffer the file data read from the disk by the sending terminal 210 into the memory. The transmission rate scheduling module 212 may be used to set the buffer capacity and the early warning water line of a designated buffer or buffers (e.g., the MAC layer transmission buffer 215) in the transmitting terminal 210. The transmission rate scheduling module 212 may also be used to adjust the data writing rate of the MAC layer transmission buffer 215 according to the buffer level of one or more buffers (e.g., the MAC layer transmission buffer 215) in the transmitting terminal 210 and the buffer information transmitted by the transmission rate feedback module 222 on the receiving terminal 220. Wherein the buffer information may be used to indicate buffered water lines for one or more buffers (e.g., write buffer 223 and MAC layer receive buffer 226) on the receiving terminal 220.
The socket abstraction layer of the sending terminal 210 may include a socket send buffer (socket send buffer) 214. The socket send buffer 214 can be used to buffer data written by the process of the application 211 in the sending terminal 210 to the corresponding socket.
The UDP layer/IP layer of the transmitting terminal 210 may encapsulate the file data delivered by the socket abstraction layer into a data packet (e.g., a UDP data packet or an IP data packet), and deliver the data packet to the MAC layer.
The MAC layer of the transmitting terminal 210 may include a MAC layer transmission buffer (qdisk _ buffer) 215. The MAC layer transmission buffer 215 may be used to buffer data packets (e.g., UDP data packets/IP data packets) transmitted by the UDP layer/IP layer. The MAC layer may be configured to sequentially extract data packets from the MAC layer transmit buffer 215, and encapsulate the data packets into MAC data frames to be sent to the network card.
The network card of the sending terminal 210 may include a network card sending buffer 216, and the buffer type of the network card sending buffer 216 may be a ring buffer (ring _ buffer). The network card transmission buffer 216 may be used to buffer MAC packets sent by the MAC layer. The network card of the transmitting terminal 210 may be configured to sequentially extract MAC data frames from the network card transmission buffer 216 and convert the MAC data frames into physical frames, and transmit the physical frames to the receiving terminal 220 in a point-to-point manner through the wireless network.
The application layer of the receiving terminal 220 may include one or more applications. For example, the application 221 may be a data sharing application such as huashi sharing.
The very simple protocol layer of the receiving terminal 220 may include a transmission rate feedback module 222 and a write buffer (write _ buffer) 223. The write buffer 223 can be used to buffer the file data that the receiving terminal 220 fetches from the socket receiving buffer 224, and the receiving terminal 220 can sequentially fetch the file data from the write buffer 223 and write the file data to the disk. The transmission rate feedback module 222 may be used to set the buffer capacity and the early warning horizon for one or more buffers (e.g., write buffer 223 and MAC layer receive buffer 226) on the receiving terminal 220. The sending rate feedback module 222 is further configured to obtain buffering information of the one or more buffers of the receiving terminal 220, and send the buffering information to the sending rate scheduling module 212 of the sending terminal 210. Wherein the buffer information may be used to indicate buffered water lines for one or more buffers (e.g., write buffer 223 and MAC layer receive buffer 226) on the receiving terminal 220.
The socket abstraction layer of the receiving terminal 220 may include a socket receive buffer (socket receive buffer) 224. The socket receiving buffer 224 can be used to buffer the file data reported by the UDP layer/IP layer. The receiving terminal 220 can copy the file data from the socket receiving buffer 224 into the write buffer 223.
When the receiving terminal 220 directly obtains the IP packet from the MAC layer, the UDP layer/IP layer of the receiving terminal 220 may include an IP fragment reassembly buffer (IP _ defrag _ buffer) 225. After acquiring the parsed IP data packets from the MAC layer, the receiving terminal 220 may sequentially store the IP data packets into the IP fragment reassembly buffer 225, and then the receiving terminal 220 may sequentially take out the IP data packets from the IP fragment reassembly buffer 225, reassemble the IP data packets into a reassembled data packet according to the fragments, and place the reassembled data packet into the socket receiving buffer 224 after performing logical processing of the UDP layer/IP layer.
The MAC layer of the receiving terminal 220 may include a MAC layer reception buffer (netdev _ backlog _ buffer) 226. The MAC layer receive buffer 226 may be used to buffer MAC packets obtained from the network card. The receiving terminal 220 may sequentially extract MAC data frames from the MAC layer reception buffer 226, perform logical processing of the MAC layer, and report the UDP packet/IP packet obtained after the processing to the UDP layer/IP layer.
The network card of the receiving terminal 220 may include a network card receiving buffer 227. The buffer type of the network card receiving buffer 227 may be a ring buffer (ring _ buffer). The network card receive buffer 227 may be used to buffer MAC data frames parsed from received physical frames by the receiving terminal 220. The receiving terminal 220 may sequentially extract the MAC data frames from the network card receiving buffer 227, and perform logical processing of the MAC layer to parse the UDP packet/IP packet.
The following describes exemplary software workflow of the sending terminal 210 and the receiving terminal 220 in conjunction with a file transfer scenario.
The transmission rate scheduling module 212 may set the buffer capacity of a plurality of buffers on the transmitting terminal 210 before the transmitting terminal 210 transmits file data to the receiving terminal 220. The sending rate scheduling module 212 may set the buffer capacity and the early warning waterline of the MAC layer sending buffer 215 according to the maximum transmission rate and the transmission round trip delay of the physical channel. The transmission rate feedback module 222 may set the buffering capacity of a plurality of buffers at the receiving terminal 220. The sending rate feedback module 222 may set the buffer capacity and the early warning water level of the MAC layer sending buffer 215 and the write buffer 223 according to the maximum transmission rate and the transmission round trip delay of the physical channel.
The application 211 of the sending terminal 210 may issue a file sending request for the first file to the minimalist protocol layer, which requests the minimalist protocol layer to read the file data of the first file from a disk (i.e., read Only Memory (ROM)) into the read buffer 213, and then copy the file data from the read buffer 213 into the socket sending buffer 214. For example, the application 211 calls the minimalist protocol layer to read file data from the disk into the read buffer 213 through the file sending call interface send _ file ().
The minimalist protocol layer of the transmitting terminal 210 may copy the file data in the read buffer 213 to the socket transmit buffer 214 by calling the socket transmit interface socket _ sendto ().
The socket abstraction layer of the transmitting terminal 210 may call a UDP packet transmission interface (e.g., UDP _ sendmsg ()) to fetch file data from the socket transmission buffer 214 and send it down to the UDP layer.
The UDP layer of the sending terminal 210 may encapsulate the file data into a UDP packet, call an IP packet sending interface (e.g., IP _ queue _ xmit ()), trigger the IP layer to set a route, create an IP protocol header and an IP option, and encapsulate the UDP packet into an IP packet. The IP layer may send the IP packets down the MAC layer transmit buffer 215.
In one possible implementation, data transmission between the sending terminal 210 and the receiving terminal 220 does not need to be routed due to close-range end-to-end transmission between the sending terminal 210 and the receiving terminal 220. The transmitting terminal 210 may include a UDP layer, not an IP layer. The UDP layer of the transmitting terminal 210 may encapsulate the file data into UDP packets, and then directly send the UDP packets to the MAC layer transmission buffer 215.
The MAC layer of the sending terminal 210 may take out a data packet (e.g., a UDP data packet or an IP data packet) from the MAC layer sending buffer 215, encapsulate the data packet into a MAC data packet, and call a network card sending interface (e.g., hard _ start _ xmit () or net _ tx _ action ()) to send the MAC data packet to the network card sending buffer 216 in the network card.
The network card of the transmitting terminal 210 may take out the MAC packet from the network card transmission buffer 216, and encapsulate the MAC packet into a data frame to be transmitted to the receiving terminal 220.
The network card of the receiving terminal 220 may store the data frame sent by the sending terminal 210 into the network card receiving buffer 227. The network card of the receiving terminal 220 may parse the MAC packet from the data frame and send the MAC packet to the MAC layer receive buffer 226 through a network card receive interface (e.g., net _ rx _ action () or netif _ receive _ skb ()).
The MAC layer of the receiving terminal 220 may extract the MAC packet from the MAC layer reception buffer 226, parse the IP packet from the MAC packet, and then send the IP packet up to the IP layer by calling an IP packet reception interface (e.g., IP _ rcv ()).
The IP layer of the receiving terminal 220 may store the IP packets obtained from the MAC layer in the IP fragment reassembly buffer 225, and then the IP layer may take out the IP packets from the IP fragment reassembly buffer 225, reassemble the IP packets belonging to the same fragment into a UDP packet, and upload the UDP packet to the UDP layer.
The UDP layer of the receiving terminal 220 may parse out the file data from the UDP packet and upload the file data into the socket reception buffer 224 of the socket abstraction layer by calling the UDP reception interface (e.g., UDP _ rcv ()).
The socket abstraction layer of the receiving terminal 220 may copy the file data in the socket receive buffer 224 to the write buffer 223 of the minifile protocol layer.
The application 221 of the receiving terminal 220 may fetch the file data from the write buffer 223 and write the file data to the disk of the receiving terminal 220 by calling a file write interface (e.g., write _ file ()).
In the data transmission system 400, at least three types of physical storage media may be included for both the sending terminal 210 and the receiving terminal 220: a magnetic disk (i.e., ROM), a running memory (i.e., random Access Memory (RAM)), and a network card storage. The disk can still retain data after power failure, and can be used for storing document, picture, music, video and other file data. The run-time memory may be used for temporary data generated during the operation of the operating system and applications. The network card may include a memory for temporarily storing data frames to be transmitted or received. The read buffer 213, the socket send buffer 214, and the MAC layer send buffer 215 on the sending terminal 210 are established on the operating memory of the sending terminal 210. The network card transmit buffer 216 on the transmitting terminal 210 is built on the network card of the transmitting terminal 211. The write buffer 223, socket receive buffer 224, IP fragment reassembly buffer 225, and MAC layer receive buffer 226 of the receiving terminal 220 are established on the receiving terminal 220. The network card receive buffer 227 of the receiving terminal 220 is established on the network card of the receiving terminal 220.
Generally, the data transmission rate between two buffers in the same physical storage medium is relatively fast and higher than the maximum transmission rate of a physical channel. For example, the data fetch rate in the socket transmit buffer 214 in the transmitting terminal 210 may reach the maximum transmission rate of the physical channel. The UDP layer/IP layer of the transmitting terminal 210 may also process data at a rate up to the maximum transmission rate of the physical channel. As another example, the data extraction rate in the socket receive buffer 224 in the receiving terminal 220 may reach the maximum transmission rate of the physical channel.
However, when the IP layer of the sending terminal 210 uses IP fragment transmission, the IP layer of the receiving terminal 220 needs to integrate the received IP packets into one data packet according to the sequence number of the IP packets, and at this time, the receiving terminal 220 must wait for the IP packets in a sequence number range to be completely received before integrating into one data packet in sequence. The receiving terminal 220 does not receive the IP data packets in the same time sequence as the sequence numbers of the IP data packets. Therefore, the receiving terminal 220 may spend a long time waiting for all IP packets within a sequence number range, and if there are IP packets missing in a plurality of sequence number ranges, the IP layer cannot timely reassemble the plurality of IP packets within each sequence number range into a data packet, which may easily cause overflow of the IP fragment reassembly buffer (IP _ defrag _ buffer) 225.
The data transfer rate between two buffers in different physical storage media is mainly influenced by the CPU power and the I/O power. For example, the backlog degree of the data in the MAC layer transmission buffer 215 on the transmitting terminal 210 is influenced by the channel capacity and the CPU capacity of the transmitting terminal 210, wherein the data fetching rate in the MAC layer transmission buffer 215 is mainly limited by the network card and is secondarily limited by the CPU soft interrupt load. The CPU power of the receiving terminal 220 affects the rate at which the kernel mode takes data out of the network card and puts the data into the MAC layer receive buffer 226, and thus the backlog of data in the MAC layer receive buffer 226 is affected by the CPU power of the receiving terminal 220. The I/O computational power of the receiving terminal 220 affects the rate at which data is retrieved from the write buffer 223 and written to disk.
Therefore, in the embodiment of the present application, the rate of the MAC layer transmission buffer 215 to which the file data is written may be controlled based on one or more of the MAC layer transmission buffer (qdisk _ buffer) 215, the MAC layer reception buffer (netdev _ backing _ buffer) 226, the IP fragment reassembly buffer (IP _ defrag _ buffer) 225, and the write buffer (write _ buffer) 223. Wherein, in the process of transmitting the file data from the transmitting terminal 210 to the receiving terminal 220, the sending rate feedback module 222 in the receiving terminal 220 may feed back the buffered water line of the MAC layer receiving buffer 226 and the buffered water line of the writing buffer 223 to the sending rate scheduling module 212 of the transmitting terminal 210. The transmit rate scheduling module 212 may also obtain the buffered water line of the MAC layer transmit buffer 215. The transmission rate scheduling module 212 may control the rate at which the transmitting terminal 210 writes file data to the MAC layer transmit buffer 215 based on the waterline of the one or more buffers. When the one or more buffers are all lower than the early warning waterline, the sending terminal 210 writes the file data into the MAC layer sending buffer 215 at the network card limit rate (for example, the physical negotiation rate is 90%), and sends the file data in the MAC layer sending buffer 215 to the network card, and sends a receiving terminal 220 through the network card. When any of the one or more buffers exceeds the early warning waterline, the sending terminal 210 may reduce the rate of writing the file data into the MAC layer sending buffer 215 (e.g., 10% of the upper limit of the physical layer sending rate), and wait until the contents of the one or more buffers are all consumed, and the sending terminal 210 resumes reading the file data from the body storage into the read buffer 213 at the network card limit rate (e.g., 90% of the upper limit of the physical layer sending rate). Thus, the file transmission speed is close to the physical channel limit, and the packet loss rate is reduced.
A data transmission method provided in the second section of the embodiment of the present application is described below.
Referring to fig. 8, fig. 8 is a schematic flowchart illustrating a data transmission method provided in the second part of the embodiment of the present application. Among them, the transmitting terminal 210 may be referred to as a first terminal, and the receiving terminal 220 may be referred to as a second terminal. As shown in fig. 8, the method may include the steps of:
s801, the sending terminal 210 obtains a transmission request for the first file.
The first file may be a picture, video, document, etc. type file. The first file may be stored in a body memory of the transmitting terminal 210. The sending terminal 210 may obtain a transmission request for the first file input by the user, where the transmission request may include a storage address of the first file and address information (e.g., an IP address or a MAC address, etc.) of the receiving terminal 220.
For example, the user may open a sharing interface on the sending terminal 210 for the video file, which may include options for one or more devices discovered by the sending terminal 210, where the one or more devices may include the receiving terminal 220. When the sending terminal 210 receives an input operation of selecting an option corresponding to the receiving terminal 220 by a user, the sending terminal 210 may acquire a transmission request for the video file.
S802, the sending terminal 210 establishes a file transmission connection with the receiving terminal 220.
After the sending terminal 210 obtains the transmission request of the first file, the sending terminal 210 may establish a file transmission connection with the receiving terminal 220 according to the address information of the receiving terminal 220. The file transfer connection may include a Wi-Fi direct (e.g., wi-Fi P2P), wi-Fi softAP, ultra Wide Band (UWB), bluetooth, or other communication connection.
S803, the sending terminal 210 obtains the physical layer transmission rate upper limit Vmax and the feedback time Ts of the MAC layer.
The physical layer transmission rate upper limit Vmax may be preset on the transmitting terminal 210. For example, when the transmitting terminal 210 and the receiving terminal 220 are configured with 2 × 2 MIMO antennas and the connection network between the transmitting terminal 210 and the receiving terminal 220 is a Wi-Fi 5-based wireless local area network, the physical layer transmission rate upper limit Vmax may be 1Gbps. When the transmitting terminal 210 and the receiving terminal 220 are configured with 2 × 2 MIMO antennas and the connection network between the transmitting terminal 210 and the receiving terminal 220 is a Wi-Fi 6-based wireless local area network, the physical layer transmission rate upper limit Vmax may be 2.4Gbps.
In a possible implementation manner, after the sending terminal 210 establishes the file transfer connection with the receiving terminal 220, the sending terminal 210 may negotiate a physical layer sending rate upper limit Vmax of a network card of the sending terminal 210 with the receiving terminal 220.
Before the sending terminal 210 starts to transmit the data of the first file, the MAC layer of the sending terminal 210 may report the measurement data packet to a sending rate scheduling module of an upper layer. The measurement data packet includes a time for the MAC layer to report the measurement data packet, and the sending rate scheduling module of the sending terminal 210 may record the time for obtaining the measurement data packet after obtaining the measurement data packet. The sending terminal 210 may determine the feedback time Ts of the MAC layer according to the time when the MAC layer reports the measurement data packet and the time when the first terminal obtains the measurement data packet.
S804, the sending terminal 210 determines the buffer capacity of the MAC layer sending buffer and the first early warning waterline according to the physical layer sending rate upper limit Vmax and the feedback time Ts of the MAC layer.
As shown in fig. 9, the buffer may be an abstract model of any one of the above MAC layer transmission buffer, the MAC layer reception buffer on the receiving terminal 220, the IP fragment reassembly buffer IP _ defrag _ buffer on the receiving terminal 220, and the write buffer on the receiving terminal 220.
The total capacity of the MAC buffer may be M, and the first early warning water level line may be a × M, so that when the buffer water level line in the buffer is at the first early warning water level line, the remaining capacity of the buffer is (1-a) × M. Wherein, A is more than 0 and less than 1.
Because the highest transmission rate needs to be ensured as much as possible, and the packet loss rate needs to be reduced, the amount of buffered data in the MAC layer transmission buffer needs to be monitored, which cannot be empty or overflow. If the buffered data amount of the MAC layer sending buffer reaches the first early warning waterline a × M at the time t, and the buffered data amount of the MAC layer sending buffer continues to increase at the time t + Δ t, and it is to be ensured that the MAC layer sending buffer does not overflow, the MAC layer of the sending terminal 210 needs to report the first indication information to the upper sending rate scheduling module, so that the upper sending rate scheduling module reduces the rate at which the data of the first file is written into the MAC layer sending buffer. The maximum time taken for this process is Ts. If the buffered data volume of the buffer reaches the first early warning water level line a × M at the time t and the buffered data volume continues to decrease at the time t + Δ t, it is ensured that the MAC layer readjusts the normal sending rate (again, time Ts) after a feedback of an error is given to the sending rate scheduling module (time 0.5 RTT).
Therefore, the transmitting terminal 210 can determine the buffer capacity of the MAC layer transmission buffer and the early warning water level line by the following formula (6) and formula (7) according to the physical layer transmission rate upper limit Vmax and the feedback time Ts of the MAC layer.
(1-A) M/Vmax ≧ Ts formula (6)
(A M)/Vmax ≥ 2 Ts formula (7)
Wherein the buffer capacity M of the buffer should satisfy the minimum value in the ranges defined by the above equations (6) and (7).
Illustratively, vmax can be 2.4Gbps (300 MB/s), ts can be 2ms, and M.gtoreq.1.8MB, A =2/3 can be calculated according to the above formula (6) and formula (7). Therefore, the transmitting terminal 220 may set the capacity of the transmission buffer to 1.8MB and the first pre-warning water line to 1.2MB.
In one possible implementation, the unit of the buffer capacity of the buffer may be the number of maximum length packets, and after calculating the buffer capacity of the buffer in Megabytes (MB) according to the above equations (6) and (7), the buffer capacity of the buffer in number of packets may be obtained by performing conversion according to the maximum length of the packets. For example, M is 1.2MB, a maximum of 1500 bytes (Byte) can be a packet, and the buffer capacity of the buffer is 800 packets.
In one possible implementation, the first warning waterline may be preset, and the transmitting terminal 210 may determine the buffer capacity of the MAC layer buffer according to the above equation (6) and equation (7).
In a possible implementation manner, the buffer capacity of the MAC layer buffer may be preset, and the transmitting terminal 210 may determine the first warning waterline according to the above equation (6) and equation (7).
S805, after the sending terminal 210 sets the buffer capacity and the first early warning waterline of the MAC layer sending buffer, the sending terminal 210 may write the first data of the first file into the MAC layer sending buffer at the first rate.
S806, the sending terminal 210 sends the first data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
The sending terminal 210 may determine the first rate according to the upper limit of the physical layer sending rate. The first rate may be a value close to an upper limit of a physical layer transmission rate. The physical layer sending rate cap is a sending rate cap that can be supported by the network card of the sending terminal 210. For example, the first rate may be 90% of the maximum rate of the physical layer. When the physical layer transmission rate is capped at 2.4Gbps, the first rate may be 2.16Gbps.
The process of writing the first data of the first file into the MAC layer sending buffer after the sending terminal 210 reads the first data of the first file from the disk at the first rate may refer to the embodiment shown in fig. 7, and is not described herein again.
After sending the first data of the first file to the MAC layer sending buffer, the sending terminal 210 may obtain the first data of the first file from the MAC layer sending buffer through the network card, encapsulate the first data into a data frame, and send the data frame to the receiving terminal 220.
After receiving the data frame sent by the sending terminal 210, the network card of the receiving terminal 220 may parse the MAC data packet from the data frame and send the MAC data packet to the MAC layer receiving buffer, and then the receiving terminal 220 may take out the data of the first file from the MAC layer receiving buffer and send the data of the first file to the writing buffer. Then, the receiving terminal 220 writes the data of the first file in the write buffer into the disk of the receiving terminal 220. The process of the receiving terminal 220 extracting the data of the first file from the MAC layer receive buffer and uploading the data to the write buffer may refer to the embodiment shown in fig. 7, which is not described herein again.
S807, the sending terminal 210 monitors whether the buffered data amount of the MAC layer sending buffer is larger than or equal to the first early warning waterline. If so, step S808 is executed, and the transmitting terminal 210 may determine whether the remaining capacity of the MAC layer transmission buffer is smaller than the data amount to be transmitted of the first file. When the remaining capacity of the MAC layer transmission buffer is smaller than the amount of data to be transmitted of the first file, S809 is executed, and the transmitting terminal 210 writes the second data of the first file into the MAC layer transmission buffer at the second rate.
S810, the sending terminal 210 may send the second data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
S811, after the sending terminal 210 sends the second data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card, the sending terminal 210 may determine whether the buffered data amount in the MAC layer sending buffer is smaller than the first specified threshold, if yes, execute S812, where the sending terminal 210 sends the third data written in the first file in the MAC layer sending buffer at the first rate.
S813, the sending terminal 210 may send the third data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
Wherein the second rate is less than the first rate. For example, the first rate may be 90% of the upper physical layer transmission rate limit, and the second rate may be 10% or 0 of the upper physical layer transmission rate limit. When the second rate is 0, the sending terminal 210 stops reading the data of the first file from the disk. And the first designated threshold value is smaller than the buffer capacity of the MAC layer sending buffer zone when the first early warning waterline is smaller than the first early warning waterline.
When the sending terminal 210 monitors that the buffered data amount of the MAC layer sending buffer is greater than or equal to the first early warning waterline and the remaining capacity of the MAC layer sending buffer is less than the to-be-sent data amount of the first file, the sending terminal 210 writes the second data of the first file into the MAC layer sending buffer at the second rate, and sends the second data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card. The network card of the transmitting terminal 210 extracts the data of the first file from the MAC layer transmission buffer at the maximum rate as possible, and transmits the data to the receiving terminal 220. Thereafter, when the sending terminal 210 monitors that the data amount of the MAC layer transmission buffer is less than or equal to a first specified threshold (for example, 10% or 0 of the total capacity of the MAC layer transmission buffer), the sending terminal 210 may write the third data of the first file into the MAC layer transmission buffer at a first rate, and send the third data of the first file in the MAC layer transmission buffer to the receiving terminal 220 through the network card. The network card of the transmitting terminal 210 still extracts the data of the first file from the MAC layer transmission buffer at the maximum rate as possible, and transmits the data to the receiving terminal 220.
Illustratively, the data size of the first file is 800MB, the physical layer transmission rate upper limit Vmax may be 2.4Gbps (300 MB/s), the feedback time Ts of the MAC layer may be 2ms, the buffer capacity of the MAC layer transmission buffer may be 1.8MB, and the first early warning waterline may be 1.2MB. The first rate may be 90% of the upper physical layer delivery rate limit Vmax, i.e., 2.16Gbps (270 MB/s), and the second rate may be 10% of the upper physical layer delivery rate limit Vmax, i.e., 0.24Gbps (30 MB/s). The first specific threshold may be 10% of the buffer capacity of the MAC layer transmission buffer, i.e., 0.18MB.
After the transmitting terminal 210 sets the buffer capacity of the MAC layer transmit buffer and the first early warning water line, the transmitting terminal 210 may write the first data of the first file to the MAC layer transmit buffer at a rate of 2.16Gbps (270 MB/s). The network card of the sending terminal 210 may extract the first data of the first file from the MAC layer sending buffer at the maximum rate as much as possible, and send the first data to the receiving terminal 220.
When the transmitting terminal 210 monitors that the amount of buffered data of the MAC layer transmission buffer has reached 1.2MB, the remaining capacity of the MAC layer transmission buffer is 0.6MB. If the amount of data to be sent of the first file is 600MB, at this time, the remaining capacity of the MAC layer send buffer is smaller than the amount of data to be sent of the first file, and the sending terminal 210 may write the second data of the first file into the MAC layer send buffer at a rate of 0.24Gbps (30 MB/s). The network card of the sending terminal 210 may extract the second data of the first file from the MAC layer sending buffer at the maximum rate as much as possible, and send the second data to the receiving terminal 220.
Since the rate at which the sending terminal 210 reads the data of the first file is reduced, and the network card also fetches the data of the first file from the MAC layer transmission buffer at the maximum rate as possible and transmits to the receiving terminal 220, the amount of data in the MAC layer transmission buffer is reduced. When the transmitting terminal 210 monitors that the amount of data in the MAC layer transmit buffer has dropped to 0.18MB (10% of the total capacity), the transmitting terminal 210 may write the third data of the first file to the MAC layer transmit buffer at 2.16Gbps (270 MB/s). The network card of the sending terminal 210 may extract the third data of the first file from the MAC layer sending buffer at the maximum rate as much as possible, and send the third data to the receiving terminal 220.
The above examples are merely illustrative of the present application and should not be construed as limiting.
In a possible implementation manner, when the sending terminal 210 monitors that the buffered data amount of the MAC layer sending buffer is greater than or equal to the first early warning waterline and the remaining capacity of the MAC layer sending buffer is greater than or equal to the to-be-sent data amount of the first file, the sending terminal 210 may continue to write the second data of the first file into the MAC layer sending buffer at the first rate, and send the second data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card. The network card of the transmitting terminal 210 extracts the data of the first file from the MAC layer transmission buffer at the maximum rate as possible, and transmits the data to the receiving terminal 220. Thus, when the remaining capacity of the MAC layer transmission buffer is sufficient to support the amount of the data to be transmitted of the first file, the transmitting terminal 210 can read the data of the first file at the limit rate and transmit the data to the receiving terminal 220, and the MAC layer transmission buffer does not overflow and lose packets.
In a possible implementation manner, when the sending terminal 210 monitors that the buffered data amount of the MAC layer sending buffer is smaller than the first early warning waterline, the sending terminal 210 may continue to write the second data of the first file into the MAC layer sending buffer at the first rate, and send the second data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
In some embodiments, the sending terminal 210 may determine the rate at which data of the first file is written to the MAC layer send buffer by simply monitoring the relationship between the amount of buffered data of the MAC layer send buffer and the first early warning waterline. Specifically, when the sending terminal 210 monitors that the buffered data amount of the MAC layer sending buffer is greater than or equal to the first early warning waterline, the sending terminal 210 may write the second data of the first file into the MAC layer sending buffer at the second rate, and send the second data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card. When the sending terminal 210 monitors that the buffered data amount of the MAC layer sending buffer is smaller than the first early warning water line, the sending terminal 210 may continue to send the second data, in which the first file is written, to the MAC layer at the first rate, and send the second data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
By the method for data transmission provided in the second part of the embodiment of the present application, the transmission speed of the file approaching the limit speed of the physical channel and reducing the packet loss rate can be achieved by setting the buffer capacity and the first early warning waterline of the MAC layer transmission buffer (qdisk _ buffer) of the transmitting end 210, and determining the transmission speed of the data written into the first file by the transmitting end 210 to the MAC layer transmission buffer according to the buffered data amount of the MAC layer transmission buffer (qdisk _ buffer).
Referring to fig. 10, fig. 10 is a flowchart illustrating a data transmission method provided in the second part of the present application. Among them, the transmitting terminal 210 may be referred to as a first terminal, and the receiving terminal 220 may be referred to as a second terminal. As shown in fig. 10, the method may include the steps of:
s1001, the transmitting terminal 210 obtains a transmission request for the first file.
For specific content, reference may be made to step S501 in the embodiment shown in fig. 8, which is not described herein again.
S1002, the sending terminal 210 establishes a file transfer connection with the receiving terminal 220.
For specific content, reference may be made to step S502 in the embodiment shown in fig. 8, which is not described herein again.
S1003, the receiving terminal 220 obtains the upper limit Vmax of the physical layer transmission rate of the sending terminal 210 and the round trip time RTT on the file transmission connection.
The physical layer transmission rate upper limit Vmax may be preset at the receiving terminal 220. For example, when the transmitting terminal 210 and the receiving terminal 220 are configured with 2 × 2 MIMO antennas and the connection network between the transmitting terminal 210 and the receiving terminal 220 is a Wi-Fi 5-based wireless local area network, the physical layer transmission rate upper limit Vmax may be 1Gbps. When the transmitting terminal 210 and the receiving terminal 220 are configured with 2 × 2 MIMO antennas and the connection network between the transmitting terminal 210 and the receiving terminal 220 is a Wi-Fi 6-based wireless local area network, the physical layer transmission rate upper limit Vmax may be 2.4Gbps.
The receiving terminal 220 may detect a round trip delay between the receiving terminal 220 and the transmitting terminal 210 after establishing a file transfer connection with the transmitting terminal 210. The receiving terminal 220 may send an ICMP packet to the sending terminal 210, and after receiving the ICMP packet, the sending terminal 210 may return a response packet to the receiving terminal 220. Then, the receiving terminal 220 may calculate the round trip delay RTT by the time when the ICMP packet is transmitted and the time when the response packet returned from the transmitting terminal 210 is received. In a possible implementation manner, the receiving terminal 220 may send an ICMP packet to the sending terminal 210 multiple times, and the receiving terminal 220 may determine the RTT according to time differences between multiple sending packets and multiple receiving packets. For example, the receiving terminal 210 may determine the RTT from the time difference between the sending and receiving of a plurality of packets. For another example, the receiving terminal 220 may determine the maximum value among the time differences between a plurality of transmitted packets and received packets as the RTT.
S1004, the receiving terminal 220 determines respective buffer capacities and a second early warning waterline of the IP fragment reassembly buffer and the write buffer according to the physical layer sending rate upper limit Vmax and the round trip time RTT.
The buffer capacities of the IP fragment reassembly buffer and the write buffer may both be m, and the second early warning waterline may be a × m, so that when the buffered waterline in the buffer is on the first early warning waterline, the remaining capacity of the buffer is (1-a) × m. Wherein a is more than 0 and less than 1.
Because it is necessary to ensure the highest transmission rate as possible and reduce the packet loss rate, it is necessary to monitor the buffered data amount of the IP fragment reassembly buffer (or write buffer) neither empty nor overflow. If the buffered data amount of the IP fragment reassembly buffer (or write buffer) reaches the second early warning waterline a × m at time t, and the buffered data amount of the IP fragment reassembly buffer (or write buffer) continues to increase at time t + Δ t, it is to be ensured that the IP fragment reassembly buffer (or write buffer) does not overflow, the receiving terminal 220 needs to send the buffering information to the sending rate scheduling module of the sending terminal 210, so that the sending rate scheduling module of the sending terminal 210 reduces the rate at which the data of the first file is written into the MAC layer sending buffer. The maximum time taken for this process is 0.5 rtt. If the buffered data amount in the buffer area reaches the second early warning water level a × m at the time t and the buffered data amount continues to decrease at the time t + Δ t, it is ensured that the receiving terminal 220 re-adjusts the sending rate back to the normal sending rate (again, 0.5 × RTT is consumed) after sending an error feedback (0.5 RTT is consumed).
Therefore, the sending terminal 210 can determine the buffer capacity of the IP fragment reassembly buffer and the write buffer and the second early warning waterline according to the physical layer transmission rate upper limit Vmax and the round trip delay RTT by the following formula (8) and formula (9).
(1-a) m)/Vmax ≧ 0.5 RTT equation (8)
(a x m)/Vmax is more than or equal to 0.5 x RTT +0.5 x RTT formula (9)
The receiving terminal 220 may set the buffer capacity of the IP fragment reassembly buffer and the write buffer and the second early warning waterline according to the physical layer transmission rate upper limit Vmax and the round trip delay RTT by using formula (8) and formula (9).
Illustratively, vmax may be 2.4Gbps (300 MB/s), RTT may be 16ms, and m ≧ 7.2MB may be calculated according to equations (8) and (9) above, and a =2/3. Therefore, the receiving terminal 220 may set the capacity of the receiving buffer and the capacity of the writing buffer to 7.2MB and the second warning water line to 4.8MB for the MAC layer.
In one possible implementation, the unit of the buffer capacity of the buffer may be the number of maximum length packets, and after calculating the buffer capacity of the buffer in Megabytes (MB) according to the above equations (8) and (9), the buffer capacity of the buffer in number of packets may be obtained by performing conversion according to the maximum length of the packets. For example, M is 7.2MB, a maximum of 1500 bytes (Byte) can be a packet, and the buffer capacity of the buffer is 4800 packets.
In a possible implementation manner, the second early warning waterline may be preset, and the transmitting terminal 210 may determine the buffer capacity of the IP fragment reassembly buffer and the write buffer according to the above equation (8) and equation (9).
In a possible implementation manner, the buffer capacities of the IP fragment reassembly buffer and the write buffer may be preset, and the sending terminal 210 may determine the second early warning waterline according to the above equation (8) and equation (9).
S1005, after the receiving terminal 220 sets the buffer capacity of the IP fragment reassembly buffer, the buffer capacity of the write buffer, and the second early warning bit line, the sending terminal 210 may write the first data of the first file into the MAC layer sending buffer at the first rate.
S1006, the sending terminal 210 sends the first data of the first file in the buffer to the MAC layer through the network card, and transmits the first data to the receiving terminal 220.
The sending terminal 210 may determine the first rate according to the upper limit of the physical layer sending rate. The first rate may be a value close to an upper limit of a physical layer transmission rate. The physical layer sending rate cap is a sending rate cap that can be supported by the network card of the sending terminal 210. For example, the first rate may be 90% of the maximum rate of the physical layer. When the physical layer transmission rate is capped at 2.4Gbps, the first rate may be 2.16Gbps.
The process of writing the first data of the first file into the MAC layer sending buffer after the sending terminal 210 reads the first data of the first file from the disk at the first rate may refer to the embodiment shown in fig. 7, and is not described herein again.
After the sending terminal 210 sends the first data of the first file to the MAC layer sending buffer, the first data of the first file may be obtained from the MAC layer sending buffer through the network card, and encapsulated into a data frame, and sent to the receiving terminal 220.
After receiving the data frame sent by the sending terminal 210, the network card of the receiving terminal 220 may parse the MAC data packet from the data frame and send the MAC data packet to the MAC layer receiving buffer, and then the receiving terminal 220 may take out the data of the first file from the MAC layer receiving buffer and send the data of the first file to the writing buffer. Then, the receiving terminal 220 writes the data of the first file in the write buffer into the disk of the receiving terminal 220. The process of the receiving terminal 220 extracting the data of the first file from the MAC layer receive buffer and uploading the data to the write buffer may refer to the embodiment shown in fig. 7, which is not described herein again.
S1007, the receiving terminal 220 may monitor whether the first buffer with the buffered data amount greater than or equal to the second early warning waterline exists in the IP fragment reassembly buffer and the write buffer, if so, execute S1008, and the receiving terminal 220 may determine whether the remaining capacity in the first buffer is less than the data amount to be sent in the first file. If yes, S1009 is executed, and the receiving terminal 220 may feed back the first buffering information to the sending terminal 210.
S1010, after receiving the first buffering information, the sending terminal 210 may write the fourth data of the first file into the MAC layer sending buffer at a third rate (e.g. 10% or 0 of the upper limit of the physical layer sending rate) in response to the first buffering information.
S1011, the sending terminal 210 sends the fourth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
The third rate is less than the first rate. For example, the third rate may be 10% of the upper limit of the physical layer transmission rate of the transmitting end 210, and so on.
When the sending terminal 210 establishes a file transmission connection with the receiving terminal 220, the sending terminal 210 may send the total data volume of the first file to the receiving terminal 220. The receiving terminal 220 may count the received data amount of the first file, and then the receiving terminal 220 may determine the data amount to be sent of the first file according to the total data amount and the received data amount of the first file.
The receiving terminal 220 may monitor the buffered data amount of the IP fragment reassembly buffer and the write buffer, and when it is monitored that the buffered data amount of a first buffer in the IP fragment reassembly buffer and the write buffer is greater than or equal to the early warning waterline and the remaining capacity of the first buffer is smaller than the to-be-sent data amount of the first file, the receiving terminal 220 may feed back first buffering information to the sending terminal 210, where the first buffering information may be used to instruct the sending terminal 210 to send, to the MAC layer, fourth data in which the first file is written in the buffer at a third rate. After receiving the first buffering information, the sending terminal 210 may write the fourth data of the first file into the MAC layer sending buffer at the third rate, and send the fourth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card. In this way, when the MAC layer of the receiving terminal 220 receives the buffered water line of the buffer area or the write buffer area exceeds the second early warning water line, and the remaining capacity of the IP fragment reassembly buffer area or the write buffer area is not enough to support the amount of data to be sent of the first file, the sending terminal 210 reduces the data to be read of the first file, and then the sending rate of the network card of the sending terminal 210 is reduced, so that the IP fragment reassembly buffer area or the write buffer area on the receiving terminal 220 does not overflow or lose packets.
When the receiving terminal 220 monitors that the buffered data amount of the first buffer in the MAC layer and the write buffer is greater than or equal to the second early warning waterline and the remaining capacity of the first buffer is greater than or equal to the to-be-sent data amount of the first file, the receiving terminal 220 does not need to notify the sending terminal 210, the sending terminal 210 continues to send fourth data of the first file written in the buffer to the MAC layer at the first rate, and sends the fourth data of the first file in the MAC layer send buffer to the receiving terminal 220 through the network card. Thus, when the remaining capacity of the IP fragment reassembly buffer and the write buffer is sufficient to support the amount of data to be sent of the first file, the sending terminal 210 may read the data of the first file at the limit rate and send the data to the receiving terminal 220, and the IP fragment reassembly buffer and the write buffer on the receiving terminal 220 will not overflow and lose packets.
In a possible implementation manner, when the receiving terminal 220 monitors that the buffered data amount of the first buffer in the MAC layer and the write buffer is less than or equal to the second early warning waterline, the receiving terminal 220 does not need to notify the sending terminal 210, the sending terminal 210 continues to write the fourth data of the first file into the MAC layer sending buffer at the first rate, and sends the fourth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
In some embodiments, the receiving terminal 220 may determine whether to trigger the sending terminal 210 to reduce the rate at which data of the first file is written to the MAC layer sending buffer by only monitoring the relation between the buffered data amount of the first buffer and the second early warning waterline. Specifically, when the receiving terminal 220 monitors that the buffered data amount of the first buffer area is greater than or equal to the first early warning water level line, the receiving terminal 220 sends the first buffering information to the sending terminal 210. The sending terminal 210 may write the fourth data of the first file into the MAC layer send buffer at the third rate in response to the first buffer information, and send the fourth data of the first file in the MAC layer send buffer to the receiving terminal 220 through the network card. When the receiving terminal 220 monitors that the buffered data amount of the first buffer area is smaller than the second early warning water level line, the receiving terminal 220 does not need to send the first buffer information to the sending terminal 210. The sending terminal 210 may continue to write the fourth data of the first file into the MAC layer send buffer at the first rate, and send the fourth data of the first file in the MAC layer send buffer to the receiving terminal 220 through the network card.
S1012, after the receiving terminal 220 feeds back the first buffering information to the sending terminal 210, the receiving terminal 220 may determine whether the buffered data amount in the first buffer is smaller than a second specified threshold. If yes, step S1013 is executed in which the receiving terminal 220 feeds back the second buffering information to the sending terminal 210.
S1014, after receiving the second buffering information fed back by the receiving terminal 220, the sending terminal 210 may send, at the first rate, the fifth data written with the first file in the buffer to the MAC layer in response to the second buffering information.
S1015, the sending terminal 210 sends the fifth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
After the receiving terminal 220 feeds back the first buffering information to the transmitting terminal 210, when the receiving terminal 220 detects that the amount of buffered data in the first buffer is less than or equal to a second specified threshold (e.g., 10% or 0 of the total capacity of the IP fragment reassembly buffer or the write buffer), the receiving terminal 220 may feed back the second buffering information to the transmitting terminal 210. Wherein the second buffering information may be used to instruct the transmitting terminal 210 to transmit fifth data written with the first file in the buffer to the MAC layer at the first rate. After receiving the second buffering information fed back by the receiving terminal 220, the sending terminal 210 may write the fifth data of the first file into the MAC layer sending buffer at the first rate, and send the fifth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
In a possible implementation manner, after the sending terminal 210 receives the second buffering information fed back by the receiving terminal 220, if the buffering waterline of the MAC layer sending buffer is greater than or equal to the first early warning waterline and the remaining capacity of the MAC layer sending buffer is less than or equal to the amount of the to-be-sent data of the first file, the sending terminal 210 writes the data of the first file in the MAC layer sending buffer at the second rate, and sends the data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
In a possible implementation manner, after the sending terminal 210 receives the second buffering information fed back by the receiving terminal 220, if the buffering waterline of the MAC layer sending buffer is greater than or equal to the first early warning waterline and the remaining capacity of the MAC layer sending buffer is smaller than the to-be-sent data amount of the first file, the sending terminal 210 writes the data of the first file in the MAC layer sending buffer at the first rate, and sends the data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
Illustratively, the data size of the first file is 800MB, the physical layer transmission rate upper limit Vmax may be 2.4Gbps (300 MB/s), the MAC layer feedback time Ts of the transmitting terminal 210 is 2ms, the buffer capacities of the MAC layer transmission buffer, the MAC layer reception buffer, and the write buffer may be 1.8MB, and the first early warning waterline may be 1.2MB. The round trip delay RTT between the transmitting terminal 210 and the receiving terminal 220 may be 16ms. The buffer capacity of the IP fragment reassembly buffers and write buffers may be 7.2MB. The second early warning water line may be 4.8MB. The first rate may be 90% of the upper physical layer delivery rate limit Vmax, i.e., 2.16Gbps (270 MB/s), and the second rate may be 10% of the upper physical layer delivery rate limit Vmax, i.e., 0.24Gbps (30 MB/s). The third rate may be 10% of the upper Vmax physical layer transmission rate limit, i.e., 0.24Gbps (30 MB/s). The first specified threshold may be 10% of the buffer capacity of the MAC layer transmission buffer, i.e., 0.18MB. The second specified threshold may be 10% of the buffer capacity of the IP fragment reassembly buffer and the write buffer, i.e., 0.72MB.
After the sending terminal 210 and the receiving terminal 220 have set the capacity and the early warning waterline of their respective buffers, the sending terminal 210 may send the first data of the first file of the buffer to the MAC layer at a rate of 2.16Gbps (270 MB/s), and the network card of the sending terminal 210 may take out the first data of the first file from the MAC layer sending buffer at the maximum rate as possible and send the first data to the receiving terminal 220.
When the receiving terminal 220 monitors that the buffered data amount of the IP fragment reassembly buffer (or write buffer) has reached 4.8MB, the remaining capacity of the IP fragment reassembly buffer (or write buffer) is 2.4MB. If the data size to be sent of the first file is 600MB, at this time, the remaining capacity of the IP fragment reassembly buffer (or write buffer) is smaller than the data size to be sent of the first file, and the receiving terminal 220 feeds back the first buffer information to the sending terminal 210. After receiving the fed back first buffer information, the sending terminal 210 may write the fourth data of the first file into the MAC layer sending buffer at a rate of 0.24Gbps (30 MB/s), and send the fourth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
Since the rate at which the sending terminal 210 reads the data of the first file is reduced, the rate at which the network card takes out the data of the first file from the MAC layer send buffer is also reduced. The amount of data in the IP fragment reassembly buffer (or write buffer) may decrease. When the receiving terminal 220 monitors that the data amount in the IP fragment reassembly buffer (or write buffer) decreases to 0.72MB (10% of the total capacity), the receiving terminal 220 may feed back the second buffer information to the transmitting terminal 210. When the sending terminal 210 receives the second buffering information, if the sending terminal 210 monitors that the buffer waterline of the MAC layer sending buffer is 1MB (1.2 MB lower than the first early warning waterline), the sending terminal 210 may write the fifth data of the first file into the MAC layer sending buffer at a rate of 2.16Gbps (270 MB/s), and send the fifth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
If the sending terminal 210 monitors that the buffer water line of the MAC layer sending buffer is 1.2MB (reaches 1.2MB of the first early warning water line) and the to-be-sent data amount of the first file is 200MB (is greater than the remaining capacity of the MAC layer sending buffer by 2.4 MB) when the sending terminal 210 receives the second buffer information, the sending terminal 210 may write the fifth data of the first file into the MAC layer sending buffer at a rate of 0.24Gbps (30 MB/s), and send the fifth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
If after the sending terminal 210 receives the second buffering information fed back by the receiving terminal 220, and the sending terminal 210 monitors that the buffer water line of the MAC layer sending buffer is 1.2MB (reaches 1.2MB of the first early warning water line), and the data volume to be sent of the first file is 2MB (is less than 2.4MB of the remaining capacity of the MAC layer sending buffer), the sending terminal 210 writes the fourth data of the first file into the MAC layer sending buffer at a rate of 2.16Gbps (270 MB/s), and sends the fourth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card.
The above examples are merely illustrative of the present application and should not be construed as limiting.
In some embodiments, the receiving terminal 220 may periodically (e.g., with a period of 2 ms) send the buffered water line of the IP fragment reassembly buffer and the buffered water line of the write buffer to the sending terminal 210. The transmitting terminal 210 may determine whether a second buffer (e.g., a MAC layer transmit buffer) greater than or equal to the early warning water line exists among the three buffers, i.e., the MAC layer transmit buffer, the IP fragment reassembly buffer, and the write buffer. If so, the sending terminal 210 may determine whether the remaining capacity of the second buffer is smaller than the amount of data to be sent of the first file. When the remaining capacity of the buffer B is smaller than the amount of data to be sent of the first file, the sending terminal 210 may read the data of the first file from the body storage at a fourth rate (for example, 10% or 0 of the upper limit of the physical layer sending rate), and send the data to the MAC layer sending buffer. Then, the sending terminal 210 may determine whether the buffer level in the second buffer is less than or equal to a specified threshold, if so, the sending terminal 210 may write the fourth data of the first file in the MAC layer sending buffer at a first rate (for example, 90% of an upper limit of a physical layer sending rate), and send the fourth data of the first file in the MAC layer sending buffer to the receiving terminal 220 through the network card. Wherein the fourth rate is less than the first rate.
It should be noted that the method steps of the embodiment shown in fig. 10 and the method steps of the embodiment shown in fig. 8 may be combined with each other.
In the second part of the embodiment of the present application, the transmission rate of the transmitting terminal 210 is not limited to be controlled only by monitoring the buffer level lines in the three buffers, i.e., the MAC layer transmission buffer, the IP fragment reassembly buffer, and the write buffer.
In some embodiments, the sending rate of the sending terminal 210 may also be controlled by monitoring the buffer water level in the three buffers, the MAC layer send buffer, the MAC layer receive buffer, and the write buffer. In some embodiments, the sending rate of the sending terminal 210 may also be controlled by monitoring the buffer waterline in the four buffers of the MAC layer sending buffer, the IP fragment reassembly buffer, the MAC layer receiving buffer, and the write buffer. In some embodiments, the transmission rate of the transmitting terminal 210 may also be controlled by monitoring the buffer level lines in the four buffers, the MAC layer transmit buffer and the write buffer. For the process of controlling the sending rate of the sending terminal 210, reference may be made to the embodiment shown in fig. 7, which is not described herein again.
Fig. 11 is a diagram illustrating a buffer level line of a MAC layer transmission buffer on the transmitting terminal 210 over time in a data transmission method provided in the second part of the embodiment of the present application.
As shown in fig. 11, the buffer capacity of the MAC layer transmission buffer (qdisk _ buffer) on the transmitting terminal 210 may be 10000 packets, and the early warning horizon may be 7500 packets. In the process of transmitting the first file to the receiving terminal 220 by the sending terminal 210, the MAC layer sending buffer always has data, and the buffer waterline in the MAC layer sending buffer does not reach 10000, which indicates that the sending rate of the sending terminal 210 reaches the limit of hardware, and the MAC layer sending buffer does not overflow and lose packets. According to experimental data, by using the data transmission method provided by the embodiment of the application, when the sending terminal 210 starts a radar frequency band to transmit 20GB of files to the receiving terminal 220 based on a Wi-Fi 6 network, the average transmission rate can reach 210MB/s, which can reach 100% of the physical limit rate of the network card, the jitter of the transmission rate can be less than 10MB/s, and the number of packet losses is less than 10.
The second part of the embodiment of the application provides a data transmission method, which may be implemented by setting capacities and early warning water line levels of one or more buffers specified on a sending end and a receiving end, for example, a MAC layer transmission buffer (qdisk _ buffer) of the sending end, a MAC layer transmission buffer (netdev _ back log _ buffer) of the receiving end, an IP fragment reassembly buffer (IP _ defrag _ buffer) of the receiving end, and a write buffer (write _ buffer) of the receiving end. Then, the sending rate of the sending end can be determined according to the current buffered data volume in the one or more buffer areas, so that the file transmission speed is close to the limit rate of the physical channel, and the packet loss rate is reduced.
A data storage method and related contents provided in the third part of the embodiments of the present application are described below with reference to fig. 12 to 15.
The ordinal numbers of some of the nouns in the third portion of the embodiments of the present application do not continue in the order in which they are recited in other portions of the embodiments of the present application, and the nouns in the third portion of the embodiments of the present application are used only in the third portion of the embodiments of the present application.
A third part of the embodiments of the present application provides a data storage method, including: and the terminal receives the data of the first file and stores the data of the first file into a network protocol stack receiving buffer area. The terminal takes out the data of the first file from the network protocol stack receiving buffer zone and directly writes the data into a disk. The terminal obtains the residual buffer capacity of the network protocol stack receiving buffer, the data volume to be transmitted of the first file and the buffer data growth rate of the network protocol stack receiving buffer. If the buffer data rate increase of the network protocol stack receiving buffer area is larger than 0, the terminal determines the overflow time of the network protocol stack receiving buffer area and the remaining transmission time of the first file according to the remaining buffer capacity of the network protocol stack receiving buffer area, the data volume to be transmitted of the first file, the buffer data rate increase of the network protocol stack receiving buffer area and the network card receiving rate. If the overflow time of the network protocol stack receiving buffer is less than the remaining transmission time of the first file and the buffered data amount of the network protocol stack receiving buffer is greater than a first threshold, the terminal transfers the data stored in the network protocol stack receiving buffer to a user mode buffer and writes the data in the user mode buffer into the disk through a kernel mode writing buffer.
By the data storage method provided by the third part of the embodiment of the application, after receiving the file data, the terminal can adopt different data storage paths through the water level line in the kernel-mode network protocol stack receiving buffer area, so that packet loss caused by overflow in the network protocol stack receiving buffer area can be avoided, and the packet loss rate is reduced while the file data is transmitted at a high speed.
First, the basic logic of congestion control in the TCP transport protocol is introduced.
Fig. 12 shows the basic logic of the congestion control mechanism in the TCP transport protocol. As shown in fig. 12, after the sending end starts to transmit the file data to the receiving end, the receiving end may count the packet loss rate, and feed back the packet loss rate to the sending end, and the sending end may determine whether the packet loss rate increases, and if the packet loss rate increases, the sending end may decrease the sending rate of the data packet, for example, the sending end decreases the sending rate to a previous half, and when the sending end determines that the packet loss rate does not increase, the sending end may increase the sending rate, for example, the sending end increases the sending rate by a fixed value Δ than the previous sending rate. Therefore, the network congestion degree can be improved, and the packet loss rate counted by the receiving end can be influenced after the network congestion degree is improved.
As shown in fig. 13, when packet loss is caused by factors such as air interface co-channel interference, the congestion control policy at the transmitting end cannot improve the influence of factors such as air interface co-channel interference on the packet loss rate. Therefore, under the influence of the air interface co-frequency interference and other factors, the sending end reduces the sending rate to the former half through the congestion control strategy, which cannot improve the influence of the co-frequency interference on the packet loss rate, and when the packet loss is not increased, the sending end increases the sending rate by a fixed value Δ too conservatively as compared with the former sending rate, which cannot improve the rate of data transmission.
An architecture diagram of a data storage system provided in the third part of the embodiments of the present application is described below.
Referring to fig. 14, fig. 14 is a diagram illustrating an architecture of a data storage system according to an embodiment of the present application. As shown in fig. 14, the data storage system on the terminal 100 may employ a layered architecture that divides the software into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. The data storage system of the terminal 100 may include a user mode, a kernel mode, and a hardware layer.
The terminal 100 may include at least three types of physical storage media: a magnetic disk (i.e., read Only Memory (ROM)) 505, a running memory (i.e., random Access Memory (RAM)), and a network card 504. The disk 505 may still retain data after power off, and may be used to store file data such as documents, pictures, music, and videos. The run-time memory may be used for temporary data generated during the operation of the operating system and applications. The terminal 100 can virtually divide the running memory into two parts, namely a user mode and a kernel mode. The network card 504 may include a memory for temporarily storing data frames to be transmitted or received.
Among them, in the data storage system of the terminal 100, the user mode may include a user mode buffer 501. The kernel mode may include a kernel mode write buffer 502, a network protocol stack receive buffer 503. The hardware layer may include a network card 504 and a hard disk 505.
When the network card 504 of the terminal 100 receives the data of the first file transmitted by the transmitting end, the terminal 100 may extract the data of the first file from the network card 504 to the network protocol stack receiving buffer 503 in the kernel mode. In some embodiments, when the terminal 100 receives data of the first file using a User Datagram Protocol (UDP), the network protocol stack receiving buffer 503 may be a UDP receiving buffer.
The terminal 100 may write the data of the first file buffered in the network protocol stack receiving buffer 503 into the disk 505 through two paths:
route 1: the terminal 100 may retrieve the data of the first file from the network protocol stack reception buffer 503 and write the data directly into the disk 505.
Route 2: the terminal 100 may retrieve the data of the first file from the network protocol stack reception buffer 503 and dump it into the user mode buffer 501. Then, the terminal 100 fetches and transfers the data in the user mode buffer 501 to the kernel mode write buffer 502. Then, the terminal 100 writes the data in the kernel mode write buffer 502 into the disk 505.
In the process of receiving the data of the first file by the terminal 100, the terminal 100 may expand the total buffer capacity of the user mode receiving buffer 501 at any time, and the total buffer capacity of the network protocol stack receiving buffer 503 is fixed. The terminal 100 adopts the path 1: when the data of the first file is directly fetched from the network protocol stack receiving buffer 503 and written into the disk 505, the number of times that the terminal 100 copies the data of the first file is reduced, and the power consumption of the terminal 100 can be saved.
In the data storage method provided in the third part of the embodiment of the present application, after receiving the file data, the terminal 100 may adopt different data storage paths through the water line in the kernel-state network protocol stack receiving buffer, so as to avoid packet loss caused by overflow in the network protocol stack receiving buffer, and reduce the packet loss rate while transmitting the file data at a high speed.
A data storage method provided in the third part of the embodiment of the present application is described below based on the data storage system shown in fig. 14.
Referring to fig. 15, fig. 15 shows a data storage method provided in the third part of the embodiment of the present application. As shown in fig. 15, the method may include:
S1501, the terminal 100 receives the data of the first file, and stores the data of the first file in the socket receiving buffer.
The sender of the first file may be another terminal or a server. When the sender of the first file is another terminal, the terminal 100 may transmit data of the first file with the other terminal through a Wi-Fi direct connection (e.g., a wireless fidelity peer to peer (Wi-Fi P2P)), a Wi-Fi softAP, an ultra-wideband (UWB), or other communication technologies. When the transmitting end is a server, the terminal 100 may receive data of the server transmission first file through the internet.
S1502, the terminal 100 fetches the data of the first file from the network protocol stack receiving buffer and directly writes the data into the disk.
After receiving the data of the first file, the terminal 100 may store the data of the first file into a network protocol stack receiving buffer, and the terminal 100 may directly take out the data of the first file from the network protocol stack receiving buffer and write the data into a disk. Reference may be made in particular to path 1 in the embodiment illustrated in figure 4 described above.
S1503, the terminal 100 obtains the remaining buffer capacity P of the network protocol stack receiving buffer, the amount of data to be transmitted FLS of the first file, and the buffer data growth rate a of the network protocol stack receiving buffer.
In the process that the terminal 100 directly writes the data of the first file in the network protocol stack receiving buffer into the disk, the terminal 100 may periodically (for example, with a period of 1 ms) obtain the remaining capacity P of the network protocol stack receiving buffer, the data FLS to be transmitted of the first file, and the buffered data growth rate a of the network protocol stack receiving buffer.
The terminal 100 may monitor a buffer water level line of the network protocol stack receiving buffer, and the terminal 100 determines the remaining capacity P of the network protocol stack receiving buffer according to the total buffer capacity and the buffer water level line (i.e., the buffered data amount) of the network protocol stack receiving buffer.
Illustratively, the total buffer capacity Pmax of the network protocol stack receive buffer may be 10 Megabytes (MB), the buffer water line may be 6MB, and the terminal 100 may determine that the remaining capacity P of the network protocol stack receive buffer is 4MB. The examples are merely for the user to explain the application and should not be construed as limiting.
The terminal 100 may receive a total data amount of the first file transmitted by the transmitting end before the transmitting end starts transmitting the first file to the terminal 100. The terminal 100 may count the received data volume of the first file, and the terminal 100 may determine the data volume FLS to be transmitted of the first file according to the total data volume of the first file and the received data volume of the first file.
For example, the total data volume of the first file may be 400MB, the terminal 100 counts that the received data volume of the first file is 360MB, and the terminal 100 may determine that the data volume FLS to be transmitted of the first file may be 40MB. The examples are merely illustrative of the present application and should not be construed as limiting.
The terminal 100 monitors the change of the buffer water level line in the network protocol stack receiving buffer area to obtain the buffer data growth rate a of the network protocol stack receiving buffer area.
In a possible implementation manner, the terminal 100 may monitor the receiving rate rateNet of the network card and the disk writing rate rateIO of the first file. The terminal 100 may determine the buffered data growth rate a of the network protocol stack reception buffer according to the reception rate rateNet of the network card and the disk write rate rateIO of the first file.
Illustratively, the receiving rate rateNet of the network card may be 100 megabytes per second (MBps), the disk writing rate rateIO of the first file may be 90MBps, and the terminal 100 may determine that the growth rate a of the network protocol stack receiving buffer is 10MBps. The examples are merely illustrative of the present application and should not be construed as limiting.
S1504, the terminal 100 may determine whether the buffer data increase rate a is greater than 0, and if so, perform steps S1505 and S1506.
Wherein when the buffered data growth rate a is greater than 0, the amount of buffered data in the network protocol stack reception buffer of the terminal 100 is still increasing. When the buffer increase rate a is equal to or less than 0, the amount of buffered data in the network protocol stack reception buffer of the terminal 100 does not continue to increase.
S1505, the terminal 100 determines the overflow time of the network protocol stack receiving buffer according to the buffer data growth rate a of the network protocol stack receiving buffer and the remaining buffer capacity P of the network protocol stack receiving buffer.
The overflow time T1 of the network protocol stack receive buffer can be determined by the following equation (10):
t1= c × P/a formula (10)
C is a conservative coefficient, c is more than 0 and less than or equal to 1, and c can be less than 1 in order to prevent the real overflow of the network protocol stack receiving buffer, so that the overflow time T1 determined by the terminal 100 can be ahead of the actual overflow time of the network protocol stack receiving buffer.
Illustratively, the remaining buffer capacity P of the network protocol stack receiving buffer may be 4MB, the buffered data growth rate a of the network protocol stack receiving buffer may be 10mbps, and c may be 0.9, so that the terminal 100 determines that the overflow time T1 of the network protocol stack receiving buffer may be 0.6s. The examples are merely illustrative of the present application and should not be construed as limiting.
S1506, the terminal 100 determines the remaining transmission time of the first file according to the data amount to be transmitted FLS of the first file and the network card transmission rate rateNet.
The remaining transmission time T2 of the first file may be determined by the following formula (11):
t2= FLS/rateNet formula (11)
For example, the amount FLS of data to be transmitted of the first file may be 40MB, and the network card transmission rate rateNet may be 100MBps, so that the terminal 100 may determine that the remaining transmission time of the first file is 0.4s. The examples are merely illustrative of the present application and should not be construed as limiting.
S1507, the terminal 100 determines whether the overflow time of the network protocol stack receiving buffer is less than the remaining transmission time of the first file. If yes, S1508, the terminal 100 determines whether the buffered data amount P of the network protocol stack reception buffer is greater than the specified threshold M1.
The terminal 100 may determine, according to the above formula (10) and the above formula (11), that a difference f1 between the overflow time of the network protocol stack receiving buffer and the remaining transmission time of the first file is:
f1= c P/a-FLS/rateNet formula (12)
When f1 is less than 0, the terminal 100 may determine that the overflow time of the network protocol stack receiving buffer is less than the remaining transmission time of the first file. For example, the conservative coefficient c is 0.9, p may be 4MB, the buffer data growth rate a of the network protocol stack receive buffer may be 10MBps, the amount of data to be transmitted FLS of the first file may be 80MB, the network card transmission rate rateNet may be 100MBps, and the terminal 100 may calculate the difference f1 between the overflow time of the network protocol stack receive buffer and the remaining transmission time of the first file to be-0.2 s (less than 0), so that the terminal 100 may determine that the overflow time of the network protocol stack receive buffer is less than the remaining time of the first file. The examples are merely illustrative of the present application and should not be construed as limiting.
When f1 is greater than or equal to 0, the terminal 100 may determine that the overflow time of the network protocol stack receiving buffer is greater than or equal to the remaining transmission time of the first file. For example, if c is 0.9, p may be 4MB, the buffer data growth rate a of the network protocol stack receiving buffer may be 10MBps, the flash to be transmitted of the first file may be 40MB, the network card transmission rate may be 100MBps, and the terminal 100 may determine that a difference f1 between the overflow time of the network protocol stack receiving buffer and the remaining transmission time of the first file is 0.2s (greater than 0), so that the terminal 100 may determine that the overflow time of the network protocol stack receiving buffer is greater than the remaining time of the first file. The examples are merely illustrative of the present application and should not be construed as limiting.
S1509, when the overflow time of the network protocol stack receiving buffer is less than the remaining transmission time of the first file and the buffered data amount P of the network protocol stack receiving buffer is greater than the specified threshold M1, the terminal 100 transfers the buffered data in the network protocol stack receiving buffer to the user mode buffer, and fetches data from the user mode buffer, and writes the data into the disk through the kernel mode writing buffer.
The specified threshold M1 is less than the total buffer capacity of the network protocol stack receive buffer. For example, the total buffer capacity Pmax of the network protocol stack receive buffer may be 10MB, the specified threshold M1 may be 6MB, and the buffered amount P of the network protocol stack receive buffer may be 6.1MB, so the terminal 100 may receive the buffered data of the network protocol stack receive buffer. The examples are merely illustrative of the present application and should not be construed as limiting.
When the overflow time of the network protocol stack receiving buffer is less than the remaining transmission time of the first file and the buffered data amount P of the network protocol stack receiving buffer is greater than the specified threshold M1, the terminal 100 stops taking out data from the network protocol stack receiving buffer and directly writes the data into the user mode buffer, and switches from the path 1 to the path 2 shown in fig. 4. On path 2, the terminal 100 may forward all buffered data in the network protocol stack reception buffer to the user mode buffer, then the terminal 100 takes out data from the user mode buffer and stores the data into the kernel mode write buffer, and finally, the terminal 100 writes the buffered data in the kernel mode write buffer into the disk.
When the overflow time of the network protocol stack receiving buffer is less than the remaining transmission time of the first file and the buffered data amount P of the network protocol stack receiving buffer is greater than the specified threshold value M1, the terminal 100 switches the data storage path from the path 1 to the path 2, because the terminal 100 can increase the capacity of the user mode buffer at any time, and the rate of fetching data from the network protocol stack receiving buffer by the terminal 100 and transferring the data into the user mode buffer is faster than the rate of fetching data from the network protocol stack receiving buffer and writing the data into a disk, the overflow and packet loss of the network protocol stack receiving buffer can be prevented.
S1510, after the terminal 100 writes the received buffer from the network protocol stack to the disk via the user mode buffer and the kernel mode write buffer, the terminal 100 may determine the overflow time of the user mode buffer according to the buffer data growth rate E of the user mode buffer and the remaining buffer capacity U of the user mode buffer.
The terminal 100 monitors the buffer water level line change in the user buffer to obtain the buffer data growth rate E in the user buffer.
The overflow time T3 of the user-mode reception buffer can be determined by the following equation (13):
t3= d U/E equation (13)
D is a conservative coefficient, d is more than 0 and less than or equal to 1, and d can be less than 1 in order to prevent the user state buffer area from really overflowing, so that the overflowing time T3 determined by the terminal 100 can be ahead of the actual overflowing time of the user state buffer area.
Illustratively, the remaining buffer capacity U of the user mode buffer may be 10MB, the buffer data growth rate E of the user mode buffer may be 10mbps, and d may be 0.9, so that the terminal 100 determines that the overflow time T1 of the user mode buffer may be 0.9s. The examples are merely illustrative of the present application and should not be construed as limiting.
S1511, the terminal 100 determines whether the overflow time of the user mode buffer is less than the remaining transmission time of the first file. If so, S1512, the terminal 100 sends buffer information to the sending end of the first file, where the buffer information is used to instruct the sending end to reduce the sending rate of the first file.
The terminal 100 may determine, according to the above equation (11) and the above equation (12), that the difference f2 between the overflow time of the user-state buffer and the remaining transmission time of the first file is:
f2= d U/E-FLS/rateNet formula (14)
Wherein, when f2 < 0, the terminal 100 may determine that the overflow time of the user mode buffer is less than the remaining transmission time of the first file. Illustratively, the conservative coefficient d is 0.9, u may be 10MB, the buffered data growth rate E of the user-mode buffer may be 10MBps, the amount FLS of data to be transmitted of the first file may be 100MB, the network card transmission rate rateNet may be 100MBps, and the terminal 100 may calculate that the difference f1 between the overflow time of the user-mode buffer and the remaining transmission time of the first file is-0.1 s (less than 0), so that the terminal 100 may determine that the overflow time of the user-mode buffer is less than the remaining time of the first file. The examples are merely illustrative of the present application and should not be construed as limiting.
When f2 ≧ 0, the terminal 100 can determine that the overflow time of the user-mode buffer is equal to or greater than the remaining transmission time of the first file. Illustratively, d is 0.9, u may be 10MB, the buffered data growth rate E of the user mode buffer may be 10MBps, the FLS of the office to be transmitted of the first file may be 80MB, the network card transmission rate rateNet may be 100MBps, and the terminal 100 may determine that the difference f1 between the overflow time of the user mode buffer and the remaining transmission time of the first file is 0.1s (greater than 0), and thus, the terminal 100 may determine that the overflow time of the user mode buffer is greater than the remaining time of the first file. The examples are merely illustrative of the present application and should not be construed as limiting.
When the terminal 100 determines that the overflow time of the user mode buffer is less than the remaining transmission time of the first file, that is, it indicates that the end user mode buffer is likely to overflow before the first file is completely transmitted, therefore, the terminal 100 may send buffer information to the sending end of the first file, where the buffer information is used to instruct the sending end of the first file to reduce the sending rate of the first file.
S1513, when the overflow time of the user-state buffer is less than the remaining transmission time of the first file and the buffered data amount of the network protocol stack receiving buffer is 0, the terminal 100 may determine the maximum overflow time of the network protocol stack receiving buffer according to the total buffer capacity Pmax of the network protocol stack receiving buffer and the buffered data growth rate E of the user-state buffer.
Since the rate of transferring the buffered data in the network protocol stack receiving buffer into the user mode buffer by the terminal 100 is greater than the network card rate rateNet, the buffered data in the network protocol stack receiving buffer can be taken out by the terminal 100 in time and transferred into the user mode buffer, and the buffered data amount in the network protocol stack receiving buffer can be reduced to 0.
The maximum overflow time Tmax of the network protocol stack receive buffer may be determined by the following equation (15):
Tmax = Pmax/E equation (15)
Illustratively, pmax may be 10mb, e may be 10Mbps, i.e., terminal 100 may determine Tmax to be 1s according to equation (15) above. The examples are merely illustrative of the present application and should not be construed as limiting.
S1514, the terminal 100 determines whether the maximum overflow time of the network protocol stack receiving buffer is greater than or equal to the remaining transmission time of the first file. When the maximum overflow time of the network protocol stack receiving buffer is greater than or equal to the remaining transmission time of the first file, the terminal 100 takes the data of the first file from the network protocol stack receiving buffer and directly writes the data into the disk.
The terminal 100 may determine, according to the above equation (11) and the above equation (15), that a difference f3 between the overflow time of the network protocol stack receiving buffer and the remaining transmission time of the first file is:
f3= Pmax/E-FLS/rateNet formula (16)
When f3 < 0, the terminal 100 may determine that the maximum overflow time of the network protocol stack receive buffer is less than the remaining transmission time of the first file. Illustratively, pmax may be 10MB, the buffered data growth rate E of the user mode buffer may be 10Mbps, the amount of data to be transmitted FLS of the first file may be 110mb, ratenet may be 100Mbps, and therefore, the terminal 100 may determine that the difference f3 between the overflow time of the network protocol stack receive buffer and the remaining transmission time of the first file is-0.1 s (less than 0), and thus, the terminal 100 may determine that the maximum overflow time of the network protocol stack receive buffer is less than the remaining time of the first file. The examples are merely illustrative of the present application and should not be construed as limiting.
When f3 is greater than or equal to 0, the terminal 100 may determine that the maximum overflow time of the network protocol stack receiving buffer is greater than or equal to the remaining transmission time of the first file. Illustratively, pmax may be 10MB, the buffered data growth rate E of the user mode buffer may be 10Mbps, the amount of data to be transmitted FLS of the first file may be 90mb, ratenet may be 100Mbps, and therefore, the terminal 100 may determine that the difference f3 between the overflow time of the network protocol stack receiving buffer and the remaining transmission time of the first file is 0.1s (less than 0), and thus, the terminal 100 may determine that the maximum overflow time of the network protocol stack receiving buffer is greater than or equal to the remaining time of the first file. The examples are merely illustrative of the present application and should not be construed as limiting.
When the maximum overflow time of the network protocol stack receiving buffer is greater than or equal to the remaining transmission time of the first file, the terminal 100 stops transferring the buffered data of the network protocol stack receiving buffer to the user mode buffer, and at this time, no data in the user mode buffer enters into a state where only data is taken out by the terminal 100 and written into a disk through the kernel mode writing buffer. The terminal 100 may wait until all buffered data in the user mode buffer is written into the disk, and fetch data from the network protocol stack receiving buffer and write the data directly into the disk.
In some embodiments, after the terminal 100 takes out the data of the first file from the network protocol stack receiving buffer by using the path 1 and writes the data into the disk, the terminal 100 may obtain the total buffer capacity Pmax of the network protocol stack receiving buffer, the network card receiving rate rateNet, the amount of data to be transmitted FLS of the first file, and the buffer data increasing rate a of the network protocol stack receiving buffer. The terminal 100 may determine the required buffer capacity Pn of the network protocol stack receiving buffer according to the amount FLS of the data to be transmitted of the network card receiving rate rateNet first file and the buffer data increasing speed a of the network protocol stack receiving buffer.
When the required buffer capacity Pn is greater than the total buffer capacity Pmax of the network protocol stack receiving buffer, the terminal 100 can write the buffered data in the network protocol stack receiving buffer to the disk by using the path 1 and the path 2. The terminal 100 may store the first part of data stored in the network protocol stack receiving buffer, and write the first part of data in the disk through path 1. The terminal 100 stores the second part of data in the network protocol stack receiving buffer and writes the second part of data into the disk through the path 2. The proportion of the data volume of the first part of data to the data volume stored in the network protocol stack receiving buffer is beta.
The terminal 100 may determine the required buffer capacity Pn of the network protocol stack receive buffer by equation (17):
c Pn/a-FLS/rateNet =0 equation (17)
The terminal 100 may determine, by using equation (18), that the ratio of the data size of the first portion of data to the data size of the network protocol stack receiving buffer is β:
beta = (Pn-Pmax)/Pmax formula (18)
Wherein, when β > 0, the terminal 100 may determine that the required buffer capacity Pn of the network protocol stack reception buffer is greater than the total buffer capacity Pmax of the network protocol stack reception buffer. Illustratively, the total buffer capacity Pmax of the network protocol stack receiving buffer is 8MB, the conservative coefficient c may be 0.9, the buffer data growth rate a of the network protocol stack receiving buffer may be 10MBps, the amount of data to be transmitted FLS of the first file may be 90MB, and the network card transmission rate rateNet may be 100MBps. The terminal 100 can determine that β is 0.2 (greater than 0). Therefore, the terminal 100 can write 20% of the stored data in the network protocol stack receiving buffer to the disk through the path 2. The examples are merely illustrative of the present application and should not be construed as limiting.
When β is less than or equal to 0, the terminal 100 may determine that the required buffer capacity Pn of the network protocol stack receive buffer is less than or equal to the total buffer capacity Pmax of the network protocol stack receive buffer. Illustratively, the total buffer capacity Pmax of the network protocol stack receive buffer is 12MB, the conservative coefficient c may be 0.9, the buffer data growth rate a of the network protocol stack receive buffer may be 10MBps, the amount of data to be transmitted FLS of the first file may be 90MB, and the network card transmission rate rateNet may be 100MBps. The terminal 100 can determine that beta is-0.17 (less than 0). Therefore, the terminal 100 can write the stored data in the network protocol stack receiving buffer to the disk directly through the path 1. The examples are merely illustrative of the present application and should not be construed as limiting.
In the data storage method provided in the third part of the embodiment of the present application, after receiving the file data, the terminal 100 may adopt different data storage paths through the water line in the kernel-state network protocol stack receiving buffer, so as to avoid packet loss caused by overflow in the network protocol stack receiving buffer, and reduce the packet loss rate while transmitting the file data at a high speed.
A multi-path data prefetching method and related contents according to the fourth aspect of the embodiment of the present application are described below with reference to fig. 16 to 27.
The ordinal numbers of some of the nouns in the fourth portion of the embodiments of the present application do not continue in the order in which they are recited in other portions of the embodiments of the present application, and the nouns in the fourth portion of the embodiments of the present application are used only in the fourth portion of the embodiments of the present application.
With the development of broadband access technology, terminals with multiple network interfaces are becoming more and more popular. For example, most smart phones have networking functions of both Wireless Local Area Network (WLAN) and mobile cellular network. As another example, some smartphones may simultaneously support networking functionality of dual mobile cellular networks and/or networking functionality of dual WLANs. Also for example, a notebook computer is typically provided with a limited LAN adapter and a wireless LAN adapter. However, a conventional Transmission Control Protocol (TCP) is an end-to-end transmission protocol, and cannot simultaneously use multiple pairs of network connections. Therefore, the advantages of multiple network interfaces of the current terminal cannot be fully utilized, and a lot of network bandwidth resources are wasted.
Currently, a terminal may allow a wireless fidelity (Wi-Fi) network and a cellular network to be used simultaneously, so as to improve a communication experience, for example, when a streaming video is watched, a larger aggregate bandwidth may be provided by using the Wi-Fi network and the cellular network simultaneously, so that a downloading rate is higher, a pause is less, and the streaming media is played more smoothly. Among them, a multipath transmission control protocol (MPTCP) is a transport layer protocol based on a multi-network interface technology, and uses multiple paths to cooperate and distribute data. The method can fully utilize idle resources of multiple network interfaces, improve the end-to-end transmission throughput rate and increase the utilization rate of network resources.
A fourth aspect of the embodiments of the present application provides a multi-path data prefetching method, including: the terminal acquires a first HTTP request initiated by a first application of the terminal aiming at the first URI, wherein the first HTTP request is used for requesting first data from the server. The terminal generates L second HTTP requests, the L second HTTP requests are used for requesting second data from the server, the second data comprise the first data, the data volume of the second data is larger than that of the first data, and L is a positive integer. And the terminal sends the L second HTTP requests to the server through L network paths respectively. The terminal receives L first HTTP responses sent by the server on the L network paths, wherein the L first HTTP responses comprise the second data. The terminal takes the first data out of the second data and returns the first data to the first application through HTTP response. The terminal receives a third HTTP request initiated by the first application aiming at the first URI, wherein the third HTTP request is used for requesting third data from the server. And if the second data comprises the third data, the terminal takes out the third data from the second data and returns the third data to the first application through an HTTP response.
By the multi-path data prefetching method provided by the fourth aspect of the embodiment of the present application, when an application service requests data of a first data size, a terminal may prefetch data of a second data size to a server, where the second data size is greater than the first data size. Then, after receiving the data of the second data volume returned by the server, the terminal may first return the data of the first data volume in the second data volume to the application. Then, the remaining (second amount of data — first amount of data) is stored to the prefetch buffer. When the application requests the next time the remaining (second amount of data-first amount of data) bytes of data, the terminal may directly fetch the remaining (second amount of data-first amount of data) bytes of data from the pre-fetch buffer to the application. The bandwidth utilization rate of the network path between the terminal and the server is improved, and when the application frequently accesses data in different ranges on the same URI address, the time for the application to acquire the data can be saved.
As shown in fig. 16, the terminal and the server need to support MPTCP simultaneously. An Application (APP) on the terminal 100 may establish a plurality of TCP connections with the server in a plurality of network paths, respectively, through a Proxy (Proxy) of MPTCP. For example, the proxy for MPTCP may establish one TCP connection with the server over the cellular network while establishing another TCP connection with the server in the Wi-Fi network. In this way, the terminal can simultaneously carry out data transmission with the server on the cellular network and the Wi-Fi network. However, since the MPTCP is used, the terminal and the server need to support the MPTCP at the same time, and the deployment difficulty is high, and for the server that does not support the MPTCP, the terminal cannot access the server by using the Wi-Fi network and the cellular network at the same time.
As shown in fig. 17, a multi-path hypertext transfer protocol (mptcp) may split an original hypertext transfer protocol (HTTP) request initiated by an application into multiple sub-HTTP requests according to a request range of the original HTTP request. Mptcp may allow the terminal 100 to issue these multiple sub-HTTP requests to the server 200 over multiple network paths to provide the maximum aggregate bandwidth. Since both the terminal 100 and the server 200 support HTTP, the server 200 returns data requested by the terminal 100 to the terminal 100 through an HTTP response upon receiving the HTTP request. Accordingly, multipath transmission between the terminal 100 and the server 200 can be achieved without modifying the existing server 200.
Fig. 18 shows a system architecture for multipath transmission between the terminal 100 and the server 200 through mptcp.
As shown in fig. 18, the terminal may include an application layer and a kernel layer. The application layer of the terminal may include an application upper business logic module, a multi-path hypertext transfer protocol (mptcp) library (e.g., a modified library based on an OKHTTP library), and an HTTP request splitting module. The terminal may communicate with the server via a number of network paths, such as a cellular network, a Wireless Local Area Network (WLAN) 1, and a Wireless Local Area Network (WLAN) 2. Wherein the content of the first and second substances,
The application upper layer business logic module may integrate the mptcp library.
When an application issues a data acquisition request for a first Uniform Resource Identifier (URI) address to an mptcp library, the mptcp library may generate an original HTTP request according to the data acquisition request for the first URI address, and issue the original HTTP request to an HTTP request splitting module. Therein, a byte range field in the original HTTP request may include a data request range of the original HTTP request, for example, 0-8999.
The HTTP request splitting module may split the original HTTP request into a plurality of HTTP requests based on a byte range of the original HTTP request according to a number of network paths. For example, the terminal may have access to the server via 3 network paths (e.g., cellular network, WLAN 1, and WLAN 2), and the original HTTP request may have a byte range of 0-8999. The HTTP request splitting module may split the original HTTP request into 3 HTTP requests (including HTTP request 1, HTTP request 2, and HTTP request 3). The byte range of HTTP request 1 can be 0-2999, the byte range of HTTP request 2 can be 3000-5999, and the byte range of HTTP request 3 can be 6000-8999.
The HTTP request splitting module may send the plurality of HTTP requests to the server over a plurality of network paths through encapsulation of a TCP/IP protocol stack, respectively, by a socket system call.
For example, after splitting the original HTTP request into 3 HTTP requests (including HTTP request 1, HTTP request 2, and HTTP request 3), the HTTP request splitting module may establish a TCP connection with the server through the cellular network, and then the terminal may send HTTP request 1 to the server through the cellular network. After receiving the HTTP request 1 sent by the terminal through the cellular network, the server may encapsulate the data of bytes 0 to 2999 in the data resource corresponding to the URI address in the HTTP request 1 in the HTTP response 1, and return the data to the terminal through the network path of the cellular network. When the terminal receives the HTTP response 1, the TCP connection established over the cellular network between the terminal and the server is disconnected.
The terminal may establish a TCP connection with the server via the wireless local area network 1 and then the terminal may send an HTTP request 2 to the server via the cellular network. After receiving the HTTP request 2 sent by the terminal through the cellular network, the server may encapsulate data of 3000 th to 5999 th bytes in the data resource corresponding to the URI address in the HTTP request 2 in the HTTP response 2, and return the data to the terminal through the network path of the wireless lan 1. When the terminal receives the HTTP response 2, the TCP connection established between the terminal and the server over the wireless lan 1 is disconnected.
The terminal may establish a TCP connection with the server via the wireless local area network 2 and the terminal may then send an HTTP request 3 to the server via the cellular network. After receiving the HTTP request 3 sent by the terminal through the cellular network, the server may encapsulate the 6000 th to 8999 th bytes of data in the data resource corresponding to the URI address in the HTTP request 3 in the HTTP response 3, and return the data to the terminal through the network path of the wireless lan 2. When the terminal receives the HTTP response 3, the TCP connection established between the terminal and the server over the wireless lan 2 is disconnected.
Fig. 19 is a flowchart showing multipath transmission between the terminal and the server via mpthttp.
As shown in fig. 19, the terminal can access the server through three network paths, i.e., a cellular network, WLAN 1, and WLAN 2. The process of multipath transmission between the terminal and the server through the mptcp may be as follows:
1. the application on the terminal initiates the original HTTP request, which may range in bytes from 0-8999, for example.
2. The application on the terminal splits the original HTTP request into 3 HTTP requests (e.g., HTTP request 1, HTTP request 2, and HTTP request 3) based on the byte range of the original HTTP request. The byte range of HTTP request 1 can be 0-2999, the byte range of HTTP request 2 can be 3000-5999, and the byte range of HTTP request 3 can be 6000-8999.
3. The terminal sends an HTTP request 1 to the server over the network path of the cellular network.
4. The terminal sends the HTTP request 2 to the server over the network path of the WLAN 1.
5. The terminal sends an HTTP request 3 to the server over the network path of the WLAN 2.
6. The server, upon receiving the HTTP request 1, may send an HTTP success status response code 1 (e.g., 206partial content response) to the terminal over the network path of the cellular network. The HTTP success status response code 1 can be used to indicate that the HTTP request 1 has requested data with a content length of 3000 bytes.
7. The server can transmit response data 1 (data of byte range: 0-2999) of HTTP request 1 to the terminal.
8. The server, upon receiving the HTTP request 2, may send an HTTP successful status response code 2 (e.g., 206partial content response) to the terminal over the network path of the WLAN 1 network. The HTTP success status response code 2 can be used to indicate that the HTTP request 2 has requested data with a content length of 3000 bytes.
9. The server can transmit response data 2 (data of byte range: 3000-5999) of HTTP request 2 to the terminal.
10. The server, upon receiving the HTTP request 3, may transmit an HTTP success status response code 3 (e.g., 206partial content response) to the terminal through the network path of the WLAN 2 network. The HTTP success status response code 3 can be used to indicate that the HTTP request 3 has requested data with a content length of 3000 bytes.
11. The server may send response data 3 (data of byte range: 6000-8999) of HTTP request 2 to the terminal.
At present, when an application on a terminal requests data such as streaming media from a server, a long connection is first established with the server on a specified network path, and then the terminal requests a server for fragmented data of a specified size each time through an HTTP request, for example, the size of the fragmented data may be 0.2MB to 2MB. The terminal can request the server for data through a plurality of network paths at the same time, so that the bandwidth of a transmission network between the terminal and the server is increased. For a network environment with a large bandwidth, when the fragment data is too small, the bandwidth utilization rate is reduced.
For example, the data amount of a slice data requested by an application (e.g., a video application) on the terminal from the server at a time may be 2MB. Wherein, each time the terminal sends the HTTP request to the server, 0.5 round-trip time (RTT) is required. The server will then return the data requested by the terminal to the terminal. Wherein, the theoretical bandwidth utilization ratio is higher for the network path with smaller bandwidth. For example, in a Long Term Evolution (LTE) network path, 0.5RTT is 30ms, a bandwidth is 5MBps, and a server transmits 2MB of fragment data to a terminal, which takes 400ms, so that a bandwidth utilization rate in the LTE network path may be: 400/(400 + 30) =93%.
As shown in fig. 20, the data amount of the sliced data requested from the server by an application (e.g., a video application) on the terminal at a time may be 2MB. Wherein, each time the terminal sends the HTTP request to the server, 0.5 round-trip time (RTT) is required. Under a network path with a bandwidth of 100MBps (0.8 Gbps), the time consumed for transmitting the fragmented data to the terminal by the server is only 20ms, wherein under the network with the bandwidth of 100MBps, the round trip delay RTT between the terminal and the server can reach 40ms, and the RTT of 0.5RTT is 20ms. For example, it takes 20ms for the terminal to send an HTTP request 1 (byte range: 0-2 MB) initiated by an application to the server, and it takes 20ms for the server to transmit the fragment data 1 to the terminal after receiving the HTTP request 1. Then, the terminal may send an HTTP request 2 (byte range: 2MB-4 MB) initiated by the application to the server, which takes 20ms, and the server may transmit the fragment data 2 to the terminal after receiving the HTTP request 2, which takes 20ms again. Thus, the theoretical bandwidth utilization is 50%.
This means that for Gbps-level transmission network paths, more than half of the time is wasted in sending HTTP requests to the server, and bandwidth utilization is low.
As shown in fig. 21, the relationship between the bandwidth utilization and the data volume of the fragmented data, the network bandwidth and the round trip delay of the network may be as follows:
R = Trans/(Trans +0.5 RTT) equation (19)
Trans = max { M/B,0.5RTT } equation (20)
In the above formula (19) and formula (20), R is bandwidth utilization, trans is time consumed for transmitting fragmented data, M is data size of fragmented data, B is network bandwidth, and RTT is round trip delay of the network.
When the bandwidth of the network path is fixed and the data volume of the fragmented data is smaller, the theoretical bandwidth utilization rate is lower when the terminal requests the fragmented data from the server through the network path. When the data volume of the fragmented data is certain, the larger the bandwidth of the network path is, the lower the theoretical bandwidth utilization rate is when the terminal requests the fragmented data from the server through the network path.
Illustratively, for a network path with a network bandwidth of 100mbps and an rtt of 40ms, for example. When the bandwidth utilization rate is more than 90%, the data volume of the fragment data needs to be more than or equal to 18MB, and when the bandwidth utilization rate is more than 75%, the data volume of the fragment data needs to be more than or equal to 15 MB. When the data volume of the fragment data is less than or equal to 10MB, the bandwidth utilization rate is not higher than 50%.
Therefore, a fourth aspect of the embodiments of the present application provides a multi-path data prefetching method, where a terminal may prefetch data of a second data size to a server when an application service requests data of a first data size, where the second data size is larger than the first data size. Then, after receiving the data of the second data volume returned by the server, the terminal may first return the data of the first data volume in the second data volume to the application. Then, the remaining (second amount of data — first amount of data) is stored to the prefetch buffer. When the application requests the next time the remaining (second amount of data-first amount of data) bytes of data, the terminal may directly fetch the remaining (second amount of data-first amount of data) bytes of data from the pre-fetch buffer to the application. The bandwidth utilization rate of the network path between the terminal and the server is improved, and when the application frequently accesses data in different ranges on the same URI address, the time for the application to acquire the data can be saved.
Illustratively, as shown in fig. 22A, the terminal may fetch the pre-fetch data from the server via a network path. Wherein, the step includes:
1. the application on the terminal sends a data request 1 (request range: 1-100) to the full network aggregation module (link turbo).
2. After receiving the data request 1, the whole network aggregation module can enlarge the request range of the data request 1, and then selects an appropriate network path to send the HTTP request 1 (request range: 1-200) to the server based on the mptcp protocol.
3. After receiving the HTTP request 1, the server returns the requested data (data range: 1-200) to the whole network aggregation module through the HTTP response 1.
4. And the whole network aggregation module returns response data 1 to the application, wherein the data range in the response data 1 is 1-100.
5. And the full-network aggregation module stores the residual data into a local pre-fetching buffer area of the terminal, wherein the data range of the residual data is 101-200.
6. And the application issues a data request 2 to the whole network aggregation module, wherein the data range requested by the data request 2 is 101-200.
7. When the full-network aggregation module receives a data request 2 issued by an application, the full-network aggregation module may determine whether data requested by the data request 2 is stored in the prefetch buffer, and if so, the data request 2 hits the prefetch buffer.
8. When data request 2 hits in the prefetch buffer, the application may retrieve the response data 2 (data range: 101-200) of data request 2 directly from the prefetch buffer.
As another example, as shown in fig. 22B, the terminal may fetch the prefetch data from the server through multiple network paths. Wherein, the step includes:
1. the application on the terminal sends a data request 1 (request range: 1-100) to the whole network aggregation module.
2-3, after receiving the data request 1, the whole network aggregation module can expand the request range of the data request 1 to 1-200. The network-wide aggregation module may then select a suitable plurality (e.g., two) of network paths based on the mpthttp protocol, send HTTP request 1 (request scope: 1-50) to the server on network path 1 (e.g., a cellular network), and HTTP request 2 (request scope: 51-200) to the server on network path 2 (e.g., a WLAN network), respectively.
4. The whole network aggregation module receives an HTTP response 1 returned by the server through a network path 1, wherein the HTTP response 1 comprises data in a data range of 1-50.
5. And the whole network aggregation module receives an HTTP response 2 returned by the server through a network path 2, wherein the HTTP response 1 comprises data in a data range of 51-200.
6. After receiving the HTTP response 1 and the HTTP response 2, the network wide aggregation module may return the response data 1 to the application, where the data range of the response data 1 is 1 to 100.
7. And the full-network aggregation module stores the residual data into a local pre-fetching buffer area of the terminal, wherein the data range of the residual data is 101-200.
8. And the application issues a data request 2 to the whole network aggregation module, wherein the data range requested by the data request 2 is 101-200.
9. When the full-network aggregation module receives a data request 2 issued by an application, the full-network aggregation module may determine whether data requested by the data request 2 is stored in the prefetch buffer, and if so, the data request 2 hits the prefetch buffer.
10. When data request 2 hits in the prefetch buffer, the application may retrieve the response data 2 (data range: 101-200) for data request 2 directly from the prefetch buffer.
According to the multipath data prefetching method provided by the application, the data fragment requested by the terminal to the server is larger than the data fragment requested by the application, the bandwidth utilization rate of a network path between the terminal and the server is increased, and when the application frequently accesses data in different ranges on the same URI address, the time for the application to acquire the data can be saved. For example, in scenes such as video playing, application needs to acquire data streams frequently, and smoothness during video playing can be improved by the data prefetching method provided by the application.
A software system architecture of the terminal 100 provided in the fourth part of the embodiment of the present application is described below.
Referring to fig. 23, fig. 23 illustrates a software system architecture of the terminal 100 according to an embodiment of the present application. As shown in fig. 23, the software system of the terminal 100 may adopt a layered architecture, which can divide the software into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. The software system of the terminal 100 may include an application (application) layer, a user space (user space) layer, and a kernel (kernel) layer.
The application layer may include applications 901. Such as video applications, music applications, etc. When the application 901 requests the server for the fragment data through the original HTTP request, the original HTTP request may be sent to the server through the TCP port 80.
The user space may include a plurality of function modules scheduled based on buffer pools, a flow intelligence (flow intelligence) module 907. The plurality of functional modules scheduled based on the buffer pool may include a buffer management module 902, an intelligent pre-fetching module 903, a high performance service request reordering module 904, a multi-path scheduling module 905 based on the buffer, and a path affinity analysis module 906.
The buffer management module 902 may be configured to, during the process of filtering the data packet in the TCP port 80 by the network filtering module (e.g., netfilter), export the original HTTP request sent by the upper application from the TCP port 80 through the software interface (e.g., iptables). The buffer management module 902 may be further configured to analyze whether the original HTTP request hits in the prefetch buffer (i.e., whether the prefetch buffer includes the data requested by the original HTTP request) after the original HTTP request sent by the upper layer application is guided in the TCP port 80. When the original HTTP request hits in the prefetch buffer, the buffer management module 902 may directly return data corresponding to the request range of the original HTTP request in the prefetch buffer to the application. When the original HTTP request punctures the prefetch buffer (i.e., the request range in the original HTTP request is larger than the amount of data already cached in the prefetch buffer), the buffer management module 902 may notify the high performance traffic reordering module 904 of the information that the buffer punctures the original request. The buffer management module 902 may also be used to send the original HTTP request to the intelligent prefetch module 903.
The intelligent prefetch module 903 may send a trigger instruction of the prefetch request to the high-performance service request reordering module 904 according to information such as a buffer water line of the prefetch buffer and the number of times that the application 901 accesses the same URI address.
The high performance service request reordering module 904 is configured to determine a data request range of the prefetch request according to the last prefetch value, and data such as bandwidth/delay of a network path after receiving the trigger instruction of the prefetch request. The high performance service request reordering module 904 may be further configured to send the original HTTP request or the reordered HTTP request to a multipath scheduling module 905 based on buffering.
The path affinity analyzing module 906 may be configured to analyze performance information of each network path on the terminal according to the service awareness information (e.g., service quality of the service flow, type of the service flow, etc.)/network awareness information (e.g., number of network paths and transmission quality of each network path) sent by the flow intelligence module 907.
The buffer-based multipath scheduling module 905 may be configured to determine a multipath scheduling policy (i.e., which paths are used to request data and how much data is requested on each path) according to performance information of the network paths. The buffered multipath scheduling module 905 may be configured to split the original HTTP request/the reordered HTTP request into a plurality of sub-HTTP requests via mptcp based on the determined multipath scheduling policy, and send the sub-HTTP requests to the server via a plurality of network paths (e.g., a dual Wi-Fi network, a dual cellular network, etc.).
The flow intelligence module 907 may be configured to perform DNS parsing (DNS matching), manifest file parsing, flow QoS probing (flow QoS mapping), flow classification (flow classification), and obtain service awareness/network awareness information. The flow intelligence module 907 may send the traffic-aware information/network-aware information to the path affinity analysis module 906.
The kernel layer may include a kernel transmission control protocol/Internet protocol (TCP/IP) protocol stack. The TCP/IP stack includes a TCP port 80.
In this embodiment, the plurality of functional modules scheduled based on the buffer pool may be the full network aggregation module in the embodiment shown in fig. 22A or fig. 22B. For other functional descriptions of the multiple functional modules scheduled based on the buffer pool, reference may also be made to the text description for the full network aggregation module in the embodiment shown in fig. 22A or fig. 22B, which is not described herein again.
A multi-path data prefetching method according to the fourth aspect of the embodiment of the present application is described below.
Referring to fig. 24, fig. 24 is a schematic flowchart illustrating a method for a first application to obtain data on a server for the first time according to an embodiment of the present application. As shown in fig. 24, the method includes the steps of:
S2401, a first application on the terminal 100 initiates a first obtaining request for first fragmented data for a first time according to the first URI.
Wherein the first URI corresponds to a storage location of a data resource (e.g., a resource such as an HTML document, an image, a video clip, a program, etc.) on the server. The structural composition of the URI includes a naming mechanism for accessing the resource, a host name for storing the resource, and the name of the resource itself. The naming mechanism for accessing the resource may include http, ftp, mailto, file, and the like. The first URI may specifically be a Uniform Resource Locator (URL). The first acquisition request includes a data range of the first fragmented data.
Illustratively, the first application may be a video application, and the first URI may be "http: and/huawei.himovie.com/movie/romeoo and juliet.rmvb ", the resource access mechanism corresponding to the first URI may be an HTTP protocol access mechanism, the resource corresponding to the first URI is located on a server of huawei.himovie.com", and the name of the resource corresponding to the first URI may be "/movie/romeoo and juliet.rmvb". The data range of the first sliced data may be 0-2MB. The examples are merely illustrative of the present application and should not be construed as limiting.
S2402, in response to the first obtaining request, the terminal 100 starts all network communication modules and sends DNS requests on all network paths according to the domain name of the first URI.
Wherein the network communication module may include a cellular network communication module and a WLAN communication module. The cellular network communication module can realize single-cellular network communication or dual-cellular network communication. The WLAN communication module can realize single Wi-Fi network communication or double Wi-Fi network communication.
After the terminal 100 opens all network modules, the terminal 100 may obtain the domain name (i.e., host name) of the first URI and send DNS requests on all network paths. The DNS request may be used for the terminal 100 to obtain the IP address of the server to which the first URI corresponds. For example, the network paths on the terminal 100 may include a cellular network path 1, a cellular network path 2, a Wi-Fi network path 1, and a Wi-Fi network path 2. The terminal 100 may send DNS requests on cellular network path 1, cellular network path 2, wi-Fi network path 1, wi-Fi network path 2, respectively.
S2403, the terminal 100 receives the DNS responses returned on the N network paths, and analyzes the IP addresses of the server corresponding to the N network paths from the N DNS responses. Wherein N is a positive integer.
After the terminal 100 sends the DNS request to all network paths, and when the terminal 100 does not receive the DNS response on a certain network path, the terminal 100 may determine that the network path that does not receive the DNS response is unavailable, that is, the terminal 100 cannot access the server corresponding to the first URI through the network path. When the terminal 100 receives a DNS response returned from a network path, the terminal 100 may determine that the network path receiving the DNS response is available, that is, the terminal 100 may access the server corresponding to the first URI through the network path.
The IP addresses of the servers corresponding to the first URI that the terminal 100 acquires from different network paths may be the same. In a possible implementation manner, the IP address of the server corresponding to the first URI that the terminal 100 acquires from different network paths may be different. For example, the IP address of the server corresponding to the first URI acquired by the terminal 100 from the cellular network path 1 may be IP address _1. The IP address of the server corresponding to the first URI acquired by the terminal 100 from the cellular network path 2 may be IP address _2. The IP address of the server corresponding to the first URI acquired by the terminal 100 from the Wi-Fi network path 1 may be IP address _3. The IP address of the server corresponding to the first URI acquired by the terminal 100 from the Wi-Fi network path 2 may be IP address _4. The above examples are merely illustrative of the present application and should not be construed as limiting.
S2404, the first application on the terminal 100 initiates an initial HTTP request according to the first URI and the IP address of the server on the default network path. The request range of the initial HTTP request is the same as the request range of the first acquisition request.
The byte range field of the initial HTTP request may include a request range of the initial HTTP request.
When the terminal 100 starts all network communication modules, the terminal 100 may preset a default network path. When the first application on the terminal 100 initiates the initial HTTP request, the destination IP address in the initial HTTP request is the IP address of the server corresponding to the first URI, which is obtained by the terminal 100 on the default network path.
Illustratively, the terminal 100 may access the server through a cellular network path 1, a cellular network path 2, a Wi-Fi network path 1, and a Wi-Fi network path 2. The default network path preset on the terminal 100 may be the Wi-Fi network path 1, and the terminal 100 may use the IP address _3 of the server on the Wi-Fi network path 1 as the destination IP address of the initial HTTP request.
S2405, the terminal 100 splits the request range of the initial HTTP request into N sub-request ranges with the same range length. The request range of the initial HTTP request is the same as the data range of the first fragment data.
For example, the request range for the initial HTTP request may be 0-2MB. The terminal 100 may access the server corresponding to the first URI through 4 network paths, namely, cellular network path 1, cellular network path 2, wi-Fi network path 1, and Wi-Fi network path 2. The terminal 100 may split the request range of the initial HTTP request into 4 sub-request ranges with the same request range length, for example, the sub-request range 1 is 0 MB to 0.5MB, the sub-request range 2 is 0.5MB to 1MB, the sub-request range 3 is 1MB to 1.5MB, and the sub-request range 4 is 1.5MB to 2MB. The above examples are merely illustrative of the present application and should not be construed as limiting.
S2406, the terminal 100 generates N HTTP requests according to the first URI, the N sub-request ranges, and the IP addresses of the servers on the N network paths, and sends the N HTTP requests to the servers through the N network paths, respectively.
It should be noted that the N HTTP requests may be referred to as N fifth HTTP requests in this embodiment of the present application.
Illustratively, the terminal 100 may access the server corresponding to the first URI through 4 network paths, namely, cellular network path 1, cellular network path 2, wi-Fi network path 1, and Wi-Fi network path 2. Wherein, the IP address of the server on cellular network path 1 may be IP address _1, the IP address of the server on cellular network path 2 may be IP address _2, the IP address of the server on Wi-Fi network path 1 may be IP address _3, and the IP address of the server on Wi-Fi network path 2 may be IP address _4. The sub-request range 1 is 0 MB to 0.5MB, the sub-request range 2 is 0.5MB to 1MB, the sub-request range 3 is 1MB to 1.5MB, and the sub-request range 4 is 1.5MB to 2MB. The above examples are merely illustrative of the present application and should not be construed as limiting. The correspondence between the N HTTP requests, the N sub-request ranges, the server IP address, and the network path may be as shown in table 1 below:
TABLE 1
Figure BDA0003175853830000501
As can be seen from table 1 above, the terminal 100 may send the HTTP request 1 to the server corresponding to the first URI on the cellular network path 1, where the sub-request range 1 of the HTTP request 1 is 0-0.5mb, and the destination IP address of the HTTP request 1 is IP address _1. The terminal 100 may send HTTP request 2 to the server corresponding to the first URI over cellular network path 2, where the sub-request range 2 of HTTP request 2 is 0.5-1.0mb, and the destination IP address of HTTP request 2 is IP address _2. The terminal 100 may send an HTTP request 3 to the server corresponding to the first URI on the Wi-Fi network path 1, where a sub-request range 3 of the HTTP request 3 is 1 st to 1.5mb, and a destination IP address of the HTTP request 3 is IP address _3. The terminal 100 may send the HTTP request 1 to the server corresponding to the first URI on the cellular network path 1, where the sub-request range 4 of the HTTP request 4 is 1.5-2mb, and the destination IP address of the HTTP request 4 is IP address _4. Table 1 above is merely illustrative of the present application and should not be construed as limiting.
S2407, the terminal 100 receives N HTTP responses returned by the server over the N network paths, and returns the first fragment data in the N HTTP responses to the first application.
It should be noted that the first sliced data may be referred to as fifth data in the embodiment of the present application.
After receiving the HTTP request sent by the terminal 100, the server may encapsulate the data requested by the HTTP request in an HTTP response, and return the HTTP response to the terminal 100 according to the original path of the HTTP request.
For example, the terminal 100 transmits the HTTP request 1 to the server through the cellular network path 1, the HTTP request 2 to the server through the Wi-Fi network path 1, the HTTP request 3 to the server through the Wi-Fi network path 1, and the HTTP request 4 to the server through the Wi-Fi network path 2. Wherein, HTTP request 1 is used for requesting the data of the resource corresponding to the first URI within the range of 0 MB-0.5 MB, HTTP request 2 is used for requesting the data of the resource corresponding to the first URI within the range of 0.5MB-1MB, HTTP request 3 is used for requesting the data of the resource corresponding to the first URI within the range of 1MB-1.5MB, and HTTP request 4 is used for requesting the data of the resource corresponding to the first URI within the range of 1.5MB-2 MB.
After receiving the HTTP request 1, the server may encapsulate the 0-0.5MB of data of the resource corresponding to the first URI in the HTTP response 1, and return the HTTP response 1 to the terminal 100 through the cellular network path 1. After receiving the HTTP request 2, the server may encapsulate the data of 0.5MB to 1MB of the resource corresponding to the first URI in the HTTP response 2, and return the HTTP request 2 to the terminal 100 through the cellular network path 2. After receiving the HTTP request 3, the server may encapsulate the data of the 1 st MB to 1.5 th MB of the resource corresponding to the first URI in the HTTP response 3, and return the HTTP request 3 to the terminal 100 through the Wi-Fi network path 1. After receiving the HTTP request 4, the server may encapsulate the data of the 1.5MB to 2MB of the resource corresponding to the first URI in the HTTP response 4, and return the HTTP request 4 to the terminal 100 through the Wi-Fi network path 2.
After receiving the HTTP response 1, the terminal 100 may retrieve the 0 th to 0.5MB data of the resource corresponding to the first URI from the HTTP response 1. After the HTTP response 2, the terminal 100 may fetch the 0.5MB to 1MB of data of the resource corresponding to the first URI from the HTTP response 2. After the HTTP response 3, the terminal 100 may retrieve the data of the 1 st MB to 1.5 st MB of the resource corresponding to the first URI from the HTTP response 3. After HTTP response 4, terminal 100 may retrieve the 1.5MB to 2MB of data of the resource corresponding to the first URI from HTTP response 4.
The terminal 100 may combine the 0 th-0.5 MB data, the 0.5MB-1MB data, the 1 st MB-1.5MB data, and the 1.5MB-2.0MB data of the resource corresponding to the first URI into the first fragment data, and return the first fragment data to the first application. The above examples are merely illustrative of the present application and should not be construed as limiting.
S2408, the terminal 100 measures Key Performance Index (KPI) information of the N network paths.
The key performance indicator information may include real bandwidth, round trip delay RTT, flow Completion Time (FCT), and the like.
The terminal 100 may measure the real bandwidths of the N network paths according to the following formula:
Figure BDA0003175853830000511
Figure BDA0003175853830000512
TransTime i =max{U i /Z i ,0.5*RTT i equation (23)
Wherein, in the above formula (21), formula (22) and formula (23),
Figure BDA0003175853830000513
Represents the theoretical bandwidth utilization, Z, of the ith network path i Representing the true bandwidth, X, of the ith network path i Represents the throughput of the ith network path, transTime i Indicating the time spent on data transmission on the ith network path, U i Indicating the amount of data requested by the HTTP request over the ith network path, RTT i And (3) representing the round-trip delay on the ith network path, wherein i is less than or equal to N. Wherein, U i Known as X i And RTT i Measurable, therefore, Z is determined by the above equation (21), the above equation (22) and the above equation (23) i
Illustratively, the terminal 100 has 4 network paths, cellular network path 1, cellular network path 2, wi-Fi network path 1, and Wi-Fi network path 2. The data amount requested by the terminal 100 on the 4 network paths may be 5MB each. Wherein the respective throughputs X of the 4 network paths i Transtime consumed by data transmission i Round trip time RTT i Requested data volume U i As shown in table 2 below:
TABLE 2
Figure BDA0003175853830000521
From the above table 2, it can be seen that the throughput X of the cellular network path 1 1 Requested data volume U of 10MBps 1 0.5MB, round trip time RTT 1 50ms, time consumed by data transmission TransTime 1 Is 25ms. Throughput X of cellular network path 2 2 Requested data volume U of 5.88MBps 2 0.5MB, round trip time RTT 2 70ms, time-consuming TransTime for data transmission 2 Is 20ms. Throughput X of Wi-Fi network path 1 3 20MBps, requested data volume U 3 0.5MB, round trip time RTT 3 Is 40ms and takes TransTime for data transmission 3 Is 20ms. Throughput X of Wi-Fi network path 2 4 15MBps, requested data volume U 4 0.5MB, round trip time RTT 4 60ms, time-consuming TransTime for data transmission 4 Is 30ms.
From table 2 above and equations (20), (21) and (22) above, it can be calculated: bandwidth utilization for cellular network path 1
Figure BDA0003175853830000522
At 50%, the real bandwidth of cellular network path 1 is 20MBps. Bandwidth utilization for cellular network path 2
Figure BDA0003175853830000523
At 58.82%, the true bandwidth of the cellular network path 2 is 10MBps. The bandwidth utilization rate of the Wi-Fi network path 1 is 50 percent, wi-The actual bandwidth of Fi network path 1 is 40MBps. The bandwidth utilization of the Wi-Fi network path 2 is 50%, and the real bandwidth of the Wi-Fi network path 2 is 30MBps. The above examples are merely illustrative of the present application and should not be construed as limiting.
Referring to fig. 25, fig. 25 is a flowchart illustrating a method for the first application to obtain data on the server again according to the fourth embodiment of the present application. As shown in fig. 25, the method includes the steps of:
S2501, the first application of the terminal 100 initiates an initial HTTP request for the first fragmented data to the first URI.
For specific content, reference may be made to step S2404 in the embodiment shown in fig. 24, which is not described herein again.
S2502, the terminal 100 records time information of the first application initiating the initial HTTP request, and creates a first prefetch buffer (initially empty) corresponding to the first URI.
When the first application requests the fragment data of the resource corresponding to the first URI each time, the terminal 100 may record time information that the first application initiates an HTTP request for the fragment data of the resource corresponding to the first URI. For example, the first application initiates the first HTTP request (i.e., the initial HTTP request) for the first URI in "6/18/26 min 2 sec 30 ms" 2020.
When a first application of the terminal 100 first initiates an initial HTTP request for obtaining first fragment data for a first URI, the terminal 100 locally creates a first prefetch buffer corresponding to the first URI. Wherein the first prefetch buffer is empty on the initial water line.
S2503, the first application of the terminal 100 initiates a first HTTP request for acquiring the second fragment data with respect to the first URI.
It should be noted that the first sliced data may be referred to as first data in the embodiments of the present application.
The first HTTP request may refer to any HTTP request initiated by the first application for the fragment data on the resource corresponding to the first URI after the initial HTTP request is initiated. For example, the second slice data may be data in the range of 2MB-4MB in the resource (e.g., video resource) to which the first URI corresponds. The second acquisition request includes a data range of the second fragmented data. For another example, the second tile data may be data in a range of 4MB-6MB in the resource (e.g., video resource) corresponding to the first URI.
For the text description of the first URI, reference may be made to the embodiment shown in fig. 24, which is not described herein again.
S2504, the terminal 100 records time information of the first application initiating the first HTTP request.
Each time the first application initiates an HTTP request to request data of a resource corresponding to the first URI, the terminal 100 may record a time when the first application requests the first URI. When the first application initiates a first HTTP request for obtaining the second fragmented data for the first URI, the terminal 100 may record the time at which the first HTTP request was initiated. For example, the time for the first application to initiate the first HTTP request is "6/18/26/3/200 ms" 2020.
S2505, the terminal 100 determines whether the first pre-fetch buffer includes the second fragment data. If yes, go to S2506; if the terminal 100 determines that the first prefetch buffer does not include the data requested in the first HTTP request, S2510 is performed.
S2506, the terminal 100 returns the second tile data in the first pre-fetch buffer to the first application.
S2507, after the terminal 100 returns the second fragment data in the first pre-fetch buffer pool to the first application, the terminal 100 deletes the second fragment data in the first pre-fetch buffer to release the storage space of the second fragment data in the first pre-fetch buffer.
After the first application initiates the first HTTP request, the terminal 100 may obtain the first HTTP request and parse out a request range (i.e., a data range of the second fragmented data) in the first HTTP request. The terminal 100 may determine whether the second slice data is included in the first prefetch buffer.
The data in the first prefetch buffer is derived from the data prefetching process for the resource corresponding to the first URI in the embodiment shown in subsequent fig. 26, and specific contents may refer to the embodiment shown in subsequent fig. 26 and are not described herein again.
When the terminal 100 determines that the second fragmented data is included in the first prefetch buffer, the terminal 100 may return the second fragmented data in the first prefetch buffer to the first application. Then, the terminal 100 may delete the second fragmented data in the first prefetch buffer to release the storage space of the second fragmented data in the first prefetch buffer.
Illustratively, the first prefetch buffer may have stored therein data in the range of 6MB-10MB of the corresponding resource of the first URI. The second fragment data requested by the first HTTP request is data in the range of 6MB-8MB in the resource corresponding to the first URI. The terminal 100 may determine that the second slice data is included in the first prefetch buffer. The terminal 100 may return the second fragment data in the first pre-fetch buffer to the first application, delete the second fragment data in the first pre-fetch buffer, and release the storage space of the second fragment data. After the second slice data is deleted, the first pre-fetching buffer stores the data in the range of 8MB-10MB in the resource corresponding to the first URI. The above examples are merely illustrative of the present application and should not be construed as limiting.
S2508, the terminal 100 judges whether the remaining buffer amount in the first prefetch buffer is lower than the water line threshold. If so, S2509 is executed, and the terminal 100 may initiate a data prefetching procedure for the resource corresponding to the first URI.
After the terminal 100 deletes the second tile data in the first pre-fetch buffer, the terminal 100 may determine whether the amount of buffered data in the first pre-fetch buffer is below a water line threshold. When the terminal 100 determines that the amount of buffered data in the first pre-fetch buffer is below the water line threshold, the terminal 100 may trigger a pre-fetch procedure for the data at the first URL. For the data prefetching process of the resource corresponding to the first URI, reference may be made to the embodiment shown in fig. 26, which is not described herein again.
Illustratively, after deleting the second slice data, the first prefetch buffer stores the data in the range of 8MB to 10MB in the resource corresponding to the first URI, i.e. the buffered amount of the first prefetch buffer is 2MB. The water line threshold may be 4MB. The terminal 100 may determine that the buffered amount of the first prefetch buffer is below the water line threshold, and the terminal 100 may trigger a data prefetch process for the resource corresponding to the first URI. The above examples are merely illustrative of the present application and should not be construed as limiting.
S2510, the terminal 100 may determine whether the number of times that the first application requests to acquire the resource corresponding to the first URI is greater than a number threshold in a specified time period according to the time information of each time the first application initiates the initial HTTP request, and if so, execute the step S2509 and the terminal 100 to trigger a data prefetching procedure for the resource corresponding to the first URI.
If the number of times of the first application accessing the first URI in the specified time period is less than or equal to the threshold number of times, executing:
s2511, the terminal 100 splits the request range of the second original request according to the key index information of the N network paths to obtain R HTTP requests, and sends the R HTTP requests to the server through the R network paths, respectively. Wherein N is greater than or equal to R, and R is a positive integer.
When the terminal 100 determines that the number of times that the first application requests the resource corresponding to the first URI in the specified time period is greater than the number threshold according to the time information of the HTTP request initiated by the first application for the first URI each time, the terminal 100 triggers a data prefetching procedure for the resource corresponding to the first URI. For the data prefetching procedure of the resource corresponding to the first URI, reference may be made to the embodiment shown in fig. 26, which is not described herein again.
For example, the terminal 100 may determine whether the number of times that the first application requests the resource corresponding to the first URI within the last 3S (i.e., within 3S before the step S2510) is greater than 3, and when the number of times that the first application requests the resource corresponding to the first URI within the last 3S is 5 times (greater than 3 times), the terminal 100 may trigger a data prefetching procedure for the resource corresponding to the first URI.
When the terminal 100 determines that the number of times that the first application requests to acquire the resource corresponding to the first URI in the specified time period is less than or equal to the threshold of the number of times according to the time information of the first application initiating the HTTP request for the first URI each time, the terminal 100 selects R network paths according to the key performance indicator information of the N network paths and the request range of the first HTTP request. Then, the terminal 100 may split the request range of the first HTTP request into R sub-request ranges according to the key performance indicator information of the R network paths. Next, the terminal 100 may determine R HTTP requests according to the first URI, the IP addresses of the servers on the R network paths, and the R sub-request ranges, and send the R HTTP requests to the servers through the R network paths, respectively.
In one possible implementation, after R network paths selected by the terminal 100 transmit data requested by the first HTTP request, the terminal 100 may first establish TCP connections with the server over the R network paths. Then, the terminal 100 may determine, according to the request range of the first HTTP request, the actual bandwidths and the round trip delays of the R network paths, the sub-request ranges corresponding to the R network paths respectively by using the following formulas.
Figure BDA0003175853830000541
FCT i =U i /Z i +0.5*RTT i Equation (25)
FCT i = c equation (26)
Wherein, in the above formula (24), M may be used to represent the data length, U, requested by the terminal 100 to the server i The method can be used for representing the length of a sub-request range corresponding to the ith network path in the R network paths, wherein i is more than or equal to 1 and less than or equal to R. In the above equation (25), FCT i Can be used for representing the completion of transmission U of the ith network path in the R network paths i Length of data. Wherein, it takes 0.5 × rtt for the terminal 100 to send the HTTP request to the server on the ith network path i When the server returns the data flow requested by the terminal 100 on the ith network path, the time is U i /Z i Wherein, Z i Which may be used to represent the true bandwidth of the ith network path of the R network paths. In the above equation (26), the terminal 100 needs to make the transmission time on each network path the same (i.e. FCT on each network path) i Are all fixed values c). The above formula is for explanation onlyThis application is not intended to be limiting.
Illustratively, the N network paths on the terminal 100 may include a cellular network path 1, a cellular network path 2, a Wi-Fi network path 1, and a Wi-Fi network path 2. The real bandwidth, round trip time RTT, and the obtained server IP address of the 4 network paths may be as shown in table 3 below:
TABLE 3
Figure BDA0003175853830000551
Therein, as can be seen from table 3 above, the real bandwidth Z of the cellular network path 1 1 Which may be 20MBps, round trip delay RTT of cellular network path 1 1 And may be 50ms. True bandwidth Z of cellular network path 2 2 May be 10MBps, round trip delay RTT of cellular network path 2 2 And may be 60ms. True bandwidth Z of Wi-Fi network path 1 3 The round trip delay RTT of path 1 of the 40MBps wi-Fi network 3 And may be 40ms. True bandwidth Z of Wi-Fi network path 2 4 May be 20MBps, the round trip delay RTT of the wi-Fi network path 2 4 And may be 60ms. The examples shown in table 3 above are merely illustrative of the present application and should not be construed as limiting.
The request range of the first HTTP request may be 6MB to 8MB, and the data length M requested by the terminal 100 to the server is 2MB. The terminal 100 may split the request range of the first HTTP request into 4 sub-request ranges, namely, sub-request ranges 1, 2, 3 and 4, through the above formulas (24), (25) and (26), according to the real bandwidths of the 4 network paths (i.e., R = N = 4).
Wherein the request range length U of cellular network path 1 1 May be 0.35MB, request range length U of cellular network path 2 2 Request range length U which may be 0.075MB, wi-Fi network path 1 3 May be 0.9MB, request range length U of cellular network path 2 4 May be 0.675MB. Thus, sub-request range 1 may be 6MB-6.35MB, with sub-request range 1 corresponding to cellular network path 1. Sub request scope2 may be 6.35MB-6.425MB, with sub-request range 2 corresponding to cellular network path 2. Sub-request range 3 may be 6.425MB-7.325MB, sub-request range 3 corresponding to Wi-Fi network path 3. Sub-request range 4 may be 7.325MB-8MB, sub-request range 4 corresponding to Wi-Fi network path 4.
The terminal 100 may determine the HTTP request 1 based on the IP address _1, the first URI, and the sub-request range 1 of the server on the cellular network path 1, and transmit the HTTP request 1 to the server through the cellular network path 1. The terminal 100 may determine the HTTP request 2 based on the IP address _2, the first URI and the sub-request range 2 of the server on the cellular network path 2 and send the HTTP request 2 to the server via the cellular network path 2. The terminal 100 may determine the HTTP request 3 according to the IP address _3, the first URI, and the sub-request range 3 of the server on the Wi-Fi network path 1, and send the HTTP request 3 to the server through the Wi-Fi network path 1. The terminal 100 may determine the HTTP request 4 according to the IP address _4, the first URI, and the sub-request range 3 of the server on the Wi-Fi network path 2, and send the HTTP request 4 to the server through the Wi-Fi network path 2.
The above examples are merely illustrative of the present application and should not be construed as limiting.
In a possible implementation manner, after R network paths selected by the terminal 100 transmit data requested by the first HTTP request, the terminal 100 may determine sub-request ranges corresponding to the R network paths according to a request range of the first HTTP request, actual bandwidths of the R network paths, and round-trip delay. The terminal 100 then establishes TCP connections with the server over R network paths. At this time, the terminal 100 establishes TCP connection with the server through three-way handshake on the ith network path, which takes 1.5 × rtt i . It takes 0.5 × rtt for the terminal 100 to send the HTTP request to the server on the ith network path i When the server returns the data flow requested by the terminal 100 on the ith network path, the time is U i /Z i . Therefore, the above equation (25) may be replaced with the following equation (27):
FCT i =U i /Z i +2*RTT i formula (27)
The terminal 100 can determine the sub-request ranges corresponding to the R network paths through the above equation (24), equation (26) and equation (27).
The above formula is only used to explain the present application and should not be construed as limiting.
S2512, the terminal 100 receives R HTTP responses returned by the server on R network paths, and returns the second fragment data in the R HTTP responses to the first application.
After receiving the HTTP request sent by the terminal 100, the server may encapsulate data requested by the HTTP request in an HTTP response, and return the HTTP response to the terminal 100 according to a network path sent by the HTTP request. After receiving the R HTTP responses, the terminal 100 takes out the second fragmented data from the R HTTP responses in the order of the request range, and returns the second fragmented data to the first application.
Illustratively, the terminal 100 sends an HTTP request 1 to the server via the cellular network path 1, an HTTP request 2 to the server via the cellular network path 2, an HTTP request 3 to the server via the Wi-Fi network path 1, and an HTTP request 4 to the server via the Wi-Fi network path 2. Wherein, HTTP request 1 is used for requesting data in the range of 6MB-6.35MB of the resource corresponding to the first URI, HTTP request 2 is used for requesting data in the range of 6.35MB-6.425MB of the resource corresponding to the first URI, HTTP request 3 is used for requesting data in the range of 6.425MB-7.325MB of the resource corresponding to the first URI, and HTTP request 4 is used for requesting data in the range of 7.325MB-8MB of the resource corresponding to the first URI.
After receiving the HTTP request 1, the server may encapsulate the data in the 6 th to 6.35 th MB range of the resource corresponding to the first URI in the HTTP response 1, and return the HTTP response 1 to the terminal 100 through the cellular network path 1. After receiving the HTTP request 2, the server may encapsulate the data in the range of 6.35MB to 6.425MB of the resource corresponding to the first URI in the HTTP response 2, and return the HTTP request 2 to the terminal 100 through the cellular network path 2. After receiving the HTTP request 3, the server may encapsulate the data in the range of 6.425MB to 7.325MB of the resource corresponding to the first URI in the HTTP response 3, and return the HTTP request 3 to the terminal 100 through the Wi-Fi network path 1. After receiving the HTTP request 4, the server may encapsulate the data in the range of 7.325MB to 8MB of the resource corresponding to the first URI in the HTTP response 4, and return the HTTP request 4 to the terminal 100 through the Wi-Fi network path 2.
After receiving the HTTP response 1, the terminal 100 may retrieve data in the range of 6MB to 6.35MB of the resource corresponding to the first URI from the HTTP response 1. After HTTP response 2, the terminal 100 may retrieve data in the range of 6.35MB to 6.425MB of the resource corresponding to the first URI from HTTP response 2. After receiving the HTTP response 3, the terminal 100 may retrieve data in the range of 6.425MB to 7.325MB of the resource corresponding to the first URI from the HTTP response 3. After receiving the HTTP response 4, the terminal 100 may retrieve data in the range of 7.325MB to 8MB of the resource corresponding to the first URI from the HTTP response 4.
The terminal 100 may combine the data in the range from 6MB to 6.35MB, the data in the range from 6.35MB to 6.425MB, the data in the range from 6.425MB to 7.325MB, and the data in the range from 7.325MB to 8MB of the resource corresponding to the first URI into the second fragment data according to a range order (the byte order is arranged from small to large), and return the second fragment data to the first application. The above examples are merely illustrative of the present application and should not be construed as limiting.
The following describes a flow of a data prefetching method for a resource corresponding to a first URI provided in the fourth part of the embodiment of the present application.
Referring to fig. 26, fig. 26 is a schematic flowchart illustrating a data prefetching method according to an embodiment of the application. As shown in fig. 26, the method includes the steps of:
S2601, the terminal 100 acquires the last acquired data volume K and the last end byte position of the resource corresponding to the first URI.
Illustratively, the last acquired data amount of the resource corresponding to the first URI by the terminal 100 is 2MB, and the last request range of the resource corresponding to the first URI is 4MB-6MB. The last time the first URI was requested the end byte position of the corresponding resource may be the 6MB th byte. The examples are merely illustrative of the present application and should not be construed as limiting.
S2602, the terminal 100 determines whether the total bandwidth utilization of the N network paths exceeds a specified threshold P when the predetermined quantity is a × K (a is an integer greater than 1), and if so, executes S2603 and the terminal 100 determines a corresponding first predetermined value when the total bandwidth utilization of the N network paths is the specified threshold P. If the bandwidth utilization of the available network path does not exceed the specified threshold P, step S2607 is performed.
The terminal 100 may determine, according to the predetermined quantity a × K, the total bandwidth of the N network paths, and the average round-trip delay of the N network paths, the total bandwidth utilization of the N network paths when the predetermined quantity a × K (a is an integer greater than 1) is set.
The terminal 100 may determine the first pre-value according to the specified threshold P, the total bandwidth of the N network paths, and the average round-trip delay of the N network paths.
Illustratively, the network paths on the terminal 100 may include a cellular network path 1, a cellular network path 2, a Wi-Fi network path 1, and a Wi-Fi network path 2. Where the bandwidth of cellular network path 1 may be 20MBps and the round trip delay may be 50ms. The bandwidth of the cellular network path 2 may be 10MBps and the round trip delay may be 70ms. The bandwidth of the Wi-Fi network path 1 may be 40MBps and the round trip delay may be 40ms. The bandwidth of Wi-Fi network path 2 may be 30MBps and the round-trip delay may be 60ms. Thus, the total bandwidth of the N network paths on the terminal 100 may be 100MBps and the average round trip delay of the N network paths may be 55ms. The specified threshold P may be 80%. When a is 2, the last data prefetch amount K is 8MB, and the terminal 100 sets the prefetch amount a × K to be 16MB, it is determined that the total bandwidth utilization rate of the N network paths is 87.67% and is greater than P (e.g., 80%) through the above equations (19) and (20). Therefore, the terminal 100 may determine that the first predetermined value is 9MB according to a specified threshold P (e.g., 80%), a total bandwidth of the N network paths (e.g., 100 MBps), and an average round-trip delay of the N network paths (e.g., 55 ms).
As yet another example, the network paths on the terminal 100 may include a cellular network path 1, a cellular network path 2, a Wi-Fi network path 1, and a Wi-Fi network path 2. Where the bandwidth of cellular network path 1 may be 20MBps and the round trip delay may be 50ms. The bandwidth of cellular network path 2 may be 10MBps and the round trip delay may be 70ms. The bandwidth of Wi-Fi network path 1 may be 40MBps and the round-trip delay may be 40ms. The bandwidth of Wi-Fi network path 2 may be 30MBps and the round-trip delay may be 60ms. Thus, the total bandwidth of the N network paths on the terminal 100 may be 100MBps and the average round trip delay of the N network paths may be 55ms. a may be 2, P may be 90%, the last data prefetch K is 2MB, and when the terminal 100 sets the prefetch amount a × K to 4MB, the total bandwidth utilization of the N network paths is determined to be 64% and less than the specified threshold P (e.g., 80%) through the above equation (19) and equation (20). Accordingly, the terminal 100 may perform step S2607 described below.
S2604, the terminal 100 determines whether the remaining capacity in the first pre-fetch buffer is greater than the first pre-fetch value, if so, executes S2605 and the terminal 100 determines that the pre-fetch value is the first pre-fetch value. If the remaining capacity in the first pre-fetch buffer is less than or equal to the first pre-fetch value, S2606 is executed, and the terminal 100 determines that the pre-fetch value is the previous pre-fetch value K.
For example, the remaining buffer capacity in the first prefetch buffer may be 20MB, the first prefetch value may be 9MB, and the remaining buffer capacity in the first prefetch buffer is greater than the first prefetch value, so that the terminal 100 may determine the current prefetch value as the first prefetch value determination.
Further illustratively, the remaining buffer capacity in the first prefetch buffer may be 8.5MB, the first prefetch value may be 9MB, and the remaining buffer capacity in the first prefetch buffer is smaller than the first prefetch value, so that the terminal 100 may determine the prefetch value this time as the last prefetch value K.
S2607, the terminal 100 determines whether the remaining buffer capacity in the first pre-fetch buffer is greater than or equal to a × K, if so, executes S2608 and the terminal 100 determines that the pre-fetch value is a × K this time. If the remaining buffer capacity in the first prefetch buffer is less than a × K, S2606 is executed, and the terminal 100 determines that the current prefetch value is the last requested data volume K.
For example, a may be 2, the last requested data amount K may be 2mb, a × K may be 4MB, and the remaining buffer capacity in the first prefetch buffer may be 8.5MB greater than a × K. Therefore, the terminal 100 may determine the amount of data requested this time to be a × K.
As another example, a may be 2, the last requested data amount may be 2mb, ajk may be 4MB, and the remaining buffer capacity in the first prefetch buffer may be 3MB, less than ajk. Therefore, the terminal 100 can determine the present requested data amount as the last requested data amount K (e.g., 2 MB).
In an implementation manner, after obtaining the last requested data volume K and the last request end byte position of the resource corresponding to the first URI, the terminal 100 may directly determine whether the remaining buffer capacity in the first prefetch buffer is greater than or equal to a × K, and if so, the terminal 100 determines that a × K is the current requested data volume. If the remaining buffer capacity in the first prefetch buffer is less than a × K, the terminal 100 determines that the current requested data volume is the last requested data volume K.
S2609, the terminal 100 determines the present request range according to the first URI, the present request data size, and the last requested end byte position.
After determining the data size of the current request, the terminal 100 may determine the current request range according to the terminal byte position of the previous request.
For example, the data amount of the current request may be 8MB, the last byte position of the last request may be 6MB, and thus, the current request may range from 6MB to 14MB.
S2610, the terminal 100 selects L network paths according to the key index information of the N network paths and the current request range, and splits the current request range into L sub-request ranges. Wherein L is less than or equal to N.
S2611, the terminal 100 determines L HTTP requests according to the L sub-request ranges, the server IP addresses on the L network paths, and the first URI, and sends the L HTTP requests to the server through the L network paths, respectively.
The terminal 100 may select L network paths according to the key performance indicator information of the N network paths and the current request range. Then, the terminal 100 may split the current request range into L sub-request ranges according to the key performance indicator information of the L network paths. Next, the terminal 100 may determine L HTTP requests according to the first URI, the IP addresses of the servers on the L network paths, and the L sub-request ranges, and send the L HTTP requests to the servers through the L network paths, respectively. Wherein, one network path corresponds to one HTTP request.
For details, reference may be made to step S2511 shown in fig. 25, which is not described herein again.
S2612, the terminal 100 receives L HTTP responses returned by the server in the L network paths, acquires response data in the L HTTP responses, returns second tile data in the response data to the first application, and stores prefetch data in the response data in the first prefetch buffer.
After receiving the HTTP request sent by the terminal 100, the server may encapsulate data requested by the HTTP request in an HTTP response, and return the HTTP response to the terminal 100 according to a network path sent by the HTTP request. After receiving the L HTTP responses, the terminal 100 takes out response data from the L HTTP responses in the order of the request range. The response data may include second fragment data and prefetch data requested by the first application. The terminal 100 may extract the second fragment data requested by the first application from the response data, return the second fragment data to the first application, and store the remaining prefetch data in the response data into the first prefetch buffer. In this way, when the first application requests the fragmented data next time, the terminal 100 may directly return the fragmented data requested by the first application from the first pre-fetch buffer to the first application, thereby reducing the waiting time for the first application to request the fragmented data.
For example, the range of the current request for the resource corresponding to the first URI may be from 6MB to 14MB. After receiving the L HTTP responses, the terminal 100 may obtain data in the range from 6MB to 14MB of the resource corresponding to the first URI from the L HTTP responses. The second fragment data obtained by the first application through the first HTTP request is data within a range from 6MB to 8 MB. The terminal 100 may return the data in the range from 6MB to 8MB to the first application, and store the data in the range from 8MB to 14MB in the first prefetch buffer corresponding to the first URI. The above examples are merely illustrative of the present application and should not be construed as limiting.
The selected network paths may be the same or different each time the terminal 100 initiates the pre-fetch procedure. For example, in the current prefetching flow, the terminal 100 may select L network paths, and in the next prefetching flow, the terminal 100 may select S network paths, where S is less than or equal to N, and S is a positive integer.
In the prefetching process, the terminal 100 may obtain a first HTTP request initiated by the first application for the first URI, where the first HTTP request may be used to request the server for the first data. The terminal 100 may generate L second HTTP requests, which may be used to request second data from the server, where the second data includes the first data and a data amount of the second data is greater than a data amount of the first data. The terminal 100 may transmit the L second HTTP requests to the server through L network paths, respectively. The terminal 100 may receive L first HTTP responses sent by the server over L network paths, where the L first HTTP responses include the second data. The terminal 100 may take the first data out of the second data and return the first data to the first application through an HTTP response. The terminal 100 may store the remaining data of the second data into the first prefetch buffer.
In some scenarios, the first application of the terminal 100 may download resource data such as video from a server. The terminal 100 may obtain an HTTP request 1 issued by the first application and used for requesting the fragmented data 1 in the resource corresponding to the first URI. If the terminal 100 determines that the number of times that the first application acquires the resource corresponding to the first URI through the HTTP request is greater than the number threshold, the terminal 100 may acquire a byte range of the remaining data in the resource corresponding to the first URI, and generate r HTTP requests according to the byte range of the remaining data in the resource corresponding to the first URI, where r is less than or equal to N and is a positive integer. The terminal 100 may send the r HTTP requests to the server through r network paths, respectively, and request the server for the remaining data in the resource corresponding to the first URI (that is, directly download all the data of the resource corresponding to the first URI). After receiving the remaining data in the resource corresponding to the first URI returned by the server over the r network paths, the terminal 100 may return fragment data 1 in the remaining data in the resource corresponding to the first URI to the first application. If the first application issues the HTTP request 2 for requesting the fragment data 2 in the resource corresponding to the first URI next time, the first terminal 100 may directly take out the fragment data 2 from the remaining data in the resource corresponding to the first URI and return the fragment data 2 to the first application.
Illustratively, as shown in fig. 27, the terminal 100 may access the server through both the cellular network path and the Wi-Fi network path. Wherein, on the cellular network path, the IP address of the terminal 100 may be "189.100.3.195" and the IP address of the server may be "211.91.160.241". On the Wi-Fi network path, the IP address of the terminal 100 may be "11.240.22.56" and the IP address of the server may be "58.216.88.125".
The first application initiates an HTTP request 1 for a first URI for the first time at time t1, where the URI in the HTTP request 1 may be:
"/P _ VT/video _ focus/3F/v 3/5B99115D352202788861689856/MP4_ H.265_854x480 \500 _HEAAC1 _PVC4.MP4", a source IP address (Src) of "11.240.22.56", a destination IP address (Dst) of "58.216.88.125", a byte range (range) of "bytes =0-14163", and a destination port number of "80". The HTTP request 1 is for requesting data in the range of 0-14163 bytes of the resource corresponding to the first URI. The terminal 100 may obtain the HTTP request 1 from the port 80, change the destination port number in the HTTP request 1 from "80" to the port number "9091" corresponding to the first application, and change the destination IP address in the HTTP request 1 to the IP address "127.0.0.1" of the pre-fetch processing module local to the terminal 100. The terminal 100 acquires the modified HTTP request 1 of the destination IP address, and the modified URI in the HTTP request 1 is presented as:
"/P _ VT/video _ focus/3F/v 3/5B99115D352202788861689856/MP4_ H.265_854x480 \500 _HEAAC1 _PVC4.MP4", a source IP address (Src) of "11.240.22.56", a destination IP address (Dst) of "127.0.0.1", a byte range (range) of "bytes =0-14163", and a destination port number of "9091".
At this time, the terminal 100 determines not to perform the prefetching procedure, and therefore, the terminal 100 may directly transmit the HTTP request 1 to the server through the Wi-Fi network. The terminal 100 may receive an HTTP response 1 sent by the server over the Wi-Fi network path, where the source IP address (Src) in the HTTP response 1 is "58.216.88.125", the destination IP address is "11.240.22.56", and the content range is "bytes 0-14163/90982601". "90982601" in the content range (content range) indicates that the total size of the resource corresponding to the first URI is 90982601 bytes. The HTTP response 1 includes data in the range of 0 to 14163 bytes of the resource corresponding to the first URI. The terminal 100 may return an HTTP response 1 to the first application.
The first application initiates an HTTP request 2 for the first URI a second time at time t2, where the URI in the HTTP request 2 may be:
"/P _ VT/video _ focus/3F/v 3/5B99115D352202788861689856/MP4_ H.265_854x480 \500 _HEAAC1 _PVC4.MP4", a source IP address (Src) of "11.240.22.56", a destination IP address (Dst) of "58.216.88.125", a byte range (range) of "bytes =14164-95757", and a destination port number of "80". The HTTP request 2 is for requesting data in the range of 14164-95757 bytes of the resource to which the first URI corresponds. The terminal 100 may intercept the HTTP request 2 from the port 80, change the destination port number in the HTTP request 2 from "80" to the port number "9091" corresponding to the first application, and change the destination IP address in the HTTP request 2 to the IP address "127.0.0.1" of the pre-fetch processing module local to the terminal 100. The terminal 100 acquires the modified HTTP request 2 of the destination IP address, and the modified URI in the HTTP request 2 is presented as follows through the package capture software:
"/P _ VT/video _ cutover/3F/v3/5B99115D 3522088861689856/MP 4_ H.265_854x480_500 _HEAAC1 _ PVC4.MP4", a source IP address (Src) of "11.240.22.56", a destination IP address (Dst) of "127.0.0.1", a byte range (range) of "bytes =14164-95757", and a destination port number of "9091".
At this time, the terminal 100 determines not to perform the prefetching procedure, and therefore, the terminal 100 may directly transmit the HTTP request 2 to the server through the Wi-Fi network. The terminal 100 may receive an HTTP response 2 sent by the server over the Wi-Fi network path, where a source IP address (Src) in the HTTP response 2 is "58.216.88.125", a destination IP address is "11.240.22.56", and a content range (content range) is "bytes 14164-95757/90982601". "90982601" in the content range (content range) indicates that the total size of the resource corresponding to the first URI is 90982601 bytes. The HTTP response 2 includes data in the 14164-95757 byte range of the resource corresponding to the first URI. The terminal 100 may return an HTTP response 2 to the first application.
The first application initiates an HTTP request 3 for the first URI for the third time at time t3, where the URI in the HTTP request 3 may be:
"/P _ VT/video _ focus/3F/v 3/5B99115D352202788861689856/MP4_ H.265_854x480 \500 _HEAAC1 _PVC4.Mp4", a source IP address (Src) of "11.240.22.56", a destination IP address (Dst) of "58.216.88.125", a byte range (range) of "bytes =95758-177720" and a destination port number of "80". The HTTP request 3 is for requesting data in the 95758-177720 byte range of the resource corresponding to the first URI. The terminal 100 may obtain the HTTP request 3 from the port 80, change the destination port number in the HTTP request 3 from "80" to the port number "9091" corresponding to the first application, and change the destination IP address in the HTTP request 3 to the IP address "127.0.0.1" of the local full network aggregation module of the terminal 100. The terminal 100 acquires the modified HTTP request 3 of the destination IP address, and the modified URI in the HTTP request 3 is presented by the package capture software as follows:
"/P _ VT/video _ cutover/3F/v3/5B99115D352202788861689856/MP4_ H.265_854x480 \500 _HEAAC1 _PVC4.Mp4", a source IP address (Src) of "11.240.22.56", a destination IP address (Dst) of "127.0.0.1", a byte range (range) of "bytes =95758-177720" and a destination port number of "9091".
At this time, the terminal 100 determines to perform the prefetching procedure (for example, the number of times the first application requests the resource corresponding to the first URI reaches 3 times within 3 s), and therefore, the terminal 100 can generate the HTTP request 4 and the HTTP request 5 based on the byte range of the request in the HTTP request 3.
The URI in the HTTP request 4 may be:
"/P _ VT/video _ cut/3F/v 3/5B99115D 3522088861689856/MP 4_ H.265_854x480_500 _HEAAC1 _ PVC4.MP4", source IP address (Src) of "189.100.3.195", destination IP address (Dst) of "211.91.160.241", byte range (range) of "bytes =95758-45539187", and destination port number of "80". The HTTP request 4 is for requesting data in the 95758-45539187 byte range of the resource to which the first URI corresponds.
The URI in HTTP request 5 may be:
"/P _ VT/video _ cut/3F/v 3/5B99115D 3522088861689856/MP 4_ H.265_854x480_500 _HEAAC1 _ PVC4.MP4", a source IP address (Src) of "11.240.22.56", a destination IP address (Dst) of "58.216.88.125", a byte range (range) of "bytes = 45178-90982600", and a destination port number of "80". The HTTP request 5 is for requesting data in the 45539178-90982600 byte range of the resource corresponding to the first URI.
Accordingly, the terminal 100 may transmit the HTTP request 4 to the server through the cellular network path, and transmit the HTTP request 4 to the server through the cellular network path. The terminal 100 may receive the HTTP response 4 sent by the server over the cellular network path. In the HTTP response 4, the source IP address (Src) is "211.91.160.241", the destination IP address is "189.100.3.195", and the content range is "bytes 95758-45539187/90982601". "90982601" in the content range (content range) indicates that the total size of the resource corresponding to the first URI is 90982601 bytes. The HTTP response 4 includes data in the range of 95758-45539187 bytes of the resource corresponding to the first URI.
The terminal 100 may send the HTTP request 5 to the server over a cellular network path and the HTTP request 5 to the server over a Wi-Fi network path. The terminal 100 may receive the HTTP response 5 sent by the server over the Wi-Fi network path. In the HTTP response 5, the source IP address (Src) is "58.216.88.125", the destination IP address is "11.240.22.56", and the content range is "bytes 45539178-90982600/90982601". The HTTP response 5 includes data in the 45539178-90982600 byte range of the resource corresponding to the first URI.
Wherein, since the terminal 100 sends the HTTP request 4 to the server over the cellular network path and the terminal 100 sends the HTTP request 5 to the server over the Wi-Fi network path, the byte range in the HTTP request 4 and the byte range in the HTTP request 5 may have an overlapping portion. For example, the byte range in HTTP request 4 is "95758-45539187", the byte range in HTTP request 5 is "45539178-90982600", and the end of the byte range in HTTP request 4 and the start of the byte range in HTTP request 5 are repeated 10 bytes (the repeated byte range is "45539178-45539187"). In this way, data acquired on the cellular network path and data acquired on the Wi-Fi network path can be better combined together.
In the process of receiving the HTTP response 4 and the HTTP response 5, after receiving the data in the 95758-177720 byte range of the resource corresponding to the first URI, the terminal 100 may encapsulate the data in the 95758-177720 byte range of the resource corresponding to the first URI into the HTTP response 6, and return the HTTP response 6 to the first application. In the HTTP response 6, the source IP address (Src) is "211.91.160.241", the destination IP address (Dst) is "189.100.3.195", and the content range is "bytes95758-177720/90982601". "90982601" in the content range (content range) indicates that the total size of the resource corresponding to the first URI is 90982601 bytes. The HTTP response 6 includes data in the range of 95758-177720 bytes of the resource corresponding to the first URI.
Therefore, a fourth aspect of the embodiments of the present application provides a multi-path data prefetching method, where a terminal may prefetch data of a second data size to a server when an application service requests data of a first data size, where the second data size is larger than the first data size. Then, after receiving the data of the second data volume returned by the server, the terminal may first return the data of the first data volume in the second data volume to the application. Then, the remaining (second amount of data — first amount of data) is stored to the prefetch buffer. When the application requests the next time the remaining (second amount of data-first amount of data) bytes of data, the terminal may directly fetch the remaining (second amount of data-first amount of data) bytes of data from the pre-fetch buffer to the application. The bandwidth utilization rate of the network path between the terminal and the server is improved, and when the application frequently accesses data in different ranges on the same URI address, the time for the application to acquire the data can be saved.
The above examples are only intended to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (15)

1. A method of buffer management, comprising:
the method comprises the steps that a terminal receives data of a first file, stores the data of the first file into a first buffer area, and writes the data in the first buffer area into a magnetic disc;
the terminal monitors the buffered data volume of the first buffer area, the data volume to be transmitted of the first file, the buffer data growth rate of the first buffer area and the available memory capacity;
if the increase rate of the buffered data of the first buffer area is greater than 0, the terminal determines the required total capacity value of the first buffer area according to the buffered data volume of the first buffer area, the data volume to be transmitted of the first file, the increase rate of the buffered data of the first buffer area and the receiving rate of the network card;
if the ratio of the required total capacity value of the first buffer area to the available memory capacity of the terminal is greater than or equal to a second value and less than or equal to a first value, and the remaining buffer capacity of the first buffer area is less than the data volume to be transmitted of the first file, the terminal adjusts the size of the first buffer area to the required total capacity value of the first buffer area, wherein the first value is greater than the second value.
2. The method of claim 1, further comprising:
if the ratio of the total capacity value required by the first buffer area to the available memory capacity on the terminal is larger than the first value, the terminal adjusts the size of the first buffer area to be a first buffer capacity, wherein the ratio of the first buffer capacity to the available memory capacity is a first value.
3. The method of claim 1, further comprising:
if the ratio of the required total capacity value of the first buffer area to the available memory capacity of the terminal is smaller than the second value, the terminal adjusts the size of the first buffer area to the required total capacity value of the first buffer area.
4. The method of claim 2, wherein after the terminal adjusts the size of the first buffer to the first buffering capacity, the method further comprises:
if the times of receiving user input in a specified time period by the terminal is larger than a time threshold value, and the buffered data amount of the first buffer area is smaller than or equal to a second buffer capacity, the terminal determines a safe sending rate according to the second buffer capacity, the buffered data amount of the first buffer area, the remaining data amount of the first file, and the buffered data growth rate of the first buffer area, wherein the ratio of the second buffer capacity to the available memory capacity is the second value;
The terminal sends first rate information to a sending end of the first file, wherein the first rate information is used for indicating the sending end to adjust the sending rate of the first file to be the safe sending rate;
the terminal receives the confirmation information sent by the sending terminal;
in response to the acknowledgement information, the terminal adjusts the size of the first buffer to the second buffer capacity.
5. The method of claim 2, wherein after the terminal adjusts the size of the first buffer to the first buffering capacity, the method further comprises:
if the number of times that the terminal receives user input in a specified time period is larger than a time threshold and the buffered data volume of the first buffer area is larger than a second buffer capacity, the terminal sends second rate information to a sending end of the first file, the second rate information is used for indicating the sending end to adjust the sending rate of the first file to be smaller than or equal to the rate threshold, and the ratio of the second buffer capacity to the available memory capacity is the second value;
and if the buffered data volume of the first buffer area is smaller than the second buffer capacity, the terminal adjusts the size of the first buffer area to the second buffer capacity.
6. The method of claim 5, wherein after the terminal adjusts the size of the first buffer to the second buffering capacity, the method further comprises:
the terminal determines a safe sending rate according to the residual buffer capacity of the first buffer area, the residual data volume of the first file and the buffer data growth rate of the first buffer area;
and the terminal sends first rate information to a sending end of the first file, wherein the first rate information is used for indicating the sending end to adjust the sending rate of the first file to be the safe sending rate.
7. The method of claim 3, wherein after the terminal adjusts the size of the first buffer to the required total capacity value of the first buffer, the method further comprises:
and when the terminal determines that the increase rate of the buffered data of the first buffer area is less than 0, the terminal reduces the size of the first buffer area by the specified capacity.
8. The method according to claim 1, wherein the terminal determines the required total capacity value of the first buffer area according to the buffered data amount of the first buffer area, the data amount to be transmitted of the first file, the buffered data growth rate of the first buffer area, and the network card receiving rate, and specifically includes:
The terminal determines the required capacity value of the first buffer area according to the following formula:
c*(H-W)/A-FLS/rateNet=0
c is a conservative coefficient, c is more than 0 and less than or equal to 1, H is a required total capacity value of the first buffer area, W is a buffered data volume of the first buffer area, A is a buffered data growth rate of the first buffer area, FLS is a data volume to be transmitted of the first file, and rateNet is the network card receiving rate.
9. The method according to claim 4, wherein the terminal determines a safe transmission rate according to the second buffer capacity, the remaining data amount of the first file, and the buffer data growth rate of the first buffer, and specifically includes:
the terminal determines the safe sending rate according to the following formula:
c*(X-W)/A-FLS/V1=0
wherein c is a conservative coefficient, c is greater than 0 and less than or equal to 1, X is the second buffer capacity, W is the buffered data volume of the first buffer, A is the buffered data growth rate of the first buffer, FLS is the data volume to be transmitted of the first file, and V1 is the safe transmission rate.
10. The method according to claim 6, wherein the terminal determines a safe sending rate according to the remaining buffer capacity of the first buffer, the remaining data amount of the first file, and the buffer data growth rate of the first buffer, specifically comprising:
The terminal determines the safe sending rate according to the following formula:
c*P/A-FLS/V1=0
c is a conservative coefficient, c is more than 0 and less than or equal to 1, P is the residual buffer capacity of the first buffer area, A is the buffer data growth rate of the first buffer area, FLS is the data volume to be transmitted of the first file, and V1 is the safe transmission rate.
11. The method according to claim 4 or 6, characterized in that the method further comprises:
if the ratio of the data volume to be transmitted of the first file to the total data volume of the first file is smaller than a specified ratio value, the terminal adjusts the size of the first buffer area to be a third buffer capacity, the ratio of the third buffer capacity to the available memory capacity is a third value, and the third value is larger than the first value.
12. The method of claim 1, wherein the obtaining, by the terminal, the buffered data rate increase of the first buffer area specifically comprises:
and the terminal acquires the increase rate of the buffered data of the first buffer area by monitoring the change of the buffered data amount in the first buffer area.
13. The method of claim 1, wherein the obtaining, by the terminal, the buffered data rate increase of the first buffer area specifically comprises:
The terminal acquires the writing rate of the data of the first file written into the disk;
and the terminal determines the buffer data growth rate of the first buffer area according to the network card receiving rate and the writing rate.
14. A terminal, comprising: one or more processors, one or more memories, a network card; wherein the network card, the one or more memories are coupled with the one or more processors, the one or more memories for storing computer program code, the computer program code comprising computer instructions that, when executed by the one or more processors, cause the terminal to perform the method of any of claims 1-13.
15. A computer storage medium, comprising computer instructions which, when run on a terminal, cause the terminal to perform the method of any of claims 1-13.
CN202110832128.4A 2020-07-25 2021-07-22 Buffer management method and related device Active CN113972962B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/108275 WO2022022429A1 (en) 2020-07-25 2021-07-23 Buffer management method and related device

Applications Claiming Priority (8)

Application Number Priority Date Filing Date Title
CN202010726671 2020-07-25
CN202010726638 2020-07-25
CN2020107266571 2020-07-25
CN202010726657 2020-07-25
CN2020107266711 2020-07-25
CN2020107266389 2020-07-25
CN202010734674X 2020-07-27
CN202010734674 2020-07-27

Publications (2)

Publication Number Publication Date
CN113972962A CN113972962A (en) 2022-01-25
CN113972962B true CN113972962B (en) 2023-02-03

Family

ID=79586495

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110832128.4A Active CN113972962B (en) 2020-07-25 2021-07-22 Buffer management method and related device

Country Status (2)

Country Link
CN (1) CN113972962B (en)
WO (1) WO2022022429A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114501114A (en) * 2022-02-11 2022-05-13 福建星网智慧科技有限公司 Audio network self-adaption method and storage device
CN115277589B (en) * 2022-06-30 2023-08-29 北京比特大陆科技有限公司 Control data sending method, device, equipment and storage medium
CN116582258B (en) * 2023-06-06 2024-04-30 深圳珠宝产业服务有限公司 Enterprise management information sharing system based on Internet and data analysis

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6272589B1 (en) * 1998-03-20 2001-08-07 Kabushiki Kaisha Toshiba Method and apparatus for controlling write buffering operation in a disk drive
CN1578516A (en) * 2003-06-26 2005-02-09 日本电气株式会社 Data flow control system, method and program
CN101001362A (en) * 2006-01-11 2007-07-18 腾讯科技(深圳)有限公司 Method and terminal of on-line playing flow media
CN103402136A (en) * 2013-07-29 2013-11-20 重庆大学 Self-adaptive cache adjustment control method and device and self-adaptive player
US8787163B1 (en) * 2010-02-24 2014-07-22 Marvell International Ltd. Method and apparatus for adjusting the size of a buffer in a network node based on latency
CN107333169A (en) * 2017-06-30 2017-11-07 郑州云海信息技术有限公司 A kind of client-cache method of adjustment and device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006189937A (en) * 2004-12-28 2006-07-20 Toshiba Corp Reception device, transmission/reception device, reception method, and transmission/reception method
US8782221B2 (en) * 2012-07-05 2014-07-15 A10 Networks, Inc. Method to allocate buffer for TCP proxy session based on dynamic network conditions
US9756112B2 (en) * 2015-02-11 2017-09-05 At&T Intellectual Property I, L.P. Method and system for managing service quality according to network status predictions
US10506061B1 (en) * 2015-07-30 2019-12-10 CSC Holdings, LLC Adaptive system and method for dynamically adjusting message rates through a transport
CN107247679A (en) * 2017-05-27 2017-10-13 努比亚技术有限公司 Data transmission system and method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6272589B1 (en) * 1998-03-20 2001-08-07 Kabushiki Kaisha Toshiba Method and apparatus for controlling write buffering operation in a disk drive
CN1578516A (en) * 2003-06-26 2005-02-09 日本电气株式会社 Data flow control system, method and program
CN101001362A (en) * 2006-01-11 2007-07-18 腾讯科技(深圳)有限公司 Method and terminal of on-line playing flow media
US8787163B1 (en) * 2010-02-24 2014-07-22 Marvell International Ltd. Method and apparatus for adjusting the size of a buffer in a network node based on latency
CN103402136A (en) * 2013-07-29 2013-11-20 重庆大学 Self-adaptive cache adjustment control method and device and self-adaptive player
CN107333169A (en) * 2017-06-30 2017-11-07 郑州云海信息技术有限公司 A kind of client-cache method of adjustment and device

Also Published As

Publication number Publication date
CN113972962A (en) 2022-01-25
WO2022022429A1 (en) 2022-02-03

Similar Documents

Publication Publication Date Title
CN113972962B (en) Buffer management method and related device
US10986029B2 (en) Device, system, and method of data transport with selective utilization of a single link or multiple links
US10587522B2 (en) Data-connection aggregation
US9992786B2 (en) Facilitation of multipath scheduling
KR101554398B1 (en) System and method of performing domain name server pre-fetching
JP5878614B2 (en) System and method for optimizing media playback quality in wireless handheld computing devices
US8867354B2 (en) Transmission control method, transmission control system, communication device and recording medium of transmission control program
KR101150084B1 (en) Energy-aware communications for a multi-radio system
JP5662582B2 (en) System and method for establishing a transmission control protocol connection
KR102036579B1 (en) Method and apparatus for providing a web service in a wireless communication system
KR102658608B1 (en) Methods and apparatus for generating VR content
US20230164682A1 (en) Selection of a radio access technology for communicating data between network devices
US9893991B2 (en) Device and method for processing data in content transmission system
CN113872862B (en) Communication method, mobile device and routing device
US20120201210A1 (en) Terminal and method for data communication using multiple wireless communication methods
Jahed et al. Practical device-centric WiFi/cellular link aggregation mechanism for mobile devices
CN112566262A (en) Data processing method and device, communication equipment and storage medium
WO2022267739A1 (en) Connection detection method, client, and server
CN114500511B (en) Data transmission method and device and electronic equipment
WO2023030386A1 (en) Data transmission method, electronic device and apparatus
Chari et al. Vehicle Telematics Platform Using Multipath TCP
KR102283903B1 (en) Method for media service based on moble edge cloud and apparatus supporting the same
US9071652B1 (en) Demand based communication format switching
Bolte et al. Optimized LTE NB-IoT Sensor Node With MQTT
US20180227220A1 (en) Router Cooperation

Legal Events

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