[CN notes] Transport and Applications Layers

莉森羊
5 min readDec 20, 2022

CN notes 前情提要:傳送門

目錄:
What does the transport layer provide?
What is a packet for the transport layer called?
What are the two main protocols within the transport layer?
What is multiplexing, and why is it necessary?
Describe the two types of multiplexing/demultiplexing.
What are the differences between UDP and TCP?
When would an application layer protocol choose UDP over TCP?
Explain the TCP Three-way Handshake.
Explain the TCP connection tear down.
What is Automatic Repeat Request or ARQ?
What is Stop and Wait ARQ?
What is Go-back-N?
What is selective ACKing?
What is fast retransmit?
What is transmission control, and why do we need to control it?
What is flow control, and why do we need to control it?
What is congestion control?
What are the goals of congestion control?
What is network-assisted congestion control?
What is end-to-end congestion control?
How does a host infer congestion?
How does a TCP sender limit the sending rate?
Explain Additive Increase/Multiplicative Decrease (AIMD) in the context of TCP.
What is a slow start in TCP?
Is TCP fair in the case where connections have the same RTT? Explain.
Is TCP fair in the case where two connections have different RTTs? Explain.
Explain how TCP CUBIC works.
Explain TCP throughput calculation.

What does the transport layer provide?

The Transport Layer provides an end-to-end connection between two applications that are running on different hosts, regardless if the hosts are in the same network.

What is a packet for the transport layer called?

We refer to this combined message as a segment.

What are the two main protocols within the transport layer?

The two most common transport layer protocols:

  • Transmission Control Protocol (TCP)
  • User Datagram Protocol (UDP)

What is multiplexing, and why is it necessary?

  • Multiplexing: the ability for a host to run multiple applications to use the network simultaneously.
  • 例如:一名用戶在使用 Facebook 的同時也在 Spotify 上聽音樂。這兩個過程都涉及到兩個不同服務器的通信。

Describe the two types of multiplexing/demultiplexing.

The two types of multiplexing / demultiplexing:

  • Connectionless: uses UDP and only requires the destination IP address and destination port.
  • Connection-oriented: uses TCP and requires the source IP address, source port, destination IP address and destination port.

What are the differences between UDP and TCP?

  • TCP: provides end-to-end communication and reliability. TCP 保證數據的可靠傳送,並確保數據包以它們發送的相同順序到達,並且提供錯誤檢測和糾正功能。
  • UDP: 是一種無連接協議,其功能與 TCP 非常相似,但沒有錯誤檢測和糾正服務 ( The Application Layer must implement these features, if necessary.)。取而代之的是,無論是否收到數據包,都會不斷地將數據包發送給接收方。這允許設備以更少的開銷更快地相互通信。

When would an application layer protocol choose UDP over TCP?

對於一些對延遲敏感的實時應用程序,UDP 是更好的選擇,儘管丟包(packet loss)率可能更高。

Explain the TCP Three-way Handshake.

建立 TCP 連接時,會收送三個封包,這個部分稱作「三向交握」(Three-way Handshake)
  • step 1:TCP client 發送一個特殊的 segment(不包含數據),SYN bit 設置為 1。客戶端還生成一個初始序列號(client_isn)並將其包含在這個特殊的 TCP SYN segment 中。
  • step 2:The server 收到此 packet 後,為連接分配所需的資源,並發送回特殊的 “connection-granted” segment,我們稱之為 SYNACK segment。 此 packet 的 SYN bit 設置為 1,TCP segment header 的 acknowledgement field 設置為client_isn+1,以及為服務器隨機選擇的初始序列號 ( server_isn)。
  • step 3:當 the client 收到 SYNACK segment 時,它也會為連接分配緩衝區和資源,並發送一個 SYN bit 設置為 0 的 acknowledgment。

Explain the TCP connection tear down.

  • step 1:當客戶端想要結束連接時,它會向服務器發送一個 FIN bit 設置為 1 的 segment。
  • step 2:服務器 確認已收到連接關閉請求,現在正在關閉連接。
  • step 3:服務器隨後發送一個 FIN bit 設置為 1 的 segment,表示連接已關閉。
  • step 4:客戶端為它發送一個 ACK 給服務器。它還等待某個時間重新發送此 acknowledgment,以防第一個 ACK segment 丟失。

What is Automatic Repeat Request or ARQ?

Automatic Repeat Request (ARQ): If the sender does not receive an acknowledgment within a given period of time, the sender can assume the packet is lost and resend it.

What is Stop and Wait ARQ?

Stop and Wait ARQ: sending and receiving with a timeout for acknowledged segments.

What is Go-back-N?

The sender would then send all packets from the most recently received in-order packet, even if some of them had been sent before. The receiver can simply discard any out-of-order received packets. This is called Go-back-N.

What is selective ACKing?

因單個數據包錯誤會導致大量不必要的重傳,為了解決這個問題, TCP uses selective ACK ing. 發送方僅重新傳輸它懷疑接收錯誤的那些數據包。然後,接收方將確認正確接收到的數據包,即使它不按順序排列。

What is fast retransmit?

當發送方接收到一個數據包的 3 個重複 ACK 時,它認為該數據包丟失,並將重新發送它,而不是等待超時。這稱為 fast retransmit. 這種方法比利用超時來控制重送更快速。

What is transmission control, and why do we need to control it?

Transmission control is used to control how much data is sent over a link by applications in used by each host on the network. Transmission control implements fairness on the network and congestion control for Layer 3 devices that provide connectivity.

What is flow control, and why do we need to control it?

Flow control controls the transmission rate to protect a receiving host’s network buffer from overflowing with information. It’s possible that a receiving host is involved with multiple processes and does not read data from its network buffer instantly. This could cause an accumulation of data that overflows its buffer.

What is congestion control?

Congestion Control is concerned with protecting the entire network from congestion. Given multiple devices using the same link, Congestion Control aims to avoid the link reaching max capacity, thus causing dropped packets and retransmissions.

What are the goals of congestion control?

  • Efficiency — high throughput and network utilization.
  • Fairness — every host should get a fair share of the network bandwidth.
  • Low delay
  • Fast convergence — network flow should be able to quickly converge to fair allocation.

What is network-assisted congestion control?

Network-assisted congestion control involves Layer 3 devices providing feedback to hosts on the congestion of the network. This is usually implemented by sending diagnostic ICMP messages.

  • 然而,即使是 ICMP 數據包也可能在嚴重擁塞的情況下丟失,從而導致網絡反饋無效。

What is end-to-end congestion control?

The network does not provide any feedback to hosts about the congestion of the network to end points. Hosts must infer network behavior and adapt their transmission rate.

How does a host infer congestion?

主要有兩種擁塞信號:

  • the packet delay:可以基於 ACK 估計的往返時間的增加可以指示網絡中的擁塞。然而,事實證明,網絡中的數據包延遲往往是可變的,這使得基於延遲的擁塞推斷非常棘手。
  • packet loss: 隨著網絡擁塞,路由器開始丟棄數據包。請注意,數據包也可能由於其他原因而丟失,例如路由錯誤、硬件故障、生存時間 (TTL) 到期、鏈接錯誤或流量控制問題,儘管這種情況很少見。

How does a TCP sender limit the sending rate?

TCP uses a congestion window, similar to the receive window for flow control by receiving hosts. TCP probes and adapts the congestion window, increasing to try and achieve the highest through, and decreasing when enough segments are dropped.

Explain Additive Increase/Multiplicative Decrease (AIMD) in the context of TCP.

當擁塞級別上升時它會減小窗口,當擁塞級別下降時它會增加窗口。我們將這種組合機制稱為 additive increase/ multiplicative decrease (AIMD)

What is a slow start in TCP?

Instead of using addition to establish the initial size of the congestion window, TCP will exponentially increase the congestion window until congestion is experienced.

Is TCP fair in the case where connections have the same RTT? Explain.

Yes, as both will increase and decrease window sizes as needed to balance.

Is TCP fair in the case where two connections have different RTTs? Explain.

No, a shorter RTT would increase the window faster.

Explain how TCP CUBIC works.

TCP CUBIC uses a cubic function for the calculation of its congestion window. When TCP CUBIC detects congestions, it exercises a multiplicative decrease on its congestion window. Afterwards, it greatly increases its congestion window and plateaus until no congestion is detected. It then increases the congestion window again.

Explain TCP throughput calculation.

--

--