UNIX System V Network Programming

UNIX System V Network Programming

by Stephen Rago
UNIX System V Network Programming

UNIX System V Network Programming

by Stephen Rago

eBook

$26.99  $35.99 Save 25% Current price is $26.99, Original price is $35.99. You Save 25%.

Available on Compatible NOOK Devices and the free NOOK Apps.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

Finally, with UNIX® System V Network Programming, an authoritative reference is available for programmers and system architects interested in building networked and distributed applications for UNIX System V. Even if you currently use a different version of the UNIX system, such as the latest release of 4.3BSD or SunOS, this book is valuable to you because it is centered around UNIX System V Release 4, the version of the UNIX system that unified many of the divergent UNIX implementations.

For those professionals new to networking and UNIX system programming, two introductory chapters are provided. The author then presents the programming interfaces most important to building communication software in System V, including STREAMS, the Transport Layer Interface library, Sockets, and Remote Procedure Calls. So that your designs are not limited to user-level, the author also explains how to write kernel-level communication software, including STREAMS drivers, modules, and multiplexors.

Many examples are provided, including an Ethernet driver and a transport-level multiplexing driver. In the final chapter, the author brings the material from previous chapters together, presenting the design of a SLIP communication package.


Product Details

ISBN-13: 9780133893014
Publisher: Pearson Education
Publication date: 03/31/1993
Series: Addison-Wesley Professional Computing Series
Sold by: Barnes & Noble
Format: eBook
File size: 50 MB
Note: This product may take a few minutes to download.

About the Author

Stephen A. Rago, one of the Bell Laboratories developers who built UNIX System V, Release 4, currently works as a manger at EMC, specializing in file servers and file systems.



Table of Contents

( Each chapter ends with a Summary, Exercises, Bibliographic Notes.)

Preface.

I. BACKGROUND MATERIAL.

1. Introduction to Networks.

Background.

Network Characteristics.

Networking Models.

2. UNIX Programming.

Overview.

Concepts.

Conventions.

Writing Programs.

Summary.

Exercise.

II. USER-LEVEL NETWORK PROGRAMMING.

3. STREAMS.

STREAMS Background.

STREAMS Architecture.

System Calls.

Nonblocking I/O and Polling.

Service Interfaces.

IPC with STREAMS Pipes.

Advanced Topics.

4. The Transport Layer Interface.

Introduction.

Transport Endpoint Management.

Connectionless Service.

Connection-oriented Service.

TLI and Read/Write.

5. Selecting Networks and Addresses.

Introduction.

Network Selection.

Name-to-Address Translation.

Name-to-Address Library.

Design.

6. The Network Listener Facility.

The Service Access Facility.

Port Monitors.

The Listener Process.

One-shot Servers.

Standing Servers.

The NLPS Server.

7. Sockets.

Introduction.

Socket Management.

Connection Establishment.

Data Transfer.

UNIX Domain Sockets.

Advanced Topics.

Comparison with the TLI.

Name-to-Address Translation.

8. Remote Procedure Calls.

Introduction.

XDR.

High-level RPC Programming.

Low-level RPC Programming.

rpcgen.

Advanced RPC Features.

III. KERNEL-LEVEL NETWORK PROGRAMMING.

9. The STREAMS Subsystem.

The Kernel Environment.

The STREAMS Environment.

STREAMS Messages.

STREAMS Queues.

Communicating with Messages.

Message Types.

10. STREAMS Drivers.

Introduction.

Driver Entry Points.

The Data Link Provider Interface.

Ethernet Driver Example.

11. STREAMS Modules.

Introduction.

Module Entry Points.

The Terminal Interface.

Network TTY Emulator Example.

12. STREAMS Multiplexors.

Introduction.

How Multiplexors Work.

The Transport Provider Interface.

Transport Provider Example.

IV. DESIGN PROJECT: IMPLEMENTING SLIP.

13. Design Project: Implementing SLIP.

Introduction to SLIP.

Software Architecture.

User-level Components.

Kernel-level Components.

Bibliography.
Index. 0201563185T04062001

Preface

This book is for programmers who are interested in learning how to use the networking interfaces in UNIX System V Release 4 (SVR4). We use real-life examples to demonstrate how interfaces are used and techniques are applied. All too often in the workplace we find ourselves faced with new assignments for which we have little background. In these situations, we must educate ourselves as quickly as possible so that we can competently undertake the task at hand. Although technical manuals usually provide the information necessary to complete a task, they often lack the background, motivation, and explanation that help us to understand more clearly what we're doing and why we're doing it.

Intended as a practical reference, this book contains very little coverage of theory, and details better dealt with through manual pages are omitted, although references are used liberally. It could, however, be used to complement a graduate or advanced undergraduate course in networking.

As a prerequisite to reading this book, you should be familiar with the UNIX environment and the C programming language so that the examples can be understood. Some background in data structures and algorithms would be helpful, but is not required.

References to SVR4 manual pages are in the running text, appearing as the command name or function name, followed by the section of the manual in which the page is found, as in open (2). Here, we are referring to the open manual page in Section 2 of the system manuals.

Originally, there was only one manual for the system. With the introduction of each new release of the system, the manual grew in size until it had to be split up into separate manuals. In UNIX SystemV Release 3, there was one manual for users, one manual for programmers, and one manual for system administrators.

In SVR4, however, the manual pages were redistributed by functional area. The user commands are no longer in a single manual, nor can you find all the programming interfaces in one place. This new organization has proven difficult to navigate by novices and experts alike. The following summary should aid in the process of locating the desired manual pages.

Programmer's Reference Manual
(1) Commands relating to source code management, compilation, and loading
(2) System calls
(3, 3C, 3S, 3E, 3G, 3M, 3X) Most library routines
(4) File formats
(5) Miscellany (commonly used constants, data structures, and macros)

Programmer's Guide: Networking Interfaces
(1, 1M) Networking commands
(3, 3C, 3N) Network-related library routines
(4) Network-related file formats
(5) Miscellany, including network-related environment variables
(7) Networking drivers and modules

Programmer's Guide: STREAMS
(1, 1M) STREAMS-related commands
(2) STREAMS-specific system calls
(3C) STREAMS-specific library routines
(7) STREAMS modules and drivers

User's Reference Manual
(1) Commands any user might want to run

System Administrator's Reference Manual
(1M) Administrative commands
(4) Administrative file formats
(5) Miscellaneous facilities
(7) Special files (devices)
(8) Administrative procedures

You might find it helpful if these manuals are close by when you read this book.

Background

The first standard network interface incorporated in the UNIX system was the socket mechanism. This mechanism was provided in the 4.2 release of the Berkeley Software Distribution (BSD) version of the UNIX operating system from the University of California at Berkeley. With it was an implementation of the Internet protocol suite (TCP, UDP, IP, et al.). These became available in 1983.

AT&T did not address standard networking interfaces in System V until 1985, when it ported Dennis Ritchie's Streams mechanism from the Version 8 Research UNIX System to UNIX System V Release 2.0p, the unreleased predecessor to System V Release 3.0 (SVR3). With the release of SVR3 in 1986, STREAMS, the framework for networking in System V, became generally available, along with the Transport Layer Interface (TLI) library. Ironically, SVR3 was released without including any networking protocols.

In 1988, X/OPEN, a consortium dedicated to enhancing application portability through standards endorsements, specified its own transport layer interface library, based on AT&T's TLI library. The X/OPEN specification, called the X/OPEN Transport Interface (XTI), is effectively a superset of TLI. In 1990 the Portable Operating System Interface (POSIX) committee of the Institute of Electrical and Electronics Engineers (IEEE) created the 1003.12 working group to standardize portable networking interfaces for application programs. As of this writing, the 1003.12 working group's efforts are still underway, but it looks as though both sockets and XTI will be included in the standard.

SVR4 is unique in that it includes support for many standards in one operating system. Unlike other versions of UNIX that support dual-universe environments, SVR4 provides applications with one environment consisting of features from previous versions of the System V, SunOS, BSD, Xenix, SCO, and Research UNIX systems, as well as some new features of its own. Support for POSIX 1003.1 (the system application programming interface) is also provided. The major networking interfaces provided include STREAMS, TLI, sockets, and remote procedure calls.

Organization

The material covered in this book pertains mainly to SVR4, although some features were present in earlier releases of UNIX System V. This book is divided into four sections: background material, user-level network programming, kernel-level network programming, and a design example.

Both user-level and kernel-level networking components are described to present a complete picture of network programming in UNIX System V. Although not everyone will be interested in both environments, knowledge of one environment makes programming in the other easier. Instead of just blindly following the instructions in the manuals, it enables the programmer to understand the effects of his or her actions and make better design decisions.

The first two chapters provide some background that will make the rest of the book more useful to readers with less experience. More experienced readers can skip these introductory chapters without much loss of context. Chapter 1 provides a brief introduction to networking concepts, and Chapter 2 provides an overview of application programming in the UNIX System V environment. In particular, Chapter 2 contains example functions that are used throughout the rest of this text. If you skip Chapter 2, you might want to refer back to individual examples as you come across these functions in later chapters.

Chapter 3 is the first chapter concerned with network programming per se. It covers the STREAMS programming environment. Since the STREAMS mechanism is the basis for most of the communication facilities in System V, understanding its services and system call interface is a prerequisite to discussing any System V networking facility.

Chapter 4 covers the Transport Layer Interface library. This is the interface applications use to access the services provided by the transport layer of a computer network. Emphasis is placed on application design to support network independence.

Chapter 5 describes the network selection and name-to-address translation facilities, which further extend the ability of a programmer to design network-independent applications. Chapter 6 covers the network listener process. Using the listener simplifies the design of server processes. The Service Access Facility (SAF), the administrative framework in which the listener operates, is also discussed.

Chapter 7 gives a brief description of the BSD socket interface and its corresponding implementation in SVR4. The socket and TLI mechanisms are contrasted and compared. Chapter 8 discusses remote procedure calls and the external data representation used to develop distributed applications. This ends the user-level section of the text.

The next four chapters are dedicated to kernel-level network programming. Chapter 9 describes the kernel environment, its utility routines, and the interfaces to the STREAMS environment. Chapter 10 describes how to write STREAMS drivers, centering around the design of a simple Ethernet driver. Chapter 11 describes how to write STREAMS modules, centering around the design of a module that can be used to emulate a terminal over a network connection. Chapter 12 describes how to write STREAMS multiplexing drivers. It uses a simple connection-oriented transport provider as a detailed example.

Finally, the last section of the book, Chapter 13, covers the design of a SLIP package for SVR4, including both the user-level and kernel-level components. It illustrates the application of much from the preceding 12 chapters and, in essence, ties the book together.

Much of the interesting material lies in the examples. You are encouraged to work through each until it is understood. Source code for the examples is available via anonymous FTP from the host ftp.uu.net in the file published/books/rago.netprog.tar.Z. If you don't have direct access to the Internet, you can use uucp to copy the source to your machine as follows:

  • uucp uunet!~/published/books/rago.netprog.tar.Z /tmp

    (This will place a copy of rago.netprog.tar.Z in /tmp on your system.) If you have any comments, questions, or bug reports, please send electronic mail.

    Acknowledgements

    This book was produced on an Intel i386-based system running UNIX System V Release 4.0, Version 3. The text editor sam was used to create and update the text. The pictures were created with xcip, a newer version of cip, on an AT&T 630MTG terminal. The output for the book was produced with eqn, tbl, pic, troff, and dpost from the Documenter's WorkBench, Version 3.2.

    I would like to thank the following reviewers for their invaluable input: Steve Albert (Unix System Laboratories), Maury Bach (IBM Scientific and Technical Center), George Bittner (Programmed Logic Corporation), Steve Buroff (AT&T Bell Labs), Jeff Gitlin (AT&T), Ron Gomes (Morgan Stanley & Company), Peter Honeyman (University of Michigan), Brian Kernighan (AT&T Bell Labs), Dave Olander (Unix System Laboratories), Dennis Ritchie (AT&T Bell Labs), Michael Scheer (Plexus Systems), Douglas Schmidt (University of California), Rich Stevens (independent consultant), and Graham Wheeler (Aztec Information Management). In particular, both Brian Kernighan and Rich Stevens read every chapter and freely shared their knowledge, experience, and formatting macros and shell scripts. They have greatly increased the quality of the book.

    Many people helped by answering questions where written history was vague or incomplete. In addition to the reviewers, this group includes Guy Harris (Auspex Systems), Bob Israel (Epoch Systems), Hari Pulijal (Unix System Laboratories), Usha Pulijal (Unix System Laboratories), Glenn Skinner (SunSoft), Ken Thompson (AT&T Bell Labs), and Larry Wehr (AT&T Bell Labs).

    Rich Drechsler (AT&T Bell Labs) provided the PostScript program that increased the width of the constant-width font used throughout this book. Both he and Len Rago (AT&T Bell Labs) helped in debugging problems with the laser printer used during the typesetting of this book. Thanks to them both. Thanks to Dick Hamilton (Unix System Laboratories) for making an early copy of SVR4.2 documentation available. Also, thanks to Gus Amegadzie (Programmed Logic Corporation), who helped test the SLIP software presented in Chapter 13. Special thanks to John Wait (Addison-Wesley) for his advice and encouragement during the last two years.

    Finally, I want to thank my family, without whom this book wouldn't have been possible. They have supported me and helped to pull up the slack created by the amount of time I devoted to writing this book. My parents instilled in me the work ethic necessary to get it done (as well as provided their baby-sitting services), and my wife worked harder to give me the time to write it.

  • From the B&N Reads Blog

    Customer Reviews