SDSU CS 596: Client Server Programming
Basic Terms

[To Course Home Page]
San Diego State University -- This page last updated February 5, 1995
----------

Contents of Basic Terms Lecture

  1. References for Lecture
  2. Terminology and Concepts
    1. Transport Layer Services
    2. TCP/IP - DARPA Internet Protocols
    3. Concepts and Abstraction
    4. Stateless vs. Stateful Servers
    5. Concurrency

References for Lecture

Comer Text Chapters 2 & 3

UNIX Networking Programming by Stevens

Parts of chapter 4 & 5

Terminology and Concepts

Application programs exist at the process layer

Protocol Suite

Collection of protocols from more than one layer that forms the basis of a useful network
Transport and Network layer usually define protocol

Some existing protocol suites:


Network Byte Order & Network Protocols

How to store multibyte data?

Little endian

memory addresses going from right to left

Big endian

memory addresses going from left to right

Network protocol specifies its network byte order

TCP/IP, XNS and SNA use big endian

What happens to application data?


Transport Layer Services

Duplex

Full-duplex - transfer data in two direction at same time

Half-duplex - data can be transferred in one direction at a time

Byte stream or messages

Byte stream

data is considered one flow(stream) of data
data may consist of many separate records (messages)
application must separate message
Unix pipes use streams
Print spooler uses newline character to separate messages

message

boundary is provided between records by network protocols

Flow control

Assures that the sender does not overwhelm the receiver

Does IP have flow control?

Error control

Guarantees that data is received is "error-free"

Corrupted data

Data can be changed during transmission
Use checksum to detect corrupted data
Is it possible for corrupted data to have same checksum as original data?
What is the overhead for checksums?
Lost data

Receiver send acknowledgment of receiving data
Sender resends if it does not get acknowledgment is a specified time

What happens if acknowledgment is lost or corrupted?

What is the overhead for error control?

network performance?
complexity of code?
performance of code?
Sequencing

Data arrives in the same order as it is sent

Packet-switched networks can send two consecutive packets on different routes to same destination

Connection-oriented vs. Connectionless

Connection-oriented (virtual circuit)

Applications appear to have a dedicated circuit between them
send multiple messages

Connectionless (datagram)

Each message is sent independently

Mixing Modes

Reliable protocol - provides sequencing and error control

Are all connection-oriented protocols reliable?


TCP/IP - DARPA Internet Protocols

TCP - Transmission Control Protocol

UDP - User Datagram Protocol

ICMP - Internet Control Message Protocol

Handles error and control information between gateways and hosts

IP - Internet Protocol

ARP - Address Resolution Protocol

RARP - Reverse Address Resolution Protocol


TCP/IP Transport Layer

                                                 IP             UDP            TCP            
Connection-Oriented                              no             no             yes            
Message boundaries                               yes            yes            no             
Data checksum                                    no             opt            yes            
Positive  Acknowledgment                         no             no             yes            
Timeout and Retransmit                           no             no             yes            
Duplication detection                            no             no             yes            
Sequencing                                       no             no             yes            
Flow Control                                     no             no             yes            
Full Duplex                                      yes            yes            yes            


TCP vs. UDP for Client-Server

TCP

Reliable and connection-oriented

UDP

Transmits data faster than TCP

Application must supply all checks on datagrams

Works fine if network works well

Use UDP only if:

Connectionness should addressed in the protocol!

Beware of the UDP trap!


Concepts and Abstraction

We pause for a brief message from our sponsor

Don't lose the forest for all the trees!

Network and C/S programming involves lots of details

Step back and identify concepts and abstractions

Comer seems to do the following

Connection-oriented = TCP
Connectionless = UDP


Stateless vs. Stateful Servers

State information

information about the status of ongoing interactions with clients

Stateless server

Server that does not maintain any state information
Stateful server

Server that maintains state information
Example - File Server

Server allows clients to access files on disk

Client can read and write files

Stateless server

Each client request must contain:

complete file name
/usr/local/www/htdoc/myFile
what to do to the file
current location in the file
Stateful server

Server could store:

file names a client is using
what the client is doing to the file
the current position in the file
keep the file open
Handle               File Name                               other info                       
1                    /usr/sys/crash                                                           
2                    /math/course/hard                                                        
3                    /usr/include/me                                                          

Benefits

messages between client and server can be smaller
processing can be simpler

Problems

State information adds to complexity of server

Client and server can get out of sync


Statelessness is a Protocol Issue

Protocol has to specify if server is stateful or stateless

Protocol has to be different for each

Use stateless servers if network can mess up messages

If using stateless servers all client requests must be idempotent

that is the same request must always produce the same result

Concurrency

Real or apparent simultaneous computing

Timeslicing

Context Switching

Due to concurrency in computers and networks servers can receive concurrent requests from multiple clients

Iterative server

Handle one client at a time (let them wait)
Concurrent Server

Handles multiple clients concurrently
Fork and Processes

Instruction pointer (ip)

Environment pointer (ep)

#include <stdio.h>
int global = 5;

main() {
	int local = 10;

	if (fork() !=0) {

		printf("I'm the parent\n");

	} else {

		printf("Move over Pops\n");
	}
	exit(0);
}