kaitoy / pcap4j

A Java library for capturing, crafting, and sending packets.
https://www.pcap4j.org/
Other
1.16k stars 309 forks source link

windows + npcap + Loopback Adapter=> "Failed to retrieve the link layer address" error #282

Open ohuseyinoglu opened 3 years ago

ohuseyinoglu commented 3 years ago

Whenever any API entry point to list/iterate network interfaces (like Pcaps.findAllDevs() or Pcaps.getDevByName()), is used, apparently a PcapNetworkInterface object would be constructed (for each? interface), and when it calls getMacAddress we run into this error.

I'm not sure if any real MAC address would be assigned to the loopback adapter, so this may somewhat be an "expected error", but it pollutes the logs, and causes unnecessary concern by users.

So, my suggestion is, (if a MAC address for a loopback adapter is not meaningful anyway), do not make to call to get/set mac address of the loopback NIF (and avoid logging this unnecessary error).

(Since I'm not familiary with the PacketRequest() API of , I cannot speculate much on the expected behavior here).

ohuseyinoglu commented 3 years ago

Forgot the add this: This may have started with a particular version of npcap (started seeing this after a long time with no errors), but unfortunately I don't have the test environment now, to play around with different versions to check. Environment: Win7 + Npcap version 1.00, based on libpcap version 1.9.1 + JDK 1.8 + Pcap4j 1.7.4 (with minor changes)

Nikhiladiga commented 3 years ago

Did you resolve this issue? If yes, could you please let me know how? Thank you.

ohuseyinoglu commented 3 years ago

(Assuming you were asking me - the reporter of the issue (and not the owner/developer of the project)) No, I still don't have any resolution/workaround for this problem.

Nikhiladiga commented 3 years ago

(Assuming you were asking me - the reporter of the issue (and not the owner/developer of the project)) No, I still don't have any resolution/workaround for this problem.

Yes. I was asking you. Thank you. I'm facing the same issue.