1 of 16

Computer Networking: �A Top Down Approach �6th edition �Jim Kurose, Keith Ross�Addison-Wesley�March 2012

Computer Communications �& Networks

CSNC-2413

  • Ch 3 : Reliable Data Transfer

Lec: 17

2 of 16

Chapter 3 outline

3.1 Transport-layer services

3.2 Multiplexing and � demultiplexing

3.3 Connectionless � transport: UDP

3.4 Principles of reliable data� transfer

3.5 Connection-oriented � transport: TCP

    • segment structure
    • reliable data transfer
    • flow control
    • connection management

3.6 Principles of congestion� control

3.7 TCP congestion control

2

3 of 16

TCP reliable data transfer

  • TCP creates reliable service on top of IP’s unreliable service
  • Pipelined segments �(for performance)
  • Cumulative ACKs
  • Retransmissions
    • TCP uses single retransmission timer
    • even if multiple Tx but unACKed segments

  • Retransmissions are triggered by:
    • timeout events
    • duplicate ACK �(for performance reason)
  • Initially consider simplified TCP sender:
    • use only timeouts
    • ignore duplicate ACKs
    • also ignore flow control, congestion control

3

4 of 16

TCP sender events

data rcvd from app:

  • Create segment with �seq#
    • seq# is byte-stream number of first data byte in segment
  • start timer if not already running
    • think of timer as for oldest unACKed segment
    • expiration interval…

TimeOutInterval

timeout:

  • retransmit segment that caused timeout
  • restart timer

Ack rcvd:

  • if ACKs previously unACKed segments
    • update what is known to be ACKed
    • start timer if there are outstanding segments

4

5 of 16

TCP: retransmission scenarios

Host A

Seq=92, 8 bytes data

ACK=100

loss

timeout

reTx due to lost ACK

Host B

X

Seq=92, 8 bytes data

ACK=100

time

SendBase

= 100

Host A

Seq=100, 20 bytes data

ACK=100

time

Seq 100 not reTx

Host B

Seq=92, 8 bytes data

ACK=120

Seq=92, 8 bytes data

Seq=92 timeout

ACK=120

Seq=92 timeout

SendBase

= 120

SendBase

= 120

Sendbase

= 100

5

6 of 16

TCP: retransmission scenarios

Host A

Seq=92, 8 bytes data

ACK=100

loss

timeout

cum ACK avoids reTx

Host B

X

Seq=100, 20 bytes data

ACK=120

time

SendBase

= 120

6

7 of 16

Double Timeout Interval

8 of 16

TCP ACK generation [RFC 1122, RFC 2581]

Event at Receiver

Arrival of in-order segment with

expected seq #; All data up to

expected seq # already ACKed

Arrival of in-order segment with

expected seq #; One other in �order segment has ACK pending

Arrival of out-of-order segment

Higher than expected seq#;

Gap detected

Arrival of segment that

partially or completely fills gap

TCP Receiver action

Delayed ACK; Wait up to 500ms

for next segment; If no next segment,

send ACK

Immediately send single Cum ACK,

ACKing both in-order segments

Immediately send Duplicate ACK,

indicating seq# of expected byte

Imm send ACK, provided segment

starts at lower end of gap

Ack the “largest in-order byte” seq #

8

9 of 16

TCP fast retransmit

  • time-out period often relatively long:
    • long delay before resending lost packet
  • detect lost segments via duplicate ACKs
    • sender often sends many segments back-to-back
    • if a segment is lost, there will likely be many duplicate ACKs

if sender receives 3 ACKs for same data

(“triple duplicate ACKs”)

resend unACKed segment with smallest seq #

    • likely that unACKed segment got lost
    • so don’t wait for timeout

TCP fast retransmit

(Implicit NAK)

9

10 of 16

TCP fast retransmit

Fast retransmit �after sender receipt of �triple duplicate ACK

X

Host B

Host A

Seq=92, 8 bytes of data

ACK=100

timeout

ACK=100

ACK=100

ACK=100

Seq=100, 20 bytes of data

Seq=100, 20 bytes of data

10

11 of 16

Principles in practice

  • TCP uses Seq Nums to allow receiver to identify lost or duplicate segments
  • TCP provides reliable data transfer by using positive ACKs and timeouts
  • TCP uses ACKs even when data not received correctly, and retransmits when segments or ACKs lost/corrupted
  • Certain TCP versions also have Implicit NAK with fast retransmit;
    • receipt of three duplicate ACKs for a segment serves as �Implicit NAK for the following segment
    • triggers reTx of that segment before timeout

11

12 of 16

Principles in practice

  • As in case of reliable data transfer protocol , TCP sender cannot itself tell for certain if a segment or its ACK, is lost, corrupted, or overly delayed
    • At sender, TCP response will be the same; �reTx the segment in question
  • TCP also uses pipelining, allowing sender to have multiple transmitted but yet-to-be ACKed segments outstanding at any given time
  • Pipelining can greatly improve session thruput, when ratio of segment size to round trip delay is small

12

13 of 16

Chapter 3 outline

3.1 Transport-layer services

3.2 Multiplexing and � demultiplexing

3.3 Connectionless � transport: UDP

3.4 Principles of reliable data� transfer

3.5 Connection-oriented � transport: TCP

    • segment structure
    • reliable data transfer
    • flow control
    • connection management

3.6 Principles of congestion� control

3.7 TCP congestion control

13

14 of 16

TCP Flow control

  • receive side of TCP connection has a receive buffer
  • speed-matching required: match the send rate to the receiving app’s drain rate
  • app process may be slow at reading from buffer

sender won’t overflow

receiver’s buffer �by transmitting too much,

too fast

flow control

14

15 of 16

TCP Receive Window size

(assume TCP receiver discards out-of-order segments)

Spare room in buffer

= RcvWindow

= RcvBuffer - [LastByteRcvd - LastByteRead]

15

16 of 16

TCP Flow control

    • Rcv Buffer size typical default is 4096 bytes
    • many operating systems auto adjust Rcv Buffer
  • Sender limits amount of unACKed data to receiver rwnd value

buffered data

free buffer space

rwnd

RcvBuffer

TCP segment payloads

to application process

Receiver-side buffering

16

  • Receiver “advertises” free buffer space by including rwnd value in TCP header of receiver-to-sender segments

LastByteSent-LastByteAcked ≤ rwnd

  • guarantees Rcv Buffer will �not overflow