18 Aralık 2020 Cuma

TCP Header - SACK Permitted Alanı

Giriş
Bu yazıdaki içeriği uzun zaman önce not almıştım. Anladığım şekliyle tekrar kaleme almaya çalıştım. Konunu uzmanı değilim, böyle bir iddiam yok, yazıda eksikler olabilir.
 
Bu yazıda kavramlar var, her TCP gerçekleştirimi buradaki olmak zorunda değil. 

Acknowledgment Nedir?
Acknowledgment, ARQ (Automatic Repeat Request) kavramı ile ilgili. ARQ güvenilir (reliable) iletişim için vardır. ACK gelmeyen paketleri tekrar gönderir.

Not : ARQ TCP seviyesinde zaten var, ancak daha alta seviyelerde de uygulanabiliyor. Örneğin Mobile Ad hoc Network (Manet) sistemlerinde TCP'nin getirdiği maliyet fazla olduğu için Layer 2 (MAC) seviyesinde de uygulanabiliyor.

TCP Hangi Acknowledgement Yöntemini Kullanır
TCP "Cumulative Positive Acknowledgements" yöntemini kullanır. Açıklaması şöyle
Each TCP segment contains the sequence number of the next byte that the sender of the acknowledgement expects to receive from the remote host. 
Bu yöntemde alan taraf bir sonraki beklediği mesaj numarasını gönderir. Eğer bir sonraki beklenen mesaj gelmezse sürekli aynı numarayı göndererek "go-back-n" denilen davranışı istediğini belirtir. Şeklen şöyle. Burada 123 numaralı paket kaybolduğu için alan taraf 3 tane Cumulative Positive ACK gönderiyor. 123'ten sonra gelen 127,129,131 numaralı paketler için Cumulative Positive ACK gönderilemiyor, dolayısıyla gönderen taraf ta bu paketleri kendi Windows'undan çıkartamıyor

Ancak bu yöntem verimli değil. Açıklaması şöyle. Bu yüzden ilave olarak Selective Acknowledgement (SACK) yöntemi de geliştirilmiş.
The default go-back-n retransmission strategy used by TCP has the advantage of being simple to implement, in particular on the receiver side, but when there are losses, a go-back-n strategy provides a lower performance than a selective repeat strategy. 
SACK mesajların geldiğini bloklar/aralıklar şeklinde karşı tarafa bildirir. Ancak SACK kullanımının olup olmayacağına dair her iki tarafın da evet demesi gerekir.

SACK'e geçmeden önce bir küçük iyileştirme daha yapılmış. Buna "TCP fast retransmit heuristic" deniliyor. Şeklen şöyle Burada yine 3 tane ACK = 123 gönderiliyor ancak 127,129,131 numaralı mesajlar da alındığı için en sonunda ACK = 133 gönderiliyor.
Açıklaması şöyle. Yani dizideki bir mesaj kaybolur ancak dizinin gerisi düzgün gelirse (isolated loss), sorun yok fakat durum bu değilse yine problem var.
The fast retransmit heuristic improves the TCP performance provided that isolated segments are lost and the current window is large enough to allow the sender to send three duplicate acknowledgements.
When losses are not isolated or when the windows are small, the performance of the fast retransmit heuristic decreases. In such environments, it is necessary to allow a TCP sender to use a selective repeat strategy instead of the default go-back-n strategy.
Selective Acknowledgement (SACK) Kullanma Kararı Ne Zaman Verilir
SACK kullanılmasına izin verilip verilmediği yani TCP zarfındaki "SACK Permitted" değeri SYN aşamasında gönderilir. Her iki taraf SACK kullanıp kullanılmayacağını söyler. Açıklaması şöyle.
The SACK option is negotiated between the TCP endpoints, and is only used if support is advertised by both sides of a connection.
Daha detaylı açıklama şöyle.
Selective Acknowledgment (SACK) TCP was another TCP proposal in 1996, in RFC 2018. The earlier variants 8f TCP, even back to Tahoe, implement a cumulative acknowledgment scheme where a lost packet results in duplicate ACKs for each subsequently received packet. Relying purely on the cumulative acknowledgment scheme can lead to inefficiencies when packets are lost. An example of this is a case where 10,000 bytes are sent in 10 different TCP packets, and the first packet is lost during transmission. Using cumulative acknowledgment scheme, the receiver cannot say that it received the bytes 1,000 to 9,999 successfully, and only failed to receive the first packet, containing bytes 0 to 999. Thus the sender may then have to resend all 10,000 bytes.
Selective Acknowledgement (SACK) Yapısı Nasıldır
Yapısı şöyledir.
                     +--------+--------+
                     | Kind=5 | Length |
   +--------+--------+--------+--------+
   |      Left Edge of 1st Block       |
   +--------+--------+--------+--------+
   |      Right Edge of 1st Block      |
   +--------+--------+--------+--------+
   |                                   |
   /            . . .                  /
   |                                   |
   +--------+--------+--------+--------+
   |      Left Edge of nth Block       |
   +--------+--------+--------+--------+
   |      Right Edge of nth Block      |
   +--------+--------+--------+--------+
Örnek
İletişim esnasında şu paketler gelmiş olsun.
0 - 500, 900 - 1100 ve 1300 - 2000 ?
Paketlerin sırasının bozuk olması SACK gönderilmesine sebep olur. Gönderilen SACK şöyledir.
TCP ACK - 501 (in TCP header, not in SACK Option)
TCP SACK - 1st block Left Edge  - 900
TCP SACK - 1st block Right Edge - 1100
TCP SACK - 2nd block Left Edge  - 1300
TCP SACK - 2nd block Right Edge - 2000
(all in the same Segment)
Örnek
Şeklen şöyle. Burada 123 numaralı paket kaybolduğu için alan taraf 3 tane Cumulative Positive ACK gönderiyor. 123'ten sonra gelen 127,129,131 numaralı paketler içinse Selective ACK gönderiliyor. 




Hiç yorum yok:

Yorum Gönder