Unite5 Part 2 TCP
Unite5 Part 2 TCP
• In addition, TCP uses flow and error control mechanisms at the transport level.
TCP Services
TCP Features
Segment
A TCP Connection
Flow Control
Error Control
Table 23.2 Well-known ports used by TCP
Figure 23.13 Stream delivery
Circular
Buffer
• Since sending and receiving processes may not write or read at same
time thus TCP employs buffers
• Two buffers – sending buffer and receiving buffer (duplex mode)
• Grey section → sent bytes but not ack, Red section → bytes to be sent,
& white → empty buffer’s byte-space that can be filled by process
Figure 23.15 TCP segments
Solution
The following shows the sequence number for each
segment:
Note
Mandatory
20 Bytes
Part
Optional
40 Bytes
Part
Source Port Address:
This is a 16-bit field that defines the port number of the application program
in the host that is sending the segment
Destination Port Address:
This is a 16-bit field that defines the port number of the application program
in the host that is receiving the segment
Sequence number:
This 32-bit field defines the number assigned to the first byte of data
contained in this segment
Acknowledgment Number:
This 32-bit field defines the byte number that the receiver of the segment is
expecting to receive from the other party
Acknowledgment is piggybacked with the data
HLEN: (Header length since the size of header is variable – 20 to 60 B)
This 4-bit field indicates the number of 4-byte words in the TCP header
The length of the header can be between 20 and 60 bytes
Therefore, the value of this field can be between 20/4 = 5 and 60/4 = 15
Reserved:
This is a 6-bit field reserved for future use
Figure 23.17 Control field
Control Fields
Push Control Bit
• The application program (i.e., process) at the sender can request a push
operation. This means that the sending TCP must not wait for the window to
be filled. It must create a segment and send it immediately.
• The sending TCP must also set the push bit (PSH) to let the receiving TCP
know that the segment includes data that must be delivered to the receiving
application program as soon as possible and not to wait for more data to come.
Control Fields
URG: Urgent pointer value is valid
ACK: Acknowledgment No. value is valid
PSH: Push the buffered data to the receiving
RST: Reset the connection
SYN: Synchronize the sequence number (only first packet)
FIN: No more data from the sender
Window Size:
This field defines the size of the window, in bytes, that the other party must
follow (dynamic buffer management)
Checksum:
This 16-bit checksum field is mandatory for TCP.
Urgent Pointer:
This l6-bit field, which is valid only if the urgent flag is set, is used when the
segment contains urgent data
It defines the number that must be added to the sequence number to obtain
the number of the last urgent byte in the data section of the segment.
Connection Establishment
• TCP transmits data in full-duplex mode
• Each party must initialise communication and get approval from the other
party before any data are transferred
4. TCP will check, is there any process listening on the port specified by
Destination Port address
seq: 8000
UAPRS F
SYN
seq: 15000
ack: 8001
nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
ack: 15001
UAPRS F
rwnd: 10000
ACK
Means “no data” !
IF seq# = 8001 then it means carrying data
Chapter 15, TCP/IP Protocol by Forouzan AMK, CCE, MUJ
Phase 1: Connection Establishment Using Three-way Handshake
seq: 8000
UAPRS F
SYN
seq: 8000
UAPRS F
SYN
seq: 15000
ack: 8001
nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
UAPRS F
SYN
seq: 15000
ack: 8001
nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
ack: 15001
UAPRS F
rwnd: 10000
ACK
seq: 8000
UAPRS F
SYN
seq: 15000
ack: 8001
nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
ack: 15001
UAPRS F
rwnd: 10000
ACK
Means “no data” !
IF seq# = 8001 then it means carrying data
Chapter 15, TCP/IP Protocol by Forouzan AMK, CCE, MUJ
Client -> Server
This is synchronisation of sequence
number
Solution
The value of rwnd = 5000 − 1000 = 4000. Host B can
receive only 4000 bytes of data before overflowing its
buffer. Host B advertises this value in its next segment to
A.
Example 23.5
Solution
The size of the window is the smaller of rwnd and cwnd,
which is 3000 bytes.
Example 23.6
• The window can be opened or closed by the receiver, but should not be shrunk
• The destination can send an ack. at any time as long as it does not result in a
shrinking window
Error Control
• For reliable delivery of message, application layer is
relies on TCP to deliver the entire stream reliably