Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS4470 Computer Networking Protocols

Similar presentations


Presentation on theme: "CS4470 Computer Networking Protocols"— Presentation transcript:

1 CS4470 Computer Networking Protocols
4/5/2019 CS Computer Networking Protocols 17. TCP 4 Huiping Guo Department of Computer Science California State University, Los Angeles

2 Outline Flow control TCP congestion control 17. TCP CS4470

3 4/5/2019 TCP Flow Control Define the amount of data the sender can send before receiving an Ack from the destination Two extreme cases Send one byte and wait for Ack Extremely slow Send all of the data without waiting for Acks Speed up the process May overwhelm the receiver TCP uses a window Send as much data as defined by the window 17. TCP CS4470

4 TCP segment structure Flow control 17. TCP CS4470

5 TCP Sliding Window How to determine the window size?
Flow control: rwnd Congestion Control: cwnd 17. TCP CS4470

6 TCP Sliding Window The window size changes
Controlled by the receiver and the congestion in the network, not the sender The receiver window is the number of bytes the other end can accept before its buffer overflows and data is discarded The congestion window is a value determined by the network to avoid congestion TCP’s sliding windows are byte oriented 17. TCP CS4470

7 TCP Flow Control Receiver’s side of TCP connection has a receiving buffer: App. process may be slow at reading from buffer Two variables LastByteRead: the number of the last byte in the data stream read from the buffer by the application process LastByteRcvd: the number of the last byte that has arrived 17. TCP CS4470

8 TCP Flow control: how it works
Spare room in the receiver’s buffer RcvWnd = RcvBuffer-[LastByteRcvd - LastByteRead] Receiver advertises spare room by including value of RcvWnd in segments Sender limits unACKed data to RcvWindow LastByteSent-LastByteAcked<=RcvWindow guarantees receive buffer doesn’t overflow 17. TCP CS4470

9 Exercise 1 What is the value of the receiver window (rwnd) for host A if the receiver, host B, has a buffer size of 5,000 bytes and 1,000 bytes of received and unprocessed data? Solution The value of rwnd = 5,000 − 1,000 = 4,000. Host B can receive only 4,000 bytes of data before overflowing its buffer. Host B advertises this value in its next segment to A. 17. TCP CS4470

10 Exercise 2 What is the size of the window for host A if the value of rwnd is 3,000 bytes and the value of cwnd is 3,500 bytes? Solution The size of the window is the smaller of rwnd and cwnd, which is 3,000 bytes. 17. TCP CS4470

11 Exercise 3 The sender has sent bytes up to 202. We assume that cwnd is 20 The receiver has sent an acknowledgment number of 200 with an rwnd of 9 bytes The size of the sender window is the minimum of rwnd and cwnd or 9 bytes. Bytes 200 to 202 are sent, but not acknowledged. Bytes 203 to 208 can be sent without worrying about acknowledgment. Bytes 209 and above cannot be sent. 17. TCP CS4470

12 Exercise 3 17. TCP CS4470

13 Exercise 4 Following the previous exercise, the sender receives a packet with an acknowledgment value of 202 and an rwnd of 9. The sender has already sent bytes 203, 204, and 205. The value of cwnd is still 20. Show the new window. Solution The window closes from the left and opens from the right by an equal number of bytes, so the size of the window has not been changed. The acknowledgment value, 202, declares that bytes 200 and 201 have been received and the sender needs not worry about them; the window can slide over them. 17. TCP CS4470

14 Exercise 4 17. TCP CS4470

15 Exercise 5 Following the previous exercise, the sender receives a packet with an acknowledgment value of 206 and an rwnd of 12. The sender has not sent any new bytes. The value of cwnd is still 20. Show the new window. Solution The value of rwnd is less than cwnd, so the size of the window is 12. Note that the window has been opened from the right by 7 and closed from the left by 4; the size of the window has increased. 17. TCP CS4470

16 Exercise 5 17. TCP CS4470

17 MSS Maximum segment size (MSS) Why MSS?
The maximum amount of application data (in bytes) that can be put in a TCP segment Set based on the path MTU (Maximum Transmission Unit, link layer) Path MTU: the largest link layer frame that can be sent on all links from the source to destination Why MSS? Ensure that a single TCP segment (encapsulated in an IP datagram) can fit into a single link layer frame IP datagram fragmentation Fragment the data in the IP datagram into two or more smaller IP datagrams TCP prevents a segment from being fragmented by IP 17. TCP CS4470

18 Congestion Network congestion How congestion happens
The number of packets sent to the network is greater than the number of packets a network can handle How congestion happens Each interface of a router has an input and output buffer Input buffer overflow Arrival rate > processing rate Output buffer overflow Processing rate > departure rate 17. TCP CS4470

19 Router queues 17. TCP CS4470

20 Congestion Control What is congestion control How?
Prevent congestion before it happens Remove congestion after it has happened How? Adjust the congestion window size: cwnd Let’s now ignore recWindow 17. TCP CS4470

21 TCP Congestion Control
Three phases Slow start Congestion avoidance Congestion detection The algorithms in each phase are independent Some important variables Cwnd Threshold 17. TCP CS4470

22 Slow start algorithm The slow start phase is the phase right after the connection is established. The algorithm Cwnd starts with 1MSS Each time one new ACK arrives, cwnd is increased by 1MSS cwnd is effectively doubled per RTT “epoch” Cwnd keeps growing until Cwnd reaches threshold Or congestion occurs Cwnd starts slowly, but grows exponentially 17. TCP CS4470

23 TCP Slow Start Slow Start Add one MSS per ACK 17. TCP 4 CS4470 Source
Destination Slow Start Add one MSS per ACK 17. TCP CS4470

24 Congestion avoidance The phase after the slow start phase
Slow down the exponential growth Avoid congestion before it happens When congestion avoidance phase starts? cwnd >= Threshold The algorithm Each time the WHOLE WINDOW of packets is acknowledged, Cwin is increased by 1MSS cwnd is increased by 1/cwnd for each acknowledged segment (Additive increase) Cwin keeps growing LINEALLY until congestion happens 17. TCP CS4470

25 Congestion avoidance 17. TCP CS4470

26 Congestion detection Timeout 3 duplicate ACKs
Strong possibility of congestion A segment has probably been dropped No news about following segments TCP reacts strongly 3 duplicate ACKs Weaker possibility of congestion A segment may have been dropped Some segments after that may have arrived safely TCP applies fast recovery algorithm 17. TCP CS4470

27 Timeout Retransmit the lost packet Threshold = ½ cwnd Cwnd = 1
NOT threshold = ½ threshold! Cwnd = 1 Starts the slow start phase 17. TCP CS4470

28 17. TCP CS4470

29 Figure: Behavior of TCP Congestion Control
17. TCP CS4470

30 Fast Retransmit Coarse timeouts remained a problem, and Fast retransmit was added. Since the receiver responds every time a packet arrives, this implies the sender will see duplicate ACKs. Basic Idea: use duplicate ACKs to signal lost packet Fast recovery: upon receipt of three duplicate ACKs, the TCP Sender retransmits the lost packet. 17. TCP CS4470

31 Fast Retransmit Based on three duplicate ACKs 2 3 3 3 3 7
17. TCP CS4470

32 Fast recovery When fast retransmit detects three duplicate ACKs, start the recovery process After retransmit Threshold = ½ cwnd Cwnd = threshold (multiplicative decrease) Starts the congestion avoidance phase 17. TCP CS4470

33 Summary: TCP Congestion Control
3 dup ACKs 17. TCP CS4470

34 Congestion control example
17. TCP CS4470

35 TCP Congestion Window Trace
17. TCP CS4470

36 Exercise 17. TCP CS4470

37 Exercise Slow start time intervals Congestion avoidance interval
4/5/2019 Exercise Slow start time intervals Congestion avoidance interval At time 4, what happened? At time 4, if 3 duplicate acks are received, what’s the value of cwnd, threshold? Slow start time intervals 0-4, 5-8 Congestion avoidance interval 8- At time 4, what happened? Timeout or 3 duplicate acks are received? At time 4, if 3 duplicate acks are received, the value of cwnd, threshold? Cwnd=8, threshold=8 17. TCP CS4470


Download ppt "CS4470 Computer Networking Protocols"

Similar presentations


Ads by Google