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. SVN代码的回滚二

    SVN代码的回滚: 不丢失新建的文件,获得最新的SVN版本控制.TortoiseSVN-ShowLog-选中你要回滚的版本-右键-Export,之后将修改的文件覆盖到你的最新版本,commit即可. ...

  2. Android 界面排版的5种方式

    Android布局是应用界面开发的重要一环,在Android中,共有五种布局方式,分别是:FrameLayout(框架布局),LinearLayout (线性布局),AbsoluteLayout(绝对 ...

  3. 在windows中,如何使用cmd命令行窗口正确显示编码为utf-8格式的文字

    在windows中,如何使用cmd命令行窗口正确显示编码为utf-8格式的文字呢? 正确的步骤如下: 1, 打开cmd命令行窗口 2, 输入命令 >chcp 65001 数字65001代表的是c ...

  4. VFS分析(一)挂载(持续更新)

    基础知识在<深入linux内核架构>第8章,自行脑补. 看下几个关键的过程: do_add_mount里有重要函数lock_mount, lock_mount函数的输入是struct pa ...

  5. ubuntu 查看软件包版本以及软件包的源码

    aptitude show  xxx sudo apt-cache show autoconf setattr, getattr, setattr http://ju.outofmemory.cn/e ...

  6. AndroidStudio .gitinore编写

    # Built application files *.apk *.ap_ # files for the dex VM *.dex # Java class files *.class */R.ja ...

  7. 不支持一个 STA 线程上针对多个句柄的 WaitAll

    [csharp] view plaincopy using System; using System.Collections.Generic; using System.Windows.Forms; ...

  8. C语言 读取文件中特定数据

    //读取文件数据 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> struct jia ...

  9. css3 线性渐变和径向渐变

    线性渐变:ie6以下不兼容 径向渐变:只支持firefox.Chrome和Safari <!DOCTYPE html> <html> <head> <meta ...

  10. Asp.net与Dojo交互:仪器仪表实现

    项目中需要用到仪器仪表的界面来显示实时的采集信息值,于是便遍地寻找,参考了fusionchart和anychart之后,发现都是收费的,破解的又没有这些功能,只好作罢.之后又找遍了JQuery的插件, ...