COMPUTER AND COMMUNICATION NETWORKS

Nader F. Mir

Upper Saddle River, NJ . Boston . Indianapolis . San Francisco . New York Toronto . Montreal . London . Munich . Paris . Madrid . Capetown Sydney . Tokyo . Singapore . Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the United States, please contact: International Sales [email protected]

This Book Is Safari Enabled The Safari® Enabled icon on the cover of your favorite technology book means the book is available through Safari Bookshelf. When you buy this book, you get free access to the online edition for 45 days. Safari Bookshelf is an electronic reference library that lets you easily search thousands of technical books, find code samples, download chapters, and access technical information whenever and wherever you need it. To gain 45-day Safari Enabled access to this book:

. Go to http://www.prenhallprofessional.com/safarienabled . Complete the brief registration form . Enter the coupon code VZGY-SBEH-4Q1D-K8IN-BX58 If you have difficulty registering on Safari Bookshelf or accessing the online edition, please e-mail customer- [email protected].

Visit us on the Web: www.prenhallprofessional.com Library of Congress Cataloging-in-Publication Data Mir, Nader F. Computer and communication networks / Nader F. Mir. p. cm. Includes bibliographical references and index. ISBN 0-13-174799-1 (hardcover : alk. paper) 1. Computer networks. 2. Data transmission systems. I. Title. TK5105.5M567 2006 004.6—dc22 2006025914 Copyright © 2007 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc. Rights and Contracts Department One Lake Street Upper Saddle River, NJ 07458 Fax: (201) 236-3290 ISBN 0-13-174799-1 Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana. First printing, November 2006 Contents

Preface xxi About the Author xxxi

PART I: Fundamental Concepts 1

1 Packet-Switched Networks 3 1.1 Basic Definitions in Data Networks 4 1.1.1 Packet Switching versus Circuit Switching 4 1.1.2 Messages, Packets, and Frames 5 1.1.3 The Internet 6 1.1.4 ISPs and Internetwork Components 9 1.2 Types of Packet-Switched Networks 10 1.2.1 Connectionless Networks 11 1.2.2 Connection-Oriented Networks 13 1.3 Packet Size and Optimizations 14 1.4 Summary 16 1.5 Exercises 17

2 Foundation of Networking Protocols 19 2.1 5-Layer TCP/IP Model 20 2.2 7-Layer OSI Model 22 2.3 Internet Protocols and Addressing 23 2.3.1 IP Packet 23 2.3.2 IP Addressing Scheme 24 2.3.3 Subnet Addressing and Masking 25 viii Contents

2.3.4 Classless Interdomain Routing (CIDR) 27 2.3.5 Packet Fragmentation and Reassembly 28 2.3.6 Internet Control Message Protocol (ICMP) 29 2.3.7 IP Version 6 (IPv6) 30 2.4 Equal-Sized Packets Model: ATM 33 2.4.1 ATM Protocol Structure 34 2.4.2 ATM Cell Structure 36 2.5 Summary 39 2.6 Exercises 39

3 Networking Devices 43 3.1 Multiplexers 43 3.1.1 Frequency-Division Multiplexing (FDM) 44 3.1.2 Wavelength-Division Multiplexing (WDM) 44 3.1.3 Time-Division Multiplexing 45 3.2 Modems and Internet Access Devices 50 3.2.1 Line Coding Methods 50 3.2.2 Digital Modulation Techniques 52 3.2.3 Digital Subscriber Line (DSL) Modems 54 3.2.4 Cable Modems 56 3.3 Switching and Routing Devices 57 3.3.1 Repeaters, Hubs, and Bridges 57 3.3.2 Routers and Higher-Layer Switches 59 3.4 Router Structure 60 3.4.1 Input Port Processor (IPP) 60 3.4.2 Switch Fabric 63 3.4.3 Switch Controller 64 3.4.4 Output Port Processors (OPP) 65 3.5 Summary 67 3.6 Exercises 67

4 Data Links and Transmission 71 4.1 Data Links 72 4.2 Wired Links and Transmission 73 4.2.1 Twisted-Pair Links 73 4.2.2 Coaxial Cable 73 4.2.3 Optical Fiber 73 4.3 Wireless Links and Transmission 74 4.3.1 Choice of Antenna 75 Contents ix

4.3.2 Wireless Channels 76 4.3.3 Capacity Limits of Wireless Channels 79 4.3.4 Channel Coding 79 4.3.5 Flat-Fading Countermeasures 79 4.3.6 Intersymbol Interference Countermeasures 80 4.3.7 Orthogonal Frequency Division Multiplexing (OFDM) 81 4.4 Methods of Channel Access on Links 82 4.4.1 Frequency-Division Multiple Access 83 4.4.2 Time-Division Multiple Access 83 4.4.3 Code-Division Multiple Access 85 4.4.4 Space-Division Multiple Access 87 4.4.5 Hybrid Multiple-Access Techniques 87 4.5 Error Detection and Correction 87 4.5.1 Error Detection Methods 89 4.5.2 Cyclic Redundancy Check (CRC) Algorithm 89 4.6 Link-Level Flow Control 94 4.6.1 Stop-and-Wait Flow Control 95 4.6.2 Sliding-Window Flow Control 96 4.7 Summary 98 4.8 Exercises 99

5 Local Area Networks and Networks of LANs 101 5.1 LANs and Basic Topologies 102 5.2 LAN Protocols 103 5.2.1 Logical-Link Layer (LLC) 103 5.2.2 Medium Access Control (MAC) 104 5.3 MAC and IP Addresses 104 5.3.1 Address Resolution Protocol (ARP) 105 5.3.2 Reverse Address Resolution Protocol (RARP) 106 5.4 Classification of MAC Protocols 106 5.5 Contention-Access MAC 107 5.5.1 Carrier Sense Multiple Access (CSMA) 108 5.5.2 Ethernet LAN: IEEE 802.3 Standard 113 5.6 Round-Robin-Access MAC 114 5.6.1 Token-Ring Access Protocol 114 5.6.2 Token-Ring: IEEE 802.5 Standard 116 5.7 Network of LANs 116 5.7.1 Using Repeaters, Hubs, and Bridges 117 5.7.2 Layers 2 and 3 Switches 124 x Contents

5.8 Summary 125 5.9 Exercises 126

6 Wireless Networks and Mobile IP 129 6.1 Infrastructure of Wireless Networks 130 6.2 Wireless LAN Technologies 131 6.2.1 Infrared LANs 132 6.2.2 Spread-Spectrum LANs 133 6.2.3 Narrowband RF LANs 133 6.2.4 Home RF and Bluetooth 134 6.3 IEEE 802.11 Wireless Standard 134 6.3.1 802.11 Physical Layer 136 6.3.2 802.11 MAC Layer 137 6.3.3 WiFi Technology and 802.11 141 6.4 Cellular Networks 142 6.4.1 Connectivity 143 6.4.2 Frequency Reuse 146 6.4.3 Local and Regional Handoffs 149 6.4.4 Mobility Management 150 6.4.5 Generations of Cellular Systems 154 6.4.6 CDMA-Based Mobile Wireless 154 6.5 Mobile IP 155 6.5.1 Addresses and Agents 156 6.5.2 Agent Discovery Phase 157 6.5.3 Registration 158 6.5.4 Mobile IP Routing 159 6.5.5 Security 163 6.6 Wireless Mesh Networks (WMNs) 163 6.6.1 WiMAX Technology and IEEE 802.16 163 6.6.2 Applications of Mesh Networks 164 6.6.3 Physical and MAC Layers of WMNs 167 6.7 Summary 168 6.8 Exercises 168

7 Routing and Internetworking 171 7.1 Network-Layer Routing 172 7.1.1 Assigning Addresses to Hosts and Routers, and DHCP 173 7.1.2 Network Address Translation (NAT) 174 7.1.3 Route Cost 176 7.1.4 Classification of Routing Algorithms 176 Contents xi

7.2 Least-Cost-Path Algorithms 177 7.2.1 Dijkstra’s Algorithm 177 7.2.2 Bellman-Ford Algorithm 178 7.3 Non-Least-Cost-Path Routing 180 7.3.1 Flood Routing 180 7.3.2 Deflection Routing 181 7.4 Intradomain Routing Protocols 182 7.4.1 Routing Information Protocol (RIP) 183 7.4.2 Open Shortest Path First (OSPF) 187 7.5 Interdomain Routing Protocols 190 7.5.1 Border Gateway Protocol (BGP) 190 7.6 Congestion Control at Network Layer 194 7.6.1 Unidirectional Congestion Control 196 7.6.2 Bidirectional Congestion Control 197 7.6.3 Random Early Detection (RED) 198 7.6.4 A Quick Estimation of Link Blocking 200 7.7 Summary 202 7.8 Exercises 203

8 Transport and End-to-End Protocols 207 8.1 Transport Layer 208 8.1.1 Interaction of Transport and Network Layers 209 8.2 Transmission Control Protocol (TCP) 209 8.2.1 TCP Segment 210 8.2.2 Connection Setup 212 8.3 User Datagram Protocol (UDP) 213 8.3.1 UDP Segment 213 8.3.2 Applications of TCP and UDP 214 8.4 Mobile Transport Protocols 215 8.4.1 TCP for Mobility 215 8.4.2 UDP for Mobility 216 8.5 TCP Congestion Control 217 8.5.1 Additive Increase, Multiplicative Decrease Control 217 8.5.2 Slow Start Method 219 8.5.3 Fast Retransmit Method 220 8.5.4 TCP Congestion Avoidance Methods 221 8.6 Summary 222 8.7 Exercises 223 xii Contents

9 Applications and Network Management 225 9.1 Application-Layer Overview 226 9.1.1 Client and Server Model 226 9.2 Domain Name System (DNS) 227 9.2.1 Domain Name Space 228 9.2.2 Name/Address Mapping 230 9.2.3 DNS Message Format 231 9.3 Remote Login Protocols 232 9.3.1 TELNET Protocol 233 9.3.2 Secure Shell (SSH) Protocol 234 9.4 Electronic Mail (E-mail) 235 9.4.1 Simple Mail Transfer Protocol (SMTP) and E-mail 235 9.5 File Transfer and FTP 237 9.5.1 File Transfer Protocol (FTP) 237 9.5.2 Secure Copy Protocol (SCP) 237 9.6 World Wide Web (WWW) and HTTP 237 9.6.1 Web Caching (Proxy Server) 238 9.7 Network Management 239 9.7.1 Elements of Network Management 241 9.7.2 Structure of Management Information (SMI) 241 9.7.3 Management Information Base (MIB) 242 9.7.4 Simple Network Management Protocol (SNMP) 243 9.8 Summary 245 9.9 Exercises 246

10 Network Security 249 10.1 Overview of Network Security 250 10.1.1 Elements of Network Security 250 10.1.2 Threats to Network Security 251 10.2 Overview of Security Methods 255 10.2.1 Cryptographic Techniques 255 10.2.2 Authentication Techniques 256 10.3 Secret-Key Encryption Protocols 257 10.3.1 Data Encryption Standard (DES) 257 10.3.2 Advanced Encryption Standard (AES) 259 10.4 Public-Key Encryption Protocols 260 10.4.1 RSA Algorithm 260 10.4.2 Diffie-Hillman Key-Exchange Protocol 262 Contents xiii

10.5 Authentication 263 10.5.1 Secure Hash Algorithm (SHA) 264 10.6 Authentication and Digital Signature 265 10.7 Security of IP and Wireless Networks 266 10.7.1 IP Security and IPsec 266 10.7.2 Security of Wireless Networks and IEEE 802.11 267 10.8 Firewalls 269 10.9 Summary 270 10.10 Exercises 271

PART II: Advanced Concepts 273

11 Packet Queues and Delay Analysis 275 11.1 Little’s Theorem 276 11.2 Birth-and-Death Process 278 11.3 Queueing Disciplines 279 11.4 Markovian FIFO Queueing Systems 281 11.4.1 M/M/1 Queueing Systems 281 11.4.2 Systems with Limited Queueing Space: M/M/1/b 286 11.4.3 M/M/a Queueing Systems 287 11.4.4 Models for Delay-Sensitive Traffic: M/M/a/a 292 11.4.5 M/M/ ∞ Queueing Systems 293 11.5 Non-Markovian and Self-Similar Models 295 11.5.1 Pollaczek-Khinchin Formula and M/G/1 295 11.5.2 M/D/1 Models 298 11.5.3 Self-Similarity and Batch-Arrival Models 298 11.6 Networks of Queues 299 11.6.1 Burke’s Theorem 299 11.6.2 Jackson’s Theorem 304 11.7 Summary 308 11.8 Exercises 309

12 Quality of Service and Resource Allocation 315 12.1 Overview of QoS 316 12.2 Integrated Services QoS 316 12.2.1 Traffic Shaping 317 12.2.2 Admission Control 324 12.2.3 Resource Reservation Protocol (RSVP) 324 xiv Contents

12.2.4 Packet Scheduling 325 12.3 Differentiated Services QoS 335 12.3.1 Per-Hop Behavior (PHB) 336 12.4 Resource Allocation 337 12.4.1 Management of Resources 338 12.4.2 Classification of Resource-Allocation Schemes 338 12.4.3 Fairness in Resource Allocation 340 12.4.4 ATM Resource Allocation 340 12.4.5 Cell Scheduling and QoS 343 12.5 Summary 344 12.6 Exercises 344

13 Networks in Switch Fabrics 349 13.1 Characteristics and Features of Switch Fabrics 350 13.1.1 Blocking and Nonblocking Networks 350 13.1.2 Features of Switch Fabrics 351 13.1.3 Complexity of Switching Networks 351 13.1.4 Definitions and Symbols 351 13.2 Crossbar Switch Fabrics 352 13.3 Blocking Switch Fabrics 353 13.3.1 Omega Network 353 13.3.2 Banyan Network 355 13.3.3 Delta Networks 355 13.3.4 Beneˇs Networks 356 13.4 Nonblocking Switch Fabrics: Clos Networks 357 13.4.1 Estimation of Blocking Probabilities 360 13.4.2 Five-Stage Clos Networks 361 13.5 Concentration and Expansion Switches 361 13.5.1 Knockout Switching Network 363 13.5.2 Expansion Network 364 13.6 Shared-Memory Switch Fabrics 365 13.7 Techniques for Improving Performance 366 13.7.1 Parallel-Plane Switching Networks 367 13.8 Case Study: Multipath Buffered Crossbar 368 13.8.1 Queueing Model 370 13.8.2 Markov Chain Model 371 13.8.3 Throughput and Delay 374 Contents xv

13.9 Summary 375 13.10 Exercises 376

14 Optical Networks and WDM Systems 379 14.1 Overview of Optical Networks 380 14.1.1 Protocol Models and Standards 380 14.2 Basic Optical Networking Devices 382 14.2.1 Tunable Lasers 382 14.2.2 Optical Buffers or Delay Elements 382 14.2.3 Optical Amplifiers 382 14.2.4 Optical Filters 382 14.2.5 Wavelength-Division Multiplexer (WDM) 383 14.2.6 Optical Switches 384 14.3 Large-Scale Optical Switches 386 14.3.1 Crossbar Switching Network 387 14.3.2 Spanke-Beneˇs Switching Network 387 14.4 Optical Routers 388 14.4.1 Structure of Wavelength Routing Nodes 389 14.5 Wavelength Allocation in Networks 391 14.5.1 Classification of Optical Networks 392 14.5.2 Wavelength Allocation 393 14.6 Case Study: An All-Optical Switch 395 14.6.1 Self-Routing in SSN 397 14.6.2 Transmission in SSN 397 14.7 Summary 398 14.8 Exercises 399

15 Multicasting Techniques and Protocols 401 15.1 Basic Definitions and Techniques 402 15.1.1 IP Multicast Address 403 15.1.2 Basic Multicast Tree Algorithms 404 15.1.3 Classification of Multicast Protocols 406 15.2 Intradomain Multicast Protocols 406 15.2.1 Distance Vector Multicast Routing Protocol (DVMRP) 407 15.2.2 Internet Group Management Protocol (IGMP) 407 15.2.3 Multicast OSPF (MOSPF) Protocol 409 15.2.4 Protocol-Independent Multicast (PIM) 410 15.2.5 Core-Based Trees (CBT) Protocol 413 xvi Contents

15.2.6 Multicast Backbone (MBone) 413 15.3 Interdomain Multicast Protocols 414 15.3.1 Multiprotocol BGP (MBGP) 414 15.3.2 Multicast Source Discovery Protocol (MSDP) 415 15.3.3 Border Gateway Multicast Protocol (BGMP) 417 15.4 Node-Level Multicast Algorithms 417 15.4.1 Tree-Based Multicast Algorithm 418 15.4.2 Boolean Splitting Multicast Algorithm 420 15.4.3 Packet Recirculation Multicast Algorithm 423 15.4.4 Multicasting in Three-Dimensional Switches 424 15.5 Summary 426 15.6 Exercises 427

16 VPNs, Tunneling, and Overlay Networks 431 16.1 Virtual Private Networks (VPNs) 432 16.1.1 Remote-Access VPN 433 16.1.2 Site-to-Site VPN 433 16.1.3 Tunneling and Point-to-Point Protocol (PPP) 434 16.1.4 Security in VPNs 436 16.2 Multiprotocol Label Switching (MPLS) 437 16.2.1 MPLS Operation 438 16.2.2 Routing in MPLS Domains 439 16.2.3 Tunneling and Use of FEC 441 16.2.4 Traffic Engineering 442 16.2.5 MPLS-Based VPNs 443 16.3 Overlay Networks 444 16.3.1 Peer-to-Peer (P2P) Connection 445 16.4 Summary 446 16.5 Exercises 447

17 Compression of Digital Voice and Video 449 17.1 Overview of Data Compression 450 17.2 Digital Voice and Compression 451 17.2.1 Signal Sampling 451 17.2.2 Quantization and Distortion 452 17.3 Still Images and JPEG Compression 455 17.3.1 Raw-Image Sampling and DCT 456 17.3.2 Quantization 459 17.3.3 Encoding 460 Contents xvii

17.4 Moving Images and MPEG Compression 461 17.4.1 MP3 and Streaming Audio 462 17.5 Limits of Compression with Loss 463 17.5.1 Basics of Information Theory 463 17.5.2 Entropy of Information 464 17.5.3 Shannon’s Coding Theorem 465 17.5.4 Compression Ratio and Code Efficiency 467 17.6 Compression Methods Without Loss 467 17.6.1 Run-Length Encoding 468 17.6.2 Huffman Encoding 468 17.6.3 Lempel-Ziv Encoding 469 17.7 Case Study: FAX Compression for Transmission 470 17.8 Summary 472 17.9 Exercises 472

18 VoIP and Multimedia Networking 479 18.1 Overview of IP Telephony 480 18.1.1 VoIP Quality-of-Service 481 18.2 VoIP Signaling Protocols 482 18.2.1 Session Initiation Protocol (SIP) 483 18.2.2 H.323 Protocols 486 18.3 Real-Time Media Transport Protocols 490 18.3.1 Real-Time Transport Protocol (RTP) 491 18.3.2 Real-Time Control Protocol (RTCP) 493 18.3.3 Estimation of Jitter in Real-Time Traffic 496 18.4 Distributed Multimedia Networking 497 18.4.1 Content Distribution Networks (CDNs) 498 18.4.2 CDN Interactions with DNS 498 18.4.3 Providing QoS to Streaming 499 18.5 Stream Control Transmission Protocol (SCTP) 500 18.5.1 SCTP Packet Structure 501 18.6 Self-Similarity and Non-Markovian Streaming Analysis 503 18.6.1 Self-Similarity with Batch Arrival Models 503 18.7 Summary 506 18.8 Exercises 507

19 Mobile Ad-Hoc Networks 511 19.1 Overview of Wireless Ad-Hoc Networks 512 xviii Contents

19.2 Routing in Ad-Hoc Networks 513 19.2.1 Classification of Routing Protocols 514 19.3 Routing Protocols for Ad-Hoc Networks 515 19.3.1 Destination-Sequenced Distance Vector (DSDV) Protocol 515 19.3.2 Cluster-Head Gateway Switch Routing Protocol 517 19.3.3 Wireless Routing Protocol (WRP) 517 19.3.4 Dynamic Source Routing (DSR) Protocol 519 19.3.5 Temporally Ordered Routing Algorithm (TORA) 520 19.3.6 Associative-Based Routing (ABR) Protocol 521 19.3.7 Ad-Hoc On-Demand Distance Vector (AODV) Protocol 522 19.4 Security of Ad-Hoc Networks 528 19.4.1 Types of Attacks 529 19.4.2 Criteria for a Secure Routing Protocol 530 19.5 Summary 531 19.6 Exercises 531

20 Wireless Sensor Networks 535 20.1 Sensor Networks and Protocol Structures 536 20.1.1 Clustering in Sensor Networks 536 20.1.2 Protocol Stack 537 20.1.3 Sensor Node Structure 538 20.2 Communication Energy Model 540 20.3 Clustering Protocols 545 20.3.1 Classification of Clustering Protocols 546 20.3.2 LEACH Clustering Protocol 546 20.3.3 DEEP Clustering Protocol 547 20.3.4 Reclustering 551 20.4 Routing Protocols 551 20.4.1 Intracluster Routing Protocols 552 20.4.2 Intercluster Routing Protocols 554 20.5 Case Study: Simulation of a Sensor Network 557 20.5.1 Cluster-Head Constellation and Distribution of Load 557 20.5.2 Optimum Percentage of Cluster Heads 558 20.6 Other Related Technologies 559 20.6.1 Zigbee Technology and IEEE 802.15.4 559 20.7 Summary 560 20.8 Exercises 561 Contents xix

Appendix A: Glossary of Acronyms 563 Appendix B: RFCs 569 Appendix C: Probabilities and Stochastic Processes 573 C.1 Probability Theory 573 C.1.1 Bernulli and Binomial Sequential Laws 574 C.1.2 Counting and Sampling Methods 574 C.2 Random Variables 574 C.2.1 Basic Functions 575 C.2.2 Conditional Functions 575 C.2.3 Popular Random Variables 576 C.2.4 Expected Value and Variance 577 C.2.5 A Function of Random Variable 578 C.3 Multiple Random Variables 578 C.3.1 Basic Functions of Two Random Variables 578 C.3.2 Two Independent Random Variables 579 C.4 Stochastic (Random) Processes 579 C.4.1 IID Random Process 580 C.4.2 Brownian Motion Random Process 580 C.5 Theory of Markov Chains 580 C.5.1 Continuous-Time Markov Chains 581

Index 583