Professional Documents
Culture Documents
UNIT-IV
TRANSPORT LAYER
FACULITY:
SREENU BANOTH
ASSISTANT PROFESSOR ,
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING,
IIMT COLLEGE OF ENGINEERING,GREATER NOIDA-201308
Syllabus:
UNIT-IV
Transport Layer: Process-to process delivery, Transport layer protocols (UDP
and TCP), Multiplexing, Connection management, Flow control and
retransmission, Window management, TCP Congestion control, Quality of
service.
Introduction:
• The transport Layer is the second layer in the TCP/IP model and the fourth layer in the OSI model.
• It is an end-to-end layer used to deliver messages to a host.
• It is termed an end-to-end layer because it provides a point-to-point connection rather than hop-to-hop, between
the source host and destination host to deliver the services reliably.
• The unit of data encapsulation in the Transport Layer is a segment.
• Congestion Control
• Flow control
Transport Layer
• The transport layer in the TCP/IP suite is located between the application layer and the network
layer.
• It provides services to the application layer and receives services from the network layer.
• The transport layer acts as a liaison between a client program and a server program, a process-to-
process connection.
Transport Layer
• The transport layer is responsible for process-to-process delivery.
• A process is an application program running on a host.
• The transport layer is responsible for:
• Service point or Port addressing
• Segmentation and reassembly
• A message is divided into transmittable segments each segment containing a sequence
number.
• Connection Control
• Connection oriented or connectionless.
• Flow control
• Error control
Process to Process Communication
• The first duty of a transport-layer protocol is to provide process-to-process or (end to end delivery)
communication.
• A process is an application-layer entity (running program) that uses the services of the transport layer.
• Type of data deliveries
• Data Link Layer: Node to Node delivery
• Network Layer: Host to host delivery
• Transport Layer: Process to process delivery
Process to Process Communication
• Network layer
• Communication at the computer level (host-to-host communication).
• Deliver the message only to the destination computer.
• Transport layer:
• Message handed to the correct process on the host computer. shows the domains of a network
Client-Server Communication
• Most common way to achieve process-to-process communication, is through
the client-server paradigm.
• A process on the local host, called a client, needs services from a process usually on the
remote host, called a server.
• A remote computer/server can run several server programs at the same time, just as
several local computers/clients can run one or more client programs at the same time.
• Well-known ports. The ports ranging from 0 to 1023 are assigned and controlled by ICANN. These
are the well-known ports.
• Registered ports. The ports ranging from 1024 to 49,151 are not assigned or controlled by ICANN.
They can only be registered with ICANN to prevent duplication.
• Dynamic ports. The ports ranging from 49,152 to 65,535 are neither controlled nor registered. They
can be used as temporary or private port numbers.
Some Well Known Port Numbers
Stream and Segment
Data viewed as a byte stream, i.e., a sequence of bytes
• The stream of bytes is divided into segments, each segment is given a TCP header, and transmitted
• Each TCP segment will contain a 32-bit sequence no. to identify its position in the stream
Maximum Segment Size
• Maximum size of a segment (excluding header)
• Ideally, should be (Minimum MTU of any link from the source to the destination –TCP headersize –
IP header size)
• Hard to know minimum MTU of links end-to-end, though can be known in some cases, for ex, if all
links are Ethernet
• IP address
• port number
• If the sender delivers items whenever they are produced- without a prior request from the consumer-
the delivery is referred to as pushing.
• If the producer delivers the items after the consumer has requested them, the delivery is referred to as
pulling.
Flow Control
• If the items are produced faster than they can be consumed, the consumer can be overwhelmed and
may need to discard some items.
• Pushing: sender delivers items whenever they are produced⎯ without a prior request from the
consumer.
• Pulling: producer delivers the items after the consumer has requested them
• Two cases of flow control at the transport layer:
• From the sending transport layer to the sending application layer and
• From the receiving transport layer to the sending transport layer
Error Control
• Error control at the transport layer is responsible for
• Reliability can be achieved by adding error control services to the transport layer. Error control at
the transport layer is responsible for
• Detecting and discarding corrupted packets.
• Keeping track of lost and discarded packets and resending them.
• Recognizing duplicate packets and discarding them.
• Buffering out-of-order packets until the missing packets arrive.
• Error control, unlike flow control, involves only the sending and receiving transport layers.
• We assume that the message chunks exchanged between the application and transport layers are
error free.
Congestion control
• Congestion control refers to the mechanisms and techniques that control the congestion and keep the load
below the capacity.
• Congestion in a network may occur if the load on the network the number of packets sent to the network is
greater than the capacity of the network the number of packets a network can handle.
• Congestion in a network or internetwork occurs because routers and switches have queues buffers that hold the
packets before and after processing.
• A router, for example, has an input queue and an output queue for each interface.
• If a router cannot process the packets at the same rate at which they arrive, the queues become overloaded and
congestion occurs.
• Congestion at the transport layer is actually the result of congestion at the network layer, which manifests itself
at the transport layer.
• Congestion at the transport layer can be implemented if there is no congestion control at the network layer.
Transport Layer Protocol
• The transport layer in the TCP/IP suite is located between the application layer and the network layer.
• It provides services to the application layer and receives services from the network layer.
• Unreliable connectionless transport-layer protocol used for its simplicity and efficiency in applications
where error control can be provided by the application-layer process.
• Reliable connection-oriented protocol that can be used in any application where reliability is
important.
• SCTP
• The transport layer treats each chunk as a single unit without any relation between the chunks.
• When a chunk arrives from the application layer, the transport layer encapsulates it in a packet and
sends it.
• To show the independency of packets, assume that a client process has three chunks of messages to
send to a server process.
• The chunks are handed over to the connectionless transport protocol in order.
• However, since there is no dependency between the packets at the transport layer, the packets may
arrive out of order at the destination and will be delivered out of order to the server process.
Connection Oriented Services
• In a connection-oriented service, the client
and the server first need to establish a
logical connection between themselves.
• The sending process produces (writes to) the stream and the receiving process consumes (reads from)
it.
UDP:
• User Datagram Protocol (UDP)
• Connectionless, unreliable transport protocol.
• It does not add anything to the services of IP except for providing process-to-process
communication instead of host-to-host communication.
• UDP is a very simple protocol using a minimum of overhead.
• UDP packets called user datagrams,
• Fixed-size header of 8 bytes made of four fields, each of 2 bytes (16 bits).
• The first two fields define the source and destination port numbers.
UDP Packets-User datagram
• The third field defines the total length of the user datagram, header plus data.
• The total length needs to be less because a UDP user datagram is stored in an IP datagram with
the total length of 65,535 bytes.
• Connectionless Services
• Independent datagram, No relationship between the different user datagrams even if they are
coming from the same source process and going to the same destination program, Datagrams are
not numbered.
• Flow Control
• When the receiver detects an error through the checksum, the user datagram is silently
discarded.
• Checksum
• A pseudo-header
• No congestion control
• UDP does not create additional traffic in an error-prone network. Therefore, in some cases, lack
of error control in UDP can be considered an advantage when congestion is a big issue.
• To send a message from one process to another, the UDP protocol encapsulates and decapsulates
messages.
• In a host running a TCP/IP protocol suite, there is only one UDP but possibly several processes
that may want to use the services of UDP. To handle this situation, UDP multiplexes and
demultiplexes.
Transmission control protocol (TCP)
Transmission Control Protocol (TCP)
TCP explicitly defines connection establishment, data transfer, and connection teardown phases to
provide connection oriented service.
TCP uses checksum (for error detection), retransmission of lost or corrupted packets, cumulative
and selective acknowledgments, and timers
TCP Services
• Process-to-Process Communication
• In TCP the sending process delivers data as a stream of bytes and allows the receiving process
to obtain data as a stream of bytes.
• In TCP two processes seem to be connected by an imaginary “tube” that carries their bytes
across the Internet.
TCP Services
• Full-Duplex Communication
• Offers full-duplex service, where data can flow in both directions at the same time.
• Multiplexing and Demultiplexing
• TCP performs multiplexing at the sender and demultiplexing at the receiver.
• Connection-Oriented Service
• TCP is a connection-oriented protocol. When a process at site A wants to send to and
receive data from another process at site B, the following three phases occur:
• The two TCP’s establish a logical connection between them.
• Data are exchanged in both directions.
• The connection is terminated.
• This is a logical connection, not a physical connection.
• Reliable Service
• TCP is a reliable transport protocol. It uses an acknowledgment mechanism to check the
safe and sound arrival of data.
TCP Packets/Segments
• A packet in TCP is called a segment.
• Format
Format
• Header: The segment consists of a header of 20 to 60 bytes, followed by data from the application
program.
• Source port address. This is a 16-bit field that defines the port number of the application program in
the host that is sending the segment.
• Destination port address. This is a 16-bit field that defines the port number of the application
program in the host that is receiving the segment.
• Sequence number. This 32-bit field defines the number assigned to the first byte of data contained in
this segment.
• Acknowledgment number. This 32-bit field defines the byte number that the receiver of the segment
is expecting to receive from the other party.
• Header length. This 4-bit field indicates the number of 4-byte words in the TCP header
Format
• Window size. This field defines the window size of the sending TCP in bytes.
• Checksum.
• This 16-bit field contains the checksum.
• The calculation of the checksum for TCP follows the same procedure as the one described for
UDP.
• The use of the checksum in the UDP datagram is optional, whereas the use of the checksum for
TCP is mandatory.
• The pseudo header serves the same purpose as in UDP.
• For the TCP pseudo header, the value for the protocol field is 6.
• Urgent pointer. This 16-bit field, which is valid only if the urgent flag is set, is used when the
segment contains urgent data.
Format
Encapsulation
TCP Application-layer data
header
IP
header
Frame
header
TCP payload
IP payload
Data-link layer payload
TCP Connection
• TCP is connection-oriented.
• All of the segments belonging to a message are then sent over this virtual path.
• You may wonder how TCP, which uses the services of IP, a connectionless protocol, can be
connection-oriented.
• TCP operates at a higher level. TCP uses the services of IP to deliver individual segments to the
receiver, but it controls the connection itself. If a segment is lost or corrupted, it is retransmitted.
• A SYN segment cannot carry data, but it consumes one sequence number.
• A SYN + ACK segment cannot carry data, but does consume one sequence number.
• An ACK segment, if carrying no data, consumes no sequence number
Connection establishment using three way handshake Figure
Data Transfer
Connection termination using three-way handshake
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.
Congestion Control
• In the Internet, TCP plays the main role in controlling congestion, as well as the main role in reliable
transport.
• TCP uses the following techniques for congestion control
• A congestion window
• TCP congestion window size is the number of bytes the sender may have in the network at
any time.
• Congestion policy that avoid congestion and detect and alleviate congestion after it has occurred.
• The congestion window is maintained in addition to the flow control window, which specifies the
number of bytes that the receiver can buffer.
• Both windows are tracked in parallel, and the number of bytes that may be sent is the smaller of the
two windows.
• Thus, the effective window is the smaller of what the sender thinks is all right and what the receiver
thinks is all right.
• TCP will stop sending data if either the congestion or the flow control window is temporarily full.
Congestion Control
• Congestion Window
• The use of flow control strategy at the transport layer guarantees that the receive window is
never overflowed with the received bytes (no end congestion).
• Intermediate buffers, buffers in the routers can become congested.
• TCP needs to define policies that accelerate the data transmission when there is no congestion
and decelerate the transmission when congestion is detected.
• To control the number of segments to transmit, TCP uses a variable called a congestion window,
cwnd, whose size is controlled by the congestion situation in the network.
• The size of the window is the minimum of the cwnd variable and the rwnd variable.
• TCP’s general policy for handling congestion is based on three algorithms: slow start,
congestion avoidance, and fast recovery.
• In the slow start algorithm, the size of the congestion window increases exponentially until it
reaches a threshold.
• In the congestion avoidance algorithm the size of the congestion window increases additively
until congestion is detected.
Slow Start Algorithm
• When a connection is established, the sender
initializes the congestion window to a small
initial value of at most four segments
• The sender then sends the initial window.
• The packets will take a round-trip time to be
acknowledged.
• For each segment that is acknowledged before
the retransmission timer goes off, the sender
adds one segment’s worth of bytes to the
congestion window.
• As that segment has been acknowledged, there is
now one less segment in the network.
• The upshot is that every acknowledged segment
allows two more segments to be sent.
• The congestion window is doubling every round
trip time.
• This algorithm is called slow start
Congestion avoidance algorithm/Additive Increase
TCP segment
Send Timing
• Before Tahoe
- On connection, nodes send full window of packets
- Retransmit packet immediately after its timer expires
• Result: window-sized bursts of packets in network
Bursts of packets
Retransmission
• TCP dynamically estimates round trip time
• If segment goes unacknowledged, must retransmit
• Use exponential backoff (in case loss from congestion)
• After 10 minutes, give up and reset connection