Linux TCP 擁塞控制實現機制

來源:互聯網
上載者:User

幾個重要的計數器:

packets_out    : snd.una後面的資料包

sacked_out     :由SACK確認的資料包(當沒有SACK時,duplicate ack 也使該計數+1)

lost_out          :網路中丟失的資料包的估計

retrans_out    :重傳資料包計數

 

其中lost_out是一個估計值,  取決於具體實現。

駐留於網路中的資料包in_flight = packets_out + retrans_out - left_out。

其中left_out表示離開網路的資料包個數 left_out = sacked_out + lost_out。

 

另外對發送隊列中的資料包都設定了標記:(核心注釋)

 We have three tag bits: SACKED(S), RETRANS(R) and LOST(L).
 Packets in queue with these bits set are counted in variables
 sacked_out, retrans_out and lost_out, correspondingly.
 
 Valid combinations are:
 Tag    InFlight             Description
 0        1                      - orig segment is in flight.
 S        0                      - nothing flies, orig reached receiver.
 L        0                      - nothing flies, orig lost by net.
 R        2                      - both orig and retransmit are in flight.
 L|R     1                      - orig is lost, retransmit is in flight.
 S|R     1                      - orig reached receiver, retrans is still in flight.
 (L|S|R is logically valid, it could occur when L|R is sacked,
 but it is equivalent to plain S and code short-curcuits it to S.
  L|S is logically invalid, it would mean -1 packet in flight 8))

 

在NewReno下,寄件者進入recovery狀態時第一個未確認的資料包被標記為lost;

在SACK下,SACK block間的hole被標記為lost(FACK)。

 

TCP擁塞控制狀態機器(由ACK觸發)

A Open狀態。正常狀態,執行slow start演算法或者是congestion avoid演算法,取決於擁塞視窗和ssthresh的大小

 

B Disorder狀態。當檢測到duplicate ack或者是SACK時,進入此狀態。在此狀態下擁塞視窗不調整,沒收到一個資料包都觸發一個新的資料包的發送。

 

C CWR狀態。檢測到由ECN,ICMP,或者本地設定引起的擁塞提示時,進入此狀態。在此狀態下,每收到2個ACK就把擁塞視窗-1,直到減為原來的一半。

 

D Recovery狀態。當檢測到3個重複的ACK時進入此狀態,一般由Disorder狀態進入。立即重傳第一個未確認的資料包,每收到2個ACK就把擁塞視窗-1,

   直到見到ssthresh(此值在進入Recovery狀態時設定為擁塞視窗的一半)。TCP停留在此狀態直到剛進入此狀態時所有駐留網路的資料包都得到確認,然後

   返回到open狀態

E Loss狀態。當RTO定時器逾時時,進入此狀態。所有駐留於網路的資料包都標記為Lost,擁塞視窗設定為1,啟用slow start演算法。

   當進入此狀態時所有駐留於網路的資料包得到確認後,返回到Open狀態。

 

There are occasions where the number of outstanding

packets decreases suddenly by several segments. For
example, a retransmitted segment and the following forward
transmissions can be acknowledged with a single
cumulative ACK. These situations would cause bursts of
data to be transmitted into the network, unless they are
taken into account in the TCP sender implementation.
The Linux TCP sender avoids the bursts by limiting the
congestion window to allow at most three segments to be
transmitted for an incoming ACK. Since burst avoidance
may reduce the congestion window size below the slow
start threshold, it is possible for the sender to enter slow
start after several segments have been acknowledged by
a single ACK.

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.