Diameter数据类型

RFC3588_RFC2030(部分)

 

 loading...

support (百度翻译,有道翻译)

 

diameter 基本数据

OctetString   数据长度任意(0~)但是整个数据长度必须是4字节的整数倍,不够填充0.有Octet组成,其中octet
              八位字符串-一字节--C语言 char;eg.char c='1'  (ASCII   :49(十进制)   0x31(十六进制))   内存地址0x  00  对应存放 31
                                             char c=50   (ASCII   :50(十进制)   0x32(十六进制))   内存地址0x  00  对应存放 32
                                             char c=0x33 (ASCII   :51(十进制)   0x33(十六进制))   内存地址0x  00  对应存放 33

Integer32     四字节-C语言 int   存到发送的缓冲区buf中用大端模式(网络字节序) htonl();   eg.61712(十进制)     0xF110(十六进制)         内存地址0x  00  01  02   03  对应存放   00 00 F1  10

Integer64     八字节-C语言 long int 存到发送的缓冲区buf中用大端模式(网络字节序)

Unsigned32    四字节-C语言 unsigned int  存到发送的缓冲区buf中用大端模式(网络字节序)

Unsigned64    八字节-C语言 unsigned long int 存到发送的缓冲区buf中用大端模式(网络字节序)

Float32       四字节-C语言 float  存到发送的缓冲区buf中用大端模式(网络字节序)

Float64       八字节-C语言 double 存到发送的缓冲区buf中用大端模式(网络字节序)

Grouped       AVP组,文档中有定义以及样例,多样

派生类型

Address(ipv4 / ipv6 /...) 由OctetString(C语言 char)派生。但是整个数据长度必须是4字节的整数倍,不够填充0.
                          需要区分32/63位(4/8字节)地址;6字节/10字节
                          两字节:区分什么类型地址(使用IANAADFAM中的十进制值tag(C语言 char=0x0~0xFFFF) http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml)
                          后面字节根据相应地址格式,其中ipv4占四字节,ipv6占八字节
                          eg.
                          ipv4: tag=1   address:128.0.0.1(点分十进制)   内存地址0x 00 01 02 03 04 05   对应存放 00 01 80 00 00 01
                          ipv6: tag=2   address:...                    内存地址0x 00 01 02 03 04 05   对应存放 00 02 ...
Time           四字节。由OctetString(C语言 char)派生。字节等于NTP的整数部分(相对秒钟RFC2030)
               必须支持SNTP。
               eg.
               0x80120420(十六进制)  第一个字节0x8=1000(二进制)   第0bit为1那么通过1900年1月0时整进行估算
               0x42004484(十六进制)  第一个字节0x4=0100(二进制)   第0bit为0那么SNTP通过UTC时间2036年2月7号6时28分16秒整估算
 
UTF8String     由OctetString(C语言 char)派生。整个数据长度必须是4字节的整数倍,不够填充0.
               传递的是UTF-8 octet sequence。根据 
               Note that the AVP Length field of an UTF8String is measured in octets, not characters. 
               需注意的是一个UTF8String的AVP长度用字节衡量而不是编了几个字码
               UCS-4 range (hex.)           UTF-8 octet sequence (binary)
               0000 0000-0000 007F   0xxxxxxx
               0000 0080-0000 07FF   110xxxxx 10xxxxxx
               0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
               0001 0000-001F FFFF   11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
               0020 0000-03FF FFFF   111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
               0400 0000-7FFF FFFF   1111110x 10xxxxxx ... 10xxxxxx
               RFC2279英文版https://tools.ietf.org/html/rfc2279
               RFC2279中文版http://www.chinaitlab.com/linux/manual/develop/rfc/RFC2279.txt
               由于标准10646不断在更新版本中增加附加编码点,实施必须能够处理0x00000001到0x7fffffff之间的任何编码点。
               字节顺序不符合UTF-8字符集中编码点的有效编码、或者超出该范围都是被禁止的。
               避免使用控制字符(ascii码=控制字符+打印字符)。
               但当需要另起一个新行时,可以使用控制字符CR LF。
               (CR的ascii码13(十进制)=0x0D(十六进制)、LF的ascii码10(十进制)=0x0A(十六进制))
               应避免使用前导或尾随空格字符--就是除数据内容外没有多余空格
               (“前导空格”指的就是变量或者常量值的有效内容前面的空格。“尾随空格”,指的就是变量或者常量值的有效内容后面的空格)

DiameterIdentity 由OctetString(C语言 char)派生。但是整个数据必须是4字节的整数倍,不够填充0.
                 DiameterIdentity  = FQDN 
                 --FQDN 正式域名Fully Qualified Host Name
                 --DiameterIdentity值唯一标识一个Diameter节点,用于重复连接和路由环路检测 
                 --若一个Diameter节点可以有多个FQDN标识,应在启动时挑选其中一个FQDN,作为该节点唯一DiameterIdentity
                 --若多个Diameter节点在同一台主机上运行,每个Diameter节点必须分配一个唯一的DiameterIdentity

DiameterURI     "aaa://" FQDN [ port ] [ transport ] [ protocol ]  //没有传输安全 
                "aaas://" FQDN [ port ] [ transport ] [ protocol ] //有传输安全 
                FQDN              = Fully Qualified Host Name 
                port              = ":" 1*DIGIT    //一个端口用来监听进来的连接。默认Diameter端口(3868)
                transport         = ";transport=" transport-protocol 
                                  // 传输层协议中用来监听外来的连接请求。默认为SCTP协议。如果aaa-protocol字段设置为Diameter,则不能使用UDP。
                transport-protocol = ( "tcp" / "sctp" / "udp" )
                protocol           = ";protocol=" aaa-protocol  //默认AAA协议是Diameter
                aaa-protocol       = ( "diameter" / "radius" / "tacacs+" )
            eg.
            aaa://host.example.com;transport=tcp
            aaa://host.example.com:6666;transport=tcp
            aaa://host.example.com;protocol=diameter
            aaa://host.example.com:6666;protocol=diameter
            aaa://host.example.com:6666;transport=tcp;protocol=diameter
            aaa://host.example.com:1813;transport=udp;protocol=radius

Enumerated     由Integer32(C语言 int)派生。类似C语言的int值+使用宏定义,int大端模式(网络字节序)
               对应的diameter应用会有相应的数值解释

IPFilterRule   由OctetString(C语言 char)派生。但是整个数据必须是4字节的整数倍,不够填充0.
               IP过滤规则,IPFW(8) -- IP防火墙和流量整形的控制程序 
               可能涉及到的过滤信息
               Direction
               Source and destination IP address
               Protocol
               Source and destination port
               TCP flags
               IP fragment flag
               IP options
               ICMP types
               用ascii码存放的格式:
                action  dir  proto from src to dst  [options]
               该字段(IPFilterRule)根据IP过滤器实现操作而构成传送的数据
               以RFC为主,部分内容涉及链接,有个别不同,有指出
               英文:https://www.freebsd.org/cgi/man.cgi?query=ipfw
               中文:http://blog.csdn.net/liuyu60305002/article/details/7675623
               action ="permit"|"deny"//permit – 允许匹配该规则的分组通过。 deny - 丢弃匹配该规则的分组。
               dir= "in"|"out" //"in"是来自终端的, "out"是到终端的。
               proto=通过数字定义的IP协议。关键字"ip"表示任何协议都可匹配
               src=<address/mask>[ports]
               dst=<address/mask>[ports]
               address/mask=(ipno)|(ipno/bits)
               option=[frag]//如果与tcpflags 或TCP/UDP 端口规范冲突,Frag可不使用(与ipfw不同点)
                      [ipoptins-spec] [tcpoptions-spec][established]
                      [setup][tcpflags-spec]
                      [icmptypes-types]//option:RFC3588支持范围(与ipfw不同点),多数据逗号隔开
               eg.
               IPFilterRule过滤器实现操作:所有其他地址匹配
               TPFilterRule传的"deny in ip! assigned"  (用的ascii码)
                 
         
QoSFilterRule  由OctetString(C语言 char)派生。但是整个数据必须是4字节的整数倍,不够填充0.
             服务质量过滤规则。
               action dir proto from src to dst [options]
            action ="permit"|"deny"//permit – 允许匹配该规则的分组通过。 deny - 丢弃匹配该规则的分组。
            dir= "in"|"out" //"in"是来自终端的, "out"是到终端的。
            proto=通过数字定义的IP协议。关键字"ip"表示任何协议都可匹配
            src=<address/mask>[ports]
            dst=<address/mask>[ports]
            address/mask=(ipno)|(ipno/bits)
            option=
                tag    - Mark packet with a specific DSCP
                         [DIFFSERV].  The DSCP option MUST be
                         included.使用一个特定的DSCP[RFC2474]标记分组。必须包括DSCP选项
                meter  - Meter traffic.  The metering options
                         MUST be included.Meter流量。必须包括metering选项

 

 

 

 

 

RFC2030
3. NTP Timestamp Format--NTP时间戳格式

   SNTP uses the standard NTP timestamp format described in RFC-1305 and
   SNTP使用在RFC1305或更早的文档版本中被描述的标准NTP时间戳
   previous versions of that document. In conformance with standard
                                       根据标准通信网络惯例,
   Internet practice, NTP data are specified as integer or fixed-point
                      NTP数据指定用指定的整型或固定小数点的数据,
   quantities, with bits numbered in big-endian fashion from 0 starting
               采用大端模式
   at the left, or high-order, position. Unless specified otherwise, all
                                         除非特别说明,       
   quantities are unsigned and may occupy the full field width with an
   否则所有的数据都采用无符号并且会用0填充
   implied 0 preceding bit 0.
   (比如528(十进制)=0x210(十六进制),那么(假设指定长度4字节)内存地址0x 00 01 02 03  对应存放 00 00 02 10)

   Since NTP timestamps are cherished data and, in fact, represent the
   虽然时间戳用来存数据,                          事实上,代表协议的主要辅助
   main product of the protocol, a special timestamp format has been
                                 指定的时间戳格式已经制定好了。
   established. NTP timestamps are represented as a 64-bit unsigned
                时间戳有64bit(指定8字节长度的无符号数且固定小数点的数值)
   fixed-point number, in seconds relative to 0h on 1 January 1900. The
                       时间是相对于1900 已阅0时0分0秒整的
   integer part is in the first 32 bits and the fraction part in the
   前4字节是整数部分(C语言int,需转大端模式htonl()),而小数部分是后面的4字节。
   last 32 bits. In the fraction part, the non-significant low order can
                 小数部分如果不重要可以置0。
   be set to 0.

      It is advisable to fill the non-significant low order bits of the
      恰当的随意填充不重要的低阶位
      timestamp with a random, unbiased bitstring, both to avoid
      systematic roundoff errors and as a means of loop detection and
      既可以避免系统舍入错误也可以作为循环和延迟的检测手段
      replay detection (see below). One way of doing this is to generate
                                    这样做能使8字节产生随机位串,
      a random bitstring in a 64-bit word, then perform an arithmetic
                                            通过算数右移(C语言操作符">>")
      right shift a number of bits equal to the number of significant
                  一定数量的位而获得所需要的时间戳
      bits of the timestamp, then add the result to the original
      timestamp.             在把这个结果假如原时间戳中



   This format allows convenient multiple-precision arithmetic and
   这个算法方便了高精度算法和转换到UDP/TIME
   conversion to UDP/TIME representation (seconds), but does complicate
   the conversion to ICMP Timestamp message representation, which is in
   但是也恶化了从毫秒转换到ICMP实践戳消息的表示。
   milliseconds. The maximum number that can be represented is
                 有代表性的最大的数值0xFFFFFFFF(十六进制)精度到200微微秒
   4,294,967,295 seconds with a precision of about 200 picoseconds,
   which should be adequate for even the most exotic requirements.
   对于更精密的需求将会被屏蔽掉

                        1                   2                   3   
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1/十进制
   |<-----0------->|<-----1------->|<-----2------->|<-----3------->|第/字节
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                           Seconds(秒钟的整数部分)              |--4字节
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                  Seconds Fraction (0-padded)  (秒钟的小数 部分)|--4字节
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

   Note that, since some time in 1968 (second 2,147,483,648) the most
   注释:一些时间溢出,
   significant bit (bit 0 of the integer part) has been set and that the
   64-bit field will overflow some time in 2036 (second 4,294,967,296).
   Should NTP or SNTP be in use in 2036, some external means will be
   Should NTP 或者SNTP将会在2036年以后使用,一些其他衡量相对于1900年整或者2036
   necessary to qualify time relative to 1900 and time relative to 2036
   年整的方法是必须的,                            
   (and other multiples of 136 years). There will exist a 200-picosecond
   (甚至更多的其他136年)。             一些200微微秒的间隔将被忽略
   interval, henceforth ignored, every 136 years when the 64-bit field
                                 每136年的无效或无法读取的8字节段将被置为0。
   will be 0, which by convention is interpreted as an invalid or
   unavailable timestamp.

      As the NTP timestamp format has been in use for the last 17 years,
      这个时间戳格式已经用了17年
      it remains a possibility that it will be in use 40 years from now
      还能够继续使用40年才会发生数据溢出
      when the seconds field overflows. As it is probably inappropriate
                                        在1968年之前被设置为0的可能和存档的时间戳
      to archive NTP timestamps before bit 0 was set in 1968, a
      有偏差,
      convenient way to extend the useful life of NTP timestamps is the
      一个适当的方法去扩展有用的时间戳的生命期是:
      following convention: If bit 0 is set, the UTC time is in the
                            如果第0bit置1,那么UTC时间在1968到2036范围内,
      range 1968-2036 and UTC time is reckoned from 0h 0m 0s UTC on 1
                      并且时间可以通过1900年1月0时整进行估算。
      January 1900. If bit 0 is not set, the time is in the range 2036-
                    如果第0bit置0,时间范围为2036-2104,
      2104 and UTC time is reckoned from 6h 28m 16s UTC on 7 February
            并且时间可以通过UTC时间2036年2月7号6时28分16秒整估算。
      2036. Note that when calculating the correspondence, 2000 is not a
              请注意,在计算对应关系时,2000年不是一个闰年。
      leap year. Note also that leap seconds are not counted in the
                 请注意,闰秒不计算在估算里面。
      reckoning.

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值