0% found this document useful (0 votes)
6 views83 pages

Transport Layer Functions and Protocols

Uploaded by

momoparty10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views83 pages

Transport Layer Functions and Protocols

Uploaded by

momoparty10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Tribhuvan University

Faculty of Humanities and Social Sciences


Bachelor in Computer Application (BCA)
5Th Semester
Computer Networking (CACS-303 )
Unit-5: Transport Layer 7hrs

Instructor
Tekendra Nath Yogi
Tekendranath@[Link]
Contents
• 5.1. Functions of transport Layer.

• 5.2. Elements of Transport Protocols:


– Addressing, Establishing and Releasing Connection, Flow Control and Buffering, Error
Control, Multiplexing and Demultiplexing, Crash Recovery.

• 5.3. User Datagram Protocol:


– User Datagram, UDP Operations, Uses of UDP, RPC.

• 5.4. Transmission Control Protocol (TCP):


– TCP Services, TCP Features, TCP Segment Header.

• 5.5. Principles of Reliable Data Transfer:


– Building a Reliable Data Transfer Protocol, Pipelined Reliable Data Transfer Protocol,
Go-back N(GBN), Selective Repeat(SR).

• 5.6. Principle of Congestion Control

9/15/2024 By: Tekendra Nath Yogi 2


5.1. Functions of Transport Layer
• Transport layer is the 4th layer of the OSI model as shown in figure below:

• The transport layer takes services from the Network layer and provides
services to the session layer.
9/15/2024 By: Tekendra Nath Yogi 3
5.1. Functions of Transport Layer
• At the sender’s side:
– The transport layer receives data (message) from the Session layer and then
performs Segmentation, adds source and destination’s port numbers into the
header of the segment, and transfers the message to the Network layer.

• 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 Session layer.

9/15/2024 By: Tekendra Nath Yogi 4


5.1. Functions of Transport Layer
• The transport layer is mainly responsible for the delivery of a message from
one process to another process.

Figure: Process-to-process delivery of a message

9/15/2024 By: Tekendra Nath Yogi 5


5.1. Functions of Transport Layer
• Other responsibilities of the transport layer include the following:
– Service point addressing
– Segmentation and reassembly
– Connection control.
– Flow control
– Error control
– Reliable data transfer
– Multiplexing and demultiplexing
– Congestion Control
• The services provided by the transport layer are similar to those of the data
link layer. The data link layer provides the services within a single network
while the transport layer provides the services across an internetwork.
9/15/2024 By: Tekendra Nath Yogi 6
5.2. Elements of Transport
Protocols
5.2.1. Addressing
5.2.2. Establishing and Releasing Connection
5.2.3. Flow Control and Buffering
5.2.4. Error Control
5.2.5. Multiplexing and Demultiplexing
[Link] Recovery.
5.2. Elements of Transport Protocols
• Service point addressing or Port Addressing: Transport layer include
source and destination port address in the segment header for process to
process delivery.

9/15/2024 By: Tekendra Nath Yogi 8


5.2. Elements of Transport Protocols
• Segmentation and reassembly
– Sender side: breaks application messages into segments, passes to network
layer by adding transport layer header information.

– Receiver side: reassembles segments into messages, passes to upper layer

Sender Side Receiver side

9/15/2024 By: Tekendra Nath Yogi 9


5.2. Elements of Transport Protocols
• Connection control : It includes 2 types:

– Connectionless : Each segment is considered as an independent packet


and delivered to the transport layer at the destination machine.

– Connection Oriented : Before delivering packets, connection is made


with transport layer at the destination machine.

9/15/2024 By: Tekendra Nath Yogi 10


5.2. Elements of Transport Protocols
• Flow control: Transport layer maintain the pacing of segment transfer
between sender and receiver to prevent the sender from overwhelming the
receiver. It also maintains pacing of data receiving from the upper layers.

Figure: Flow control at the transport layer

• Note: Transport Layer uses stop and wait and, Sliding Window methods for
flow control.

9/15/2024 By: Tekendra Nath Yogi 11


5.2. Elements of Transport Protocols
• Error control: Transport layer performs error detection and correction for
end to end reliable delivery.

Segments

Error Control
Figure: Error control at the transport layer

• Note: Transport Layer uses check sum method for error control.

9/15/2024 By: Tekendra Nath Yogi 12


5.2. Elements of Transport Protocols
• Reliable data transfer:
– Using flow control, sequence numbers, acknowledgments, and timers Transport
layer ensures that data is delivered from sending process to receiving process,
correctly and in order.

9/15/2024 By: Tekendra Nath Yogi 13


5.2. Elements of Transport Protocols
• Congestion Control:
– Congestion in a network may occur if the load on the network is greater than the capacity
of the network.

• Load: the number of packets sent to the network

• Capacity: the number of packets a network can handle

– Transport layer provides the mechanism to keep the load below the capacity.

– This mechanism is known as congestion control

9/15/2024 By: Tekendra Nath Yogi 14


5.2. Elements of Transport Protocols
• Multiplexing and Demultiplexing: Single host may have multiple
application processes running. Need to combine the data from variety of
application processes and send them in one session. This can be achieve by
using multiplexing and demultiplexing.

9/15/2024 By: Tekendra Nath Yogi 15


5.2. Elements of Transport Protocols
• Multiplexing at sender:

– Gathering data from multiple application processes of the sender,


enveloping that data with a header, and sending them as a whole to the
intended receiver is called multiplexing.

• Demultiplexing at receiver:

– Remove the envelop of the data and use header info to deliver received
segments to correct socket

9/15/2024 By: Tekendra Nath Yogi 16


5.2. Elements of Transport Protocols
• Crash Recovery: No matter how well the client and the server are
programmed, there are situations in which the transport layer’s protocols fail to
fine-tune.

• For example,

9/15/2024 By: Tekendra Nath Yogi 17


5.2. Elements of Transport Protocols
• Crash recovery at the transport layer involves a combination of following
techniques to ensure reliable communication even in the face of failures. :

– Three-Way Handshake: Establishes a connection and ensures that both


parties are ready to communicate. Communicate using the established
connection and at the end close the connection.

– Sequence Numbering, Acknowledgments and retransmission: Ensure data is


delivered correctly and in order.

– State management by using checkpoint in order to periodically save state to


enable recovery in case of a crash.

– Error detection and correction.

9/15/2024 By: Tekendra Nath Yogi 18


5.3. User Datagram Protocol:

5.3.1. User Datagram


5.3.2. UDP Operations
5.3.3. Uses of UDP
5.3.4. RPC.
5.3. Transport Protocols: TCP and UDP
• The Transport layer protocols are responsible for transport layer services.

• The transport layer protocols are implemented in the end systems but not in
the network routers.

• The two most important protocols in the Transport Layer are:

– Transmission Control Protocol (TCP) for reliable and connection


oriented services and

– User Datagram Protocol (UDP) for unreliable and connectionless


services.

9/15/2024 By: Tekendra Nath Yogi 20


5.3. Transport Protocols: UDP
• UDP is a 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.
• It provides process-to-process delivery, rudimentary error control,
multiplexing/demultiplexing, and queuing services.
• UDP Features:
– Connectionless services
– Unreliable: best effort service, UDP segments may be lost or delivered .
– Simple: No connection state at sender and receiver
– Small header size : have a fixed-size header of 8 bytes only.
– No congestion control: UDP can blast away as fast as desired
– There is no error control mechanism in UDP except for the checksum
– There is no flow control

9/15/2024 By: Tekendra Nath Yogi 21


5.3. Transport Protocols: User Datagram
• Also known as UDP Segment. Its header size is 8 bytes, and the packet size is up to
65,535 bytes.

Figure: User datagram format


• The UDP header contains four fields:
– Source port number: It identifies which port is going to send the packet.
– Destination port number: It identifies which port is going to accept the information.
– Length: It specifies the entire length of the UDP packet that includes the header also.
– Checksum: It is an optional field to check whether the information is accurate or not as
there is the possibility that the information can be corrupted while transmission.
9/15/2024 By: Tekendra Nath Yogi 22
5.3.2. UDP Operations
• To send a message from one process to another, the UDP protocol
encapsulates and decapsulates messages.

9/15/2024 By: Tekendra Nath Yogi 23


Contd…
• Queuing:

9/15/2024 By: Tekendra Nath Yogi 24


Contd…
• Multiplexing and Demultiplexing

9/15/2024 By: Tekendra Nath Yogi 25


5.3.3. Uses of UDP
• UDP is mainly used by loss tolerant, rate sensitive applications such as:

– DNS

– RIP

– SNMP

– Multicasting Protocols and

– Streaming multimedia applications

9/15/2024 By: Tekendra Nath Yogi 26


5.3.4. Remote Procedure Call (RPC)
• mechanism that allows a
program to execute a procedure
on a remote server based on the
call made from the local client.
• Works as:
– Local procedure make Call,
marshalling of parameter by client
stub, transmission through network.
– Server Receive, Unmarshalling of
parameters by server stub, procedure
execution, and response to client by
marshaling the result.
– Client receive response,
Unmarshalling the result and return
to the calling procedure.

9/15/2024 By: Tekendra Nath Yogi 27


5.4. Transmission Control
Protocol (TCP):
5.5.1. TCP Services
5.5.2. TCP Features
5.5.3. TCP Segment Header.
5.4. Transmission Control Protocol (TCP)
• The Transmission Control Protocol (TCP) is a connection-oriented
protocol; it creates a virtual connection between two hosts to send data. In
addition, TCP uses flow and error control mechanisms at the transport
level.
– point-to-point: one sender, one receiver

– reliable, in-order byte steam: no “message boundaries”

– full duplex data: bi-directional data flow in same connection.

– connection-oriented: handshaking (exchange of control messages) initialize


sender and receiver state before data exchange.

– flow controlled: sender will not overwhelm receiver.

– pipelined: TCP congestion and flow control set window size.

9/15/2024 By: Tekendra Nath Yogi 29


5.4. Transmission Control Protocol (TCP): Services
• Process-to-Process Communication

• Stream Delivery Service

• Full-Duplex Communication

• Multiplexing and Demultiplexing

• Connection-Oriented Service

• Reliable Service

9/15/2024 By: Tekendra Nath Yogi 30


5.4. Transmission Control Protocol (TCP): Features
• TCP characterized by the following features:

– Numbering System

– Flow Control

– Error Control

– Congestion Control

9/15/2024 By: Tekendra Nath Yogi 31


5.4. Transmission Control Protocol (TCP): TCP Segment Header

Figure: TCP segment format


9/15/2024 By: Tekendra Nath Yogi 32
5.4. Transmission Control Protocol (TCP): TCP Segment Header
• Source port: It defines the port of the application, which is sending the data.

• Destination port: It defines the port of the application on the receiving side.

• Sequence number: This field contains the sequence number of Segment in a


particular session.

• Acknowledgment number: When the ACK flag is set, then this field contains
the next sequence number of the segment and works as an acknowledgment for
the previous data received.

• HLEN: It specifies the length of the header indicated by the 4-byte words in
the header. The size of the header lies between 20 - 60 bytes.

• Reserved: It is a 4-bit field reserved for future use. By default, all are set to
zero.

9/15/2024 By: Tekendra Nath Yogi 33


5.4. Transmission Control Protocol (TCP): TCP Segment Header

• Flags: There are six control bits or flags:


• URG: It represents an urgent pointer. If it is set, then the data is
processed urgently.

• ACK: If the ACK is set to 0, then it means that the data packet does not
contain an acknowledgment.

• PSH: If this field is set, then it requests the receiving device to push the
data to the receiving application without buffering it.

• RST: If it is set, then it requests to restart a connection.

• SYN: It is used to establish a connection between the hosts.

• FIN: It is used to release a connection, and no further data exchange


will happen.

9/15/2024 By: Tekendra Nath Yogi 34


5.4. Transmission Control Protocol (TCP): TCP Segment Header

• Window size: It contains the size of data that the receiver can accept.

• Checksum: Contains checksum for error detection and correction.

• Urgent pointer: It is a pointer that points to the urgent data byte if the

URG flag is set to 1.

• Options: It provides additional options.

9/15/2024 By: Tekendra Nath Yogi 35


5.5. Principles of Reliable Data
Transfer:
5.4.1. Building a Reliable Data Transfer Protocol
5.4.2. Pipelined Reliable Data Transfer Protocol
5.4.3. Go-back N(GBN)
5.4.4. Selective Repeat(SR).
5.5.1. Building a Reliable Data Transfer Protocol
▪ Transport layer provides reliable transport service as shown in figure below.

Figure: Reliable data transfer: service provided or model

9/15/2024 By: Tekendra Nath Yogi 3-37


5.5.1. Building a Reliable Data Transfer Protocol
• However, the service implementation is not straight forward as shown in figure
below:

Sender side Receiver side

Figure: Reliable data transfer: service implementation

9/15/2024 By: Tekendra Nath Yogi 3-38


5.5.1. Building a Reliable Data Transfer Protocol
• rdt_send(): called from above, (e.g., by app.). Passed data to a deliver to
receiver upper layer.

• udt_send(): called by reliable data transfer (rdt) protocol, to transfer packet


over unreliable channel to receiver.

• rdt_rcv(): called when packet arrives on receiver-side of channel.

• deliver_data(): called by rdt to deliver data to upper layer.

• Characteristics of unreliable channel determines complexity of rdt.

9/15/2024 By: Tekendra Nath Yogi 3-39


5.5.1. Building a Reliable Data Transfer Protocol --
rdt1.0: reliable transfer over a reliable channel
▪ Assumption: Underlying channel perfectly reliable

• No bit errors

• No loss of packets

▪ Working:

• Sender sends data into underlying channel

• Receiver reads data from underlying channel

Wait for rdt_send(data) Wait for rdt_rcv(packet)


call from call from extract (packet,data)
above packet = make_pkt(data) below deliver_data(data)
udt_send(packet)
sender receiver
Figure : rdt1.0 - a protocol for a completely reliable channel
9/15/2024 By: Tekendra Nath Yogi 3-40
5.5.1. Building a Reliable Data Transfer Protocol –
rdt2.0: channel with bit errors

▪ Assumption: Underlying channel may flip bits in packet.

▪ Working: Similar functionality as the rdt1.0 with additional new


mechanisms to recover from errors:

1. Error detection: checksum to detect bit errors.

2. Feedback: control messages (ACK,NAK) from receiver to sender.

• Acknowledgements (ACKs): receiver explicitly tells sender that packet


received OK.

• Negative acknowledgements (NAKs): receiver explicitly tells sender that


packet had errors.

• Sender retransmits packet on receipt of NAK.

9/15/2024 By: Tekendra Nath Yogi 3-41


5.5.1. Building a Reliable Data Transfer Protocol –
rdt2.0: channel with bit errors –Operation with no errors and Error Scenario

rdt_send(data)
sndpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt) Error
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) Scenario corrupt(rcvpkt)
above NAK
udt_send(NAK)

rdt_rcv(rcvpkt) && isACK(rcvpkt)


Wait for
 call from
below
Operation with no errors
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
Figure: rdt2.0 - a protocol for a channel with bit-errors
9/15/2024 By: Tekendra Nath Yogi 3-42
5.5.1. Building a Reliable Data Transfer Protocol –
rdt2.0: channel with bit errors –Has fatal flaw!!!

What happens if ACK/NAK Handling duplicates:

corrupted? • Sender retransmits current packet if


• sender does ’ t know ACK/NAK corrupted.
what happened at
receiver!
• While sending, Sender adds
• Can’t just retransmit:
sequence number to each packet.
retransmission causes
duplicate delivery of
same packet. • Receiver discards duplicate packet.

9/15/2024 By: Tekendra Nath Yogi 3-43


5.5.1. Building a Reliable Data Transfer Protocol –
rdt2.1: Sender, Handles garbled ACK/NAKs

rdt_send(data)
sndpkt = make_pkt(0, data, checksum)
udt_send(sndpkt) rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) ||
Wait for Wait for
isNAK(rcvpkt) )
call 0 from ACK or
NAK 0 udt_send(sndpkt)
above
rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt) rdt_rcv(rcvpkt)
&& isACK(rcvpkt) && notcorrupt(rcvpkt)
&& isACK(rcvpkt)


Wait for Wait for
ACK or call 1 from
rdt_rcv(rcvpkt) && NAK 1 above
( corrupt(rcvpkt) ||
isNAK(rcvpkt) ) rdt_send(data)
sndpkt = make_pkt(1, data, checksum)
udt_send(sndpkt)
udt_send(sndpkt)

9/15/2024 By: Tekendra Nath Yogi 3-44


5.5.1. Building a Reliable Data Transfer Protocol –
rdt2.1: Receiver, Handles garbled ACK/NAKs
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
&& has_seq0(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) rdt_rcv(rcvpkt) && (corrupt(rcvpkt)
sndpkt = make_pkt(NAK, chksum) sndpkt = make_pkt(NAK, chksum)
udt_send(sndpkt) udt_send(sndpkt)
Wait for Wait for
rdt_rcv(rcvpkt) && 0 from 1 from rdt_rcv(rcvpkt) &&
not corrupt(rcvpkt) && below below not corrupt(rcvpkt) &&
has_seq1(rcvpkt) has_seq0(rcvpkt)
sndpkt = make_pkt(ACK, chksum) sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt) udt_send(sndpkt)
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
&& has_seq1(rcvpkt)

extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)

9/15/2024 By: Tekendra Nath Yogi 3-45


5.5.1. Building a Reliable Data Transfer Protocol –
rdt2.2: a NAK-free Protocol

▪ Same functionality as rdt2.1, using ACKs only.

▪ Instead of NAK, receiver sends ACK for last packet received OK.

• Receiver must explicitly include sequence number of packet being


ACKed.

▪ Duplicate ACK at sender results in same action as NAK: retransmit current


packet

9/15/2024 By: Tekendra Nath Yogi 3-46


5.5.1. Building a Reliable Data Transfer Protocol –
rdt2.2: Sender, receiver fragments
rdt_send(data)
sndpkt = make_pkt(0, data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) ||
Wait for Wait for isACK(rcvpkt,1) )
call 0 from ACK
above 0 udt_send(sndpkt)
sender FSM
fragment rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt)
rdt_rcv(rcvpkt) && && isACK(rcvpkt,0)
(corrupt(rcvpkt) || 
has_seq1(rcvpkt)) Wait for receiver FSM
0 from
udt_send(sndpkt) below fragment
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)
&& has_seq1(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK1, chksum)
udt_send(sndpkt)
9/15/2024 By: Tekendra Nath Yogi 3-47
5.5.1. Building a Reliable Data Transfer Protocol –
rdt3.0: Channels with errors and loss

• New assumption: • Approach: Sender waits “ reasonable ”

• Underlying channel can amount of time for ACK.

also lose packets (data, • Retransmits if no ACK received in this time


ACKs) • If packet (or ACK) just delayed (not lost):
– checksum, sequence – retransmission will be duplicate, but
number, ACKs, sequence number’s already handles this

retransmissions can – receiver must specify sequence numbers of

be helpful but not packet being ACKed

enough. • Requires countdown timer

9/15/2024 By: Tekendra Nath Yogi 3-48


5.5.1. Building a Reliable Data Transfer Protocol –
rdt3.0: Sender
rdt_send(data)
rdt_rcv(rcvpkt) &&
sndpkt = make_pkt(0, data, checksum) ( corrupt(rcvpkt) ||
udt_send(sndpkt) isACK(rcvpkt,1) )
rdt_rcv(rcvpkt) start_timer 
 Wait for Wait
for timeout
call 0from udt_send(sndpkt)
above ACK0
start_timer
rdt_rcv(rcvpkt)
&& notcorrupt(rcvpkt) rdt_rcv(rcvpkt)
&& isACK(rcvpkt,1) && notcorrupt(rcvpkt)
stop_timer && isACK(rcvpkt,0)
stop_timer
Wait
timeout Wait for
for
call 1 from
udt_send(sndpkt) ACK1
above rdt_rcv(rcvpkt)
start_timer
rdt_send(data) 
rdt_rcv(rcvpkt) &&
( corrupt(rcvpkt) || sndpkt = make_pkt(1, data, checksum)
isACK(rcvpkt,0) ) udt_send(sndpkt)
start_timer

9/15/2024 By: Tekendra Nath Yogi 3-49


5.5.1. Building a Reliable Data Transfer Protocol –
rdt3.0: In action

sender receiver sender receiver


send pkt0 pkt0 send pkt0 pkt0
rcv pkt0 rcv pkt0
ack0 send ack0 ack0 send ack0
rcv ack0 rcv ack0
send pkt1 pkt1 send pkt1 pkt1
rcv pkt1 X
ack1 send ack1 loss
rcv ack1
send pkt0 pkt0
rcv pkt0 timeout
ack0 send ack0 resend pkt1 pkt1
rcv pkt1
ack1 send ack1
rcv ack1
send pkt0 pkt0
(a) no loss rcv pkt0
ack0 send ack0

(b) packet loss


9/15/2024 By: Tekendra Nath Yogi 3-50
5.5.1. Building a Reliable Data Transfer Protocol –
rdt3.0: In action
sender receiver
sender receiver send pkt0 pkt0
send pkt0 pkt0 rcv pkt0
ack0 send ack0
rcv pkt0
send ack0 rcv ack0
ack0 send pkt1 pkt1
rcv ack0 rcv pkt1
send pkt1 pkt1
rcv pkt1 send ack1
ack1 ack1
send ack1
X
loss timeout
resend pkt1 pkt1
rcv pkt1
timeout
resend pkt1 pkt1 rcv ack1 pkt0 (detect duplicate)
rcv pkt1 send pkt0 send ack1
(detect duplicate) ack1
ack1 send ack1 rcv ack1 rcv pkt0
rcv ack1 ack0 send ack0
pkt0 send pkt0 pkt0
send pkt0 rcv pkt0
rcv pkt0 ack0 (detect duplicate)
ack0 send ack0 send ack0

(c) ACK loss (d) premature timeout/ delayed ACK

9/15/2024 By: Tekendra Nath Yogi 3-51


5.5.2. Pipelined Reliable Data Transfer Protocol
• Pipelining: sender allows multiple, “in-flight”, yet-to-be-acknowledged
packets.

– Buffering at sender and/or receiver.

Figure : Stop-and-wait versus pipelined protocols

▪ Two generic forms of pipelined protocols: go-Back-N, selective repeat


9/15/2024 By: Tekendra Nath Yogi 3-52
5.5.3. Go-back N(GBN)
• Sender can have up to N unacknowledged packets in pipeline.

– That is, sender has “window” of up to N.

– Allows N unacknowledged packets in transmission pipeline.

• Receiver only sends cumulative acknowledge - ACKs all packets up to,

including sequence number n.

• Sender has timer for oldest unacknowledged packet

– when timer expires, retransmit all unacknowledged packets

9/15/2024 By: Tekendra Nath Yogi 53


5.5.3. Go-back N(GBN)

9/15/2024 By: Tekendra Nath Yogi 3-54


5.5.3. Go-back N(GBN) – Sender
rdt_send(data)
if (nextseqnum < base+N) {
sndpkt[nextseqnum] = make_pkt(nextseqnum,data,chksum)
udt_send(sndpkt[nextseqnum])
if (base == nextseqnum)
start_timer
nextseqnum++
}
else
refuse_data(data)
base=1
nextseqnum=1
timeout
start_timer
Wait udt_send(sndpkt[base])
rdt_rcv(rcvpkt) udt_send(sndpkt[base+1])
&& corrupt(rcvpkt) …
udt_send(sndpkt[nextseqnum-1])
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
base = getacknum(rcvpkt)+1
If (base == nextseqnum)
stop_timer
else
start_timer
9/15/2024 By: Tekendra Nath Yogi 3-55
5.5.3. Go-back N(GBN) – Receiver
default
udt_send(sndpkt) rdt_rcv(rcvpkt)
&& notcurrupt(rcvpkt)
&& hasseqnum(rcvpkt,expectedseqnum)
expectedseqnum=1 Wait extract(rcvpkt,data)
sndpkt = deliver_data(data)
make_pkt(expectedseqnum,ACK,chksum) sndpkt = make_pkt(expectedseqnum,ACK,chksum)
udt_send(sndpkt)
expectedseqnum++

• ACK-only: always send ACK for correctly-received packet with highest in-
order sequence number.
– need only remember expected sequence number

• Out-of-order packet:
– Discard (don’t buffer): no receiver buffering!
– Re-ACK packet with highest in-order sequence number
9/15/2024 By: Tekendra Nath Yogi 3-56
5.5.3. Go-back N(GBN) – In Action

sender window (N=4) sender receiver


012345678 send pkt0
012345678 send pkt1
send pkt2 receive pkt0, send ack0
012345678
send pkt3 Xloss receive pkt1, send ack1
012345678
(wait)
receive pkt3, discard,
012345678 rcv ack0, send pkt4 (re)send ack1
012345678 rcv ack1, send pkt5 receive pkt4, discard,
(re)send ack1
ignore duplicate ACK receive pkt5, discard,
(re)send ack1
pkt 2 timeout
012345678 send pkt2
012345678 send pkt3
012345678 send pkt4 rcv pkt2, deliver, send ack2
012345678 send pkt5 rcv pkt3, deliver, send ack3
rcv pkt4, deliver, send ack4
rcv pkt5, deliver, send ack5

9/15/2024 By: Tekendra Nath Yogi 3-57


5.5.4. Selective Repeat(SR)
• Receiver individually acknowledges all correctly received packets

– buffers packets, as needed, for eventual in-order delivery to upper layer

• Sender only resends packets for which ACK not received

– sender timer for each unACKed packet

• Sender window:

– N consecutive sequence number’s

– limits sequence numbers of sent, unACKed packets

9/15/2024 By: Tekendra Nath Yogi 58


5.5.4. Selective Repeat(SR) – Sender, Receiver Windows

9/15/2024 By: Tekendra Nath Yogi 3-59


5.5.4. Selective Repeat(SR) – In Action

sender window (N=4) sender receiver


012345678 send pkt0
012345678 send pkt1
send pkt2 receive pkt0, send ack0
012345678
send pkt3 Xloss receive pkt1, send ack1
012345678
(wait)
receive pkt3, buffer,
012345678 rcv ack0, send pkt4 send ack3
012345678 rcv ack1, send pkt5 receive pkt4, buffer,
send ack4
record ack3 arrived receive pkt5, buffer,
send ack5
pkt 2 timeout
012345678 send pkt2
012345678 record ack4 arrived
012345678 rcv pkt2; deliver pkt2,
record ack5 arrived
012345678 pkt3, pkt4, pkt5; send ack2

9/15/2024 By: Tekendra Nath Yogi 3-60


5.6. Principle of Congestion
Control:
5.6.1. Congestion Control
5.6.2. Principles of Congestion Control
5.6.3. Congestion Control Mechanisms
5.6.4. Techniques to improve QoS
5.6.1 Congestion Control
• Congestion in a network may occur if the load on the network is greater
than the capacity of the network.

– Load: the number of packets sent to the network

– Capacity: the number of packets a network can handle

• Congestion control refers to the mechanism to keep the load below the
capacity.

– can either prevent congestion, before it happens, or

– remove congestion, after it has happened.

9/15/2024 By: Tekendra Nath Yogi 62


5.6.2 Principles of Congestion Control
• Congestion Control Principles are the broad, theoretical guidelines that
underpin the design and implementation of congestion control mechanisms.

• Major congestion control principles includes the following:


– Avoidance and Prevention: Early detection, traffic shaping and rate limiting.

– Adaptive response: dynamic adjustment and feedback mechanisms.

– Fairness: Equitable resource allocation and bandwidth allocation.

– Scalability: Efficient and scalable mechanisms.

– Robustness and Resilience: Handling variability and fault tolerance.

– Resource optimization: Utilize available resources and load balancing.

– Transparency: Protocol transparency and minimal impact on other layers.

– Predictability: Consistent performance and stable operations.

9/15/2024 By: Tekendra Nath Yogi 63


5.6.3. Congestion Control Mechanism
• In general, congestion control mechanisms can be divide into two broad
categories as shown below:

Figure: Congestion control mechanisms

9/15/2024 By: Tekendra Nath Yogi 64


5.6.3. Congestion Control Mechanism – Open Loop
• Open-loop congestion control also known as congestion prevention
methods.

• Make scheduling decisions at various points in the network without regard


to the current state of the network.

• Such decisions are:


– When to accept new traffic.

– When to discard packets and which ones.

9/15/2024 By: Tekendra Nath Yogi 65


5.6.3. Congestion Control Mechanism – Open Loop
• Retransmission policy: to optimize efficiency and reduce congestion set
proper retransmission policy and timers.

• Windows policy: Type of window at sender may also affect congestion.


Selective repeat is better than Go-Back-N.

• Acknowledgement policy: Policy set by receiver may also affect


congestion. If receiver does not acknowledge every packet it receives, it
may slow down the sender and help prevent congestion.

• Discard policy: Discard less sensitive packets [in audio transmission] at


routers.

• Admission policy: first check the resource requirement of a flow before


admitting it to the network.

9/15/2024 By: Tekendra Nath Yogi 66


5.6.3. Congestion Control Mechanism – Closed Loop
• Closed-loop congestion control (removal) are based on the concept of a
feedback loop. This approach has three steps:

1. Monitor the system to detect when and where congestion occurs.

2. Pass this information to places where action can be taken.

3. Adjust system operation to correct the problem.

9/15/2024 By: Tekendra Nath Yogi 67


5.6.3. Congestion Control Mechanism – Closed Loop: Back Pressure
• When a router is congested, it can inform the previous upstream router to
reduce the rate of outgoing packets. The action can be recursive all the way
to the source.

Figure: Backpressure method for alleviating congestion

9/15/2024 By: Tekendra Nath Yogi 68


5.6.3. Congestion Control Mechanism – Closed Loop: Choke Packet
• Control packet Generated at congested node and Sent to source node to
inform it of congestion.

Figure: Choke packet

9/15/2024 By: Tekendra Nath Yogi 69


5.6.3. Congestion Control Mechanism – Closed Loop
• Implicit Signalling: Source can detect an implicit signal concerning
congestion and slow down its sending rate.
– For example, the mere delay in receiving an acknowledgement can be a signal that the
network is congested.

• Explicit Signalling: Routers that experience congestion can send an explicit


signal, the setting of a bit in a packet.
– For example, to inform the sender or the receiver of congestion.

9/15/2024 By: Tekendra Nath Yogi 70


5.6.4 Techniques to improve QoS
• Quality of Service (QoS) is defined as something a network traffic seeks to
attain and ensure the performance of critical applications.

• The main goal of QoS is to reduce interference like packet loss, bit rate,
throughput, transmission delay, availability, etc in the network.

• For this, traffic prioritization and resource reservation control mechanisms


are used.

• Four common Techniques to improve the QoS:


– Scheduling

– Traffic shaping

– Admission control, and

– Resource reservation.

9/15/2024 By: Tekendra Nath Yogi 71


5.6.4 Techniques to improve QoS: Scheduling
• Three Types of Scheduling Algorithms:

– First-in first-out (FIFO)queuing

– Priority queuing

– Weighted Fair queuing

9/15/2024 By: Tekendra Nath Yogi 72


5.6.4 Techniques to improve QoS: Scheduling
• First-in first-out (FIFO)queuing:

– First admitted packet in the queue is first serviced by the node.

– Packets wait in a buffer queue until the node (router or switch) is ready
to process them.

– If average arrival rate is higher than average processing rate, the queue
will fill up and new packets will be discarded.

Figure: FIFO queue


9/15/2024 By: Tekendra Nath Yogi 73
5.6.4 Techniques to improve QoS: Scheduling
• Priority Queuing:
– Packets are first assigned to a priority class. Each priority class has its own queue.

– Packets in highest-priority queue are processed first. Packets in lowest-priority queue are
processed last. System does not stop serving a queue until it is empty.

– Starvation is possible: If there is a continuous flow in a high-priority queue, the packets


in lower-priority queues will never have a chance to be processed.

Figure: Priority queuing


9/15/2024 By: Tekendra Nath Yogi 74
5.6.4 Techniques to improve QoS: Scheduling
• Weighted Fair Queuing: Packets are assigned to different classes and
admitted to different queues. System processes packets in each queue in
round-robin fashion with the number of packets selected from each queue
based on the corresponding weight.

Figure: Weighted fair queuing


9/15/2024 By: Tekendra Nath Yogi 75
5.6.4 Techniques to improve QoS: Traffic Shaping Algorithms
• Traffic shaping: Mechanism to control the amount and rate of the traffic
sent to the network.

• Two Techniques for Traffic Shaping


– Leaky Bucket

– Token Bucket

9/15/2024 By: Tekendra Nath Yogi 76


5.6.4 Techniques to improve QoS: Traffic Shaping Algorithms
• A leaky bucket algorithm shapes bursty traffic into fixed-rate traffic by
averaging the data rate. It may drop the packets if the bucket is full.

Figure: Leaky bucket


9/15/2024 By: Tekendra Nath Yogi 77
5.6.4 Techniques to improve QoS: Traffic Shaping Algorithms

Figure: Leaky bucket implementation

9/15/2024 By: Tekendra Nath Yogi 78


5.6.4 Techniques to improve QoS: Traffic Shaping Algorithms
• The token bucket allows bursty traffic at a regulated maximum rate.

Figure: Token bucket


9/15/2024 By: Tekendra Nath Yogi 79
5.6.4 Techniques to improve QoS: Admission Control
• Mechanism used by a router, or a switch, to accept or reject a flow based on
predefined parameters called flow specifications.

• Before a router accepts a flow for processing, it checks the flow


specifications to see if its capacity (in terms of bandwidth, buffer size, CPU
speed, etc.) and its previous commitments to other flows can handle the
new flow.

9/15/2024 By: Tekendra Nath Yogi 80


5.6.4 Techniques to improve QoS: Resource Reservation
• Flow of data needs resources such as a buffer, bandwidth, CPU time, and
so on. Resources are reserved beforehand.

• For example:

9/15/2024 By: Tekendra Nath Yogi 81


Homework
• What is transport layer? Explain the functions and services of Transport
layer in detail.

• What is TCP? Explain the header structure of TCP in detail.

• What is UDP? Explain the header structure of UDP in detail.

• What is connection oriented and connection less services? How connection


oriented services provided by the transport layer? Explain.

• Explain the congestion control principle and its approaches.

• Explain the connection oriented and connectionless services.

• Differentiate between network layer and transport layer.

9/15/2024 By: Tekendra Nath Yogi 82


Thank You !

9/15/2024 By: Tekendra Nath Yogi 83

You might also like