3.TCP protocol
3.TCP protocol
TCP
However, the network layer, that provides service for the TCP, sends
packets of information not streams of bytes. Hence, TCP groups a number
of bytes together into a segment and adds a header to each of these
segments and then delivers these segments to the network layer.
This means that the communication can take place in both directions
at the same time.
1. Connection establishment
2. Data transfer
3. Connection termination
• Reliability
• Multiplexing
TCP does multiplexing and de-multiplexing at the sender and receiver ends
respectively as a number of logical connections can be established between
port numbers over a physical connection.
• Byte number, Sequence number and Acknowledgement number
All the data bytes that are to be transmitted are numbered and the
beginning of this numbering is arbitrary. Sequence numbers are given to
the segments so as to reassemble the bytes at the receiver end even if they
arrive in a different order.
Sequence number of a segment is the byte number of the first byte that is
being sent.
TCP Header.
Header Detail
• The header of a TCP segment can range from 20-60 bytes. 40 bytes are for
options. If there are no options, header is of 20 bytes else it can be of
upmost 60 bytes.
16 bit field that holds the port address of the application that is sending the
data segment.
16 bit field that holds the port address of the application in the host that is
receiving the data segment.
• Sequence Number
32 bit field that holds the sequence number, i.e, the byte number of the first
byte that is sent in that particular segment. It is used to reassemble the
message at the receiving end if the segments are received out of order.
• Acknowledgement Number
32 bit field that holds the acknowledgement number, i.e, the byte number
that the receiver expects to receive next. It is an acknowledgment for the
previous bytes being received successfully.
• Header Length (HLEN) – it uses scale of 4
This is a 4 bit field that indicates the length of the TCP header by number
of 4-byte words in the header, i.e, if the header is of 20 bytes(min length of
TCP header), then this field will hold 5 (because 5 x 4 = 20) and the
maximum length: 60 bytes, then it’ll hold the value 15(because 15 x 4 =
60). Hence, the value of this field is always between 5 and 15.
• Control flags
This field tells the window size of the sending TCP in bytes.
• Checksum
This field holds the checksum for error control. It is mandatory in TCP as
opposed to UDP. (for extra reliability)
• Urgent pointer
This field (valid only if the URG control flag is set) is used to point to data
that is urgently required that needs to reach the receiving process at the
earliest. The value of this field is added to the sequence number to get the
byte number of the last urgent byte.