简体   繁体   English

libuv:src响应端口与正在侦听进程的端口不同

[英]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进行调查时,发现以下内容:

  1. A UDP packet by the client is send with source port 58963(keeps changing) to destination at port 1234 客户端发送的UDP数据包的源端口为58963(keeps不断变化),到达目标端口1234

  2. A UDP response (form the UDPserver) is also send back from 58845 to 58963 UDP响应(来自UDP服务器)也从58845发送回58963

  3. 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.

相关问题 基于libuv的tcp服务器未在指定端口上侦听 - libuv based tcp server not listening on specified port 分叉的进程一直在监听服务器的端口 - Forked process keeps listening to the server's port 在C中的同一主机和端口上进行多播侦听 - Multicast listening on same host and port in C 如何以编程方式获取正在侦听某个端口的进程的pid? - How to get the pid of a process that is listening on a certain port programmatically? UDP:为两个不同的多播流侦听同一端口 - UDP: Listening to the same port for two different multicast streams 如果我用一个监听套接字监听 2 个端口,我怎么知道哪个端口收到了数据包? - if I am listening on 2 ports with one Listening Socket how can I tell which port received the packet? 使用libuv接收UDP数据包时如何知道目标地址和端口? - How to know target address and port when receiving a UDP packet with libuv? 由accept()返回的新连接的套接字是否始终与侦听套接字绑定到相同的端口? - Is the new connected socket returned by accept() always bound to the same port as the listening socket? UDP单播:两个进程侦听同一个udp端口; 只有一个接收数据包 - UDP unicast: two processes listening on same udp port; only one receiving packets 如何长时间正确维护监听端口? - How to properly maintain a listening port for a long time?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM