Foundations TCP/IP 4370.book Page i Friday, July 23, 2004 1:02 PM 4370.book Page ii Friday, July 23, 2004 1:02 PM San Francisco ◆ London Foundations TCP/IP Andrew G. Blank 4370.book Page iii Friday, July 23, 2004 1:02 PM Associate Publisher: Neil Edde Acquisitions Editor: Heather O’Connor Developmental Editor: Heather O’Connor Production Editor: Rachel Gunn Copyeditor: Anamary Ehlen Compositor: Craig Woods, Happenstance Type-O-Rama Graphic Illustrator: Tony Jonick, Rappid Rabbit Proofreaders: Laurie O'Connell, Nancy Riddiough Indexer: Lynnzee Elze Book Designer: Judy Fung Cover Design: Ingalls + Associates Cover Photo: Jerry Driendl, Taxi Copyright © 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. No part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photo- copy, photograph, magnetic, or other record, without the prior agreement and written permission of the publisher. An earlier version of this book was published under the title TCP/IP JumpStart © 2002 SYBEX Inc. Library of Congress Card Number: 2004109311 ISBN: 0-7821-4370-9 SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc. in the United States and/or other countries. Screen reproductions produced with Collage Complete and FullShot 99. FullShot 99 © 1991–1999 Inbit Incorporated. All rights reserved. FullShot is a trademark of Inbit Incorporated. Collage Complete is a trademark of Inner Media Inc. TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by fol- lowing the capitalization style used by the manufacturer. The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s). The author and the publisher make no representation or warranties of any kind with regard to the completeness or accuracy of the con- tents herein and accept no liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages of any kind caused or alleged to be caused directly or indirectly from this book. Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 4370.book Page iv Friday, July 23, 2004 1:02 PM To my inspiration, my encourager, my perfect match, my best friend, and the love of my life, my wife, Suzie, you have had a profound and awesome impact on my life. I love you very much. To my son, A.J. and my daughter, Amber, I treasure your love and have tremendous pride in both of you; Daddy loves you so much. 4370.book Page v Friday, July 23, 2004 1:02 PM Acknowledgments Several people have assisted me in many ways while writing this book. I’d like to acknowledge their contribu- tions and offer my sincere appreciation. I appreciate several devoted people at Sybex. I have had the privilege of working closely with some very talented people, especially Rachel Gunn and Heather O’Connor. Anamary Ehlen did an exceptional job of editing my garbled-up thoughts into complete sentences. Many thanks to Sybex production department, including proof- readers Laurie O'Connell and Nancy Riddiough, indexer Lynnzee Elze, and compositor Craig Woods at Hap- penstance Type-O-Rama, who diligently turned text into print. I applaud the imagination and creativity of Tony Jonick in turning my sketches into illustrations. What an awesome honor to work with all of you! I’d like to acknowledge the encouragement and prayers of my family and friends. All things are possible! 4370.book Page vi Friday, July 23, 2004 1:02 PM Contents Introduction xiii Chapter 1 The Origin of TCP/IP and the Internet 1 What Is TCP/IP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Features of TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 The Origins of the Internet: ARPAnet . . . . . . . . . . . . . . . . 3 ARPAnet’s Requirements . . . . . . . . . . . . . . . . . . . . . . . 4 Requests For Comments . . . . . . . . . . . . . . . . . . . . . . . . . . 5 The Birth of TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Design Goals of TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Moving Data across the Network . . . . . . . . . . . . . . . . . . . 7 Moving Data on a Circuit-Switched Network . . . . . . . . 8 Moving Data on a Packet-Switched Network . . . . . . . . 8 Why Use TCP/IP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Chapter 2 Protocols 13 What Are Protocols? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Protocols Move Packets of Data . . . . . . . . . . . . . . . . . 15 Why We Need Protocols and Standards . . . . . . . . . . . . . . 17 The OSI Reference Model . . . . . . . . . . . . . . . . . . . . . . . . 18 The Seven Layers of the OSI Model . . . . . . . . . . . . . . . 19 Responsibilities of Each Layer . . . . . . . . . . . . . . . . . . . 19 How the OSI Model Is Used . . . . . . . . . . . . . . . . . . . . 23 TCP/IP and the DoD Model . . . . . . . . . . . . . . . . . . . . . . . 24 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Chapter 3 The Network Interface and Internet Layers 27 The Network Interface Layer . . . . . . . . . . . . . . . . . . . . . . 28 Hardware Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 The Internet Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Internet Protocol (IP) . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Address Resolution Protocol (ARP) . . . . . . . . . . . . . . . 35 Internet Control Message Protocol (ICMP) . . . . . . . . . 38 Internet Group Management Protocol (IGMP) . . . . . . 40 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 4370.book Page vii Friday, July 23, 2004 1:02 PM viii Contents Chapter 4 The Transport Layer 45 Understanding the Transport Layer . . . . . . . . . . . . . . . . . 46 Understanding Transmission Control Protocol . . . . . . . . . 47 Using a Three-Way Handshake . . . . . . . . . . . . . . . . . . 48 Organizing Data and Guaranteeing Delivery . . . . . . . . 49 Understanding User Datagram Protocol . . . . . . . . . . . . . . 49 UDP Communication . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Chapter 5 The Application Layer 55 Understanding the Application Layer . . . . . . . . . . . . . . . . 56 Understanding Ports and Sockets . . . . . . . . . . . . . . . . . . . 56 Well-Known Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 File Transfer Protocol (FTP) . . . . . . . . . . . . . . . . . . . . . . . 58 How FTP Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Hypertext Transfer Protocol (HTTP) . . . . . . . . . . . . . . . . 60 Ports and Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Requesting a Service in the TCP/IP Stack . . . . . . . . . . . 62 The Firewall is Protecting the LAN . . . . . . . . . . . . . . . 63 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Chapter 6 IP Addressing 67 What Is IP Addressing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Numbering Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Reviewing Binary and Decimal Numbering Systems . . 69 Converting Binary Numbers to Decimal . . . . . . . . . . . 70 Converting Decimal Numbers to Binary . . . . . . . . . . . 71 IP Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 IP Address Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Class A Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Class B Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Class C Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Class D Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Class E Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 IP Address Class Summary . . . . . . . . . . . . . . . . . . . . . . . . 82 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Chapter 7 Addressing IP Hosts 85 Installing and Assigning IP Addresses . . . . . . . . . . . . . . . . 86 Manual IP Address Configuration . . . . . . . . . . . . . . . . 86 4370.book Page viii Friday, July 23, 2004 1:02 PM Contents ix Installing TCP/IP on Windows XP and 2003 . . . . . . . . 86 Installing TCP/IP on Windows 2000 . . . . . . . . . . . . . . 90 Installing TCP/IP on Windows NT . . . . . . . . . . . . . . . 93 Installing TCP/IP on Windows 95/98 . . . . . . . . . . . . . 96 Dynamic Host Configuration Protocol (DHCP) . . . . . 99 Obtaining an IP Address from a DHCP Server . . . . . . . . 100 DHCP Discover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 DHCP Offer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 DHCP Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 DHCP Acknowledgment . . . . . . . . . . . . . . . . . . . . . . 105 DHCP Leases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 DHCP IP Address Renewal . . . . . . . . . . . . . . . . . . . . 109 Reserving DHCP IP Addresses . . . . . . . . . . . . . . . . . . . . 110 Setting the Lease Duration . . . . . . . . . . . . . . . . . . . . . . . 110 Setting DHCP Scopes and Options . . . . . . . . . . . . . . . . . 111 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Chapter 8 Introduction to Subnet Masks 115 What Is a Subnet Mask? . . . . . . . . . . . . . . . . . . . . . . . . 116 Network and Host . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Identifying a Local or Remote Network . . . . . . . . . . 119 Standard Subnet Masks . . . . . . . . . . . . . . . . . . . . . . . . . 122 Class A Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Class B Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Class C Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Chapter 9 Using Custom Subnet Masks 127 Custom Subnet Masks . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Creating Additional Networks . . . . . . . . . . . . . . . . . 130 Subnetting Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Creating a Custom Subnet Mask . . . . . . . . . . . . . . . . 131 Class A Subnet Masks . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Class B Subnet Masks . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Class C Subnet Masks . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Chapter 10 Supernetting and CIDR 155 IP Address Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Limitations of the Classful System . . . . . . . . . . . . . . . 156 The Trouble with Class B . . . . . . . . . . . . . . . . . . . . . 156 4370.book Page ix Friday, July 23, 2004 1:02 PM x Contents Supernetting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Classless Inter-Domain Routing (CIDR) . . . . . . . . . . . . . 161 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Chapter 11 Name Resolution 165 Understanding Name Resolution . . . . . . . . . . . . . . . . . . 166 What Is Host Name Resolution? . . . . . . . . . . . . . . . . 167 What Is NetBIOS Name Resolution? . . . . . . . . . . . . . 167 NetBIOS Name Resolution vs. Host Name Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Understanding Host Name Resolution . . . . . . . . . . . . . . 169 Local Host (HOSTNAME) . . . . . . . . . . . . . . . . . . . . 170 The HOSTS file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Domain Name System (DNS) . . . . . . . . . . . . . . . . . . 174 NetBIOS Name Cache . . . . . . . . . . . . . . . . . . . . . . . . 174 Windows Internet Naming Service (WINS) . . . . . . . . 177 Broadcast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 The LMHOSTS file . . . . . . . . . . . . . . . . . . . . . . . . . . 179 The Host Name Resolution Cycle . . . . . . . . . . . . . . . 182 Understanding NetBIOS Name Resolution . . . . . . . . . . . 183 The NetBIOS Name Resolution Cycle . . . . . . . . . . . . 184 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Chapter 12 Domain Name System (DNS) 189 What Is DNS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 DNS on the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Name Resolution Using DNS . . . . . . . . . . . . . . . . . . . . . 191 Querying a DNS Server . . . . . . . . . . . . . . . . . . . . . . . 192 Querying Name Servers . . . . . . . . . . . . . . . . . . . . . . . 193 Completing Resolution . . . . . . . . . . . . . . . . . . . . . . . 194 Understanding Recursive and Iterative Queries . . . . . 195 Maintaining a Database . . . . . . . . . . . . . . . . . . . . . . . 197 Maintaining a DNS Server . . . . . . . . . . . . . . . . . . . . . . . 197 Primary Name Server . . . . . . . . . . . . . . . . . . . . . . . . . 198 Secondary Name Server . . . . . . . . . . . . . . . . . . . . . . . 198 DNS Zone Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Caching-Only Server . . . . . . . . . . . . . . . . . . . . . . . . . 199 Record Types in DNS . . . . . . . . . . . . . . . . . . . . . . . . 200 Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 4370.book Page x Friday, July 23, 2004 1:02 PM . TCP/ IP on Windows XP and 2003 . . . . . . . . 86 Installing TCP/ IP on Windows 2000 . . . . . . . . . . . . . . 90 Installing TCP/ IP on Windows NT . . . . . . . . . . . . . . . 93 Installing TCP/ IP. protocol suite. TCP/ IP Foundations assumes no prior knowledge of TCP/ IP and provides a solid introduction to this core networking topic, explaining the fun- damentals of TCP/ IP in simple terms. tangible examples. My goal with TCP/ IP Foundations is to introduce you to TCP/ IP concepts so that you’ll come away with an intermediate understanding of TCP/ IP. This book isn’t boringly technical;