1e41f4b71Sopenharmony_ci# @ohos.net.statistics (Traffic Management)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **statistics** module provides APIs to query real-time or historical data traffic by the specified network interface card (NIC) or user ID (UID).
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci## Modules to Import
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci```js
11e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
12e41f4b71Sopenharmony_ci```
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## statistics.getIfaceRxBytes<sup>10+</sup>
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_cigetIfaceRxBytes(nic: string, callback: AsyncCallback\<number>): void;
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of the specified NIC. This API uses an asynchronous callback to return the result.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**Parameters**
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                   |
25e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- |
26e41f4b71Sopenharmony_ci| nic      | string                 | Yes  | NIC name.                                                                                                     |
27e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time downlink data traffic of the NIC in bytes. Otherwise, **error** is an error object.   |
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**Error codes**
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci| ID| Error Message                                    |
34e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
35e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
36e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
37e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
38e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
39e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
40e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci**Example**
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci```js
45e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
46e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_cistatistics.getIfaceRxBytes("wlan0", (error: BusinessError, stats: number) => {
49e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
50e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
51e41f4b71Sopenharmony_ci});
52e41f4b71Sopenharmony_ci```
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci## statistics.getIfaceRxBytes<sup>10+</sup>
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_cigetIfaceRxBytes(nic: string): Promise\<number>;
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of the specified NIC. This API uses a promise to return the result.
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**Parameters**
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description              |
65e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------ |
66e41f4b71Sopenharmony_ci| nic    | string | Yes  | NIC name.|
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci**Return value**
69e41f4b71Sopenharmony_ci| Type| Description|
70e41f4b71Sopenharmony_ci| -------- | -------- |
71e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time downlink data traffic of the NIC in bytes.|
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**Error codes**
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci| ID| Error Message                                    |
78e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
79e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
80e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
81e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
82e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
83e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
84e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**Example**
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci```js
89e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_cistatistics.getIfaceRxBytes("wlan0").then((stats: number) => {
92e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
93e41f4b71Sopenharmony_ci});
94e41f4b71Sopenharmony_ci```
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci## statistics.getIfaceTxBytes<sup>10+</sup>
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_cigetIfaceTxBytes(nic: string, callback: AsyncCallback\<number>): void;
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of the specified NIC. This API uses an asynchronous callback to return the result.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**Parameters**
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                   |
107e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- |
108e41f4b71Sopenharmony_ci| nic      | string                 | Yes  | NIC name.                                                                                                     |
109e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time uplink data traffic of the NIC in bytes. Otherwise, **error** is an error object.   |
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**Error codes**
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci| ID| Error Message                                    |
116e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
117e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
118e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
119e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
120e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
121e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
122e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci**Example**
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci```js
127e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
128e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_cistatistics.getIfaceTxBytes("wlan0", (error: BusinessError, stats: number) => {
131e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
132e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
133e41f4b71Sopenharmony_ci});
134e41f4b71Sopenharmony_ci```
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci## statistics.getIfaceTxBytes<sup>10+</sup>
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_cigetIfaceTxBytes(nic: string): Promise\<number>;
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of the specified NIC. This API uses a promise to return the result.
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci**Parameters**
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description              |
147e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------ |
148e41f4b71Sopenharmony_ci| nic    | string | Yes  | NIC name.|
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci**Return value**
151e41f4b71Sopenharmony_ci| Type| Description|
152e41f4b71Sopenharmony_ci| -------- | -------- |
153e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time uplink data traffic of the NIC in bytes.|
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ci**Error codes**
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci| ID| Error Message                                    |
160e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
161e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
162e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
163e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
164e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
165e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
166e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**Example**
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci```js
171e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_cistatistics.getIfaceTxBytes("wlan0").then((stats: number) => {
174e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
175e41f4b71Sopenharmony_ci});
176e41f4b71Sopenharmony_ci```
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci## statistics.getCellularRxBytes<sup>10+</sup>
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_cigetCellularRxBytes(callback: AsyncCallback\<number>): void;
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of a cellular network. This API uses an asynchronous callback to return the result.
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**Parameters**
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                   |
189e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- |
190e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time downlink data traffic of the cellular network in bytes. Otherwise, **error** is an error object.   |
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci**Error codes**
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci| ID| Error Message                                    |
197e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
198e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
199e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
200e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
201e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
202e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**Example**
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci```js
207e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
208e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_cistatistics.getCellularRxBytes((error: BusinessError, stats: number) => {
211e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
212e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
213e41f4b71Sopenharmony_ci});
214e41f4b71Sopenharmony_ci```
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci## statistics.getCellularRxBytes<sup>10+</sup>
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_cigetCellularRxBytes(): Promise\<number>;
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of a cellular network. This API uses a promise to return the result.
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**Return value**
225e41f4b71Sopenharmony_ci| Type| Description|
226e41f4b71Sopenharmony_ci| -------- | -------- |
227e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time downlink data traffic of the cellular network in bytes.|
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**Error codes**
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci| ID| Error Message                                    |
234e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
235e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
236e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
237e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
238e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
239e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci**Example**
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci```js
244e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_cistatistics.getCellularRxBytes().then((stats: number) => {
247e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
248e41f4b71Sopenharmony_ci});
249e41f4b71Sopenharmony_ci```
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci## statistics.getCellularTxBytes<sup>10+</sup>
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_cigetCellularTxBytes(callback: AsyncCallback\<number>): void;
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of a cellular network. This API uses an asynchronous callback to return the result.
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci**Parameters**
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                   |
262e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- |
263e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time uplink data traffic of the cellular network in bytes. Otherwise, **error** is an error object.   |
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci**Error codes**
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci| ID| Error Message                                    |
270e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
271e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
272e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
273e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
274e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
275e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci**Example**
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci```js
280e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
281e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_cistatistics.getCellularTxBytes((error: BusinessError, stats: number) => {
284e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
285e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
286e41f4b71Sopenharmony_ci});
287e41f4b71Sopenharmony_ci```
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci## statistics.getCellularTxBytes<sup>10+</sup>
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_cigetCellularTxBytes(): Promise\<number>;
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of a cellular network. This API uses a promise to return the result.
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci**Return value**
298e41f4b71Sopenharmony_ci| Type| Description|
299e41f4b71Sopenharmony_ci| -------- | -------- |
300e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time uplink data traffic of the cellular network in bytes.|
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**Error codes**
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci| ID| Error Message                                    |
307e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
308e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
309e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
310e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
311e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
312e41f4b71Sopenharmony_ci| 2103012   | Failed to obtain the NIC name.               |
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci**Example**
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci```js
317e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_cistatistics.getCellularTxBytes().then((stats: number) => {
320e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
321e41f4b71Sopenharmony_ci});
322e41f4b71Sopenharmony_ci```
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci## statistics.getAllRxBytes<sup>10+</sup>
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_cigetAllRxBytes(callback: AsyncCallback\<number>): void;
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of all NICs. This API uses an asynchronous callback to return the result.
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci**Parameters**
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                         |
335e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
336e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time downlink data traffic of all NICs in bytes. Otherwise, **error** is an error object.   |
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci**Error codes**
339e41f4b71Sopenharmony_ci
340e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
341e41f4b71Sopenharmony_ci
342e41f4b71Sopenharmony_ci| ID| Error Message                                    |
343e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
344e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service. |
345e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
346e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
347e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci**Example**
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci```js
352e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
353e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_cistatistics.getAllRxBytes((error: BusinessError, stats: number) => {
356e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
357e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
358e41f4b71Sopenharmony_ci});
359e41f4b71Sopenharmony_ci```
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci## statistics.getAllRxBytes<sup>10+</sup>
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_cigetAllRxBytes(): Promise\<number>;
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of all NICs. This API uses a promise to return the result.
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci**Return value**
370e41f4b71Sopenharmony_ci| Type| Description|
371e41f4b71Sopenharmony_ci| -------- | -------- |
372e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time downlink data traffic of all NICs in bytes.|
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci**Error codes**
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci| ID| Error Message                                    |
379e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
380e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
381e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
382e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
383e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci**Example**
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ci```js
388e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_cistatistics.getAllRxBytes().then((stats: number) => {
391e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
392e41f4b71Sopenharmony_ci});
393e41f4b71Sopenharmony_ci```
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci## statistics.getAllTxBytes<sup>10+</sup>
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_cigetAllTxBytes(callback: AsyncCallback\<number>): void;
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of all NICs. This API uses an asynchronous callback to return the result.
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci**Parameters**
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                         |
406e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
407e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time uplink data traffic of all NICs in bytes. Otherwise, **error** is an error object.   |
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci**Error codes**
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci| ID| Error Message                                    |
414e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
415e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
416e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
417e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
418e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci**Example**
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci```js
423e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
424e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_cistatistics.getAllTxBytes((error: BusinessError, stats: number) => {
427e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
428e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
429e41f4b71Sopenharmony_ci});
430e41f4b71Sopenharmony_ci```
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci## statistics.getAllTxBytes<sup>10+</sup>
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_cigetAllTxBytes(): Promise\<number>;
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of all NICs. This API uses a promise to return the result.
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci**Return value**
441e41f4b71Sopenharmony_ci| Type| Description|
442e41f4b71Sopenharmony_ci| -------- | -------- |
443e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time uplink data traffic of all NICs in bytes.|
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci**Error codes**
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci| ID| Error Message                                    |
450e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
451e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
452e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
453e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
454e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**Example**
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci```js
459e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_cistatistics.getAllTxBytes().then((stats: number) => {
462e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
463e41f4b71Sopenharmony_ci});
464e41f4b71Sopenharmony_ci```
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci## statistics.getUidRxBytes<sup>10+</sup>
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_cigetUidRxBytes(uid: number, callback: AsyncCallback\<number>): void;
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of the specified application. This API uses an asynchronous callback to return the result.
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci**Parameters**
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                   |
477e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- |
478e41f4b71Sopenharmony_ci| uid      | number                 | Yes  | Application UID.                                                                                                   |
479e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time downlink data traffic of the application in bytes. Otherwise, **error** is an error object.   |
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci**Error codes**
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ci| ID| Error Message                                    |
486e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
487e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
488e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
489e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
490e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
491e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ci**Example**
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci```js
496e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
497e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_cistatistics.getUidRxBytes(20010038, (error: BusinessError, stats: number) => {
500e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
501e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
502e41f4b71Sopenharmony_ci});
503e41f4b71Sopenharmony_ci```
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ci## statistics.getUidRxBytes<sup>10+</sup>
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_cigetUidRxBytes(uid: number): Promise\<number>;
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ciObtains the real-time downlink data traffic of the specified application. This API uses a promise to return the result.
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
512e41f4b71Sopenharmony_ci
513e41f4b71Sopenharmony_ci**Parameters**
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                |
516e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------- |
517e41f4b71Sopenharmony_ci| uid    | number | Yes  | Application UID.|
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci**Return value**
520e41f4b71Sopenharmony_ci| Type| Description|
521e41f4b71Sopenharmony_ci| -------- | -------- |
522e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time downlink data traffic of the application in bytes.|
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci**Error codes**
525e41f4b71Sopenharmony_ci
526e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci| ID| Error Message                                    |
529e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
530e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
531e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
532e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
533e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
534e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ci**Example**
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci```js
539e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_cistatistics.getUidRxBytes(20010038).then((stats: number) => {
542e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
543e41f4b71Sopenharmony_ci});
544e41f4b71Sopenharmony_ci```
545e41f4b71Sopenharmony_ci
546e41f4b71Sopenharmony_ci## statistics.getUidTxBytes<sup>10+</sup>
547e41f4b71Sopenharmony_ci
548e41f4b71Sopenharmony_cigetUidTxBytes(uid: number, callback: AsyncCallback\<number>): void;
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of the specified application. This API uses an asynchronous callback to return the result.
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci**Parameters**
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                                                                                   |
557e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- |
558e41f4b71Sopenharmony_ci| uid      | number                 | Yes  | Application UID.                                                                                                   |
559e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the real-time uplink data traffic of the application in bytes. Otherwise, **error** is an error object.   |
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ci**Error codes**
562e41f4b71Sopenharmony_ci
563e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
564e41f4b71Sopenharmony_ci
565e41f4b71Sopenharmony_ci| ID| Error Message                                    |
566e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
567e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
568e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
569e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
570e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
571e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ci**Example**
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci```js
576e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
577e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_cistatistics.getUidTxBytes(20010038, (error: BusinessError, stats: number) => {
580e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
581e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
582e41f4b71Sopenharmony_ci});
583e41f4b71Sopenharmony_ci```
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci## statistics.getUidTxBytes<sup>10+</sup>
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_cigetUidTxBytes(uid: number): Promise\<number>;
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ciObtains the real-time uplink data traffic of the specified application. This API uses a promise to return the result.
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
592e41f4b71Sopenharmony_ci
593e41f4b71Sopenharmony_ci**Parameters**
594e41f4b71Sopenharmony_ci
595e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                |
596e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------- |
597e41f4b71Sopenharmony_ci| uid    | number | Yes  | Application UID.|
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci**Return value**
600e41f4b71Sopenharmony_ci| Type| Description|
601e41f4b71Sopenharmony_ci| -------- | -------- |
602e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result, which is the real-time uplink data traffic of the application in bytes.|
603e41f4b71Sopenharmony_ci
604e41f4b71Sopenharmony_ci**Error codes**
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci| ID| Error Message                                    |
609e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
610e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
611e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
612e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
613e41f4b71Sopenharmony_ci| 2103005   | Failed to read the system map.               |
614e41f4b71Sopenharmony_ci| 2103011   | Failed to create a system map.               |
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**Example**
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci```js
619e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
620e41f4b71Sopenharmony_ci
621e41f4b71Sopenharmony_cistatistics.getUidTxBytes(20010038).then((stats: number) => {
622e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
623e41f4b71Sopenharmony_ci});
624e41f4b71Sopenharmony_ci```
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci## statistics.getSockfdRxBytes<sup>11+</sup>
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_cigetSockfdRxBytes(sockfd: number, callback: AsyncCallback\<number\>): void;
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ciObtains the downlink data traffic (in bytes) of the specified socket. This API uses an asynchronous callback to return the result.
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci**Parameters**
636e41f4b71Sopenharmony_ci
637e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                        |
638e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
639e41f4b71Sopenharmony_ci| sockfd   | number                 | Yes  | FD of the socket.                    |
640e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the downlink data traffic of the socket. Otherwise, **error** is an error object.|
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci**Error codes**
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci| ID| Error Message                                    |
647e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
648e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
649e41f4b71Sopenharmony_ci| 2100001   | Invalid parameter value.                     |
650e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
651e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ci**Example**
654e41f4b71Sopenharmony_ci
655e41f4b71Sopenharmony_ci```js
656e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
657e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
658e41f4b71Sopenharmony_ci
659e41f4b71Sopenharmony_cilet sockfd = 50; // FD of the socket you created.
660e41f4b71Sopenharmony_cistatistics.getSockfdRxBytes(sockfd, (error: BusinessError, stats: number) => {
661e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
662e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
663e41f4b71Sopenharmony_ci});
664e41f4b71Sopenharmony_ci```
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci## statistics.getSockfdRxBytes<sup>11+</sup>
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_cigetSockfdRxBytes(sockfd: number): Promise\<number\>;
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ciObtains the downlink data traffic (in bytes) of the specified socket. This API uses a promise to return the result.
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
673e41f4b71Sopenharmony_ci
674e41f4b71Sopenharmony_ci**Parameters**
675e41f4b71Sopenharmony_ci
676e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                    |
677e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- |
678e41f4b71Sopenharmony_ci| sockfd | number | Yes  | FD of the socket.|
679e41f4b71Sopenharmony_ci
680e41f4b71Sopenharmony_ci**Return value**
681e41f4b71Sopenharmony_ci
682e41f4b71Sopenharmony_ci| Type            | Description                                                        |
683e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------------ |
684e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result.|
685e41f4b71Sopenharmony_ci
686e41f4b71Sopenharmony_ci**Error codes**
687e41f4b71Sopenharmony_ci
688e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ci| ID| Error Message                                    |
691e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
692e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
693e41f4b71Sopenharmony_ci| 2100001   | Invalid parameter value.                     |
694e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
695e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
696e41f4b71Sopenharmony_ci
697e41f4b71Sopenharmony_ci**Example**
698e41f4b71Sopenharmony_ci
699e41f4b71Sopenharmony_ci```js
700e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
701e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_cilet sockfd = 50; // FD of the socket you created.
704e41f4b71Sopenharmony_cistatistics.getSockfdRxBytes(sockfd).then((stats: number) => {
705e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
706e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
707e41f4b71Sopenharmony_ci  console.error(JSON.stringify(err));
708e41f4b71Sopenharmony_ci});
709e41f4b71Sopenharmony_ci```
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ci## statistics.getSockfdTxBytes<sup>11+</sup>
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_cigetSockfdTxBytes(sockfd: number, callback: AsyncCallback\<number\>): void;
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ciObtains the uplink data traffic (in bytes) of the specified socket. This API uses an asynchronous callback to return the result.
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci**Parameters**
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ci| Name  | Type                  | Mandatory| Description                                                        |
722e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
723e41f4b71Sopenharmony_ci| sockfd   | number                 | Yes  | FD of the socket.                    |
724e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. Callback used to return the result. If the operation is successful, **error** is **undefined** and **stats** is the uplink data traffic of the socket. Otherwise, **error** is an error object.|
725e41f4b71Sopenharmony_ci
726e41f4b71Sopenharmony_ci**Error codes**
727e41f4b71Sopenharmony_ci
728e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ci| ID| Error Message                                    |
731e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
732e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
733e41f4b71Sopenharmony_ci| 2100001   | Invalid parameter value.                     |
734e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
735e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ci**Example**
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci```js
740e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
741e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_cilet sockfd = 50; // FD of the socket you created.
744e41f4b71Sopenharmony_cistatistics.getSockfdTxBytes(sockfd, (error: BusinessError, stats: number) => {
745e41f4b71Sopenharmony_ci  console.log(JSON.stringify(error));
746e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
747e41f4b71Sopenharmony_ci});
748e41f4b71Sopenharmony_ci```
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ci## statistics.getSockfdTxBytes<sup>11+</sup>
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_cigetSockfdTxBytes(sockfd: number): Promise\<number\>;
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ciObtains the uplink data traffic (in bytes) of the specified socket. This API uses a promise to return the result.
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Communication.NetManager.Core
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ci**Parameters**
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                    |
761e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------------------- |
762e41f4b71Sopenharmony_ci| sockfd | number | Yes  | FD of the socket.|
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_ci**Return value**
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci| Type            | Description                                                        |
767e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------------------------ |
768e41f4b71Sopenharmony_ci| Promise\<number> | Promise used to return the result.|
769e41f4b71Sopenharmony_ci
770e41f4b71Sopenharmony_ci**Error codes**
771e41f4b71Sopenharmony_ci
772e41f4b71Sopenharmony_ciFor details about the error codes, see [Traffic Management Error Codes](errorcode-net-statistics.md).
773e41f4b71Sopenharmony_ci
774e41f4b71Sopenharmony_ci| ID| Error Message                                    |
775e41f4b71Sopenharmony_ci| --------- | -------------------------------------------- |
776e41f4b71Sopenharmony_ci| 401       | Parameter error.                             |
777e41f4b71Sopenharmony_ci| 2100001   | Invalid parameter value.                     |
778e41f4b71Sopenharmony_ci| 2100002   | Failed to connect to the service.            |
779e41f4b71Sopenharmony_ci| 2100003   | System internal error.                       |
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci**Example**
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci```js
784e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
785e41f4b71Sopenharmony_ciimport { statistics } from '@kit.NetworkKit';
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_cilet sockfd = 50; // FD of the socket you created.
788e41f4b71Sopenharmony_cistatistics.getSockfdTxBytes(sockfd).then((stats: number) => {
789e41f4b71Sopenharmony_ci  console.log(JSON.stringify(stats));
790e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
791e41f4b71Sopenharmony_ci  console.error(JSON.stringify(err));
792e41f4b71Sopenharmony_ci});
793e41f4b71Sopenharmony_ci```
794