简体   繁体   English

数据包嗅探与Linux中的通道跳跃

[英]Packet sniffing with Channel hopping in linux

I want to scan the WiFi on b/g interface, and I want to sniff packets on each channel, by spending 100 ms on each channel. 我想在b / g接口上扫描WiFi,我想在每个通道上嗅探数据包,每个通道花费100毫秒。 One of the biggest requirements I have is not to store the packets I get (because of less disk space), my application will parse the packets, retrieve Tx MAC and RSSI, and would construct the list (MAC, Avg RSSI, #Records) at the end of every minute, and then clear this list and start over again. 我有一个最大的要求是不存储我得到的数据包(因为磁盘空间较少),我的应用程序将解析数据包,检索Tx MAC和RSSI,并构建列表(MAC,Avg RSSI,#RECords)在每分钟结束时,然后清除此列表并重新开始。

I've figured out two ways to do channel hop on linux: 我已经想出了两种在linux上进行频道跳转的方法:

Option 1 : Use wi_set_channel(struct wif *, channel number) system call in C, and write the code in C to sniff all the packets 选项1 :在C中使用wi_set_channel(struct wif *,channel number)系统调用,并在C中编写代码以嗅探所有数据包

Option 2 : Use linux command iw dev wlan0 set channel 4 , and use any language like python+scapy OR C to sniff the packets 选项2 :使用linux命令iw dev wlan0 set channel 4 ,并使用python + scapy OR C等任何语言来嗅探数据包

I'd like to know which is more efficient of the two, if at all, so that the delay/wait for WiFi interface to switch to a different channel is minimal. 我想知道哪两个更有效,如果有的话,那么WiFi接口切换到不同通道的延迟/等待是最小的。 I suspect that this delay would mean loss of packet while the switch to a different channel happens, is that the case? 我怀疑这种延迟意味着在切换到不同通道时丢失数据包,是这样的吗?

I would also like to know some of the other ways to solve this problem in linux. 我还想了解一些在linux中解决这个问题的方法。

Answer to your first question us straight forward, use Option1 and have two threads doing the work - one thread populating an in-memory circular buffer with packets collected from channels and second thread processing them in sequence. 直接回答你的第一个问题,使用Option1并有两个线程完成工作 - 一个线程填充内存循环缓冲区,其中包含从通道收集的数据包,第二个线程按顺序处理它们。 You can determine best packet discarding algo depending on the measured performance of processing thread and other factors if any. 您可以根据处理线程的测量性能和其他因素(如果有)确定最佳数据包丢弃算法。

As for the second question, I would go with the above for being in complete control on exactly how you can tune the algorithm rather than depending on canned processing tools. 至于第二个问题,我会完全控制上面的内容,完全控制你如何调整算法,而不是依赖于固定的处理工具。

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

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