Within data communication protocols, optional information may be encoded as a type-length-value or TLV element inside a protocol. TLV is also known as tag-length value.

The type and length are fixed in size (typically 1-4 bytes), and the value field is of variable size. 一条经TLV编码的消息,有三部分组成:Type,Length,Value。其中,Type是指消息的类型,供解析时识别;Length是指消息的长度,通常以Byte计;Value是真正的消息体,因为已经通过Length携带了消息体的具体长度,所以,这里的消息体长度是可变的。另外,Type和Length所占的Byte位数通常是固定的,通常用1-4个字符。

These fields are used as follows:

- Type: A binary code, often simply alphanumeric, which indicates the kind of field that this part of the message represents;

- Length: The size of the value field (typically in bytes);

- Value: Variable-sized series of bytes which contains data for this part of the message.

Some advantages of using a TLV representation:

- TLV sequences are easily searched using generalized parsing functions;

- New message elements which are received at an older node can be safely skipped and the rest of the message can be parsed.

- This is similar to the way that unknown XML tags can be safely skipped;

- TLV elements can be placed in any order inside the message body;

- TLV elements are typically used in a binary format which makes parsing faster and the data smaller;

- It is easier to generate XML from TLV to make human inspection of the data possible.

Type-Length-Value编码的更多相关文章

  1. TLV(类型—长度—值)格式及编码

    转自: http://www.cnblogs.com/tml839720759/archive/2014/07/13/3841820.html 引子: 前段时间在项目中第一次接触TLV,项目中用这种格 ...

  2. ASN.1编码

    来自几年前本人写的一篇博客 http://blog.csdn.net/newyf_cun/article/details/13016069 如下使用libtasn1分析asn1的编码规则. http: ...

  3. unicode 编码在线转换--javascript

    // unicode 编码在线转换工具--javascript 本人在网上搜索,看到有使用javascript做unicode编码转换的,感觉很好玩,所以拿来使用的. 这个功能有目前测试了两种: 1) ...

  4. Protocol Buffers编码详解,例子,图解

    Protocol Buffers编码详解,例子,图解 本文不是让你掌握protobuf的使用,而是以超级细致的例子的方式分析protobuf的编码设计.通过此文你可以了解protobuf的数据压缩能力 ...

  5. js实现编码,解码

    <p><script type="text/javascript">// <![CDATA[var decToHex = function(str) ...

  6. Protocol Buffers(2):编码与解码

    目录 Message Structure 解码代码一窥 varint Protobuf中的整数和浮点数 Length-delimited相关类型 小结 参考 博客:blog.shinelee.me | ...

  7. 车牌、手机、身份证、等敏感信息 屏蔽 替换 、中文转unicode编码 函数

    应工作要求,需要对展示的内容进行敏感信息替换.琢磨的一些时间,编写的函数匹配率还是比较高的. 顺便说下思路,使用的是正则匹配替换和字符串替换.函数可以再改进. 先把需要匹配的内容写好相应的正则,然后进 ...

  8. ASN.1编码方式详解

    ASN ASN.1 – Abstract Syntax Notation dot one,抽象记法1.数字1被ISO加在ASN的后边,是为了保持ASN的开放性,可以让以后功能更加强大的ASN被命名为A ...

  9. rust实战系列-base64编码

    前言 某些只能使用ASCII字符的场景,往往需要传输非ASCII字符的数据,这时就需要一种编码可以将数据转换成ASCII字符,而base64编码就是其中一种. 编码原理很简单,将原始数据以3字节(24 ...

  10. 密码学的基础:X.690和对应的BER CER DER编码

    目录 简介 BER编码 类型标识符 长度 内容 CER编码和DER编码 总结 简介 之前我们讲到了优秀的数据描述语言ASN.1,很多协议标准都是使用ASN.1来进行描述的.对于ASN.1来说,只定义了 ...

随机推荐

  1. Java 枚举活用

    /** * 联盟神兽.神兽资源枚举 * * @author TonyCody * @author 13-9-22 * @time 下午5:35 */ public enum LegionDogzTyp ...

  2. js知识体系的梳理一

    今天简单的总结了js的一些东西,梳理下整个体系,每一次的总结都会有不同的收获:js总结一一.[获取元素]: 1.通过ID: var oBtn=document.getElementById('btn1 ...

  3. 通过imeMode禁用键盘只能输入数字

    var obj = document.getElementById('y'); var arr = [48,49,50,51,52,53,54,55,56,57];//数字对应的键码 obj.onke ...

  4. docker中清理冗余的image,container

    1) 首先进入超级用户模式 [root@docker ~]# sudo su2) 删除container ( container运行时是不能删除的 )首先停止container [root@docke ...

  5. vuejs常用指令

    v-model 表单双向绑定 v-for="文件名 in 向文件添加内容的文件名" 渲染列表(内容) 将中间的in可改写成of v-on:click="name" ...

  6. mybatis-config.xml详解

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC ...

  7. python 操作注册表

    import win32api import win32con keyname = r'Software\Microsoft\Internet Explorer\Main' page = 'www.l ...

  8. Matlab中的fread函数

    Matlab中fread函数用法    "fread"以二进制形式,从文件读出数据. 语法1:[a,count]=fread(fid,size,precision) 语法2:[a, ...

  9. 20145311利用gdb调试汇编代码

    利用GDB调试汇编代码 首先编写c语言原代码,我使用的是同学分析过的代码 #include<stdio.h>short addend1 = 1;static int addend2 = 2 ...

  10. 20145314郑凯杰《信息安全系统设计基础》GDB调试32位汇编堆栈分析

    20145314郑凯杰<信息安全系统设计基础>GDB调试32位汇编堆栈分析 本篇博客将对第五周博客中的GDB调试32位汇编堆栈进行分析 首先放上以前环境配置的图: 图1: 测试代码: #i ...