- TCP provides a “connection-oriented,” reliable, byte stream service.
- “Connection-oriented” means that two applications using TCP MUST establish a TCP connection with each other before exchanging data.
- TCP reliability is achieved by breaking data down into the “best” size chunks.
- The unit of information passed by TCP is called a segment.
- When TCP sends a segment, it maintains a “timer” waiting for the other side to acknowledge the reception of the segment.
- When TCP receives data from the other end of the connection, it sends an acknowledgment. The ack is not sent immediately.
- TCP maintains a checksum on its header and data. This is an end-to-end checksum that aims to detect any modifications of the data in transit.
- If a segment arrives with an invalid checksum, TCP discards it and doesn’t acknowledge receiving it. It expects the sender to timeout and retransmit.
- Since IP datagrams can get duplicated, a receiving TCP must discard duplicate data.
- TCP also provides “flow control”. Each end of the TCP connection has a finite amount of buffer space. A receiving TCP device only allows the other end to send as much data as the receiver has buffers for. This prevents faster hosts from utilizing all the buffers from slower hosts.
TCP Header
- Each TCP segment contains a “source” and “destination” port number to identify the sending and receiving application
- The sequence number identifies the byte in the data stream from the source to the destination. This is the first by of data in the segment.
- The sequence number is a 32-bit unsigned number that returns to zero after reaching 4,294,967,295.
- The “SYN” flag is turned on when a new connection is made. The sequence number file contains the “initial sequence number” (ISN) chosen by the host for the connection. The sequence number of the first byte of data sent by the host will be the ISN + 1 because the “SYN” flag consumes a sequence number.
- The “acknowledgment number” contains number contains the next sequence number that the sender of the acknowledgment expects to receive.
- It is the sequence number + 1 of the last successfully received byte of data.