简体   繁体   English

WCF“单向”通信实际上是UDP吗?

[英]Are WCF 'one way' communications actually UDP?

In this article, (toward the end in the 'Windows Communication Foundation' section) the author suggests that a one way transmission in WCF is essentially UDP. 文章中,(朝“Windows通讯基础”部分结束)笔者认为,变速器在WCF一种方式基本上是UDP。 Is this correct? 这个对吗? Should I assume based off the content of this article that marking my service ops as 'one way' means I'm using UDP? 我是否应该根据本文的内容假设将服务操作标记为“单向”意味着我正在使用UDP?

Furthermore, he's suggesting using UDP in conjunction with WS-ReliableMessaging to negate the need to write those aspects of the transport protocol yourself... Ok, but if I want to leverage the performance benefits of UDP in a situation that warrants it, I should, as per this article's suggestion, just use 'one way' and WS-ReliableMessaging and I'm good to go!? 此外,他建议将UDP与WS-ReliableMessaging结合使用,以消除自己编写传输协议的那些方面的需要……好吧,但是,如果我想在需要的情况下利用UDP的性能优势,我应该,按照本文的建议,只需使用“单向”和WS-ReliableMessaging,我就很好了! Sounds a little far fetched to me... 听起来有点牵强我...

So what's the deal here? 那么这是怎么回事? What are the caveats of what this article is suggesting? 本文建议的注意事项是什么?

No, you are misunderstanding the article. 不,您误会了这篇文章。 The article is saying two different things: 文章说了两件事:

  1. WCF one way operations are somewhat analogous to UDP datagrams. WCF单向操作在某种程度上类似于UDP数据报。

  2. WS-ReliableMessaging could be implemented on top of UDP if desired. 如果需要,可以在UDP之上实现WS-ReliableMessaging。

Even one way operations require acknowledgements, retransmissions, and the like to make them reliable. 甚至单向操作也需要确认,重传等来使其可靠。

From the article you mentioned: 在您提到的文章中:

WCF exposes multiple network protocols (most notably TCP) and is extensible to other network protocols by writing a WCF transport channel. WCF公开了多个网络协议(最著名的是TCP),并且可以通过编写WCF传输通道扩展到其他网络协议。 WCF supports UDP through its extensibility model, and the code for a basic UDP channel will be provided as a code sample in the WinFX® SDK. WCF通过其可扩展性模型支持UDP,并且基本UDP通道的代码将作为WinFX®SDK中的代码示例提供。

They're using a UDP transport in their setup so in their situation, yes. 他们在设置中使用UDP传输,因此在他们的情况下,是的。 If you have a service using a TCP-based transport then one way communication would not be UDP. 如果您有使用基于TCP的传输的服务,则单向通信将不是UDP。

And further down in the article: 在文章的后面:

The WCF-based implementation of UDP is a one-way channel 基于WCF的UDP实现是单向通道

So they are really only talking about how UDP in WCF is implemented, and not WCF in general. 因此,他们实际上只是在谈论WCF中UDP的实现方式,而不是一般而言的WCF。

WS-ReliableMessaging relies on the receiver sending acknowledgments ('acks') back to the sender. WS-ReliableMessaging依赖于接收方将确认(“ acks”)发送回发送方。 Otherwise the sender would have no way of knowing whether the message needed resending. 否则,发送者将无法知道消息是否需要重新发送。 In TCP, this is built into the transport protocol (that's one of the differences between TCP and UDP). 在TCP中,它内置在传输协议中(这是TCP和UDP之间的区别之一)。

In UDP, you are forgoing the 'overhead' of TCP, but if you need reliable messaging your server is still sending something back to the client. 在UDP中,您放弃了TCP的“开销”,但是如果您需要可靠的消息传递,您的服务器仍会向客户端发送一些消息。

Actually, if you read that section of the article a bit more closely, you'll see that there's a fair bit more to it than just using one-way messaging and WS-ReliableMessaging. 实际上,如果您更仔细地阅读本文的这一部分,您会发现,不仅使用单向消息传递和WS-ReliableMessaging,还有很多其他事情。 You also have to add a UDP binding element (.eg, bindingElements.Add(new UdpTransportBindingElement()); ), and other similar things. 您还必须添加UDP绑定元素( bindingElements.Add(new UdpTransportBindingElement()); )和其他类似内容。 If you don't add those things, you're still gonna be using TCP. 如果您不添加这些内容,那么您仍将使用TCP。

As an additional note, my suspicion is that you'd need to indulge yourself in some pretty sophisticated benchmarks before you could conclude that UDP is actually going to have higher performance than TCP for web services. 另外要注意的是,我怀疑您需要沉迷于一些相当复杂的基准测试中,然后才能得出结论:对于Web服务,UDP实际上将具有比TCP更高的性能。 I haven't done these tests myself, but my suspicion is that by the time your soap.udp:// binding gets done adding all the reliable messaging bits and what-not to your service, you're going to have pretty much all the same overhead as TCP. 我自己还没有进行这些测试,但是我怀疑当您的soap.udp://绑定完成时,将所有可靠的消息发送位添加为您的服务,而不是添加什么,您将拥有几乎所有与TCP相同的开销。 I suspect that the reason UDP is available as a transport binding is not because of any superior performance characteristics, but to provide an alternative for the corner case of scenarios where TCP (for whatever bizarre environmental reason) isn't available. 我怀疑将UDP用作传输绑定的原因不是由于具有任何优越的性能特征,而是为无法使用TCP(无论出于奇怪的环境原因)的特殊情况提供了替代方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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