使用不同的机器上同一端口的错误 [英] Errors using same port on different machines

查看:531
本文介绍了使用不同的机器上同一端口的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个应用程序(称为M2)其内容为一个端口上的数据到达,处理它,然后将结果发送到另一个端口。

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

如果我选择将数据发送到193.168.1.101:5001一切正常。

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

如果我发送给192.168.1.101:5001事实并非如此。为什么要更改IP地址的第一个字节有什么区别?

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?

的原因的变化是,当我trasmit数据包到193.168.1.101:5001那么大约需要一毫秒,但是当我传送到192.168.1.101:5001它接管第二。这在时间上千倍的变化打乱了一切在我的计划 - 在特定的读者饥饿集,我开始失去输入数据包

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.

推荐答案

地址192.168.1.101:5001极慢(约2秒至发送分组)相比193.168.1.101:5001(约1毫秒)。由于采用同步发送器发送,输入被饿死的CPU等输入数据包被放弃了。

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.

我改变了输出的变送器异步操作,加上一个期限定时器来限制时间花在试图发送一个数据包的数量。这解决了输入饥荒。我用code基于这样的:<一href=\"http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/timeouts/blocking_udp_client.cpp\" rel=\"nofollow\">http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/timeouts/blocking_udp_client.cpp

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?

这篇关于使用不同的机器上同一端口的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆