QoS

QoS

  • 封包的 QoS(Quality of Service) 表示該封包的品質,品質越好,表示有越低的延遲、掉包、…,作法是利用封包 header 的特定欄位值,來表示此封包 的優先等級。
  • 此欄位定義在 網路架構 第三層(Internet Protocol) header 的欄位中,長度為 8 bits,在 IPv4 和 IPv6 的 header 中的位置不同。
    • 在 IPv4 Header 此欄位稱為: DSCP / ToS
    • 在 IPv6 Header 此欄位稱為: Traffic Class

      intro

  • 在網路實行 QoS 一般分為 Integrated Services (IntServ) 和 Differentiated Services (DiffServ) 兩大方向

    IntServ

  • IntServ 的 QoS 實施方法是預先在訊息即將通過的每一隻 Router 預留網絡資源 (主要是 Bandwidth),讓訊息封包通過時保證有足夠資源去提供服務。
    • 用道路來作比喻,有一輛消防車趕著去救火,如若遇到交通擠塞便不能提供服務了,IntServ 就好比在每一個路段都把其中一條行車線劃為緊急車輛通道,只有像消防車這類緊急車輛可以使用。
    • 缺點是就算沒有緊急車輛通過,所有道路使用者也不可使用這條預留路線。

      DiffServ

  • DiffServ 則不預先設置緊急通道,當道路暢通時,所有車輛可自由使用任何路線。當某路段發生壅塞 (Congestion) 時,該路段才會實施交通管制,包括把道路分為緊急線、快線和慢線等,然後把車輛分門別類,按其緊急性去使用不同的路線
    • 例如緊急車輛使用緊急線,私人車用快線,公共交通工具使用慢線。甚至會在路線上選擇一些車輛炸掉 😨 (Packet Drop) 來舒緩 Congestion,通當是慢線車輛遭殃。
  • DiffServ 巧妙的地方在於每段道路可設立自己的交通管制方法,路段間互不影響,稱為 Per-hop Behavior (PHB)。而且交通管制措施只會在發生 Congestion 時才會實行,不像 IntServ 需長期預留路線。DiffServ 缺點在於設定比較複雜。

ToS (Type of Service)

  • ToS (Type of Service),細分成 Precedence 及 ToS 欄位
    • | Precedence(3) | ToS(4) | Unused(1) |
    • Precedence (RFC-1112) – 值越高,優先權越高
      1
      2
      3
      4
      5
      6
      7
      8
      | 111 | Network Control |
      | 110 | Internetwork Control |
      | 101 | Critic/ECP |
      | 100 | Flash Override |
      | 011 | Flash |
      | 010 | Immediate |
      | 001 | Priority |
      | 000 | Routine |
    • ToS (RFC-1349) – 值越大,優先權越高。這些值的組合是沒有意義的,分別獨立。
      1
      2
      3
      4
      5
      | 1000 | Minimize Delay |
      | 0100 | Maximize Throughput |
      | 0010 | Maximize Reliability |
      | 0001 | Minimize Monetary Cost |
      | 0000 | Normal Service(Default) |
      :::warning
    • Type of Service 最早定義在 RFC-791。之後的 RFC-2474 則改變了這些區域的代表意義,稱作 DS (Differentiated Services)。
    • ToS 因為定義問題,使得支援性比較低,實際網路上都是用 DS,因此在 IPv6 階段,ToS 已經不支援了。
      :::

      DSCP (Differentiated Service Code Point)

  • RFC-2474,分成 Class Selector、Drop Precedence 及 Explicit Congestion Notification (ECN)欄位
  • Class selector values (3)
DSCP Binary Hex Decimal Typical application Examples
CS0 (Default) 000 0x00 0
CS1 001 0x08 8 Scavenger YouTube, Gaming, P2P
CS2 010 0x10 16 OAM SNMP, SSH, Syslog
CS3 011 0x18 24 Signaling SCCP, SIP, H.323
CS4 100 0x20 32 Realtime TelePresence
CS5 101 0x28 40 Broadcast video Cisco IPVS
CS6 110 0x30 48 Network control EIGRP, OSPF, HSRP, IKE
CS7 111 0x38 56
  • Drop Precedence value (3)

    Drop Precedence Binary Hex Decimal
    Undefined 000 0x00 0
    Low 010 0x02 2
    Medium 100 0x04 4
    Heigh 110 0x06 6
    :::danger
  • The EF marking of 46 does NOT follow the drop preference rules of the assured forwarding model. Please do NOT think that the 11 means high drop preference.
    :::

ntp

1
2
3
4
5
6
7
8
9
10
11
12
From tests that were performed, indications are that precise time
distribution requires a very low packet delay variation (jitter)
transport. Therefore, we suggest that the following guidelines for
Network Time Protocol (NTP) be used:

o When NTP is used for providing high-accuracy timing within an
administrator's (carrier's) network or to end users/clients, the
Telephony service class should be used, and NTP packets should be
marked with EF DSCP value.
o For applications that require "wall clock" timing accuracy, the
Standard service class should be used, and packets should be
marked with DF DSCP.
  • wall clock time
    • Wall-clock time is the time that a clock on the wall (or a stopwatch in hand) would measure as having elapsed between the start of the process and ‘now’.
    • The user-cpu time and system-cpu time are pretty much as you said - the amount of time spent in user code and the amount of time spent in kernel code.
    • The units are seconds (and subseconds, which might be microseconds or nanoseconds).
    • The wall-clock time is not the number of seconds that the process has spent on the CPU; it is the elapsed time, including time spent waiting for its turn on the CPU (while other processes get to run).

Reference