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.