0% found this document useful (0 votes)
15 views21 pages

Lecture - 11 - Chapter 3 - 01 Oct 2024

Uploaded by

Usman Butt
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)
15 views21 pages

Lecture - 11 - Chapter 3 - 01 Oct 2024

Uploaded by

Usman Butt
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
You are on page 1/ 21

National University of

Computer & Emerging Sciences


CS 3001 – COMPUTER NETWORKS

Lecture 11
Chapter 3

1st October, 2024

Nauman Moazzam Hayat


[email protected]
Office Hours: 02:00 pm till 04:30 pm (Every Tuesday & Thursday)
Chapter 3
Transport Layer
A note on the use of these PowerPoint slides:
We’re making these slides freely available to all (faculty, students,
readers). They’re in PowerPoint form so you see the animations; and
can add, modify, and delete slides (including this one) and slide
content to suit your needs. They obviously represent a lot of work on
our part. In return for use, we only ask the following:
 If you use these slides (e.g., in a class) that you mention their
source (after all, we’d like people to use our book!)
 If you post any slides on a www site, that you note that they are
adapted from (or perhaps identical to) our slides, and note our
copyright of this material.
Computer Networking: A
For a revision history, see the slide note for this page.
Top-Down Approach
Thanks and enjoy! JFK/KWR 8th edition
All material copyright 1996-2023
Jim Kurose, Keith Ross
J.F Kurose and K.W. Ross, All Rights Reserved Pearson, 2020

Transport Layer: 3-2


Two generic Forms of Pipelined Protocols
are:

- go-Back-N (GBN ), also called sliding window protocol &

- selective repeat (SR)


Go-Back-N: sender (GBN , Sliding Window)
 sender: “window” of up to N, consecutive transmitted but unACKed pkts
 If N = 1, it becomes a Stop & Wait Protocol (thus N should always be greater than 1
to implement pipelining.)
• k-bit seq # in pkt header, range of sequence numbers is [0, 2k -1]

 cumulative ACK: ACK(n): ACKs all packets up to, including seq # n


• on receiving ACK(n): move window forward to begin at n+1 (TCP uses cumulative ACKs)
 timer for oldest in-flight packet
 timeout(n): retransmit packet n and all higher seq # packets in window

Transport Layer: 3-4


Go-Back-N: sender
 Invocation from above
 When rdt_sent() is called, checks if window is full
 If not full, a packet is created and sent
 Receipt of an ACK
 Cumulative acknowledgement: ack with seq number n means all
previous packets has been received at receiver
 A timeout event
 All previous packets that have been sent, their acknowledgements have
not been received will be resent

4 Ranges of Sequence Numbers

1. [0, base -1]  are packets with sequence numbers sent & ACKed.
2. [base, nextseqnum - 1]  are sequence numbers sent but not yet
ACKed (inflight.)
3. [nextseqnum, base + N - 1]  are sequence numbers that can be
sent immediately if more data arrives from the App layer.
4. [>=, base + N]  are sequence numbers that can’t be used until an
unACKed packet is ACKed. Transport Layer 3-6
Go-Back-N: receiver
 ACK-only: always send ACK for correctly-received packet so far, with
highest in-order seq #
• may generate duplicate ACKs
• need only remember rcv_base
 on receipt of out-of-order packet:
• can discard (don’t buffer) or buffer: an implementation decision
• re-ACK pkt with highest in-order seq #

Receiver view of sequence number space:


received and ACKed

… … Out-of-order: received but not ACKed

rcv_base
Not received
Transport Layer: 3-7
Go-Back-N in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, discard,
012345678 rcv ack0, send (re)send ack1
012345678 pkt4
rcv ack1, send receive pkt4, discard,
pkt5 (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

Transport Layer: 3-8


Selective repeat: the approach
pipelining: multiple packets in flight
receiver individually ACKs all correctly received packets
• buffers packets, as needed, for in-order delivery to upper layer
sender:
• maintains (conceptually) a timer for each unACKed pkt
• timeout: retransmits single unACKed packet associated with timeout
• maintains (conceptually) “window” over N consecutive seq #s
• limits pipelined, “in flight” packets to be within this window

Transport Layer: 3-9


Selective repeat: sender, receiver windows

Sender window size = Receiver window size =N


Transport Layer: 3-10
Selective repeat: sender and receiver
sender receiver
data from above: packet n in [rcvbase, rcvbase+N-1]
 if next available seq # in  send ACK(n)
window, send packet  out-of-order: buffer
timeout(n):  in-order: deliver (also deliver
buffered, in-order packets),
 resend packet n, restart timer advance window to next not-yet-
ACK(n) in [sendbase,sendbase+N-1]: received packet
 mark packet n as received packet n in [rcvbase-N,rcvbase-1]
 if n smallest unACKed packet,  ACK(n)
advance window base to next otherwise:
unACKed seq #  ignore

Transport Layer: 3-11


Selective Repeat in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, buffer,
012345678 rcv ack0, send send ack3
012345678 pkt4
rcv ack1, send
receive pkt4, buffer,
pkt5
record ack3 arrived send ack4
receive pkt5, buffer,
pkt 2 timeout send ack5
012345678 send pkt2
012345678 (but not 3,4,5)
012345678 rcv pkt2; deliver pkt2,
012345678 pkt3, pkt4, pkt5; send ack2

Q: what happens when ack2 arrives?

Transport Layer: 3-12


sender window receiver window
Selective repeat: (after receipt) (after receipt)

pkt0
a dilemma! 0123012
0123012 pkt1 0123012
0123012 pkt2 0123012

example: 0123012 pkt3


0123012

X
 seq #s: 0, 1, 2, 3 (base 4 counting) 0123012
pkt0 will accept packet
 window size=3 (a) no problem
with seq number 0

0123012 pkt0
0123012 pkt1 0123012
0123012 pkt2 X 0123012
X 0123012
X
timeout
retransmit pkt0
0123012 pkt0
will accept packet
with seq number 0
(b) oops!
Transport Layer: 3-13
sender window receiver window
Selective repeat: (after receipt) (after receipt)

pkt0
a dilemma! 0123012
0123012 pkt1 0123012
0123012 pkt2 0123012

example: 0123012 pkt3


0123012

X
 seq #s: 0, 1, 2, 3 (base 4 counting)  0receiver
123012
can’t
pkt0 will accept packet
 window size=3 see sender side with seq number 0
(a) no problem
 receiver
behavior
identical in both
cases!
0something’s
123012 pkt0
Q: what relationship is needed 0(very)
1 2 3 0 1wrong!
2 pkt1 0123012
pkt2 X
between sequence # size and 0123012
X
0123012
0123012
window size to avoid problem X
timeout
in scenario (b)? retransmit pkt0
0123012 pkt0
will accept packet
with seq number 0
(b) oops!
Transport Layer: 3-14
Selective repeat: sender window receiver window

dilemma (after receipt) (after receipt)

example: 0123012 pkt0


pkt1
seq #’s: 0, 1, 2, 3 0123012 0123012

0123012 pkt2 0123012
 window size=3 0123012
 receiver sees no 0123012 pkt3
X
difference in two 0123012
pkt0 will accept packet
scenarios! with seq number 0
(a) no problem
 duplicate data
accepted as new in receiver can’t see sender side.
receiver behavior identical in both cases!
(b) (new packet or retransmission?) something’s (very) wrong!
Q: what relationship
between seq # size 0123012 pkt0

and window size to 0123012 pkt1 0123012

avoid problem in (b)? 0123012 pkt2 0123012


X 0123012
Window size should be less than or
equal to half the sequence number X
space in SR protocol.This is to avoid timeout
packets being recognized incorrectly. retransmit pkt0 X
If the windows size is greater than 0123012 pkt0
half the sequence number space, then will accept packet
if an ACK is lost, the sender may send with seq number 0
new packets that the receiver believes
(b) oops!
are retransmissions.
Transport Layer 3-15
Major Differences between Stop & Wait, Go-Back-N (GBN) and
Selective Repeat (SR) [1/2]
- Stop and Wait
The sender sends the packet and waits for the ACK (acknowledgement) of
the packet. Once the ACK reaches the sender, it transmits the next
packet in row. If the ACK is not received, it re-transmits the previous
packet again.

- Go Back N
The sender sends N packets which is equal to the window size. Once the
entire window is sent, the sender then waits for a cumulative ACK to
send more packets. On the receiver end, it receives only in-order
packets and discards out-of-order packets. As in case of packet loss,
the entire window would be re-transmitted.

- Selective Repeat
The sender sends packet of window size N and the receiver acknowledges
all packet whether they were received in order or not. In this case,
the receiver maintains a buffer to contain out-of-order packets and
sorts them. The sender selectively re-transmits the lost packet and
moves the window forward.

URL for Interactive Animations:


https://wps.pearsoned.com/ecs_kurose_compnetw_6/216/55463/14198702.cw/inde
x.html
Differences between Stop & Wait, Go-Back-N
(GBN) and Selective Repeat (SR) [2/2]
Where,
• a = Ratio of Propagation delay
and Transmission delay

• At N=1, Go Back N is
effectively reduced to Stop
and Wait

• As Go Back N acknowledges
the packets cumulatively, it
rejects out-of-order packets

• As Selective Repeat supports


receiving out-of-order
packets (it sorts the window
after receiving the packets),
it uses Independent
Acknowledgement to
acknowledge the packets.
Chapter 3: roadmap
 Transport-layer services
 Multiplexing and demultiplexing
 Connectionless transport: UDP
 Principles of reliable data transfer
 Connection-oriented transport: TCP
• segment structure
• reliable data transfer
• flow control
• connection management
 Principles of congestion control
 TCP congestion control

Transport Layer: 3-18


TCP: overview RFCs: 793,1122, 2018, 5681, 7323
 point-to-point:  cumulative ACKs
• one sender, one receiver  pipelining:
 reliable, in-order byte • TCP congestion and flow control
stream: set window size
• no “message boundaries"  connection-oriented:
 full duplex data: • 3-way handshaking (exchange of
• bi-directional data flow in control messages) initializes
same connection sender, receiver state before data
• MSS: maximum segment size Is exchange
based on Path MTU. (It is the max.  flow controlled:
amount of app layer data in the • sender will not overwhelm receiver
segment, not the max size of TCP
segment including the TCP header.)
Transport Layer: 3-19
TCP segment structure
32 bits

source port # dest port # segment seq #: counting


ACK: seq # of next expected sequence number bytes of data into bytestream
byte; A bit: this is an ACK (not segments!)
acknowledgement number
head not
length (of TCP header) len used C E UA P R S F receive window flow control: # bytes
Internet checksum checksum Urg data pointer receiver willing to accept

options (variable
C, E: congestion notification length)
TCP options
application data sent by
RST, SYN, FIN: connection data application into
management (variable length) TCP socket

Transport Layer: 3-20


TCP Header (cont’d)

• Header length is a 4 bit field.


• It contains the length of TCP header.
• It helps in knowing from where the actual data begins.
 Minimum and Maximum Header length
The length of TCP header always lies in the range: [20 bytes (minimum) till 60 bytes (maximum)]

• The initial 5 rows of the TCP header are always used.


• The size of the 6th row representing the Options field vary as it can be used or not used.
• The size of Options field can go from 0 bytes till 40 bytes.
• Header length is a 4-bit field, thus it can have a min value of 0000 (0 in decimal) till a max value of 1111 (15 in
decimal)
• But the range of header length is [20, 60].
• So, to represent the header length, we use a scaling factor of 4.

• Thus, in general: Header length = Header length
field value x 4 bytes
Difference between PUSH & Urgent Flags in TCP Header

(marked by the
Urgent Data
Pointer field.)

You might also like