Protocol buffers tlv和protobuf

Protocol buffers tlv和protobuf,protocol-buffers,Protocol Buffers,我正在尝试将protobuf-c消息附加到TLV中的值,并通过网络发送它。但是我在数据包转储中看不到正确的内容。下面是tlv结构和.proto文件 struct test_tlv { unsigned int type; unsigned int len; unsigned int val; }; message testproto { optional uint32 type=1; optional string id =2; } 将消息值填充为te

我正在尝试将protobuf-c消息附加到TLV中的值,并通过网络发送它。但是我在数据包转储中看不到正确的内容。下面是tlv结构和.proto文件

struct test_tlv { 
    unsigned int type;
    unsigned int len;
    unsigned int val;
};
message testproto
{
    optional uint32 type=1;
    optional string id =2;
}
将消息值填充为
test.type=2和test.id=“0xabcdbcda”


我已经使用protobuf api将测试打包到val中,并通过网络发送tlv,但在转储的数据包中看不到正确的值。我遗漏了什么吗?

由于消息是以各种形式编码的,所以我假设值是错误的。。解码后,值看起来正确。

您可以使用ready实现将结构转换为字节数组并将其还原。您可以将结果字节数组附加到协议缓冲区结构并通过网络发送。这只是一个选择。。。