简体   繁体   中英

libuv : src port of response not same as port on which process is listening

I have a client, written in python-twisted, that send a UDP packet to port 1234 of an IP aaa.bbb.ccc.ddd and then wait for response. I also have UDP server written in C-libuv, that listens on port 1234 and responds back to the client.

Now when is run both of them in the same machine, I can see that from the log of the UDP-server that the data is received by it and it has send back a response. But the logs of client doesn't show any signs of any UDP packet received.

When I investigated using wire-shark i found the following:

  1. A UDP packet by the client is send with source port 58963(keeps changing) to destination at port 1234

  2. A UDP response (form the UDPserver) is also send back from 58845 to 58963

  3. This is followed by a ICMP Destination unreachable (Port unreachable) msg.

What might be the reason for this behavior ?

The reason is that the server is using a new UDP socket to send the reply on, instead of using the same socket the request was received on. This is poor practice on the grounds of economy, and it also makes any required UDP hole-punching impossible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM