24
CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

CSEE W4140Networking Laboratory

Lecture 7: TCP flow control and congestion control

Jong Yul Kim03.22.2010

Page 2: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Short review of TCP from last time

Characteristics of the IP network Delivers packets from host to host May lose packets (discarded by routers) Doesn’t care about packet order

TCP is a reliable, in-order, byte-stream service (delivers data from application to application)

Page 3: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Short review of TCP from last time TCP is a reliable, in-order, byte-stream

service The beauty of TCP is that it works without

explicit support from the network Each end of the connection cooperate to make

sure packets are delivered reliably and in order

Techniques used by TCP Sequence numbers Acknowledgements (and numbers) Retransmissions Timer

Page 4: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Today’s lecture

TCP Flow Control Throttling the rate of sender so that the

receiver’s buffer does not overflow

TCP Congestion Control Throttling the rate of sender in the face

of network congestion

Page 5: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

TCP Flow Control (Receive Window) When a connection is established, the

receiver allocates a receive buffer. Incoming packets are stored in the buffer

so that the application can read data from the buffer.

Page 6: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

TCP Flow Control (Receiver behavior)

The receiver lets the sender know: how much space is

left in the buffer= RcvWindow

by placing that value in the window size field

in every segment that it sends to the sender

IP header TCP header TCP data

Sequence number (32 bits)

DATA

20 bytes 20 bytes

0 15 16 31

Source Port Number Destination Port Number

Acknowledgement number (32 bits)

window sizeheaderlength

0 Flags

Options (if any)

TCP checksum urgent pointer

20 bytes

Page 7: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

TCP Flow Control (Sender behavior)

Sender can fill up the spare room in the receiver’s buffer by sending more data

Sender maintains the size of data that has already been sent but unacknowledged = bytes_unACKed

Makes sure that bytes_unACKed ≤ RcvWindow

Page 8: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Network Congestion Why does congestion occur?

Too many senders sending at high rate Routers dropping packets due to overflowing

buffers

What are the symptoms? Packet loss Packet queuing delay More retransmission more packet loss Link bandwidth wasted on retransmissions

Page 9: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

TCP Congestion Control

Remember: TCP has no support from the network about congestions Need to use end-to-end congestion

control

TCP relies on perceived network congestion and throttles the sending rate accordingly

Page 10: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

How does TCP know there is congestion in the network?

Answer: packet loss Timeout Three duplicate

ACKs shown in diagram on right

Page 11: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

How does TCP limit sending rate?

Using a variable called congestion window = CongWin

Size of unacknowledged data must be less than CongWin bytes_unACKed ≤ CongWin

Sending rate is roughly CongWin/RTT bytes/sec

We can throttle the sending rate by controlling CongWin

Page 12: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

TCP Congestion Control Algorithm Is an algorithm that controls CongWin

Simply stated: Packet loss (=congestion) decrease CongWin All is well increase CongWin

Three main parts Additive-Increase, Multiplicative Decrease Slow Start Reaction to timeout events

Page 13: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Additive Increase, Multiplicative Decrease (AIMD)

Additive Increase Increase CongWin by 1 MSS every RTT

while there is no packet loss

Multiplicative Decrease Decrease CongWin by half when packet

is lost

Page 14: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Additive Increase, Multiplicative Decrease (AIMD)

Congestion Avoidance phase

Page 15: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Slow Start (SS)

When connection is established CongWin is set to 1 MSS Increase CongWin by 1 MSS every ACK

Different from Additive Increase (+1 MSS every RTT)

Until a loss occurs

Result is an exponentially fast growth in sending rate

Page 16: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Slow Start (SS)

Page 17: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Example of Slow Start/Congestion Avoidance

Assume that ssthresh = 8

cwnd = 1

cwnd = 2

cwnd = 4

cwnd = 8

cwnd = 9

cwnd = 10

0

2

4

6

8

10

12

14

t=0

t=2

t=4

t=6

Roundtrip times

Cw

nd

(in

seg

men

ts)

ssthresh

Page 18: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010
Page 19: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Reaction to Timeouts We already discussed that TCP perceives

congestion through packet loss

Packet is considered lost when: Timeout occurs Three duplicate ACKs are received

But timeouts and three duplicate ACKs are different. What do they tell about the severity of

congestion?

Page 20: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Reaction to Timeouts Let’s do something different for

timeout. Reset CongWin to 1 MSS Begin again from Slow Start Slow start (exponential increase) until

when? New variable called Threshold

Threshold is set to ½ CongWin After Threshold, do AIMD instead of SS

Page 21: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Lab 5 part 2 in the lab manual

PC1

R1 R2

R3 R4

PC210.0.3.0/24

10.0.2.0/2410.0.1.0/24

10.0.5.0/24

10.0.4.0/24

Serial WAN connection

Page 22: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Lab 5 part 2 – our version

PC1

R1 R2

PC2

10.0.3.0/24 10.0.2.0/2410.0.1.0/24

10.0.5.0/24

Use Table 5.3 and Table 5.4 to configure PC1, PC2, Router1, and Router2.

Do parts 5(B), 6(A), 6(C), and 8.

For part 8, configure PC1 and PC2 so that all packets travel along PC1 – R1 – R2 – PC2 path.

Page 23: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Main Points of Lab 5 Parts 5~8

More about TCP Interactive applications over TCP Data transfer applications over TCP Congestion Control

Page 24: CSEE W4140 Networking Laboratory Lecture 7: TCP flow control and congestion control Jong Yul Kim 03.22.2010

Prelab and lab reports

Prelab 6 is due this Friday.

Lab report 5.1 is due this week before your labs.

Lab report 5.2 + BGP lab is due next week before your labs.