TCP Fairness
What is TCP fairness? Is there real fairness in TCP? Like many good anwers, the answer is yes and no! Note that a TCP Reno sender adjust its rate based on the AIMD algorithm. To understand TCP fairness, consider two flow sharing an output link. In steady-state periods, the window of a flow, operating in congestion avoidance phase, increases linearly by 1 every RTT. When packet loss is detected, the flow exercises congestion control by halving its window size and then continue with congestion avoidance. Note that the SS threshold is also equal to half the window size when packet loss is detected. Let’s consider the case in which both flows have the same RTT. Then they operate in a similar manner. But, the two flows can be out-of-phase with flow 1 having a larger window than flow 2. Will there be fairness? If the output link has capacity R, then the fair rate for each flow is R/2. Because transmission rate can be approximated by CW/RTT, we need both congestion window to be approximately equal for fair queueing. Let CW1 and CW2 be the window sizes of flow 1 and 2 respectively and CW1 > Cw2 when a loss occur. Note that CW1/2 > CW2/2 meaning that flow 1 decreses its window size faster than flow 2. Then both flow increase then window size by 1 per RTT. CW1 and CW2 will increase until packet losses are detected and CW1 and Cw2 are halved again. With this cycle repeating, Cw1 and CW2 tend towards CW1 = CW2 meaning that both flows share the bandwidth fairly.
What happen if RTTs are different? TCP is a self clocking protocol that utlizes ACKs received in rate adjustment. Let’s consider flow 1 and flow 2 with RTT1 and RTT2, where RTT1 > RTT2. If packet loss is detected in a flow, the CW is halved followed by congestion avoidance. Notably, ACKs for flow 1 will take longer to reach its sender than flow 2. Therefore, flow 2 will icrease its window faster than flow 1. Let RTT1 = 2xRTT2. Then flow 1’s rate increase is appromately half that of flow 2. Because of TCP’s self clocking design, flow 2 will get higher rate than flow 1. When RTT1 >> RTT2, then flow 1’s rate << flow 2’s rate, where unfairness arises.