Week8 lec1-bscs1

16
Chapter 3 Transport Layer Computer Networking: A Top Down Approach, 4 th edition. Jim Kurose, Keith Ross Addison-Wesley, July 2007.

description

Computer Networks

Transcript of Week8 lec1-bscs1

Page 1: Week8 lec1-bscs1

Chapter 3Transport Layer

Computer Networking: A Top Down Approach, 4th edition. Jim Kurose, Keith RossAddison-Wesley, July 2007.

Page 2: Week8 lec1-bscs1

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 Connection Oriented

HandshakeSend segments to each other to establish

parameters of ensuing data transfer Runs on the end systems TCP connection is point to point (single

sender and receiver)Does not support multicast (one sender

many receivers) TCP send buffer

TCP grab a chunk of data from this buffer MSS (Maximum Segment Size)

The maximum amount of data that can be grabbed and placed in a segment

TCP receive buffer

Page 3: Week8 lec1-bscs1

TCP Segment Structure

source port # dest port #

application data (variable length)

sequence number

acknowledgement number Receive window

Urg data pointerchecksumFSRPAU

headlen

notused

Options (variable length)

URG: urgent data

ACK?

PSH?

RST, SYN, FIN:connection estab(setup, teardown

commands)

Used for flow control

Used in implementinga reliable data transfer

Same as in UDP

To negotiate maximum

segment size etc.

Page 4: Week8 lec1-bscs1

TCP Sequence Numbers and ACKs

Sequence Numbers: Sequence nos. are over the stream of

transmitted bytes and not over the series of transmitted segments

Sequence no. is the byte stream “number” of first byte in segment’s data

Example: Host A wants to send data to Host B File consisting of 500,000 bytes, MSS is 1,000 bytes First byte of stream is numbered zero TCP constructs 500 segments out of data stream First segment gets sequence number --- 0 Second segment gets sequence number----1000 Third segment gets sequence number------2000 and so

on

Page 5: Week8 lec1-bscs1

TCP ACKs

Acknowledgement Numbers: The acknowledgement no that hosts A puts in its

segment is the sequence no of the next byte host A is expecting from host B.

Example Host A receives all bytes numbered 0 through 535 from

B Host A puts 536 in the acknowledgment number field of

the segment it sends to B TCP acknowledges bytes up to first missing bytes in the

stream Cumulative Acknowledgement How receiver handles out-of-order segments?

TCP RFCs do not impose any rulesTwo choices

o The receiver discards out of order segmentso Keeps out of order bytes and waits for missing bytes to

fill

Page 6: Week8 lec1-bscs1

TCP Sequence Numbers and ACKs

Example: Host A sends a

character to Host B, which echoes it back to Host A.

Starting Sequence no for client and server are 42 and 79.

Piggybacking: Acknowledgement of

client to server data is carried by segment of server to client data

Host A Host B

Seq=42, ACK=79, data = ‘C’

Seq=79, ACK=43, data = ‘C’

Seq=43, ACK=80

Usertypes‘C’

host ACKsreceipt of echoed‘C’

host ACKsreceipt of‘C’, echoesback ‘C’

time

Piggybacked

Page 7: Week8 lec1-bscs1

TCP Reliable Data Transfer

TCP creates reliable data transfer service on top of IP’s unreliable service

TCP uses single retransmission timer, even if there are multiple unacknowledged segments (RFC 2988)

Uses cumulative acknowledgements Retransmissions are triggered by:

Timeout Duplicate Acks ( will see shortly)

Initially consider simplified TCP sender: Ignore Duplicate Acks Ignore Flow control

Page 8: Week8 lec1-bscs1

TCP Sender Events:

(1) Data Rcvd from Application Layer

Create segment with sequence number.

Sequence number is byte-stream number of first data byte in segment.

Start timer if not already running.

(2) Timeout: Retransmit segment Restart timer

(3)Ack Received: If acknowledges

previously unACked segments Update what is

known to be ACKed Start timer if there

are outstanding segments

Page 9: Week8 lec1-bscs1

TCP Sender(Simplified)

NextSeqNum = InitialSeqNum SendBase = InitialSeqNum

loop (forever) { switch(event)

event: data received from application above create TCP segment with sequence number NextSeqNum if (timer currently not running) start timer pass segment to IP NextSeqNum = NextSeqNum + length(data)

event: timer timeout retransmit not-yet-acknowledged segment with smallest sequence number start timer

event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer }

} /* end of loop forever */

Page 10: Week8 lec1-bscs1

TCP: Retransmission Scenarios

Host A

Seq=100, 20 bytes data

ACK=100

timePremature Timeout

Host B

Seq=92, 8 bytes data

ACK=12

0

Seq=92, 8 bytes data

Seq=

92

tim

eout

ACK=12

0

Host A

Seq=92, 8 bytes data

ACK=100

losstim

eout

Lost ACK Scenario

Host B

X

Seq=92, 8 bytes data

ACK=10

0

time

SendBase= 100

SendBase= 120

SendBase= 120

Sendbase= 100

Page 11: Week8 lec1-bscs1

TCP Retransmission Scenarios Host A

Seq=92, 8 bytes data

ACK=100

losstim

eout

Cumulative ACK scenario

Host B

X

Seq=100, 20 bytes data

ACK=12

0

time

SendBase= 120

Page 12: Week8 lec1-bscs1

TCP ACK Generation [RFC 1122, RFC 2581]

Event at Receiver

Arrival of in-order segment withexpected seq #. All data up toexpected seq # already ACKed

Arrival of in-order segment withexpected seq #. One other Inorder segment has ACK pending

Arrival of out-of-order segmenthigher-than-expect seq. # .Gap detected

TCP Receiver action

Delayed ACK. Wait up to 200ms for next in order segment. If no next segment, send ACK

Immediately send single cumulative ACK, ACKing both in-order segments

Immediately send duplicate ACK, indicating seq. # of next expected byte

Page 13: Week8 lec1-bscs1

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 segment is lost, there will likely be many duplicate

ACKs.

If sender receives 3 ACKs for the same data, it supposes that segment after ACKed data was lost: Fast Retransmit: resend

segment before timer expires

Page 14: Week8 lec1-bscs1

Host A

tim

eout

Host B

time

X

resend 2nd segment

Resending a Segment after Triple Duplicate ACK

Page 15: Week8 lec1-bscs1

event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) start timer } else { increment count of duplicate ACKs received for y if (count of duplicate ACKs received for y ==3) { resend segment with sequence number y }

Fast Retransmit Algorithm:

Fast Retransmit

Page 16: Week8 lec1-bscs1

Go-Back N or Selective Repeat GBN Protocol

TCP acknowledgements are cumulative and out of order segments are not individually acked.

Difference Buffering of correctly received packets GBN transmits all packets after the lost packet

TCP only the missing packet Selective Repeat

Buffering of out of order packets TCP SACK (RFC 2018) allows to ACK out of order

packets selectively rather than cumulatively Difference

Timer with every packet

Hybrid of Go-Back N and Selective Repeat