Chapter 1 Introduction And Overview 1
1.1 Internet Applications Using TCP/IP 1
1.2 Designing Applications For A Distributed Environment 1
1.3 Standard And Nonstandard Application Protocols 2
1.4 An Example Of Standard Application Protocol Use 2
1.5 An Example TELNET Connection 3
1.6 Using TELNET To Access An Alternative Service 4
1.7 Application Protocols And Software Flexibility 5
1.8 Viewing Services From The Provider’s Perspective 6
1.9 The Remainder Of This Text 6
1.10 Summary 7
Chapter 2 The Client Server Model And Software Design 9
2.1 Introduction 9
2.2 Motivation 10
2.3 Terminology And Concepts 10
2.3.1 Clients And Servers 11
2.3.2 Privilege And Complexity 11
2.3.3 Standard Vs. Nonstandard Client Software 12
2.3.4 Parameterization Of Clients 12
2.3.5 Connectionless Vs. Connection-Oriented Servers 13
2.3.6 Stateless Vs. Stateful Servers 14
2.3.7 A Stateless File Server Example 15
2.3.8 A Stateful File Server Example 15
2.3.9 Identifving A Client 16
2.3.10 Statelessness Is A Protocol Issue 18
2.3.11 Servers As Clients 19
2.4 Summary 20
Chapter 3 Concurrent Processing In Client-Server Software 23
3.1 Introduction 23
3.2 Concurrency In Networks 23
3.3 Concurrency In Servers 25
3.4 Terminology And Concepts 26
3.4.1 The Process Concept 26
3.4.2 Sharing Of Local And Global Variables 27
3.4.3 Procedure Calls 28
3.5 An Example Of Concurrent Process Creation 29
3.5.1 A Sequential C Example 29
3.5.2 A Concurrent Version 30
3.5.3 Timeslicing 31
3.5.4 Singly-Threaded Process Assumption 32
3.5.5 Making Processes Diverge 33
3.6 Executing New Code 34
3.7 Context Switching And Protocol Software Design 34
3.8 Concurrency And Asynchronous I/O 35
3.9 Summary 36
Chapter 4 Application Interface To Protocols 39
4.1 Introduction 39
4.2 Loosely Specified Protocol Software Interface 39
4.2.1 Advantages And Disadvantages 40
4.3 Interface Functionality 40
4.4 Conceptual Interface Specification 41
4.5 System Calls 42
4.6 Two Basic Approaches To Network Communication 43
4.7 The Basic I/O Functions Available In Linux 43
4.8 Using Linux I/O With TCP/IP 45
4.9 Summary 45
Chapter 5 The Socket API 47
5.1 Introduction 47
5.2 Berkeley Sockets 47
5.3 Specifying A Protocol Interface 48
5.4 The Socket Abstraction 49
5.4.1 Socket Descriptors And File Descriptors 49
5.4.2 System Data Structures For Sockets 50
5.4.3 Making A Socket Active Or Passive 51
5.5 Specifying An Endpoint Address 52
5.6 A Generic Address Structure 52
5.7 Major System Calls In The Socket API 54
5.7.1 The Socket Call 54
5.7.2 The Connect Call 54
5.7.3 The Send Call 55
5.7.4 The Recv Call 55
5.7.5 The Close Call 55
5.7.6 The Bind Call 56
5.7.7 The Listen Call 56
5.7.8 The Accept Call 56
5.7.9 Using Read And Write With Sockets 56
5.7.10 Summary Of Socket Calls 57
5.8 Utility Routines For Integer Conversion 58
5.9 Using Socket Calls In A Program 58
5.10 Symbolic Constants For Socket Call Parameters 59
5.11 Summary 60
Chapter 6 Algorithms And Issues In Client Software Design 63
6.1 Introduction 63
6.2 Learning Algorithms Instead Of Details 63
6.3 Client Architecture 64
6.4 Identifying The Location Of A Server 64
6.5 Parsing An Address Argument 66
6.6 Looking Up A Domain Name 67
6.7 Looking Up A Well-Known Port By Name 68
6.8 Port Numbers And Network Byte Order 68
6.9 Looking Up A Protocol By Name 69
6.10 The TCP Client Algorithm 69
6.11 Allocating A Socket 70
6.12 Choosing A Local Protocol Port Number 71
6.13 A Fundamental Problem In Choosing A Local IP Address 71
6.14 Connecting A TCP Socket To A Server 72
6.15 Communicating With The Server Using TCP 72
6.16 Receiving A Response From A TCP Connection 73
6.17 Closing A TCP Connection 74
6.17.1 The Need For Partial Close 74
6.17.2 A Partial Close Operation 74
6.18 Programming A UDP Client 75
6.19 Connected And Unconnected UDP Sockets 76
6.20 Using Connect With UDP 76
6.21 Communicating With A Server Using UDP 76
6.22 Closing A Socket That Uses UDP 77
6.23 Partial Close For UDP 77
6.24 A Warning About UDP Unreliability 77
6.25 Summary 77
Chapter 7 Example Client Software 81
7.1 Introduction 81
7.2 The Importance Of Small Examples 81
7.3 Hiding Details 82
7.4 An Example Procedure Library For Client Programs 82
7.5 Implementation Of ConnectTCP 83
7.6 Implementation Of ConnectUDP 84
7.7 A Procedure That Forms Connections 85
7.8 Using The Example Library 88
7.9 The DAYTIME Service 88
7.10 Implementation Of A TCP Client For DAYTIME 89
7.11 Reading From A TCP Connection 90
7.12 The TIME Service 91
7.13 Accessing The TIME Service 91
7.14 Accurate Times And Network Delays 92
7.15 A UDP Client For The TIME Service 92
7.16 The ECHO Service 94
7.17 A TCP Client For The ECHO Service 94
7.18 A UDP Client For The ECHO Service 96
7.19 Summary 98
Chapter 8 Algorithms And Issues In Server Software Design 101
8.1 Introduction 101
8.2 The Conceptual Server Algorithm 101
8.3 Concurrent Vs. Iterative Servers 102
8.4 Connection-Oriented Vs. Connectionless Access 102
8.5 Transport Protocol Semantics 103
8.5.1 TCP Semantics 103
8.5.2 UDP Semantics 103
8.6 Choice Of Transport 104
8.7 Connection-Oriented Servers 104
8.8 Connectionless Servers 105
8.9 Failure, Reliability, And Statelessness 106
8.10 Optimizing Stateless Servers 106
8.11 Four Basic Types Of Servers 109
8.12 Request Processing Time 109
8.13 Iterative Server Algorithms 110
8.14 An Iterative, Connection-Oriented Server Algorithm 110
8.15 Binding To A Well-Known Address Using INADDR ANY 111
8.16 Placing The Socket In Passive Mode 112
8.17 Accepting Connections And Using Them 112
8.18 An Iterative, Connectionless Server Algorithm 112
8.19 Forming A Reply Address In A Connectionless Server 113
8.20 Concurrent Server Algorithms 114
8.21 Master And Slaves 114
8.22 A Concurrent, Connectionless Server Algorithm 115
8.23 A Concurrent, Connection-Oriented Server Algorithm 116
8.24 Implementations Of Server Concurrency 117
8.25 Using Separate Programs As Slaves 118
8.26 Apparent Concurrency Using A Single Thread 118
8.27 When To Use Each Server Type 119
8.28 A Summary of Server Types 120
8.29 The Important Problem Of Server Deadlock 121
8.30 Alternative Implementations 122
8.31 Summary 122
Chapter 9 Iterative, Connectionless Servers (UDP) 125
9.1 Introduction 125
9.2 Creating A Passive Socket 125
9.3 Process Structure 129
9.4 An Example TIME Server 130
9.5 Summary 132
Chapter 10 Iterative, Connection-Oriented Servers (TCP) 135
10.1 Introduction 135
10.2 Allocating A Passive TCP Socket 135
10.3 A Server For The DAYTIME Service 136
10.4 Process Structure 136
10.5 An Example DAYTIME Server 137
10.6 Closing Connections 140
10.7 Connection Termination And Server Vulnerability 140
10.8 Summary 141
Chapter 11 Concurrent, Connection-Oriented Servers (TCP) 143
11.1 Introduction 143
11.2 ECHO Service 143
11.3 Iterative Vs. Concurrent Implementations 144
11.4 Process Structure 144
11.5 An Example Concurrent ECHO Server 145
11.6 Cleaning Up Errant Processes 149
11.7 Summary 150
Chapter 12 Using Threads For Concurrency (TCP) 151
12.1 Introduction 151
12.2 Overview Of Linux Threads 151
12.3 Advantages Of Threads 152
12.4 Disadvantages Of Threads 153
12.5 Descriptors, Delay, And Exit 153
12.6 Thread Exit 154
12.7 Thread Coordination And Synchronization 154
12.7.1 Mutex 154
12.7.2 Semaphore 155
12.7.3 Condition Variable 155
12.8 An Example Server Using Threads 156
12.9 Monitor And Control 160
12.10 Summary 161
Chapter 13 Single-Thread, Concurrent Servers (TCP) 163
13.1 Introduction 163
13.2 Data-driven Processing In A Server 163
13.3 Data-Driven Processing With A Single Thread 164
13.4 Process Structure Of A Single-Thread Server 165
13.5 An Example Single-Thread ECHO Server 166
13.6 Summary 168
Chapter 14 Multiprotocol Servers (TCP, UDP) 171
14.1 Introduction 171
14.2 The Motivation For Reducing The Number Of Servers 171
14.3 Multiprotocol Server Design 172
14.4 Process Structure 172
14.5 An Example Multiprotocol DAYTIME Server 173
14.6 The Concept Of Shared Code 177
14.7 Concurrent Multiprotocol Servers 177
14.8 Summary 178
Chapter 15 Multiservice Servers (TCP, UDP) 179
15.1 Introduction 179
15.2 Consolidating Servers 179
15.3 A Connectionless, Multiservice Server Design 180
15.4 A Connection-Oriented, Multiservice Server Design 181
15.5 A Concurrent, Connection-Oriented, Multiservice Server 182
15.6 A Single-Thread, Multiservice Server Implementation 182
15.7 Invoking Separate Programs From A Multiservice Server 183
15.8 Multiservice, Multiprotocol Designs 185
15.9 An Example Multiservice Server 185
15.10 Static and Dynamic Server Configuration 192
15.11 The Super Server, Inetd 193
15.12 An Example Inetd Server 195
15.13 A List Of Server Variations 197
15.14 Summary 197
Chapter 16 Uniform, Efficient Management Of Server Concurrency 199
16.1 Introduction 199
16.2 Choosing Between An Iterative And A Concurrent Design 199
16.3 Level Of Concurrency 200
16.4 Demand-Driven Concurrency 201
16.5 The Cost Of Concurrency 201
16.6 Overhead And Delay 202
16.7 Small Delays Can Matter 202
16.8 Slave Preallocation 204
16.8.1 Preallocation In Linux 204
16.8.2 Preallocation In A Connection-Oriented Server 205
16.8.3 Mutex, File Locking, and Concurrent Calls To Accept 206
16.8.4 Preallocation In A Connectionless Server 207
16.8.5 Preallocation, Bursty Traffic, And NFS 208
16.8.6 Preallocation On A Multiprocessor 208
16.9 Delayed Slave Allocation 208
16.10 The Uniform Basis For Both Techniques 210
16.11 Combining Techniques 210
16.12 Summary 211
Chapter 17 Concurrency In Clients 213
17.1 Introduction 213
17.2 The Advantages Of Concurrency 213
17.3 The Motivation For Exercising Control 214
17.4 Concurrent Contact With Multiple Servers 215
17.5 Implementing Concurrent Clients 216
17.6 Single-Thread Implementations 217
17.7 An Example Concurrent Client That Uses ECHO 218
17.8 Execution Of The Concurrent Client 222
17.9 Concurrency In The Example Code 224
17.10 Summary 224
Chapter 18 Tunneling At The Transport And Application Levels 227
18.1 Introduction 227
18.2 Multiprotocol Environments 227
18.3 Mixing Network Technologies 229
18.4 Dynamic Circuit Allocation 230
18.5 Encapsulation And Tunneling 231
18.6 Tunneling Through An IP Internet 232
18.7 Application-Level Tunneling Between Clients And Servers 232
18.8 Tunneling, Encapsulation, And Dialup Phone Lines 233
18.9 Summary 234
Chapter 19 Application Level Gateways 237
19.1 Introduction 237
19.2 Clients And Servers In Constrained Environments 237
19.2.1 The Reality Of Limited Access 237
19.2.2 Computers With Limited Functionality 238
19.2.3 Connectivity Constraints That Arise From Security 238
19.3 Using Application Gateways 238
19.4 Interoperability Through A Mail Gateway 240
19.5 Implementation Of A Mail Gateway 240
19.6 A Comparison Of Application Gateways And Tunneling 241
19.7 Application Gateways And Limited Internet Connectivity 243
19.8 Application Gateways Used For Security 245
19.9 Application Gateways And The Extra Hop Problem 245
19.10 An Example Application Gateway 247
19.11 Implementation Of An Application Gateway 248
19.12 Code For The Application Gateway 250
19.13 An Example Gateway Exchange 251
19.14 Using Rfcd With forward Or Slocal 252
19.15 A General-Purpose Application Gateway 253
19.16 Operation Of SLIRP 253
19.17 How SLIRP Handles Connections 254
19.18 IP Addressing And SLIRP 254
19.19 Summary 255
Chapter 20 External Data Representation (XDR) 257
20.1 Introduction 257
20.2 Representations Of Data 257
20.3 Asymmetric Conversion And The N-Squared Problem 258
20.4 Network Standard Byte Order 259
20.5 A De Facto Standard External Data Representation 261
20.6 XDR Data Types 261
20.7 Implicit Types 263
20.8 Software Support For Using XDR 263
20.9 XDR Library Routines 263
20.10 Building A Message One Piece At A Time 264
20.11 Conversion Routines In The XDR Library 265
20.12 XDR Streams, I/O, and TCP 267
20.13 Records, Record Boundaries, And Datagram I/O 268
20.14 Summary 268
Chapter 21 Remote Procedure Call Concept (RPC) 271
21.1 Introduction 271
21.2 Remote Procedure Call Model 271
21.3 Two Paradigms For Building Distributed Programs 272
21.4 A Conceptual Model For Conventional Procedure Calls 273
21.5 An Extension Of the Procedural Model 274
21.6 Execution Of Conventional Procedure Call And Return 274
21.7 The Procedural Model In Distributed Systems 275
21.8 Analogy Between Client-Server And RPC 276
21.9 Distributed Computation As A Program 277
21.10 Sun Microsystems’ Remote Procedure Call Definition 278
21.11 Remote Programs And Procedures 278
21.12 Reducing The Number Of Arguments 279
21.13 Identifying Remote Programs And Procedures 279
21.14 Accommodating Multiple Versions Of A Remote Program 280
21.15 Mutual Exclusion For Procedures In A Remote Program 281
21.16 Communication Semantics 282
21.17 At Least Once Semantics 282
21.18 RPC Retransmission 283
21.19 Mapping A Remote Program To A Protocol Port 283
21.20 Dynamic Port Mapping 284
21.21 RPC Port Mapper Algorithm 285
21.22 ONC RPC Message Format 287
21.23 Marshaling Arguments For A Remote Procedure 288
21.24 Authentication 288
21.25 An Example Of RPC Message Representation 290
21.26 An Example Of The UNIX Authentication Field 290
21.27 Summary 291
Chapter 22 Distributed Program Generation (Rpcgen Concept) 295
22.1 Introduction 295
22.2 Using Remote Procedure Calls 296
22.3 Programming Mechanisms To Support RPC 297
22.4 Dividing A Program Into Local And Remote Procedures 298
22.5 Adding Code For RPC 299
22.6 Stub Procedures 299
22.7 Multiple Remote Procedures And Dispatching 300
22.8 Name Of The Client-Side Stub Procedure 301
22.9 Using Rpcgen To Generate Distributed Programs 302
22.10 Rpcgen Output And Interface Procedures 302
22.11 Rpcgen Input And Output 304
22.12 Using Rpcgen To Build A Client And Server 304
22.13 Summary 305
Chapter 23 Distributed Program Generation (Rpcgen Example) 307
23.1 Introduction 307
23.2 An Example To Illustrate Rpcgen 308
23.3 Dictionary Operations 308
23.4 Eight Steps To A Distributed Application 309
23.5 Step1: Build A Conventional Application Program 310
23.6 Step 2: Divide The Program Into Two Parts 314
23.7 Step 3: Create An Rpcgen Specification 320
23.8 Step 4: Run Rpcgen 322
23.9 The .h File Produced By Rpcgen 322
23.10 The XDR Conversion File Produced By Rpcgen 325
23.11 The Client Code Produced By Rpcgen 326
23.12 The Server Code Produced By Rpcgen 328
23.13 Step 5: Write Stub Interface Procedures 331
23.13.1 Client-Side Interface Routines 331
23.13.2 Server-Side Interface Routines 333
23.14 Step 6: Compile And Link The Client Program 335
23.15 Step 7: Compile And Link The Server Program 339
23.16 Step 8: Start The Server And Execute The Client 341
23.17 Using The Make Utility 341
23.18 Summarv 344
Chapter 24 Network File System Concepts (NFS) 347
24.1 Introduction 347
24.2 Remote File Access Vs. Transfer 347
24.3 Operations On Remote Files 348
24.4 File Access Among Heterogeneous Computers 348
24.5 Stateless Servers 349
24.6 NFS And UNIX File Semantics 349
24.7 Review Of The UNIX File System 349
24.7.1 Basic Definitions 350
24.7.2 A Byte Sequence Without Record Boundaries 350
24.7.3 A File’s Owner And Group Identifiers 350
24.7.4 Protection And Access 351
24.7.5 The Open-Read-Write-Close Paradigm 352
24.7.6 Data Transfer 353
24.7.7 Permission To Search A Directory 353
24.7.8 Random Access 354
24.7.9 Seeking Beyond The End Of File 354
24.7.10 File Position And Concurrent Access 355
24.7.11 Semantics Of Write During Concurrent Access 356
24.7.12 File Names And Paths 356
24.7.13 Inode: Information Stored With A File 357
24.7.14 Stat Operation 358
24.7.15 The File Naming Mechanism 359
24.7.16 File System Mounts 360
24.7.17 File Name Resolution 362
24.7.18 Symbolic Links 363
24.8 Files Under NFS 363
24.9 NFS File Types 364
24.10 NFS File Modes 364
24.11 NFS File Attributes 365
24.12 NFS Client And Server 366
24.13 NFS Client Operation 367
24.14 NFS Client And UNIX Systems 368
24.15 NFS Mounts 369
24.16 File Handle 370
24.17 Handles Replace Path Names 370
24.18 File Positioning With A Stateless Server 372
24.19 Operations On Directories 372
24.20 Reading A Directory Statelessly 372
24.21 Multiple Hierarchies In An NFS Server 373
24.22 The Mount Protocol 374
24.23 Transport Protocols For NFS 374
24.24 Summary 375
Chapter 25 Network File System Protocols (NFS, Mount) 377
25.1 Introduction 377
25.2 Using RPC To Define A Protocol 377
25.3 Defining A Protocol With Data Structures And Procedures 378
25.4 NFS Constant, Tvpe, And Data Declarations 379
25.4.1 NFS Constants 379
25.4.2 NFS Tvpedef Declarations 380
25.4.3 NFS Data Structures 380
25.5 NFS Procedures 383
25.6 Semantics Of NFS Operations 385
25.6.1 NFSPROC3_NULL (Procedure 0) 385
25.6.2 NFSPROC3_GETATTR (Procedure 1) 385
25.6.3 NFSPROC3_SETATTR (Procedure 2) 385
25.6.4 NFSPROC3_LOOKUP (Procedure 3) 385
25.6.5 NFSPROC3_ACCESS (Procedure 4) 385
25.6.6 NFSPROC3_READLINK (Procedure 5) 385
25.6.7 NFSPROC3_READ (Procedure 6) 386
25.6.8 NFSPROC3_WRITE (Procedure 7) 386
25.6.9 NFSPROC3_CREATE (Procedure 8) 386
25.6.10 NFSPROC3_MKDIR (Procedure 9) 386
25.6.11 NFSPROC3_SYMLINK (Procedure 10) 386
25.6.12 NFSPROC3_MKNOD (Procedure 11) 386
25.6.13 NFSPROC3_REMOVE (Procedure 12) 387
25.6.14 NFSPROC3_RMDIR (Procedure 13) 387
25.6.15 NFSPROC3_RENAME (Procedure 14) 387
25.6.16 NFSPROC3_LINK (Procedure 15) 387
25.6.17 NFSPROC3_READDIR (Procedure 16) 387
25.6.18 NFSPROC3_READDIRPLUS (procedure 17) 388
25.6.19 NFSPROC3_FSSTAT (Procedure 18) 388
25.6.20 NFSPROC3_FSINFO (Procedure 19) 388
25.6.21 NFSPROC3_PATHCONF (Procedure 20) 388
25.6.22 NFSPROC3_COMMIT (Procedure 21) 389
25.7 The Mount Protocol 389
25.7.1 Mount Constant Definitions 389
25.7.2 Mount Type Definitions 389
25.7.3 Mount Data Structures 390
25.8 Procedures In The Mount Protocol 391
25.9 Semantics of Mount Operations 391
25.9.1 MOUNTPROC3_NULL (Procedure 0) 392
25.9.2 MOUNTPROC3_MNT (Procedure 1) 392
25.9.3 MOUNTPROC3_DUMP (Procedure 2) 392
25.9.4 MOUNTPROC3_UMNT (Procedure 3) 392
25.9.5 MOUNTPROC3_UMNTALL (Procedure 4) 392
25.9.6 MOUNTPROC3_EXPORT (Procedure 5) 392
25.10 NFS And Mount Authentication 393
25.11 File Locking 394
25.12 Changes In NFS Between Versions 3 And 4 394
25.13 Summary 395
Chapter 26 A TELNET Client (Program Structure) 397
26.1 Introduction 397
26.2 Overview 398
26.2.1 The User’s Terminal 398
26.2.2 Command And Control Information 398
26.2.3 Terminals, Windows, and Files 398
26.2.4 The Need For Concurrency 399
26.2.5 A Process Model For A TELNET Client 400
26.3 A TELNET Client Algorithm 400
26.4 Terminal I/O In Linux 401
26.4.1 Controlling A Device Driver 402
26.5 Establishing Terminal Modes 403
26.6 Global Variable Used For Stored State 405
26.7 Restoring Terminal Modes Before Exit 406
26.8 Client Suspension And Resumption 407
26.9 Finite State Machine Specification 408
26.10 Embedding Commands In A TELNET Data Stream 409
26.11 Option Negotiation 410
26.12 Request/Offer Svmmetrv 410
26.13 TELNET Character Definitions 411
26.14 A Finite State Machine For Data From The Server 412
26.15 Transitions Among States 413
26.16 A Finite State Machine Implementation 415
26.17 A Compact FSM Representation 415
26.18 Keeping The Compact Representation At Run-Time 417
26.19 Implementation Of A Compact Representation 417
26.20 Building An FSM Transition Matrix 419
26.21 The Socket Output Finite State Machine 421
26.22 Definitions For The Socket Output FSM 423
26.23 The Option Subnegotiation Finite State Machine 424
26.24 Definitions For The Option Subnegotiation FSM 425
26.25 FSM Initialization 426
26.26 Arguments For The TELNET Client 427
26.27 The Heart Of The TELNET Client 428
26.28 Implementation Of The Main FSM 432
26.29 Summary 433
Chapter 27 A TELNET Client (Implementation Details) 435
27.1 Introduction 435
27.2 The FSM Action Procedures 435
27.3 Recording The Type Of An Option Request 436
27.4 Performing No Operation 437
27.5 Responding To WILL/WONT For The Echo Option 437
27.6 Responding To WILL/WONT For Unsupported Options 439
27.7 Responding To WILL/WONT For The No Go-Ahead Option 439
27.8 Generating DO/DONT For Binary Transmission 441
27.9 Responding To DO/DONT For Unsupported Options 442
27.10 Responding To DO/DONT For Transmit Binary Option 442
27.11 Responding To DO/DONT For The Terminal Type Option 444
27.12 Option Subnegotiation 445
27.13 Sending Terminal Type Information 446
27.14 Terminating Subnegotiation 448
27.15 Sending A Character To The Server 448
27.16 Displaying Incoming Data On The User’s Terminal 450
27.17 Using Termcap To Control The User’s Terminal 453
27.18 Writing A Block Of Data To The Server 455
27.19 Interacting With The Client Process 456
27.20 Responding To Illegal Commands 456
27.21 Scripting To A File 457
27.22 Implementation Of Scripting 457
27.23 Initialization Of Scripting 458
27.24 Collecting Characters Of The Script File Name 459
27.25 Opening A Script File 460
27.26 Terminating Scripting 462
27.27 Printing Status Information 463
27.28 Summary 464
Chapter 28 Streaming Audio And Video Transport (RTP Concept And Design) 467
28.1 Introduction 467
28.2 Streaming Service 467
28.3 Real-Time Delivery 468
28.4 Protocol Compensation For Jitter 468
28.5 Retransmission, Loss, And Recovery 469
28.6 Real-Time Transport Protocol 470
28.7 Stream Translation And Mixing 471
28.8 Delayed Playback And Jitter Buffers 471
28.9 RTP Control Protocol (RTCP) 472
28.10 Synchronizing Multiple Streams 474
28.11 RTP Transport And Many-To-Many Transmission 475
28.12 Sessions, Streams, Protocol Ports, And Demultiplexing 476
28.13 Basic Approaches To Encoding 477
28.14 Conceptual Organization Of RTP Software 478
28.15 Process/Thread Structure 479
28.16 Semantics Of The API 481
28.17 Jitter Buffer Design And Rebuffering 482
28.18 Event Handling 483
28.19 Playback Anomaly And Timestamp Complications 483
28.20 Size of An Example Real-Time Library 484
28.21 An Example MP3 Player 484
28.22 Summary 485
Chapter 29 Streaming Audio And Video Transport (Example RTP Im- plementation) 487
29.1 Introduction 487
29.2 An Integrated Implementation 487
29.3 Program Architecture 488
29.4 RTP Definitions 488
29.5 Manipulation Of Time Values 492
29.6 RTP Sequence Space Processing 493
29.7 RTP Packet Queue Manipulation 494
29.8 RTP Input Processing 496
29.9 Keeping Statistics For RTCP 499
29.10 RTP Initialization 500
29.11 RTCP Definitions 504
29.12 Receiving RTCP Sender Reports 506
29.13 Generating RTCP Receiver Reports 507
29.14 RTCP Header Creation 509
29.15 RTCP Delay Computation 510
29.16 Generation Of An RTCP Bye Message 511
29.17 Size Of An Integrated Implementation 511
29.18 Summary 512
Chapter 30 Practical Hints And Techniques For Linux Servers 515
30.1 Introduction 515
30.2 Operating In Background 515
30.3 Programming A Server To Operate In Background 516
30.4 Open Descriptors And Inheritance 517
30.5 Programming A Server To Close Inherited Descriptors 518
30.6 Signals From The Controlling TTY 518
30.7 Programming A Server To Change Its Controlling TTY 519
30.8 Moving To A Safe And Known Directory 519
30.9 Programming A Server To Change Directories 520
30.10 The Linux Umask 520
30.11 Programming A Server To Set Its Umask 521
30.12 Process Groups 521
30.13 Programming A Server To Set Its Process Group 521
30.14 Descriptors For Standard I/O 522
30.15 Programming A Server To Open Standard Descriptors 522
30.16 Mutual Exclusion For The Server 522
30.17 Programming A Server To Avoid Multiple Copies 523
30.18 Recording A Server’s Process ID 524
30.19 Programming A Server To Record Its Process ID 524
30.20 Waiting For A Child Process To Exit 524
30.21 Programming A Server To Wait For Each Child To Exit 525
30.22 Extraneous Signals 525
30.23 Programming A Server To Ignore Extraneous Signals 525
30.24 Using A System Log Facility 525
30.24.1 Generating Log Messages 525
30.24.2 The Advantage Of Indirection And Standard Error 526
30.24.3 Limitations Of I/O Redirection 527
30.24.4 A Client-Server Solution 527
30.24.5 The Syslog Mechanism 528
30.24.6 Syslog Message Classes 528
30.24.7 Syslog Facilities 528
30.24.8 Syslog Priority Levels 529
30.24.9 Using Syslog 529
30.24.10 An Example Syslog Configuration File 530
30.25 Summaty 531
Chapter 31 Deadlock And Starvation In Client-Server Systems 533
31.1 Introduction 533
31.2 Definition Of Deadlock 534
31.3 Difficulty Of Deadlock Detection 534
31.4 Deadlock Avoidance 535
31.5 Deadlock Between A Client And Server 535
31.6 Avoiding Deadlock In A Single Interaction 536
31.7 Starvation Among A Set Of Clients And A Server 536
31.8 Busy Connections And Starvation 537
31.9 Avoiding Blocking Operations 538
31.10 Processes, Connections, And Other Limits 538
31.11 Cycles Of Clients And Servers 539
31.12 Documenting Dependencies 540
31.13 Summary 540
Appendix 1 System Calls And Library Routines Used With Sockets 543
Appendix 2 Manipulation Of Linux File And Socket Descriptors 573
Bibliography 577
Index 585