data com ch4.3 (1)
data com ch4.3 (1)
15 maggio 2025
Outline
Overview of the Transport Layer
protocols
Introduction
Sequencing,
multiplexing,
reliable delivery,
congestion control,
TCP & UDP
2
1
15 maggio 2025 Data com by Eng. Matios Z.
User Datagram protocol (UDP) ...………………………..3
UDP does not perform:
Flow control
Error control
Connection control
UDP is not capable of segmenting and
reassembling frames and does not
implement sequence numbers
All these functions are done by the
processes (application layer programs)
using TCP. But UDP, like TCP, performs:
Service point addressing
UDP can transmit only small portions of
2 data at a time because it is not capable of
2
segmenting and reassembling frames
15 maggio 2025
and
Data com by Eng. Matios Z.
does not implement sequence numbers
User Datagram protocol (UDP) ...………………………..4
Application of UDP
1. UDP is suitable for a process that requires simple
request-response communication with little
concern for flow and error control. It is not usually
used for a process such as FTP that needs to send
bulk data.
2. UDP is suitable for a process with internal flow
and error control mechanisms. For example, the
Trivial File Transfer Protocol (TFTP) process
includes flow and error control. It can easily use
UDP.
3. UDP is a suitable transport protocol for
multicasting. Multicasting capability is embedded
2
in the UDP software but not in the TCP software.
3
4. UDP
15 maggio is used for management processes
2025 Data comsuch as Z.
by Eng. Matios
SNMP and used for some route updating protocols
Transmission Control protocol (TCP) ...……..…………..1
Transmission Control Protocol
TCP is a process-to-process transmission
protocol.
TCP, uses port numbers and unlike UDP, TCP is
a connection-oriented protocol; it creates a
virtual connection between two TCPs to send
data.
In addition, TCP uses flow and error control
mechanisms at the transport level.
In brief, TCP is called a connection-oriented,
reliable transport protocol.
2
It adds connection oriented, and reliability
4
features to the services of IP.
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………..2
TCP Services
1. Process-to-Process
2. Stream Delivery Service
3. Full-Duplex Communication
4. Connection-Oriented Service
5. Reliable Service
Stream delivery service
TCP, unlike UDP, is a stream-oriented
protocol.
In UDP, a process (an application program)
sends messages, with predefined boundaries,
2 to UDP for delivery.
5
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………..3
UDP adds its own header to each of these
messages and delivers them to IP for
transmission.
Each message from the process is called a
user datagram and becomes, eventually, one
IP datagram.
Neither IP nor UDP recognizes any relationship
between the datagrams.
Each application using UDP must send small
data to fit into one user datagram as it is. (UDP
does not segment/reassemble)
TCP, on the other hand, allows the sending
2
6 process to deliver data as a stream of bytes
and
15 maggio 2025allows the receiving process to Data
obtain data
com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………..4
TCP creates an environment in which the two
processes seem to be connected by an
imaginary "tube” that carries their data across
the Internet.
The sending process produces (writes to) the
stream of bytes, and the receiving process
consumes (reads from) them.
2
7
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………..5
Sending and Receiving Buffers
Because the sending and the receiving
processes may not write or read data at the
same speed, TCP needs buffers for storage.
There are two buffers, the sending buffer and
the receiving buffer, one for each direction.
One way to implement a buffer is to use a
circular array of 1-byte locations. For simplicity,
we have shown two buffers of 20 bytes each in
example next slide; normally the buffers are
hundreds or thousands of bytes, depending on
the implementation.
2 We also show the buffers as the same size,
8
which
15 maggio 2025 is not always the case. Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………..6
Sending and receiving buffers
2
9
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………..7
Segment
TCP, Although buffering handles the disparity
between the speed of the processes, we need one
more step before we can send data.
The IP layer, as a service provider for TCP, needs
to send data in packets, not as the transport layer,
TCP groups several bytes together into segment.
TCP adds a header to each segment (for control
purposes) and delivers the segment to the IP layer
for transmission. The segments are encapsulated
in IP datagrams and transmitted.
This entire operation is transparent to the
receiving process. Later we will see that segments
may be received out of order, lost, or corrupted
3 and resent.
0
All these are handled by TCP with the receiving
15 maggio 2025 Data com by Eng. Matios Z.
process unaware of any activities.
Transmission Control protocol (TCP) ...……..…………..8
Full-Duplex communication
TCP offers full-duplex service, in which data can
flow in both directions at the same time.
Each TCP then has a sending and receiving
buffer, and segments move in both directions.
Connection-Oriented Service
TCP, unlike UDP, is a connection-oriented
protocol.
When a process at site A wants to send and
receive data from another process at site B, the
following occurs:
1. The two TCPs establish a connection
3
between them.
1
2. Data are exchanged in bothData com by Eng. Matios Z.
15 maggio 2025
Transmission Control protocol (TCP) ...……..…………..9
Note that this is a virtual connection, not a
physical connection.
The TCP segment is encapsulated in an IP
datagram and can be sent out of order, or
lost, or corrupted, and then resent.
Each may use a different path to reach the
destination. There is no physical
connection.
TCP creates a stream-oriented environment
in which it accepts the responsibility of
delivering the bytes in order to the other
3 site.
2
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………10
TCP Segment Numbering System
Byte Number. TCP numbers all data bytes that
are transmitted in a connection.
Numbering is independent in each direction.
When TCP receives bytes of data from a
process, it stores them in the sending buffer
and numbers them.
The numbering does not necessarily start from
0. Instead, TCP generates a random number
between 0 and 232 - 1 for the number of the
first byte.
For example, if the random number happens
to be 1057 and the total data to be sent are
3
6000 bytes, the bytes are numbered from
3 1057 to 7056.
15 maggio2025 Data com by Eng. Matios Z.
Byte numbering is used for flow and error
Transmission Control protocol (TCP) ...……..…………11
Sequence Number. After the bytes have been
numbered, TCP assigns a sequence number to
each segment that is being sent.
The sequence number for each segment is
the number of the first byte carried in
that segment.
Example: Suppose a TCP connection is
transferring a file of 8000 bytes. The first byte
is numbered 10,001. What are the sequence
numbers for each segment if data are sent in
four segments, each carrying 2000 bytes?
Solution: The following shows the sequence number for
each segment:
3
4 Segment 1 Sequence Number: 10,001 (range: 10,001
15 maggio 2025
to 12,000) Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………12
Acknowledgment Number: communication in
TCP is full duplex; when a connection is
established, both parties can send and receive
data at the same time.
Each party numbers the bytes, usually with a
different starting byte number since it is
randomly selected.
The sequence number in each direction shows
the number of the first byte carried by the
segment.
Each party also uses an acknowledgment
number to confirm the bytes it has received.
3
5
However, the acknowledgment number defines
the
15 maggio 2025number of the next byte that theby Eng.
Data com partyMatios Z.
Transmission Control protocol (TCP) ...……..…………13
In addition, the acknowledgment number is
cumulative, which means that the party takes
the number of the last byte that it has
received, safe and sound, adds 1 to it,
and announces this sum as the
acknowledgment number.
The term cumulative here means that if a party
uses 5643 as an acknowledgment number, it
has received all bytes from the beginning up to
5642.
Note that this does not mean that the
party has received 5642 bytes because the
3
first byte number might not have to start
6 from 0.
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………14
Three-way handshaking in connection
establishment
The connection establishment in TCP is called
three-way handshaking. An application program,
called the client, wants to make a connection with
another application program, called the server,
using TCP as the transport layer protocol.
The process starts with the server. The server
program tells its TCP that it is ready to accept a
connection. This is called a request for a passive
open. Although the server TCP is ready to accept
any connection from any machine in the world, it
cannot make the connection itself.
The client program issues a request for an active
3
7 open. A client that wishes to connect to an open
15 maggio 2025 Data com by Eng. Matios Z.
server tells its TCP that it needs to be connected to
Transmission Control protocol (TCP) ...……..…………15
To show the process, we use two timelines: Each
segment has values for all its header fields and
perhaps for some of its option fields, to. However,
we show only the few fields necessary to
understand each phase.
3
8
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………16
The three steps in this phase are as follows
1. The client sends the first segment, a SYN segment, in
which only the SYN flag is set. This segment is for
synchronization of sequence numbers. It consumes one
sequence number. When the data transfer starts, the
sequence number is incremented by 1. We can say that
the SYN segment carries no real data, but we can think
of it as containing 1 imaginary byte.
2. The server sends the second segment, a SYN +ACK
segment, with 2 flag bits set: SYN and ACK. This
segment has a dual purpose. It is a SYN segment for
communication in the other direction and serves as the
acknowledgment for the SYN segment. It consumes one
sequence number.
3. The client sends the third segment. This is just an ACK
3
9 segment. It acknowledges the receipt of the second
15 maggiosegment
2025 with the ACK flag and acknowledgment
Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………17
Data transfer
After connection is established, bidirectional data
transfer can take place. Both send data and
acknowledgments. Data and acknowledgment
traveling in the same direction are carried on the
same segment.
The acknowledgment is piggybacked with the
data. In the example next slide, after connection is
established (not shown in the figure), the client
sends 2000 bytes of data in two segments. The
server then sends 2000 bytes in one segment. The
client sends one more segment. The first three
segments carry both data and acknowledgment,
but the last segment carries only an
4
0 acknowledgment because there are no more data
to 2025
15 maggio be sent. Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………18
Any of the two parties involved in exchanging data
(client or server) can close the connection, although
it is usually initiated by the client.
4
1
15 maggio 2025 Data com by Eng. Matios Z.
Transmission Control protocol (TCP) ...……..…………19
Three-way handshaking in connection termination
4
3
15 maggio 2025 Data com by Eng. Matios Z.
44 28-Mar-22