Currently I am working on a research project, let's say we have two computers connected over LAN cable directly with out any switch or router in same sub-network. Both nodes not have IP address currently, Is there any way i can fetch MAC of destination node and vice versa? I have research on this issue but mostly find solution linked with IP. like arping, getmac, nmap etc. but all based on IP. Is there any code using some network socket like PF_PACKET socket or something else which can give idea about how we handle this problem. I have found something about ARP but I am wondering it will not that solution which we hunting for click [here] https://www.lynxbee.com/understanding-arp-basics-and-sending-arp-request-and-receiving-arp-reply-using-c-code-in-linux/

Our application send/receive frame from Layer-2 MAC using PF_PACKET based socket. Right now we can extract MAC address from source NIC interface but for destination MAC address we need some method with out IP layer-3 module communication.

Env: Language C,CentOS 7, kernel v3.10.

Thank you in advance.

closed as off-topic by Ron Maupin Jan 7 at 13:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "NE is a site for to ask and provide answers about professionally managed networks in a business environment. Your question falls outside the areas our community decided are on topic. Please visit the help center for more details. If you disagree with this closure, please ask on Network Engineering Meta." – Ron Maupin
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    You need some address discovery mechanism for the protocol you're using. IPv4 has ARP. IPv6 has ND. If you're rolling your own protocol, this is a part of your protocol to solve. This is why layer-2 broadcast (and multicast) exist. – Ricky Beam Jan 7 at 7:10
  • @RickyBeam Yeah, I got your point. For this we need to deep study in previous work's that have been done for address discovery like ARP for IPv4. Thank you. – Ehsanur Jan 7 at 7:25
  • Please do not cross-post a question to multiple SE sites. Pick one and delete the question on the others, or you may find your question closed on all the sites. – Ron Maupin Jan 7 at 13:43
  • @RonMaupin ohh sorry, I will be care full next time. thank you. – Ehsanur Jan 8 at 6:49

When the MAC address of your destination is unknown it needs to be discovered in some way. ARP is the method for IPv4, but you could run a protocol on Ethernet layer 2 directly.

Use an EtherType value that does not collide with any other protocol - a serious application should be registered with IEEE. Then you can broadcast or better multicast one end to make it known to the other node(s) in the same network. For instance, you could advertise a server service on a regular basis and each client would listen for some time to discover the server(s). Alternatively, a client could broad/multicast the request to discover a server and each server answers in reply.

Programming this protocol is off-topic here on NE. You could try on Stack Overflow.

  • Yeah I get your point and already working in this side. But if we set our own value in EtherType, you know these values are define in Linux kernel defined by IEEE Ethernet standards. If we use our value which not collide with others in this way i think we need to modify kernel networking module otherwise sockets will not work with our defined value. @Zac67 – Ehsanur Jan 8 at 7:03
  • You should be able to register your EtherType value with the OS, but I'm not sure how this works and programming, OS, APIs and such are off-topic here. – Zac67 Jan 8 at 7:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.