我应该修改linux 2.6内核中的哪个模块来计算发送/接收的ip数据包的数量?
我需要修改内核模块来计算机器通过 Linux 2.6 内核的无线适配器发送/接收的数据包数量。请让我知道我应该修改哪些模块。任何参考资料也会有所帮助。
I need to modify a kernel module(s) to count number of packets that the machine has sent / received over my wireless adapter for the linux 2.6 kernel. Please let me know which modules should I modify. Any references would also be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不太确定无线适配器,但我认为它与有线适配器类似。对于有线和无线网卡,您可以使用 ifconfig eth0 命令,然后在输出中,您将看到一两行告诉您发送(TX)或接收(RX)的数据包数量。
要从内核模块获取相同的信息,一种方法是修改网卡的设备驱动程序。关于rtl8139(有线)的一个教程在这里:http://linuxgazette.net/156/jangir.html< /a>
另外,我认为您可以使用一些标准内核接口来获取相同的信息。例如上面链接中提到的
tp->stats.tx_packets
。I am not very sure about wireless adapter, but I think it is similar to a wired one. For wired and wireless NIC, you can use ifconfig eth0 command, then in the output, you will see one or two lines telling you the number of packets sent(TX) or received(RX).
To get the same information from the kernel module, one way is to modify the device driver for the network card. One tutorial about rtl8139 (wired one) is here: http://linuxgazette.net/156/jangir.html
Also, I think there are some standard kernel interface that you can use to get the same info. For example,
tp->stats.tx_packets
mentioned in the above link.如果您对 IP 数据包感兴趣,您应该考虑创建一个使用 netfilter 挂钩的内核模块。很简单,这里看一下:
http:// www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-3.html
Netfilter 主要用于防火墙,但它可以做您想做的事情,并且您不需要干扰其他内核模块。希望有帮助。
If you're interested in IP packets you should consider creating a kernel module that uses netfilter hooks. It's very simple, here take a look at this:
http://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-3.html
Netfilter is primarily intended for firewalling, but it can do what you want and you don't need to mess with other kernel modules. Hope it helps.
可能不是您想要的,但请解释原因。
is probably not what you want, but then explain why.