[英]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. 我有一个用python扭曲编写的客户端,该客户端将UDP数据包发送到IP aaa.bbb.ccc.ddd的端口1234,然后等待响应。 I also have UDP server written in C-libuv, that listens on port 1234 and responds back to the client.
我还有用C-libuv编写的UDP服务器,它侦听端口1234并响应客户端。
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. 现在,当它们都在同一台机器上运行时,我可以从UDP服务器的日志中看到它已接收到数据并且它已发送回一个响应。 But the logs of client doesn't show any signs of any UDP packet received.
但是客户端的日志没有显示任何收到的UDP数据包的迹象。
When I investigated using wire-shark i found the following: 当我使用wire-shark进行调查时,发现以下内容:
A UDP packet by the client is send with source port 58963(keeps changing) to destination at port 1234 客户端发送的UDP数据包的源端口为58963(keeps不断变化),到达目标端口1234
A UDP response (form the UDPserver) is also send back from 58845 to 58963 UDP响应(来自UDP服务器)也从58845发送回58963
This is followed by a ICMP Destination unreachable (Port unreachable) msg. 随后是ICMP目标不可达(端口不可达)消息。
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. 原因是服务器使用新的UDP套接字发送答复,而不是使用接收请求的套接字。 This is poor practice on the grounds of economy, and it also makes any required UDP hole-punching impossible.
从经济的角度来看,这是一种糟糕的做法,并且也使得不可能进行任何必需的UDP打孔。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.