Linux中NDIS过滤器的模拟方式是什么? [英] What is the analogue of an NDIS filter in linux?

查看:103
本文介绍了Linux中NDIS过滤器的模拟方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在linux上尽可能地在as close to real-time系统上工作,并且在收到特定数据包后需要在TCP数据包中发送大约600-800字节.

I am working on an as close to real-time system as possible in linux and need to send about 600-800 bytes in a TCP packet as soon as I receive a specific packet.

为了获得最佳的延迟,我希望直接从内核发送此数据包,而不是将接收到的数据包一直发送到用户空间和应用程序,然后再返回.

For best possible latencies I want this packet to be sent directly from the kernel instead of it the received packet going all the way up to the userspace and the applicaiton and then making its way back.

如果我在Windows上,我已经编写了一个NDIS过滤器,该过滤器将缓存要与之一起发送的数据包以及匹配参数,以便它将检查接收到的数据包,并在匹配时将预缓存的数据包发送到网络,而不会将收到的数据包传递到更高的层.

If I were on windows I'd have written an NDIS filter which I would cache the packet to be sent with and the matching parameters so that it would check the received packet and on a match fire the pre-cached packet onto the network without passing the received packet up to the higher layers.

所以我的问题是Linux上最接近NDIS过滤器的模拟物是什么?

So my question is what is the closest analogue of an NDIS filter on linux?

我已经阅读了有关netfilter的信息,也许这就是我要使用的内容,但是我不知道这是否是最好的方法.

I have read about netfilter and perhaps that is what I would use, but I do not know if it is the best way possible.

我还可以做些什么来达到最低的延迟?

What else could I do to achieve lowest-possible latencies?

我当前的纯用户空间代码在运行2.6.3x内核的Intel Xeon 3.7 GHz处理器上给了我80-100微秒的时间.

My current purely userspace code gives me about 80-100 micro seconds on an Intel Xeon 3.7 GHz processor running Ubuntu 10.04 on 2.6.3x kernel.

推荐答案

您可以使用iptables目标NFLOG将数据包复制到用户空间中,或者使用NFQUEUE允许用户空间处理它们.这种互动是通过 netlink 发生的,但是您可以使用 libnetfilter_log libnetfilter_queue 环绕它.

You can use the iptables target NFLOG to copy packets out to userspace or NFQUEUE to allow userspace to mangle them. This interaction happens over netlink, but you can use libraries such as libnetfilter_log and libnetfilter_queue which wrap around it.

这篇关于Linux中NDIS过滤器的模拟方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆