TCP stands Transmission Control Protocol. TCP is one of the transport layer protocols in IP networks. TCP protocol is a connection-oriented protocol which provides end-to-end reliability. When we say TCP is connection-oriented, we mean that before two network nodes start sending and receiving data packets using TCP, they must first create connections using three handshaking protocols. TCP contain techniques for control flow and error detection. This is on reason we say that TCP provide end to end reliability.
TCP establishes a full duplex connection between two end nodes. Each node is defined by an IP address and a TCP port number. The byte stream is transferred in segments. The window size determines the number of bytes of data that can be sent before an acknowledgment from the receiver is necessary. The length of TCP packet is 32 bits.
the packet is like this :
- Code:
MAC Header | IP Header |TCP Header | Data
- TCP Header
Source Port. 16 bits.
Destination Port. 16 bits.
Sequence Number. 32 bits.
The sequence number of the first data byte in this segment. If the SYN bit is set, the sequence number is the initial sequence number and the first data byte is initial sequence number + 1.
Acknowledgment Number. 32 bits.
If the ACK bit is set, this field contains the value of the next sequence number the sender of the segment is expecting to receive. Once a connection is established this is always sent.
Data Offset. 4 bits.
The number of 32-bit words in the TCP header. This indicates where the data begins. The length of the TCP header is always a multiple of 32 bits.
reserved. 3 bits.
Must be cleared to zero.
ECN, Explicit Congestion Notification. 3 bits.
Added in RFC 3168.
- Code:
00 01 02
N C E
N, NS, Nonce Sum. 1 bit.
Added in RFC 3540. This is an optional field added to ECN intended to protect against accidental or malicious concealment of marked packets from the TCP sender.
C, CWR. 1 bit.
E, ECE, ECN-Echo. 1 bit.
Control Bits. 6 bits.
- Code:
00 01 02 03 04 05
U A P R S F
U, URG. 1 bit.
Urgent pointer valid flag.
A, ACK. 1 bit.
Acknowledgment number valid flag.
P, PSH. 1 bit.
Push flag.
R, RST. 1 bit.
Reset connection flag.
S, SYN. 1 bit.
Synchronize sequence numbers flag.
F, FIN. 1 bit.
End of data flag.
Window. 16 bits, unsigned.
The number of data bytes beginning with the one indicated in the acknowledgment field which the sender of this segment is willing to accept.
Checksum. 16 bits.
This is computed as the 16-bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the TCP header, and the data, padded as needed with zero bytes at the end to make a multiple of two bytes. The pseudo header contains the following fields: