(NOTE: Each chapter begins with an Introduction and concludes with a Summary.
) 1. Introduction and Overview.
Internet Applications Using TCP/IP. Designing Applications for a Distributed Environment. Standard and Nonstandard Application Protocols. An Example of Standard Application Protocol Use. AN Example TELNET Connection. Using TELNET to Access an Alternative Service. Application Protocols and Software Flexibility. Viewing Services from the Provider's Perspective. The Remainder of This Text. 2. The Client Server Model and Software Design.
Motivation. Terminology and Concepts. 3. Concurrent Processing in Client-Server Software.
Concurrency in Networks. Concurrency in Servers. Terminology and Concepts. An Example of Concurrent Process Creation. Executing New Code. Context Switching and Protocol Software Design. Concurrency and Asynchronous I/O. 4. Application Interface to Protocols.
Loosely Specified Protocol Software Interface. Interface Functionality. Conceptual Interface Specification. System Calls. Two Basic Approaches to Network Communication. The Basic I/O Functions Available in Linux. Using Linux I/O with TCP/IP. 5. The Socket API.
Berkeley Sockets. Specifying a Protocol Interface. The Socket Abstraction. Specifying an Endpoint Address. A Generic Address Structure. Major System Calls in the Socket API. Utility Routines for Integer Conversion. Using Socket Calls in a Program. Symbolic Constants for Socket Call Parameters. 6. Algorithms and Issues in Client Software Design.
Learning Algorithms Instead of Details. Client Architecture. Identifying the Location of a Server. Parsing an Address Argument. Looking Up a Domain Name. Looking Up a Well-Known Port by Name. Port Numbers and Network Byte Order. Looking Up a Protocol by Name. The TCP Client Algorithm. Allocating a Socket. Choosing a Local Protocol Port Number. A Fundamental Problem in Choosing a Local IP Address. Connecting a TCP Socket to a Server. Communication with the Server Using TCP. Receiving a Response from a TCP Connection. Closing a TCP Connection. Programming a UDP Client. Connected and Unconnected UDP Sockets. Using Connect with UDP. Communicating with a Server Using UDP. Closing a Socket That Uses UDP. Partial Close for UDP. A Warning about UDP Unreliability. 7. Example Client Software.
The Importance of Small Examples. Hiding Details. An Example Procedure Library for Client Programs. Implementation of ConnectTCP. Implementation of ConnectUDP. A Procedure That Forms Connections. Using the Example Library. The DAYTIME Service. Implementation of a TCP Client for DAYTIME. Reading from a TCP Connection. The TIME Service. Accessing the TIME Service. Accurate Time and Network Delays. A UDP Client for the TIME Service. The ECHO Service. A TCP Client for the ECHO Service. A UDP Client for the ECHO Service. 8. Algorithms and Issues in Server Software Design.
The Conceptual Server Algorithm. Concurrent vs. Iterative Servers. Connection-Oriented vs. Connectionless Access. Transport Protocol Semantics. Choice of Transport. Connection-Oriented Servers. Connectionless Servers. Failure, Reliability, and Statelessness. Optimizing Stateless Servers. Four Basic Types of Servers. Request Processing Time. Iterative Server Algorithms. An Iterative, Connection-Oriented Server Algorithm. Binding to a Well-Known Address Using INADDR_ANY. Placing the Socket in Passive Mode. Accepting Connections and Using Them. An Iterative, Connectionless Server Algorithm. Forming a Reply Address in a Connectionless Server. Concurrent Server Algorithms. Master and Slaves. A Concurrent, Connectionless Server Algorithm. A Concurrent, Connection-Oriented Server Algorithm. Implementations of Server Concurrency. Using Separate Programs as Slaves. Apparent Concurrency Using a Single Thread. When to Use Each Server Type. A Summery of Server Types. The Important Problem of Server Deadlock. Alternative Implementations. 9. Iterative, Connectionless Servers (UDP).
Creating a Passive Socket. Process Structure. An Example TIME Server. 10. Iterative, Connection-Oriented Servers (TCP).
Allocating a Passive TCP Socket. A Server for the DAYTIME Service. Process Structure. An Example DAYTIME Server. Closing Connections. Connection Termination and Server Vulnerability. 11. Concurrent, Connection-Oriented Servers (TCP).
ECHO Service. Iterative vs. Concurrent Implementations. Process Structure. An Example Concurrent ECHO Server. Cleaning Up Errant Processes. 12. Using Threads for Concurrency (TCP).
Overview of Linux Threads. Advantages of Threads. Disadvantages of Threads. Descriptors, Delay, and Exit. Thread Exit. Thread Coordination and Synchronization. An Example Server Using Threads. Monitor and Control. 13. Single-Thread, Concurrent Servers (TCP).
Data-Driven Processing in a Server. Data-Driven Processing with a Single Thread. Process Structure of a Single-Thread Server. An Example Single-Thread ECHO Server. 14. Multiprotocol Servers (TCP, UDP).
The Motivation for Reducing the Number of Servers. Multiprotocol Server Design. Process Structure. An Example Multiprotocol DAYTIME Server. The Concept of Shared Code. Concurrent Multiprotocol Servers. 15. Multiservice Servers (TCP, UDP).
Consolidating Servers. A Connectionless, Multiservice Server Design. A Connection-Oriented, Multiservice Server Design. A Concurrent, Connection-Oriented, Multiservice Server. A Single-Thread, Multiservice Server Implementation. Invoking Separate Programs from a Multiservice Server. Multiservice, Multiprotocol Designs. An Example Multiservice Server. Static and Dynamic Server Configuration. The Super Server, Inetd. An Example Inetd Server. A List of Server Variations. 16. Uniform, Efficient Management of Server Concurrency.
Choosing between an Iterative and a Concurrent Design. Level of Concurrency. Demand-Driven Concurrency. The Cost of Concurrency. Overhead and Delay. Small Delays Can Matter. Slave Preallocation. Delayed Slave Allocation. The Uniform Basis for Both Techniques. Combining Techniques. 17. Concurrency in Clients.
The Advantages of Concurrency. The Motivation for Exercising Control. Concurrent Contact with Multiple Servers. Implementing Concurrent Clients. Single-Thread Implementations. An Example Concurrent Client That Uses ECHO. Execution of the Concurrent Client. Concurrency in the Example Code. 18. Tunneling at the Transport and Application Levels.
Multiprotocol Environments. Mixing Network Technologies. Dynamic Circuit Allocation. Encapsulation and Tunneling. Tunneling through an IP Internet. Application-Level Tunneling between Clients and Servers. Tunneling, Encapsulation, and Dialup Phone Lines. 19. Application Level Gateways.
Clients and Servers in Constrained Environments. Using Application Gateways. Interoperability through a Mail Gateway. Implementation of a Mail Gateway. A Comparison of Application Gateways and Tunneling. Application Gateways and Limited Internet Connectivity. Application Gateways Used for Security. Application Gateways and the Extra Hop Problem. An Example Application Gateway. Implementation of an Application Gateway. Code for the Application Gateway. An Example Gateway Exchange. Using Rfcd with .Forware or Slocal. A General-Purpose Application Gateway. Operation of SLIRP. How SLIRP Handles Connections. IP Addressing and SLIRP. 20. External Data Representation (XDR).
Representations of Data. Asymmetric Conversion and the N-Squared Problem. Network Standard Byte Order. A De Facto Standard External Data Representation. XDR Data Types. Implicit Types. Software Support for Using XDR. XDR Library Routines. Building a Message One Piece at a time. Conversion Routines in the XDR Library. XDR Streams, I/O, and TCP. Records, Record Boundaries, and Datagram I/O. 21. Remote Procedure Call Concept (RPC).
Remote Procedure Call Model. Two Paradigms for Building Distributed Programs. A Conceptual Model for Conventional Procedure Calls. An Extension of Conventional Procedure Call and Return. The Procedural Model in Distributed Systems. Analogy between Client-Server and RPC. Distributed Computation as a Program. Sun Microsystems' Remote Procedure Call Definition. Remote Programs and Procedures. Reducing the Number of Arguments. Identifying Remote Programs and Procedures. Accommodating Multiple Versions of a Remote Program. Mutual Exclusion for Procedures in a Remote Program. Communication Semantics. At Least Once Semantics. RPC Retransmission. Mapping a Remote Program to a Protocol Port. Dynamic Port Mapping. RPC Port Mapper Algorithm. ONC RPC Message Format. Marshaling Arguments for a Remote Procedure. Authentication. An Example of RPC Message Representation. An Example of the UNIX Authentication Field. 22. Distributed Program Generation (Rpcgen Concept).
Using Remote Procedure Calls. Programming Mechanisms to Support RPC. Dividing a Program into Local and Remote Procedures. Adding Code for RPC. Stub Procedures. Multiple Remote Procedures and Dispatching. Name of the Client-Side Stub Procedure. Using Rpcgen to Generate Distributed Programs. Rpcgen Output and Interface Procedures. Rpcgen Input and Output. Using Rpcgen to Build a Client and Server. 23. Distributed Program Generation (Rpcgen Example).
An Example to Illustrate Rpcgen. Dictionary Operations. Eight Steps to a Distributed Application. Step 1: Build a Conventional Application Program. Step 2: Divide the Program into Two Parts. Step 3: Create an Rpcgen Specification. Step 4: Run Rpcgen. The .H File Produced by Rpcgen. The XDR Conversion File Produced by Rpcgen. The Client Code Produced by Rpcgen. The Server Code Produced by Rpcgen. Step 5: Write Stub Interface Procedures. Step 6: Compile and Link the Client Program. Step 7: Compile and Link the Server Program. Step 8: Start the Server and Execute the Client. Using the Make Utility. 24. Network File System Concepts (NFS).
Remote File Access vs. Transfer. Operations on Remote Files. File Access among Heterogeneous Computers. Stateless Servers. NFS and UNIX File Semantics. Review of the UNIX File System. Files under NFS. NFS File Types. NFS File Modes. NFS File Attributes. NFS Client and Server. NFS Client Operation. NFS Client and UNIX Systems. NFS Mounts. File Handle. Handles Replace Path Names. File Positioning with a Stateless Server. Operations on Directories. Reading a Directory Statelessly. Multiple Hierarchies in an NFS Server. The Mount Protocol. Transport Protocols for NFS. 25. Network File System Protocols (NFS, Mount).
Using RPC to Define a Protocol. Defining a Protocol with Data Structures and Procedures. NFS Constant, Type, and Data Declarations. NFS Procedures. Semantics of NFS Operations. The Mount Protocol. Procedures in the Mount Protocol. Semantics of Mount Operations. NFS and Mount Authentication. File Locking. Changes in NFS between Versions 3 and 4. 26. A TELNET Client (Program Structure).
Overview. A TELNET Client Algorithm. Terminal I/O in Linux. Establishing Terminal Modes. Global Variable Used for Stored State. Restoring Terminal Modes before Exit. Client Suspension and Resumption. Finite State Machine Specification. Embedding Commands in a TELNET Data Stream. Option Negotiation. Request/Offer Symmetry. TELNET Character Definitions. A Finite State Machine for Data from the Server. Transitions among States. A Finite State Machine Implementation. A Compact FSM Representation. Keeping the Compact Representation at Run-Time. Implementation of a Compact Representation. Building an FSM Transition Matrix. The Socket Output Finite State Machine. Definitions for the Socket Output FSM. The Option Subnegotiation FSM. FSM Initialization. Arguments for the TELNET Client. The Heart of the TELNET Client. Implementation of the Main FSM. 27. A TELNET Client (Implementation Details).
The FSM Action Procedures. Recording the Type of an Option Request. Performing No Operation. Responding to WILL/WONT for the ECHO Option. Responding to WILL/WONT for Unsupported Options. Responding to WILL/WONT for the No Go-Ahead Option. Generating DO/DONT for Binary Transmission. Responding to DO/DONT for Unsupported Options. Responding to DO/DONT for Transmit Binary Option. Responding to DO/DONT for the Terminal Type Option. Option Subnegotiation. Sending Terminal Type Information. Terminating Subnegotiation. Sending a Character to the Server. Displaying Incoming Data on the User's Terminal. Using Termcap to Control the User's Terminal. Writing a Block of Data to the Server. Interacting with the Client Process. Responding to Illegal Commands. Scripting to a File. Implementation of Scripting. Initialization of Scripting. Collecting Characters of the Script File Name. Opening a Script File. Terminating Scripting. Printing Status Information. 28. Streaming Audio and Video Transport (RTP Concept and Design).
Streaming Service. Real-Time Delivery. Protocol Compensation for Jitter. Retransmission, Loss, and Recovery. Real-Time Transport Protocol. Stream Translation and Mixing. Delayed Playback and Jitter Buffers. RTP Control Protocol (RTCP). Synchronizing Multiple Streams. RTP Transport and Many-to-Many Transmission. Sessions, Streams, Protocol Ports, and Demultiplexing. Basic Approaches to Encoding. Conceptual Organization of RTP Software. Process/Thread Structure. Semantics of the API. Jitter Buffer Design and Rebuffering. Event Handling. Playback Anomaly and Timestamp Complications. Size of an Example Real-Time Library. An Example MP3 Player. 29. Streaming Audio and Video Transport (Example RTP Implementation).
An Integrated Implementation. Program Architecture. RTP Definitions. Manipulation of Time Values. RTP Sequence Space Processing. RTP Packet Queue Manipulation. RTP Input Processing. Keeping Statistics for RTCP. RTP Initialization. RTCP Definitions. Receiving RTCP Sender Reports. Generating RTCP Receiver Reports. RTCP Header Creation. RTCP Delay Computation. Generation of an RTCP Bye Message. Size of an Integrated Implementation. 30. Practical Hints and Techniques For Linux Servers.
Operating in Background. Programming a Server to Operate in Background. Open Descriptors and Inheritance. Programming a Server to Close Inherited Descriptors. Signals from the Controlling TTY. Programming a Server to Change Its Controlling TTY. Moving to a Safe and Known Directory. Programming a Server to Change Directories. The Linux Unmask. Programming a Server to Set Its Unmask. Process Groups. Programming a Server to Set Its Process Group. Descriptors for Standard I/O. Programming a Server to Open Standard Descriptors. Mutual Exclusion for the Server. Programming a Server to Avoid Multiple Copies. Recording a Server's Process ID. Programming a Server to Record Its Process ID. Waiting for a Child Process to Exit. Programming a Server to Wait for Each Child to Exit. Extraneous Signals. Programming a Server to Ignore Extraneous Signals. Using a System Log Facility. 31. Deadlock and Starvation in Client-Server Systems.
Definition of Deadlock. Difficulty of Deadlock Detection. Deadlock Avoidance. Deadlock between a Client and Server. Avoiding Deadlock in a Single Interaction. Starvation among a Set of Clients and a Server. Busy Connections and Starvation. Avoiding Blocking Operations. Processes, Connections, and Other Limits. Cycles of Clients and Servers. Documenting Dependencies. Appendix 1: System Calls and Library Routines Used with Sockets. Appendix 2: Manipulation of Linux File and Socket Descriptors. Bibliography. Index.