窄带可扩展消息格式

发布于 2024-07-26 18:07:12 字数 214 浏览 6 评论 0原文

我正在整理一份对招标的技术响应,其中一项要求是在窄带宽网络(10 字节/秒左右)上使用可扩展格式传递消息。 为了让服务器上的生活变得轻松,我想使用 Xml,服务器将从 1000 个设备接收信息。 为了帮助解决带宽问题,我可以使用压缩的 Xml,但数据来自嵌入式设备,这些设备可能没有足够的能力进行动态压缩。 任何人都有更好的想法,理想的是一种小型可扩展格式,一旦通过窄带接收到消息,就可以将其合并为 Xml。

I'm putting together a technical response to tender, one of the requirements is to pass messages using an extensible format over a narrow bandwidth network (10 bytes/sec or so). To make life easy on the server, which will be receiving info from 1000's of devices I'd like to use Xml. To help with the bandwidth issue I could use compressed Xml, but the data is coming from embedded devices that might not have the omph to do compression on the fly. Anyone got any better ideas, an ideal would be a small extensible format, that could be hyrdated into Xml once the messages have been received over the narrow band.

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

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

发布评论

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

评论(5

荒岛晴空 2024-08-02 18:07:12

Google Protocol Buffers

协议缓冲区是一种以高效且可扩展的格式对结构化数据进行编码的方法。 Google 几乎所有内部​​ RPC 协议和文件格式都使用 Protocol Buffer。

Google Protocol Buffers

Protocol Buffers are a way of encoding structured data in an efficient yet extensible format. Google uses Protocol Buffers for almost all of its internal RPC protocols and file formats.

ˇ宁静的妩媚 2024-08-02 18:07:12

YAML 是一种非常简洁的格式,非常适合在设备之间传递序列化信息。 大多数编程语言都有可用的库,因此服务器可能可以直接理解它,而无需转换为 XML。

YAML is a very terse format ideal for passing serialized information between devices. There are libraries available for most programming languages, so the server could probably understand it directly and there wouldn't be any need to convert to XML.

倒数 2024-08-02 18:07:12

更多信息会很有用。 如前所述,答案可能是 ASCII。 您是否正在考虑传输数字、浮点数、度数、名称? 也许是一些更深奥的东西,比如 ASN.1。 或者你可能会完全发疯,就像其他建议一样。

Some more info would be useful. As it's stated the answer could be ASCII. Were you thinking of transmitting numbers, floats, degrees, names? Perhaps something more esoteric like ASN.1. Or you could go completely mad, as with the other suggestions.

蹲墙角沉默 2024-08-02 18:07:12

正如其他人所说,Google Protocol Buffers 或 Apache Thrift 是非常流行的二进制序列化工具。 也就是说,它们确实有一些开销,因为它们标记每个字段(以在更改架构时实现有限形式的向后/向前兼容性)。

Apache Avro 不会做这种标记,会为您节省一点空间因为这个。

Like others have said, Google Protocol Buffers or Apache Thrift are very popular binary serialization tools. That said, they do have some overhead because they tag each field (to achieve a limited form of backward/forward compatibility as you change the schema).

Apache Avro doesn't do that tagging and will save you a tiny bit more space because of that.

給妳壹絲溫柔 2024-08-02 18:07:12

一般来说,使用 XML 不会让服务器的工作变得更轻松。 如果您使用 XML 的任何“功能”(命名空间、实体、转义、国际化等),XML 解析代码就会很复杂,并且解析 XML 通常比解析其他格式(例如 JSON)慢。 您可以在一页代码中编写一个简单的 JSON 编码器/解码器,而 XML 甚至 YAML 将需要更多的复杂性。 Avro、Thrift 和 Google Protocol Buffers 都是不错的选择,尽管您会增加依赖足迹。

如果您确实限制为 10 字节/秒,那么您可能需要一种没有大量引用或语法的编码; 手工制作的长度前缀协议,或者类似 protobuf 的二进制编码,可能就是您想要的。

In general, you won't be making the server's life easier by using XML. XML parsing code is complex if you use any "features" of XML (namespaces, entities, escaping, internationalization, etc), and parsing XML is usually slower than parsing other formats such as JSON. You can write a simple JSON encoder/decoder in a page of code, whereas XML and even YAML will require more complexity. Avro and Thrift and Google Protocol Buffers are good choices though you will be increasing your dependency footprint.

If you're really restricted to 10 bytes / sec then you will likely want an encoding that doesn't have a lot of quoting or syntax; a hand-crafted length-prefixed protocol, or something like protobuf's binary encoding, is probably what you want.

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