仅使用 MAC 地址在两个系统之间进行通信
我想知道如何使用 C 程序仅使用 MAC 地址(不使用 IP 地址)在两个系统之间进行通信。我认为这是原始的以太网通信。我的要求是仅使用 MAC 地址从客户端向服务器发送数据。也许这可以通过创建我们自己的原始以太网框架来完成。
请帮助我解决这个问题。如果有人用C写过代码,请分享。
此链接可能对您有帮助, http://aschauf.landshut.org/fh/linux /udp_vs_raw/ch01s03.html
I want to know how to communicate between two systems using only MAC address using C program (without using IP address). I think this is raw ethernet communication. My requirement is to send data from client to server only by using the MAC address. May be this can be done by creating our own raw ethernet frame.
Please help me regarding this. If anybody has written code in C, please share.
This link may help you, http://aschauf.landshut.org/fh/linux/udp_vs_raw/ch01s03.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
libpcap 库允许您组装原始以太网数据包并将它们直接发送到适配器:最困难的部分是发现正确的适配器。这是专为大多数平台(Win PCAP 等)上的 C/C++ 使用而设计的。
但请确保这就是您想要的:我见过几个使用原始以太网数据包接口的项目,只是为了重新传输和窗口等而放置越来越多的协议,直到您最终得到自己的版本TCP/IP(只有一种尚未经过数百万人使用 Windows/Linux 或任何平台的测试)。如今,大多数以太网芯片也具有加速 TCP/IP 堆栈的功能:所以您也会错过这一点。
The libpcap library allows you to assemble raw Ethernet packets and send them directly to an adapter: the hardest part being the discovery of the correct adapter. This is designed for C/C++ usage on most platforms (Win PCAP etc.).
Be sure this is what you want though: I have seen several projects where raw Ethernet packet interfaces have been used, only for more and more protocol to be put in place for re-transmission and windowing etc. until you end up with your own version of TCP/IP (only one that hasn't been tested by millions of people using Windows/Linux or whatever your platform is). Most Ethernet chips have functions to accelerate TCP/IP stacks these days too: so you will be missing out on that too.
这里是示例对于 C#,也许你可以利用这个。正确的代码取决于操作系统,甚至取决于微控制器编程时所使用的芯片。
Here are examples for C#, maybe you can leverage this. The right code depends on OS and even from the used chips when programming for microcontrollers.