I want to analyze networks traffic but not by connecting it Just switch on wifi and sniff the packets (IEEE 802.11 Frames) in promiscuous mode
I have tried libpcap but it may be internally changing datalinktype as i am giving wifi interface in
descr=pcap_open_live("en1", MAXBYTES2CAPTURE, 1, 512, errbuf);
(as we know mac OS x have en1 as wifi interface )
now when i do this
printf("%s", pcap_datalink_val_to_name( pcap_datalink(descr)));
It gives me result "ethernet"
I have tried to capture packets using wireshark without connecting to my wifi network and it worked!!
I was able to capture Beacon , Acknowledgement and Authentication frames
without connecting to my wifi network.
now:
- do I have to make a network card driver for that or libpcap can do that ?if yes how?
- Is wireshark making some kind of driver for that? if yes please help me to locate that in it's source code.
- I have tried Apple's CFNetwork but it too can't capture without connecting to the network.
- It will be very helpful if i get some suggestion on some user space code as kernel level coding is a little tuff :(
I am coding on MacOS 10.7 in xCode 4.5.1
Update:
I am already doing this:
descr=pcap_create("e1", errbuf);
pcap_set_rfmon(descr, 0);
pcap_set_promisc(descr, 0);
pcap_activate(descr);
descr=pcap_open_live("en1", 2048, 1, 512, errbuf);
And yes there is a little monitor icon at the wifi and I can sniff the packets but only when I connect to the network, I want to do the same when I am not connected to wifi like capturing Beacon and Acknowledgment Frames means packets through which our network card detects available wifi network