Nagle算法作用为延迟发送,其意为,不足MSS的数据直到收到确认再发送
Nagle’s Algorithm:(RFC 896)
if there is new data to send
if the window size >= MSS and available data is >= MSS
send complete MSS segment now
else
if there is unconfirmed data still in the pipe
enqueue data in the buffer until an acknowledge is received
else
send data immediately
end if
end if
end if
延迟确认为减少通道中包的数目,如果应答方有数据传输,或有两个ACK需要发送,则发送数据包,否则等待,直到timer超时
Delayed ACK: (RFC1122)
while(timer<ack_delayed_timer)
{
if(there_is_a_segment_from_source())
segment_received++;
if(segment_received==1 && is_possible_piggy_back())
{
piggy_back(sequence_number_of_the_last_segment+1); # ACK within the data
segment_received=0;
timer=0;
break;
}
# if 2 consecutive segments are received, we send a pure ACK
if(segment_received==2)
{
send_pure_ack(sequence_number_of_the_last_segment+1);
segment_received=0;
timer=0;
break;
}
}