1 / 60

Μαρία Παπαδοπούλη Τμήμα Επιστήμης Υπολογιστών, Πανεπιστήμιο Κρήτης Χειμερινό εξάμηνο 2008-2009

Μαρία Παπαδοπούλη Τμήμα Επιστήμης Υπολογιστών, Πανεπιστήμιο Κρήτης Χειμερινό εξάμηνο 2008-2009 Κεφάλαι a 3.5, 3.6, 3.7 των Kurose/Ross. TCP. ΗΥ335. principles behind TCP : reliable data transfer flow control congestion control. TCP. Στόχος μας είναι η κατανόηση των :.

ianchandler
Download Presentation

Μαρία Παπαδοπούλη Τμήμα Επιστήμης Υπολογιστών, Πανεπιστήμιο Κρήτης Χειμερινό εξάμηνο 2008-2009

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Μαρία Παπαδοπούλη Τμήμα Επιστήμης Υπολογιστών, Πανεπιστήμιο Κρήτης Χειμερινό εξάμηνο 2008-2009 Κεφάλαιa 3.5, 3.6, 3.7 των Kurose/Ross TCP ΗΥ335 TCP

  2. principles behind TCP: reliable data transfer flow control congestion control TCP Στόχος μας είναι η κατανόηση των: TCP

  3. unreliable, unordered delivery: UDP no-frills extension of “best-effort” IP reliable, in-order delivery: TCP congestion control flow control connection setup services notavailable: delay guarantees bandwidth guarantees application transport network data link physical application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical logical end-end transport Internet transport-layer protocols TCP

  4. TCP socket χαραχτηρίζεται απο 4 πεδία: source IP address source port number dest IP address dest port number Ο παραλήπτης χρησιμοποιεί και τα 4 πεδία για να προωθήσει το segment στο κατάλληλο socket Ενας server host μπορεί να υποστηρίξει πολλαπλά ταυτόχρονα (“παράλληλαστον χρόνο”) TCP sockets:  κάθε socket χαραχτηρίζεται από τη δική του 4-άδα Web servers έχουν διαφορετικά sockets για κάθε client που συνδέεται non-persistent HTTP έχουν διαφορετικά sockets για κάθε αίτημα TCP TCP

  5. 10 Mbps 1.5 Mbps 100 Mbps Συμφόρηση (congestion) bottleneck link • Τα sources ανταγωνίζονται για τους πόρους του δικτύου, αλλά • δέν έχουν γνώση των πόρων του δικτύου state of resource • δεν ξέρουν την ύπαρξη η μία της άλλης • Με αποτέλεσμα: • Πακέτα να χάνονται (λόγω buffer overflow στους δρομολογητές) • Μεγάλες καθυστερήσεις (αναμονή στις ουρέςτων buffers στους δρομολογητές) • throughput μικρότερο από το bottleneck link (1.5Mbps for the above topology)  a.k.a. congestion collapse TCP

  6. Congestion Collapse • Definition: Increase in network load results in decrease of useful work done • Many possible causes • Spurious retransmissions of packets still in flight • Classical congestion collapse • How can this happen with packet conservation • Solution: better timers and TCP congestion control • Undelivered packets • Packets consume resources and are dropped elsewhere in network • Solution: congestion control for ALL traffic TCP

  7. full duplex data: bi-directional data flow in same connection MSS: maximum segment size connection-oriented: handshaking (exchange of control msgs) init’s sender, receiver state before data exchange flow controlled: sender will not overwhelm receiver point-to-point: one sender, one receiver (σε αντίθεση με το multicasting) reliable, in-orderbyte steam: Ηεφαρμογή από επάνω θα “παραλάβει” τα πακέτα στη σωστή σειρά pipelined: TCP congestion &flow control set window size Πολλά πακέτα μπορούν να έχουν σταλθεί παράλληλα και να μην έχουν γίνει ACKed send & receive buffers TCP: OverviewRFCs: 793, 1122, 1323, 2018, 2581 TCP

  8. 32 bits source port # dest port # sequence number acknowledgement number head len not used Receive window U A P R S F checksum Urg data pnter Options (variable length) application data (variable length) TCP segment structure URG: urgent data (generally not used) counting by bytes of data (not segments!) ACK: ACK # valid PSH: push data now (generally not used) # bytes rcvr willing to accept RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP) TCP

  9. Sequence Number Space Το TCP βλέπει τα δεδομένα σαν μια ροή δεδομένων, σειρά από bytes Ο αποστολέας στέλνει τα πακέτα σύμφωνα με τη σειρά αυτή Ο παραλήπτης θα προσπαθήσει να την “ξαναδημιουργήσει” Each byte in byte stream is numbered • 32 bit value • Wraps around • Initial values selected at start up time • TCP breaks up the byte stream in packets. • Packet size is limited to the Maximum Segment Size • Each packet has a sequence number • Indicates where it fits in the byte stream 13450 14950 16050 17550 packet 8 packet 9 packet 10 TCP

  10. Step 1: client host sends TCP SYN segment to server specifies initial seq # no data Step 2: server host receives SYN, replies with SYNACK segment server allocates buffers specifies server initial seq. # Step 3: client receives SYNACK, replies with ACK segment, which may contain data TCP Connection: 3-way handshake TCP

  11. Establishing Connection: 3-Way handshake • Each side notifies other of starting sequence number it will use for sending • Why not simply chose 0? • Must avoid overlap with earlier incarnation • Security issues • Each side acknowledges other’s sequence number • SYN-ACK: Acknowledge sequence number + 1 • Can combine second SYN with first ACK SYN: SeqC ACK: SeqC+1 SYN: SeqS ACK: SeqS+1 Client Server TCP

  12. Recall: TCP sender, receiver establish “connection” before exchanging data segments initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow) client:connection initiator Socket clientSocket = new Socket("hostname","port number"); server:contacted by client Socket connectionSocket = welcomeSocket.accept(); Three way handshake: Step 1: client host sends TCP SYN segment to server specifies initial seq # no data Step 2: server host receives SYN, replies with SYNACK segment server allocates buffers specifies server initial seq. # Step 3: client receives SYNACK, replies with ACK segment, which may contain data TCP Connection Management TCP

  13. Closing a connection: client closes socket:clientSocket.close(); Step 1:client end system sends TCP FIN control segment to server Step 2:server receives FIN, replies with ACK. Closes connection, sends FIN client server close FIN ACK close FIN ACK timed wait closed TCP Connection Management (cont.) TCP

  14. Step 3:client receives FIN, replies with ACK Enters “timed wait” - will respond with ACK to received FINs Step 4:server, receives ACK. Connection closed. Note: with small modification, can handle simultaneous FINs. TCP Connection Management (cont.) client server closing FIN ACK closing FIN ACK timed wait closed closed TCP

  15. Tearing Down Connection • Either side can initiate tear down • Send FIN signal • “I’m not going to send any more data” • Other side can continue sending data • Half open connection • Must continue to acknowledge • Acknowledging FIN • Acknowledge last sequence number + 1 A B FIN, SeqA ACK, SeqA+1 Data ACK FIN, SeqB ACK, SeqB+1 TCP

  16. Round-trip time estimation & timeout • Μηχανισμός που καθορίζει πόσο να περιμένει ο αποστολέας μέχρι να ξαναστείλει το πακέτο • Ο timer (εάν ήδη δεν “τρέχει” για κάποιο άλλο segment) ξεκινά όταν το segment “παραδίδεται” στο IP επίπεδο • Όταν ο timer κάνει expire το segment ξαναστέλνεται και το TCP ξεκινά ξανά τον timer Το TCP του sender διατηρεί πληροφορία για το παλιότερο unacknowledged byte TCP

  17. TCP Flow Control  TCP is a sliding window protocol • For window size n,can send up to nbytes without receiving an acknowledgement • When the data is acknowledged then the window slides forward • Each packet advertises a window size • Indicates number of bytes the receiver has space for • Original TCP always sent entire window • Congestion control now limits this TCP

  18. Window Flow Control: Sender Side window Sent but not acked Not yet sent Sent and acked Next to be sent TCP

  19. Window Flow Control: Send Side Packet Received Packet Sent Source Port Dest. Port Source Port Dest. Port Sequence Number Sequence Number Acknowledgment Acknowledgment HL/Flags Window HL/Flags Window D. Checksum Urgent Pointer D. Checksum Urgent Pointer Options… Options... App write acknowledged sent to be sent outside window TCP

  20. Window Flow Control: Receive Side What should receiver do? New Receive buffer Acked but not delivered to user Not yet acked window TCP

  21. Ερωτήσεις για τον έλεγχο ροής • What happens if window is 0? Receiver updates window when application reads data • What if this update is lost? • TCP Persist state • Sender periodically sends 1 byte packets • Receiver responds with ACK even if it can’t store the packet • Σε κάποια στιγμή το Receive Window του Receiver θα είναι ≠0, θα φανεί στο ACK και ο Sender θα ξέρει ότι μπορεί να στείλει δεδομένα TCP

  22. Performance Considerations • The window size can be controlled by receiving application • Can change the socket buffer size from a default (e.g. 8Kbytes) to a maximum value (e.g. 64 Kbytes) • The window size field in the TCP header limits the window that the receiver can advertise TCP

  23. Seq. #’s: byte stream “number” of first byte in segment’s data ACKs: seq # ofnext byte expectedfrom other side cumulative ACK Q: how receiver handles out-of-order segments A: TCP spec doesn’t say- up to implementor Ο παραλήπτης έχει τις παρακάτω δύο γενικές επιλογές αμέσως “πετά” τα segments που έφτασαν με λάθος σειρά, ή “κρατά” τα segments που ήρθα με λάθος σειρά και περιμένει τα λάβει πακέτα με τα bytes που “χάθηκαν/δεν έφτασαν” νακαλύψουν τα κενά TCP seq. #’s and ACKs TCP

  24. Seq. #’s: byte stream “number” of first byte in segment’s data ACKs: seq # ofnext byte expectedfrom other side cumulative ACK Q: how receiver handles out-of-order segments A: TCP spec doesn’t say - up to implementor Ο παραλήπτης: αμέσως “πετά” τα segments που έφτασαν με λάθος σειρά, ή “κρατά” τα segments που ήρθα με λάθος σειρά και περιμένει τα λάβει πακέτα με τα bytes που “χάθηκαν/δεν έφτασαν” νακαλύψουν τα κενά time TCP seq. #’s and ACKs Host B Host A 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 TCP

  25. Q: how to set TCP timeout value? longer than RTT  but RTT varies too short  premature timeout  unnecessary retransmissions too long: slow reaction to segment loss Q:how to estimate RTT? SampleRTT:measured time from segment transmission until ACK receipt Αγνοεί segments που έχουν φτάσει με retransmissions SampleRTT will vary, want estimated RTT “smoother” average several recent measurements, not just current SampleRTT TCP Round Trip Time and Timeout TCP

  26. TCP Round Trip Time and Timeout EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT • Exponential weighted moving average • influence of past sample decreases exponentially fast • typical value:  = 0.125 TCP

  27. Example RTT estimation: TCP

  28. Setting the timeout EstimtedRTT plus “safety margin” large variation in EstimatedRTT -> larger safety margin first estimate of how much SampleRTT deviates from EstimatedRTT: TCP Round Trip Time and Timeout DevRTT = (1-)*DevRTT + *|SampleRTT-EstimatedRTT| (typically,  = 0.25) Then set timeout interval: TimeoutInterval = EstimatedRTT + 4*DevRTT TCP

  29. TCP creates rdt service on top of IP’s unreliable service Pipelined segments Cumulative acks TCP uses single retransmission timer Retransmissions are triggered by: timeout events duplicate acks Initially consider simplified TCP sender: ignore duplicate acks ignore flow control, congestion control TCP reliable data transfer TCP

  30. Data received from application: Δημιουργεί segment με seq # seq # is byte-stream αριθμός του πρώτου data byte στο segment Αρχίζει τον timer, εάν δεν “τρέχει” ήδη Ο timer κάθε φορά αντιστοιχεί στο παλιότεροunacked segment Υπάρχει μονάχα ένας timer για το κάθε TCP flow στο host expiration interval: TimeOutInterval Timeout: Ξαναστέλνει το segment που προκάλεσε το timeout Ξανα αρχινά το timer Ack received: Εάν acknowledges παλιότερα unacked segments Ενημέρωσε τους buffers/παραμέτρους για το τι ειναι γνωστό να έχει γίνει acked Αρχισε το timer εάν υπάρχουν outstanding segments TCP sender events: TCP

  31. 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) • Comment: • SendBase-1: last • cumulatively ack’ed byte • Example: • SendBase-1 = 71;y= 73, so the rcvrwants 73+ ;y > SendBase, sothat new data is acked TCP

  32. Host A Host B Seq=92, 8 bytes data ACK=100 Seq=92 timeout timeout X loss Seq=92, 8 bytes data ACK=100 time time lost ACK scenario TCP: retransmission scenarios Host A Host B Seq=92, 8 bytes data Seq=100, 20 bytes data ACK=100 ACK=120 Seq=92, 8 bytes data Sendbase = 100 SendBase = 120 ACK=120 Seq=92 timeout SendBase = 100 SendBase = 120 premature timeout TCP

  33. Host A Host B Seq=92, 8 bytes data ACK=100 Seq=100, 20 bytes data timeout X loss ACK=120 time Cumulative ACK scenario TCP retransmission scenarios (more) SendBase = 120 TCP

  34. TCP ACK generation[RFC 1122, RFC 2581] TCP Receiver action Delayed ACK. Wait up to 500ms for next 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 Immediate send ACK, provided that segment startsat lower end of gap 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 segment has ACK pending Arrival of out-of-order segment higher-than-expect seq. # . Gap detected Arrival of segment that partially or completely fills gap TCP

  35. Να θυμάστε • TCP acks είναι cummulative Ενα segment που έχει ληφθεί σωστά αλλά σε λάθος σειράδεν γίνεται ACKedαπό τον παραλήπτη • TCP sender διατηρεί μονάχα την πληροφορία των: • segment με τον μικρότερο αριθμόπου έχει στείλει αλλά δεν έχει γίνει ACKed ακόμη (sendBase), καθώς και • sequence αριθμό του επόμενου byte που θα πρέπει να σταλεί (NextSeqNum) TCP

  36. Παράδειγμα • Εστω οτι ο sender στέλνει 1,2,..., Ν segments και όλα λαμβάνονται στη σωστή σειρά δίχως λάθος από τον receiver • Εστω οτι το ACK για το πακέτο n<Ν χάνεται, αλλά τα υπόλοιπα Ν-1 φτάνουν σωστά στον sender πριν τοδικό τους timeout • Πόσα segments θα κάνει retransmit ο sender ?  Στην χειρότερη περίπτωση μόνο το segment n.  Μάλιστα άν το ΑCK για το segment n+1 έρθει πριν το timeout του segment n, δεν θα χρειαστεί ναξανασταλθεί το segment n TCP

  37. Παρατήρηση σχετικά με τα Timeout Διάστηματα • Τα timer expiration συμβαίνουν συνήθως εξαιτίας της συμφόρησης του δικτύου • Πολλά πακέτα που φτάνουν σε ζεύξεις στο μονοπάτι μεταξύ του sender & receiver χάνονται ή έχουν μεγάλες καθυστερήσεις στις ουρές των δρομολογητών λόγω συμφόρησης Εάν οι senders συνεχίσουν να ξαναστέλνουν τα πακέτα “σταθερά”, η συμφόρηση μπορεί να χειροτερεύσει • Με την εκθετική αύξηση με κάθε retransmission του sender, ο TCP sender προσπαθεί “ευγενικά” να περιμένει όλο και μεγαλύτερο διάστημα TCP  Οι περισσότερες TCP υλοποιήσεις το υποστηρίζουν

  38. Διπλασιάζοντας το Timeout Διάστημα Κάθε φορά που το TCP retransmits διπλασιάζει το επόμενο timeout διάστημα αντί να θέτει την τιμή απο τον υπολογισμό των lastEstimatedRTT & DevRTT • έχομε δηλαδή εκθετική αύξηση του timerμετά από κάθε retransmission Οταν ένα από τα παρακάτω γεγονόταν συμβούν: • Νεα δεδομένα προωθούνται απο την εφαρμογή για τον σχηματισμό segment • Παραλαβή ενός ACK Ο timer παίρνει τιμή βάσει των lastEstimatedRTT και DevRTT  Οι περισσότερες TCP υλοποιήσεις το υποστηρίζουν TCP

  39.  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 Fast Retransmit TCP

  40. 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 dup ACKs received for y if (count of dup ACKs received for y = 3) { resend segment with sequence number y } a duplicate ACK for already ACKed segment fast retransmit TCP

  41. 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 Chapter 3 outline TCP

  42. Receiver TCP has a receive buffer: speed-matching service: matching the send rate to the receiving application’s drain rate flow control sender won’t overflow receiver’s buffer by transmitting too much, too fast TCP Flow Control • application process may be slow at reading from buffer TCP

  43. (Suppose TCP receiver discards out-of-order segments) spare room in buffer = RcvWindow = RcvBuffer-[LastByteRcvd - LastByteRead] Receiver advertises spare room by including value of Receive Window in segments Sender limits unACKed data to Receive Window guarantees receive buffer doesn’t overflow TCP Flow control: how it works TCP

  44. Συμφόρηση: informally: “too many sources sending too much data too fast for network to handle”  Διαφορετικό απο τον έλεγχο ροής (flow control) ! manifestations: lost packets (buffer overflow at routers) long delays (queueing in router buffers)  a top-10 problem! Βασικά για τον Ελεγχο Συμφόρησης TCP

  45. 2 senders, 2 receivers 1 router, infinite buffers no retransmission large queuing delayswhen congested maximum achievable throughput lout lin : original data unlimited shared output link buffers Host A Host B Causes/costs of congestion: scenario 1 Per-connection throughput: Number of bytes/second @ receiver  Αλλά αυτό είναι πρόβλημα! • Πολύ ωραία! μέγιστο throughput TCP Connection sending rate

  46. 1 router, finite buffers sender retransmission of lost packet Causes/costs of congestion: scenario 2 Host A lout lin : original data l'in : original data, plus retransmitted data Host B finite shared output link buffers TCP

  47. always: (goodput) “perfect” retransmission only when loss: retransmission of delayed (not lost) packet makes larger (than perfect case) for same l l l > = l l l R/2 in in in R/2 R/2 out out out R/3 lout lout lout R/4 R/2 R/2 R/2 lin lin lin a. b. c. Causes/costs of congestion: scenario 2 Μαντεύει αν ο buffer ειναι γεμάτος ή οχι Πρώιμα timeouts Retrx οταν ξέρει ότι το πακέτο θα χαθεί Κάθε πακέτο στέλνεται (κατά μέσο όρο) 2 φορές Original data + retransmissions  “costs” of congestion:  more work (retransmissions) for given “goodput”  unneeded retransmissions: link carries multiple copies of packet TCP

  48. 4 senders multihop paths timeout/retransmit l l in in Host A Host B Causes/costs of congestion: scenario 3 Q:what happens as and increase ? lout lin : original data l'in : original data, plus retransmitted data finite shared output link buffers TCP

  49. Host A Host B Causes/costs of congestion: scenario 3 lout Another “cost” of congestion:  when packet dropped, any “upstream transmission capacity used for that packet was wasted! TCP

  50. End-to-end congestion control: no explicit feedback from network congestion inferred from end-system observed loss, delay approach taken by TCP Network-assisted congestion control: routers provide feedback to end systems single bit indicating congestion (SNA, DECbit, TCP/IP ECN, ATM) explicit rate sender should send at Γενικοί τρόποι αντιμετώπισης συμφόρησης Two broad approaches towards congestion control: end-to-end: τα 2 hosts που συμμετέχουν παρακολουθούν και ρυθμίζουν το ρυθμό κίνησης τους IP does not provide explicit feedback to the end systems TCP

More Related