The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, the entire suite is commonly referred to as TCP/IP. TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network. Major internet applications such as the World Wide Web, email, remote administration, and file transfer rely on TCP, which is part of the Transport layer of the TCP/IP suite. SSL/TLS often runs on top of TCP.
TCP is connection-oriented, and a connection between client and server is established before data can be sent. The server must be listening (passive open) for connection requests from clients before a connection is established. Three-way handshake (active open), retransmission, and error detection adds to reliability but lengthens latency. Applications that do not require reliable data stream service may use the User Datagram Protocol (UDP) instead, which provides a connectionless datagram service that prioritizes time over reliability. TCP employs network congestion avoidance. However, there are vulnerabilities in TCP, including denial of service, connection hijacking, TCP veto, and reset attack.
Attributes
- It stands for Transmission Control Protocol.
- It is a Layer 4 protocol to transmit data between server and client.
- It can address processes in a host using ports.
- It can control the transmission, unlike UDP, which is a firehose. It's more empathetic than 59.32 UDP.
- It connects the server and the client before transmitting any data.
- It requires a handshake, i.e., both parties must know each other before data transfer.
- It needs 20-byte headers and segments and can go up to 60.
- It is a stateful protocol and maintains the order of the data.
Use cases
- Reliable communication: both parties need to ensure that the communication has happened with feedback.
- Remote shell -> SQL queries and shell commands
- Database connections
- Web communications
- Any bidirectional communication
- It is not a request-response system.
TCP Connections
- Connection is a Layer 5 (session)
- Connection is an agreement between the client and the server.
- Must create a connection to send data -> For Security reasons
- Four properties identify the connection.
- SourcelP-SourcePort
- DestinationIP-DestinationPort
- It can't send data outside of a connection.
- Sometimes called socket or file descriptor.
- Requires a 3-way TCP handshake
- Segments are sequenced and ordered.
- Segments are acknowledged
- Lost segments are retransmitted, but UDP does not care.