TCP/IP (Transmission Control Protocol)is the transmission layer of the TCP/IP suite of protocols. It breaks data into pieces, wraps it with information needed to route it and reassembles the pieces at the receiving computer's end. The wrapped and bundled pieces are called datagrams.
TCP puts a header on the datagram that provides the information for error checking, error recovery and routing. Examples of this are:
Source port number and destination port number: This allows the data to be sent back and forth to the correct processes running on each computer.
Sequence number: Allows the datagrams to be rebuilt in the correct order on the receiving computer.
Checksum: Allows the protocol to check whether the data sent is the same as the data received. It does this by first totaling the number of bits that make up the content of the datagram and inserting that number into the header. Once that number is inserted TCP passes the datagram to the IP which then routes it to the target computer. The receiving computer then performs the same calculations on the packet. If the two calculations do not match, then there was a transmission error and the datagram is resent.
Acknowledgment number: This number indicates that the data was successfully received. If it wasn't, then after a predefined time-out expires, the sending computer re-sends the data for which no ACK (acknowledgment) was received.
Offset: Tells how long the header is.
Reserved: Variables set aside for future use.
Flags: Indicates that a packet is the last one in a data stream or that the data is urgent.
Window: Provides a way to increase packet size, which improves data transfer efficiency.
Urgent pointer: Gives the location of urgent data.
Options: A set of variables reserved for future use or for special options as defined by the user.
Padding: This ensures that the header ends on a 32-bit boundary.
After all of the above information is the actual data that is to be transferred.