0% found this document useful (0 votes)
27 views25 pages

TCP Transmission Control Protocol

Uploaded by

Maelef Getu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views25 pages

TCP Transmission Control Protocol

Uploaded by

Maelef Getu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

TCP

Transmission Control Protocol


Transmission Control Protocol (TCP) is a
connection-oriented protocol used for
communication between different devices
over a network. It plays a crucial role in
ensuring reliable data delivery.
When you send data using TCP, it breaks
down the information into smaller segments
(bundles) and reassembles them at the
destination.
These smaller segments allow for efficient
transmission, especially when dealing with
network congestion or multiple routes.
TCP Overview
TCP is a byte-oriented protocol, which
means that the sender writes bytes into a
TCP connection, and the receiver reads
bytes out of the TCP connection. Although
the term “byte stream” describes the service
TCP offers to application processes, TCP
does not transmit individual bytes over the
Internet directly.
TCP Services
■ Connection- ■ Full duplex:two way
oriented:est comunication can
ablish send and receive
connection data at the same
between time
sender and ■ Flow control: keep
receiver sender from
■ Byte-stream overrunning receiver
□ app writes ■ Congestion control:
bytes

keep sender from
TCP sends
segments
overrunning network
□ app reads
bytes
TCP Services
 Ordered Delivery: TCP ensures that segments
arrive at the receiver in the same order they
were sent.
 Error Detection and Correction: TCP
uses checksums to detect errors in transmitted
segments.
 Multiplexing and Demultiplexing: TCP
supports multiple connections (sockets) on the
same host. It uses port numbers to distinguish
between different application processes.
 Application Interface: TCP provides an
interface for applications to send and receive
data.
TCP Header
0 4 10 16 31
SrcPort DstPort
SequenceNum
Acknowledgment
HdrLen 0 Flags AdvertisedWindow
Checksum UrgPtr
Options (variable)

Data

• Flags: It controlls the state of TCP connection


example SYN, FIN, RESET, PUSH, URG, ACK
• Checksum:it detect errors,by using IP pseudo
header + TCP header + data
TCP Overview

■ When a client requests a connection, it


sends a “SYN” segment (a special TCP
segment) to the server port.
■ SYN stands for synchronize. The SYN
message includes the client’s ISN.
■ ISN is Initial Sequence Number.
TCP Overview (Contd.)
■ Every TCP segment includes a Sequence
Number that refers to the first byte of
data included in the segment.
■ Every TCP segment includes
Acknowledgement Number that indicates
the byte number of the next data that is
expected to be received.
□ All
bytes up through this number have already
been received.
TCP Overview (Contd.)

■ MSS: Maximum segment size (A TCP


option)

■ Window: Every ACK includes a Window


field that tells the sender how many
bytes it can send before the receiver
will have to toss it away (due to fixed
buffer size).
Three-Way Handshake
TCP Connection Establishment
Step 1: Client Starts
■ A client starts by sending a SYN segment
with the following information:
□ Client’s
ISN (generated pseudo-randomly)
□ Maximum Receive Window for client.
□ Optionally (but usually) MSS (largest
datagram accepted).
□ No payload! (Only TCP headers)
TCP Connection Establishment
Step 2: Sever Response
■ When a waiting server sees a new
connection request, the server sends
back a SYN segment with:
□ Server’s ISN (generated pseudo-
randomly)
□ Request Number is Client ISN+1
□ Maximum Receive Window for server.
□ Optionally (but usually) MSS
□ No payload! (Only TCP headers)
TCP Connection Establishment
Step 3:
■ When the Server’s SYN is received, the
client sends back an ACK with:
□ Request Number is Server’s ISN+1
TCP Data Transfer

■ Once the connection is established, data


can be sent.
■ Each data segment includes a sequence
number identifying the first byte in the
segment.
■ Each segment (data or empty) includes an
acknowledgement Number indicating
what data has been received.
Buffering

■ Keep in mind that TCP is part of the


Operating System. It takes care of
all these details.
■ The TCP layer doesn’t know when the
application will ask for any received data.
■ TCP buffers incoming data so it’s ready
when we ask for it.
TCP Buffers

■ Both the client and server allocate buffers


to hold incoming and outgoing data
□ The TCP layer does this.
■ Both the client and server announce how
much buffer space remains (the
Window field in a TCP segment).
Send Buffers

■ The application gives the TCP layer some


data to send.
■ The data is put in a send buffer, where it stays
until the data is ACK’d.
□ it has to stay, as it might need to be sent again!
■ The TCP layer won’t accept data from the
application unless (or until) there is buffer
space.
ACKs(Acknolegment)

■ A receiver doesn’t have to ACK every


segment (it can ACK many segments with
a single ACK segment).
■ Each ACK can also contain outgoing data
(piggybacking).
■ If a sender doesn’t get an ACK after some
time limit (MSL) it resends the data.
TCP Segment Order

■ Most TCP implementations will accept out-of-


order segments (if there is room in the
buffer).
■ Once the missing segments arrive, a single
ACK can be sent for the whole thing.
■ Remember: IP delivers TCP segments, and IP
in not reliable - IP datagrams can be lost or
arrive out of order.
TCP Connection Termination

■ The TCP can send a RST segment


that terminates a connection if something
is wrong.
■ Usually the application tells TCP to
terminate the connection politely with a
FIN segment.
FIN(Finish)
■ Either end of the connection can initiate
termination.
■ A FIN is sent, which means the application
is done sending data.
■ The FIN is ACK’d.
■ The other end must now send a FIN.
■ That FIN must be ACK’d.
App1 App2

FIN
SN=X

ACK=X+1

...
FIN
SN=Y

ACK=Y+1
TCP TIME_WAIT
■ Once a TCP connection has been
terminated (the last ACK sent) there is
some unfinished business:
□ What if the ACK is lost? The last FIN will
be resent and it must be ACK’d.
□ What if there are lost or duplicated
segments that finally reach the destination
after a long delay?
■ TCP hangs out for a while (2 * Max.
Segment Life) to handle these
situations.
TCP Applications
Transmission Control Protocol (TCP) is widely
used in various real-world applications.
 Web Browsing (HTTP):
 Email (SMTP, IMAP, POP3):
 Database Communication (MySQL,
PostgreSQL):
 Network Printing (IPP):
 Remote Access (SSH, Telnet):
 Network Services (DNS, NTP):
SUMMARY
 TCP provides a reliable, ordered, and error-
checked byte stream service between
applications running on hosts connected via an
IP network. It complements the Internet
Protocol (IP) and is essential for major internet
applications like the World Wide Web, email,
and file transfer
 TCP is the backbone of many essential internet
services. Its widespread adoption makes it a
fundamental protocol in modern networking.

You might also like