Download presentation
Presentation is loading. Please wait.
1
Chapter 3 Transport Layer
Computer Networking: A Top Down Approach th edition. Jim Kurose, Keith Ross Addison-Wesley, July
2
Last Lecture Go-Back-N (GBN) Selective Repeat (SR)
3
Today’s Lecture Selective Repeat TCP Segment Structure
TCP ACKs and Sequence numbers TCP Reliable Data transfer
4
Go-Back-N (GBN) Sender:
Sender is allowed to transmit multiple packets without waiting for an acknowledgement Constrained to a certain maximum number N. Base or send_base Sequence number of oldest unacknowledged packet Nextseqnum Sequence number of next packet to be sent The range of sequence numbers for transmitted but not acknowledged packets can be viewed as a window of size N. This window slides forward as the protocol operates
5
Go-Back-N GBN sender must respond to three types of events
Invocation from above (rdt_send() is called): If window is full, returns data to upper layer Maintain synchronization mechanism Receipt of an ACK: ACK for packet with seq # n is taken as“Cumulative ACK” More shortly in receiver Time out event: Sender has timer for oldest unacknowledged packet If timer expires, retransmit all unacknowledged packets
6
Go-Back-N Receiver: If a packet with seq # n is received correctly and is in order ACK is sent and data is delivered to upper layers For all other cases Receiver discards the packet and resends ACK for most recently received in order packet Packets are delivered one at a time to upper layers If a packet k has been received and delivered, then all packets with seq # lower than k have also been delivered. Receiver discards out of order packets No receiver buffering Need only remember expectedseqnum
7
GBN in action
8
Selective Repeat Sender: Data received from upper layers Timeout
If window is full, returns data to upper layer Maintain synchronization mechanism Timeout Each packet has its own timer Single packet is retransmitted on timeout ACK received: Sender marked packet as received provided its in the window Packets sequence no is equal to send_base, The window base is moved forward to the unacknowledged packet
9
Selective Repeat Receiver: Packets with sequence no in the window
Selective ACK is sent to the sender whether or not it is in order. Out-of-order: buffer but send ACK for that packet Deliver base plus buffered packets Packets with sequence number below the window base An ACK must be generated even though the packet has already been acknowledged by the receiver
10
Selective Repeat in Action
11
Selective Repeat: Dilemma
Lack of synchronization between sender and receiver Finite range of sequence numbers Example: Seq #’s: 0, 1, 2, 3 Window size=3 Receiver sees no difference in two scenarios! Incorrectly passes duplicate data as new in (a) Window size of one less than the sequence number space does not work Window size must be less than or equal to half the size of sequence no. space
12
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 Connection Oriented
Handshake Send 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 MSS is set by determining the length of the largest link layer frame TCP receive buffer
13
TCP Segment Structure source port # dest port # sequence number
URG: urgent data source port # dest port # application data (variable length) sequence number acknowledgement number Receive window Urg data pointer checksum F S R P A U head len not used Options (variable length) Used in implementing a reliable data transfer ACK? PSH? Used for flow control RST, SYN, FIN: connection estab (setup, teardown commands) Same as in UDP To negotiate maximum segment size etc. Find out about PSH?ACK? OPTONS?
14
TCP Segment Structure
15
TCP Sequence Numbers and ACKs
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 Second segment gets sequence number Third segment gets sequence number and so on
16
TCP Sequence Numbers Imagine a TCP connection is transferring a file of 6000 bytes. The first byte is numbered What are the sequence numbers for each segment if data is sent in five segments with the first four segments carrying 1,000 bytes and the last segment carrying 2,000 bytes?
17
TCP Sequence Numbers The following shows the sequence number for each segment: Segment 1 10, (10,010 to 11,009) Segment 2 11, (11,010 to 12,009) Segment 3 12, (12,010 to 13,009) Segment 4 13, (13,010 to 14,009) Segment 5 14, (14,010 to 16,009)
18
TCP ACKs Acknowledgement Numbers: Example
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 rules Two choices The receiver discards out of order segments Keeps out of order bytes and waits for missing bytes to fill
19
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 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’ Piggybacked Seq=43, ACK=80 time
20
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 Initially consider simplified TCP sender: Ignore Duplicate Acks Ignore Flow control
21
TCP Sender Events: (1) Data Rcvd from Application Layer (2) Timeout:
Create segment with sequence number. Sequence number is byte-stream number of first data byte in segment. Start timer if not already running. Expiration Interval: Will study in next lecture (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
22
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 event: ACK received, with ACK field value of y if (y > SendBase) { SendBase = y if (there are currently not-yet-acknowledged segments) } } /* end of loop forever */ TCP Sender (Simplified)
23
TCP: Retransmission Scenarios
Host A Host B Host A Seq=92, 8 bytes data ACK=100 loss timeout Lost ACK Scenario Host B X time Seq=92 timeout Seq=92, 8 bytes data Seq=100, 20 bytes data ACK=100 ACK=120 Sendbase = 100 Seq=92, 8 bytes data SendBase = 120 ACK=120 SendBase = 100 SendBase = 120 time Premature Timeout
24
TCP Retransmission Scenarios (more)
Host A Seq=92, 8 bytes data ACK=100 loss timeout Cumulative ACK scenario Host B X Seq=100, 20 bytes data ACK=120 time SendBase = 120
25
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 expected seq #. One other Inorder segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. # . Gap detected TCP Receiver action Delayed ACK. Wait up to 500ms 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
26
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 Why Three Duplicate ACKs? Home Assignment
27
X Host A Host B timeout time
resend 2nd segment Resending a Segment after Triple Duplicate ACK
28
Fast Retransmit Algorithm:
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
29
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 Timer with every packet Hybrid of Go-Back N and Selective Repeat Home Assignment:TCP SACK (RFC 2018)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.