Week8 lec1-bscs1

604 views

Published on

Computer Networks

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
604
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Week8 lec1-bscs1

  1. 1. Chapter 3 Transport Layer Computer Networking: A Top Down Approach, 4th edition. Jim Kurose, Keith Ross Addison-Wesley, July 2007.
  2. 2. 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  TCP receive buffer
  3. 3. TCP Segment Structure URG: urgent data ACK? PSH? RST, SYN, FIN: connection estab (setup, teardown commands) Same as in UDP To negotiate maximum segment size etc. source port # dest port # sequence number acknowledgement number head not len used UAP R S F Receive window Urg data pointer checksum Options (variable length) application data (variable length) Used in implementing a reliable data transfer Used for flow control
  4. 4. 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
  5. 5. 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 rules Two choices o The receiver discards out of order segments o Keeps out of order bytes and waits for missing bytes to fill
  6. 6. 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‟ host ACKs receipt of echoed „C‟ host ACKs receipt of „C‟, echoes back „C‟ Piggybacked time
  7. 7. 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
  8. 8. TCP Sender Events: (1) Data Rcvd from Application Layer  Create segment with (2) Timeout:  Retransmit segment  Restart timer sequence number. (3)Ack Received:  Sequence number is bytestream number of first data  If acknowledges previously unACked byte in segment. segments  Start timer if not already  Update what is known running. to be ACKed  Start timer if there are outstanding segments
  9. 9. 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 */ TCP Sender (Simplified)
  10. 10. TCP: Retransmission Scenarios Host A Host B X loss Host B Seq=92 timeout timeout Host A Sendbase = 100 SendBase = 120 SendBase = 100 time Lost ACK Scenario SendBase = 120 time Premature Timeout
  11. 11. TCP Retransmission Scenarios timeout Host A Host B X loss SendBase = 120 time Cumulative ACK scenario
  12. 12. TCP ACK Generation Event at Receiver Arrival of in-order segment with expected seq #. All data up to expected seq # already ACKed [RFC 1122, RFC 2581] TCP Receiver action Delayed ACK. Wait up to 200ms for next in order segment. If no next segment, send ACK Arrival of in-order segment with Immediately send single cumulative ACK, ACKing both in-order segments expected seq #. One other Inorder segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. # . Gap detected Immediately send duplicate ACK, indicating seq. # of next expected byte
  13. 13. 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-toback 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
  14. 14. Host A Host B timeout X time Resending a Segment after Triple Duplicate ACK
  15. 15. 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
  16. 16. 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

×