TCP-IP Illustrated Vol 3
1194 pág.

TCP-IP Illustrated Vol 3


DisciplinaDesenvolvimento1.519 materiais2.138 seguidores
Pré-visualização50 páginas
ptg11539634
ptg11539634
i
TCP/IP Illustrated 
The Implementation 
Volume 2 
W. Richard Stevens 
Gary R. Wright 
Addison-Wesley Professional
ptg11539634
Addison-Wesley Professional Computing Series
Brian W. Kernighan, Consulting Editor 
Matthew H. Austern, Generic Programming and the STL: Using and Extending the C++ Standard Template Library
David R. Butenhof, Programming with POSIX® Threads
Brent Callaghan, NFS Illustrated
Tom Cargill, C++ Programming Style
William R. Cheswick/Steven M. Bellovin/Aviel D. Rubin, Firewalls and Internet Security, Second Edition: Repelling 
the Wily Hacker
David A. Curry, UNIX® System Security: A Guide for Users and System Administrators
Stephen C. Dewhurst, C++ Gotchas: Avoiding Common Problems in Coding and Design
Dan Farmer/Wietse Venema, Forensic Discovery
Erich Gamma/Richard Helm/Ralph Johnson/John Vlissides, Design Patterns: Elements of Reusable Object-
Oriented Software
Erich Gamma/Richard Helm/Ralph Johnson/John Vlissides, Design Patterns CD: Elements of Reusable Object-
Oriented Software 
Peter Haggar, Practical Java\u2122 Programming Language Guide
David R. Hanson, C Interfaces and Implementations: Techniques for Creating Reusable Software
Mark Harrison/Michael McLennan, Effective Tcl/Tk Programming: Writing Better Programs with Tcl and Tk
Michi Henning/Steve Vinoski, Advanced CORBA® Programming with C++
Brian W. Kernighan/Rob Pike, The Practice of Programming
S. Keshav, An Engineering Approach to Computer Networking: ATM Networks, the Internet, and the Telephone Network
John Lakos, Large-Scale C++ Software Design
Scott Meyers, Effective C++ CD: 85 Specific Ways to Improve Your Programs and Designs
Scott Meyers, Effective C++, Third Edition: 55 Specific Ways to Improve Your Programs and Designs
Scott Meyers, More Effective C++: 35 New Ways to Improve Your Programs and Designs
Scott Meyers, Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library
Robert B. Murray, C++ Strategies and Tactics
David R. Musser/Gillmer J. Derge/Atul Saini, STL Tutorial and Reference Guide, Second Edition: 
C++ Programming with the Standard Template Library
John K. Ousterhout, Tcl and the Tk Toolkit
Craig Partridge, Gigabit Networking
Radia Perlman, Interconnections, Second Edition: Bridges, Routers, Switches, and Internetworking Protocols
Stephen A. Rago, UNIX® System V Network Programming
Eric S. Raymond, The Art of UNIX Programming
Marc J. Rochkind, Advanced UNIX Programming, Second Edition
Curt Schimmel, UNIX® Systems for Modern Architectures: Symmetric Multiprocessing and Caching for Kernel Programmers
W. Richard Stevens, TCP/IP Illustrated, Volume 1: The Protocols
W. Richard Stevens, TCP/IP Illustrated, Volume 3: TCP for Transactions, HTTP, NNTP, and the UNIX®
Domain Protocols
W. Richard Stevens/Bill Fenner/Andrew M. Rudoff, UNIX Network Programming Volume 1, Third Edition: The 
Sockets Networking API
W. Richard Stevens/Stephen A. Rago, Advanced Programming in the UNIX® Environment, Second Edition
W. Richard Stevens/Gary R. Wright, TCP/IP Illustrated Volumes 1-3 Boxed Set
John Viega/Gary McGraw, Building Secure Software: How to Avoid Security Problems the Right Way
Gary R. Wright/W. Richard Stevens, TCP/IP Illustrated, Volume 2: The Implementation
Ruixi Yuan/W. Timothy Strayer, Virtual Private Networks: Technologies and Solutions
Visit www.awprofessional.com/series/professionalcomputing for more information about these titles.
ii
www.awprofessional.com/series/professionalcomputing
ptg11539634
 iii
Table of Contents 
 
Copyright 
Preface 
Chapter 1. Introduction 1 
Section 1.1. Introduction 1 
Section 1.2. Source Code Presentation 1 
Section 1.3. History 3 
Section 1.4. Application Programming Interfaces 4 
Section 1.5. Example Program 4 
Section 1.6. System Calls and Library Functions 6 
Section 1.7. Network Implementation Overview 8 
Section 1.8. Descriptors 9 
Section 1.9. Mbufs (Memory Buffers) and Output Processing 13 
Section 1.10. Input Processing 18 
Section 1.11. Network Implementation Overview Revisited 21 
Section 1.12. Interrupt Levels and Concurrency 22 
Section 1.13. Source Code Organization 25 
Section 1.14. Test Network 26 
Section 1.15. Summary 27 
Chapter 2. Mbufs: Memory Buffers 29 
Section 2.1. Introduction 29 
Section 2.2. Code Introduction 33 
Section 2.3. Mbuf Definitions 34 
Section 2.4. mbuf Structure 35 
Section 2.5. Simple Mbuf Macros and Functions 37 
Section 2.6. m_devget and m_pullup Functions 41 
Section 2.7. Summary of Mbuf Macros and Functions 48 
Section 2.8. Summary of Net/3 Networking Data Structures 51 
Section 2.9. m_copy and Cluster Reference Counts 53 
Section 2.10. Alternatives 57 
Section 2.11. Summary 57 
Chapter 3. Interface Layer 59 
Section 3.1. Introduction 59 
Section 3.2. Code Introduction 59 
Section 3.3. ifnet Structure 61 
Section 3.4. ifaddr Structure 70 
Section 3.5. sockaddr Structure 72 
Section 3.6. ifnet and ifaddr Specialization 73 
Section 3.7. Network Initialization Overview 75 
Section 3.8. Ethernet Initialization 77 
Section 3.9. SLIP Initialization 80 
Section 3.10. Loopback Initialization 83 
Section 3.11. if_attach Function 83 
Section 3.12. ifinit Function 91 
3.13 Summary 93 
Chapter 4. Interfaces: Ethernet 94 
Section 4.1. Introduction 94 
Section 4.2. Code Introduction 95 
Section 4.3. Ethernet Interface 98 
ptg11539634
 iv
Section 4.4. ioctl System Call 115 
 
 
 
Section 4.5. Summary 127 
Chapter 5. Interfaces: SLIP and Loopback 128 
Section 5.1. Introduction 128 
Section 5.2. Code Introduction 128 
Section 5.3. SLIP Interface 129 
Section 5.4. Loopback Interface 149 
Section 5.5. Summary 152 
Chapter 6. IP Addressing 153 
Section 6.1. Introduction 153 
Section 6.2. Code Introduction 155 
Section 6.3. Interface and Address Summary 155 
Section 6.4. sockaddr_in Structure 157 
Section 6.5. in_ifaddr Structure 158 
Section 6.6. Address Assignment 159 
Section 6.7. Interface ioctl Processing 176 
Section 6.8. Internet Utility Functions 179 
Section 6.9. ifnet Utility Functions 179 
Section 6.10. Summary 180 
Chapter 7. Domains and Protocols 182 
Section 7.1. Introduction 182 
Section 7.2. Code Introduction 182 
Section 7.3. domain Structure 183 
Section 7.4. protosw Structure 184 
Section 7.5. IP domain and protosw Structures 187 
Section 7.6. pffindproto and pffindtype Functions 193 
Section 7.7. pfctlinput Function 194 
Section 7.8. IP Initialization 195 
Section 7.9. sysctl System Call 197 
Section 7.10. Summary 200 
Chapter 8. IP: Internet Protocol 202 
Section 8.1. Introduction 202 
Section 8.2. Code Introduction 203 
Section 8.3. IP Packets 205 
Section 8.4. Input Processing: ipintr Function 208 
Section 8.5. Forwarding: ip_forward Function 216 
Section 8.6. Output Processing: ip_output Function 224 
Section 8.7. Internet Checksum: in_cksum Function 232 
Section 8.8. setsockopt and getsockopt System Calls 236 
Section 8.9. ip_sysctl Function 241 
Section 8.10. Summary 242 
Chapter 9. IP Option Processing 244 
Section 9.1. Introduction 244 
Section 9.2. Code Introduction 244 
Section 9.3. Option Format 245 
Section 9.4. ip_dooptions Function 246 
Section 9.5. Record Route Option 249 
Section 9.6. Source and Record Route Options 251 
ptg11539634
 v
Section 9.7. Timestamp Option 258 
Section 9.8. ip_insertoptions Function 262 
Section 9.9. ip_pcbopts Function 266 
Section 9.10. Limitations 270 
Section 9.11. Summary 270 
Chapter 10. IP Fragmentation and Reassembly 272 
Section 10.1. Introduction 272 
Section 10.2. Code Introduction 273 
Section 10.3. Fragmentation 274 
Section 10.4. ip_optcopy Function 279 
Section 10.5. Reassembly 280 
Section 10.6. ip_reass Function 283 
Section 10.7. ip_slowtimo Function 296 
Section 10.8. Summary 297 
Chapter 11. ICMP: Internet Control Message Protocol 299 
Section 11.1. Introduction 299 
Section 11.2. Code Introduction 302