简体   繁体   English

libpcap获取数据包的进程ID

[英]libpcap getting the process ID of a packet

I'm currently working on a project that will monitor the network usage of my system. 我目前正在从事一个项目,该项目将监视系统的网络使用情况。 One feature I'm planning on adding is the ability to get the usage of a specific process (upload and download). 我计划添加的功能之一是能够使用特定流程(上传和下载)。 The library I'm using is libpcap. 我正在使用的库是libpcap。 Is there any way I can get the process ID of a packet without using a third party library? 有什么方法可以在不使用第三方库的情况下获取数据包的进程ID? Are there any third party libraries that I can use if libpcap doesn't have the process ID? 如果libpcap没有进程ID,是否可以使用任何第三方库? I'm developing this on Linux, but I do want it to be cross-platform. 我正在Linux上进行开发,但我确实希望它可以跨平台。

Well the process ID isn't in the packet, so libpcap won't have it, so you're going to have to grapple with operating-system specific stuff to relate the port to a processID. 好吧,进程ID不在数据包中,因此libpcap将没有它,因此您将不得不处理操作系统特定的内容,以将端口与processID相关联。

You could investigate SNMP, specificaly the TCPConnTable and TCPConnectionTable. 您可以研究SNMP,特别是TCPConnTable和TCPConnectionTable。 One or other is supported on most platforms, if not necessarily enabled by default. 大多数平台都支持一种或多种(如果默认情况下未启用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM