Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

python 3.x - windows sockets, udp and udp replies different addresses

I have a problem with UDP messages under Python3 on Windows10. The UDP messages are a command/response scheme.

  • Example: CMD_TURN_ON_LIGHT_BULB, Bulb #4
  • Response: RSP_TURN_ON_LIGHT_BULB, Bulb #4 - OK.

My local Windows PC address is: 10.1.1.10

In all cases, the netmask here is 255.255.255.0

The remote device has 2 network addresses. There are various routers between the PC and the remote device.

Device Address (A) is 10.2.2.10 (and is the "default route").

Device Address (B) is 10.3.3.10 (it is a backup interface)

Case 1: This works.

PC sends UDP to 10.2.2.10 (it uses "sendto()") The remote device responds to the source address using sendto()

The PC receives the response, and the application receives the response. The PC has a pending/waiting "recvfrom()"

Case 2: This does not work.

PC Sends UDP to 10.3.3.10 (the backup interface) The remote device replies - However - due to default route rules, the device replies from 10.2.2.10

The PC receives the reply (I see the reply/response in Wireshark) The PC has the firewall 100% disabled But - The application does not receive the UDP message from the remote device.

Any suggestions?

Stated differently:

  • This works: Transmit to UPD address (A), Port X - reply from: A, port Y
  • This fails: Transmit to UDP address (B), port X - reply from: A, port Y

The second case, the packet seems to be lost inside the bowels of Windows...

question from:https://stackoverflow.com/questions/65602762/windows-sockets-udp-and-udp-replies-different-addresses

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...