CN112787828A - Application flow statistical method and device and mobile electronic device - Google Patents

Application flow statistical method and device and mobile electronic device Download PDF

Info

Publication number
CN112787828A
CN112787828A CN202110024032.5A CN202110024032A CN112787828A CN 112787828 A CN112787828 A CN 112787828A CN 202110024032 A CN202110024032 A CN 202110024032A CN 112787828 A CN112787828 A CN 112787828A
Authority
CN
China
Prior art keywords
network
connection
apn
flow
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110024032.5A
Other languages
Chinese (zh)
Other versions
CN112787828B (en
Inventor
翁刚金
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Chuangtong Lianzhi Internet Of Things Co ltd
Original Assignee
Chongqing Chuangtong Lianzhi Internet Of Things Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing Chuangtong Lianzhi Internet Of Things Co ltd filed Critical Chongqing Chuangtong Lianzhi Internet Of Things Co ltd
Priority to CN202110024032.5A priority Critical patent/CN112787828B/en
Publication of CN112787828A publication Critical patent/CN112787828A/en
Application granted granted Critical
Publication of CN112787828B publication Critical patent/CN112787828B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/14Charging, metering or billing arrangements for data wireline or wireless communications
    • H04L12/1432Metric aspects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a traffic statistical method and device of an application program and mobile electronic equipment, wherein the method comprises the following steps: responding to a network connection request of an application program, and establishing data connection with an access point APN for the process of the application program; and counting the flow generated by each process through the corresponding APN by using the network connection and management service of the system so as to determine the flow generated by each APN by the application program. The technical scheme solves the problem that the flow is difficult to count under the condition that the application program uses different APNs to connect the network, and designs and realizes the technology for counting the flow consumed when the application program is connected with the specific APN by using the process identifier, so that the flow data generated when the application program is connected through different APNs can be counted, and the network connection management and the charging are facilitated.

Description

Application flow statistical method and device and mobile electronic device
Technical Field
The invention relates to the field of network connection, in particular to a traffic statistical method and device of an application program and mobile electronic equipment.
Background
For mobile terminal users such as mobile phones, there are many types of external networks that can be accessed, for example: internet, WAP website, internal network of group enterprise, and special network of industry. The range and Access mode of different Access points are different, and the network side acquires information such as IP of which network segment is allocated to which network the mobile phone is to Access after being activated according to the Access Point Name (APN), that is, the APN determines what network the mobile phone of the user accesses through which Access mode. The mobile terminal device is simultaneously networked with a plurality of APN channels, which is a requirement that different applications must be widely applied in the future, that is, different APNs are simultaneously used for network connection by different applications, but the current operating system of the mobile terminal lacks corresponding interfaces and designs for simultaneously networking a plurality of APN channels, charging modes of different APNs may be different, and a user cannot obtain how much traffic is generated by connecting different APNs.
For example, an application a uses APN 1 to perform network connection, and an application B uses APN 2 to perform network connection at the same time, because the current traffic counting mode is counted by the user identifier Uid, when the Uid of the application a is the same as that of the application B, it is impossible to count how much traffic is used by the specific application.
In another scenario, an APN 1 used by an application a in a certain time period is used for network connection, and an APN 2 used by the application a in another time period is used for network connection, and how to respectively count how much traffic the application a uses on the APN 1 and the APN 2 is also a problem that cannot be solved currently.
Disclosure of Invention
In view of the above, the present invention is proposed in order to provide a traffic statistics method, device, mobile electronic device of an application that overcomes or at least partially solves the above mentioned problems.
According to an aspect of the present invention, there is provided a traffic statistic method for an application, the method including:
responding to a network connection request of an application program, and establishing data connection with an access point APN for a process of the application program;
and counting the flow generated by each process through the corresponding APN by utilizing the network connection and management service of the system so as to determine the flow generated by each APN by the application program.
Optionally, the system is a Linux system or an android system, the network connection and management service includes a connection management module, a network policy management module, and a network statistics module, and the system further includes a telephone module and a modem or a wireless interface layer;
the establishing of the data connection with the APN for the process of the application program in response to the network connection request of the application program comprises:
receiving a request for establishing connection sent by the application program to the connection management module;
after receiving the connection request, the connection management module judges whether the connection request exists or not, and if the connection request does not exist, the connection management module sends a request for establishing data connection to the telephone module;
after receiving the request of data connection, the telephone module sends a request for establishing network connection to the modem or the wireless interface layer;
if the modem or the wireless interface layer successfully establishes the network connection, routing information is sequentially returned to the telephone module and the connection management module, the connection management module transmits the routing information to the network management module, and updates the routing information in the kernel of the system through the network management module, wherein the routing information comprises APN of the network connection.
Optionally, the counting, by using the network connection and management service of the system, traffic generated by each process through a corresponding APN includes:
and acquiring flow data of the application program and the APN during the connection period by utilizing an interface which is preset in a network statistical module and acquires the flow according to the process, storing the flow data into a virtual file system, and writing the flow data into a BIN file in a system directory after reading the flow data from the virtual file system for system call.
Optionally, the counting, by using the network connection and management service of the system, traffic generated by each process through a corresponding APN specifically includes:
and periodically calling a PerformPoll function by using a network statistical module, wherein the PerformPoll function acquires network transmission statistical information including flow data corresponding to the process from a virtual file system by calling an interface provided by a network management module, converts the network transmission statistical information into a data structure for flow statistics, stores the data structure into a HashMap variable of the network statistical module, and writes information in the HashMap variable into a BIN file corresponding to a system directory, so that the system can conveniently acquire the flow data from the BIN file.
Optionally, the type of the network corresponding to the APN is any one of the following: mobile, WiFi, BT, Internet, Ethetet, VPN, Tethering.
Optionally, the method further includes a step of performing policy management on the APN network connection, specifically:
for each APN, controlling the network connection of the corresponding process of the APN through a policy file or a preset policy interface, wherein the control comprises at least one of the following items: setting the on-off of network connection, adjusting the connection limit of network bandwidth and setting the maximum threshold of flow.
Optionally, the step of performing policy management on the APN network connection further includes:
and judging whether the flow of the current process exceeds the maximum flow threshold, if so, sending a network disconnection request to a modem or a wireless interface layer through a telephone service, and closing the APN corresponding to the process by using the modem or the wireless interface layer.
Optionally, the method further includes a step of updating a network connection state in a system kernel, specifically:
and after the network connection of the APN is closed, the network management module is notified through the telephone module and the connection management module, and the network management module updates the network connection state of the APN.
According to another aspect of the present invention, there is provided a traffic statistic apparatus for an application, the apparatus including:
the data connection unit is suitable for responding to a network connection request of an application program and establishing data connection with an access point APN for the process of the application program;
and the flow counting unit is suitable for counting the flow generated by each process through the corresponding APN by utilizing the network connection and management service of the system so as to determine the flow generated by the application program through each APN.
In accordance with yet another aspect of the present invention, there is provided a mobile electronic device comprising: a processor; and a memory arranged to store computer executable instructions that, when executed, cause the processor to perform a method as any one of the above.
According to a further aspect of the invention, there is provided a computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement a method as any one of the above.
In view of the above, in the technical solution of the present invention, in response to a network connection request of an application program, a data connection with an access point APN is established for a process of the application program; and counting the flow generated by each process through the corresponding APN by utilizing the network connection and management service of the system so as to determine the flow generated by each APN by the application program. Therefore, aiming at the technical problems in the background art, the technology for counting the flow consumed when the application program is connected with the specific APN by using the process identifier is designed and realized, so that the data of each flow generated when the application program is connected by different APNs can be counted, and the network connection management and charging are facilitated.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow diagram illustrating a method for traffic statistics for an application according to one embodiment of the invention;
FIG. 2 illustrates a flow diagram of an application connecting to a network, according to one embodiment of the invention;
FIG. 3 is a block diagram illustrating a statistical traffic interface setup using process identification according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a flow statistics device of an application according to an embodiment of the present invention;
FIG. 5 shows a schematic structural diagram of a mobile electronic device according to one embodiment of the present invention;
fig. 6 shows a schematic structural diagram of a computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
Fig. 1 shows a traffic statistical method of an application according to an embodiment of the present invention, the method including:
s110, responding to the network connection request of the application program, and establishing data connection with the APN for the process of the application program.
When an application component is started and the application has no other running components, the system will create a process containing a single thread for the application program, and certainly, multiple processes can also be created for the application program, however, a component generally corresponds to a process, the identification PID of the process will be recovered by the system after the process is terminated, when the application or a component is opened again, a process will be reallocated, and the identification of the new process is generally larger than the number of the previous identification. After the flow statistics of the process identifier is added, the flow connected with the APN of each application program can be conveniently obtained by combining the flow statistics of the APN.
And according to the requirement, a process can be created for a network module in the application program, when the application program is switched among different APNs, the processes corresponding to the different APNs are different, and therefore the flow of each application program is directly counted according to the process identification PID.
And S120, counting the flow generated by each process through the corresponding APN by using the network connection and management service of the system, so as to determine the flow generated by the application program through each APN.
In the step, on the basis of network connection and management service of the existing system, the flow of each process is acquired by designing and developing an interface for counting the flow under the process identification PID, and further the flow generated by the application program through each APN is acquired.
In a word, the technical scheme can solve the problem that different APN connections are difficult to acquire flow, thereby facilitating subsequent management and charging.
In one or some embodiments, referring to fig. 2 and fig. 3, in the case that the system is Linux or android system, the network connection and management service includes a connection management module (connectivity service), a network management module (network management service), a network policy management module (network policy management service), and a network statistics module (network statistics service), and in order to implement network communication, the android or Linux system further includes a telephone module and a modem or wireless interface layer.
The application or application program is used for providing a certain service function for a user and initiating a network connection request according to a specific APN; the Linux system Kernel is used for taking charge of functions such as network management, a protocol stack, flow statistics and the like; the telephone module Telephony is used for receiving and sending a telephone call, receiving and sending short messages, monitoring a telephone directory, monitoring a network event, reading user information and the like; the modem or Radio Interface Layer (RIL) is responsible for establishing and releasing network connection; and the Network adapter is used for hardware equipment responsible for Network transmission.
Specifically, referring to fig. 2, in the above system, in the presence of multiple APNs, an application needs to connect to a network through the following steps:
firstly, receiving a request for establishing connection, such as a NetworkRequest1, sent by the application program to the connection management module, wherein the number of the NetworkRequest may correspond to the number of the APN; and after receiving the connection request NetworkRequest1, the connection management module judges whether the connection request NetworkRequest1 already exists, and if the NetworkRequest1 is not in the network connection list, the connection management module sends a request for establishing data connection to the telephone module.
And after receiving the request of the data connection, the telephone module sends a request for establishing network connection to the modem or the wireless interface layer.
If the modem or the wireless interface layer successfully establishes network connection, an IP address of a connection network and routing information comprising APN, connection strategy and the like are sequentially returned to the telephone module and the connection management module, and the connection management module transmits the routing information to the network management module and updates the routing information in the kernel of the system through the network management module.
When other application programs exist, a new piece of routing information is established according to the same step, and different application programs can be connected with the network through different APNs at the same time.
In one or some embodiments, the specific steps for implementing the statistics of the traffic generated by the APN according to the process include: firstly, an interface capable of acquiring flow according to a process is developed in a network statistical module, then flow data of the application program and the APN during connection are acquired according to the interface and stored in a virtual file system, and then the flow data are written into a BIN file under a system directory after being read from the virtual file system so as to be called by the system.
According to the schematic structural diagram of utilizing the process identifier to count the traffic interface setting shown in fig. 3, the specific implementation process is as follows:
the network statistics module networkstatservice calls a performPoll function periodically to obtain network transmission statistics information, the performPoll function reads the network statistics information from a file containing network transmission statistics data under a/proc/directory by calling a getnetworkstatsidusiduntail, getnetworksummery and getnetworkstatterother function, converts the network statistics information into a networkstatHistory data structure, stores the networkstatvsservice three hash variables taking the variable of the networkstatkservice type corresponding to the APN and the variable of the uidstatksKey type corresponding to the UID as keys, and calls a writestatstatstatxslot, writenetworkXtlocked, and networkusLocked function according to parameter flag information transmitted by the performPoll to write the corresponding statistics information in the Haspsbind system file (n _ statistics).
Therefore, as the interface for acquiring the flow according to the PID is added in the network statistical module, different process identification PIDs can be set to surf the internet through different routes, and the passing flow is counted.
Specifically, the network type corresponding to the APN is any one of the following types: mobile network Mobile, WiFi, peer-to-peer sharing network BT, Internet, ethernet, virtual network VPN, and hotspot connection services.
In an embodiment, the method further includes a step of performing policy management on APN network connection by using a network policy module, and specifically may include: for each APN, by reading from a policy file (the policy file is stored in a network policy.xml file in a system directory), or by setting a policy setting interface (setnetpolicys and setUidPolicy) provided externally by a network policy manager, the network policy module netpolicymanagervice can control network connection according to the settings or a policy read from the policy file.
In addition, the network strategy module also has the functions of dynamically adjusting the network connection limit and dynamically setting the network connection, the mechanism of dynamically adjusting the network connection limit is to acquire the transmission statistical information of the network connection type matched with the strategy set or read above through the network StatsService service, the network strategy module adopts the network template to match the network connection type, generates effective rules according to the information and submits the rules to the connection management module, and calls the setInterfaceQuota function of the network management module to limit the bandwidth of the network connection.
Therefore, it can be known that at least one of the following controls, including setting on/off of network connection, adjusting network bandwidth connection limit, setting a maximum flow threshold, and the like, can be implemented through interfaces of different network types added in the network policy management module.
For example, the specific steps of setting the maximum flow threshold include: firstly, judging whether the flow of the current process exceeds the maximum flow threshold, if so, sending a network disconnection request to a modem or a wireless interface layer through a telephone service, and then closing the APN corresponding to the process by utilizing the modem or the wireless interface layer.
In one embodiment, the method further includes the step of updating the network connection state in the system kernel, specifically as follows: and after the network connection of the APN is closed, the network management module is informed through the telephone module and the connection management module, and then the network management module is used for updating the network connection state of the APN in the kernel of the system.
Fig. 4 shows a flow statistics apparatus 400 of an application according to an embodiment of the invention, the apparatus comprising:
a data connection unit 410 adapted to establish a data connection with an access point APN for a process of an application in response to a network connection request of the application.
When an application component is started and the application has no other running components, the system will create a process containing a single thread for the application program, and certainly, multiple processes can also be created for the application program, however, a component generally corresponds to a process, the identification PID of the process will be recovered by the system after the process is terminated, when the application or a component is opened again, a process will be reallocated, and the identification of the new process is generally larger than the number of the previous identification. After the flow statistics of the process identifier is added, the flow connected with the APN of each application program can be conveniently obtained by combining the flow statistics of the APN.
And according to the requirement, a process can be created for a network module in the application program, when the application program is switched among different APNs, the processes corresponding to the different APNs are different, and therefore the flow of each application program is directly counted according to the process identification PID.
And a traffic counting unit 420, adapted to count traffic generated by each process through a corresponding APN by using a network connection and a management service of the system, so as to determine the traffic generated by the application program through each APN.
In the step, on the basis of network connection and management service of the existing system, the flow of each process is acquired by designing and developing an interface for counting the flow under the process identification PID, and further the flow generated by the application program through each APN is acquired.
In a word, the technical scheme can solve the problem that different APN connections are difficult to acquire flow, thereby facilitating subsequent management and charging.
In one or some embodiments, referring to fig. 2 and fig. 3, in the case that the system is Linux or android system, the network connection and management service includes a connection management module (connectivity service), a network management module (network management service), a network policy management module (network policy management service), and a network statistics module (network statistics service), and in order to implement network communication, the android or Linux system further includes a telephone module and a modem or wireless interface layer.
In particular, referring to fig. 2, in the above system, in case of the presence of multiple APNs, the data connection unit 410 is further adapted to:
receiving a request for establishing connection, such as a NetworkRequest1, sent by the application to the connection management module, wherein the NetworkRequest corresponds to an APN; and after receiving the connection request NetworkRequest1, the connection management module judges whether the connection request NetworkRequest1 already exists, and if the NetworkRequest1 is not in the network connection list, the connection management module sends a request for establishing data connection to the telephone module.
And after receiving the request of the data connection, the telephone module sends a request for establishing network connection to the modem or the wireless interface layer.
If the modem or the wireless interface layer successfully establishes network connection, an IP address of a connection network and routing information comprising APN, connection strategy and the like are sequentially returned to the telephone module and the connection management module, and the connection management module transmits the routing information to the network management module and updates the routing information in the kernel of the system through the network management module.
When other application programs exist, a new piece of routing information is established according to the same step, and different application programs can be connected with the network by different APNs and other routes.
In one or some embodiments, the flow statistics unit 420 is specifically adapted to: and developing an interface capable of acquiring flow according to a process in a network statistics module, acquiring flow data of the application program and the APN during connection according to the interface, storing the flow data into a virtual file system, reading the flow data from the virtual file system, and writing the flow data into a BIN file in a system directory for system call.
According to the schematic structural diagram of utilizing the process identifier to count the traffic interface setting shown in fig. 3, the traffic counting unit 420 is configured to implement the following operations:
the network statistics module networkstatservice calls a performPoll function periodically to obtain network transmission statistics information, the performPoll function reads the network statistics information from a file containing network transmission statistics data under a/proc/directory by calling a getnetworkstatsidusiduntail, getnetworksummery and getnetworkstatterother function, converts the network statistics information into a networkstatHistory data structure, stores the networkstatvsservice three hash variables taking the variable of the networkstatkservice type corresponding to the APN and the variable of the uidstatksKey type corresponding to the UID as keys, and calls a writestatstatstatxslot, writenetworkXtlocked, and networkusLocked function according to parameter flag information transmitted by the performPoll to write the corresponding statistics information in the Haspsbind system file (n _ statistics).
Therefore, as the interface for acquiring the flow according to the PID is added in the network statistical module, different process identification PIDs can be set to surf the internet through different routes, and the passing flow is counted.
Specifically, the network type corresponding to the APN is any one of the following types: mobile network Mobile, WiFi, peer-to-peer sharing network BT, Internet, ethernet, virtual network VPN, and hotspot connection services.
In one embodiment, the apparatus further comprises a policy management unit adapted to: for each APN, by reading from a policy file (the policy file is stored in a network policy.xml file in a system directory), or by setting a policy setting interface (setnetpolicys and setUidPolicy) provided externally by a network policy manager, the network policy module netpolicymanagervice can control network connection according to the settings or a policy read from the policy file.
Therefore, it can be known that at least one of the following controls, including setting on/off of network connection, adjusting network bandwidth connection limit, setting a maximum flow threshold, and the like, can be implemented through interfaces of different network types added in the network policy management module.
In particular, the policy management unit is adapted to: and judging whether the flow of the current process exceeds the maximum flow threshold, if so, sending a network disconnection request to a modem or a wireless interface layer through a telephone service, and then closing the APN corresponding to the process by utilizing the modem or the wireless interface layer.
In one embodiment, the apparatus further comprises a status updating unit adapted to implement the following operations: and after the network connection of the APN is closed, the network management module is informed through the telephone module and the connection management module, and then the network management module is used for updating the network connection state of the APN in the kernel of the system.
In summary, the technical solution of the present invention designs and implements a technology for counting traffic consumed by an application program by using a process identifier, so as to count traffic data generated when the application program is connected through different APNs, thereby facilitating network connection management and charging.
It should be noted that:
the algorithms and displays presented herein are not associated with any particular computer, virtual machine, or other apparatus. Various general purpose devices may be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the invention and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the flow statistics apparatus of an application according to an embodiment of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
For example, fig. 5 shows a schematic structural diagram of a mobile electronic device according to one embodiment of the invention. The mobile electronic device 500 comprises a processor 510 and a memory 520 arranged to store computer executable instructions (computer readable program code). The memory 520 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. The memory 520 has a storage space 530 storing computer readable program code 531 for performing any of the method steps in the above described method. For example, the storage space 530 for storing the computer readable program code may include respective computer readable program codes 531 for respectively implementing various steps in the above method. The computer readable program code 531 may be read from or written to one or more computer program products. These computer program products comprise a program code carrier such as a hard disk, a Compact Disc (CD), a memory card or a floppy disk. Such a computer program product is typically a computer readable storage medium such as described in fig. 6. Fig. 6 shows a schematic structural diagram of a computer-readable storage medium according to an embodiment of the present invention. The computer readable storage medium 600 has stored thereon a computer readable program code 531 for performing the steps of the method according to the invention, readable by the processor 510 of the mobile electronic device 500, which computer readable program code 531, when executed by the electronic device 500, causes the mobile electronic device 500 to perform the steps of the method described above, in particular the computer readable program code 531 stored on the computer readable storage medium may perform the method shown in any of the embodiments described above. The computer readable program code 531 may be compressed in a suitable form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (10)

1. A traffic statistic method for an application program, the method comprising:
responding to a network connection request of an application program, and establishing data connection with an access point APN for a process of the application program;
and counting the flow generated by each process through the corresponding APN by utilizing the network connection and management service of the system so as to determine the flow generated by each APN by the application program.
2. The method according to claim 1, wherein the system is a Linux system or an android system, the network connection and management service includes a connection management module, a network policy management module, and a network statistics module, and the system further includes a telephone module and a modem or wireless interface layer;
the establishing of the data connection with the APN for the process of the application program in response to the network connection request of the application program comprises:
receiving a request for establishing connection sent by the application program to the connection management module;
after receiving the connection request, the connection management module judges whether the connection request exists or not, and if the connection request does not exist, the connection management module sends a request for establishing data connection to the telephone module;
after receiving the request of data connection, the telephone module sends a request for establishing network connection to the modem or the wireless interface layer;
if the modem or the wireless interface layer successfully establishes the network connection, routing information is sequentially returned to the telephone module and the connection management module, the connection management module transmits the routing information to the network management module, and updates the routing information in the kernel of the system through the network management module, wherein the routing information comprises APN of the network connection.
3. The method of claim 2, wherein the utilizing the network connection and management service of the system to count the traffic generated by each process through the corresponding APN comprises:
and acquiring flow data of the application program and the APN during the connection period by utilizing an interface which is preset in a network statistical module and acquires the flow according to the process, storing the flow data into a virtual file system, and writing the flow data into a BIN file in a system directory after reading the flow data from the virtual file system for system call.
4. The method of claim 3, wherein the utilizing the network connection and management service of the system to count the traffic generated by each process through the corresponding APN specifically comprises:
and periodically calling a PerformPoll function by using a network statistical module, wherein the PerformPoll function acquires network transmission statistical information including flow data corresponding to the process from a virtual file system by calling an interface provided by a network management module, converts the network transmission statistical information into a data structure for flow statistics, stores the data structure into a HashMap variable of the network statistical module, and writes information in the HashMap variable into a BIN file corresponding to a system directory, so that the system can conveniently acquire the flow data from the BIN file.
5. The method according to any of claims 2-4, wherein the APN corresponds to a network type that is any of the following: mobile, WiFi, BT, Internet, Ethetet, VPN, Tethering.
6. The method according to any of claims 2-4, characterized in that the method further comprises a step of performing policy management on the APN network connection, specifically:
for each APN, controlling the network connection of the corresponding process of the APN through a policy file or a preset policy interface, wherein the control comprises at least one of the following items: setting the on-off of network connection, adjusting the connection limit of network bandwidth and setting the maximum threshold of flow.
7. The method of claim 6, wherein the step of policy managing the APN network connection further comprises:
and judging whether the flow of the current process exceeds the maximum flow threshold, if so, sending a network disconnection request to a modem or a wireless interface layer through a telephone service, and closing the APN corresponding to the process by using the modem or the wireless interface layer.
8. The method according to claim 7, wherein the method further comprises the step of updating the network connection status in the system kernel, specifically:
and after the network connection of the APN is closed, the network management module is informed through the telephone module and the connection management module, and the network management module updates the network connection state of the APN in the kernel of the system.
9. An application flow statistics device, the device comprising:
the data connection unit is suitable for responding to a network connection request of an application program and establishing data connection with an access point APN for the process of the application program;
and the flow counting unit is suitable for counting the flow generated by each process through the corresponding APN by utilizing the network connection and management service of the system so as to determine the flow generated by the application program through each APN.
10. A mobile electronic device, wherein the mobile electronic device comprises: a processor; and a memory arranged to store computer-executable instructions that, when executed, cause the processor to perform the method of any one of claims 1-8.
CN202110024032.5A 2021-01-08 2021-01-08 Application flow statistical method and device and mobile electronic device Active CN112787828B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110024032.5A CN112787828B (en) 2021-01-08 2021-01-08 Application flow statistical method and device and mobile electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110024032.5A CN112787828B (en) 2021-01-08 2021-01-08 Application flow statistical method and device and mobile electronic device

Publications (2)

Publication Number Publication Date
CN112787828A true CN112787828A (en) 2021-05-11
CN112787828B CN112787828B (en) 2023-03-21

Family

ID=75756905

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110024032.5A Active CN112787828B (en) 2021-01-08 2021-01-08 Application flow statistical method and device and mobile electronic device

Country Status (1)

Country Link
CN (1) CN112787828B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114726905A (en) * 2022-03-07 2022-07-08 中科创达软件股份有限公司 Method, device, equipment and storage medium for accessing Tbox network to Android system
CN115037516A (en) * 2022-04-28 2022-09-09 统信软件技术有限公司 Application usage flow statistical method, computing device and storage medium

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060013211A1 (en) * 2004-07-14 2006-01-19 Deerman James R Apparatus and method for mapping overlapping internet protocol addresses in layer two tunneling protocols
CN102355425A (en) * 2011-10-26 2012-02-15 深信服网络科技(深圳)有限公司 Network traffic control method and device
CN102629909A (en) * 2012-03-30 2012-08-08 奇智软件(北京)有限公司 Traffic counting method and system based on processes
CN103533165A (en) * 2013-10-10 2014-01-22 成都达信通通讯设备有限公司 Multi-APN (Access Point Name) concurrency method supporting Android applications of handheld equipment and system thereof
WO2014180204A1 (en) * 2013-10-08 2014-11-13 中兴通讯股份有限公司 Customer premise equipment and method for independently counting traffic
CN104159231A (en) * 2014-08-19 2014-11-19 北京奇虎科技有限公司 Method for optimizing background flow of client, and client
CN104254097A (en) * 2013-06-27 2014-12-31 腾讯科技(深圳)有限公司 Flow control method and device
EP2933955A1 (en) * 2013-08-05 2015-10-21 Huawei Technologies Co., Ltd. Deep packet inspection method, device, and coprocessor
CN106157619A (en) * 2016-07-12 2016-11-23 浙江大学 Under hypersaturated state, road network is in fortune vehicle number computational methods
CN107800651A (en) * 2017-10-31 2018-03-13 广东欧珀移动通信有限公司 Closing application program method, apparatus, storage medium and electronic equipment
CN108259207A (en) * 2016-12-29 2018-07-06 北京国双科技有限公司 Flow statistical method, client, server and system
CN108400909A (en) * 2018-02-12 2018-08-14 腾讯科技(深圳)有限公司 A kind of flow statistical method, device, terminal device and storage medium

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060013211A1 (en) * 2004-07-14 2006-01-19 Deerman James R Apparatus and method for mapping overlapping internet protocol addresses in layer two tunneling protocols
CN102355425A (en) * 2011-10-26 2012-02-15 深信服网络科技(深圳)有限公司 Network traffic control method and device
CN102629909A (en) * 2012-03-30 2012-08-08 奇智软件(北京)有限公司 Traffic counting method and system based on processes
CN104254097A (en) * 2013-06-27 2014-12-31 腾讯科技(深圳)有限公司 Flow control method and device
EP2933955A1 (en) * 2013-08-05 2015-10-21 Huawei Technologies Co., Ltd. Deep packet inspection method, device, and coprocessor
WO2014180204A1 (en) * 2013-10-08 2014-11-13 中兴通讯股份有限公司 Customer premise equipment and method for independently counting traffic
CN103533165A (en) * 2013-10-10 2014-01-22 成都达信通通讯设备有限公司 Multi-APN (Access Point Name) concurrency method supporting Android applications of handheld equipment and system thereof
CN104159231A (en) * 2014-08-19 2014-11-19 北京奇虎科技有限公司 Method for optimizing background flow of client, and client
CN106157619A (en) * 2016-07-12 2016-11-23 浙江大学 Under hypersaturated state, road network is in fortune vehicle number computational methods
CN108259207A (en) * 2016-12-29 2018-07-06 北京国双科技有限公司 Flow statistical method, client, server and system
CN107800651A (en) * 2017-10-31 2018-03-13 广东欧珀移动通信有限公司 Closing application program method, apparatus, storage medium and electronic equipment
CN108400909A (en) * 2018-02-12 2018-08-14 腾讯科技(深圳)有限公司 A kind of flow statistical method, device, terminal device and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
杨晶晶: "基于Logistic模型的度假酒店客流量预测系统设计", 《长春师范大学学报》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114726905A (en) * 2022-03-07 2022-07-08 中科创达软件股份有限公司 Method, device, equipment and storage medium for accessing Tbox network to Android system
CN114726905B (en) * 2022-03-07 2023-09-15 中科创达软件股份有限公司 Method, device, equipment and storage medium for accessing Tbox network into Android system
CN115037516A (en) * 2022-04-28 2022-09-09 统信软件技术有限公司 Application usage flow statistical method, computing device and storage medium

Also Published As

Publication number Publication date
CN112787828B (en) 2023-03-21

Similar Documents

Publication Publication Date Title
CN101594614B (en) Data downloading methods and terminal
CN108702613B (en) Embedded user identity module, device for sending command and communication system
CN117793952A (en) Communication method and device
CN112787828B (en) Application flow statistical method and device and mobile electronic device
US20060154691A1 (en) Architecture and protocol for software defined radio system
CN107071824B (en) A kind of method and device called under network congestion
JP2004126735A (en) Communication system, relay device and communication control method
CN109891830B (en) Function scheduling method, device and system
CN112565334B (en) Access method and device of Internet of things equipment and MQTT gateway
US10893407B2 (en) Method for controlling an embedded subscriber identity module
CN110519825A (en) Processing method, device, relevant device and the storage medium of routing strategy
US8469267B2 (en) Method for implementing a wireless personal communication protocol for an IC card
CN112882742A (en) Software updating method and related equipment
CN111726367B (en) Method, device, system and equipment for binding access of Customer Premises Equipment (CPE)
CN113438169A (en) Data scheduling method, electronic equipment and storage medium
KR20040010788A (en) Implementing and coordinating configuration of protocols
CN112532664A (en) Data upgrading method and device
CN112637821B (en) Management platform and management method of vehicle communication chip and vehicle communication management system
US11487910B2 (en) Terminal and communication method
CN113448744B (en) Application program selection method and device
CN114189893A (en) O-RAN capability opening method, communication system, device and storage medium
CN111988446A (en) Message processing method and device, electronic equipment and storage medium
CN114697375B (en) Voice packet switching method and device, storage medium and electronic device
EP3324654A1 (en) Integrating internet-of-things devices with sim and without sim
CN118234007A (en) Built-in session binding support function query method and system

Legal Events

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