Errors using same port on different machines

限于喜欢 提交于 2019-12-14 03:32:26

问题


I have written an application ( called M2 ) which reads data arriving on one port, processes it, then sends the results out to another port.

If I choose to send data to 193.168.1.101:5001 everything works.

If I send to 192.168.1.101:5001 it does not. Why should changing the first byte of the IP address make any difference?

The reason for the change is that when I trasmit a packet to 193.168.1.101:5001 then it takes about a millisecond, but when I transmit to 192.168.1.101:5001 it takes over a second. This thousand-fold change in timing messes up everything else in my program - in particular reader starvation sets in and I start losing input packets.

What would cause such a drastic change in transmission time? Note that the transmission does not fail, it just takes an extremely long time.


回答1:


The address 192.168.1.101:5001 is extremely slow ( around 2 seconds to transmit a packet ) compared to 193.168.1.101:5001 ( about 1 millisecond ). Since the transmitter was using synchronous sends, the input was starved of CPU and so input packets were dropped.

I changed the the output transmitter to asynchronous operation, with a deadline timer to limit the amount of time spent on attempting to transmit a packet. This solved the input starvation. I used code based on this: http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/timeouts/blocking_udp_client.cpp

I am still curious why one address would be a thousand times slower than another. The bad address is on the same subnet ( is that the correct term? ) as the transmitting computer, so perhaps that has something to do with it?



来源:https://stackoverflow.com/questions/33831639/errors-using-same-port-on-different-machines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!