0% found this document useful (0 votes)
11 views25 pages

Lecture - 12 - Chapter 3 - 03 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)
11 views25 pages

Lecture - 12 - Chapter 3 - 03 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/ 25

National University of

Computer & Emerging Sciences


CS 3001 – COMPUTER NETWORKS

Lecture 12
Chapter 3

3rd October, 2024

Nauman Moazzam Hayat


nauman.moazzam@lhr.nu.edu.pk
Office Hours: 02:00 pm till 04:30 pm (Every Tuesday & Thursday)
TCP sequence numbers, ACKs
outgoing segment from sender
Sequence numbers: source port # dest port #
sequence
• byte stream “number” of number
acknowledgement
numberrwnd
first byte in segment’s data checksum urg pointer

window size
Acknowledgements: N

• seq # of next byte expected


from other side sender sequence number space

• cumulative ACK sent sent, not- usable not


ACKed yet ACKed but not usable
(“in-flight”) yet sent
Q: how receiver handles out-of-
order segments outgoing segment from receiver

• A: TCP spec doesn’t say, - up


source port # dest port #
sequence

to implementor (two basic A


number
acknowledgement
number rwnd
choices, i.e. either discard out- checksum urg pointer
Transport Layer: 3-2
of-order segment or buffer it.)
TCP sequence numbers, ACKs
Host A Host B

User types‘C’
Seq=42, ACK=79, data = ‘C’
host ACKs receipt
of‘C’, echoes back ‘C’
Seq=79, ACK=43, data = ‘C’
host ACKs receipt
of echoed ‘C’
Seq=43, ACK=80

simple telnet scenario


Transport Layer: 3-3
TCP round trip time, timeout
Q: how to set TCP timeout Q: how to estimate RTT?
value?  SampleRTT:measured time
from segment transmission until
ACK receipt
 too short: premature timeout,
• ignore retransmissions
unnecessary retransmissions
 SampleRTT will vary, want
 too long: slow reaction to estimated RTT “smoother”
segment loss • average several recent
 should be longer than RTT, but measurements, not just current
RTT varies! SampleRTT

Transport Layer: 3-4


TCP round trip time, timeout
EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT
 exponential weighted moving average (EWMA)
 influence of past sample decreases exponentially
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr
fast
 typical value:  = 0.125
350

RTT: gaia.cs.umass.edu to fantasia.eurecom.fr

RTT (milliseconds)
300

250
RTT (milliseconds)

200

sampleRTT
150

EstimatedRTT

100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)
time Estimated RTT
SampleRTT
Transport Layer: 3-5
(seconds)
TCP round trip time, timeout
 timeout interval: EstimatedRTT plus “safety margin”
• large variation in EstimatedRTT: want a larger safety margin
TimeoutInterval = EstimatedRTT + 4*DevRTT

estimated RTT “safety margin”

 DevRTT: EWMA of SampleRTT deviation from EstimatedRTT:


DevRTT = (1-)*DevRTT + *|SampleRTT-EstimatedRTT|
(typically,  = 0.25)

* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer: 3-6
Doubling the Timeout Interval
This modification provides a limited form of congestion
control

o In this modification, whenever the timeout event


occurs, each time TCP retransmits, it sets the next
timeout interval to twice the previous value, rather
than deriving it from the last EstimatedRTT and
DevRTT

o Thus the intervals grow exponentially after each


retransmission

o However, whenever the timer is started after either


of the two other events (that is, data received from
application above and/or ACK received), the
TimeoutInterval is derived from the most recent
values of EstimatedRTT and DevRTT
TCP Sender (simplified)
event: data received from event: timeout
application  retransmit segment that
caused timeout
 create segment with seq #
 restart timer
 seq # is byte-stream number
of first data byte in segment
event: ACK received (cumulative ACK)
 start timer if not already
 if ACK acknowledges
running
previously unACKed segments
• think of timer as for oldest
unACKed segment • update what is known to be
ACKed
• expiration interval:
TimeOutInterval • start timer if there are still
unACKed segments
Transport Layer: 3-8
TCP: retransmission scenarios
Host A Host B Host A Host B

SendBase=92
Seq=92, 8 bytes of data Seq=92, 8 bytes of data

Seq=100, 20 bytes of data


timeout

timeout
ACK=100
X
ACK=100
ACK=120

Seq=92, 8 bytes of data Seq=92, 8


SendBase=100 bytes of data send cumulative
SendBase=120 ACK for 120
ACK=100
ACK=120

SendBase=120

lost ACK scenario premature timeout

Transport Layer: 3-11


TCP: retransmission scenarios
Host A Host B

Seq=92, 8 bytes of data

Seq=100, 20 bytes of data


ACK=100
X
ACK=120

Seq=120, 15 bytes of data

cumulative ACK covers


for earlier lost ACK

Transport Layer: 3-12


TCP fast retransmit
Host A Host B
TCP fast retransmit
if sender receives 3 additional
ACKs for same data (“triple
duplicate ACKs”), resend
unACKed segment with X
smallest seq #
 likely that unACKed segment

timeout
lost, so don’t wait for timeout

Receipt of three duplicate


ACKs indicates 3 segments Seq=100, 20 bytes of data

received after a missing


segment – lost segment is
likely. So retransmit!
Transport Layer: 3-13
So is TCP Go Back-N or Selective
Repeat???

- TCP (error / loss recovery mechanism) is best categorized as a hybrid of GBN & SR

- Please refer to Page 246 of the Course Textbook for further details.
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-15


Flow Control vs Congestion Control (Courtesy Rutgers University)

Flow control Congestion control

Sender
Sender

Feedback:
“Not much
Feedback:
getting through”
“Receiver
overflowing”
Receiver

Receiver
TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster data from TCP socket


buffers
than application layer TCP socket
removes data from socket receiver buffers
buffers?
TCP
code
Network layer
delivering IP
datagram payload
IP
into TCP socket
code
buffers

from sender

receiver protocol stack

Transport Layer: 3-17


TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster data from TCP socket


buffers
than application layer TCP socket
removes data from socket receiver buffers
buffers?
TCP
code
Network layer
delivering IP
datagram payload
IP
into TCP socket
code
buffers

from sender

receiver protocol stack

Transport Layer: 3-18


TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster data from TCP socket


buffers
than application layer TCP socket
removes data from socket receiver buffers
buffers?
TCP
code

receive window
flow control: # bytes
receiver willing to accept IP
code

from sender

receiver protocol stack

Transport Layer: 3-19


TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster data from TCP socket


buffers
than application layer TCP socket
removes data from socket receiver buffers
buffers?
TCP
code
flow control
receiver controls sender, so
sender won’t overflow IP
code
receiver’s buffer by
transmitting too much, too
fast from sender

receiver protocol stack

Transport Layer: 3-20


TCP flow control
 TCP receiver “advertises” free buffer
space in rwnd field in TCP header to application process
• RcvBuffer size set via socket
options (typical default is 4096 bytes) RcvBuffer buffered data
• many operating systems auto-adjust
RcvBuffer
rwnd free buffer space

 sender limits amount of unACKed


(“in-flight”) data to received rwnd TCP segment payloads

 guarantees receive buffer will not TCP receiver-side buffering


overflow

Transport Layer: 3-21


TCP flow control
flow control: # bytes receiver willing to accept

 TCP receiver “advertises” free buffer


space in rwnd field in TCP header
• RcvBuffer size set via socket
receive window
options (typical default is 4096 bytes)
• many operating systems auto-adjust
RcvBuffer (i.e. dynamic)
 sender limits amount of unACKed
(“in-flight”) data to received rwnd
 guarantees receive buffer will not
overflow
TCP segment format
 (Assumption: TCP receiver discards
out-of-order segments) Transport Layer: 3-22
TCP Flow Control - Implementation
 TCP provides flow control by having the sender maintain a dynamic
variable called the receive window (rwnd)

(Since TCP is not permitted to overflow the allocated buffer, we must have)

LastByteRcvd – LastByteRead <= RcvBuffer (where:

- RcvBuffer is the size of the buffer allocated at the receiver for this connection,
- LastByteRcvd is the number of the last byte in the data stream received from the
network and placed in the receive buffer, &
- LastByteRead is the number of the last byte in the data stream read by the
application process from the receive buffer), thus

rwnd = RcvBuffer – [LastByteRcvd – LastByteRead]

 While the receiver is keeping track of many variables as seen


above, the sender is keeping track of primarily two variables, (i.e.
LastByteSent & LastByteAcked)

LastByteSent – LastByteAcked <= rwnd (i.e. the UnAckedData.)


- By maintaining this throughout the connection’s life, i.e. keeping the UnAckedData
less than or equal to the rwnd, the sender ensures it doesn’t overflow the buffer
at the receiver
TCP Flow Control - Issue
Issue: One minor technical problem with this scheme.
- To see this, suppose Host B’s (receiver) receive buffer
becomes full so that rwnd = 0.
- After advertising rwnd = 0 to Host A (sender), also suppose
that B has nothing to send to A.
- As the application process at B empties the buffer, TCP does
not send new segments with new rwnd values to Host A (indeed,
TCP sends a segment to Host A only if it has data to send or if
it has an acknowledgment to send)

Therefore, Host A is never informed that some space has opened up in


Host B’s receive buffer (i.e. Host A is blocked and can transmit no
more data!)

- To solve this problem, the TCP specification requires Host A to


continue to send segments with one data byte when B’s receive
window is zero.
- These segments will be acknowledged by the receiver.
- Eventually the buffer will begin to empty and the
acknowledgments will contain a non-zero rwnd value.
Midterm 1 Solution Discussion

Midterm 1 Solution
was discussed

Application Layer 2-25


Assignment # 3 (Chapter – 3)
- 3rd Assignment
th
will be uploaded on Google Classroom on
Tuesday, 8 October, 2024, in the Stream - Announcement
Section

- Due Date: Tuesday, 15th October, 2024 (Handwritten


solutions to be submitted during the lecture)

- Please read all the instructions carefully in the uploaded


Assignment document, follow & submit accordingly

Quiz # 3 (Chapter – 3)
- On: Tuesday, 15th October, 2024 (During the lecture)

- Quiz to be taken during own section class only

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy