sngrep icon indicating copy to clipboard operation
sngrep copied to clipboard

Multiple device selection on none Linux systems.

Open dunst0 opened this issue 10 years ago • 27 comments

I would like to suggest a feature request. Like you said in an other issue the any device is part of libpcap but only on Linux systems, so I would be great if it would be possible to specify more devices on startup to capture from.

dunst0 avatar Feb 03 '16 07:02 dunst0

Hi @dunst0

As far as I know, there is no easy way to listen on multiples interfaces with libpcap. I think most of the network sniffers based on libpcap doesn't allow multiples interfaces (tcpdump, ngrep, and so) and I am not totally sure if it is Thread-Safe (as we should launch a thread for each capturing interface). Using multiple child process won't work with sngrep design.

Not an elegant workaround, but If you have the need to capture in multiples interfaces, you can use hep/eep to run two different sngrep (one without showing interface) and send captured data from one sngrep to another.

sngrep -Hudp:127.0.0.1:9999 -d eth0 -Nq
sngrep -Ludp:127.0.0.1:9999 -d eth1

If you find a way to do this or other tool implementing multiple interface capture with libpcap, don't hesitate to comment it :)

Kaian avatar Feb 03 '16 12:02 Kaian

I found some information regarding pcap and multi device caputuring.

Maybe it helps: http://seclists.org/tcpdump/2012/q2/18

dunst0 avatar Feb 08 '16 09:02 dunst0

Hii,

After a year... I have created a branch called multi_device that implements support for multiple -d command line options so multiple capture devices can be now specified.

This requires a lot of testing, just to be sure that all shared structures are properly locked and no memory is now accessed/free'd at the same time from multiple capture threads.

I think someone in the IRC was also interested in this feature, so all the testing is appreciated.

Best regards!

Kaian avatar Apr 03 '17 11:04 Kaian

I will merge this into master and wait for a bit of testing before releasing :)

Kaian avatar Apr 18 '17 08:04 Kaian

This should be supported in 1.4.3

As always, feel free to reopen if it doesn't work as expected and will try to fix it for the next release!

Kaian avatar May 10 '17 14:05 Kaian

Hi @Kaian I haven't checked for some time the messages in github, so I missed some of your messages. Great to hear that there is now multiple devices. Many thanks to you for implementing that feature and thank you for developing and maintaining that great tool.

dunst0 avatar May 12 '17 06:05 dunst0

Just to let you know, seem that with multi it seems that on FreeBSD I receive ever package double or they are displayed double.

dunst0 avatar Sep 07 '17 15:09 dunst0

You mean using a single interface in the command line? :thinking:

Kaian avatar Sep 07 '17 15:09 Kaian

It seems that with 1.4.3 every package has a retransmission, maybe not a problem from multi interface.

17:45:16.353595   │ ─────── INVITE (SDP) ─────> │
17:45:16.353595   │ ─────── INVITE (SDP) ───>>> │
17:45:16.355355   │ <─────── 100 Trying ─────── │
17:45:16.355355   │ <<<───── 100 Trying ─────── │
17:45:16.932852   │ <─────── 180 Ringing ────── │
17:45:16.932852   │ <<<───── 180 Ringing ────── │
17:45:44.644340   │ ────────── CANCEL ────────> │
17:45:44.644340   │ ────────── CANCEL ──────>>> │
17:45:44.645274   │ <────── 200 canceling ───── │
17:45:44.645274   │ <<<──── 200 canceling ───── │
17:45:44.882831   │ <──── 487 Request Termi ─── │
17:45:44.882831   │ <<<── 487 Request Termi ─── │
17:45:44.883180   │ ──────────── ACK ─────────> │
17:45:44.883180   │ ──────────── ACK ───────>>> │

dunst0 avatar Sep 07 '17 15:09 dunst0

it doesn't matter if do sngrep -d em0 or sngrep -d em0 -d lo0

dunst0 avatar Sep 07 '17 15:09 dunst0

Does this happen when you capture a pcap file with tcpdump or ngrep and open it in sngrep?

Kaian avatar Sep 07 '17 16:09 Kaian

Yes even when I capture a file with tcpdump and just open it with sngrep

dunst0 avatar Sep 07 '17 16:09 dunst0

Then the final test will be checking if the pcap file contains duplicate packets inside. If so, then the problem must be in the interface or libpcap (as all that capture tools use the same library to capture). If packets only appear once in the file and sngrep display them twice, then I must dig a bit more :thinking:

We've using sngrep 1.4.3 since May, but only in debian based systems.. :S

Kaian avatar Sep 07 '17 16:09 Kaian

Wireshark doesn't show up resends in the call flows. :flushed:

dunst0 avatar Sep 07 '17 16:09 dunst0

bildschirmfoto 2017-09-07 um 18 21 35

dunst0 avatar Sep 07 '17 16:09 dunst0

Hmmm.. could you send me a sample pcap to check its contents?

I don't think wireshark has some duplicated packets removal logic, but I don't know tbh. It's using the same libpcap version that the machine capturing? You can also check if content are duplicated in the capturing maching by running tcpdump -r your.pcap -A and check if packets seems duplicated.

Thanks for the testing!

Kaian avatar Sep 07 '17 16:09 Kaian

For that I have to create a filter and the problem is the pcap may contains telephone numbers from customers if I doesn't filter it correct, that will be work for tomorrow. I will try to make a pcap. Btw with tcpdump the 180 Ringing isn't displayed multiple times.

dunst0 avatar Sep 07 '17 16:09 dunst0

If you're compiling from sources, you also have a test pcap in tests/aaa.pcap to give it a try :smile:

Kaian avatar Sep 07 '17 17:09 Kaian

With tests/aaa.pcap the packets are show double as well 😢

dunst0 avatar Sep 11 '17 08:09 dunst0

Could you give it a try to latest commits to check if somehow the error still persist? If that's the case then I should not release 1.4.4 :sweat_smile:

Thanks @dunst0 !

Kaian avatar Sep 11 '17 09:09 Kaian