【发布时间】:2013-04-17 20:10:45
【问题描述】:
我的 Java 应用程序应该控制直接连接到我的计算机(Ubuntu 和 Windows)网络接口的外部设备(EtherCAT 总线技术)。没有连接其他网络设备。通信确实在没有 IP 堆栈的标准 IEEE 802.3 以太网帧上完成。
发送数据示例:
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);
我尝试了 JNetPcap,它使用 pcap 原生库。给定的 API 很好,但是在重负载时存在多线程问题,这迫使我放弃。
netty.io 也是候选人。我不确定,但 TCP/IP 堆栈是强制性的。我说的对吗?
还有其他与低级以太网帧通信的想法吗?如果存在的话,我更喜欢像 netty.io 这样的纯 Java 库。
当然,JNA/JNI 也是一种选择。但是我不想写C代码。
其他选择?
【问题讨论】:
-
你找到解决办法了吗?
标签: java ethernet raw-ethernet