Transport Layer
Transport Layer
CS-439
Transport Layer
11
Transport Layer - Introduction
• In a protocol architecture, the transport protocol lies above
network or internetwork layer, and just below application and other
upper layer protocols.
• The data link layer is responsible for delivery of frames between
two neighboring nodes over a link. This is called node to node
delivery.
• The network layer is responsible for delivery of datagrams between
two hosts. This is called host to host delivery.
• Communication on the Internet is not defined as the exchange of
data between two nodes or between two hosts. Real
communication takes place between two processes (application
programs). We need process to process delivery.
2
Processes Communication
• It is important to understand how the programs, running in multiple end systems,
communicate with each other. They are processes that communicate.
• A process is simply a program that is running within an end system.
• When processes are running on the same end system, they can communicate with each other
with inter process communication, using rules that are governed by the end system’s
operating system.
• We are not particularly interested in how processes in the same host communicate, but
instead in how processes running on different hosts communicate.
• Processes on two different end systems communicate with each other by exchanging
messages across the computer network.
• A sending process creates and sends messages into the network; a receiving process receives
these messages and possibly responds by sending messages back.
• The transport layer is responsible for process to process delivery the delivery of a packet from
one process to another.
3
Services Provided by Transport Layer
• A transport layer protocol provides logical communication between application processes running on
different hosts.
• Logical communication from an application’s perspective is as if the hosts running the processes were
directly connected; in reality, the hosts may be on geographically distant connected via numerous
routers and a wide range of link types.
• On the sending side, the transport layer converts the application layer messages it receives from a
sending application process into transport layer packets, known as transport layer segments.
• This is done by breaking the application messages into smaller chunks and adding a transport layer
header to each chunk to create the transport layer segment.
• The transport layer then passes the segment to the network layer at the sending end system, where the
segment is encapsulated within a network layer packet (a datagram) and sent to the destination.
• On the receiving side, the network layer extracts the transport layer segment from the datagram and
passes the segment up to the transport layer. The transport layer then processes the received segment,
making the data in the segment available to the receiving application.
4
Transport Layer Protocols
• The TCP/IP protocol suite specifies two protocols for the transport layer:
• UDP – connectionless and unreliable service.
• TCP – connection oriented and reliable service
5
User Datagram Protocol (UDP) - Operation
• UDP's task is to take data from higher layer protocols and place it in UDP messages, which
are then passed down to the Internet Protocol for transmission. The basic steps for
transmission using UDP are:
• Higher Layer Data Transfer - An application sends a message to the UDP software.
• UDP Message Encapsulation - The higher layer message is encapsulated into the Data field of
a UDP message. The headers of the UDP message are filled in, including the Source Port of
the application that sent the data to UDP, and the Destination Port of the intended recipient.
The checksum value may also be calculated.
• Transfer Message To IP - The UDP message is passed to IP for transmission.
6
User Datagram Protocol (UDP) - Operation
• UDP does not do include the following:
• UDP does not establish connections before sending data. –
connectionless service.
• UDP does not provide acknowledgments to show that data was
received. – unreliable service.
• UDP does not provide any guarantees that its messages will arrive.
• UDP does not detect lost messages and retransmit them.
• UDP does not ensure that data is received in the same order that
they were sent.
• UDP does not provide any mechanism to manage the flow of data
between devices, or handle congestion.
7
UDP – Segment Structure
• The UDP header has four fields, each consisting of two bytes.
• Source Port number - The 16 bit port number of the process that originated the UDP message
on the source devices.
• Destination port number - The 16 bit port number of the process that is the ultimate intended
recipient of the message on the destination device.
• Length – This field specifies the number of bytes in the UDP segment (header plus application
data).
• Checksum - is used by the receiving host to check whether errors have been introduced into
the segment.
• Application Data - The encapsulated higher-layer message to be sent.
32 Bits
Length Checksum
Application Data 8
UDP - Checksum
• The UDP checksum provides for error detection. That is, the checksum is used to determine
whether bits within the UDP segment have been altered as it moved from source to
destination.
• UDP at the sender side performs the 1s complement of the sum of all the 16 bit words in the
segment, with any overflow encountered during the sum being wrapped around. This result is
put in the checksum field of the UDP segment.
• At the receiver, all four 16 bit words are added, including the checksum. If no errors are
introduced into the packet, then clearly the sum at the receiver will be all 1’s. If one of the
bits is a 0, then we know that errors have been introduced into the packet.
• Although UDP provides error checking, it does not do anything to recover from an error.
Sometimes UDP simply discard the damaged segment or pass the damaged segment to the
application with a warning.
• The use of the Checksum field is optional in UDP. If it is not used, it is set to a value of all
zeroes. This could potentially create confusion, however, since when the checksum is used,
the calculation can sometimes result in a value of zero. To avoid having the destination think
the checksum was not used in this case, this zero value is instead represented as a value of all
ones. 9
Why Some TCP/IP Applications Use UDP
• The following lists some uses of the UDP protocol:
• Data Where Performance Is More Important Than Completeness - multimedia application. If
you are streaming a video clip over the Internet, the most important thing is that the stream
starts flowing quickly and keeps flowing. We only notice significant disruptions in the flow of
this type of information, so a few bytes of data missing due to a lost datagram is not a big
problem.
• Data Exchanges That Are Short - There are many TCP/IP applications where the underlying
protocol consists of only a very simple request/reply exchange. A short request message is
sent from a client to a server, and a short reply message goes back from the server to the
client. In this situation, there is no real need to set up a connection like TCP does.
• If an application needs to multicast or broadcast data, it must use UDP, because TCP is only
supported for unicast communication between two devices.
10
Transmission Control Protocol(TCP) - Characteristics
• TCP is connection-oriented service - TCP requires that devices first establish a
connection with each other before they send data.
• Suppose a process(client process) running in one host wants to initiate a
connection with another process(server process) in another host.
• The client application process first informs the client transport layer that it
wants to establish a connection to a process in the server.
• TCP in the client then proceeds to establish a TCP connection with TCP in the
server. The client first sends a special TCP segment; the server responds with
a second special TCP segment; and finally the client responds again with a
third special segment.
• The first two segments carry no payload, that is, no application layer data; the
third of these segments may carry a payload.
• Because three segments are sent between the two hosts, this connection
establishment procedure is often referred to as a three way handshake. 11
Transmission Control Protocol(TCP) - Characteristics
• A TCP connection provides a full duplex service - if there is a TCP connection between
Process A on one host and Process B on another host, then application layer data can flow
from Process A to Process B at the same time as application layer data flows from Process B
to Process A.
• A TCP connection is also always point to point - between a single sender and a single receiver.
• TCP is reliable - TCP keeps track of data that has been sent and received to ensure it all gets
to its destination. A key to providing reliability is that all transmissions in TCP are
acknowledged.
• TCP provides flow control and congestion avoidance - allows the flow of data between two
devices to be controlled and managed. It also includes features to deal with congestion that
may be experienced during communication between devices.
12
TCP Segment Structure
• Source & Destination Port Number - specifies the 16 bit port number of the process that originated the TCP
segment on the source device and the 16 bit port number of the process that is the ultimate intended recipient of
the message on the destination device respectively.
• Sequence number and acknowledgment number field - are used by the TCP sender and receiver in implementing a
reliable data transfer service.
• Receive window field - used for flow control.
• Header length field - specifies the length of the TCP header in 32 bit words. The TCP header can be of variable
length due to the TCP options field. 32 Bits
Data 13
TCP Flow Control
• TCP provides a flow control service to its applications to eliminate the
possibility of the sender overflowing the receiver’s buffer.
• Flow control is thus a speed matching service—matching the rate at which the
sender is sending against the rate at which the receiving application is
reading.
• TCP provides flow control by having the sender maintain a variable called the
receive window. Informally, the receive window is used to give the sender an
idea of how much free buffer space is available at the receiver.
• TCP is full duplex, the sender at each side of the connection maintains a
distinct receive window.
14
Questions?
15