Title: An Introduction to Internetworking
1An Introduction to Internetworking
Topics on Distributed Systems
2Algorithm for client-server communication with
UDP (connectionless)
A SERVER
A CLIENT
- Create a server-socket (listener)and bound it to
a port (higher than 1024) - Start listening for UDP packages comming
- Receive the UDP package and extract Message,
Host Address Port from seder - Build a new UDP package with thesenders Address
Port and the reply message - Send message
- Build a UDP package with the request message,
servers address port numbre - Create socket
- Send package
- Listen to answer
- Receive package
- Extract answer
3Algorithm for client-server communication with
TCP (connection-oriented)
A SERVER
A CLIENT
- Create a server-socket (listener)and bound it to
a port (higher than 1024) - Start listening for request
- Create another (normal) socket and build a TCP
connection when a request arrives - Open IO streams for this connection
- read-write
- Create socket and try a redezvous with a server
(given address and port) - If the redezvous occurs, build a TCP connection
- Open IO streams for this connection
- write-read
THIS IS THE APPLICATIONS PROTOCOLL
4Every layer has the illusion to be talking to the
correspondent one in the other application
A CLIENT
The UDP User Defined Package like writing a
letter
Read write sequence
A SERVER
4444
UDP or TCP communication
A CLIENT
Internet frames and addresses
A CLIENT
electric pulses
5Attending more than a client The sequential
server The problem
A CLIENT
A SERVER
?
A CLIENT
4444
A CLIENT
6During the conversation the server is not
listening at the port 444
A CLIENT
A SERVER
X
A CLIENT
4444
A CLIENT
7Only after the server is ready with the first
client it can listen to the port 4444 again
A CLIENT
A SERVER
?
A CLIENT
4444
A CLIENT
8The service may be to transfer a file. The user
at the client may have first to type and send the
filename
A CLIENT
A SERVER
X
A CLIENT
4444
A CLIENT
9What if the server has to wait too much for a
client to type in a file name ? (or the file is
too big)
A CLIENT
A SERVER
Timeout
X
A CLIENT
4444
A CLIENT
10Concurrent Servers there are separate processes
to attend the port and to transfer the file
A CLIENT
A SERVER
?
4444
A CLIENT
A CLIENT
11After the client contacts the server, the server
creates another process to attend the client and
keeps listening to the port 4444 for another
A CLIENT
A SERVER
?
4444
A CLIENT
A CLIENT
This is a slave process or thread It is
executed paralell to the master process or
thread
12While the new process is serving the first
client, the second client can contact the server
at the port 4444
A CLIENT
A SERVER
?
4444
A CLIENT
A CLIENT
13And the server creates another process
A CLIENT
A SERVER
?
4444
A CLIENT
A CLIENT
14Now the third client contacts the server
A CLIENT
A SERVER
?
4444
A CLIENT
A CLIENT
15And a third slave process or thread is created
A CLIENT
A SERVER
?
4444
A CLIENT
A CLIENT
16When should I use iterative or concurrent server ?
- When the answer to a request is small and speedy
it is better to have an iterative server - When the server should talk to the client and
wait for actions of the clients user it is
better to use a concurrent server - Iterative servers often use UDP connections while
concurrent servers use TCP connections
17Stateless vs. Stateful servers the problem of
reading a remote file by steps. File reading
requests arrive with dealy
Request open file XYZ
A CLIENT
A SERVER
?
Answer file XYZ exists and ready
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
18A stateless server means it does not remember
previous requests
Request read bytes 0 to 49 from file XYZ
A CLIENT
A SERVER
?
Answer the content of the bytes
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
19The client must provide all the information again
!
Request read bytes 50 to 99 from file XYZ
A CLIENT
A SERVER
?
Answer the content of the bytes
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
20This may cause a lot of network traffic,
especially if there are many clients
Request read bytes X to X50 from file XYZ
A CLIENT
A SERVER
?
Answer the content of the bytes
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
21Stateful Server it mantains some information
abut what clients did
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
Pointer File Position
0 XYZ 0
1 FILE ZXY 50
Request open file XYZ
A CLIENT
A SERVER
?
Answer file pointer to file XYZ
22The information the client has to pass to the
server is much smaller
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
Pointer File Position
0 XYZ 50
1 FILE ZXY 50
Request 0, read 50
A CLIENT
A SERVER
?
Answer the content
23The information at the server should be updated
with every request
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
Pointer File Position
0 XYZ 100
1 FILE ZXY 50
Request 0, read 50
A CLIENT
A SERVER
?
Answer the content
24It is important to close the file !!!
Open file XYZ read first 50 bytes while (not end
of file XYZ) read next 50 bytes close file
Pointer File Position
0 XYZ 100
1 FILE ZXY 50
Request 0, read 50
A CLIENT
A SERVER
?
Answer the content
25Problems with stateful servers
- They are more efficient but they are more
sensitive to errors, especially with UDP
connections - What if a request does not arrive to the server?
- What if the client collapses without telling it?
26New products between the application and
transport layer make distributed programming much
easier
Libraries for distributed programming (middleware)
RPC, CORBA, RMI
27RPC remote procedure call
Remote process
1. Obtain reference 2. Call procedure Receive
results as the procedure were in the calling
computer
28RMI in JAVA (similar to CORBA)
server
Other applications use and share this object
(data)
Creates and publishes a Remote Object
29Problems to solve
- How does the client which are the name of the
procedures that can be invoked (interface file) - How can a client know where to find a remote
object? (server) - How is communication implemented? (http
protocols) - What do I gain? (protocols!)
30Programming and running a RMI
Client prog.
Implementation
The RMI-Registry server
RMI
Interface
Interface
Interface
Server prog.