Docsity

Distributed Information Systems Lecture 5 - Inter-process Communication V1, Lecture notes of Computers and Information technologies

Partial preview of the text

Download Distributed Information Systems Lecture 5 - Inter-process Communication V1 and more Lecture notes Computers and Information technologies in PDF only on Docsity!

Inter-process

communication

Dr Simon Blake

Topics for this lecture

Inter-process communication

  • Characteristics of IPC– Synchronous and asynchronous communication– External data representation and marshalling

•^

CORBA’s Common Data Representation

-^

Java Object serialisation

Client-Server Communication

•^

Client-Server Communication

-^

Communication within services provided by a group of servers:

  • Group Communication– IP multicast

Significance of this lecture

• We have looked at networking• So now we turn our focus to higher level

software layers

• These layers are designed to facilitate

easy operation

• And to embody the ‘good’ design

characteristics of our DIS

Recall: The software layered

approach

The OSI model

Application Presentation

Session Transport Network

Data Physical

Application Presentation

Session Transport Network

Data Physical

The network A message,descendsthrough thelayers

Then ascendsthrough thelayers at thereceiver

A HOST – A COMPUTER

A HOST – A COMPUTER

Messaging basics

API (application programming interface)

  • In the context of this lecture this refers to an interface for

application programmers to use either UDP or TCP

Message passing has two fundamental operations

  • Send and Receive (Request and Reply)– i.e. one process sends the other receives– Simply requires both destinations and messages– May involve synchronisation

BUT…

  • How does this occur?

Synchronisation

Synchronisation

  • Synchronous (blocking)
    • Sender is ‘blocked’, i.e. is frozen during send until the receive

message is returned

  • Sender and receiver synchronise
    • Asynchronous (non-blocking)
      • Sender can carry on processing once the message is sent

(i.e. copied to some local buffer)

  • Current systems tend to be synchronous– Non-blocking adds complexity into software code

API & IP: process communication •^

Message destinations

  • Addressing

•^

The

address

uniquely identifies the hardware, perhaps a computer

(host on a node)

-^

A

local port

a destination on a computer

  • One or more messages can be send to port(s)– Processes can use one or more ports for receiving messages

Address + port

156.254.12.35:

API & IP: process communication •^

Other issues to consider during inter-process communication

Reliability

  • Reliable systems should not corrupt messages even if

packets are lost or dropped

Ordering

  • Messages be delivered in the order sent

Process communication & Sockets^ •

Sockets

  • An abstraction whereby process bind to a socket

which relates to a port

  • Assigns a specific local port to a process– Process talk to the socket – which relates to a port– Processes can only access message from ports

linked to their socket

  • Requests must be made to specific ports but could

originate for any or in some instances specific ports

Process communication

A computer, IP address = 138.37.543.

client

ports

server

ports^ A computer, IP address = 138.37.53.

Port: 1 Port: 671

Port: 1 Port: 771

Socket maps to a port

Socket maps to a port

UDP communication

More details

  • The

send

method is non-blocking (asynchronous)

•^

thus they are free once send has taken place

  • The

receive

method uses blocking (synchronous), although

other threads can be used to perform other work.

  • Receive blocking can use time-outs to limit the length of the

block.

•^

although defining ‘good’ values for timeouts is hard

  • Received messages are stored in the bound socket’s queue.– Receive inspects the bound socket for messages– Received messages could come from anywhere

UDP communication

  • Uses of UDP and the Datagram method
    • Useful where omission failures are tolerable
      • i.e. naming services
        • Useful in reducing communication overheads that exist in

guaranteed delivery methods

API & IP: UDP communication • In Java

•^

A

DatagramPacket

class contains:

  • i.e. In Java a DatagramPacket is constructed:

myPacket =

new

DatagramPacket(m,args[0].length(), aHost, serverPort);

Note: the DatagramPacket contains the host address (aHost) and the host port

(serverPort)

The message

Length of message

Internet address

Port

3432 543 4531

13

145.25.123.

589

API & IP: UDP communication • In Java

In Java a DatagramPacket is sent and received thus:

aSocket.send(myPacket);aSocket.recieve(myPacket); Note: aSocket is an instantiated instance of the Java DatagramSocket class.Interested readers are referred to the course text (pages 138 and 139) for

more detailed implementations of UDP client and servers