如何在网络上查找邻居不使用IP

如何在网络上查找邻居不使用IP

本文介绍了C / C ++ Linux,如何在网络上查找邻居不使用IP(仅MAC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个小型网络中,说20个节点或更少,我的程序,在测试仪器上,需要知道谁在那里?由MAC而不是IP。我将插入随机网络,需要能够做到这一点,而不必知道任何地址,MAC或网络中的其他,知道我不能依赖DHCP。完全合理的DHCP服务器可能关闭,节点没有IP地址和/或,我不能得到一个。实际上,我不需要IP,我们的测试协议是MAC层,而不是IP。

In a small network, say 20 nodes or less, my program, on a test instrument, needs to know "Who is out there?" by MAC not by IP. I will be plugging into random networks and need to be able to do this without having to know any addresses, MAC or otherwise in the network and knowing I can't rely on DHCP. It is completely reasonable that the DHCP server could be down and the nodes have no IP addresses and/or, I can't get one. Truthfully, I don't need IP, our test protocol is MAC layer, not IP.

那么,如何确定我的仪器的邻居的MAC地址?这听起来很像LLDP,但是向后,即谁在那里,而不是我在这里,我可以做到这一点...。我必须假设没有IP分配到端点,所以没有ARPing,没有NMAP等。

So, how can I determine my instrument's neighbor's MAC addresses? This sounds a lot like LLDP but backwards, i.e., "who's out there", not "I'm here and I can do this...". I must assume there is no IP assigned to the endpoints, so no ARPing, no NMAP, etc.

注意我应该添加,这是有线网络。

Note I should add, this is a wired network.

推荐答案

在一般情况下,没有可以发送的MAC级别协议,并保证网络上每台机器的响应(我假设你在这里使用以太网,因为我相信在WLAN上的东西不同)。 IE在主机保证响应的MAC层没有广播(或甚至,IIRC单播)。在IP上面,你可以IP广播和检查ARP缓存。

In the general case, there is no MAC level protocol that you can send and guarantee a response from every machine on your network (I am assuming you are using ethernet here as I believe things are different on WLAN). IE there is no broadcast (or even, IIRC unicast) at the MAC layer that a host is guaranteed to respond to. With IP on top, you can IP broadcast and check the ARP cache.

最好的方法是(我认为)是使用开关/学习网桥工作在以太网,即被动地以混杂模式监听数据包并记录其MAC地址。你不会发现完全沉默的主机,但两者都不会切换,直到它发送一个数据包。根据定义,没有办法找到一个完全沉默的主机。

The best way to do this would (in my opinion) be to use the way switches / learning bridges work on ethernet, i.e. passively listen in promiscuous mode for packets and note their MAC addresses. You won't spot completely silent hosts, but neither will a switch until a packet is sent by it. By definition there is no way to spot a completely silent host anyway.

这篇关于C / C ++ Linux,如何在网络上查找邻居不使用IP(仅MAC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:07