Distributed Systems Message Passing: Prof. Aniruddha S Rumale Assistant Professor, Comp. Engg. Dept
Distributed Systems Message Passing: Prof. Aniruddha S Rumale Assistant Professor, Comp. Engg. Dept
Message Passing
Prof. Aniruddha S Rumale
Assistant Professor, Comp. Engg. Dept.
Introduction
•Process means program in execution.
•Two comps in DS are communicating
means two processes communicating with
each other.
•Process communication is necessary to
achieve some common goal.
•DS needs to provide InterProcess
Communication ( IPC)
IPC
IPC requires information sharing among two or more
processes.
1) Original sharing or shared data approach
information to be shared is stored in common
memory area
2. Uniform Semantics
semantics of remote communications( communicating
processes are on different nodes) should be as close
as possible to local communications( communicating
processes are on same node).
Features of Message-passing system …continue
3.Efficiency
an IPC protocol of a message-passing system can be
made efficient by reducing the number of message
exchanges, as far as practicable, during the
communication process.
Avoiding the cost of establishing and terminating
connections between same pair of processes each
and every message exchange between them.
Minimizing the cost of maintaining the connections.
Piggybacking the acknowledgement of previous
messages with the next message during a connection involving
several message exchanges between sender and
receiver.
Features of Message-passing system …continue
4. Reliabilty
DS is prone to catastrophic events.( node crash,
communication link (s) failures etc…)
A reliable IPC protocol can cope with failure problems
and guarantees the delivery of message.
Handling of lost messages involves ACKs and
retransmissions on the basis of timeout.
Duplicate messages may be sent in the event of
failures or timeouts. A reliable IPC protocol must be
capable of detecting and handling of duplicates. It
involves generating and assigning sequence numbers
to messages.
Features of Message-passing system …continue
5.Correctness
Correctness is a feature related to IPC protocols for
group communication.
Atomicity : message sent to a group of receivers will
be delivered to either all of them or none of them.
Ordered Delivery: messages arrive at all receivers in
order acceptable to an application.
Survivability: guarantees that messages will be
delivered correctly despite partial failures of
processes, machines, or communication links.
Features of Message-passing system …continue
6.Flexibilty
Not all applications require the same degree of
correctness and reliability of IPC protocols. Thus , the IPC
protocol of message passing system must be flexible
enough to cater to the various needs of different
applications.
IPC primitives must also have the flexibility to permit
any kind of control flow between the cooperating
processes, including synchronous and asynchronous
send/receive.
Features of Message-passing system …continue
7. Security
A good message-passing system must be capable of
providing a secure end-to-end communication.
A message in transit on the network should not be
accessible to any user other than those to whom it is
addressed and the sender. This involves
a) authentication of receiver(s) of a message by sender
b) authentication of sender of message by receiver(s)
c) encryption of message before sending it over N/W.
Features of Message-passing system …continue
8. Portability
the message-passing system should itself be
portable.
the applications written by using the primitives of IPC
protocols of message-passing system should be
portable.
Issues in IPC by message-passing
Message is a block of information formatted by a
sending process in such a manner that it is
meaningful to the receiving process.
2. Flow-controlled communication :
sender is blocked until the receiver accepts some messages.
introduces synchronization : may results in deadlocks
Communication based on Finite bound buffer implementation is more
complex to implement and use than null buffer or single message
buffer.
Multidatagram messages
All N/W has upper bound on data to be transmitted at a time,
known as Maximum Transfer Unit (MTU).
If sizeof ( message) > MTU
: fragmentMTU( sizeof (eachfragment)<=MTU)
: number each fragment serially
: if each fragment numbered
: send them in packets ( datagram)
Packet = control information + message data.
If MTU> message data to be send : single-datagram
message, else multidatagram messages.
Multidatagram messages… continued
At receiver side check packets for sequence number
If packet is numbered store it in buffer
Receive all packets with sequence numbers based on
common control information.
report any error to sender for retransmission of
missing packet
arrange packets in order
accepts packets in order
reassemble packets to form complete message
acknowledge the sender
Encoding and Decoding
A message data should be meaningful to the receiving process.
This needs preservation of program objects while transmission from
senders address space to receivers address space.
It is not easy to achieve this on homogeneous systems and it is
impossible to achieve this on heterogeneous systems.
An absolute pointer value loses its meaning when transferred from
one process address space to another.
Different program objects occupy varying amount of storage space.
And to make a message meaningful to the receiver, there must be
some way receiver to identify which program object is stored where
in the message buffer and how much space each program object
occupies.
Encoding and Decoding…continued
Due to problems in transferring program objects in their
original form, they get converted to a more suitable stream
form for transmission.
Conversion process from original to stream form taking place
at sender side is known as encoding.
Conversion of stream form of program objects in to their
original form at receiver side prior to their use is known as
Decoding.
There are two types of representation used for encoding and
decoding. Tagged and untagged representation.
Encoding and Decoding…continued
Tagged representation :
type of each program object along with its value is encoded in the
message.
Receiving process checks the type of each program object in
message due to self-describing nature of coded data.
More expensive than untagged representation.
Untagged representation :
message data only contains program objects. No information about
type of any program object is given.
Receiver must have prior knowledge to decode the received data as
coded data format is not self-describing.
Process Addressing
Addressing ( Naming ) of parties involved in communication is
an important issue in message based communication.
Explicit addressing :
the process with which communication is desired is explicitly
named as a parameter in the communication primitive used.
Eg . Send ( process_id, message)
Receive( process_id, message)
In above we are sending/receiving message to/from a process
identified using process_id
Process Addressing…continued
Implicit Addressing :
a process willing to communicate does not explicitly name a
process for communication in communication primitive used.
Useful in client server communication when client is concerned
with service and not the server from set of server-farm, who is
going to serve its purpose.
This is also known as functional addressing as address used is
of service and not of process.
Eg. Send_any( service_id, message) send message to
any process which can provide the service identified by service_id.
Receive_any(process_id, message) Receive message
from any process and return the process_id on reception of message.
Failure handling
DS is prone to following failures.
sender Receiver
sender Receiver sender Receiver
Send message Send Send message
message received
request request request
message
lost Crash
Send
lost response
Request message is
Lost either because
restarted
Of link failure or
Because receiver Response loss either due Receiver’s node
Node may be down To down sender node or Crashed before
At time of request Failed link of Receiving request
For communication comunication For communication
Failure handling…continued Client Server
To cope with these problems, IPC protocols are
designed based on the idea of internal Request
retransmissions of messages after time-outs.
And prompt return of ACK messages from
receiver.
ACK
Four-message IPC protocol for client-server:
1. Client sends request message to server. Reply
2. On reception of request server sends ACK to
client.
ACK
3. On processing of client’s request server sends
Reply containing results of processing to client. Blocked state
4. On reception of reply client sends ACK to server Executing state
Failure handling…continued Client Server
Three message reliable IPC
protocol for client server : Request
1. Client sends a request message
to server
2. On reception server processes
the request and prepares a reply
and sends it to client; meanwhile Reply
client remain blocked.
3. On reception of reply from server
client resumes its execution and ACK
sends a ACK to server. Server
remain blocked until the ACK Blocked state
from client. Executing state
Failure handling…continued Client Server
Two message IPC protocol for
client server communication : Request
1. Client sends a request message
to server and enters in block
state for time=time-out.
2. On reception of request from
client server processes it and Reply
prepares a reply and sends it to
client.
3. Servers kernel waits for ACK
from clients kernel for time=time-
out; In absence server Blocked state
retransmits the reply to client. Executing state
Failure handling…continued Unsuccessful
client server Request
Request message execution
Send request
Time-out lost
Send request Successful
Retransmit request message request
Time-out
Executions
Send request crash May produce
Retransmit request message Different results
Time-out
lost Send response
ACK
Send request
Retransmit request message
selective repeat :
After time-out, if all packets are not received, Bitmap ids of non-
received packets are communicated with the sender.
On receiving this information sender sends only those packets that
have not been received by receiver.
The process get repeated until transmission of multidatagram
message won’t get completed. i.e. when all packets of message get
received by receiver this retransmission of select packets stops.
Sender of multidatagram Message
Receiver of multidatagram Message
that consists of Five packets
Send request message Buffer
(M1,5,P1)
lost Time-out For 5