面向消息的协议与面向流的协议之间的区别

发布于 2024-09-04 18:35:55 字数 1455 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

吹梦到西洲 2024-09-11 18:35:55

面向消息的协议以不同的块或组发送数据。数据接收方可以确定一条消息的结束位置和另一条消息的开始位置。流协议发送连续的数据流。

这是一个手机示例。文本消息将是面向消息的协议,因为每个文本消息都与其他消息不同。电话呼叫是面向流的,因为在整个呼叫过程中存在连续的音频流。

互联网上使用的常见协议是 UDP(面向消息)和 TCP(面向流)。维基百科这些术语以获取更多信息。

希望这有帮助

Message Oriented protocols send data in distinct chunks or groups. The receiver of data can determine where one message ends and another begins. Stream protocols send a continuous flow of data.

Here is an example with mobile phones. Text messages would be a message oriented protocol as each text message is distinct from the other messages. A phone call is stream oriented as there is a continuous flow of audio throughout the call.

Common protocols used on the internet are UDP (message oriented) and TCP (stream oriented). Wikipedia these terms for more information.

Hope this helps

手心的海 2024-09-11 18:35:55

流协议逐字节发送数据。您可以将其视为管道,其中一侧进入的所有内容都会转移到另一侧。另一方的任务是确定何时拥有足够的数据来理解它。

TCP 就是一个典型的例子。一旦您通过管道发送“Hello World”,就无法保证它会以这种方式发送。它可以是每个字母本身、两个单词或一个整体。您唯一知道的是字母的顺序相同。

消息协议通常是在流上构建的,但中间有一层负责将每个逻辑部分与另一个逻辑部分分开。它为您解析输入流,并仅在整个数据集到达而不是中间的所有状态到达时才为您提供结果。在前面的示例中,您只会期望完整的“Hello World”消息或什么也没有。

这是相当简化的视图,但我认为它解释了最大的区别。

Stream protocols send data byte-by-byte. You can view it as pipe where all going in on one side gets transfered on other side. It is task of other side to determine when it has enough data to make any sense of it.

TCP is classic example of it. Once you send "Hello World" through pipe, there are no guaranties that it will come as such. It may come as each letter by itself, as two words or in one piece. Only thing that you know is that letters will be in same order.

Message protocols are usually built over streams but there is one layer in between which takes care to separate each logical part from another. It parses input stream for you and gives you result only when whole dataset arrives and not all states in between. In previous example, you would only expect whole "Hello World" message or nothing.

This is quite simplified view, but I think it explains biggest difference.

維他命╮ 2024-09-11 18:35:55

情况有点复杂。

一般来说,有两种不同类型的低级(OSI:物理)类型:

  • 面向包的传输
  • 面向信道的传输

两种传输类型都可以通过调频、调幅、调相发送...

那些频率/幅度/...(也称为模拟调制)可以通过数字化来增强。或用于数字信号。这称为数字调制。

请参阅:https://en.wikipedia.org/wiki/Modulation

面向包的传输使用一种多个包裹的线路。
面向通道的传输针对不同的包裹使用不同的线路。面向信道的传输(如无线电中使用的)的优点是信号无需立即发送。缺点是该通道很少被使用。因此,总带宽较低。因此,我们在 Internet 上使用面向包的传输。但是,这种传输可以基于面向通道的频率调制(如电缆调制解调器)或基于单线封装的幅度调制(如电话线)。

最后,UDP 和 TCP 在 OSI 第 5 级(传输)中是面向包的。因此,关于流式传输和面向消息的 TCP 之间有什么区别的问题是一个很好的问题。

来自shoutcast.com 的使用TCP 的流也被分成包。 (流数据包/消息分为 TCP 数据包。)一个 TCP 数据包有可能丢失。只是,因为 TCP 是面向地址的并且枚举其包,所以可以再次请求该包。这使得 TCP 变得可靠。

TCP 的顶部现在是流。他们利用根据包号对 TCP 包进行排序的可能性。关键是,它们发送的数据更有可能每时每刻都切换到流中。

也许,这澄清了这个问题。

问候

It is a little bit more complicated.

Generally, there are two different types of low-level (OSI:Physical) types:

  • package-oriented transport
  • channel-oriented transport

both transport types can be send by Frequency-Modulation, Amplitude-Modulation, Phase-Modulation ...

Those Frequency/Amplitude/... (also called Analog-Modulation) can be enhanced by digitalisation. Or used for digital signals. This is called Digital-Modulation.

see: https://en.wikipedia.org/wiki/Modulation

Package-Oriented Transports use one line for several packages.
Channel-Oriented Transports use different lines for different packages. The advantage of Channel-Oriented Transports (as used in radios) is, that the signal comes without instantly. The disadvantage is, that this channel is sparse used. So, the total bandwidth is low. Therefore, we use Package-Oriented-Transport for the Internet. But, this transport can be based on the channel-oriented frequency modulation (as Cable-Modems) or on single line package-oriented amplitude modulation (as Telefone-Lines).

In the end, UDP and TCP are package-oriented in OSI level 5 (Transport). So, the question about what is the difference between Streaming and Message-Oriented TCP is a good question.

Also streams from shoutcast.com using TCP are partitionated into packages. (Streaming-Packages/Messages are divided into TCP-Packages.) It is possible, that one TCP-Package get lost. Mere, because TCP is address-oriented and enumerates its packages, the package can be requested again. That makes TCP reliable.

On the top of TCP are now streams. They use the possiblity to order the packages of TCP according to the package-number. The point is, that they send data, which is more likely to switch into the stream on every moment.

Perhaps, that clarifies the question.

Regards

自此以后,行同陌路 2024-09-11 18:35:55

消息流和字节流之间的主要区别在于消息边界。此外,消息流将跟踪消息边界,但字节流不会。

考虑在网络中,1024字节的数据被传输到主机,然后一分钟后又有1024字节传输到同一主机,那么接收器将总共接收2048字节的数据。

在此传输中,消息流将发送两个不同的 1024 字节消息,而在字节流中,会将完整的 2048 字节作为单个单元传输到接收器。

前任。消息流是页面序列。
前任。下载歌曲或电影的字节流。

the main difference between message stream and byte stream is the message boundary. Also the message stream will keep track of the message boundaries but the byte stream dos not.

consider in network the 1024 bytes of data are transmitted to the host, then after a min another 1024 bytes has transmitted to the same host then the receiver will receive totally 2048 bytes of data.

in this transmission the message stream will send two different 1024 bytes of messages while in byte stream will transfer the full 2048to the receiver as a single unit.

Ex. Of message stream is sequence of pages.
Ex. of the byte stream downloading a song or a movie.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文