I created a packet sniffer using the pypcap Python library (in Linux). Using the .stats() method of the pypcap library, I see that from time to time few packets get dropped by the Kernel when the network is busy. Is it possible to increase the buffer size for the pypcap object so that less packets get dropped (like it is possible in tcpdump?).
I studied the source code of pypcap and as far as I could see there was no way to set the buffer size from it.
Because pypcap is using the libpcap library, I changed the default buffer size in the source code of libpcap and reinstalled it from source. That solved the problem as it seems.
Tcpdump sets the buffer size by calling the set_buffer_size() method of libpcap, but it seems that pypcap cannot do that.
Edit: The buffer size variable is located in the pcap-linux.c file, and the name is opt.buffer_size. I is 2MB by default (2*1024*1024 in source code)