Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,059 Views

get MAC address of target IP

Hi, 

 

I have already spent some days searching the information how to fetch the MAC address associated with an IP address. 

I am primarly an FPGA designer and unfortunately beginner with regard to ucOS and nichestack and would be happy for any help I can get. 

 

From what I understood, the flow is the following: the NIOS sends an ARP packet to the selected IP and on the return of the response fetches the node's ethernet address. 

Can anyone help me with some sample code how to send the arp packet and extract the needed information from the arp response? 

 

thank you!
0 Kudos
7 Replies
Altera_Forum
Honored Contributor I
71 Views

wikipedea isn't a bad bet for such information. 

The ARP protocol is used to find the MAC address of a remote system. The software for a TCP/IP stack will usually contain ARP support. 

If you need to assign a dynamic IP address to your own system you need dhcp.
Altera_Forum
Honored Contributor I
71 Views

I have tried, I have understood the structure/role of arp/icmp/etc packets, but my problem is how to intiate them from within the nios application.  

 

The question isn't about assigning ip address (I already have the simple socket server example fully operational), but how to initiate the mentioned arp/ping packets.
Altera_Forum
Honored Contributor I
71 Views

ARP packets are (typically) sent when you make an outgoing connection to an IP address for which you don't have a MAC address. This is all handled by the IP stack. 

 

Since an ARP response needs an entry in the ARP table, the receipt of an ARP message usually adds an entry for the remote system. This means that a system than only receives incomming connections (maybe typical of an embedded system using TCP for management) will never send ARP requests, only ARP responses. 

 

Some ICMP messages have to be processed in order to get TCP working properly (especially the 'fragmentation required' one), that code should be part of the IP stack (but might be optional for an embedded system that only uses TCP for management). 

 

Usually an application doesn't worry about arp or icmp - except for 'ping',
Altera_Forum
Honored Contributor I
71 Views

 

--- Quote Start ---  

ARP packets are (typically) sent when you make an outgoing connection to an IP address for which you don't have a MAC address. This is all handled by the IP stack. 

 

Since an ARP response needs an entry in the ARP table, the receipt of an ARP message usually adds an entry for the remote system. This means that a system than only receives incomming connections (maybe typical of an embedded system using TCP for management) will never send ARP requests, only ARP responses. 

 

Some ICMP messages have to be processed in order to get TCP working properly (especially the 'fragmentation required' one), that code should be part of the IP stack (but might be optional for an embedded system that only uses TCP for management). 

 

Usually an application doesn't worry about arp or icmp - except for 'ping', 

--- Quote End ---  

 

 

ok, so assuming the ARP table contains the MAC address of the IP I am interested in, how can I fetch it? I need it sent to an UDP offloader...
Altera_Forum
Honored Contributor I
71 Views

UDP is sent by the ip stack also which implicitly handles the arp cache and translates the ip address to a mac addresss. Note that if you are sending to an ip address that is several hops away then the ip kernel provides the mac address of the default router.

Altera_Forum
Honored Contributor I
71 Views

 

--- Quote Start ---  

UDP is sent by the ip stack also which implicitly handles the arp cache and translates the ip address to a mac addresss. Note that if you are sending to an ip address that is several hops away then the ip kernel provides the mac address of the default router. 

--- Quote End ---  

 

 

ok, I get this. But in my case UDP transmission is handled in hardware, not in NIOS. The only thing the FPGA logic requires from the NIOS in this scenario is the destination MAC address. Broadcast UDP is not what I want...
Altera_Forum
Honored Contributor I
71 Views

In which case you need to do one of: 

1) hard configure the destination MAC address as well as the IP address. 

2) save the MAC address associated with the IP address from some received packet. 

3) use the ARP protocol and send out an ARP packet and parse the response.
Reply