Unit - 3 Transport Layer
Unit - 3 Transport Layer
Unit - 3 Transport Layer
SUBJECT CODE:3150710
SEMESTER: 5TH FACULTY NAME: Prof. Bhaumik Gelani
Email id: bhaumik.gelani@ljku.edu.in
SUBJECT NAME: Computer Networks Mobile : +91 99092 49440
DEPARETMENT: CSE & IT
Subject Overview
3 Transport Layer 25
4 Network Layer 25
5 The Link layer and Local area networks 18
1
9/11/2023
Reference Books
Sr. No. Book Name Author Publication
1 Computer Networking- A Top-Down approach, Kurose and Pearson
5th edition Ross
2 Computer Networks- A Top-Down approach, Behrouz Mc Graw Hill
Forouzan
3 Computer Networks (4th edition) Andrew Prentice Hall
Tanenbaum
2
9/11/2023
1.
Introduction and Transport Layer Services
• Transport Layer :
• The transport layer is responsible for the delivery of a message from one
process to another.
• Transport Layer is the fourth layer from the top in OSI Model which
provide communication services to the application processes that was
running on different hosts.
• Transport Layer provides the services to the session layer and it receives
the services from network layer.
Cont..
3
9/11/2023
Cont..
• Transport layer also provides the flow control functionality and ensures that
segmented data is delivered across the network in the right sequence.
Cont..
4
9/11/2023
Cont..
• The services provided by the transport layer protocols can be divided into
five categories:
1. End-to-end delivery
2. Addressing
3. Reliable delivery
4. Flow control
5. Multiplexing
5
9/11/2023
Cont..
Cont..
• End-to-end delivery:
• The transport layer transmits the entire message to the destination.
• Therefore, it ensures the end-to-end delivery of an entire message from
a source to the destination.
• Reliable delivery:
• The transport layer provides reliability services by retransmitting the
lost and damaged packets.
6
9/11/2023
Cont..
Cont..
• Flow Control
• Flow control is used to prevent the sender from overwhelming the receiver.
• If the receiver is overloaded with too much data, then the receiver discards
the packets and asking for the retransmission of packets.
• This increases network congestion and thus, reducing the system
performance.
• The transport layer is responsible for flow control.
• It uses the sliding window protocol that makes the data transmission more
efficient as well as it controls the flow of data so that the receiver does not
become overwhelmed.
• Sliding window protocol is byte oriented rather than frame oriented.
7
9/11/2023
Cont..
• Addressing:
• According to the layered model, the transport layer interacts with the
functions of the session layer.
Cont..
8
9/11/2023
Cont..
• Multiplexing
• The transport layer uses the multiplexing to improve transmission
efficiency.
Cont..
• Upward multiplexing:
9
9/11/2023
Cont..
• Downward multiplexing:
• Downward multiplexing means one transport
layer connection uses the multiple network
connections.
• A service primitive is a set of operations that the user can invoke to access the
service.
• The communication between the two layers is carried out through a set of
operations called service primitives that are available to a user or other entity to
access the service.
10
9/11/2023
Cont..
Cont..
Primitive Meaning
• It represent entity that wants or request service to perform some
Request action or do some work (requesting for connection to remote
computer).
• It represent entity that is to be informed about event (receiver just
Indication
have received request of connection).
• It represents entity that is responding to event (receiver is simply
Response
sending the permission or allowing to connect).
• It represent entity that acknowledges the response to earlier
Confirm request that has come back (sender just acknowledge the
permission to get connected to the remote host).
11
9/11/2023
2.
Multiplexing and Demultiplexing
Cont..
12
9/11/2023
Cont..
• These segments are passed to the Network Layer which adds the
source and destination IP address to get the datagram.
Cont..
• Demultiplexing
• Delivering the received segments at the receiver side to the correct app
layer processes is called demultiplexing.
13
9/11/2023
Cont..
Cont..
14
9/11/2023
Cont..
• After segmenting the data, port numbers are given to each segment to be
ready for transmission.
• Then the segments are put on a wire to travel across the network to the
destination. This process is called "Multiplexing".
3.
Connectionless Transport (UDP)
• UDP stands for User Datagram Protocol.
• UDP is a simple protocol and it provides non-sequenced transport
functionality.
15
9/11/2023
Cont..
UDP Header
• UDP header is 8-bytes fixed and simple header, while for TCP it may vary
from 20 bytes to 60 bytes.
• First 8 Bytes contains all necessary header information and remaining part
consist of data.
Cont..
• UDP port number fields are each 16 bits long, therefore range for port
numbers defined from 0 to 65535; port number 0 is reserved.
16
9/11/2023
Cont..
17
9/11/2023
Cont..
Cont..
• Version :
• This 2-bit field defines version number.
• The current version is 2.
• P:
• The length of this field is 1-bit.
• If value is 1, then it denotes presence of padding at end of packet and if value is 0,
then there is no padding.
• X:
• The length of this field is also 1-bit.
• If value of this field is set to 1, then its indicates an extra extension header between
data and basic header and if value is 0 then, there is no extra extension.
18
9/11/2023
Cont..
• Contributor count:
• This 4-bit field indicates number of contributors.
• Here maximum possible number of contributor is 15 as a 4-bit field can
allows number from 0 to 15.
• M:
• The length of this field is 1-bit and it is used as end marker by application to
indicate end of its data.
• Payload types:
• This field is of length 7-bit to indicate type of payload.
• We list applications of some common types of payload.
Cont..
• Sequence Number:
• The length of this field is 16 bits. It is used to give serial numbers to RTP
packets.
• It helps in sequencing.
• This field mainly helps in checking lost packets and order mismatch.
• Time Stamp:
• The length of this field is 32-bit.
• It is used to find relationship between times of different RTP packets.
• The value of 1 clock tick is varying from application to application.
19
9/11/2023
Cont..
Cont..
• Applications of RTP :
1. RTP mainly helps in media mixing, sequencing and time-stamping.
2. Voice over Internet Protocol (VoIP)
3. Video Teleconferencing over Internet.
4. Internet Audio and video streaming.
20
9/11/2023
4.
Principles of Reliable Data Transfer
• Transport Layer Protocols are central piece of layered architectures, these
provides the logical communication between application processes.
• These processes uses the logical communication to transfer data from
transport layer to network layer and this transfer of data should be reliable
and secure.
• The data is transferred in the form of packets but the problem occurs in
reliable transfer of data.
Cont..
• The problem of transferring the data occurs not only at the transport layer,
but also at the application layer as well as in the link layer.
21
9/11/2023
Cont..
Cont..
• In this model, we have design the sender and receiver sides of a protocol
over a reliable channel.
• In the reliable transfer of data the layer receives the data from the above
layer breaks the message in the form of segment and put the header on
each segment and transfer.
• Below layer receives the segments and remove the header from each
segment and make it a packet by adding to header.
22
9/11/2023
Cont..
• The data which is transferred from the above has no transferred data bits
corrupted or lost, and all are delivered in the same sequence in which they
were sent to the below layer this is reliable data transfer protocol.
Cont..
23
9/11/2023
Cont..
• The sending side of the protocol is called from the above layer to
rdt_send() then it will pass the data that is to be delivered to the
sending data where rdt stands for reliable data transfer protocol and
Cont..
• When the rdt protocol wants to deliver data to the application layer, it will
do so by calling deliver_data() (where deliver_data() is a function for
delivering data to upper layer).
24
9/11/2023
Cont..
25
9/11/2023
Cont..
Cont..
26
9/11/2023
Cont..
• Problems:
• Lost Data
• Lost Acknowledgement
Cont..
• In this protocol, the sender sends a packet of data to the receiver and then
waits for the receiver to acknowledge the packet before sending the next
packet.
27
9/11/2023
Cont..
• Problems:
• Lost Data
• Lost Acknowledgement
• Above 2 problems are resolved by Stop and Wait ARQ (Automatic Repeat
Request) that does both error control and flow control.
Cont..
• There is only one bit sequence number that implies that both sender
and receiver have buffer for one frame or packet only.
28
9/11/2023
Cont..
Cont..
• Characteristics:
• Used in Connection-oriented communication.
• It offers error and flow control
• It is used in Data Link and Transport Layers
• Stop and Wait ARQ mainly implements Sliding Window Protocol
concept with Window Size 1.
• Resolved Problems:
• Time Out
• Sequence Number
29
9/11/2023
Cont..
• The range of the sequence number depends on the size of the data
frame i.e. N. So, the range of the sequence numbers can be 0 to 2 ^ N-1.
30
9/11/2023
Cont..
Cont..
• Let us suppose that the sender's window size is taken as 4.
• So, the sequence number of the data frame will be in the range of 0 to (2 ^
N-1) i.e. 0, 1, 2, 3, 0, 1, 2, 3, and so on.
• The steps of data transmission can be:
1. The sender sends multiple frames.
2. The receiver receives the frames and sends back an ACK.
3. Again the sender sends the next frame.
4. If the receiver does not sends back an ACK in the specified time then the
sender sends back the frame as the frame is either lost or damaged in the last
transmission.
5. This process is continued till all the frames have been received by the
receiver.
31
9/11/2023
Cont..
32
9/11/2023
Cont..
• Go-Back-N ARQ (Automatic Repeat Request ):
33
9/11/2023
Cont..
• Damaged Frame:
• When the frame is damaged, then the receiver sends a NAK frame.
• In the above figure, three frames have been transmitted before an error
discovered in the third frame.
• In this case, ACK 2 has been returned telling that the frames 0,1 have
been received successfully without any error.
• The receiver discovers the error in data 2 frame, so it returns the NAK
2 frame.
• The frame 3 is also discarded as it is transmitted after the damaged
frame.
• Therefore, the sender retransmits the frames 2,3.
Cont..
34
9/11/2023
Cont..
• Lost Acknowledgement:
• The sender can send as many frames as the windows allow before
waiting for any acknowledgement.
• Once the limit of the window is reached, the sender has no more
frames to send; it must wait for the acknowledgement.
• If the acknowledgement is lost, then the sender could wait forever.
• To avoid such situation, the sender is equipped with the timer that
starts counting whenever the window capacity is reached.
• If the acknowledgement has not been received within the time limit,
then the sender retransmits the frame since the last ACK.
35
9/11/2023
Cont..
1. In this technique, only those frames are retransmitted for which negative
acknowledgement (NAK) has been received.
2. The receiver storage buffer keeps all the damaged frames on hold until
the frame in error is correctly received.
3. The receiver must have an appropriate logic for reinserting the frames in
a correct order.
4. The sender must consist of a searching mechanism that selects only the
requested frame for retransmission.
36
9/11/2023
Cont..
BASIS FOR
GO-BACK-N SELECTIVE REPEAT
COMPARISON
Retransmits all the frames that sent Retransmits only those frames
Basic after the frame which suspects to be that are suspected to lost or
damaged or lost. damaged.
Cont..
BASIS FOR
GO-BACK-N SELECTIVE REPEAT
COMPARISON
ACK Numbers NAK number refer to the next NAK number refer to the frame
expected frame number. lost.
37
9/11/2023
Cont..
Minimum Sequence
2 N+1 2N
number
Efficiency 1/(1+2*a) N/(1+2*a) N/(1+2*a)
38
9/11/2023
5.
Connection-oriented Transport (TCP)
Cont..
39
9/11/2023
Cont..
• Reliability:
• TCP assigns a sequence number to each byte transmitted and expects a positive
acknowledgement from the receiving TCP.
• If ACK is not received within a timeout interval, then the data is retransmitted to the
destination.
• The receiving TCP uses the sequence number to reassemble the segments if they
arrive out of order or to eliminate the duplicate segments.
Cont..
• Flow Control:
• When receiving TCP sends an acknowledgement back to the sender indicating the
number the bytes it can receive without overflowing its internal buffer.
• The number of bytes is sent in ACK in the form of the highest sequence number that
it can receive without any problem.
• This mechanism is also referred to as a window mechanism.
• Multiplexing:
• Multiplexing is a process of accepting the data from different applications and
forwarding to the different applications on different computers.
• At the receiving end, the data is forwarded to the correct application. This process is
known as De-multiplexing. TCP transmits the packet to the correct application by
using the logical channels known as ports.
40
9/11/2023
Cont..
• Logical Connections:
• The combination of sockets, sequence numbers, and window sizes, is called a logical
connection.
• Each connection is identified by the pair of sockets used by sending and receiving
processes.
• Full Duplex:
• TCP provides Full Duplex service, i.e., the data flow in both the directions at the
same time.
• To achieve Full Duplex service, each TCP should have sending and receiving buffers
so that the segments can flow in both the directions.
• TCP is a connection-oriented protocol. Suppose the process A wants to send and
receive the data from process B.
• The following steps occur:
• Establish a connection between two TCPs.
• Data is exchanged in both the directions.
• The Connection is terminated.
• TCP Header :
41
9/11/2023
Cont..
• 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.
Cont..
• 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 six-bit field which is reserved for future use.
42
9/11/2023
Cont..
• Control bits:
• Each bit of a control field functions individually and independently.
• A control bit defines the use of a segment or serves as a validity check for other
fields.
Cont..
Flag Description
43
9/11/2023
Cont..
• Window Size:
• The window is a 16-bit field that defines the size of the window.
• Checksum:
• The checksum is a 16-bit field used in error detection.
• Urgent pointer:
• If URG flag is set to 1, then this 16-bit field is an offset from the sequence number
indicating that it is a last urgent data byte.
44
9/11/2023
Cont..
• TCP Connection:
Cont..
45
9/11/2023
Cont..
Cont..
• Step 1 (SYN):
• In the first step, the client wants to establish a connection with a server, so it sends a
segment with SYN(Synchronize Sequence Number) which informs the server that
the client is likely to start communication and with what sequence number it starts
segments with.
46
9/11/2023
Cont..
TCP Termination
(A 4-way handshake):
47
9/11/2023
Cont..
1. Firstly, from one side of the connection, either from the client or the server the
FIN flag will be sent as the request for the termination of the connection.
2. In the second step, whoever receives the FIN flag will then be sending an ACK
flag as the acknowledgment for the closing request to the other side.
3. And, at the Later step, the server will also send a FIN flag as the closing signal to
the other side.
4. In the final step, the TCP, who received the final FIN flag, will be sending an
ACK flag as the final Acknowledgement for the suggested connection closing.
Piggybacking
48
9/11/2023
• Piggybacking :
• As we can see in the figure, we can see with piggybacking, a single message
(ACK + DATA) over the wire in place of two separate messages.
• Piggybacking improves the efficiency of the bidirectional protocols.
1. If Host A has both acknowledgment and data, which it wants to send, then
the data frame will be sent with the ack field which contains the sequence
number of the frame.
2. If Host A contains only one acknowledgment, then it will wait for some
time, then in the case, if it finds any data frame, it piggybacks the
acknowledgment, otherwise, it will send the ACK frame.
3. If Host A left with only a data frame, then it will add the last
acknowledgment to it. Host A can send a data frame with an ack field
containing no acknowledgment bit.
49
9/11/2023
• Advantages of Piggybacking
1. The major advantage of piggybacking is the better use of available
channel bandwidth. This happens because an acknowledgment frame
needs not to be sent separately.
• Disadvantages of Piggybacking:
1. The disadvantage of piggybacking is the additional complexity.
2. If the data link layer waits long before transmitting the acknowledgment
(blocks the ACK for some time), the frame will rebroadcast.
50
9/11/2023
6.
Congestion Control
• A state occurring in network layer when the message traffic is so heavy that it
slows down network response time.
• Effects of Congestion
• As delay increases, performance decreases.
• If delay increases, retransmission occurs, making situation worse.
• Congestion control algorithms
1. Leaky Bucket Algorithm
2. Token bucket Algorithm
Cont..
51
9/11/2023
Cont..
• Leaky Bucket:
Cont..
52
9/11/2023
Cont..
Cont..
53
9/11/2023
Cont..
Cont..
54
9/11/2023
Cont..
Cont..
• In figure (B) We see that three of the five packets have gotten through, but
the other two are stuck waiting for more tokens to be generated.
55
9/11/2023
Cont..
• Formula:
M*s=C+ρ*s
• Where,
• S – is time taken
• M – Maximum output rate
• ρ – Token arrival rate
• C – Capacity of the token bucket in byte
If Bucket is Full Packet or Data is Discarded Token are Discarded But Not the Packet.
56
9/11/2023
Cont..
7.
TCP Congestion Control
• TCP congestion control is a method used by the TCP protocol to
manage data flow over a network and prevent congestion.
• TCP uses a congestion window and congestion policy that avoids
congestion.
• The size of the sender window is determined by the following two
factors:
1. Receiver window size
2. Congestion window size
57
9/11/2023
Cont..
Cont..
• Congestion in TCP is handled by using these three phases:
1. Slow Start
2. Congestion Avoidance
3. Congestion Detection
• Slow Start Phase:
• In the slow start phase, the sender sets congestion window size = maximum
segment size (1 MSS) at the initial stage.
• The sender increases the size of the congestion window by 1 MSS after
receiving the ACK (acknowledgment).
• The size of the congestion window increases exponentially in this phase.
• The formula for determining the size of the congestion window
is Congestion window size = Congestion window size + Maximum
segment size.
58
9/11/2023
Cont..
Cont..
59
9/11/2023
Cont..
• This is how you calculate the size of the congestion window and it goes on for n
number of values.
• The general formula for determining the size of the congestion window is (2)round
trip time.
• This phase continues until window size reaches its slow start threshold.
• The formula for determining the threshold is given:
Threshold
=
Maximum number of TCP segments that the receiver window can
accommodate / 2
=
Receiver window size / Maximum Segment Size) / 2
Cont..
• Congestion Avoidance Phase:
• In this phase, after the threshold is reached, the size of the congestion
window is increased by the sender linearly in order to avoid congestion.
• Each time an acknowledgment is received, the sender increments the size of
the congestion window by 1.
60
9/11/2023
Cont..
• The formula for determining the size of the congestion window in this phase is:
• This phase continues until the size of the window becomes equal to that of the
receiver window size.
Cont..
• Congestion Detection Phase
• In this phase, the sender identifies the segment loss and gives
acknowledgment depending on the type of loss detected.
• Case-01: Detection On Time Out
1. In this, the timer time-out expires even before receiving acknowledgment
for a segment.
2. It suggests a stronger possibility of congestion in a network
3. In this, there are chances that a segment has been dropped in the network
• Reaction in response to Detection on time out:
1. Setting the threshold to start to half of the current size of window
2. Decreasing the size of the congestion window to MSS
3. Slow start phase is resumed
61
9/11/2023
Cont..
Cont..
• Difference Between Flow Control and Congestion Control
BASIS FOR
FLOW CONTROL CONGESTION CONTROL
COMPARISON
Basic It controls the traffic from a particular It controls the traffic entering the
sender to a receiver. network.
Purpose It prevents the receiver from being It prevents the network from getting
overwhelmed by the data. congested.
Responsibility Data Link Layer and Transport Layer. Network Layer and Transport Layer.
Responsible The sender is responsible for The transport layer is responsible
transmitting extra traffic at receivers transmitting extra traffic into the
side. network.
Preventive The sender transmits the data slowly to Transport layer transmits the data into
measures the receiver. the network slowly.
Methods Feedback-based flow control and Rate- Provisioning, traffic-aware routing
based flow control and admission control
62
9/11/2023
Cont..
Network Performance
• The two major tasks in a network are the Transmission and reception of
information.
• We need to focus on how fast a message is transmitted and how fast a node
can receive a request and find the needed information.
Cont..
63
9/11/2023
Cont..
• Transit Time:
• The total time a node takes to transmit a message from the beginning until
the last character of the message.
• Response Time:
• The total time a node takes to process an inquiry or a request from another
node/ device and respond.
• It is the time between the inquiry's end and the response's beginning.
Cont..
• Throughput:
• Throughput measures how much data is transferred successfully from the
sender node to the receiver node in a particular time frame.
64
9/11/2023
Cont..
• Delay/ Latency:
• As we discussed, Throughput is the number of data packets successfully
delivered in a given time.
Cont..
• Formulas:
65
9/11/2023
Proxy Server
• The proxy server is a computer on the internet that accepts the incoming
requests from the client and forwards those requests to the destination
server.
Cont..
66
9/11/2023
Cont..
Cont..
1. If the requested data or page already exists in the local cache, the proxy
server itself provides the required retrieval to the client.
2. If the requested data or page does not exist in the local cache, the proxy
server forwards that request to the destination server.
3. The proxy servers transfer the replies to the client and also being cached to
them.
67
9/11/2023
Cont..
Cont..
68
9/11/2023
QUESTIONS
1. Write a short note: Transport Layer.
2. List and explain Transport Layer Services.
3. Write a short note: Services Primitives.
4. Explain Multiplexing and Demultiplexing.
5. Draw and explain UDP Header format.
6. Explain Real Time Transport Protocol (RTP).
7. Draw and explain RTP Header Format.
8. Describe Principles of Reliable Data Transfer.
9. Explain Stop and Wait Protocol.
10. Explain Sliding Window Protocols.
11. Explain Types of Sliding Window Protocols.
Cont..
12. Write a short note: Go-Back-N ARQ (Automatic Repeat Request ).
13. Write a short note: Stop and Wait ARQ and Selective Repeat ARQ.
14. Explain TCP Protocol.
15. List and explain Features of TCP protocol.
16. Draw and explain TCP Header format.
17. Write a short note: TCP Connection Termination.
18.Explain TCP Connection (A 3-way handshake).
19. Explain TCP Termination (A 4-way handshake).
20. What is Congestion Control? Explain Types of Congestion control algorithms.
21. Explain Leaky Bucket Algorithm.
22. Explain Token bucket Algorithm.
23. Write a short note: TCP Congestion Control.
24. List and explain Approaches for Congestion Control in TCP.
69
9/11/2023
Cont..
70