Time measurement method and device

By identifying session inactivity events and pausing time usage measurement in the communication service, and combining preset duration and ternary modulo operation, the problem of inaccurate time usage measurement and large computational load in the prior art is solved, achieving more accurate and efficient time usage measurement, supporting precise billing and user experience.

CN116471560BActive Publication Date: 2026-06-05BUSINESS-INTELLIGENCE OF ORIENTAL NATIONS CORP LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BUSINESS-INTELLIGENCE OF ORIENTAL NATIONS CORP LTD
Filing Date
2023-04-14
Publication Date
2026-06-05

Smart Images

  • Figure CN116471560B_ABST
    Figure CN116471560B_ABST
Patent Text Reader

Abstract

The application provides a time usage measurement method and device, the method comprises the following steps: in the case that no data packet is detected in a current time slice in a current time usage statistical period and it is determined that a session inactivity event occurs, suspending time usage measurement; obtaining a time usage measurement result corresponding to the current suspension time usage measurement based on a last time when time usage measurement is suspended, a time when a last data packet is detected in a last time slice and a time length threshold; and the preset time length is determined based on the time length threshold. The time usage measurement method and device provided by the application can reduce the calculation resources consumed by session inactivity event judgment, the accuracy of judging whether a session inactivity event occurs is higher, can perform time usage measurement more accurately based on ternary modulo operation under the condition of consuming less calculation resources, can realize time usage measurement to the second level, and can provide data support for more accurate communication service charging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a method and apparatus for measuring time usage. Background Technology

[0002] In the existing technology, the billing methods for communication services are generally divided into two types: traffic-based billing and time-based billing.

[0003] However, existing methods for measuring time usage suffer from inaccurate measurements or excessive computational complexity. Therefore, finding a more accurate and computationally efficient way to measure the time usage of communication services is a pressing technical problem that needs to be solved in this field. Summary of the Invention

[0004] This invention provides a time usage measurement method and apparatus to overcome the shortcomings of existing technologies in accurately measuring the time usage of communication services with relatively small computational requirements, thereby achieving more accurate and computationally less computationally intensive measurement of communication service time usage.

[0005] This invention provides a method for measuring time consumption, comprising:

[0006] If no data packets are detected within the current time segment of the current time usage statistics period, determine whether a session inactivity event has occurred;

[0007] If a session inactivity event is determined to have occurred, pause the time usage measurement, and obtain the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold.

[0008] If the measurement of usage during the pause period is determined to be terminated, obtain the termination time of the measurement of usage during the pause period.

[0009] The duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on the duration threshold.

[0010] According to a time usage measurement method provided by the present invention, the step of determining whether a session inactivity event has occurred includes:

[0011] If no data packet is detected in the next time segment, it is determined that a session inactivity event has occurred.

[0012] According to a time usage measurement method provided by the present invention, the step of determining whether a session inactivity event has occurred includes:

[0013] If a data packet is detected in the next time segment, determine whether the verification duration is not less than the duration threshold.

[0014] If the verification duration is not less than the duration threshold, it is determined that a session inactivity event has occurred.

[0015] The verification duration is determined based on the time when the first data packet is detected in the next time segment and the time when the last data packet is detected in the previous time segment.

[0016] According to a time usage measurement method provided by the present invention, the step of obtaining the termination time of the current pause time usage measurement when it is determined that the current pause time usage measurement has been terminated includes:

[0017] If a data packet is detected for the first time after the current pause time usage measurement, the current pause time usage measurement is determined to be terminated, and the moment when the first data packet is detected after the current pause time usage measurement is determined as the termination moment of the current pause time usage measurement.

[0018] According to a time usage measurement method provided by the present invention, the step of obtaining the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold includes:

[0019] Obtain the difference between the time when the last data packet was detected in the previous time segment and the termination time of the previous pause time measurement;

[0020] The sum of the difference and the duration threshold is obtained as the time usage measurement result corresponding to the current pause time usage measurement.

[0021] According to a time usage measurement method provided by the present invention, before determining whether a session inactivity event has occurred when no data packet is detected within the current time segment of the current time usage statistics period, the method further includes:

[0022] The moment when the first data packet is detected within the current time usage statistics period is determined as the measurement start moment of the current time usage statistics period.

[0023] Starting from the measurement start time, the current time usage statistics period is divided into multiple time segments according to the preset duration.

[0024] According to a time usage measurement method provided by the present invention, when the current pause time usage measurement is the first pause time usage measurement in the current time usage statistics period, the moment when the first data packet is detected in the current time usage statistics period is determined as the termination moment of the previous pause in the current time usage statistics period.

[0025] According to a time usage measurement method provided by the present invention, after obtaining the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold, the method further includes:

[0026] If the current time usage statistics period ends, the sum of the time usage measurement results corresponding to each pause time usage measurement within the current time usage statistics period is obtained and used as the time usage measurement result of the current time usage statistics period.

[0027] The present invention also provides a time consumption measuring device, comprising:

[0028] The event judgment module is used to determine whether a session inactivity event has occurred if no data packet is detected within the current time segment of the current usage statistics period.

[0029] The time usage measurement module is used to pause time usage measurement when a session inactivity event is determined to have occurred, and to obtain the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold.

[0030] The termination time determination module is used to obtain the termination time of the current pause time usage measurement when it is determined that the current pause time usage measurement is terminated.

[0031] The duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on the duration threshold.

[0032] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the time usage measurement method as described above.

[0033] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the time usage measurement method as described above.

[0034] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the time usage measurement method as described above.

[0035] The present invention provides a time usage measurement method and apparatus. In embodiments of the invention, when no data packets are detected within the current time segment of the current time usage statistics period and a session inactivity event is determined to have occurred, the time usage measurement is paused. Based on the termination time of the previous paused time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold, the time usage measurement result corresponding to the current paused time usage measurement is obtained. By reasonably selecting a preset duration, the session inactivity event judgment can be initiated only when there is no traffic within a certain time segment. This reduces the computational resources consumed by session inactivity event judgment, increases the accuracy of determining whether a session inactivity event has occurred, and better avoids the problem of missed detection of session inactivity events. Based on ternary modular arithmetic, time usage measurement is performed more accurately with less computational resources, achieving time usage measurement accuracy down to the second level. This provides data support for more accurate communication service billing and improves user experience. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0037] Figure 1 It is one of the existing schematic diagrams for measuring time usage based on inactive time;

[0038] Figure 2 This is the second schematic diagram of existing technology for measuring time usage based on inactive time;

[0039] Figure 3 This is the third schematic diagram of existing technology for measuring time usage based on inactive time;

[0040] Figure 4 This is the fourth schematic diagram of existing technology for measuring time usage based on inactive time;

[0041] Figure 5 This is one of the flowcharts illustrating the time consumption measurement method provided by the present invention;

[0042] Figure 6 This is a schematic diagram illustrating the principle of the time consumption measurement method provided by the present invention;

[0043] Figure 7 This is the second flowchart illustrating the time consumption measurement method provided by the present invention;

[0044] Figure 8 This is a schematic diagram of the process for detecting session inactivity time in the time usage measurement method provided by the present invention;

[0045] Figure 9 This is a schematic diagram of the time consumption measurement device provided by the present invention;

[0046] Figure 10 A schematic diagram of the structure of the electronic device provided by the invention. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0048] In the description of the invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0049] It should be noted that billing methods for communication services are generally divided into two types: traffic-based billing and time-based billing.

[0050] In time-based billing, the time usage of a session needs to be measured according to a certain strategy and a time usage report needs to be generated. Then, the time usage report can be sent to the billing system of the communication network to generate a billing invoice.

[0051] In the 4th generation mobile communication technology (4G) and the 5th generation mobile communication technology (5G), time usage can be measured based on inactive time.

[0052] Figure 1 This is one of the existing schematic diagrams for measuring time usage based on inactive time. For example... Figure 1 As shown, when the User Plane (UP) detects that the duration of no data packets in a session has reached the inactivity detection threshold, the calculation of the session's time usage is paused. That is, the idle time after the pause is not included in the session's time usage until data packets are detected to reappear in the session, at which point the calculation of the session's time usage resumes. The inactivity detection threshold can be represented by an Inactivity Detection Threshold (IDT), which can be predefined by the communication service provider.

[0053] In related technologies, the following three methods are commonly used to achieve time usage measurement based on inactive time.

[0054] Figure 2 This is the second schematic diagram of existing technology for measuring time usage based on inactive time. For example... Figure 2 As shown, the first method includes: when the user plane detects any data packet, it records the timestamp of the data packet being detected, and based on the timestamp of the data packet being detected and the timestamp of the previous data packet being detected, the time interval between the two data packets being detected can be obtained.

[0055] If the actual interval is greater than IDT, it is recorded as IDT when calculating the time usage between the two data packets; if the actual interval is not greater than IDT, it is the actual interval when calculating the time usage between the two data packets.

[0056] If a total of n data packets are detected within the time usage statistics period, the time usage between the (i+1)th data packet (0≤i≤n) and the ith data packet is obtained based on formula (1):

[0057] U i =Min(IDT,ΔT) i (1)

[0058] Where, ΔT i This represents the time interval between detecting the (i+1)th data packet and detecting the ith data packet.

[0059] The time usage within the time usage statistics period can be calculated based on formula (2):

[0060]

[0061] Figure 3 This is the third schematic diagram of existing technology for measuring time usage based on inactive time. For example... Figure 3As shown, the second method includes: taking the moment of session establishment or the moment when the first data packet is detected during the time usage statistics period as the starting moment, dividing the time usage statistics period into time segments with IDT as the step size, and setting an Inactive Flag for each time segment.

[0062] If a data packet is detected in any time segment, the Inactive Flag for that time segment is set to False (abbreviated as F); if no data packet is detected in any time segment, the Inactive Flag for that time segment is set to True (abbreviated as T).

[0063] The time usage within the time usage statistics period can be obtained by summing all time segments where the Inactive Flag is False.

[0064] If the time usage statistics period is divided into n time segments, the i-th time segment T i The idle flag InactiveFlag is F i The time usage within the time usage statistics period can be calculated based on formula (3):

[0065]

[0066] Figure 4 This is the fourth schematic diagram of existing technology for measuring time usage based on inactive time. For example... Figure 4 As shown, the third method includes: taking the moment of session establishment or the moment when the first data packet is detected after the time usage statistics are paused as the starting moment, dividing the time usage statistics period into time segments with a step size d smaller than IDT, and setting an idle flag for each time segment.

[0067] If no data packet is detected in any time segment, the IdleFlag of that time segment is set to True (abbreviated as T); if a data packet is detected in any time segment, the IdleFlag of that time segment is set to False (abbreviated as F).

[0068] If the cumulative duration of multiple consecutive time segments with the Idle Flag set to True exceeds the IDT, the time usage statistics will be paused, and subsequent time segments with the Idle Flag set to True will not be included in the time usage statistics until the next time segment with the Idle Flag set to False will resume the time usage statistics.

[0069] The above three methods of time usage measurement have the following shortcomings: When measuring time usage based on the first method, although the accuracy of the measurement results is relatively high, the computational load is too large and consumes a lot of system resources because it is necessary to save the timestamp of each data packet detected and compare it with the timestamp of the previous data packet detected. This has a significant impact on the service performance of the communication system.

[0070] While the second method for time usage measurement is simple and computationally efficient, its accuracy is low. For example, it is difficult to detect situations where data packets are detected in two adjacent time segments, but the time interval between the detection of the last data packet in the previous time segment and the detection of the first data packet in the next time segment exceeds the IDT, resulting in over-measurement of time usage. Alternatively, if the detection times of data packets follow a uniform distribution in each time segment, there is a 25% probability of missing events where idle time without data packets exceeds inactive time, and the maximum error in time usage measurement is 2*IDT.

[0071] Compared to the second method, the third method has a higher accuracy in measuring time usage. The maximum error in time usage measurement is 2*d. However, since the time segment is shortened to d / IDT in the second method, the computing resources required for time usage measurement based on the third method are IDT / d times that of the second method.

[0072] To address this issue, the present invention provides a method for measuring time usage. Based on the time usage measurement method provided by the present invention, the accuracy of the measurement results is comparable to that obtained using the first method described above, and significantly higher than that obtained using the second or third method. The required computational resources are twice that of the second method or 2d / IDT times that of the third method, enabling more accurate time usage measurement with less computational resources.

[0073] Figure 5 This is one of the flowcharts illustrating the time consumption measurement method provided by this invention. The following is in conjunction with... Figure 5 The time consumption measurement method of the present invention is described. For example... Figure 5 As shown, the method includes: step 501, if no data packet is detected in the current time segment of the current time usage statistics period, determine whether a session inactivity event has occurred.

[0074] It should be noted that the execution subject of this embodiment of the invention is a time usage measurement method.

[0075] Specifically, the current time usage statistics period is the measurement object of the time usage measurement method provided by this invention. Based on the time usage measurement method provided by this invention, the time usage measurement results corresponding to each pause in the current time usage statistics period can be obtained, thereby obtaining the time usage measurement results for the current time usage statistics period.

[0076] As an optional embodiment, before determining whether a session inactivity event has occurred if no data packet is detected within the current time segment of the current time usage statistics period, the method further includes: determining the moment when the first data packet is detected within the current time usage statistics period as the measurement start moment of the current time usage statistics period.

[0077] In this embodiment of the invention, the moment when the first data packet is detected in the current time usage statistics period can be determined as the measurement start time T of the current time usage statistics period. start .

[0078] Starting from the moment of measurement, the current time usage statistics period is divided into multiple time segments according to the preset duration.

[0079] Determine the start time T of the current time period for the usage statistics. start Subsequently, in this embodiment of the invention, the starting time T can be measured independently. start Starting from a preset time interval d, the measurement start time T is recorded in chronological order. start The current time usage statistics period is then divided into multiple time segments.

[0080] It should be noted that the aforementioned preset duration can be predefined based on prior knowledge and / or actual circumstances, according to a duration threshold. The aforementioned duration threshold can be predefined by the communication service operator. In this embodiment of the invention, the specific values ​​of the aforementioned duration threshold and the aforementioned preset duration are not limited.

[0081] Optionally, in this embodiment of the invention, the aforementioned duration threshold can be represented by IDT; and the aforementioned preset duration can be represented by d. In this embodiment of the invention, the preset duration d and the duration threshold IDT satisfy d = 0.5 * IDT.

[0082] In this embodiment of the invention, i can be determined as the index of the time segment in the current time usage statistics period; where 1≤i≤N; N represents the total number of time segments in the current time usage statistics period.

[0083] Figure 6 This is a schematic diagram illustrating the principle of the time consumption measurement method provided by the present invention. Figure 6The four small squares on the time axis represent the duration threshold IDT. Each small square on the time axis represents a duration of 0.25 * IDT, and the two small squares on the time axis represent a duration of d, which is the measurement start time T from the current time usage statistics period. start Then, on the timeline, in order from front to back, every two small squares form a time segment.

[0084] Optionally, the duration threshold IDT in this embodiment of the invention can be 4 seconds. Accordingly, Figure 6 On the timeline, each small grid represents a duration of 1 second, and the duration of each time segment in the current time usage statistics period is 2 seconds.

[0085] For the i-th time segment in the current time usage statistics period, the moment when the first data packet is detected in the i-th time segment can be determined as the first moment of the i-th time segment. The moment when the last data packet is detected in the i-th time segment is determined as the second moment of the i-th time segment.

[0086] It is understandable that the measurement start time T of the current time usage statistics period is... start The first moment of the first time segment in the current time usage statistics period. same.

[0087] It should be noted that, in this embodiment of the invention, the measurement start time T of the current time usage statistics period is... start The first moment of the i-th time segment and the second moment of the i-th time segment The above time can be expressed in Coordinated Universal Time (UTC), which is in seconds and represents the time relative to 00:00:00 on January 1, 1900.

[0088] It should be noted that the first moment of the i-th time segment and the second moment of the i-th time segment The initial values ​​of all are 0.

[0089] If the first data packet is detected within the i-th time segment, the first moment of the i-th time segment can be used as a reference. and the second moment of the i-th time segment Update to the moment when the first data packet was detected within the i-th time segment;

[0090] After detecting the first data packet in the i-th time segment, for each data packet detected in the i-th time segment, the second moment of the i-th time segment is... Update to the time of each detected data packet, until the end of the i-th time segment.

[0091] It should be noted that, in this embodiment of the invention, the current time segment in the current time usage statistics period is taken as the i-th time segment as an example to illustrate the time usage measurement method provided by the present invention.

[0092] It is understandable that, if the current time segment in the current time usage statistics period is the i-th time segment, the previous time segment is the (i-1)-th time segment, and the next time segment is the (i+1)-th time segment.

[0093] If no data packet is detected in the i-th time segment, the second moment of the i-th time segment. If the value is 0, it can be used to determine whether inactive time has occurred through conditional judgment.

[0094] As an optional embodiment, determining whether a session inactivity event has occurred includes: if no data packet is detected in the next time segment, determining that a session inactivity event has occurred.

[0095] Specifically, if no data packet is detected in the i-th time segment, the detection can be based on whether a data packet is detected in the (i+1)-th time segment, i.e., based on the second moment of the (i+1)-th time segment. Whether the value is 0 determines whether an inactive period has occurred.

[0096] If no data packets are detected in either the i-th or i+1-th time segment, it can be determined that an inactive period has occurred.

[0097] As an optional embodiment, determining whether a session inactivity event has occurred includes: if a data packet is detected in the next time segment, determining whether the verification duration is not less than a duration threshold;

[0098] If the verification duration is not less than the duration threshold, it is determined that a session inactivity event has occurred;

[0099] The verification duration is determined based on the time when the first data packet is detected in the next time segment and the time when the last data packet is detected in the previous time segment.

[0100] Specifically, if no data packet is detected in the i-th time segment, the detection can be based on whether a data packet is detected in the (i+1)-th time segment, i.e., based on the second moment of the (i+1)-th time segment. Whether the value is 0 determines whether an inactive period has occurred.

[0101] If no data packet is detected in the i-th time segment, but a data packet is detected in the (i+1)-th time segment, the verification duration D can be calculated using formula (4). idle :

[0102]

[0103] Understandable, This represents the first moment of the (i+1)th time segment, that is, the moment when the first data packet is detected within the (i+1)th time segment; This represents the second moment of the (i-1)th time segment, that is, the moment when the last data packet was detected within the (i-1)th time segment.

[0104] Get verification duration D idle Then, the verification duration D can be determined. idle Is it not less than the duration threshold IDT?

[0105] If the verification time is D idle Not less than the duration threshold IDT, i.e., D idle If the value is greater than or equal to IDT, then it can be determined that an inactive period has occurred.

[0106] If the verification time is D idle Less than the duration threshold IDT, i.e., D idle If <IDT, it can be determined that no inactive time has occurred, and the current time segment can be determined as the (i+1)th time segment, and the above judgment process can be repeated.

[0107] Step 502: If a session inactivity event is determined to have occurred, pause the time usage measurement, and obtain the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and the predefined duration threshold.

[0108] The duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on a duration threshold.

[0109] It should be noted that in this embodiment of the invention, j can be determined as the index of each pause time usage measurement in the current time usage statistics period; where 1≤j≤M; M represents the total number of pause time usage measurements in the current time usage statistics period.

[0110] In this embodiment of the invention, the measurement of pause time usage is taken as the j-th pause time usage measurement in the current time usage statistics period as an example for illustration.

[0111] Specifically, it can be based on the termination time of the previous pause and the second moment of the (i-1)th time segment. Using the duration threshold IDT, the time usage measurement result corresponding to this pause is obtained through numerical calculation.

[0112] It should be noted that, in this embodiment of the invention, a conditional judgment can be made to determine whether the previous pause has ended, and if it is determined that the previous pause has ended, the termination time of the previous pause time measurement can be obtained.

[0113] As an optional embodiment, based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold, the time usage measurement result corresponding to the current pause time usage measurement is obtained, including: obtaining the difference between the time when the last data packet was detected in the previous time segment and the termination time of the previous pause time usage measurement;

[0114] The sum of the difference and the duration threshold is used as the time usage measurement result corresponding to this pause time usage measurement.

[0115] Specifically, based on the termination time of the previous pause time usage measurement, the second moment of the (i-1)th time segment. The time usage measurement result corresponding to this pause is obtained by using formula (5) and the duration threshold IDT.

[0116]

[0117] Where v represents the time segment in which the data packet is first detected after the last pause time usage measurement, that is, the data packet is first detected in the v-th time segment after the last pause time usage measurement; This indicates the termination time of the last pause time usage measurement, which is the moment when the data packet was first detected in the v-th time segment.

[0118] Step 503: If it is determined that the current pause time usage measurement has been terminated, obtain the termination time of the current pause time usage measurement.

[0119] Specifically, in this embodiment of the invention, a condition judgment can be made to determine whether the current pause has ended, and if it is determined that the current pause has ended, the termination time of the current pause time usage measurement can be obtained.

[0120] As an optional embodiment, when it is determined that the current pause time usage measurement has ended, the termination time of the current pause time usage measurement is obtained, including: when a data packet is detected for the first time after the current pause time usage measurement, the termination time of the current pause time usage measurement is determined, and the time when the data packet is detected for the first time after the current pause time usage measurement is determined as the termination time of the current pause time usage measurement.

[0121] As an optional embodiment, if the current pause time usage measurement is the first pause time usage measurement in the current time usage statistics period, the moment when the first data packet is detected in the current time usage statistics period is determined as the termination moment of the last pause in the current time usage statistics period.

[0122] Specifically, if this pause time usage measurement is the first pause time usage measurement in the current time usage statistics period, then j=1. In this case, v represents the first time segment in the current time usage statistics period, i.e., v=1.

[0123] If it is determined that this pause is terminated, it can be based on the measurement start time T. start The second moment of the (i-1)th time segment The time usage measurement result corresponding to this pause is obtained by using formula (6) and the duration threshold IDT.

[0124]

[0125] To facilitate understanding of the embodiments of the present invention, an example is provided below.

[0126] The first moment of the first time segment in this example The second moment of the first time segment The first moment of the second time segment The second moment of the second time segment The first moment of the third time segment The second moment of the third time segment The first moment of the fourth time segment The second moment of the fourth time segment The first moment of the fifth time segment The second moment of the fifth time segment The first moment of the 6th time segment The second moment of the sixth time segment

[0127] In this example, the pause time usage measurement is the first pause time usage measurement in the current time usage statistics period;

[0128] In this example, the current time segment is the 7th time segment in the current time usage statistics period;

[0129] In this example, the duration threshold IDT is 4s.

[0130] Therefore, the time usage measurement results corresponding to this pause

[0131] It is understood that when measuring the time usage of the current time usage statistical period based on the time usage measurement method provided by this invention, it is only necessary to record the measurement start time T of the current time usage statistical period. start By cyclically recording the first and second moments of the (i-1)th, i-th, and i+1th time segments, time usage can be measured more accurately using ternary modular arithmetic based on these moments, while consuming less computational resources.

[0132] This invention, in its embodiments, pauses time usage measurement when no data packets are detected within the current time segment of the current time usage statistics period, thus confirming a session inactivity event. Based on the termination time of the previous pause, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold, it obtains the time usage measurement result corresponding to the current pause. By reasonably selecting a preset duration, it can ensure that session inactivity event judgment is only initiated when there is no traffic within a certain time segment. This reduces the computational resources consumed by session inactivity event judgment, increases the accuracy of determining whether a session inactivity event has occurred, and better avoids missed detections of session inactivity events. Based on ternary modular arithmetic, it can perform time usage measurement more accurately with less computational resources, achieving second-level accuracy. This provides data support for more accurate communication service billing and improves user experience.

[0133] Based on the content of the above embodiments, after obtaining the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and the predefined duration threshold, the method further includes: when it is determined that the current time usage statistics period has ended, obtaining the sum of the time usage measurement results corresponding to each pause time usage measurement in the current time usage statistics period, as the time usage measurement result of the current time usage statistics period.

[0134] Specifically, when it is determined that the current time usage statistics period has ended, the time usage measurement result U for the current time usage statistics period can be calculated using formula (7). total :

[0135]

[0136] This invention, by obtaining the sum of time usage measurement results corresponding to each pause time usage measurement within the current time usage statistics period when the current time usage statistics period has ended, and using this sum as the time usage measurement result for the current time usage statistics period, can obtain the time usage measurement result for the current time usage statistics period more accurately while consuming less computing resources.

[0137] To facilitate understanding of the time consumption measurement method provided by this invention, an example is given below to illustrate the time consumption measurement method provided by this invention. Figure 7 This is the second flowchart illustrating the time consumption measurement method provided by this invention. For example... Figure 7 As shown, the method includes: step 701, process start;

[0138] Step 702: Initialization, the measurement start time T of the current time usage statistics period. star An initial value of 0 indicates that the time usage for the current time usage period has not yet been measured.

[0139] Step 703: Determine whether the first data packet has been detected within the current time usage statistics period. If yes, proceed to step 704; otherwise, proceed to step 703 during each polling.

[0140] Step 704: Record the time when the first data packet is detected within the current time usage statistics period to the measurement start time T. start And measure the starting time T start Starting from a preset time interval d, the measurement start time T is recorded in chronological order. start The current time usage statistics period is then divided into multiple time segments. The moment when the first data packet is detected within the current time usage statistics period is recorded as the first moment of the first time segment within the current time usage statistics period.

[0141] Step 705: Check if a new data packet is detected in the i-th time segment. If yes, proceed to step 706; otherwise, proceed to step 709.

[0142] Step 706: Determine whether the detected new data packet is the first data packet detected within the i-th time segment. If yes, proceed to step 707; otherwise, proceed to step 708.

[0143] Step 707: Set the first moment of the i-th time segment. Updated to the moment a new data packet was detected;

[0144] Step 708: Set the second moment of the i-th time segment. Updated to the moment a new data packet was detected;

[0145] Step 709: Check the current clock to see if the i-th time segment has ended. If yes, proceed to step 710; otherwise, proceed to step 708.

[0146] Step 710: Determine whether no data packets were detected in the i-th time segment that just ended; if yes, proceed to step 712; otherwise, proceed to step 711.

[0147] Step 711: Update the index value i of the time segment, the first moment of the i-th time segment. Second moment Set the initial value to 0; and repeat steps 705 to 710.

[0148] Step 712: Determine if a session inactivity event has occurred. If yes, proceed to step 713; otherwise, proceed to step 711.

[0149] Step 713: Pause the measurement of usage time and proceed to step 714;

[0150] Step 714: Based on the termination time of the previous pause, the second moment of the (i-1)th time segment. Combined with the duration threshold IDT, the time usage measurement result corresponding to this pause is obtained.

[0151] Step 715: Check if the current time usage statistics period has ended. If yes, proceed to step 716; otherwise, proceed to step 717.

[0152] Step 716: Obtain the sum of the time usage measurement results corresponding to each pause time usage measurement within the current time usage statistics period, and use it as the time usage measurement result for the current time usage statistics period;

[0153] Step 717: Determine whether the usage measurement during this pause has terminated. If yes, proceed to step 718; otherwise, proceed to step 715 on the next polling.

[0154] Step 718: Obtain the termination time of this pause time usage measurement and its index i in the time segment, and the first moment of the i-th time segment. Second moment All values ​​are assigned to the time at which the measurement of the amount of data used during this pause ends;

[0155] Step 719, process ends.

[0156] Figure 8 This is a schematic diagram of the process for detecting session inactivity time in the time usage measurement method provided by this invention. Figure 8 As shown, the process for determining whether a session inactivity event has occurred includes: Step 801, Sub-process begins;

[0157] Step 802: Check whether a data packet is detected in the (i+1)th time segment. If not, proceed to step 803; if yes, proceed to step 807.

[0158] Step 803: Obtain the first moment of the (i+1)th time segment.

[0159] Step 804: Based on the first moment of the (i+1)th time segment The second moment of the (i-1)th time segment Get verification duration D idle ;

[0160] Step 805: Determine the verification duration D idle If the duration exceeds the threshold IDT, proceed to step 806; otherwise, proceed to step 807.

[0161] Step 806: Determine that a session inactivity event has occurred, and proceed to step 712;

[0162] Step 807: Determine that no session inactivity event has occurred, then proceed to step 710.

[0163] Figure 9 This is a schematic diagram of the time consumption measuring device provided by the present invention. The following is in conjunction with... Figure 9 The time consumption measuring device provided by the present invention will be described below. The time consumption measuring device described below can be referred to in correspondence with the time consumption measuring method provided by the present invention described above. For example... Figure 9 As shown, the device includes: an event judgment module 901, a time consumption measurement module 902, and a termination time determination module 903.

[0164] The event judgment module 901 is used to determine whether a session inactivity event has occurred if no data packet is detected within the current time segment of the current time usage statistics period.

[0165] The time usage measurement module 902 is used to pause the time usage measurement when it is determined that a session inactivity event has occurred, and to obtain the time usage measurement result corresponding to the current paused time usage measurement based on the termination time of the previous paused time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold.

[0166] The termination time determination module 903 is used to obtain the termination time of the current pause time usage measurement when it is determined that the current pause time usage measurement is terminated.

[0167] The duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on a duration threshold.

[0168] Specifically, the event judgment module 901, the time consumption measurement module 902, and the termination time determination module 903 are electrically connected.

[0169] Optionally, the event determination module 901 can be specifically used to determine that a session inactivity event has occurred if no data packet is detected in the next time segment.

[0170] The event judgment module 901 can also be specifically used to determine whether the verification duration is not less than the duration threshold when a data packet is detected in the next time segment; if the verification duration is not less than the duration threshold, it is determined that a session inactivity event has occurred; wherein, the verification duration is determined based on the time when the first data packet is detected in the next time segment and the time when the last data packet is detected in the previous time segment.

[0171] The termination time determination module 903 can be specifically used to determine the termination of the current pause time usage measurement when a data packet is detected for the first time after the next time segment, and to determine the time when the first data packet is detected for the first time after the next time segment as the termination time of the current pause time usage measurement.

[0172] The termination time determination module 903 can also be specifically used to obtain the difference between the time when the last data packet was detected in the previous time segment and the termination time of the previous pause time usage measurement; obtain the sum of the difference and the duration threshold as the time usage measurement result corresponding to this pause time usage measurement.

[0173] Optionally, the time usage measurement device may also include a time segmentation module.

[0174] The time segmentation module can be used to determine the moment when the first data packet is detected within the current time usage statistics period as the measurement start time of the current time usage statistics period; from the measurement start time, the current time usage statistics period is divided into multiple time segments according to a preset duration.

[0175] The termination time determination module 903 can also be specifically used to obtain the sum of the time usage measurement results corresponding to each pause time usage measurement within the current time usage statistics period when the current time usage statistics period has ended, and use it as the time usage measurement result of the current time usage statistics period.

[0176] The time usage measurement device in this embodiment of the invention pauses time usage measurement when no data packet is detected in the current time segment of the current time usage statistics period and a session inactivity event is determined to have occurred. Based on the termination time of the previous paused time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold, it obtains the time usage measurement result corresponding to the current paused time usage measurement. By reasonably selecting the preset duration, it can realize that the session inactivity event judgment is only initiated when there is no traffic in a certain time segment, which can reduce the computing resources consumed by the session inactivity event judgment, improve the accuracy of judging whether a session inactivity event has occurred, better avoid the problem of missed detection of session inactivity events, and can perform time usage measurement more accurately with less computing resources based on ternary modular arithmetic, achieving time usage measurement accuracy to the second level, providing data support for more accurate communication service billing, and improving user experience.

[0177] Figure 10 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 10 As shown, the electronic device may include a processor 1010, a communications interface 1020, a memory 1030, and a communication bus 1040. The processor 1010, communications interface 1020, and memory 1030 communicate with each other via the communication bus 1040. The processor 1010 can call logical instructions in the memory 1030 to execute a time usage measurement method. This method includes: if no data packet is detected in the current time segment of the current time usage statistics period, determining whether a session inactivity event has occurred; if a session inactivity event is determined to have occurred, pausing the time usage measurement, and obtaining the time usage measurement result corresponding to the current pause based on the termination time of the previous pause, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold; if the current pause is determined to be terminated, obtaining the termination time of the current pause; wherein the duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on a duration threshold.

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

[0179] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the time usage measurement method provided by the above methods. The method includes: determining whether a session inactivity event has occurred if no data packet is detected in the current time segment of the current time usage statistics period; pausing the time usage measurement if a session inactivity event is determined to have occurred, and obtaining the time usage measurement result corresponding to the current paused time usage measurement based on the termination time of the previous paused time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold; and obtaining the termination time of the current paused time usage measurement if it is determined that the current paused time usage measurement has terminated. The duration of each time segment within the current time usage statistics period is a preset duration, which is determined based on a duration threshold.

[0180] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the time usage measurement method provided by the above methods. The method includes: determining whether a session inactivity event has occurred if no data packet is detected within the current time segment of the current time usage statistics period; pausing the time usage measurement if a session inactivity event is determined to have occurred, and obtaining the time usage measurement result corresponding to the current paused time usage measurement based on the termination time of the previous paused time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold; and obtaining the termination time of the current paused time usage measurement if it is determined that the current paused time usage measurement has terminated; wherein the duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on a duration threshold.

[0181] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0182] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for measuring time consumption, characterized in that, include: If no data packets are detected within the current time segment of the current time usage statistics period, determine whether a session inactivity event has occurred; If a session inactivity event is determined to have occurred, pause the time usage measurement and obtain the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold. If the measurement of usage during the pause period is determined to be terminated, obtain the termination time of the measurement of usage during the pause period. Wherein, the duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on the duration threshold; The determination of whether a session inactivity event has occurred includes: If no data packet is detected in the next time segment, it is determined that a session inactivity event has occurred; If a data packet is detected in the next time segment, it is determined whether the verification duration is not less than the duration threshold; if the verification duration is not less than the duration threshold, it is determined that a session inactivity event has occurred; wherein, the verification duration is determined based on the time when the first data packet is detected in the next time segment and the time when the last data packet is detected in the previous time segment.

2. The time consumption measurement method according to claim 1, characterized in that, The step of obtaining the termination time of the current pause time usage measurement when it is determined that the current pause time usage measurement has been terminated includes: If a data packet is detected for the first time after the current pause time usage measurement, the current pause time usage measurement is determined to be terminated, and the moment when the data packet is detected for the first time after the current pause time usage measurement is determined as the termination moment of the current pause time usage measurement.

3. The time consumption measurement method according to claim 1, characterized in that, The process of obtaining the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold includes: Obtain the difference between the time when the last data packet was detected in the previous time segment and the termination time of the previous pause time measurement; The sum of the difference and the duration threshold is obtained as the time usage measurement result corresponding to the current pause time usage measurement.

4. The time consumption measurement method according to claim 1, characterized in that, Before determining whether a session inactivity event has occurred when no data packet is detected within the current time segment of the current time usage statistics period, the method further includes: The moment when the first data packet is detected within the current time usage statistics period is determined as the measurement start moment of the current time usage statistics period. Starting from the measurement start time, the current time usage statistics period is divided into multiple time segments according to the preset duration.

5. The time consumption measurement method according to claim 4, characterized in that, If this pause time usage measurement is the first pause time usage measurement in the current time usage statistics period, the moment when the first data packet is detected in the current time usage statistics period is determined as the termination moment of the previous pause time usage measurement in the current time usage statistics period.

6. The time consumption measurement method according to any one of claims 1 to 5, characterized in that, After obtaining the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold, the method further includes: If the current time usage statistics period ends, the sum of the time usage measurement results corresponding to each pause time usage measurement within the current time usage statistics period is obtained and used as the time usage measurement result of the current time usage statistics period.

7. A time consumption measuring device, characterized in that, include: The event judgment module is used to determine whether a session inactivity event has occurred if no data packet is detected within the current time segment of the current usage statistics period. The time usage measurement module is used to pause time usage measurement when a session inactivity event is determined to have occurred, and to obtain the time usage measurement result corresponding to the current pause time usage measurement based on the termination time of the previous pause time usage measurement, the time when the last data packet was detected in the previous time segment, and a predefined duration threshold. The termination time determination module is used to obtain the termination time of the current pause time usage measurement when it is determined that the current pause time usage measurement is terminated. Wherein, the duration of each time segment within the current time usage statistics period is a preset duration; the preset duration is determined based on the duration threshold; The event judgment module is specifically used for: If no data packet is detected in the next time segment, it is determined that a session inactivity event has occurred; If a data packet is detected in the next time segment, it is determined whether the verification duration is not less than the duration threshold; if the verification duration is not less than the duration threshold, it is determined that a session inactivity event has occurred; wherein, the verification duration is determined based on the time when the first data packet is detected in the next time segment and the time when the last data packet is detected in the previous time segment.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the time consumption measurement method as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the time usage measurement method as described in any one of claims 1 to 6.