I'm developing an embedded system that has to communicate with the outside world over 10Base-T ethernet. I have built all functions required to serve web pages, including ARP, IP, TCP, ICMP (ping), HTTP and portions of FTP. Now, I need to build the rest of the code, which will allow me to act as a client. All the above-mentioned protocols have been working well from the server standpoint for several months.
Now, I need to build the client half of these protocols, to request data from other servers. Step 1 is to ARP for the hardware address of the remote server. As I understand it, since the server is on another network, my gateway should respond with its MAC address so that I know to pass all packets destined for that IP to my gateway. Here's the problem:
My device (192.168.1.251, on subnet mask 255.255.255.0) doesn't get an ARP response from my gateway (192.168.1.1) or any machine outside of the network. However, my device (X.251) does get an ARP response from my laptop (192.168.1.100) which is under the same router.
I'm certain that my basic ARP ethernet frame structure is correct, because I reply to ARP requests correctly every time. The difference is in the OPERATION field, which is either a 1 or 2 depending on REQUEST or REPLY.
Here's my device's (192.168.1.251) request to the gateway (192.168.1.1), which gets no response:
FF FF FF FF FF FF <-- destination MAC - broadcast (also tried 0x00)
00 04 A3 7F C1 57 <-- source MAC - my device
08 06 <-- ARP
00 01 <-- ethernet
08 00 <-- IP
06 <-- 6 byte MAC addresses
04 <-- 4 byte IP addresses
00 01 <-- request (2 = reply)
00 04 A3 7F C1 57 <-- sender MAC - mine
C0 A8 01 FB <-- sender IP - mine = 192.168.1.251
00 00 00 00 00 00 <-- target MAC - unknown, reason for request
C0 A8 01 01 <-- target IP - gateway = 192.168.1.1
00 00 00 00 ..... 00 00 00 <-- trailer of 18 sets of 00 for padding
Now, my device's (192.168.1.251) nearly identical request to my laptop (192.168.1.100), which gets a valid response:
FF FF FF FF FF FF <-- destination MAC - broadcast (also tried 0x00)
00 04 A3 7F C1 57 <-- source MAC - my device
08 06 <-- ARP
00 01 <-- ethernet
08 00 <-- IP
06 <-- 6 byte MAC addresses
04 <-- 4 byte IP addresses
00 01 <-- request (2 = reply)
00 04 A3 7F C1 57 <-- sender MAC - mine
C0 A8 01 FB <-- sender IP - mine = 192.168.1.251
00 00 00 00 00 00 <-- target MAC - unknown, reason for request
C0 A8 01 64 <-- target IP - laptop = 192.168.1.100
00 00 00 00 ..... 00 00 00 <-- trailer of 18 sets of 00 for padding
Side notes that may or may not be important:
If I guess right you post your ARP request to your notebook, which is not permitted to answerthat ARP request. Normally every device answers just for itself. Try to enter the target ip 192.168.1.1 for your router. That should work.
By the way you cannot get the MAC Adress of any devices which are outside of your subnet. Every package needs to send to the gateway mac adress with the target ip adress.