0% found this document useful (0 votes)
2 views61 pages

Module 5_transport Layer Ppt FINAL (3)

This document provides an overview of the Transport Layer, focusing on the Transmission Control Protocol (TCP) and its characteristics, including reliability, connection orientation, and flow control. It details the TCP segment structure, connection establishment and termination processes, and error and congestion control mechanisms. Additionally, it contrasts TCP with the User Datagram Protocol (UDP), highlighting their respective applications and functionalities.

Uploaded by

giapillai04
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)
2 views61 pages

Module 5_transport Layer Ppt FINAL (3)

This document provides an overview of the Transport Layer, focusing on the Transmission Control Protocol (TCP) and its characteristics, including reliability, connection orientation, and flow control. It details the TCP segment structure, connection establishment and termination processes, and error and congestion control mechanisms. Additionally, it contrasts TCP with the User Datagram Protocol (UDP), highlighting their respective applications and functionalities.

Uploaded by

giapillai04
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/ 61

Module 5

Transport Layer:
The Transport layer Services, The Internet Transport Protocol: TCP
and UDP. TCP:-Introduction to TCP, The TCP Protocol, The TCP
Segment Header, TCP Connection Establishment, TCP Connection
Release, Modelling TCP Connection Management, TCP Transmission
Policy, TCP Congestion Control, TCP Timer Management.
TCP/IP and OSI model

Internet Layer

Host to Network Layer/Network interface

2
Transmission Control Protocol
TCP is short for Transmission Control Protocol.

It is a transport layer protocol.

It has been designed to send data packets over the Internet.

It establishes a reliable end to end connection before sending any data.


To define Process, Port numbers are used. In TCP/IP protocol suite,
port numbers are integers between 0 and 65,535.
The client program/process defines itself with a port number, called
ephemeral port number 49,152 to 65,535.
The server program/process defines itself with a port number which
can not be chosen randomly. TCP/IP use universal port numbers for
servers, these are called as well-known port numbers.
Characteristics Of TCP
1) TCP is a reliable protocol.

This is because-

• It guarantees the delivery of data packets to its correct


destination.

• After receiving the data packet, receiver sends an


acknowledgement to the sender.

• It tells the sender whether data packet has reached its destination
safely or not.
• TCP employs retransmission to compensate for packet loss.
2) TCP is a connection oriented protocol.

•TCP establishes an end to end connection between the source and


destination.

•The connection is established before exchanging the data.


•The connection is maintained until the application programs at each
end finishes exchanging the data.
3) TCP handles both congestion and flow control.

•TCP handles congestion and flow control by controlling the


window size.

•TCP reacts to congestion by reducing the sender window size.

TCP ensures in-order delivery.

•TCP ensures that the data packets get deliver to the destination in
the same order they are sent by the sender.

•Sequence Numbers are used to coordinate which data has been


transmitted and received.
4) TCP works in collaboration with Internet Protocol.

A TCP connection is uniquely identified by using-


Combination of port numbers and IP Addresses of sender and
receiver.

IP Addresses indicate which systems are communicating.

Port numbers indicate which end to end sockets are communicating.

A transport-layer protocol in the TCP suite needs both the IP address


and the port number, at each end, to make a connection. The
combination of an IP address and a port number is called a socket
address.

TCP segments are encapsulated into an IP datagram.


5) TCP can use both selective & cumulative acknowledgements.

• TCP uses a combination of Selective Repeat and Go back N


protocols.

• In TCP, sender window size = receiver window size.

• In TCP, out of order packets are accepted by the receiver. When


receiver receives an out of order packet, it accepts that packet but
sends an acknowledgement for the expected packet.

• Receiver may choose to send independent acknowledgements or


cumulative acknowledgement.

• To sum up, TCP is a combination of 75% SR protocol and 25% Go


back N protocol.
Basic services provided by
Transport layer
Process to process communication
Encapsulation and Decapsulation
 Flow control
Congestion Control
Error Control
Connectionless and Connection-Oriented
Services
Connection-oriented and Connectionless
service
Connectionless Service:
• In a connectionless service, the packets are sent from one party
to another with no need for connection establishment or
connection release.
• The packets are not numbered; they may be delayed or lost or
may arrive out of sequence.
• There is no acknowledgment either.
• UDP, is connectionless.
Connection Oriented Service:
• In a connection-oriented service, a connection is first established
between the sender and the receiver.
• Data are transferred.
• At the end, the connection is released.
TCP SEGMENT & HEADER FORMAT
 Source port number : 16 bit number

Destination port number : 16 bit number

Sequence number:
o 32 bit field
oSince TCP is connection oriented protocol, to ensure
connectivity , each byte to be transmitted is numbered.

 Acknowledgement number:
o 32-bit field
odefines the number that the receiver is expecting to receive from
source
oIf the receiver of the segment has successfully received segment
number x from the other source, it returns x + 1 as the
acknowledgment number.
• Numbering System
• TCP software keeps track of the segments being transmitted or
received , but there is no field for a segment number value in
the TCP header.
• Instead, there are two fields called the sequence number and
the acknowledgment number. These two fields refer to a byte
number and not a segment number.
• Byte Number
• The bytes of data being transferred in each connection are
numbered by TCP.
• The numbering starts with an arbitrarily generated number.
• 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 of data carried in that segment.
• Acknowledgment Number
• The value of the acknowledgment field in a segment defines
the number of the next byte a receiver expects to receive.
• The acknowledgment number is cumulative.
Header length
o 4 bit field
o value in this field is always between 5(5*4=20) and 15(15*4=60)

Reserved
o6 bit field
oFor future use

 Control
oThis field defines 6 different control bits or flags
oOne or more of these bits can be set at a time
oThese bits enable flow control, connection establishment and
termination, connection abortion, and the mode of data transfer in
TCP.
URG
oThe URG flag is used to inform a receiving station that certain data
within a segment is urgent and should be prioritized.
oIf the URG flag is set, the receiving station evaluates the urgent
pointer, a 16-bit field in the TCP header. This pointer indicates how
much of the data in the segment, counting from the first byte, is
urgent
oThe sending TCP creates a segment and inserts the urgent data at
the beginning of the segment. The rest of the segment can contain
normal data from the buffer. The urgent pointer field in the header
defines the end of the urgent data (the last byte of urgent data).
Details of Control field : Flags
oACK
oTo indicate that value carried in acknowledgement field is valid

 RST,SYN,FIN
oUsed for connection set up and tear down.

PSH
oUsed for flow control.

 Window size
o This field defines the window size of the sending TCP in bytes
 Checksum
o 16 bit field- to detect error

 Urgent pointer
o16 bit field
o valid only if the urgent flag is set.
o It is used when the segment contains urgent data.
odefines the end of the urgent data

 Options
o 40 bytes of optional info in TCP header.
User datagram format
USER User
DATAGRAM PROTOCOL
datagram Protocol
 Source port ,Destination port:16 bit
 For a client:ephemeral port (> than 1023)
 For a source : well known port (0-1023)

 Length. 16-bit field that defines the total length of the


user datagram, header plus data. The 16 bits can define
a total length of 0 to 65,535 bytes.

 Checksum. This field is used to detect errors over the


entire user datagram (header plus data).

20
Example
Given a DUMP of a UDP header in hexadecimal
format 04 21 00 0B 00 2A E2 17. Find the following:-

• Source port number?


• Destination port number?
• Length of user datagram?
• Length of the data?
solution
• The source port number is the first four hexadecimal digits
i.e. 04 21 if we convert hexadecimal to decimal we get 1057

• The destination port number is the second four hexadecimal


digits 00 0B if we convert hexadecimal to decimal we get 11

• The third four hexadecimal digits 00 2A if we convert


hexadecimal to decimal. The length of the whole UDP packet
is 42 bytes

• The length of the data is the length of the whole packet — the
length of the header i.e. 42 – 8 = 34 bytes
Example
• The following is a dump of a TCP header in hexadecimal
format.

• a. What is the source port number?


• b. What is the destination port number?
• c. What the sequence number?
• d. What is the acknowledgment number?
• e. What is the length of the header?
• f. What is the type of the segment?
• g. What is the window size?
Solution
1) Source port number:- (2 byte) -> 0532 = (1330)10
2) Destination port number:- (2 byte) -> 0017 = (23)10
3) Sequence number:- 000000001 -> 1
4) Acknowledgement number:- 00000000 -> 0
5) Length of the header (4 bits) -> 5
6) Type of the segment -> 0X02
7) Window size -> 07FF = (2047)10
0532 0017
0000 0001
0000 0000
5002 07FF
0000 0000
UDP Applications

• UDP is suitable for a process that requires simple request-response


communication with little concern for flow and error control.
• UDP is suitable for a process with internal flow and error-control
mechanisms. For example, the Trivial File Transfer Protocol
(TFTP)
• UDP is a suitable transport protocol for multicasting. Multicasting
capability is embedded in the UDP but not in the TCP.
• UDP is used for management processes such as SNMP.
• UDP is used for some route updating protocols such as RIP.
• UDP is normally used for real-time applications that cannot
tolerate uneven delay between sections of a received message.
A TCP connection
TCP is connection-oriented transport layer protocol
• protocol that establishes a virtual path between the source and
destination.
• In TCP, connection-oriented transmission requires three
phases:
• connection establishment, data transfer, and connection
termination.
Connection establishment using
three-way handshaking

Ready to accept
the connection

• A SYN segment cannot carry data, but it consumes one sequence


• A SYN + ACK segment cannot carry data, but does consume one sequence
number.
• An ACK segment, if carrying no data, consumes no sequence number.
Data Transfer
Connection termination using
three-way handshaking

The FIN segment consumes one sequence number if it does not carry data.
The FIN + ACK segment consumes one sequence number if it does not carry
data.
An ACK segment, if carrying no data, consumes no sequence number
Half-Close
• In TCP, one end can stop sending data while still receiving
data.
• Either the server or the client can issue a half-close request.
• The client half-closes the connection by sending a FIN
segment.
• The FIN + ACK segment consumes one sequence number if it
does not carry data.
TCP state machine
Windows in TCP
• TCP uses two windows (send window and receive window)
for each direction of data transfer, which means four windows
for a bidirectional communication.

Opening and Closing Windows


• To achieve flow control, TCP forces the sender and the
receiver to adjust their window sizes.
Sender side window
• 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 acknowledgement 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 send window shrinks on occasion. We assume that this
situation does not occur.
The opening, closing, and shrinking of the send
window
Receiver Window

Receiver side window

• The receive window closes (moves its left wall to the right) when
it sends acknowledgement.
• It opens (moves its right wall to the right) when more
bytes are pulled by the process.
• We assume that it does not shrink (the right wall does
not move to the left).
Receiver Window
An example of flow control
Shrinking of Windows
• The receive window cannot shrink.
• But the send window can shrink if the receiver defines a
value for rwnd that results in shrinking the window.
• The receiver needs to keep the following relationship
between the last and new acknowledgment and the last and
new rwnd values to prevent the shrinking of the send window
Shrinking of Windows example
Sender has sent bytes from 206 to 214

210

40
Window Shutdown
• Shrinking the send window by moving its right wall to the left
is strongly discouraged.
• However, there is one exception: the receiver can temporarily
shut down the window by sending a rwnd of 0.
• In this case, the sender does not actually shrink the size of the
window, but stops sending data until a new advertisement has
arrived.
• Even when the window is shut down by an order from the
receiver, the sender can always send a segment with 1 byte of
data.
• This is called probing and is used to prevent a deadlock.
Error control

• Error control in TCP is achieved through the use of three


simple tools: Checksum, acknowledgment, and time-out.
• Checksum
• Each segment includes a checksum field, which is used to
check for a corrupted packet.
• Acknowledgment
• TCP uses acknowledgments to confirm the receipt of data
segments.
• Control segments that carry no data, but consume a sequence
number, are also acknowledged.
• ACK segments are never acknowledged.
o Acknowledgment Type
– Cumulative Acknowledgment (ACK)
– Selective Acknowledgment (SACK)
– SACK does not replace ACK, but reports additional information
to the sender.
– A SACK reports a block of data that is out of order, and also a
block of segments that is duplicated, i.e. received more than
once.
• Retransmission
• A segment is stored in sender’s queue until it is acknowledged.
• When the retransmission timer expires or when the sender receives
three duplicate ACKs for the first segment in the queue, that
segment is retransmitted.
– Retransmission after Three Duplicate ACK Segments
– If three duplicate arrives for a segment, the next segment is
retransmitted without waiting for the time-out.
– This feature is called fast retransmission
Error control(normal operation)
Error control(lost segment)
The receiver TCP delivers only ordered data to the process.
Error control(Fast retransmission)
Congestion control
• Sender window size is controlled by
– Reciever
• Network is a second entity that determines the size of the
sender’s window.
– Actual window size = minimum (rwnd, cwnd)
• Congestion Policy
• TCP’s general policy for handling congestion is based on three
phases:
• slow start, congestion avoidance, and congestion detection.
Congestion policy

The sender starts with a slow rate of transmission, but increases the
rate rapidly to reach a threshold.

When the threshold is reached, the rate of increase is reduced.

Finally if ever congestion is detected, the sender goes back to the


slow start or congestion avoidance phase, based on how the
congestion is detected.
Slow start, exponential increase

In the slow start algorithm, the size of the congestion


window increases exponentially until it reaches a threshold.
Congestion Avoidance: Additive Increase
 To avoid congestion before it happens, One must slow down
this exponential growth of slow start phase.

TCP defines another algorithm called Congestion Avoidance


Which increases cwnd additively.

In this algorithm, each time the whole “window” of segments


is acknowledged, the size of the congestion window is
increased by one. A window is the number of segments
transmitted during RTT

Start → cwnd = i
After 1 RTT → cwnd = i + 1
After 2 RTT → cwnd = i + 2
After 3 RTT → cwnd = i + 3
Congestion detection
•If congestion occurs, the congestion window size must be decreased.
•The only way a sender can guess that congestion has occurred is the
need to retransmit a segment
•However, retransmission can occur in one of two cases: when the
RTO timer times out or when three ACKs are received.
a. If a time-out occurs, there is a stronger possibility of
congestion.
b. If three ACKs are received, there is a weaker possibility of
congestion.
TCP Timers
• Retransmission Timer
• To retransmit lost segments, TCP employs one retransmission timer
that handles the retransmission time-out (RTO), the waiting time for
an acknowledgment of a segment.
• Round-Trip Time (RTT)
• To calculate the retransmission time-out (RTO), we first need to
calculate the roundtrip time (RTT).
– Measured RTT (RTTM): how long it takes to send a segment and receive an
acknowledgment for it. This is the measured RTT.
– Smoothed RTT(RTTs) RTTM, is likely to change for each round trip.The
fluctuation is so high in today’s Internet that a single measurement alone
cannot be used for retransmission time-out calculation purposes.
– RTT Deviation(RTTD) Most implementations do not just use RTTS; they also
calculate the RTT deviation, called RTTD, based on the RTTS and RTTM.
Smoothed RTT Calculation

RTT Deviation Calculation

Retransmission Time-out (RTO) Calculation


RTO calculation Example
• Persistence Timer

• Based on the fact that ack segments are never acknowledged


• Used to prevent deadlocks
• When the sending TCP receives an acknowledgment with a window
size of zero, it starts a persistence timer
• When the persistence timer goes off, the sending TCP sends a special
segment called a probe
• The probe causes the receiving TCP to resend the acknowledgment.
• The sender continues sending the probe segments and doubling and
resetting the value of the persistence timer until the value reaches a
threshold (usually 60 s).
• Keepalive Timer

• To prevent a long idle connection between two TCPs


• Client opens a TCP connection to a server, transfers some data,
and becomes silent , the connection remains open forever.
• Most implementations equip a server with a keepalive timer.
• Each time the server hears from a client, it resets this timer.
• The time-out is usually 2 hours. After timeout, it sends a probe
• segment.
• If there is no response after 10 probes, each of which is 75 s
apart, it assumes that the client is down and terminates the
connection.
• TIME-WAIT Timer

• The TIME-WAIT (2MSL) timer is used during connection


termination.

You might also like