I'm sniffing WiFi packets for RSSI (my interest is probe request and data null, timestamp and source mac address), and I need to save the results in pcap
files for further processing.
The problem is that I need to divide the info to multiple different files, creating one file per hour.
I don't have an idea how to check the elapsed time in my program, except multithreading (while(1)
, sleep()
and check with clock()
function). I'm using Ubuntu, but the target platform is a router with Linux OpenWrt installed.
My first concert are the problems with cross compilation + pthread.h
, thread.h
or something else, or maybe there should be no issues in OpenWrt?
And the other side of the question - isn't it too complicated to use multithreading for this silly problem?
Maybe there are other solutions? (i.e. a small pseudo-multithreading solution, or some simpler tricks)?
You should use Cron:
Cron is a system daemon used to execute desired tasks (in the background) at designated times.
Basically, you define a script to be executed every hour with this syntax:
0 */1 * * * /path/to/script.sh
Check here for more info: https://help.ubuntu.com/community/CronHowto
For OpenWrt specific setup, check here: http://martybugs.net/wireless/openwrt/cron.cgi
For your specific case, you can use the following design:
For an overview of IPC methods to get you started, check this Wikipedia article.
For specific implementations you can use Boost.Interprocess, Sockets, Pipes, and others.