hsifeulbhsifder
hsifeulbhsifder

Reputation: 11

I need to send a UDP packet from the ethernet adapter to an FPGA with a known MAC address and ipv4 address

I need to send a UDP packet over ethernet from 169.254.xx.xx to 192.168.xx.xx. The second address is the address of the FPGA and its MAC address is known. I am using wireshark to monitor the packets, but when i have an unbound socket, and I call sock.sendto() it sends over WLAN. When I bind the socket to the WLAN interface, it sends, but when I bind the socket to the ethernet interface, I get this error when I try to send:

OSError: [WinError 10051] A socket operation was attempted to an unreachable network

When bound to the ethernet interface, and i send to an unused address in the 169.254.xx.xx subnet, it sends an ARP, but nothing is sent when the destination is in the 192.168.xx.xx subnet.

Here is the code:

import socket
import time

address = '192.168.1.239'
port = 1235
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('169.254.190.73', 0))

sock.sendto('100'.encode('utf-8'), (bytes(address, 'UTF-8'), port))
time.sleep(0.005)

sock.close()
''' 
   '''

Upvotes: 1

Views: 1216

Answers (1)

Zac67
Zac67

Reputation: 2910

Since 169.254.xx.xx and 192.168.xx.xx represent different networks, traffic in between needs to be routed. However, 169.254.0.0/16 (autoconf) isn't usually routed.

If both nodes actually reside in the same layer 2 segment, just (manually) change the autoconf client's IP address.

Upvotes: 1

Related Questions