25 Transmission Control Protocol 12-03-2025
25 Transmission Control Protocol 12-03-2025
05 32 00 17 00 00 00 01 00 00 00 00 50 02 07 FF 00 00 00 00
Figure 24-16
Write 45 bytes
Application Write 15 bytes Read 40 bytes
Write 20 bytes Read 40 bytes
Transport segments
Error Detection
buffer ACKS, sequence # buffer
&
Retransmission
Flow Control
Buffer limitations & speed mismatch can
result in loss of data that arrives at
destination
Receiver controls rate at which sender
transmits to prevent buffer overflow
Application
Transport segments
RTT buffer
ACKS buffer
Estimation
TCP Connection Establishment
Host A • “Three-way Handshake” Host B
Ack_no=Seq_no=X+1
ISN –Initial sequence Number
MSS- Maximum segment size
ACK-acknowledgement
PSH- Push-Data
RST-Reset
SYN-Syn
FIN-Finished
Connection establishment using three-way handshaking
23.16
Note
A SYN segment cannot carry data, but it consumes one sequence
number.
23.17
Note
A SYN + ACK segment cannot
carry data, but does consume one
sequence number.
23.18
Note
An ACK segment, if carrying no data, consumes no sequence
number.
23.19
Near End: Connection Request
Far End: Ack and Request
Near End: Ack
Case study
Client sends 2000 bytes of data in two
segments. The server sends 2000 bytes in
one segment.
First three segments carry both data and ack.
Last segments carries only ack.—there are no
more data to send.
Data transfer with error
Connection termination using three-way handshaking
23.26
Note
The FIN segment consumes one sequence number if it does
not carry data.
Note
The FIN + ACK segment consumes
one sequence number if it
does not carry data.
23.28
Data transfer- TCP
To provide reliable delivery service to applications,TCP
uses the selective repeat ARQ with positive Ack
implemented by a sliding window mechanism.
Suppose that at time t0 ,host B advertised window size of 2048 bytes
and next byte seq.numb is 2000. TCP entity advertise window of size
1024 bytes to host B and next byte is expected seq.num is 1
Host A transmit up to 2048 bytes.
At time t1 host A has only 1024 bytes to transmit with seq.num 2000.
At time t2 A has another 1024 bytes of data and A’s sending window
closes completely.- not allowed to transmit more data until ack
comes.
At time t3 host B has 128 bytes of data to transmit; host B can simply
piggy packing the ack.to 4048. also host B finds out it can allocate of
512 bytes.—shrink the window from 2048 to 512.
At time t4 host A has 1024 bytes to data to transmit but it can transmit
only 512.
TCP Window Flow Control
Host A Host B
t0
1024 bytes
to transmit
t1
1024 bytes
to transmit
t2
128 bytes
to transmit
t3
1024 bytes
to transmit
t4 can only
send 512
bytes
TCP connection termination
TCP entity in host A terminates its transmission first by
issuing FIN .seq—5086.
Host B send ack 5087 to acknowledge the receipt of FIN.
After B receives FIN segment ,direction of flow B to A is
still open.
Host B sends 150 bytes in one segment.
Host A sends an ack.
Host B sends FIN segment.
Host A send ack 454 to acknowledge the receipt of FIN
TCP Connection Closing
“Graceful Close”
Host A Host B
Sequence number
Acknowledgment number
U A P R S F
Header
Reserved R C S S Y I Window size
length G K H T N N
Options Padding
Data
• Each TCP segment has header of 20 or more bytes + 0 or more bytes of data
Figure 24-15
40
Examples of Networking Services
Service Port No.
HTTP 80
FTP 21
SMTP 25
TELNET 23
TFTP 69
Note:
UDP length =
IP length − IP header’s length
42
Pseudoheader for checksum calculation
43
Checksum calculation of a simple UDP user datagram
44
UDP Checksum Calculation
0 8 16 31