You are on page 1of 649

EE 122:TCP Congestion Control

Ion Stoica
TAs: Junda Liu, DK Moon, David Zats
http://inst.eecs.berkeley.edu/~ee122/
(Materials with thanks to Vern Paxson, Jennifer Rexford,
and colleagues at UC Berkeley)
1

Goals of Todays Lecture

Principles of congestion control

Learning that congestion is occurring


Adapting to alleviate the congestion

TCP congestion control

Additive-increase, multiplicative-decrease (AIMD)


How to begin transmitting: Slow Start

What We Know
We know:
How to process packets in a switch
How to route packets in the network
How to send packets reliably
We dont know:
How fast to send

Its Not Just The Sender &


Receiver
Flow control keeps one fast sender from
overwhelming a slow receiver
Congestion control keeps a set of senders from
overloading the network
Three congestion control problems:

Adjusting to bottleneck bandwidth

Without any a priori knowledge


Could be a Gbps link; could be a modem

Adjusting to variations in bandwidth


Sharing bandwidth between flows
4

Congestion is Unavoidable

Two packets arrive at the same time

The node can only transmit one


and either buffers or drops the other

If many packets arrive in a short period of time

The node cannot keep up with the arriving traffic


and the buffer may eventually overflow

Congestion Collapse

Definition: Increase in network load results in a decrease of


useful work done
Due to:
Undelivered packets
Packets consume resources and are dropped later in
network
Spurious retransmissions of packets still in flight
Unnecessary retransmissions lead to more load!
Pouring gasoline on a fire
Mid-1980s: Internet grinds to a halt
Until Jacobson/Karels (Berkeley!) devise TCP congestion
control
6

Knee point after which

Throughput increases very


slowly
Delay increases quickly

knee

congestion
collapse

Cliff point after which

Throughput starts to
decrease very fast to zero
(congestion collapse)
Delay approaches infinity

packet
loss

cliff

Load

Delay

Throughput

View from a Single Flow

Load

General Approaches

Send without care

Many packet drops

(1) Reservations

Pre-arrange bandwidth allocations


Requires negotiation before sending packets
Low utilization

(2) Pricing

Dont drop packets for the high-bidders


Requires payment model
8

General Approaches (contd)


(3) Dynamic Adjustment

Probe network to test level of congestion


Speed up when no congestion
Slow down when congestion
Suboptimal, messy dynamics, simple to implement

All three techniques have their place

But for generic Internet usage, dynamic adjustment is


the most appropriate
Due to pricing structure, traffic characteristics, and
good citizenship
9

TCP Congestion Control

TCP connection has window

Controls number of unacknowledged packets

Sending rate: ~Window/RTT

Vary window size to control sending rate

10

Sizing the Windows

cwnd (Congestion Windows)

How many bytes can be sent without


overflowing routers
Computed by congestion control algorithm

AdvertisedWindow

How many bytes can be sent without


overflowing the sender
Determined by the receiver

11

EffectiveWindow
Limits how much data can be in transit
Implemented as # of bytes
Described as # packets (segments) in this
lecture

MaxWindow = min(cwnd, AdvertisedWindow)


EffectiveWindow = MaxWindow (LastByteSent LastByteAcked)
MaxWindow
LastByteAcked

LastByteSent EffectiveWindow

sequence number increases

12

Two Basic Components

Detecting congestion

Rate adjustment algorithm

Depends on congestion or not


Three subproblems within adjustment problem

Finding fixed bandwidth


Adjusting to bandwidth variations
Sharing bandwidth

13

Detecting Congestion

Packet dropping is best sign of congestion

Delay-based methods are hard and risky

How do you detect packet drops? ACKs

TCP uses ACKs to signal receipt of data


ACK denotes last contiguous byte received

Actually, ACKs indicate next segment expected

Two signs of packet drops

No ACK after certain time interval: time-out


Several duplicate ACKs (ignore for now)
14

Rate Adjustment

Basic structure:

Upon receipt of ACK (of new data): increase rate


Upon detection of loss: decrease rate

But what increase/decrease functions should we


use?

Depends on what problem we are solving

15

Problem #1: Single Flow, Fixed BW

Want to get a first-order estimate of the available


bandwidth

Assume bandwidth is fixed


Ignore presence of other flows

Want to start slow, but rapidly increase rate until


packet drop occurs (slow-start)

Adjustment:

cwnd initially set to 1


cwnd++ upon receipt of ACK
16

Slow-Start

cwnd increases exponentially: cwnd doubles every


time a full cwnd of packets has been sent
Each ACK releases two packets
Slow-start is called slow because of starting point
cwnd = 1

segment 1

cwnd = 2

segment 2
segment 3

cwnd =
3 =
cwnd
4

segment 4
segment 5
segment 6
segment 7

cwnd =
8
17

5 Minute Break
Questions Before We Proceed?

18

Problems with Slow-Start

Slow-start can result in many losses

Example:

Roughly the size of cwnd ~ BW*RTT

At some point, cwnd is enough to fill pipe


After another RTT, cwnd is double its previous value
All the excess packets are dropped!

Need a more gentle adjustment algorithm once


have rough estimate of bandwidth
19

Problem #2: Single Flow, Varying BW

Want to be able to track available bandwidth, oscillating


around its current value

Possible variations: (in terms of RTTs)

Multiplicative increase or decrease: cwnd a*cwnd


Additive increase or decrease: cwnd cwnd + b

Four alternatives:

AIAD: gentle increase, gentle decrease


AIMD: gentle increase, drastic decrease
MIAD: drastic increase, gentle decrease (too many losses)
MIMD: drastic increase and decrease

20

Problem #3: Multiple Flows

Want steady state to be fair

Many notions of fairness, but here all we require


is that two identical flows end up with the same
bandwidth

This eliminates MIMD and AIAD

AIMD is the only remaining solution!


21

Buffer and Window Dynamics


A

Rate (pkts/RTT)

60
50
40
30

Backlog in router (pkts)


Congested if > 20

20
10

22

487

460

433

406

379

352

325

298

271

244

217

190

163

136

109

82

55

28

C = 50 pkts/RTT

No congestion x increases by one packet/RTT every RTT


Congestion decrease x by factor 2

AIMD Sharing Dynamics


x1
x2

A
D
60

Rates equalize fair share

50
40
30
20

487

460

23

406

379

352

325

298

271

244

217

190

163

136

109

82

55

433

10

28

No congestion rate increases by one packet/RTT every RTT


Congestion decrease rate by factor 2

AIAD Sharing Dynamics


x1
x2

A
D
60
50
40
30
20
10

24

487

460

433

406

379

352

325

298

271

244

217

190

163

136

109

82

55

0
28

No congestion x increases by one packet/RTT every RTT


Congestion decrease x by 1

Efficient Allocation: Challenges of


Congestion Control
Too slow

Too fast

Overshoot knee overload,


high delay, loss

Everyones doing it

May all under/over shoot


large oscillations

Optimal:

x =X
i

2 user example

Fail to take advantage of


available bandwidth
underload

goal

User 2: x2

overload

Efficiency
line

underload

User 1: x1

Efficiency = 1 - distance
from efficiency line
25

Example
1
Efficient: x1+x2=1
Fair

Total bandwidth 1

Congested: x1+x2=1.2

User 2: x2

fairness
line

(0.2, 0.5)

(0.5, 0.5)

Inefficient: x1+x2=0.7

(0.7, 0.5)

(0.7, 0.3)
Efficient: x1+x2=1
Not fair

efficiency
line

User 1: x1
26

MIAD
Increase: x*bI

Decrease: x - aD

Does not converge


to fairness
Does not converges
to efficiency

(bI(x1h-aD), bI(x2h-aD))
(x1h,x2h)

User 2: x2

fairness
line

(x1h-aD,x2h-aD)

efficiency
line

User 1: x1
27

AIAD
Increase: x + aI

Decrease: x - aD

Does not
converge to
fairness
Does not
converge to
efficiency

(x1h,x2h)

User 2: x2

fairness
line

(x1h-aD+aI),
x2h-aD+aI))

(x1h-aD,x2h-aD)

efficiency
line

User 1: x1
28

MIMD

Increase: x*bI

Decrease: x*bD

Does not
converge to
fairness
Converges to
efficiency iff

fairness
line

(x1h,x2h)
(bIbDx1h,
bIbDx2h)

User 2: x2

(bdx1h,bdx2h)

bI 1
0 bD 1

efficiency
line

User 1: x1
29

AIMD
Increase: x+aD

Decrease: x*bD

Converges to fairness
Converges to
efficiency
Increments smaller
as fairness increases

(x1h,x2h)
(bDx1h+aI,
bDx2h+aI)

User 2: x2

fairness
line

(bDx1h,bDx2h)

efficiency
line

User 1: x1
30

Implementing AIMD

After each ACK

Increment cwnd by 1/cwnd (cwnd += 1/cwnd)


As a result, cwnd is increased by one only if all
segments in a cwnd have been acknowledged

But need to decide when to leave slow-start and


enter AIMD

Use ssthresh variable

31

Slow Start/AIMD Pseudocode


Initially:
cwnd = 1;
ssthresh = infinite;
New ack received:
if (cwnd < ssthresh)
/* Slow Start*/
cwnd = cwnd + 1;
else
/* Congestion Avoidance */
cwnd = cwnd + 1/cwnd;
Timeout:
/* Multiplicative decrease */
ssthresh = cwnd/2;
cwnd = 1;

32

The big picture (with timeouts)


cwnd
Timeout

AIMD

Timeout
AIMD

ssthresh

Slow
Start

Slow
Start

Slow
Start

Time

33

Summary

Congestion is inevitable

Congestion control critical for avoiding collapse

Internet does not reserve resources in advance


TCP actively tries to grab capacity
AIMD: Additive Increase, Multiplicative Decrease
Congestion detected via packet loss (fail-safe)
Slow start to find initial sending rate & to restart after
timeout

Next class

Advanced congestion control


34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

You might also like