aldy120 / High-Performance-Browser-Networking

A reading note from <High Performance Browser Networking by Ilya Grigorik>.
0 stars 0 forks source link

Primer on Latency and Bandwidth #1

Open aldy120 opened 5 years ago

aldy120 commented 5 years ago

Latency

The time from the source sending a packet to the destination receiving it.

從 request 出發到收到所需的時間,通常一個網站,會慢在 latency 而不是 bandwidth 。

Propagation delay

Amount of time required for a message to travel from the sender to receiver, which is a function of distance over speed with which the signal propagates.

在傳送的水管內,路上所花的時間。在光纖內速度直逼光速,約為 2*10^8 m/s 。時間會隨著距離增加。 CDN 可以有效地縮短這個時間。

赤道一圈約 40000 公里,因此可以得出訊號跑一圈大約 200 ms 。

Transmission delay

Amount of time required to push all the packet’s bits into the link, which is a function of the packet’s length and data rate of the link.

發射所需的時間。會隨著傳輸過程中遇到的 router 數量而跟著增加。

Processing delay

Amount of time required to process the packet header, check for bit-level errors and determine the packet’s destination.

接收所花的時間,包括檢查封包。這通常由硬體直接處理,雖短但仍需花費時間。會隨著傳輸過程中遇到的 router 數量而跟著增加。

Queuing delay

Amount of time the incoming packet is waiting in the queue until it can be processed.

排隊等待發送所需的時間。只有當 transmission 的速度比 packets 來的速度慢時會出現。會隨著網路壅擠增加。

Bufferbloat 指的是隨著網路 congestion 的發生,queuing delay 是如何影響整體的 latency 的。問題出在有些 router 接到大量封包會堆積過多,而不是整體成本考量選擇丟棄部分封包。

Bandwidth

Maximum throughput of a logical or physical communication path

水管多粗,每秒可傳多少資料。光纖可以一次傳很多種頻率,所以可以很高。

Wavelength Division Multiplexing (WDM)

這可以在一條 fiber-optic link 裡面,同時利用不同波長的光來傳輸。大幅增加了 bandwidth 。

aldy120 commented 5 years ago

Bandwidth

指的時理想中可傳輸的資料量速度上限。例如中華電信宣稱的網路速度。

Throughput

指的是實際使用的速度,會隨著使用當下時間改變。

aldy120 commented 5 years ago

Long Fat Network (LFN)

當 RTT 太長的時候,使用 TCP 傳送少量資料,會造成時間多浪費在一來一往的確認訊息是否收到上面。一但把一次資料量,可較有效的減少 acknowledge 的次數。一個例子是 Satellite network 。

aldy120 commented 5 years ago

Bandwidth Delay Product (BDP)

一次 RTT 的時間可傳的資料量。可以用 RTT * bandwidth 算出。這個資料量越大,表示你應該一次傳多一點資料,因為 acknowledge 所花費的成本很高。

一次傳大量資料的缺點是

aldy120 commented 5 years ago

Traceroute

利用 ICMP 的 Time Exceed 的機制來獲取此 datagram 途中經過哪些 router 。

我的問題是,看起來 traceroute 是發送多個封包,設定不同的 TTL 。但是每個封包經歷的 router 真的都會一樣嗎?

aldy120 commented 5 years ago

NC (netcat)

可用來發送簡單的 TCP request ,或是 UDP request 。建立 TCP/UDP server 也行。

建立一個 TCP server 在 localhost:2389。

nc -l 2389

建立連線到 localhost:2389。

nc localhost 2389
aldy120 commented 5 years ago

MTR

看起來像加強版的 traceroute 。

重要指標有 packet loss 跟 latency 。如果只有中間的 router 飆高,之後的又降下來,那可能是 limit rate 搞鬼。如果沒有降下來,那可能真的 router 有問題而掉了 packet 。正常的連線是可以允許 10% 的 packet loss 的。

如果發現最後一台 100% packet loss ,那可能是 host 防火牆沒開。