【问题标题】:How to send Ethernet-Frames in Java without TCP/IP Stack如何在没有 TCP/IP 堆栈的情况下用 Java 发送以太网帧
【发布时间】: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


【解决方案1】:

这些是我能找到的选项:

我还看到 cmets 认为 jNetPcap 应该是线程安全的,但实际上它不是;即与多线程一起使用时会出现问题。

【讨论】:

    猜你喜欢
    • 2014-03-10
    • 2012-04-23
    • 1970-01-01
    • 2013-12-14
    • 1970-01-01
    • 1970-01-01
    • 2019-09-09
    • 1970-01-01
    • 2011-12-30
    相关资源
    最近更新 更多