Linux下查看網絡流量信息 proc/net/dev


在Linux系統中,系統調用是操作系統提供給應用程序使用操作系統服務的重要接口,但同時也正是通過系統調用機制,操作系統屏蔽了用戶直接訪問系統內核的可能性。幸運的是Linux提供了LKM機制可以使我們在內核空間工作,在LKM機制中一個重要的組成部分就是proc偽文件系統,它為用戶提供了動態操作Linux內核信息的接口,是除系統調用之外另一個重要的Linux內核空間與用戶空間交換數據的途徑。

而proc/net/dev就是提供給用戶讀取或更改網絡適配器及統計信息的途徑。

cat /proc/net/dev
[root@90d77561d95b build]# more /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
ip6tnl0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
 tunl0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
  eth0: 48674378   33431    0    0    0     0          0         0   765815   13948    0    0    0     0       0          0

 

  • bytes: The total number of bytes of data transmitted or received by the interface.(接口發送或接收的數據的總字節數)
  • packets: The total number of packets of data transmitted or received by the interface.(接口發送或接收的數據包總數)
  • errs: The total number of transmit or receive errors detected by the device driver.(由設備驅動程序檢測到的發送或接收錯誤的總數)
  • drop: The total number of packets dropped by the device driver.(設備驅動程序丟棄的數據包總數)
  • fifo: The number of FIFO buffer errors.(FIFO緩沖區錯誤的數量)
  • frame: The number of packet framing errors.(分組幀錯誤的數量)
  • colls: The number of collisions detected on the interface.(接口上檢測到的沖突數)
  • compressed: The number of compressed packets transmitted or received by the device driver. (This appears to be unused in the 2.2.15 kernel.)(設備驅動程序發送或接收的壓縮數據包數)
  • carrier: The number of carrier losses detected by the device driver.(由設備驅動程序檢測到的載波損耗的數量)
  • multicast: The number of multicast frames transmitted or received by the device driver.(設備驅動程序發送或接收的多播幀數)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM