SIP Method,可用在 Dialog 內或 Dialog 外。RFC3261 §11
UA 註冊成功後,約每分鐘送 SIP OPTIONS 確認 UA 是否還在,不在一直確認到註冊逾時。
int setvbuf(FILE *stream, char *buf, int mode, size_t size);
mode 是 _IONBF (unbuffered)、_IOLBF (line buffered)、和 _IOFBF (fully buffered,指 block buffer?) 之一。除了 unbuffered,size 大小的 buf 取代原本的緩衝區 (會釋出?)。如果 buf 是 NULL,在下次讀寫操作時自動配置新的緩衝區。setvbuf() 可能只能在 stream 任何其它操作之前使用。
注意:需要確認 stream 關閉時,buffer 是可用的。
void setbuf(FILE *stream, char *buf); 相當於 setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
void setbuffer(FILE *stream, char *buf, size_t size); 相當於 setvbuf(stream, buf, buf ? _IOFBF : _IONBF, size);
void setlinebuf(FILE *stream); 相當於 setvbuf(stream, NULL, _IOLBF, 0);
fflush() 強迫輸出。 (見 fclose().)
註:開啟 file stream
#include <stdio.h>
fopen(), fdopen(), freopen
皆會用到 mode,可能是 r、r+、w、w+、a、a+。為了相容,都可以加上 b。
fopen():開啟檔名
fdopen():開啟 file descriptor
freopen():fclose() 再 fopen()?用來改變 stdin、stdout、stderr 使用的 file。
參考
開放運算計畫 Open Compute Project (OCP) 制訂的網路交換機ASIC編程的開放標準 C API,能使同一套軟體堆疊執行於不同廠牌交換機硬體上。
Azure Cloud Switch (ACS):Microsoft 專為資料中心網路互通而設計的Linux版作業系統
精確時間協定 (Precision Time Protocol, PTP) 透過網路封包同步絕對時間、頻率、和相位,達到毫秒級精確度。
版本名詞
PTP Message
| 34-byte Header | Variable-length Body | Optional Suffix |
|---|
| Offset | Octets | Field | 說明 | |
|---|---|---|---|---|
| 0 | 1 | transportSpecific | messageType | |
| 1 | 1 | Reserved | versionPTP | |
| 2 | 2 | messageLength | 長度含 Header、Body、和 Suffix。 | |
| 4 | 1 | domainNumber | ||
| 5 | 1 | Reserved | ||
| 6 | 2 | flags | ||
| 8 | 8 | correlationField | ||
| 16 | 4 | Reserved | ||
| 20 | 10 | sourcePortIdentity | ||
| 30 | 2 | sequenceID | ||
| 32 | 1 | controlField | ||
| 33 | 1 | logMessageInterval | ||
sourcePortIndentity
Announce
Sync/DelayReq/FollowUp
DelayResp/PDelayReq/PDelayResp/PDelayRespFollowUp
Topology changes are considered every «Announce» interval•Offset and drift are adjusted every «Sync» interval•Delays are calculated every «Delay» interval•«Announce», «Sync» and «Delay» intervals don’t have to be (and often are not) the same
參考Remote Authentication Dial-In User Service (RADIUS) 是主從式網路應用協定,提供用戶使用網路服務集中式認證、授權、和記帳 (Authentication, Authorization, and Accounting, AAA) 管理,定義在 RFC2865 和 RFC2866。
+---------+ +------------+ +------+ +-----+ | RADIUS | | RADIUS | | User | | NAS | | Server | | Accounting | +--+---+ +--+--+ +----+----+ +------+-----+ | 連線請求 (用戶名、密碼) | | | |---------------------->| Access-Request | | | |---------------->| | | | Access-Accept | | | 連線通知 |<----------------| | |<----------------------| | | | Accounting-Request start | | |------------------------------->| | | Accounting-Response | | |<-------------------------------| / / / / / / | 斷線請求 | | |---------------------->| Accounting-Request stop | | |------------------------------->| | | Accounting-Response | | 斷線通知 |<-------------------------------| |<----------------------| |
RADIUS Server 使用 UDP port 1812。早期用 UDP port 1645 會和「datametrics」衝突。RADIUS Accounting Server 使用 UDP port 1813。早期用 UDP port 1646 會和「sa-msg-port」衝突。
封包格式 0 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Code | Identifier | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Authenticator |
| 16 octets |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Attributes ...
+-+-+-+-+-+-+-+-+-+-+-+-+-
0 1 2 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | Value ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Length 值包含 Type、Length、和 Value,最小是 2。Value 的格式和長度由 Type 和 Length 決定,完整 Type 列表見 IANA。Value 的類型有:
| # | type | len | value | 說明 |
|---|---|---|---|---|
| 5 | NAS-Port | 6 | integer | 用戶使用的界面編號。 |
| 26 | Vendor-Specific | ≥7 | vsa | 4-byte Vender-Id + string。Vendor-Id 是 Vendor 的 SMI Network Management Private Enterprise Code。string 由 Vendor 自行定義,例如 1-octet vendor type + 1-octet length + value。 |
| 40 | Acct-Status-Type | 6 | enum | Accounting-Request 記帳開始或結束: 1=Start 2=Stop 3=Interim-Update 7=Accounting-On 8=Accounting-Off 9-14=Reserved for Tunnel Accounting 15=Reserved for Failed |
| 41 | Acct-Delay-Time | 6 | integer | 送這個紀錄時延遲的秒數。 |
| 42 | Acct-Input-Octets | 6 | integer | |
| 43 | Acct-Output-Octets | 6 | integer | |
| 44 | Acct-Session-Id | ≥3 | text | 方便 |
| 45 | Acct-Authentic | 6 | enum | Accounting-Request 時表示認證方式 |
| 46 | Acct-Session-Time | 6 | integer | 服務秒數,Accounting-Request 的 Acct-Status-Type=Stop 時回報。 |
| 47 | Acct-Input-Packets | 6 | integer | |
| 48 | Acct-Output-Packets | 6 | integer | |
| 49 | Acct-Terminate-Cause | 6 | enum | |
| 50 | Acct-Multi-Session-Id | ≥3 | text | |
| 51 | Acct-Link-Count | 6 | integer | |
| 61 | NAS-Port-Type | 6 | enum | 用戶使用的界面類型: 0=Async 1=Sync 2=ISDN Sync 3=ISDN Async V.120 4=ISDN Async V.110 5=Virtual 6=PIAFS 7=HDLC Clear Channel 8=X.25 9=X.75 10=G.3 Fax 11=SDSL 12=ADSL-CAP 13=ADSL-DMT 14=IDSL 15=Ethernet 16=xDSL 17=Cable 18=Wireless - Other 19=Wireless - IEEE 802.11 |
| 87 | NAS-Port-Id | ≥3 | text | 描述用戶使用的界面。例如「ISDN 7/2:D:1」。 |
服務開始:送 Accounting Start (type of service being delivered and the user it is being delivered to) 給 RADIUS Accounting server 服務結束:送 Accounting Stop (type of service that was delivered and optionally statistics such as elapsed time, input and output octets, or input and output packets) 給 RADIUS Accounting server Accounting-Request (whether for Start or Stop) 成功的話 RADIUS Accounting server 回 Accounting-Response acknowledgment 建議 Client continue attempting to send the Accounting-Request 直到收到 acknowledgement, using some form of backoff. alternate server (after a number of tries to the primary server fail, or in a round-robin fashion)
Accounting-Request 的 Attribute如果 Accounting-Request 有 invalid Length,整個 request MUST be silently discarded。
所有 SIP 訊息 都要有 Via,縮寫 v。一開始的 UAC 和後續途經的每個 proxy 都會疊加一個 Via 放傳送的位址,依序作為回應的路徑。 格式 sent-protocol sent-by [ ;branch= branch ][ ; 參數 ...] s...