Beruflich Dokumente
Kultur Dokumente
S E C O N D
E D I T I O N
Computer Networking
A Top-Down Approach Featuring the Internet
James F. Kurose
University of Massachusetts, Amherst
Keith W. Ross
Eurcom Institute
Executive Editor Assistant Editor Executive Marketing Manager Production Supervisor Production Services Composition Art Art Development Text and Cover Design Prepress and Manufacturing Media Producer
Susan Hartman Sullivan Galia Shokry Michael Hirsch Kim Ellwood Pre-Press Company, Inc. Pre-Press Company, Inc. Pat Rossi Calkin and Pre-Press Company, Inc. Janet Theurer Joyce Cosentino Wells Caroline Fell Jennifer Pelland
Access the latest information about Addison-Wesley Computing titles from our World Wide Web site: http://www.aw.com/cs The programs and applications presented in this book have been included for their instructional value. They have been tested with care, but are not guaranteed for any particular purpose. The publisher does not offer any warranties or representations, nor does it accept any liabilities with respect to the programs or applications. Library of Congress Cataloging-in-Publication Data Kurose, James F Computer networking: a top-down approach featuring the Internet / James F. Kurose, Keith W. Ross.2nd ed. p. cm. Rosss name appears first on the earlier edition. Includes bibliographical references and index. ISBN 0-201-97699-4 1. Internet. 2. Computer networks I. Ross, Keith W., 1956- II. Title. TK5105.875.I57 K88 2002 004.67'8dc21 Copyright 2003 by Pearson Education, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. ISBN 0-201-97699-4 12345678910-CRW-04030201
2002071100
Keith Ross
Keith Ross is a professor in the Multimedia Communications Department at Eurcom Institute. From 1985 through 1997 he was a Professor at the University of Pennsylvania where he held appointments in both the Department of Systems Engineering and the Wharton School of Business. In 1999, he co-founded the Internet startup Wimba.com. Dr. Ross has published over 50 papers and written two books. He has served on editorial boards of five major journals, and has served on the program committees of major networking conferences., including IEEE Infocom and ACM SIGCOMM. He has supervised more than ten Ph.D. theses. His research and teaching interests included multimedia networking, asynchronous learning, Web caching, streaming audio and video, and traffic modeling. He received his Ph.D. from the University of Michigan.
iii
To Julie and our three precious onesChris, Charlie, and Nina JFK
To my wife, Vronique, and our trois petits pois, Ccile, Claire, and Katie KWR
Preface
Welcome to the second edition of Computer Networking: A Top-Down Approach Featuring the Internet. Since the publication of the first edition two years ago, our book has been adopted for use at hundreds of colleges and universities and used by tens of thousands of students and practitioners worldwide. Weve heard from many of these readers and have been overwhelmed by the positive response. We think one important reason for this success is that the book offers a fresh approach to computer networking instruction. Why is a fresh approach needed? In recent years we have witnessed two revolutionary changes in the field of networkingchanges that are not reflected in the networking texts published in the 1980s and 1990s. First, the Internet has taken over computer networking. Any serious discussion about computer networking today has to be done with the Internet in mind. Second, over the past ten years the biggest growth area has been in networking services and applications, which can be seen with the emergence of the Web, ubiquitous use of e-mail, audio and video streaming, Internet phone, instant messaging, peerto-peer applications, and online commerce.
Audience
This textbook is for a first course on computer networking. It can be used in both computer science and electrical engineering departments. In terms of programming languages, the book assumes only that the student has experience with C, C++, or Java. A student who has programmed only in C or C++ and not Java should not have any difficulty following the application programming material, even though this material is
Preface
presented in a Java context. Although this book is more precise and analytical than many other introductory computer networking texts, it rarely uses any mathematical concepts that are not taught in high school. We have made a deliberate effort to avoid using any advanced calculus, probability, or stochastic process concepts. The book is therefore appropriate for undergraduate courses and for first-year graduate courses. It should also be useful to practitioners in the telecommunications industry.
A Top-Down Approach
Unlike the other computer networking texts, this text is organized in a top-down mannerthat is, it begins at the application layer and works its way down toward the physical layer. The top-down approach has several important benefits. First, it places emphasis on the application layer, which has been the high growth area of computer networking. Indeed, many of the recent revolutions in computer networking including the Web, audio and video streaming, and content distributionhave taken place at the application layer. In preparing the first edition of this book, we believed that the application layer would remain the highest growth area in the field, both in terms of research and actual deployment. The intervening years have unquestionably shown this to be true! An early emphasis on application-layer issues differs from the approaches taken in most other texts, which have only a small (or nonexistent) amount of material on network applications, their requirements, application-layer paradigms (e.g., client/server), and the application programming interfaces. Second, our experience as instructors has been that teaching networking applications near the beginning of the course is a powerful motivational tool. Students are thrilled to learn about how networking applications workapplications such as email and the Web, which most students use on a daily basis. Once a student understands the applications, the student can then understand the network services needed
Preface
xi
to support these applications. The student can then, in turn, examine the various ways in which such services might be provided and implemented in the lower layers. Covering applications early thus provides motivation for the remainder of the text. Third, the top-down approach enables instructors to introduce network application development at an early stage. Students not only see how popular applications and protocols work, but also learn how easy it is to create their own network applications and application-level protocols. Other introductory computer networking texts do not cover application development and socket programming. (Even though there are books devoted to network programming, there are no introductory networking textbooks.) By providing socket programming examples in Java, we highlight the central ideas without confusing students with complex code. Undergraduates in electrical engineering and computer science should not have difficulty following the Java code. Thus, with the top-down approach, students get early exposure to the notions of application programming interfaces (APIs), service models, and protocolsimportant concepts that resurface in all of the subsequent layers.
An Internet Focus
As indicated by the title, this textbook features the Internet. Most existing textbooks give significant weight to a variety of telecommunications networks and protocol suites, and they treat the Internet as one of many networking technologies. We instead put the Internet in the spotlight and use the Internet protocols as vehicles for studying some of the more fundamental computer networking concepts. But why put the Internet in the spotlight? Why not some other networking technology, such as ATM? First, computer networking is now synonymous with the Internet. This wasnt the case five to ten years ago, when there was a lot of talk about ATM LANs and applications directly interfacing with ATM (without passing through TCP/IP). But now we have reached the point where just about all data traffic is carried over the Internet (or intranets). Today, the only other type of network that competes with the Internet is the circuit-switched telephone network. And this competitor may also disappear. Although today the majority of voice traffic is carried over the telephone networks, networking equipment manufacturers and telephone company operators are currently preparing for a major migration to Internet technology. Another benefit of spotlighting the Internet is that most computer science and electrical engineering students are eager to learn about the Internet and its protocols. They use the Internet on a daily basis (at least to send e-mail and surf the Web), and theyve heard that the Internet is a revolutionary and disruptive technology profoundly changing our world. Given the enormous relevance of the Internet, students are naturally curious about what is under the hood. Thus, it is easy for an instructor to get students excited about the basic principles when using the Internet as the guiding focus. Because our book has an Internet focus, it is organized around a five-layer Internet architecture rather than around the more traditional seven-layer OSI architecture. These five layers consist of the application, transport, network, link, and physical layers.
xii
Preface
Preface
xiii
We also expect to be constantly expanding the Web site, adding contributed material from instructors and readers as well as our own new features. Updates should occur about every three months. If you have any problems with the Web site, send mail to aw.cse@aw.com.
Pedagogical Features
We have each been teaching computer networking for almost 20 years. We bring to this text more than combined 30 years of teaching experience to over 3,000 students. We have also been active researchers in computer networking during this time. (In fact, Jim and Keith first met each other as masters students in a computer networking course taught by Mischa Schwartz in 1979 at Columbia University.) We think all this gives us a good perspective on where networking has been and where it is likely to go in the future. Nevertheless, we have resisted temptations to bias the material in this book towards our own pet research projects. We figure you can visit our personal Web sites if you are interested in our research. Thus, this book is about modern computer networkingit is about contemporary protocols and technologies as well as the underlying principles behind these protocols and technologies. We also believe that learning (and teaching!) about networking can be fun. A sense of humor, use of analogies, and real-world examples in this book will hopefully make this material more fun.
Interviews
We have included yet another original feature that should inspire and motivate studentsinterviews with renowned innovators in the field of networking. We provide
xiv
Preface
interviews with Len Kleinrock, Tim Berners-Lee, Sally Floyd, Vint Cerf, Bob Metcalfe, Henning Schulzrinne, Steven Bellovin, and Jeff Case.
Chapter Dependencies
The first chapter of this text presents a self-contained overview of computer networking. Introducing many key concepts and terminology, this chapter sets the stage for the rest of the book. All of the other chapters directly depend on this first chapter. We recommend that, after completing Chapter 1, instructors cover Chapters 2 through 5 in sequence, thereby teaching according to the top-down philosophy. Each of these five chapters leverages material from the preceding chapters. After completing the first five chapters, the instructor has quite a bit of flexibility. There are no interdependencies among the last three chapters, so they can be
Preface
xv
taught in any order. However, each of the last three chapters depends on the material in the first five chapters. Ideally, the instructor will have time to teach selected material from all three final chapters in a full semester course. We also note that the first chapter of the text, being comprehensive and selfcontained, can serve as the foundation of a short course on networking.
Acknowledgements
Since we began writing this book in 1996, many people have given us invaluable help and have been influential in shaping our thoughts on how to best organize and teach a networking course. We want to say A BIG THANKS to everyone who has helped. We are also very thankful to the hundreds of readers from around the world students, faculty, practitionerswho have sent us thoughts and comments on earlier editions of the book and suggestions for future editions of the book. Special thanks go out to: Al Aho (Lucent Bell Laboratories) Pratima Akkunoor (Arizona State University) Paul Amer (University of Delaware) Shamiul Azom (Arizona State University) Paul Barford (University of Wisconsin)
xvi
Preface
Steven Bellovin (AT&T Research) Shahid Bokhari (University of Engineering & Technology, Lahore) Ernst Biersack (Eurcom Institute) Daniel Brushteyn (former University of Pennsylvania student) Evandro Cantu (Federal University of Santa Catarina) Jeff Case (SNMP Research International) Vinton Cerf (MCI WorldCom) John Daigle (University of Mississippi) Edmundo A. de Souza e Silva (Federal University of Rio de Janiero) Philippe Decuetos (Eurcom Institute) Christophe Diot (Sprint) Michalis Faloutsos (University of California at Riverside) Wu-chi Feng (Oregon Graduate Institute) Sally Floyd (ICIR, University of California at Berkeley) JJ Garcia-Luna-Aceves (University of California at Santa Cruz) Mario Gerla (University of California at Los Angeles) Tim Griffin, AT&T Research Max Hailperin (Gustavus Adolphus College) Bruce Harvey (Florida A&M University, Florida State University) Carl Hauser (Washington State University) Phillipp Hoschka (INRIA/W3C) Albert Huang (former University of Pennsylvania student) Jobin James (University of California at Riverside) Sugih Jamin (University of Michigan) Shivkumar Kalyanaraman (Rensselaer Polytechnic Institute) Jussi Kangasharju (Eurcom Institute) Hyojin Kim (former University of Pennsylvania student) Leonard Kleinrock (University of California at Los Angeles) David Kotz (Dartmouth College) Beshan Kulapala (Arizona State University) Steve Lai (Ohio State University) Tim-Berners Lee (World Wide Web Consortium) Brian Levine (University of Massachusetts) William Liang (former University of Pennsylvania student) Willis Marti (Texas A&M University) Deep Medhi (University of Missouri, Kansas City) Bob Metcalfe (International Data Group) Erich Nahum (IBM Research) Christos Papadopoulos (University of Southern California) Craig Partridge (BBN Technologies) Radia Perlman (Sun Microsystems) Jitendra Padhye (Microsoft Research) George Polyzos (University of California at San Diego) Sriram Rajagopalan (Arizona State University)
Preface
xvii
Ken Reek (Rochester Institute of Technology) Martin Reisslein (Arizona State University) Jennifer Rexford (AT&T Research) Sumit Roy (University of Washington) Avi Rubin (Johns Hopkins University) Despina Saparilla (Lucent Bell Labs) Henning Schulzrinne (Columbia University) Mischa Schwartz (Columbia University) K. Sam Shanmugan (University of Kansas) Prashant Shenoy (University of Massachusetts) Clay Shields (Georgetown University) Subin Shrestra (University of Pennsylvania) Peter Steenkiste (Carnegie Mellon University) Tatsuya Suda (University of California at Irvine) Kin Sun Tam (State University of New York at Albany) Don Towsley (University of Massachusetts) David Turner (California State University, San Bernardino) Ira Winston (University of Pennsylvania) Raj Yavatkar (Intel) Yechiam Yemini (Columbia University) Ellen Zegura (Georgia Institute of Technology) Hui Zhang (Carnegie Mellon University) Lixia Zhang (University of California at Los Angeles) ZhiLi Zhang (University of Minnesota) Lixia Zhang (University of California at Los Angeles) Shuchun Zhang (former University of Pennsylvania student) Phil Zimmermann (independent consultant) We also want to thank the entire Addison-Wesley team, who have done an absolutely outstanding job (and who have put up with two very finicky authors!): Kim Ellwood, Susan Hartman Sullivan, Michael Hirsch, Patty Mahtani, Galia Shokry, and Joyce Wells. Thanks also to the artists, Janet Theurer and Patrice Rossi Calkin, for their work on the beautiful figures in the second edition. Special thanks go to Susan, our editor at Addison-Wesley. This book could not and would not have been completed without her management, encouragement, patience, and perseverance.
Table of Contents
Chapter 1 Computer Networks and the Internet
1.1 What Is the Internet? 1.1.1 A Nuts-and-Bolts Description 1.1.2 A Service Description 1.1.3 What Is a Protocol? 1.1.4 Some Good Hyperlinks The Network Edge 1.2.1 End Systems, Clients, and Servers 1.2.2 Connectionless and Connection-Oriented Service The Network Core 1.3.1 Circuit Switching and Packet Switching 1.3.2 Packet Forwarding in Computer Networks Network Access and Physical Media 1.4.1 Network Access 1.4.2 Physical Media ISPs and Internet Backbones Delay and Loss in Packet-Switched Networks 1.6.1 Types of Delay 1.6.2 Queuing Delay and Packet Loss 1.6.3 Delay and Routes in the Internet Protocol Layers and Their Service Models 1.7.1 Layered Architecture 1.7.2 The Internet Protocol Stack 1.7.3 Network Entities and Layers History of Computer Networking and the Internet 1.8.1 The Development of Packet Switching: 19611972 1.8.2 Proprietary Networks and Internetworking: 19721980 1.8.3 A Proliferation of Networks: 19801990 1.8.4 The Internet Explosion: The 1990s 1.8.5 Recent Developments
1
2 2 5 6 8 9 9 12 14 14 25 29 30 35 39 41 41 45 47 49 50 54 57 58 58 60 61 62 64
1.2
1.3
1.4
1.5 1.6
1.7
1.8
xix
xx
Table of Contents
1.9
Summary Homework Problems and Questions Problems Discussion Questions Interview: Leonard Kleinrock
65 67 68 73 74
76
77 78 83 85 87 88 89 91 94 99 101 103 103 105 106 108 111 112 117 121 122 124 129 131 133 134 136 143 151 151 155 156 162 165
2.2
2.3 2.4
2.5
2.6
Table of Contents
xxi
2.10
Summary Homework Problems and Questions Problems Discussion Questions Programming Assignments Interview: Tim Berners-Lee
184
185 185 188 190 196 199 200 201 203 214 217 222 228 228 230 235 238 246 248 253 253 259 260 262 268 271 280 281 282 290 291
xxii
Table of Contents
293
294 296 300 301 304 308 317 317 321 322 330 333 336 339 340 342 346 346 353 358 360 362 364 365 368 369 372 375 375 379 383 388 391 391 393 400 405 406 408 414 417
Table of Contents
xxiii
419
421 421 424 425 427 429 430 432 434 438 446 447 449 449 451 455 456 460 462 466 467 468 476 480 481 487 488 490 492 494 495 497 499 500 502 505 505 506 510 511 513 519 520
xxiv
Table of Contents
522
523 523 526 527 528 531 532 535 537 541 541 543 546 549 550 550 555 558 563 565 566 567 568 570 572 572 576 579 580 581 582 582 584 587 588 590 592 593
6.2
6.3
6.4
6.5
6.6
6.7
6.8
6.9
Table of Contents
xxv
6.10
Summary Homework Problems and Questions Problems Discussion Questions Programming Assignment Interview: Henning Schulzrinne
604
605 608 610 614 620 621 621 622 623 623 624 627 628 629 631 633 635 636 640 641 644 646 646 646 648 648 650 650 651 656 660 663
7.3
7.4
7.5
7.6
7.7
7.8
xxvi
Table of Contents
7.9
Summary Homework Problems and Questions Problems Discussion Questions Interview: Steven M. Bellovin
672
673 677 680 681 684 686 690 693 698 698 699 700 701 703 733
Computer Networking
A Top-Down Approach Featuring the Internet
Second Edition