You are on page 1of 26

Transport Layer

PAWA N K U M A R
A S S I STA NT P R O F ES SOR
G J U S &T, H I S A R
Contents
 Introduction to Transport Layer
 Services of Transport Layer
 Design Issues at Transport Layer
 Transport Layer Protocols
 TCP
 UDP
 TCP Segment
 TCP Connection Management

6/8/2020 NETWORK LAYER 2


Introduction to Transport Layer
 Transport layer is the 4th layer from the top according to OSI model and 2nd
according to TCP/IP model.
 Main role of the transport layer is to provide the communication services directly to
the application processes running on different hosts.
 Transport layer provides a logical communication between application processes
running on different hosts. Although the application processes on different hosts are
not physically connected, application processes use the logical communication
provided by the transport layer to send the messages to each other.
 Transport layer protocols are implemented in the end systems but not in the network
routers.

6/8/2020 NETWORK LAYER 3


Services of Transport Layer
Service Point Addressing: Transport Layer header includes service point address
which is port address.
This layer gets the message to the correct process on the computer unlike Network
Layer, which gets each packet to the correct computer.
Segmentation and Reassembling: A message is divided into segments; each
segment contains sequence number, which enables this layer in reassembling the
message.
Message is reassembled correctly upon arrival at the destination and replaces
packets which were lost in transmission.
Flow Control: Transport layer provides end to end flow control.

6/8/2020 NETWORK LAYER 4


Services of Transport Layer
 Connection Control: It provides 2 types of connection:
 Connectionless Transport Layer: Each segment is considered as an independent packet
called as datagram and delivered to the transport layer at the destination machine.
 Connection Oriented Transport Layer: Before delivering packets called as segment,
connection is made with transport layer at the destination machine.
 Error Control: Error Control is performed end to end in this layer to ensure that
the complete message arrives at the receiving transport layer without any error.
Error Correction is done through retransmission.

6/8/2020 NETWORK LAYER 5


Design Issues with Transport Layer
 Accepting data from Session layer, split it into segments/ datagram and send to the
network layer.
 Ensure correct delivery of data with efficiency.
 Isolate upper layers from the technological changes.
 Error control and flow control.

6/8/2020 NETWORK LAYER 6


Transport Layer Protocols
 Transport layer have two protocols :
 TCP
 UDP
 Transmission Control Protocol (TCP): is a connection-oriented reliable protocol.
 It provides a reliable transport service between pairs of processes executing on End
Systems (ES) using the network layer service provided by the IP protocol.
 Network layer uses IP or Internet Protocol which being a connection less protocol
treats every packet individually and separately leading to lack of reliability during a
transmission.
 For example, when data is sent from one host to another, each packet may take a
different path even if it belongs to the same session. This means the packets may or
may not arrive in the right order. Therefore, IP relies on the higher layer protocols
(TCP/ UDP) to provide reliability.

6/8/2020 NETWORK LAYER 7


Transmission Control Protocol (TCP)
 TCP provides acknowledgement of the received packets and is also reliable as it
resends the lost packets.
 It is used by application protocols like HTTP and FTP.
 Features of TCP:
 TCP ensures that the data reaches intended destination in the same order it was sent.
 TCP is connection oriented. TCP requires that connection between two remote points be
established before sending actual data.
 TCP provides error-checking and recovery mechanism.
 TCP provides end-to-end communication.
 TCP provides flow control and quality of service.
 TCP operates in Client/Server point-to-point mode.
 TCP provides full duplex server, i.e. it can perform roles of both receiver and sender.
6/8/2020 NETWORK LAYER 8
TCP Header
 A TCP segment consist
of TCP header and data.
 Length of TCP header
is minimum 20 bytes
long and maximum 60
bytes.
 Top five lines in TCP
header are compulsory
which consists of many
fields each of them
having different roles as
shown in figure:

6/8/2020 NETWORK LAYER 9


TCP Header
 Source port address: It is used to define the address of the application program in a
source computer. It is a 16-bit field.
 Destination port address: It is used to define the address of the application
program in a destination computer. It is a 16-bit field.
 Sequence number: A stream of data is divided into two or more TCP segments.
The 32-bit sequence number field represents the position of the data in an original
data stream.
 Acknowledgement number: A 32-field acknowledgement number acknowledge
the data from other communicating devices. If ACK field is set to 1, then it specifies
the sequence number that the receiver is expecting to receive.
 Reserved: It is a 6-bit field which is reserved for future use and by default set to 0.

6/8/2020 NETWORK LAYER 10


TCP Header
 Header Length (HLEN): It specifies the size of the TCP header in 32-bit words. The
minimum size of the header is 5 words, and the maximum size of the header is 15 words.
Therefore, the maximum size of the TCP header is 60 bytes, and the minimum size of the
TCP header is 20 bytes.
 The initial 5 rows of the TCP header are always used.
 So, minimum length of TCP header = 5 x 4 bytes = 20 bytes.
 The size of the 6th row representing the Options field vary.
 The size of Options field can go up to 40 bytes.
 So, maximum length of TCP header = 20 bytes + 40 bytes = 60 bytes.
 For calculating header length we use concept of scaling factor. Because header length is 4-bit field
which can represent the range 0 to15 (0000 - 1111 in binary).
 To represent header [20, 60], scaling factor  Header length = Header length field value x 4 bytes.
 For e.g., header length field contains decimal value 5 (represented as 0101), then-
Header length = 5 x 4 = 20 bytes

6/8/2020 NETWORK LAYER 11


TCP Header
 Flags: There are total 6 flags each of 1-bit-
 URG: The URG field contain value 1 indicates that the data in a segment is urgent.
 ACK: When ACK field is set to 1, then it validates the acknowledgement number.
 PSH: The PSH field is used to inform the sender that higher throughput is needed so if
possible, data must be pushed with higher throughput.
 RST: The reset bit (RST1) is used to reset the TCP connection when there is any confusion
occurs in the sequence numbers.
 SYN: The SYN field is used to synchronize the sequence numbers in three types of
segments: connection request, connection confirmation ( with the ACK bit set ), and
confirmation acknowledgement.
 FIN: The FIN field is used to inform the receiving TCP module that the sender has finished
sending data. It is used in connection termination in three types of segments: termination
request, termination confirmation, and acknowledgement of termination confirmation.

6/8/2020 NETWORK LAYER 12


TCP Header
 Window size: It is a 16 bit field contains the size of the receiving window of the sender.
 It advertises how much data (in bytes) the sender can receive without
acknowledgement.
 Thus, window size is used for Flow Control.
 window size changes dynamically during data transmission.
 It usually increases during TCP transmission up to a point where congestion is detected.
 After congestion is detected, the window size is reduced to avoid having to drop
packets.

6/8/2020 NETWORK LAYER 13


TCP Header
 Checksum: It is a 16 bit field used for error control.
 It verifies the integrity of data in the TCP payload.
 Sender adds CRC checksum to the checksum field before sending the data.
 Receiver rejects the data that fails the CRC check.
 Urgent pointer: It is a 16 bit field.
 It indicates how much data in the current segment counting from the first data byte
is urgent.
 Urgent pointer added to the sequence number indicates the end of urgent data byte.
 This field is considered valid and evaluated only if the URG bit is set to 1.

6/8/2020 NETWORK LAYER 14


TCP Header
 Options field: The size of options field vary from 0 bytes to 40 bytes.
 Options field is generally used for the following purposes-
 Time stamp: Multiple segments having the same sequence number may appear at the
receiver side. Based on the time stamp, receiver can identify the correct segment.
 Window size extension: It can be used to represent a window size of more than 16 bits.
 Parameter negotiation: To specify maximum segment size.
 Padding: Addition of dummy data to fill up unused space in the transmission unit and
make it conform to the standard size is called as padding.

6/8/2020 NETWORK LAYER 15


TCP Connection Management
 TCP is a connection oriented protocol and every connection oriented protocol needs
to establish connection in order to reserve resources at both the communicating
ends.
 A TCP connection is defined to be a 4-tuple consisting of two IP addresses and two
port numbers. It is a pair of endpoints or sockets where each endpoint is identified
by an (IP address, port number) pair.
 In TCP, the connections are established using three way handshake technique.
 TCP Connection Management includes:
 TCP Connection Establishment
 Data Transfer
 TCP Connection Release.

6/8/2020 NETWORK LAYER 16


TCP Connection Management
 TCP Connection Establishment: To
establish a TCP connection, the
following events usually take place:
 The active opener (normally called the
client) sends a SYN segment (a TCP/IP
packet with the SYN bit field turned on
in the TCP header) specifying the port
number of the peer to which it wants to
connect and the client’s Initial
Sequence Number ISN(c) (e.g. 100).
 It typically sends one or more options
(e.g. max. window size etc) at this
point. This is segment 1.

6/8/2020 NETWORK LAYER 17


TCP Connection Management
 The server responds with its own SYN segment containing its initial sequence number
(ISN(s)) (e.g. 500). This is segment 2.
 The server also acknowledges the client’s SYN by ACKing ISN(c) plus 1 (101). A SYN
consumes one sequence number and is retransmitted if lost.
 The client must acknowledge this SYN from the server by ACKing ISN(s) plus 1 (e.g.,
501). This is segment 3.
 These three segments complete the connection establishment and this process is also called
as three-way handshaking.
 The side that sends the first SYN is said to perform an active open. This is typically a client.
 The other side, which receives this SYN and sends the next SYN, performs a passive open.
It is most commonly called the server.
6/8/2020 NETWORK LAYER 18
TCP Connection Management
 Data Transfer: During this phase data is transferred between both client and server.
 TCP Connection Termination/ Release: To close or terminate TCP connection either
end can initiate a close operation, and simultaneous closes are also supported but are rare.
 Traditionally, it was most common for the client to initiate a close. However, other
servers (e.g., Web servers) initiate a close after they have completed a request.
 Usually a close operation starts with an application indicating its desire to terminate its
connection.
 The closing TCP initiates the close operation by sending a FIN segment (a TCP segment
with the FIN bit field set). The complete close operation occurs after both sides have
completed the close.

6/8/2020 NETWORK LAYER 19


TCP Connection Management
 The active closer sends a FIN segment specifying the current sequence number the
receiver expects to see (e.g., K in figure). The FIN also includes an ACK for the last
data sent in the other direction.
 The passive closer responds by ACKing value K + 1 to indicate its successful receipt
of the active closer’s FIN. At this point, the application is notified that the other end
of its connection has performed a close.
 Typically this results in the application initiating its own close operation. The passive
closer then effectively becomes another active closer and sends its own FIN. The
sequence number is equal to L (e.g., L in figure at server side).
 To complete the close, the final segment contains an ACK for the last FIN. Note that
if a FIN is lost, it is retransmitted until an ACK for it is received.
 While it takes three segments to establish a connection, it takes four to terminate one.
6/8/2020 NETWORK LAYER 20
User Datagram Protocol (UDP)
 UDP stands for User Datagram Protocol.
 It is a connectionless, simple protocol available on the TCP/IP protocol suite and it provides
non-sequenced transport functionality.
 UDP is a communications protocol that is primarily used for establishing low-latency and loss-
tolerating connections between applications on the internet.
 It speeds up transmissions by enabling the transfer of data before an agreement is provided by
the receiving party.
 This type of protocol is used when reliability and security are less important than speed and size.
 UDP is an end-to-end transport level protocol that adds transport-level addresses, checksum
error control, and length information to the data from the upper layer.
 The packet produced by the UDP protocol is known as a user datagram.
6/8/2020 NETWORK LAYER 21
User Datagram Protocol (UDP)
 UDP does not provide congestion control mechanism.
 UDP does not guarantee ordered delivery of data.
 UDP is stateless.
 UDP is suitable protocol for streaming applications such as VoIP, multimedia streaming.

6/8/2020 NETWORK LAYER 22


UDP Datagram
 User datagram has a 16-byte header along with data which is shown below:
 Source port address: It defines the address of the application process that has delivered a
message. The source port address is of 16 bits address.

 Destination port address: It defines the


address of the application process that will
receive the message. The destination port
address is of a 16-bit address.
 Total length: It defines the total length of the
user datagram in bytes. It is a 16-bit field.
 Checksum: The checksum is a 16-bit field
which is used in error detection.
6/8/2020 NETWORK LAYER 23
Difference between TCP and UDP
Basis for
TCP UDP
Comparison
UDP transmits the data directly to the
TCP establishes a virtual circuit before
Definition destination computer without verifying whether
transmitting the data.
the receiver is ready to receive or not.
Connection
It is a Connection-Oriented protocol It is a Connectionless protocol
Type
Speed Slow High
Reliability It is a reliable protocol. It is an unreliable protocol.
Header size 20-60 bytes 8 bytes
It waits for the acknowledgement of data
acknowledgeme It neither takes the acknowledgement, nor it
and has the ability to resend the lost
nt retransmits the damaged frame.
packets.

6/8/2020 NETWORK LAYER 24


References
1. Forouzan, B. A., & Mosharraf, F. (2012). Computer networks: a top-down
approach, McGraw-Hill.
2. https://www.tutorialspoint.com/
3. https://www.slideshare.net/
4. https://www.gatevidyalay.com/
5. https://www.computernetworkingnotes.com/

6/8/2020 NETWORK LAYER 25


Thank You!

6/8/2020 NETWORK LAYER 26

You might also like