Method and device for determining real-time data traffic consumption, equipment and medium
By determining the start and end times of traffic statistics in the Android system and calculating the traffic difference, the problem of delayed updates in the Android system is solved, enabling accurate acquisition of real-time data traffic and improving the timeliness of traffic calculation.
Patent Information
- Application Number
- CN202511879365.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-03-10
AI Technical Summary
The existing traffic statistics method in Android systems has a delayed update, which cannot meet the need for real-time data traffic acquisition. This is especially true in application scenarios that require real-time metering, leading to uneven resource utilization and billing errors.
By determining the start time of traffic statistics and the end time after the current system time, the first statistical traffic and the previous second statistical traffic between the start and end times are obtained, and the difference between the two is calculated to obtain the real-time data traffic consumption, thus avoiding internal system delay updates.
It achieves near real-time traffic results, meets the needs of real-time monitoring scenarios, improves the timeliness of data traffic calculation, and does not modify the system kernel or rely on additional hardware probes.
Smart Images

Figure CN121645203A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of mobile terminal and network traffic statistics technology, and in particular to a method, apparatus, device and medium for determining real-time data traffic consumption. Background Technology
[0002] With the development of smart terminals and mobile internet, Android-based devices are widely used in various mobile data sharing scenarios, such as sharing data traffic from the Subscriber Identity Module (SIM) card on a device with external terminals via mobile hotspot functionality. Current Android systems generally provide a traffic statistics interface, allowing applications or system services to query device data usage within a certain time frame.
[0003] However, in traditional methods, Android systems typically aggregate and update data on data usage at regular intervals or with delays. While this approach has minimal impact on typical internet browsing scenarios, it falls short of meeting the timeliness requirements of applications demanding real-time data measurement. Therefore, how to obtain data traffic data in real time has become a pressing issue. Summary of the Invention
[0004] To address the aforementioned technical problems, this disclosure provides a method, apparatus, device, and medium for determining real-time data traffic consumption, which can acquire data traffic in real time to solve the delay problem caused by traditional methods of traffic statistics.
[0005] The first aspect of this disclosure provides a method for determining real-time data traffic consumption, comprising: Determine the start time and first end time of traffic statistics; wherein the first end time is the time after the current system time; Obtain the first statistical flow between the start time and the first end time and the second statistical flow of the previous time; wherein, the second statistical flow is the data flow consumed between the start time and the second end time, and the second end time is the time before the first end time; The difference between the first statistical traffic and the second statistical traffic is calculated to obtain the real-time data traffic consumption of the user identification card; wherein, the real-time data traffic consumption is the actual data traffic consumed between the second end time and the first end time.
[0006] A second aspect of this disclosure provides an apparatus for determining real-time data traffic consumption, comprising: The first determining module is used to determine the start time and the first end time of traffic statistics; wherein the first end time is the time after the current system time; The first acquisition module is used to acquire a first statistical flow between the start time and the first end time and a second statistical flow from the previous time; wherein, the second statistical flow is the data flow consumed between the start time and the second end time, and the second end time is the time before the first end time; The first calculation module is used to calculate the difference between the first statistical traffic and the second statistical traffic to obtain the real-time data traffic consumption of the user identification card; wherein, the real-time data traffic consumption is the actual data traffic consumed between the second end time and the first end time.
[0007] A third aspect of this disclosure also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method for determining real-time data traffic consumption as proposed in any of the method embodiments of the first aspect above.
[0008] A fourth aspect of this disclosure also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the method for determining real-time data traffic consumption as proposed in any of the method embodiments of the first aspect described above.
[0009] In a fifth aspect of this disclosure, an embodiment provides a computer program product that, when an instruction processor in the computer program product is executed, performs the method for determining real-time data traffic consumption proposed in the first aspect of this disclosure.
[0010] The real-time data traffic consumption determination method provided in this application can determine the start time of traffic statistics and the first end time after the current system time, obtain the first statistical traffic and the previous second statistical traffic between the start time and the first end time, and then calculate the difference between the second statistical traffic and the first statistical traffic to obtain the real-time data traffic consumption between the second end time and the first end time. In the scheme of this disclosure, since the time interval for traffic statistics is a fixed start time and the end time after the current system time, the real-time data traffic consumption for the specified time period (i.e., the time period between the second end time and the first end time) obtained by the difference between the two statistical traffics covers the traffic statistics data of the current system time, avoiding the system's internal delay update problem in the traditional method. Therefore, the obtained real-time data traffic consumption is a near real-time traffic result, which meets the needs of real-time monitoring scenarios and improves the timeliness of data traffic calculation. Attached Figure Description
[0011] Figure 1 This is a schematic diagram of a data traffic calculation system provided in an exemplary embodiment of this disclosure.
[0012] Figure 2 This is a flowchart illustrating a method for determining real-time data traffic consumption provided in an exemplary embodiment of this disclosure.
[0013] Figure 3 This is a flowchart illustrating a method for determining real-time data traffic consumption provided in another exemplary embodiment of this disclosure.
[0014] Figure 4 This is a flowchart illustrating a method for determining real-time data traffic consumption provided in yet another exemplary embodiment of this disclosure.
[0015] Figure 5 This is a schematic diagram of the structure of a data traffic computing device provided in an exemplary embodiment of the present disclosure.
[0016] Figure 6 This is a structural diagram of an electronic device provided in an exemplary embodiment of this disclosure. Detailed Implementation
[0017] To explain this disclosure, exemplary embodiments of the disclosure will now be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the disclosure, and not all of them. It should be understood that the disclosure is not limited to exemplary embodiments.
[0018] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of this disclosure.
[0019] Application Overview The applicant discovered that the existing Android system's native traffic statistics interface allows callers to set the start and end times of the query to obtain traffic consumption within a specified time interval. However, the statistics from this interface typically originate from an internal system traffic counter, and its update frequency depends on system task scheduling, often resulting in a delay of several minutes or even longer. This makes it impossible to reflect the actual traffic consumption at the current moment. In scenarios requiring real-time billing or precise quota control, this delay can lead to uneven resource utilization, billing errors, or service control failures.
[0020] In some related technologies, it is proposed to obtain real-time traffic data by directly accessing network interface statistics files (such as / proc / net / dev or underlying driver counters) at the kernel layer. Although such methods can improve real-time performance, they have the following drawbacks: (1) They require modification or reliance on the Android kernel and underlying drivers, resulting in high customization and maintenance costs; (2) If kernel statistics files are accessed frequently, it may increase the system load and lead to a decrease in resource utilization.
[0021] In summary, traditional technologies still have shortcomings in terms of real-time traffic statistics, implementation complexity, and resource consumption. There is currently no solution that can utilize existing Android system interfaces while ensuring real-time performance and compatibility. Therefore, it is necessary to propose a new method to force the Android system interface to return near real-time traffic data without modifying the kernel, thereby meeting the needs of pay-as-you-go billing or real-time quota control.
[0022] Based on the aforementioned technical problems, the method for determining real-time data traffic consumption provided in this application can determine the start time of traffic statistics and the first end time after the current system time, obtain the first statistical traffic and the previous second statistical traffic between the start time and the first end time, and then calculate the difference between the second statistical traffic and the first statistical traffic to obtain the real-time data traffic consumption between the second end time and the first end time. In the solution of this disclosure, since the time interval constructed for traffic statistics is a fixed start time and the end time after the current system time, the real-time data traffic consumption for the specified time period (i.e., the time period between the second end time and the first end time) obtained by the difference between the two statistical traffic measurements covers the traffic statistics data of the current system time, avoiding the system's internal delay update problem in the traditional method. Therefore, the obtained real-time data traffic consumption is a near real-time traffic result, meeting the needs of real-time monitoring scenarios, thus improving the timeliness of data traffic calculation.
[0023] Compared with traditional traffic statistics, which suffer from delays and cannot meet real-time requirements, the solution proposed in this application can achieve real-time acquisition of hotspot shared traffic consumption. It can force the system interface to return the latest traffic data containing the "current moment" through a specific calling strategy without modifying the system kernel or relying on additional hardware probes. This meets the needs of application scenarios such as traffic-based billing, quota management, and real-time monitoring.
[0024] Exemplary System Figure 1 This is a schematic diagram of a data traffic calculation system provided in an exemplary embodiment of this disclosure. The data traffic calculation system may include a SIM card module, an Android system network stack, a traffic statistics interface module, a traffic acquisition module, a differential processing module, and a business logic module.
[0025] In some embodiments, the SIM card module is used to perform identity authentication and network access management for user devices sharing the network; the Android system network stack is used to share the network with user devices through the SIM card module, i.e., share hotspots.
[0026] In some embodiments, the traffic acquisition module is used to construct a time interval, that is, to determine the start time and the first end time of traffic statistics; wherein the first end time is the time after the current system time; and to acquire the second traffic statistics from the previous time.
[0027] In some embodiments, the traffic statistics interface module described above is used to call the traffic statistics interface to obtain the first statistical traffic within a time interval (i.e., between the start time and the first end time).
[0028] In some embodiments, the differential processing module described above is used to perform differential processing on the first statistical traffic and the second statistical traffic to obtain the real-time data traffic consumption of the user identification card.
[0029] In some embodiments, the above-mentioned business logic module is used to trigger the reporting of real-time data traffic consumption according to business needs.
[0030] The real-time data traffic consumption determination method provided in this application can determine the start time of traffic statistics and the first end time after the current system time, obtain the first statistical traffic and the previous second statistical traffic between the start time and the first end time, and then calculate the difference between the second statistical traffic and the first statistical traffic to obtain the real-time data traffic consumption between the second end time and the first end time. In the scheme of this disclosure, since the time interval for traffic statistics is a fixed start time and the end time after the current system time, the real-time data traffic consumption for the specified time period (i.e., the time period between the second end time and the first end time) obtained by the difference between the two statistical traffics covers the traffic statistics data of the current system time, avoiding the system's internal delay update problem in the traditional method. Therefore, the obtained real-time data traffic consumption is a near real-time traffic result, which meets the needs of real-time monitoring scenarios and improves the timeliness of data traffic calculation.
[0031] Exemplary methods Figure 2 This is a flowchart illustrating a method for determining real-time data traffic consumption provided in an exemplary embodiment of this disclosure. This embodiment can be applied to electronic devices (e.g., mobile data sharing devices), such as... Figure 2 As shown, it includes the following steps: Step 201: Determine the start time and first end time of the traffic statistics.
[0032] The first end time is the time after the current system time.
[0033] In some embodiments, this solution can be applied to mobile data sharing devices (i.e., portable hotspot devices). Mobile data sharing devices typically connect to the Internet through their built-in mobile network module (i.e., SIM card) and then create a hotspot network for user devices such as mobile phones to connect to. Thus, when user devices are connected to the hotspot network shared by the mobile data sharing device, the mobile data sharing device can use the real-time data traffic consumption determination method provided in the embodiments of this application to calculate the data traffic consumed by all devices connected to the mobile data sharing device.
[0034] In some embodiments, when performing traffic statistics, it is necessary to determine the time interval, i.e., the start and end times. To calculate the amount of real-time data after the device is powered on, the start time can be set based on the system power-on time. Thus, based on... Figure 2 ,like Figure 3 As shown, step 201 above can specifically include the following steps: Step 2011: Obtain the system boot time and the first preset duration.
[0035] In some examples, preset commands can be executed or system configuration files can be read to obtain the system boot time. The aforementioned first preset duration can be set at the factory or automatically set by the user.
[0036] Step 2012: Determine the start time based on the system boot time and the first preset duration.
[0037] In some examples, the start time is obtained by subtracting a first preset duration from the system boot time. For example, if the system time is 8:00 AM on November 10, 2025, and the first preset duration is 24 hours, the start time is 8:00 AM on November 9, 2025.
[0038] Based on the above embodiments, since the system boot time and the first preset duration can be obtained, and the start time can be determined based on the system boot time and the first preset duration, the external dependence is reduced by utilizing the device's own objective time base, and the start time can be dynamically adjusted through simple calculation. Compared with traditional solutions that may require pre-storing the start time of each statistical period, this method does not require additional storage. It only calculates in real time using the system boot time and the first preset duration when needed. This reduces the occupation of storage resources and avoids the storage pressure caused by the accumulation of historical start times.
[0039] In some embodiments, to ensure the system must return the real-time data traffic consumption at the current system moment, the end time needs to be set to a future time, i.e., a time after the current system moment. Thus, based on... Figure 2 ,like Figure 4As shown, step 201 above can specifically include the following steps: Step 2013: Obtain the current system time and the second preset duration.
[0040] In some examples, the current system time can be obtained by calling system-provided interfaces, executing preset commands, or reading system configuration files. The aforementioned second preset duration can be set at the factory or automatically set by the user. It should be noted that the second preset duration is usually not too large, so it can be limited to a duration no greater than a preset threshold. For example, if the preset threshold is 2 minutes, the second preset duration can be 30 seconds or 2 minutes, etc.
[0041] Step 2014: Determine the first end time based on the current system time and the second preset duration.
[0042] In some examples, a second preset duration is added to the current system time to obtain the first end time. For example, if the system time is 8:00 AM on November 10, 2025, and the second preset duration is 2 minutes, the first end time is 8:02 AM on November 9, 2025.
[0043] Based on the above embodiments, since the current system time and the second preset duration can be obtained, and the first end time can be determined based on the current system time and the second preset duration, the end time is a future point in time, thereby ensuring that the time interval covers the current system time and bypasses the original statistical delay of the system, thus achieving real-time traffic statistics.
[0044] In some embodiments, steps 201 to 203 can be executed to obtain real-time data traffic consumption based on business needs. For example, steps 201 to 203 can be executed periodically (e.g., every 30 seconds or at 3 PM daily), or, upon receiving a traffic calculation request from the server, steps 201 to 203 can be executed in response to that request. Alternatively, the user's real-time location can be obtained, and steps 201 to 203 can be executed based on that location. Thus, by selecting different strategies to execute this solution according to the business scenario, both real-time performance and system resource utilization can be ensured.
[0045] For example, this solution can be applied to mobile data sharing devices overseas. Since overseas data traffic is expensive, overseas travelers usually purchase a certain amount of data packages in advance for use within a specified period. During this period, in order to avoid running out of data or exceeding the data allowance, they will frequently check their data usage. Therefore, the user's real-time location can be obtained. If the user's real-time location is overseas, steps 201 to 203 are used to check their data usage.
[0046] Step 202: Obtain the first statistical flow between the start time and the first end time, and the second statistical flow of the previous time.
[0047] The second statistic is the data flow consumed between the start time and the second end time, and the second end time is the time before the first end time.
[0048] In some embodiments, the system traffic statistics interface can be called, and the above-mentioned start time and first end time can be passed in to obtain the traffic statistics data between the start time and the first end time returned by the system, i.e., the first statistical traffic.
[0049] For example, taking the Android system as an example, you can call the system traffic statistics interface querySummary(), passing in the start time and the first end time, to obtain the traffic statistics data between the start time and the first end time returned by the system.
[0050] In some examples, since this scheme can save the previous traffic statistics, the second traffic statistics from the previous time can be retrieved directly from the cache.
[0051] In some embodiments, after step 202 above, the method for determining real-time data traffic consumption provided in this application embodiment may further include: saving the first statistical traffic.
[0052] In some examples, in order to calculate real-time data traffic consumption in the next traffic statistics, it is necessary to save the cumulative value for each time, that is, to save the first statistics traffic in the cache.
[0053] For example, while saving the second statistical traffic, the first statistical traffic is saved in other free buffer areas; or, the second statistical traffic is replaced by saving the first statistical traffic, that is, only the latest statistical traffic is saved.
[0054] Based on the above embodiments, since the first statistical flow can be saved, after the next statistical flow, the first statistical flow can be used as a basis or benchmark to calculate the real-time data flow consumption by performing a differential operation based on the first statistical flow and the next statistical flow. In this way, the differential mechanism ensures that the obtained flow value accurately reflects the near-real-time consumption situation, rather than being repeatedly accumulated.
[0055] Step 203: Calculate the difference between the first statistical flow and the second statistical flow to obtain the real-time data flow consumption of the user identification card.
[0056] Among them, real-time data traffic consumption refers to the actual data traffic consumed between the second end time and the first end time.
[0057] In some examples, the aforementioned user identification card can be a different type of SIM card, such as a physical SIM card or a virtual SIM card, where the virtual SIM card can be an embedded SIM (eSIM) card. This ensures the versatility and feasibility of this solution on diverse and customized Android devices. Furthermore, in cases involving multiple user identification cards, the real-time data consumption of a specific user identification card can be statistically analyzed based on its unique identifier.
[0058] In some embodiments, after obtaining the second statistical traffic and the first statistical traffic, since the first statistical traffic is the data traffic consumed between the start time and the first end time, and the first statistical traffic includes the data traffic consumed between the start time and the second end time before the first end time (i.e., the second statistical traffic), in order to calculate the actual data traffic consumed by the user identification card between the second end time and the first end time, the second statistical traffic can be subtracted from the first statistical traffic to obtain the real-time data traffic consumption of the user identification card.
[0059] For example, let's take a start time of t1, a first end time of t2, and a second end time of t3. Assume the first statistical flow is T1, the second statistical flow is T2, and the actual data flow consumed between t3 and t2 (i.e., the real-time data flow consumption of the user identification card) is T3, where T3 = T1 - T2.
[0060] The real-time data traffic consumption determination method provided in this application can determine the start time of traffic statistics and the first end time after the current system time, obtain the first statistical traffic and the previous second statistical traffic between the start time and the first end time, and then calculate the difference between the second statistical traffic and the first statistical traffic to obtain the real-time data traffic consumption between the second end time and the first end time. In the scheme of this disclosure, since the time interval for traffic statistics is a fixed start time and the end time after the current system time, the real-time data traffic consumption for the specified time period (i.e., the time period between the second end time and the first end time) obtained by the difference between the two statistical traffics covers the traffic statistics data of the current system time, avoiding the system's internal delay update problem in the traditional method. Therefore, the obtained real-time data traffic consumption is a near real-time traffic result, which meets the needs of real-time monitoring scenarios and improves the timeliness of data traffic calculation.
[0061] In some embodiments, after step 203 above, the method for determining real-time data traffic consumption provided in this application embodiment may further include: reporting real-time data traffic consumption when the interval time reaches a preset duration.
[0062] In some examples, the preset duration can be either factory-set or user-defined. The interval can refer to the time interval between the last reported time and the current system time.
[0063] For example, a timer can be used to trigger a report of real-time data traffic consumption at preset intervals. A fixed preset interval (e.g., 5 minutes) can be pre-set. The timer uses the last report time as a reference, and when the preset interval is reached between the last report time and the current system time, the real-time data traffic consumption can be reported to the server. Afterwards, a timer can be started again based on the current system time to wait for the next report.
[0064] In other embodiments, real-time data traffic consumption can be acquired periodically. Multiple real-time data traffic consumptions can be acquired within a preset time period. When the preset time interval is reached, the cumulative data traffic consumption can be obtained by summing the multiple real-time data traffic consumptions and reporting the cumulative data traffic consumption. For example, assuming the preset time period is 5 minutes, all real-time data traffic consumptions within 5 minutes can be summed and then reported to the server.
[0065] Based on the above embodiments, since real-time data traffic consumption can be reported when the interval reaches a preset duration, continuous monitoring of traffic can be achieved. Thus, in some specific scenarios, this method can prevent users from running out of traffic or using excessive traffic.
[0066] In some other embodiments, after step 203 above, the method for determining real-time data traffic consumption provided in this application may further include: summing multiple real-time data traffic consumptions to obtain cumulative traffic consumption; and reporting the cumulative traffic consumption if the cumulative traffic consumption is greater than or equal to a preset traffic threshold.
[0067] In some examples, the preset traffic threshold can be either the factory default setting or a user-defined setting.
[0068] For example, let's take a preset traffic threshold of 1MB. Assume multiple real-time data traffic consumptions include a first real-time data traffic consumption, a second real-time data traffic consumption, and a third real-time data traffic consumption. If the first real-time data traffic consumption is 500KB, the second real-time data traffic consumption is 300KB, and the third real-time data traffic consumption is 400KB, then the cumulative traffic consumption = 500 + 300 + 400 = 1200KB. Since the cumulative traffic consumption of 1200KB is greater than 1024KB, meaning the traffic usage has triggered the threshold condition, we can report to the server that the cumulative traffic consumption has reached 1200KB.
[0069] Based on the above embodiments, since the cumulative data traffic consumption of multiple real-time data can be summed to obtain the cumulative traffic consumption, and the cumulative traffic consumption is reported when the cumulative traffic consumption is greater than or equal to a preset traffic threshold, corresponding measures can be taken in a timely manner by reporting when the user's traffic consumption is large, such as notifying the user or limiting the flow.
[0070] Exemplary device Figure 5 This is a schematic diagram of a device for determining real-time data traffic consumption, provided as an exemplary embodiment of the present disclosure. This device can be installed in electronic devices such as terminal devices and servers to execute the method for determining real-time data traffic consumption according to any of the embodiments described above.
[0071] like Figure 5 As shown, the device 300 may include: The first determining module 301 can be used to determine the start time and the first end time of traffic statistics; wherein, the first end time is the time after the current system time; The first acquisition module 302 can be used to acquire a first statistical flow between the start time and the first end time and a second statistical flow from the previous time; wherein, the second statistical flow is the data flow consumed between the start time and the second end time, and the second end time is the time before the first end time; The first calculation module 303 can be used to calculate the difference between the first statistical traffic and the second statistical traffic to obtain the real-time data traffic consumption of the user identification card; wherein, the real-time data traffic consumption is the actual data traffic consumed between the second end time and the first end time.
[0072] In one possible implementation, the first acquisition module 302 may be specifically used to: acquire the system boot time and a first preset duration; and determine the start time based on the system boot time and the first preset duration.
[0073] In one possible implementation, the first acquisition module 302 may be specifically used to: acquire the current system time and the second preset duration; and determine the first end time based on the current system time and the second preset duration.
[0074] In one possible implementation, the above-mentioned device may further include: a traffic reporting module, which can be used to report the real-time data traffic consumption when the interval reaches a preset duration.
[0075] In one possible implementation, the above-mentioned device may further include: a second calculation module, which can be used to sum the real-time data traffic consumption of multiple data sources to obtain the cumulative traffic consumption; and a traffic reporting module, which can be used to report the cumulative traffic consumption when the cumulative traffic consumption is greater than or equal to a preset traffic threshold.
[0076] In one possible implementation, the above-mentioned apparatus may further include: a data storage module, which can be used to store the first statistical flow.
[0077] The beneficial technical effects corresponding to the exemplary embodiments of this device can be found in the corresponding beneficial technical effects in the exemplary method section above, and will not be repeated here.
[0078] Exemplary electronic devices Figure 6 A structural diagram of an electronic device provided in an embodiment of this disclosure includes at least one processor 111 and a memory 112.
[0079] The processor 111 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 11 to perform desired functions.
[0080] The memory 112 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 111 may execute one or more computer program instructions to implement the methods for determining real-time data traffic consumption and / or other desired functions of the various embodiments of this disclosure described above.
[0081] In one example, the electronic device 11 may also include an input device 113 and an output device 114, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0082] The input device 113 may also include, for example, a keyboard, a mouse, etc.
[0083] The output device 114 can output various information to the outside, including, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0084] Of course, for the sake of simplicity, Figure 6Only some of the components of the electronic device 11 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 11 may include any other suitable components depending on the specific application.
[0085] Exemplary computer program products and computer-readable storage media In addition to the methods and apparatus described above, embodiments of this disclosure may also provide a computer program product, including computer program instructions, which, when executed by a processor, cause the processor to perform the steps of the method for determining real-time data traffic consumption in the various embodiments of this disclosure described in the "Exemplary Methods" section above.
[0086] Computer program products can be written in any combination of one or more programming languages to perform the operations of embodiments of this disclosure. These programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0087] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps in the methods for determining real-time data traffic consumption of the various embodiments of this disclosure described in the "Exemplary Methods" section above.
[0088] Computer-readable storage media may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, but is not limited to, systems, apparatuses, or devices that are electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0089] The basic principles of this disclosure have been described above with reference to specific embodiments. However, the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0090] Various modifications and variations can be made to this disclosure without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this disclosure and their equivalents, this disclosure is also intended to include such modifications and variations.
Claims
1. A method for determining real-time data traffic consumption, the method comprising: determining a start time and a first end time for traffic statistics, wherein the first end time is a time after a current time of a system; obtaining a first statistical traffic between the start time and the first end time and a second statistical traffic of a last time, wherein the second statistical traffic is a data traffic consumed between the start time and a second end time, and the second end time is a time before the first end time; calculating a difference between the first statistical traffic and the second statistical traffic to obtain a real-time data traffic consumption of a user identification card, wherein the real-time data traffic consumption is an actual data traffic consumed between the second end time and the first end time.
2. The method of claim 1, wherein, The determining of the start time and the first end time for traffic statistics comprises: obtaining a system boot time and a first preset time length; determining the start time based on the system boot time and the first preset time length.
3. The method of claim 1 or 2, wherein, The determining of the start time and the first end time for traffic statistics comprises: obtaining the current time of the system and a second preset time length; determining the first end time based on the current time of the system and the second preset time length.
4. The method of any one of claims 1 to 3, wherein, After the calculating of the difference between the first statistical traffic and the second statistical traffic to obtain the real-time data traffic consumption of the user identification card, the method further comprises: reporting the real-time data traffic consumption in a case where an interval time reaches a preset time length.
5. The method of any one of claims 1 to 3, wherein, After the calculating of the difference between the first statistical traffic and the second statistical traffic to obtain the real-time data traffic consumption of the user identification card, the method further comprises: summing a plurality of the real-time data traffic consumptions to obtain a cumulative consumption traffic; reporting the cumulative consumption traffic in a case where the cumulative consumption traffic is greater than or equal to a preset traffic threshold.
6. The method of claim 2, wherein, After the obtaining of the first statistical traffic and the second statistical traffic of the last time between the start time and the first end time, the method further comprises: saving the first statistical traffic. 7.A device for determining real-time data traffic consumption, the device comprising: a first determining module configured to determine a start time and a first end time for traffic statistics, wherein the first end time is a time after a current time of a system; a first obtaining module configured to obtain a first statistical traffic between the start time and the first end time and a second statistical traffic of a last time, wherein the second statistical traffic is a data traffic consumed between the start time and a second end time, and the second end time is a time before the first end time; a first calculating module configured to calculate a difference between the first statistical traffic and the second statistical traffic to obtain a real-time data traffic consumption of a user identification card, wherein the real-time data traffic consumption is an actual data traffic consumed between the second end time and the first end time. 8.A computer readable storage medium, the storage medium storing a computer program, the computer program being configured to execute the method for determining real-time data traffic consumption according to any one of claims 1-6.
9. An electronic device, comprising: a processor; a memory for storing processor-executable instructions; the processor, for reading the executable instructions from the memory and executing the instructions to implement the method of determining real-time data traffic consumption of any of claims 1-6.
10. A computer program product comprising a computer program, characterized in that, The computer program, which when executed by a processor implements the method of determining real-time data traffic consumption of any of claims 1-6.