• W. Internet • AD< 3.2.2 Solaris 2.2 SunOS 4.1.1 .104.1 Cisco aix solaris gemini gateway router - - - - 1'1.92 T.1.32 T.1.11 .1.4 Ethernet .1.183 - Telebit netb NetBlazer lmodeml SLIP (dialup) JmodemJ BSD/3861.0 BSD/3861.0 SunOS4.1.3 .1.29 SVR4 - SLIP slip bsdi sun svr4 .13.65 .13.66 - - - T-13.35 .13.33 T-13.34 Ethernet Portion of the class B network 140.252 used for all the examples in the text. All the hosts are in the t uc. noao. edu domain. IP Header 0 15 16 31 4-bit 14-bit headerl 8-bit type of service T 16-bit total length (in bytes) version length (TOS) 3-bit 16-bit identification 13-bit fragment offset flags I 8-bit time to live 8-bit protocol 16-bit header checksum 20 bytes (TTL) I 1 32-bit source IP address 32-bit destination IP address / options (if any) 7 7 data l UDP Header 0 15 16 31 T 16-bit source port number 16-bit destination port number 8 bytes 16-bit UDP length 16-bit UDP checksum j_ 7 data (if any) l TCP Header 0 15 16 31 16-bit source port number 16-bit destination port number T 32-bit sequence number 32-bit acknowledgment number 20 bytes 4-bit headerl reserved 1 16-bit window size length (6 bits) IMl~lllil!I! 16-bit TCP checksum 16-bit urgent pointer 7 options (if any) l l 7 data (if any) l TCP/IP Illustrated, Volume 1 Addison-Wesley Professional Computing Series Brian W. Kernighan, Consulting Editor Ken Arnold/John Peyton, A C User's Guide to ANSI C Tom Cargill, C++ Programming Style David A. Curry, UNIX® System Security: A Guide for Users and System Administrators William R. Cheswick/Steven M. Bellovin, Firewalls and Internet Security: Repelling the Wily Hacker Scott Meyers, Effective C++: 50 Specific Ways to Improve Your Programs and Designs R9bert B. Murray, C++ Strategies and Tactics John K. Ousterhout, Tel and the Tk Toolkit Craig Partridge, Gigabit Networking Radia Perlman, Interconnections: Bridges and Routers David M. Piscitello/A. Lyman Chapin, Open Systems Networking: TCP/IP and OSI Stephen A. Rago, UNIX® System V Network Programming Curt Schimmel, UNIX® Systems for Modern Architectures: Symmetric Multiprocessing and Caching for Kernel Programmers W. Richard Stevens, Advanced Programming in the UNIX® Environment W. Richard Stevens, TCP/IP Illustrated, Volume I: The Protocols TCP/IP Illustrated, Volume 1 The Protocols W. Richard Stevens ADDISON-WESLEY PUBLISHING COMPANY Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei UNIX is a technology trademark of X/Open Company, Ltd. The publisher offers discounts on this book when ordered in quantity for special sales. For more information please contact: Corporate & Professional Publishing Group Addison-Wesley Publishing Company One Jacob Way Reading, Massachusetts 01867 Library of Congress Cataloging-in-Publication Data Stevens, W. Richard TCP/IP Illustrated: the protocols/W, Richard Stevens. p. cm. - (Addison-Wesley professional computing series) Includes bibliographical references and index. ISBN 0-201-63346-9 (v. 1) l.TCP/1.P (Computer network protocol) I. Title. II. Series. TK5105.55S74 1994 004.6'2-dc20 Copyright © 1994 by Addison-Wesley Publishing Company 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 consent of the publisher. Printed in the United States of America. Published simultaneously in Canada. ISBN 0-201-63346-9 Text printed on recycled paper. 3 4 5 6 7 8 9 CRW 97969594 Third printing May 1994 To Brian Kernighan and John Wait, for their encouragement, faith, and support over the past 5 years. Praise for TCP/IP Illustrated, Volume 1: The Protocols "Thi is sure to be the bible for TCP/IP developer and user . Within minute of picking up the text, I encountered several scenario which had tripped-up both my colleagues and my elf in the pa t. Stevens reveals many of the mysteries once held tightly by the ever-elusive networking gurus. Having been involved in the implementation of TCP/IP for some year now, I con ider thi by far the finest text to date." - Robert A. Ciampa, Network Engineer, Synemetics, division of 3COM "While all of Stevens' books are readable and technically excellent, this new opu i awe ome. Although many books describe the TCP/IP protocols, Stevens provides a level of depth and real world detail lacking from the competition. He puts the reader inside TCP/IP u ing a vi ual approach and shows the protocols in action." - Steven Baker, Networking Columnist, Unix Review "TCP/IP Illustrated, Volume 1 is an excellent reference for developers, network administrators, or anyone who needs to understand TCP/IP technology. TCP/IP Illustrated i comprehensive in its coverage of TCP/IP topics, providing enough details to satisfy the experts while giving enough background and commentary for the novice." - Bob Williams, V.P. Marketing, NetManage, Inc. " ... the difference is that Stevens wants to show as well as tell about the protocols. His principal teaching tools are straight-forward explanations, exercises at the ends of chapters, byte-by-byte diagrams of headers and the like, and listings of actual traffic as examples." - Walter Zintz, UnixWorld "Much better than theory only ... W. Richard Stevens takes a multihost-based configuration and uses it as a travelogue of TCP/IP examples with illustrations. TCP/IP Illustrated, Volume 1 is based on practical examples that reinforce the theory - distinguishing this book from others on the subject, and making it both readable and informative." - Peter M. Haverlock, Consultant, IBM TCP/IP Development "The diagrams he uses are excellent and his writing style is clear and readable. In sum, Stevens has made a complex topic easy to understand. This book merits everyone's attention. Please read it and keep it on your bookshelf." - Elizabeth Zinkann, Sys Admin "W. Richard Stevens has produced a fine text and reference work. It is well organized and very clearly written with, as the title suggests, many excellent illustrations exposing the intimate details of the logic and operation of IP, TCP, and the supporting cast of protocols and applications." - Scott Bradner, Consultant, Harvard University OIT/NSD