congestion이란,
네트워크 capacity보다 더 큰 양의 packet들이 network상에 돌아다닐 때 발생한다.
specific하게 정의하자면,
switch나 router에는 queue가 있어서 packet을 processing 하기 전, 한 후에 저장해야 할 공간이 필요하다. (input queue, output queue) 예로 packet의 처리 속도보다 도착속도가 빠르면, input queue에 데이터가 쌓일 테고, packet 출발 속도가 처리속도보다 느리면, output queue에 데이터가 길게 쌓일 것이다.
congestion control이란,
이러한 load를 capacity 이하로 떨어뜨리고, congestion을 control하는 tech를 말한다.
Congestion control of TCP
- Slow Start: Exponential Increase
connection이 establish 되면서 MSS(maximum segment size)의 크기가 1부터 시작한다. window size의 크기는 segment가 ACK 되면, 한 MSS씩 크기가 커진다
EX) MSS가 1일때, ACK되면 다음 MSS가 2되고
MSS가 2가 된것이, ACK되면 다음 MSS는 4 (2+2)가 되고,
MSS가 4가 된것이, ACK 되면 다음 MSS는 8(4+4)가 된다.
이렇게 exponentially 하게 증가하지만, MSS는 ssthresh(slow start threshold)까지만 증가한다.
대부분의 ssthresh는 65535byte로 구현되어 있다.
- Congestion Avoidance: Additive Increase
Slow start 알고리즘으로 cwnd가 커져서 ssthresh까지 도달하게 되면, 그 이후에는 segment 하나씩만 증가시키게 하는 알고리즘이다. 계속 exponentially하게 growth하면 congestion이 일어날 수 있기 때문에 이것을 막고자 만든 algorithm이다.
- Congestion Detection: Multiplicative Decrease
congestion이 일어나면, cwnd가 줄어든다. 이때, ssthresh도 반으로 줄인다. (multiplicative decrease)
대부분의 tcp 구현은 다음 두가지의 reaction을 취한다.
1. time-out이 일어나면(Retransmission time out timer의 time out) 현재 ssthresh를 현재의 window size의 반으로 줄이고, cwnd를 한 segment의 크기로 줄인다음, slow start phase를 다시 시작한다.(위의 slow start algorithm을 다시 시작한다.)
2. 세개의 동일한 ack을 다시 받고 해당 packet을 retransmission 하는경우 (fast retransmission)
ssthresh를 현재 window size의 반으로 줄이고, cwnd를 ssthresh의 크기로 맞추고 congestion avoidance를 시작한다. (RTO time-out보다 weaker한 congestion이기 때문인 모양)