如何在没有TCP / IP堆栈的情况下用Java发送以太网帧

我的Java应用程序应该控制直接连接到我的计算机(Ubuntu和Windows)的网络接口的外部设备(EtherCAT总线技术)。 没有连接其他网络设备。 通信已在标准IEEE 802.3以太网帧上完成,没有IP堆栈。

发送数据的示例:

int etherType = 0x88A4; // the EtherType registered by IEEE byte[] macBroadcast = new byte[] {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; byte[] macSource = new byte[] ... ; // MAC Address of my network interface card byte[] buffer = ... // the data to send device.write(macSource, macBroadcast, etherType, buffer); 

我尝试了使用pcap本机库的JNetPcap 。 给定的API很好,但是在重载时存在multithreading问题,这迫使我放弃。

netty.io也是候选人。 我不确定,但TCP / IP堆栈是强制性的。 我对吗?

是否有其他想法与低级别以太网帧通信? 我更喜欢像netty.io这样的纯java库,如果存在的话。

当然JNA / JNI也是一种选择。 但我不想写C代码。

其他选择?

这些是我能够找到的选项:

我也看到了一些评论,认为jNetPcap应该是线程安全的,但实际上它不是; 即,当与多个线程一起使用时它是错误的。