logo资料库

Linux网络体系结构-Linux内核中网络协议的设计与实现(英文版).pdf

第1页 / 共648页
第2页 / 共648页
第3页 / 共648页
第4页 / 共648页
第5页 / 共648页
第6页 / 共648页
第7页 / 共648页
第8页 / 共648页
资料共648页,剩余部分请下载后查看
The Linux Networking Architecture: Design and Implementation of Network Protocols in the Linux Kernel
Table of Contents
Copyright
Preface
Organization of this Book
Additional Sources of Information
Conventions
Acknowledgments
Part I: The Linux Kernel
Chapter 1. Motivation
1.1 The Linux Operating System
1.2 What is Linux?
1.3 Reasons for Using Linux
Chapter 2. The Kernel Structure
2.1 Monolithic Architectures and Microkernels
2.2 Activities in the Linux Kernel
2.3 Locking--Atomic Operations
2.4 Kernel Modules
2.5 Device Drivers
2.6 Memory Management in the Kernel
2.7 Timing in the Linux Kernel
2.8 The Proc File System
2.9 Versioning
Part II: Architecture of Network Implementation
Chapter 3. The Architecture of Communication Systems
3.1 Layer-Based Communication Models
3.2 Services and Protocols
Chapter 4. Managing Network Packets in the Kernel
4.1 Socket Buffers
4.2 Socket-Buffer Queues
Chapter 5. Network Devices
5.1 The net_device Interface
5.2 Managing Network Devices
5.3 Network Drivers
Part III: Layer I + II--Medium Access and Logical Link Layer
Chapter 6. Introduction to the Data-Link Layer
6.1 Structure of the Data-Link Layer
6.2 Processes on the Data-Link Layer
6.3 Managing Layer-3 Protocols
Chapter 7. The Serial-Line Internet Protocol (SLIP)
7.1 Introduction
7.2 Slip Implementation in the Linux Kernel
Chapter 8. The Point-to-Point Protocol (PPP)
8.1 Introduction
8.2 PPP Configuration in Linux
8.3 PPP Implementation in the Linux Kernel
8.4 Implementing the PPP Daemon
Chapter 9. PPP over Ethernet
9.1 Introduction
9.2 PPPOE Specification in RFC 2516
9.3 Implementation in the User Space
9.4 Implementation in the Linux Kernel
Chapter 10. Asynchronous Transfer Mode--ATM
10.1 Introduction
10.2 Implementing ATM in Linux
10.3 Configuration
Chapter 11. Bluetooth in Linux
11.1 Host Controller Interface (HCI)
11.2 L2CAP
11.3 Other Protocols
Chapter 12. Transparent Bridges
12.1 Introduction
12.2 Basics
12.3 Configuring a Bridge in Linux
12.4 Implementation
Part IV: Network Layer
Chapter 13. The TCP/IP Protocols
13.1 The Internet Protocol Suite
Chapter 14. The Internet Protocol V4
14.1.1 Routing IP Packets Across Routers
14.2 Implementing the Internet Protocol
14.3 IP Options
14.4 Internet Control Message Protocol (ICMP)
Chapter 15. Address Resolution Protocol (ARP)
15.1 Using the Address Resolution Protocol
15.2 The ARP Command
15.3 Implementing the ARP Instance in the Linux Kernel
Chapter 16. IP Routing
16.1 Introduction
16.2 Configuration
16.3 Implementation
Chapter 17. IP Multicast for Group Communication
17.1.1 Unicast
17.2 IP Multicast
17.3 Internet Group Management Protocol (IGMP)
17.4 Multicast Data Path in the Linux Kernel
17.5 Multicasting in Today's Internet
17.6 Multicast Transport Protocols
Chapter 18. Using Traffic Control to Support Quality of Service (QoS)
18.1 Introduction
18.2 Basic Structure of Traffic Control in Linux
18.3 Traffic Control in the Outgoing Direction
18.4 Kernel Structures and Interfaces
18.5 Ingress Policing
18.6 Implementing a Queuing Discipline
18.7 Configuration
Chapter 19. Packet Filters and Firewalls
19.1 Introduction
19.2 The Ipchains Architecture of Linux 2.2
19.3 The Netfilter Architecture of Linux 2.4
Chapter 20. Connection Tracking
20.1 Introduction
20.2 Implementation
Chapter 21. Network Address Translation (NAT)
21.1 Introduction
21.2 Configuring NAT in Linux
21.3 Implementing the NAT Module
21.4 Interfaces to Extend the NAT Module
Chapter 22. Extending the Linux Network Architecture Functionality--KIDS
22.1 Managing Dynamically Extendable Functionalities
22.2 Structure of the KIDS Construction System
22.3 Using the KIDS Example to Extend the Linux Network Architecture
Chapter 23. IPv6--Internet Protocol Version 6
23.1 Introduction
23.2 IPv6 Features
23.3 IPv6 Implementation
Part V: Layer IV--Transport Layer
Chapter 24. Transmission Control Protocol (TCP)
24.1.1 Requirements on TCP
24.2 Implementing The TCP Protocol Instance
24.3 Connection Management
24.4 Protocol Mechanisms For Data Exchange
24.5 Timer Management In TCP
Chapter 25. User Datagram Protocol (UDP)
25.1 Introduction
25.2 Data Structures
25.3 Sending and Receiving UDP Datagrams
Chapter 26. The Concept of Sockets
26.1 Introduction
26.2 BSD Sockets
26.3 Protocol-Specific Sockets
Part VI: Layer V--Application Layer
Chapter 27. Network Programming With Sockets
27.1 Introduction
27.2 Functions of the Socket API
27.3 Examples
Part VII: Appendices
Appendix A. The LXR Source-Code Browser
A.1 Functionality
A.2 Installation
Appendix B. Debugging in the Linux Kernel
B.1 Log Outputs From the Linux Kernel
B.2 Creating Strings in the Kernel
B.3 Information in the /proc Directory
B.4 Using a Debugger with the Linux Kernel
Appendix C. Tools and Commands for Network Operation
C.1 Using ifconfig to Manage Network Devices
C.2 Using ping to Test the Reachability
C.3 Using netstat to View the Network State
C.4 Using route for Routing Information
C.5 Using tcpdump for Network Analysis
C.6 USING traceroute TO TRACE PACKETS
C.7 Other Tools
Appendix D. Example for a Kernel Module
Appendix E. Example for a Network-Layer Protocol
Appendix F. Example for a Transport Protocol
Appendix G. Example for Communication over Sockets
G.1 SERVER
G.2 CLIENT
Bibliography
index
SYMBOL
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Z
The Linux® Networking Architecture: Design and Implementation of Network Protocols in the Linux Kernel By Klaus Wehrle, Frank Pählke, Hartmut Ritter, Daniel Müller, Marc Bechler Publisher: Prentice Hall Pub Date: August 01, 2004 ISBN: 0-13-177720-3 Pages: 648 Supplier:Team FLY The most complete book on Linux networking by leading experts.
The Linux® Networking Architecture: Design and Implementation of Network Protocols in the Linux Kernel By Klaus Wehrle, Frank Pählke, Hartmut Ritter, Daniel Müller, Marc Bechler Publisher: Prentice Hall Pub Date: August 01, 2004 ISBN: 0-13-177720-3 Pages: 648 • Table of Contents • Index Section 1.1. The Linux Operating System Section 1.2. What is Linux? Section 1.3. Reasons for Using Linux Section 2.1. Monolithic Architectures and Microkernels Section 2.2. Activities in the Linux Kernel Section 2.3. Locking—Atomic Operations Section 2.4. Kernel Modules Section 2.5. Device Drivers Section 2.6. Memory Management in the Kernel Section 2.7. Timing in the Linux Kernel Section 2.8. The Proc File System Section 2.9. Versioning Copyright Preface Organization of this Book Additional Sources of Information Conventions Used in this Book Acknowledgments Part I: The Linux Kernel Chapter 1. Motivation Chapter 2. The Kernel Structure Part II: Architecture of Network Implementation Chapter 3. The Architecture of Communication Systems Chapter 4. Managing Network Packets in the Kernel Chapter 5. Network Devices Part III: Layer I + II—Medium Access and Logical Link Layer Chapter 6. Introduction to the Data-Link Layer Section 6.1. Structure of the Data-Link Layer Section 6.2. Processes on the Data-Link Layer Section 6.3. Managing Layer-3 Protocols Chapter 7. The Serial-Line Internet Protocol (SLIP) Chapter 8. The Point-to-Point Protocol (PPP) Section 8.1. Introduction Section 8.2. PPP Configuration in Linux Section 8.3. PPP Implementation in the Linux Kernel Section 3.1. Layer-Based Communication Models Section 3.2. Services and Protocols Section 4.1. Socket Buffers Section 4.2. Socket-Buffer Queues Section 5.1. The net_device Interface Section 5.2. Managing Network Devices Section 5.3. Network Drivers Section 7.1. Introduction Section 7.2. Slip Implementation in the Linux Kernel ii xiii xiv xv xvi xvii 1 3 4 5 6 9 11 12 17 23 29 31 35 40 43 45 47 47 52 55 55 66 71 73 82 92 115 117 117 119 127 132 132 134 145 145 148 150
Section 8.4. Implementing the PPP Daemon Section 12.1. Introduction Section 12.2. Basics Section 12.3. Configuring a Bridge in Linux Section 12.4. Implementation Section 13.1. The Internet Protocol Suite Section 14.1. Properties of the Internet Protocol Section 14.2. Implementing the Internet Protocol Section 14.3. IP Options Section 14.4. Internet Control Message Protocol (ICMP) Chapter 9. PPP over Ethernet Section 9.1. Introduction Section 9.2. PPPOE Specification in RFC 2516 Section 9.3. Implementation in the User Space Section 9.4. Implementation in the Linux Kernel Chapter 10. Asynchronous Transfer Mode—ATM Section 10.1. Introduction Section 10.2. Implementing ATM in Linux Section 10.3. Configuration Chapter 11. Bluetooth in Linux Section 11.1. Host Controller Interface (HCI) Section 11.2. L2CAP Section 11.3. Other Protocols Chapter 12. Transparent Bridges Part IV: Network Layer Chapter 13. The TCP/IP Protocols Chapter 14. The Internet Protocol V4 Chapter 15. Address Resolution Protocol (ARP) Chapter 16. IP Routing Chapter 17. IP Multicast for Group Communication Chapter 18. Using Traffic Control to Support Quality of Service (QoS) Chapter 19. Packet Filters and Firewalls Chapter 20. Connection Tracking Section 18.1. Introduction Section 18.2. Basic Structure of Traffic Control in Linux Section 18.3. Traffic Control in the Outgoing Direction Section 18.4. Kernel Structures and Interfaces Section 18.5. Ingress Policing Section 18.6. Implementing a Queuing Discipline Section 18.7. Configuration Section 17.1. Group Communication Section 17.2. IP Multicast Section 17.3. Internet Group Management Protocol (IGMP) Section 17.4. Multicast Data Path in the Linux Kernel Section 17.5. Multicasting in Today's Internet Section 17.6. Multicast Transport Protocols Section 19.1. Introduction Section 19.2. The Ipchains Architecture of Linux 2.2 Section 19.3. The Netfilter Architecture of Linux 2.4 Section 20.1. Introduction Section 20.2. Implementation Section 15.1. Using the Address Resolution Protocol Section 15.2. The ARP Command Section 15.3. Implementing the ARP Instance in the Linux Kernel Section 16.1. Introduction Section 16.2. Configuration Section 16.3. Implementation 150 158 161 161 161 163 164 168 168 169 177 179 181 185 188 189 189 190 199 202 221 223 224 227 228 233 250 262 273 274 276 277 293 293 301 309 330 331 333 339 345 355 364 366 366 367 367 369 378 378 381 383 383 386 391 399 399 400
Section 23.1. Introduction Section 23.2. IPv6 Features Section 23.3. IPv6 Implementation Section 26.1. Introduction Section 26.2. BSD Sockets Section 26.3. Protocol-Specific Sockets Section 27.1. Introduction Section 27.2. Functions of the Socket API Section 27.3. Examples Section A.1. Functionality Section A.2. Installation Section 25.1. Introduction Section 25.2. Data Structures Section 25.3. Sending and Receiving UDP Datagrams Section 21.1. Introduction Section 21.2. Configuring NAT in Linux Section 21.3. Implementing the NAT Module Section 21.4. Interfaces to Extend the NAT Module 400 410 410 414 416 422 426 Section 22.1. Managing Dynamically Extendable Functionalities 426 Section 22.2. Structure of the KIDS Construction System 428 Section 22.3. Using the KIDS Example to Extend the Linux Network Architecture431 443 443 443 450 455 457 457 460 476 486 508 513 513 514 519 522 522 522 526 533 535 535 538 548 549 551 551 555 557 557 561 564 569 572 572 575 576 578 579 582 584 588 591 593 595 595 598 Chapter 21. Network Address Translation (NAT) Chapter 22. Extending the Linux Network Architecture Functionality—KIDS Chapter 23. IPv6—Internet Protocol Version 6 Part V: Layer IV—Transport Layer Chapter 24. Transmission Control Protocol (TCP) Section 24.1. Overview Section 24.2. Implementing The TCP Protocol Instance Section 24.3. Connection Management Section 24.4. Protocol Mechanisms For Data Exchange Section 24.5. Timer Management In TCP Chapter 25. User Datagram Protocol (UDP) Chapter 26. The Concept of Sockets Part VI: Layer V—Application Layer Chapter 27. Network Programming With Sockets Part VII: Appendices Appendix A. The LXR Source-Code Browser Appendix B. Debugging in the Linux Kernel Appendix C. Tools and Commands for Network Operation Section C.1. Using ifconfig to Manage Network Devices Section C.2. Using ping to Test the Reachability Section C.3. Using netstat to View the Network State Section C.4. Using route for Routing Information Section C.5. Using tcpdump for Network Analysis Section C.6. USING traceroute TO TRACE PACKETS Section C.7. Other Tools Appendix D. Example for a Kernel Module Appendix E. Example for a Network-Layer Protocol Appendix F. Example for a Transport Protocol Appendix G. Example for Communication over Sockets Bibliography Section B.1. Log Outputs From the Linux Kernel Section B.2. Creating Strings in the Kernel Section B.3. Information in the /proc Directory Section B.4. Using a Debugger with the Linux Kernel Section G.1. SERVER Section G.2. CLIENT Index
Copyright An Alan R. Apt Book Library of Congress Cataloging-in-Publication Data CIP DATA AVAILABLE. Vice President and Editorial Director, ECS: Marcia J. Horton Publisher: Alan Apt Associate Editor: Toni Dianne Holm Editorial Assistant: Patrick Lindner Vice President and Director of Production and Manufacturing, ESM: David W. Riccardi Executive Managing Editor: Vince O'Brien Managing Editor: Camille Trentacoste Production Editor: Irwin Zucker Director of Creative Services: Paul Belfanti Creative Director: Carole Anson Art Director and Cover Manager: Jayne Conte Managing Editor, AV Management and Production: Patricia Burns Art Editor: Gregory Dulles Manufacturing Manager: Trudy Pisciotti Manufacturing Buyer: Lisa McDowell Marketing Manager: Pamela Hersperger Translator: Angelika Shafir © 2005 Pearson Education, Inc. Pearson Prentice Hall Pearson Education, Inc. Upper Saddle River, NJ 07458 Authorized translation from the German language edition entitled Linux Netzwerkarchitektur: Design und Implementierung von Netzwerkprotokollen im Linux-Kern published by Addison- Wesley, an imprint of Pearson Education Deutschland GmbH, München, ©2002. All rights reserved. No part of this book may be reproduced in any form or by any means, without permission in writing from the publisher. Pearson Prentice Hall® is a trademark of Pearson Education, Inc. Linux® is a registered trademark of Linus Torvalds.
The author and publisher of this book have used their best efforts in preparing this book. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The author and publisher make no warranty of any kind, expressed or implied, with regard to these programs or the documentation contained in this book. The author and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs. Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 Pearson Education Ltd., London Pearson Education Australia Pty. Ltd., Sydney Pearson Education Singapore, Pte. Ltd. Pearson Education North Asia Ltd., Hong Kong Pearson Education Canada, Inc., Toronto Pearson Educación de Mexico, S.A. de C.V. Pearson Education—Japan, Tokyo Pearson Education Malaysia, Pte. Ltd. Pearson Education, Inc., Upper Saddle River, New Jersey
Preface This book deals with the architecture of the network subsystem in the Linux kernel. The idea for this book was born at the Institute of Telematics at the University of Karlsruhe, Germany, where the Linux kernel has been used in many research projects and its network functionality is modified or enhanced, respectively, in a targeted way. For instance, new services and protocols were developed for the next-generation Internet, and their behavior was studied. In addition, existing protocols, such as the TCP transport protocol, were modified to improve their behavior and adapt them to the new situation in the Internet. In the course of these research projects, it has been found that the Linux kernel is very suitable for studying new network functionalities, because it features a stable and extensive implementation of the TCP/IP protocol family. The freely available source code allows us to modify and enhance the functionality of protocol instances easily. In addition, the enhancement of the kernel functionality is very elegantly supported by the principle of the kernel modules. However, many studies and theses in this field showed that familiarization with the Linux network architecture, which is required before you can modify the behavior of a protocol instance, demands considerable work and time. Unfortunately, this is mainly due to the facts that the network subsystem of the Linux kernel is poorly documented and that there is no material that would explain and summarize the basic concepts. Although there are a few books that deal with the Linux kernel architecture and introduce its basic concepts, none of these books includes a full discussion of the network implementation. This situation may be due to the following two reasons: The network subsystem in the Linux kernel is very complex. As mentioned above, it implements a large number of protocols, which is probably one good reason for the enormous success of Linux. Both [BoCe00] and [BBDK+01] mention that the description of all these protocols and their concepts would actually fill an entire book. Well, you are reading such a book now, and, as you can see, it has eventually turned out to be quite a large volume, although it describes only part of the network functionality, in addition to the basic concepts of the Linux network architecture. Operating-system developers normally deal with the classical topics of system architecture —for example, the management of memories, processes, and devices, or the synchronization of parallel activities in a system—rather than with the handling of network packets. As you go along in this book, you will surely notice that it has been written not by system developers, but by computer-science specialists and communication engineers. While considering the facts that there was little documentation covering the Linux network architecture and that students had to familiarize themselves with it over and over again, we had the idea of creating a simple documentation of the Linux network architecture ourselves. Another wish that eventually led to the more extensive concept of this book was a stronger discussion of important communication issues: design and implementation of network protocols in real-world systems. Networking courses teach students the most important concepts and standards in the field of telecommunication, but the design and implementation of network functionality (mainly of network protocols) by use of computer-science concepts has enjoyed little attention in teaching efforts, despite the fact that this knowledge could have been used often within the scope of studies and theses. The authors consider the description of the implementation of the Linux network architecture and its structure, interfaces, and applied concepts a step towards strengthening the informatics component in networking classes. The authors hope that this book will help to make the processes and structures of the Linux network architecture easier to understand, and, above all, that our readers will have fun dealing with it and perhaps learn a few things about the networking concept and its practical
分享到:
收藏