An Introduction to Internetworking. Algorithm for client-server communication with UDP...

30
An Introduction to Internetworking
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    221
  • download

    1

Transcript of An Introduction to Internetworking. Algorithm for client-server communication with UDP...

Page 1: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

An Introduction to Internetworking

Page 2: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Algorithm 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 thesender´s Address & Port and the reply message•Send message

• Build a UDP package with the request message, server´s address & port numbre• Create socket• Send package• Listen to answer•Receive package• Extract answer

Page 3: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Algorithm 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 APPLICATION’S PROTOCOLL

Page 4: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Every layer has the illusion to be talking to the correspondent one in the other

application

A SERVER

A CLIENT

A CLIENT

A CLIENT

4444

The UDP: User Defined Package: like writing a letterRead write sequence

UDP or TCP communication

Internet frames and addresses

electricpulses

Page 5: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Attending more than a client: The sequential server:

The problem

A SERVERA CLIENT

A CLIENT

A CLIENT

4444

?

Page 6: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

During the conversation the server is not listening at the port 444

A SERVERA CLIENT

A CLIENT

A CLIENT

4444

X

Page 7: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Only after the server is ready with the first client it can listen to the

port 4444 again

A SERVERA CLIENT

A CLIENT

A CLIENT

4444

?

Page 8: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

The service may be to transfer a file. The user at the client may have first

to type and send the filename

A SERVERA CLIENT

A CLIENT

A CLIENT

4444

X

Page 9: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

What if the server has to wait too much for a client to type in a file

name ? (or the file is too big)

A SERVERA CLIENT

A CLIENT

A CLIENT

4444

TimeoutX

Page 10: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Concurrent Servers: there are separate processes to attend the port

and to transfer the file

A SERVER

A CLIENT

A CLIENT

A CLIENT

4444

?

Page 11: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

After the client contacts the server, the server creates another process to attend the client and keeps listening to the port

4444 for another

A SERVER

A CLIENT

A CLIENT

A CLIENT

4444

This is a “slave”process or threadIt is executed paralell to the “master” process or thread

?

Page 12: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

While the new process is serving the first client, the second client can contact the

server at the port 4444

A SERVER

A CLIENT

A CLIENT

A CLIENT

4444

?

Page 13: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

And the server creates another process

A SERVER

A CLIENT

A CLIENT

A CLIENT

4444

?

Page 14: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Now the third client contacts the server

A SERVER

A CLIENT

A CLIENT

A CLIENT

4444

?

Page 15: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

And a third slave process or thread is created

A SERVER

A CLIENT

A CLIENT

A CLIENT

4444

?

Page 16: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

When 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 client´s user it is better to use a concurrent server

• Iterative servers often use UDP connections while concurrent servers use TCP connections

Page 17: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Stateless vs. Stateful servers: the problem of reading a remote file by steps. File reading requests arrive with dealy

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request open file XYZ

Answer file XYZ exists and ready

Page 18: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

A stateless server means it does not remember previous requests

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request read bytes 0 to 49 from file XYZ

Answer the content of the bytes

Page 19: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

The client must provide all the information again !

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request read bytes 50 to 99 from file XYZ

Answer the content of the bytes

Page 20: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

This may cause a lot of network traffic, especially if there are many

clients

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request read bytes X to X+50 from file XYZ

Answer the content of the bytes

Page 21: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Stateful Server: it mantains some information abut what clients did

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request open file XYZ

Answer: file pointer to file XYZ

Pointer File Position

0 XYZ 0

1 FILE ZXY 50

Page 22: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

The information the client has to pass to the server is much smaller

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request 0, read 50

Answer: the content

Pointer File Position

0 XYZ 50

1 FILE ZXY 50

Page 23: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

The information at the server should be updated with every request

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request 0, read 50

Answer: the content

Pointer File Position

0 XYZ 100

1 FILE ZXY 50

Page 24: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

It is important to close the file !!!

A SERVERA CLIENT

Open file XYZread first 50 byteswhile (not end of file XYZ)

read next 50 bytesclose file

?

Request 0, read 50

Answer: the content

Pointer File Position

0 XYZ 100

1 FILE ZXY 50

Page 25: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Problems 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?

Page 26: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

New products between the application and transport layer make distributed

programming much easier

Libraries for distributedprogramming (middleware)

RPC, CORBA, RMI

Page 27: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

RPC: remote procedure call

Remote process 1. Obtain reference2. Call procedure &Receive results as the procedure were in the calling computer

Page 28: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

RMI in JAVA (similar to CORBA)

Creates and publishesa Remote Object

Other applications use and share this object (data)

server

Page 29: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Problems 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!)

Page 30: An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.

Programming and running a RMI

Interface Interface

Implementation

RMIInterface

Server prog.

Client prog.

The RMI-Registry server