# @ohos.net.statistics (æµé‡ç®¡ç†) æµé‡ç®¡ç†æ¨¡å—,支æŒåŸºäºŽç½‘å¡/UID 的实时æµé‡ç»Ÿè®¡å’Œåކ岿µé‡ç»Ÿè®¡æŸ¥è¯¢èƒ½åŠ›ã€‚ > **说明:** > 本模å—首批接å£ä»Ž API version 10 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„æ–°å¢žæŽ¥å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 ## å¯¼å…¥æ¨¡å— ```js import { statistics } from '@kit.NetworkKit'; ``` ## statistics.getIfaceRxBytes<sup>10+</sup> getIfaceRxBytes(nic: string, callback: AsyncCallback\<number>): void; èŽ·å–æŒ‡å®šç½‘å¡å®žæ—¶ä¸‹è¡Œæµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- | | nic | string | 是 | 指定查询的网å¡å。 | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–网å¡å®žæ—¶ä¸‹è¡Œæµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的网å¡å®žæ—¶ä¸‹è¡Œæµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; statistics.getIfaceRxBytes("wlan0", (error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getIfaceRxBytes<sup>10+</sup> getIfaceRxBytes(nic: string): Promise\<number>; èŽ·å–æŒ‡å®šç½‘å¡å®žæ—¶ä¸‹è¡Œæµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ------ | ------ | ---- | ------------------ | | nic | string | 是 | 指定查询的网å¡å。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回网å¡å®žæ—¶ä¸‹è¡Œæµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getIfaceRxBytes("wlan0").then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getIfaceTxBytes<sup>10+</sup> getIfaceTxBytes(nic: string, callback: AsyncCallback\<number>): void; èŽ·å–æŒ‡å®šç½‘å¡å®žæ—¶ä¸Šè¡Œæµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- | | nic | string | 是 | 指定查询的网å¡å。 | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–网å¡å®žæ—¶ä¸Šè¡Œæµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的网å¡å®žæ—¶ä¸Šè¡Œæµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; statistics.getIfaceTxBytes("wlan0", (error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getIfaceTxBytes<sup>10+</sup> getIfaceTxBytes(nic: string): Promise\<number>; èŽ·å–æŒ‡å®šç½‘å¡å®žæ—¶ä¸Šè¡Œæµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ------ | ------ | ---- | ------------------ | | nic | string | 是 | 指定查询的网å¡å。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回网å¡å®žæ—¶ä¸Šè¡Œæµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getIfaceTxBytes("wlan0").then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getCellularRxBytes<sup>10+</sup> getCellularRxBytes(callback: AsyncCallback\<number>): void; 获å–蜂çªå®žæ—¶ä¸‹è¡Œæµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–蜂çªå®žæ—¶ä¸‹è¡Œæµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的蜂çªå®žæ—¶ä¸‹è¡Œæµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; statistics.getCellularRxBytes((error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getCellularRxBytes<sup>10+</sup> getCellularRxBytes(): Promise\<number>; 获å–蜂çªå®žæ—¶ä¸‹è¡Œæµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回蜂çªå®žæ—¶ä¸‹è¡Œæµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getCellularRxBytes().then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getCellularTxBytes<sup>10+</sup> getCellularTxBytes(callback: AsyncCallback\<number>): void; 获å–蜂çªå®žæ—¶ä¸Šè¡Œæµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–蜂çªå®žæ—¶ä¸Šè¡Œæµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的蜂çªå®žæ—¶ä¸Šè¡Œæµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; statistics.getCellularTxBytes((error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getCellularTxBytes<sup>10+</sup> getCellularTxBytes(): Promise\<number>; 获å–蜂çªå®žæ—¶ä¸Šè¡Œæµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回蜂çªå®žæ—¶ä¸Šè¡Œæµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | | 2103012 | Failed to obtain the NIC name. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getCellularTxBytes().then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getAllRxBytes<sup>10+</sup> getAllRxBytes(callback: AsyncCallback\<number>): void; èŽ·å–æ‰€æœ‰ç½‘å¡å®žæ—¶ä¸‹è¡Œæµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–æ‰€æœ‰ç½‘å¡å®žæ—¶ä¸‹è¡Œæµé‡ï¼Œerror 为 undefined,stats 为获å–到的所有网å¡å®žæ—¶ä¸‹è¡Œæµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; import { BusinessError } from '@kit.BasicServicesKit'; statistics.getAllRxBytes((error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getAllRxBytes<sup>10+</sup> getAllRxBytes(): Promise\<number>; èŽ·å–æ‰€æœ‰ç½‘å¡å®žæ—¶ä¸‹è¡Œæµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回所有网å¡å®žæ—¶ä¸‹è¡Œæµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getAllRxBytes().then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getAllTxBytes<sup>10+</sup> getAllTxBytes(callback: AsyncCallback\<number>): void; èŽ·å–æ‰€æœ‰ç½‘å¡å®žæ—¶ä¸Šè¡Œæµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------------- | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–æ‰€æœ‰ç½‘å¡å®žæ—¶ä¸Šè¡Œæµé‡ï¼Œerror 为 undefined,stats 为获å–到的所有网å¡å®žæ—¶ä¸Šè¡Œæµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; statistics.getAllTxBytes((error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getAllTxBytes<sup>10+</sup> getAllTxBytes(): Promise\<number>; èŽ·å–æ‰€æœ‰ç½‘å¡å®žæ—¶ä¸Šè¡Œæµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回所有网å¡å®žæ—¶ä¸Šè¡Œæµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getAllTxBytes().then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getUidRxBytes<sup>10+</sup> getUidRxBytes(uid: number, callback: AsyncCallback\<number>): void; èŽ·å–æŒ‡å®šåº”用实时下行æµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- | | uid | number | 是 | 指定查询的应用 uid。 | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–应用实时下行æµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的应用实时下行æµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; statistics.getUidRxBytes(20010038, (error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getUidRxBytes<sup>10+</sup> getUidRxBytes(uid: number): Promise\<number>; èŽ·å–æŒ‡å®šåº”用实时下行æµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ------ | ------ | ---- | -------------------- | | uid | number | 是 | 指定查询的应用 uid。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回指定应用实时下行æµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getUidRxBytes(20010038).then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getUidTxBytes<sup>10+</sup> getUidTxBytes(uid: number, callback: AsyncCallback\<number>): void; èŽ·å–æŒ‡å®šåº”用实时上行æµé‡ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ---------------------------------------------------------------------------------------------------------------------- | | uid | number | 是 | 指定查询的应用 uid。 | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–应用实时上行æµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的应用实时上行æµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; statistics.getUidTxBytes(20010038, (error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getUidTxBytes<sup>10+</sup> getUidTxBytes(uid: number): Promise\<number>; èŽ·å–æŒ‡å®šåº”用实时上行æµé‡ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ------ | ------ | ---- | -------------------- | | uid | number | 是 | 指定查询的应用 uid。 | **返回值:** | 类型 | 说明 | | -------- | -------- | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果。返回指定应用实时上行æµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | | 2103005 | Failed to read the system map. | | 2103011 | Failed to create a system map. | **示例:** ```js import { statistics } from '@kit.NetworkKit'; statistics.getUidTxBytes(20010038).then((stats: number) => { console.log(JSON.stringify(stats)); }); ``` ## statistics.getSockfdRxBytes<sup>11+</sup> getSockfdRxBytes(sockfd: number, callback: AsyncCallback\<number\>): void; èŽ·å–æŒ‡å®šsocket的下行æµé‡ä¿¡æ¯ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | sockfd | number | 是 | 指定查询的socketçš„fd(file description)。 | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–socket的下行æµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的该socket的实时下行æµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100001 | Invalid parameter value. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; let sockfd = 50; // 实际开å‘ä¸éœ€è¦å…ˆæ ¹æ®è‡ªå·±åˆ›å»ºçš„socket获å–到 statistics.getSockfdRxBytes(sockfd, (error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getSockfdRxBytes<sup>11+</sup> getSockfdRxBytes(sockfd: number): Promise\<number\>; èŽ·å–æŒ‡å®šsocket的下行æµé‡ä¿¡æ¯ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ------ | ------ | ---- | ---------------------------------------- | | sockfd | number | 是 | 指定查询的socketçš„fd(file description)。 | **返回值:** | 类型 | 说明 | | ---------------- | ------------------------------------------------------------ | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果,返回该socket的实时下行æµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100001 | Invalid parameter value. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; let sockfd = 50; // 实际开å‘ä¸éœ€è¦å…ˆæ ¹æ®è‡ªå·±åˆ›å»ºçš„socket获å–到 statistics.getSockfdRxBytes(sockfd).then((stats: number) => { console.log(JSON.stringify(stats)); }).catch((err: BusinessError) => { console.error(JSON.stringify(err)); }); ``` ## statistics.getSockfdTxBytes<sup>11+</sup> getSockfdTxBytes(sockfd: number, callback: AsyncCallback\<number\>): void; èŽ·å–æŒ‡å®šsocket的上行æµé‡ä¿¡æ¯ï¼Œä½¿ç”¨ callback æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | sockfd | number | 是 | 指定查询的socketçš„fd(file description)。 | | callback | AsyncCallback\<number> | 是 | 回调函数。当æˆåŠŸèŽ·å–socket的上行æµé‡æ—¶ï¼Œerror 为 undefined,stats 为获å–到的该socket的实时上行æµé‡(å•ä½:å—节)ï¼›å¦åˆ™ä¸ºé”™è¯¯å¯¹è±¡ã€‚ | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100001 | Invalid parameter value. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; let sockfd = 50; // 实际开å‘ä¸éœ€è¦å…ˆæ ¹æ®è‡ªå·±åˆ›å»ºçš„socket获å–到 statistics.getSockfdTxBytes(sockfd, (error: BusinessError, stats: number) => { console.log(JSON.stringify(error)); console.log(JSON.stringify(stats)); }); ``` ## statistics.getSockfdTxBytes<sup>11+</sup> getSockfdTxBytes(sockfd: number): Promise\<number\>; èŽ·å–æŒ‡å®šsocket的上行æµé‡ä¿¡æ¯ï¼Œä½¿ç”¨ Promise æ–¹å¼ä½œä¸ºå¼‚æ¥æ–¹æ³•。 **系统能力**:SystemCapability.Communication.NetManager.Core **傿•°ï¼š** | 傿•°å | 类型 | å¿…å¡« | 说明 | | ------ | ------ | ---- | ---------------------------------------- | | sockfd | number | 是 | 指定查询的socketçš„fd(file description)。 | **返回值:** | 类型 | 说明 | | ---------------- | ------------------------------------------------------------ | | Promise\<number> | 以 Promise å½¢å¼è¿”回获å–结果,返回该socket的实时上行æµé‡(å•ä½:å—节)。 | **错误ç :** 以下错误ç 的详细介ç»å‚è§[statistics 错误ç ](errorcode-net-statistics.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | --------- | -------------------------------------------- | | 401 | Parameter error. | | 2100001 | Invalid parameter value. | | 2100002 | Failed to connect to the service. | | 2100003 | System internal error. | **示例:** ```js import { BusinessError } from '@kit.BasicServicesKit'; import { statistics } from '@kit.NetworkKit'; let sockfd = 50; // 实际开å‘ä¸éœ€è¦å…ˆæ ¹æ®è‡ªå·±åˆ›å»ºçš„socket获å–到 statistics.getSockfdTxBytes(sockfd).then((stats: number) => { console.log(JSON.stringify(stats)); }).catch((err: BusinessError) => { console.error(JSON.stringify(err)); }); ``` ## NetBearType type NetBearType = connection.NetBearType 网络类型。 **系统能力**:SystemCapability.Communication.NetStack | 类型 | 说明 | | ---------------- | --------------------------- | | connection.NetBearType | 枚举网络类型。 |