This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

pass correct capturing interface for tshark via JAVA

1

Hi all,

At this moment, I am trying to implement a "one-click" packet capturing functionality (button on a GUI) in one of my JAVA applications, with the help of tshark/wireshark.

So far, I tried this:


String nic = NetworkInterface.getName();

String execute = "C:\Progra~1\Wireshark\tshark -i "+nic+" -b filesize:512 -w testCap";

try { Runtime.getRuntime().exec(execute); }

catch (IOException e1) { msg("Error during initialization of live capture"); e1.printStackTrace(); }


It turns out that String nic contains the name of the (via the GUI) selected local NIC, like for example "eth0."

I am using tshark on a pc running Windows7, and this type of NIC name that is returned by the method NetworkInterface.getName() is not recognized by tshark, since I receive the following message;

"tshark: The capture session could not be initiated (Error opening adapter: the system cannot find the device. (20)) Please check that "eth0" is the proper interface"

Any suggestions? Thanks a lot in advance!

asked 26 Apr '11, 10:56

robbertottenhof's gravatar image

robbertottenhof
16112
accept rate: 0%