When TCP Connection is ready to send data in the out buffer: (flowchart here):
- It checks if the TCP connection State is Established:
- If no, it drops the data.
- If yes,
- It adds the new data onto the out buffer.
- It checks if the Nagle service is turned on:
- If yes, it checks if the size of the out buffer is greater than the MSS:
- If yes, it starts the initial data sending step.
- If no, it checks if there is any unacknowledged data:
- If no, it starts the initial data sending step.
- If yes, it continues to wait for more incoming data.
- If no, it starts the initial data sending step.
- The initial data sending step:
- TCP checks if there are any segments to be retransmitted:
- If yes, it stops and waits.
- If no, it checks if the usable window is smaller than the MSS, and there is more data in the out buffer than usable window size:
- If yes, it stops and waits.
- If no, it starts the new segment sending step.
- The new segment sending step:
- It checks if there are any segments to be retransmitted:
- If yes, it stops and waits.
- If no, it goes through the following steps:
- It updates and checks the unacknowledged data buffer for any segments needed to be retransmitted and transmits those first.
- Otherwise, it prepares the data in the out buffer into TCP segments, and it will eventually send all segments out.