0% found this document useful (0 votes)
23 views

4.1 Transport Layer TCP, UDP

Uploaded by

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

4.1 Transport Layer TCP, UDP

Uploaded by

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

Transport Layer

Module 4
Transport Layer Services
• Process-to-Process Communication
Transport Layer Services
• Addressing: Port Numbers
• To define the processes, we need second identifiers,
called port numbers.

• Port Address – 16 bit

• The client program defines itself with a port number,


called the ephemeral port number – short lived

• TCP/IP has decided to use universal port numbers for


servers; called well-known port numbers.
Transport Layer Services
Transport Layer Services
• ICANN (Internet Corporation for Assigned
Names and Numbers) Range

Not controlled by ICANN


only registered here Neither controlled
Assigned and nor registered by
controlled by ICANN
ICANN
Transport Layer Services
• Encapsulation and Decapsulation
Transport Layer Services
• Multiplexing and Demultiplexing

• The transport layer at the source performs


multiplexing; the transport layer at the
destination performs demultiplexing
Transport Layer Services
• Flow Control
• balance between production and consumption
rates.
• Pushing or Pulling
• Pushing - If the sender delivers items whenever
they are produced ⎯ without a prior request from
the consumer
• Pulling - If the producer delivers the items after
the consumer has requested them
Transport Layer Services
• Flow Control at Transport Layer
Transport Layer Services
• Buffers
• use two buffers: one at the sending transport layer and
the other at the receiving transport layer.

• When the buffer of the sending transport layer is full, it


informs the application layer to stop passing chunks of
messages.

• When the buffer of the receiving transport layer is full,


it informs the sending transport layer to stop sending
packets.
Transport Layer Services
• Error Control
• Error control at the transport layer is responsible
for
1. Detecting and discarding corrupted packets.
2. Keeping track of lost and discarded packets and
resending them.
3. Recognizing duplicate packets and discarding
them.
4. Buffering out-of-order packets until the missing
packets arrive.
Transport Layer Services
• Receiving transport layer manages error
control, most of the time, by informing the
sending transport layer about the problems.
Transport Layer Services
• Sequence Numbers
• For error control, the sequence numbers are
modulo 2m, where m is the size of the sequence
number field in bits.

• Acknowledgment
• both positive and negative ack signals as error
control
Transport Layer Services
• Congestion Control
• Congestion control refers to the mechanisms and
techniques that control the congestion and keep
the load below the capacity.

• Congestion at the transport layer is actually the


result of congestion at the network layer, which
manifests itself at the transport layer.
Connectionless service
Connection-Oriented Service
Finite State Machine
• Behavior of a transport-layer protocol, both when
it provides a connectionless and when it provides
a connection-oriented protocol, can be better
shown as a finite state machine (FSM).

• each transport layer (sender or receiver) is taught


as a machine with a finite number of states.
USER DATAGRAM PROTOCOL
• UDP is an unreliable connectionless transport-
layer protocol used for its simplicity and
efficiency in applications where error control
can be provided by the application-layer
process.
Why use UDP?
• UDP is a very simple protocol using a minimum of
overhead.

• If a process wants to send a small message and


does not care much about reliability, it can use UDP.
UDP Services
• Process-to-Process Communication
• UDP provides process-to-process
communication using socket addresses, a
combination of IP addresses and port
numbers.
UDP Services
• Checksum
• What is Pseudo header?
• In Simple words, Pseudo header is one type of
demo header that basically helps in
calculating the CheckSum of TCP/UDP Packets.
From the TCP or UDP point of view, the TCP
packet does not contain IP addresses. Thus, to
do a proper checksum, a "pseudo-header" is
included.
UDP Services
• Connectionless Services
• UDP provides a connectionless service.

• Each user datagram sent by UDP is an independent


datagram.

• There is no relationship between the different user


datagrams even if they are coming from the same
source process and going to the same destination
program.
UDP Services
• Flow Control
• UDP is a very simple protocol. There is no flow control, and hence no
window mechanism.

• Error Control
• There is no error control mechanism in UDP except for the checksum.

• Sender does not know if a message has been lost or duplicated.

• When the receiver detects an error through the checksum, the user
datagram is silently discarded.

• The lack of error control means that the process using UDP should
provide for this service, if needed.
UDP Services
• Congestion Control
• UDP is a connectionless protocol, it does not
provide congestion control.

• Encapsulation and Decapsulation


UDP Services
• Multiplexing and Demultiplexing
UDP Applications
• Trivial File Transfer Protocol (TFTP) process
includes flow and error control. It can easily use
UDP.
• UDP is a suitable transport protocol for
multicasting.
• UDP is used for management processes such as
SNMP
• UDP is used for some route updating protocols
such as Routing Information Protocol (RIP)
• UDP is normally used for interactive real-time
applications that cannot tolerate uneven delay
between sections of a received message.
TRANSMISSION CONTROL PROTOCOL
• Transmission Control Protocol (TCP) is a connection-
oriented, reliable protocol.

• TCP explicitly defines connection establishment, data


transfer, and connection termination phases to provide a
connection-oriented service.

• TCP uses a combination of GBN and SR protocols to


provide reliability.

• TCP uses checksum (for error detection), retransmission of


lost or corrupted packets, cumulative and selective
acknowledgments, and timers.
TCP Services
• Process-to-Process Communication
TCP provides process-to-process communication
using port numbers.

• Stream Delivery Service


The sending process produces (writes to) the
stream and the receiving process consumes
(reads from) it.
TCP Services

Imaginary tube to carry


date from S to R
TCP Services
• Sending and Receiving Buffers
TCP Services
• Segments
• Buffering - disparity between the speed of the
producing and consuming processes.

• The network layer, as a service provider for TCP, needs


to send data in packets, not as a stream of bytes.

• TCP groups a number of bytes together into a packet


called a segment.

• Header added to every segment


TCP Services
• Full-Duplex Communication
• TCP offers full-duplex services

• Multiplexing and Demultiplexing


• Like UDP, TCP performs multiplexing at the
sender and demultiplexing at the receiver.
TCP Services
• Connection-Oriented Service
• TCP is connection oriented
1. The two TCP’s establish a logical connection
between them.
2. Data are exchanged in both directions.
3. The connection is terminated.
• logical connection, not a physical connection.
TCP Services
• Reliable Service
• TCP is a reliable transport protocol.
• It uses an acknowledgment mechanism to
check the safe and sound arrival of data.
TCP Features
• Numbering System
• sequence number and the acknowledgment
number.
• These two fields refer to a byte number and not a
segment number.

• Byte Number
• TCP numbers all data bytes (octets) that are
transmitted in a connection.
• Numbering is arbitrary
TCP Features
• Sequence Number
1. The sequence number of the first segment is
the ISN (initial sequence number),
• which is a random number.

2. The sequence number of any other segment


is the sequence number of the previous
segment plus the number of bytes (real or
imaginary) carried by the previous segment.
TCP Features
• Acknowledgment Number
• The value of the acknowledgment field in a
segment defines the number of the next byte
a party expects to receive. The
acknowledgment number is cumulative.
TCP Features
• Segment
TCP Features
• Encapsulation
• A TCP segment encapsulates the data received
from the application layer. The TCP segment is
encapsulated in an IP datagram, which in turn
is encapsulated in a frame at the data-link
layer.
A TCP Connection
• Connection Establishment

• Data Transfer

• Connection Termination
Connection Establishment
• TCP transmits data in full duplex mode.
• Three-Way Handshake
– Server program tells its TCP that it is ready to
accept a connection. This request is called a
passive open.
– The client program issues a request for an active
open.
Connection Establishment
Connection Establishment
• The client sends the first segment, a SYN
segment
– Only the SYN flag is set.
– This segment is for synchronization of sequence
numbers
– segment does not contain an acknowledgment
number
– Does not define window size.
– SYN segment cannot carry data, but it consumes
one sequence number ( for one imaginary byte).
Connection Establishment
• Server sends the second segment, a SYN + ACK.
• This segment has a dual purpose:
– SYN segment for communication in the other
direction(initialize a sequence number for numbering
the bytes sent from the server to the client).
– The server also acknowledges the receipt of the SYN
segment from the client by setting ACK flag.
• Because segment contains an ACK, it also need to
define window size, rwnd(to be used by client).
• A SYN + ACK segment cannot carry data, but it
does consume one sequence number.
Connection Establishment

• The client sends the third segment – an ACK


segment.
• An ACK segment, if carrying no data,
consumes no sequence number.
Data Transfer
Data Transfer
• After connection establishment, bidirectional data transfer
can take place.
• acknowledgment can be piggybacked with the
data.
• Pushing Data:
– Delayed transmission and delayed delivery of data
may not be acceptable by the application
program.
– application program at the sender can request a
push operation
– TCP can choose whether or not to use this feature.
Data Transfer
• After connection establishment, bidirectional data transfer can take
place
• Urgent Data :
– Each byte of data has a position in the stream.
However, there are occasions in which an application
program needs to send urgent bytes
– send a segment with the URG bit set.
– Sending TCP send a segment with the URG bit set.
– Sending TCP creates a segment and inserts the urgent
data at the beginning of the segment, rest segment
can carry normal data.
– The urgent pointer field in the header defines the end
of the urgent data (the last byte of urgent data).
Urgent Flag/Pointer
• For example, if
• the segment sequence number is 15000 and
the value of the urgent pointer is 200, the first
byte of urgent data is the byte 15000 and the
last byte is the byte 15200. The rest of the
bytes in the segment (if present) are non-
urgent.
Connection Termination
• Either of client or server can close the
connection, usually initiated by the client.
• Most implementation allow two options:
– Three way handshaking
– Four way handshaking with Half-close option.
Connection Termination
Connection Termination
I. Three Way Handshake :
• Client TCP sends a FIN segment in which FIN
flag is set.
• FIN segment can include the last chunk of data
sent by the client or it can be just a control
segment.
• The FIN segment consumes one sequence
number if it does not carry data.
Connection Termination
II. Three Way Handshake :
• Server TCP, after receiving FIN segment sends
a FIN+ACK segment to confirm receipt of FIN
segment and also to announce closing of
connection in other direction.
• This segment can also carry last chunk of data
from server.
• If it does not carry data, it consumes only one
sequence number because it needs to be
acknowledged.
Connection Termination
III. Three Way Handshake :
• Client TCP sends the last segment, an ACK
segment, to confirm the receipt of the FIN
segment from the TCP server.
• This segment cannot carry data and consumes
no sequence numbers
Half Close
Half Close
• one end can stop sending data while still
receiving data.
Connection Reset
• TCP at one end,
– may deny a connection request
– may abort an existing connection
– may terminate an idle connection
• All above is done using RST flag.
State Transition Diagram
Half Close Scenario
Windows in TCP
Send Window
• Send window size is dictated by the receiver
(flow control) and the congestion in the
underlying network (congestion control).
• The figure shows how a send window opens,
closes, or shrinks.
Difference between TCP and SR send
window
• window size in SR is the number of packets,
but the window size in TCP is the number of
bytes.
• TCP can store data received from the process
and send them later, but sending TCP is
capable of sending segments of data as soon
as it receives them from its process.
• number of timers
Receive Window
Difference between TCP and SR
Receive window
• TCP allows the receiving process to pull data
at its own pace.
• The receive window size determines the
number of bytes that the receive window can
accept from the sender before being
overwhelmed (flow control)
rwnd = buffer size - number of waiting bytes to be pulled
• Acknowledgments : New version of uses both
cumulative and selective acknowledgments
Flow Control
Flow Control
• To achieve flow control, TCP forces the sender
and the receiver to adjust their window sizes,
• The size of the buffer for both parties is fixed
when the connection is established.
• The opening, closing, and shrinking of the send
window is controlled by the receiver.
• The send window closes (moves its left wall to
the right) when a new acknowledgment allows it
to do so.
• The send window opens (its right wall moves to
the right) when the receive window size (rwnd)
advertised by the receiver allows it to do so.
• The receive window closes (moves its left wall
to the right) when more bytes arrive from the
sender;
• It opens (moves its right wall to the right)
when more bytes are pulled by the process.
Shrinking of Windows
• Receive window cannot shrink.
• Send window, can shrink if the receiver defines a
value for rwnd that results in shrinking the window
• Some implementation doesn’t allow shrinking of
sender window
• the receiver needs to keep the following relationship
between the last and new acknowledgment and the
last and new rwnd values to prevent shrinking of the
send window.
new ackNo + new rwnd ≥ last ackNo + last rwnd
(210) + (4) < (206) + (12)
Shrinking of WIndows
Error Control

TCP
Error Control
• TCP is a reliable transport layer protocol.
• Application program that delivers a stream of data
to TCP relies on TCP to deliver the entire stream to
the application program on the other end in order,
without error.
• TCP provides reliability using error control.
• Error control includes mechanism for:
– detecting and resending corrupted segments,
– resending lost segments,
– storing out of order segments until missing segments
arrive, and
– detecting and discarding duplicated segments.
Error Control
• Error control in TCP is achieved through the
use of three simple tools:
– checksum, acknowledgment, and time-out.
Acknowledgment
• Control segments that carry no data, but
consume a sequence number, are also
acknowledged.
• ACK segments are never acknowledged.

Acknowledgment Type
̶ Cumulative Acknowledgment (ACK)
̶ Selective Acknowledgment (SACK)

You might also like