Lecture 5


Published on

this is helpfull for all communication field

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Lecture 5

  1. 1. Data Communication I Lecture 5 presented by Werner Wild, CEO Evolution Innsbruck, San Francisco, Zurich Contact: info@evolution.at
  2. 2. Today’s Lecture Plan <ul><li>TCP </li></ul>
  3. 3. TCP <ul><li>Connection oriented byte stream </li></ul><ul><ul><li>All bytes arrive in order </li></ul></ul><ul><ul><li>No “boundaries” </li></ul></ul><ul><li>Not a virtual circuit </li></ul><ul><ul><li>“ Two end” management </li></ul></ul><ul><li>Full duplex connection </li></ul><ul><li>Always point-to-point </li></ul>
  4. 4. TCP RFCs: 793, 1122, 1323, 2018, 2581 <ul><li>full duplex data: </li></ul><ul><ul><li>bi-directional data flow in same connection </li></ul></ul><ul><ul><li>MSS: maximum segment size </li></ul></ul><ul><li>connection-oriented: </li></ul><ul><ul><li>handshaking (exchange of control msgs) init’s sender, receiver state before data exchange </li></ul></ul><ul><li>flow controlled: </li></ul><ul><ul><li>sender will not overwhelm receiver </li></ul></ul><ul><li>point-to-point: </li></ul><ul><ul><li>one sender, one receiver </li></ul></ul><ul><li>reliable, in-order byte steam: </li></ul><ul><ul><li>no “message boundaries” </li></ul></ul><ul><li>pipelined: </li></ul><ul><ul><li>TCP congestion and flow control set window size </li></ul></ul><ul><li>send & receive buffers </li></ul>
  5. 5. The TCP Header <ul><li>Byte stream sent as sequence of segments </li></ul><ul><ul><li>Segment may be 0 to 64k bytes </li></ul></ul>source port destination port sequence number acknowledgment number window size urgent pointer checksum options data header length unused flags
  6. 6. Establishing a Connection <ul><li>Normal connection </li></ul><ul><li>Host 1 initiates and chooses its initial sequence number. </li></ul><ul><li>Host 2 replies with its own initial sequence number and acknowledges host 1. </li></ul><ul><li>Host 1 begins data. </li></ul>host 1 host 2 CR (seq=x) ACK (seq=y, ack=x) DATA (seq=x’, ack=y)
  7. 7. Duplicate Request (I) <ul><li>A previous connection request appears from nowhere. </li></ul><ul><li>Host 2 replies with its own initial sequence number and acknowledges host 1. </li></ul><ul><li>Host 1 rejects the connection request. </li></ul>host 1 host 2 CR (seq=x) ACK (seq=y, ack=x) REJECT (ack=y)
  8. 8. Duplicate Connection (II) <ul><li>A previous connection request appears from nowhere . </li></ul><ul><li>Host 2 replies. </li></ul><ul><li>The first data packet of the previous connection also appears. </li></ul><ul><li>Host 1 rejects the connection request. </li></ul>host 1 host 2 CR (seq=x) ACK (seq=y, ack=x) REJECT (ack=y) DATA (seq=x’, ack=z)
  9. 9. Initial Sequence Numbers <ul><li>Ensure no sequence number is reused before all packets and acks have expired. </li></ul><ul><li>Includes restart after a crash. </li></ul><ul><li>Large sequence space. </li></ul><ul><li>Based on bits from a “clock”. </li></ul>time sequence numbers initial sequence numbers sequence numbers used forbidden range
  10. 10. TCP seq. #’s and ACKs <ul><li>Seq. #’s: </li></ul><ul><ul><li>byte stream “number” of first byte in segment’s data </li></ul></ul><ul><li>ACKs: </li></ul><ul><ul><li>seq # of next byte expected from other side </li></ul></ul><ul><ul><li>cumulative ACK </li></ul></ul><ul><li>Q: how receiver handles out-of-order segments </li></ul><ul><ul><li>A: TCP spec doesn’t say, - up to implementor </li></ul></ul>Host A Host B Seq=42, ACK=79, data = ‘C’ Seq=79, ACK=43, data = ‘C’ Seq=43, ACK=80 User types ‘ C’ host ACKs receipt of echoed ‘ C’ host ACKs receipt of ‘ C’, echoes back ‘C’ simple telnet scenario time
  11. 11. TCP ACK generation Event in-order segment arrival, no gaps, everything else already ACKed in-order segment arrival, no gaps, one delayed ACK pending out-of-order segment arrival higher-than-expect 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 cumulative ACK send duplicate ACK, indicating seq. # of next expected byte immediate ACK if segment starts at lower end of gap
  12. 12. TCP Sequencing <ul><li>Retransmission due to lost acknowledgment. </li></ul><ul><li>Note sequence number is bytes transmitted. </li></ul>A B seq=92, 8 bytes data ack=100 seq=92, 8 bytes data ack=100 timeout
  13. 13. TCP Sequencing cont. <ul><li>Cumulative acknowledgment avoids retransmission. </li></ul>ack=100 A B seq=92, 8 bytes data seq=100, 20 bytes data ack=120 timeout
  14. 14. TCP Sequencing cont. <ul><li>Delayed acknowledgment causes retransmission </li></ul><ul><li>Subsequent acknowledgment prevents retransmission. </li></ul><ul><li>Not go-back-n </li></ul><ul><li>Not selective repeat </li></ul>A B seq=92, 8 bytes data seq=92, 8 bytes data ack=100 timeout seq=100, 20 bytes data ack=120 ack=120
  15. 15. TCP Flow Control <ul><li>receiver: explicitly informs sender of (dynamically changing) amount of free buffer space </li></ul><ul><ul><li>RcvWindow field in TCP segment </li></ul></ul><ul><li>sender: keeps the amount of transmitted, unACKed data less than most recently received RcvWindow </li></ul>sender won’t overrun receiver’s buffers by transmitting too much, too fast receiver buffering RcvBuffer = size or TCP Receive Buffer RcvWindow = amount of spare room in Buffer flow control
  16. 16. Receive Window (Example) application writes 2k sender receiver empty 4k 2k, seq=0 2k ack=2048, win=2048 application writes 3k 2k, seq=2048 4k full ack=4096, win=0 ack=4096, win=2048 2k application reads 2k 1k, seq=4096 2k 1k
  17. 17. TCP RTT and Timeout <ul><li>Q: how to set TCP timeout value? </li></ul><ul><li>longer than RTT </li></ul><ul><ul><li>note: RTT will vary </li></ul></ul><ul><li>too short: premature timeout </li></ul><ul><ul><li>unnecessary retransmissions </li></ul></ul><ul><li>too long: slow reaction to segment loss </li></ul><ul><li>Q: how to estimate RTT? </li></ul><ul><li>SampleRTT : measured time from segment transmission until ACK receipt </li></ul><ul><ul><li>ignore retransmissions, cumulatively ACKed segments </li></ul></ul><ul><li>SampleRTT will vary, want estimated RTT “smoother” </li></ul><ul><ul><li>use several recent measurements, not just current SampleRTT </li></ul></ul>
  18. 18. Timeouts <ul><li>What is the appropriate value for a timeout? </li></ul><ul><li>est_rtt = (1-p)(est_rtt) + p (sample_rtt) </li></ul><ul><li>dev = (1-p) dev + p |sample_rtt - est_rtt| </li></ul>
  19. 19. The End <ul><li>Thank you for your attention ! </li></ul>
  20. 20. Sources <ul><li>For the preparation of this lectures a lot of sources where used – my special thanks go to : </li></ul><ul><ul><li>Univ. Auckland </li></ul></ul><ul><ul><li>Univ. California – San Diego (UCSD) </li></ul></ul><ul><ul><li>Univ. Hongkong </li></ul></ul><ul><ul><li>… many others … </li></ul></ul>