CN Unit 4
CN Unit 4
CN Unit 4
Unit 4
Introduction
• Transport Layer is the second layer in the TCP/IP model and the fourth
layer in the OSI model.
• The transport layer is responsible for providing services to the
application layer; it receives services from the network layer.
Working of Transport Layer:
• At the sender’s side: The transport layer receives data (message)
from the Application layer and then performs Segmentation, divides
the actual message into segments, adds source and destination’s port
numbers into the header of the segment, and transfers the message
to the Network layer.
Cont..
• At the receiver’s side: The transport layer receives data from the
Network layer, reassembles the segmented data, reads its header,
identifies the port number, and forwards the message to the
appropriate port in the Application layer.
Services Provide by TL
Cont..
Multiplexing
• The transport layer uses the multiplexing to improve transmission efficiency.
Multiplexing can occur in two ways:
• Upward multiplexing: Upward multiplexing means multiple transport layer connections use the
same network connection. To make more cost-effective, the transport layer sends several
transmissions bound for the same destination along the same path; this is achieved through
upward multiplexing.
Process-to-Process
Communication
• TCP provides a process to
process communication, i.e,
the transfer of data that takes
place between individual
processes executing on end
systems. This is done using
port numbers.
• Some well-known port
numbers used by TCP.
Cont..
Stream Oriented
• This means that the data is sent and received as a stream of
bytes(unlike UDP or IP that divides the bits into datagrams or
packets).
• TCP creates an environment in which the two processes seem to be
connected by an imaginary "tube" that carries their data across the
Internet.
• The sending process produces (writes to) the stream of bytes, and the
receiving process consumes (reads from) them.
Cont..
Sending and Receiving Buffers
• Because the sending and the receiving processes may not write or
read data at the same speed, TCP needs buffers for storage.
• There are two buffers, the sending buffer and the receiving buffer,
one for each direction and these buffers are also necessary for flow
and error control mechanisms used by TCP.
Cont..
Segment
• The IP layer, as a service provider for TCP, needs to send data in
packets, not as a stream of bytes.
• At the transport layer, TCP groups a number of bytes together into a
packet called a segment.
• TCP adds a header to each segment (for control purposes) and
delivers the segment to the IP layer for transmission.
Cont..
Full-duplex service
• This means that the communication can take place in both directions
at the same time.
Connection-oriented service
• Unlike UDP, TCP provides a connection-oriented service. It defines 3
different phases:
• Connection establishment
• Data transfer
• Connection termination
Cont..
Reliability
• TCP is reliable as it uses checksum for error detection, attempts to
recover lost or corrupted packets by re-transmission,
acknowledgement policy and timers.
Multiplexing –
• TCP does multiplexing and de-multiplexing at the sender and receiver
ends respectively as a number of logical connections can be
established between port numbers over a physical connection.
TCP Features
• TCP is reliable protocol. That is, the receiver always sends either positive or
negative acknowledgement about the data packet to the sender, so that
the sender always has bright clue about whether the data packet is
reached the destination or it needs to resend it.
• 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.
TCP Connection
• To make the transport services reliable, TCP hosts must establish a
connection-oriented session with one another.
• Connection establishment is performed by using the three-way handshake
mechanism. A three-way handshake synchronizes both ends of a network
by enabling both sides to agree upon original sequence numbers.
• This mechanism also provides that both sides are ready to transmit data
and learn that the other side is available to communicate.
• This is essential so that packets are not shared or retransmitted during
session establishment or after session termination.
Cont..
TCP Connection Establishment
• The requesting end (Host A) sends an SYN
segment determining the server's port
number that the client needs to connect to
and its initial sequence number (x).
• The server (Host B) acknowledges its own
SYN segment, including the servers initial
sequence number (y). The server also
responds to the client SYN by accepting the
sender's SYN plus one (X + 1).
• An SYN consumes one sequence number. The
client should acknowledge this SYN from the
server by accepting the server's SEQ plus one
(SEQ = x, ACK = y + 1). This is how a TCP
connection is settled.
Cont..
Cont..
TCP Connection termination
• The rule is that either end can share a FIN
when it has finished sending data.
• When a TCP receives a FIN, it should notify
the application that the other end has
terminated that data flow direction. The
sending of a FIN is usually the result of the
application issuing a close.
• A TCP can send data after receiving a FIN.
The end that first issues the close (example,
send the first FIN) executes the active close. Therefore TCP Connection
termination is 4 way Handshake
The other end (that receives this FIN)
manages the passive close.
TCP Congestion Control
• Congestion occurs, if the load offered to any network is more than its
capability
• TCP Controls congestion by means of window mechanisms (to manage the flow
of packets between two computers or network hosts)
• TCP sets a window size telling the other end how much data segment to
send.
Congestion policy or algorithm in TCP –
1.Slow Start Phase
2.Congestion Avoidance Phase: After reaching the threshold increment is by 1
3.Congestion Detection Phase: Sender goes back to Slow start phase or
Congestion avoidance phase.
1. Slow Start Phase-
Cont..
• Starts slowly, size of congestion window increases exponential to
threshold
• Initially, sender sets congestion window size = Maximum Segment
Size (1 MSS).
• After receiving each acknowledgment, sender increases the
congestion window size by 1 MSS.
Cont..
Congestion window (CWND)