Inter Process Communication
Inter Process Communication
Communication
Process is program in execution.
Communicate to achieve common goal.
IPC requires information sharing.
P1 Shared P2
memory
P1 P2
Desirable Features of a Good MPS
Simple
Clean & simple semantics of the IPC protocols to avoid worry
about system or network aspects
Uniform Semantics
Local communication: communicating process are on the same
node.
Remote communication: communicating processes are on different
nodes.
Efficiency
Aim to reduce no. of messages exchanged by
• Avoiding cost of establishing and terminating connections
between same pair of processes.
• Minimize cost of maintaining connections.
• Piggybacking of ack of previous msgs with next msgs during
a connection between sender and receiver involving several
msg exchange.
Reliability
Cope with failure problems & guaranteed delivery of messages.
Also detect and handle duplicate messages.
Correctness
• Handle group communication : allow sender
to send a message to a group of receivers and
receiver to receive messages from several
senders.
• Atomicity: deliver message either to all or
none.
• Ordered Delivery: arrival of messages in
an order acceptable to the applications
• Survivability: guaranteed delivery of
messages inspite of partial failures.
Flexibility
• Users have flexibility to choose & specify
type & level of reliability & correctness
requirement
Security
Secure end to end communication. i.e. message in
transit on the network should not be accessible to any
user other than those to whom it is addresses and the
sender. Steps required to secure the communications:
• Authentication of receiver of a message by the
sender.
• Authentication of the sender of a message by its
receiver.
• Encryption of a message before sending it to the
network.
Portability
• Message passing system : possible to construct new
IPC facility on another system by reusing the basic
design of existing message passing system.
• Applications using it should be portable. i.e.
heterogeneity of the network must be considered
while designing message passing system.
Issues in IPC by Message Passing
Message Structure
It consists of : fixed length header, variable size collection of typed
data objects.
Header usually consists of :
Address: contains characters that uniquely identify sending and
receiving process address in the network.
Sequence number: message identifier(ID) useful for identifying lost
messages and duplicate messages in case of system failures.
Structural information: a. type part specifies whether the data to be
passed onto the receiver is included within the message or only
contains pointer to the data. b. second part specifies length of
variable- size message data.
Send(msg); Receive(msg);
Execution
resumed
Blocked state
Execution state
Synchronous vs. Asynchronous
Communication
Synchronous Communication
– Advantages
• Simple & easy to implement
• Reliable
– Disadvantages
• Limits concurrency
• Can lead to communication deadlock
• Less flexible as compared to asynchronous
• Hardware is more expensive
Asynchronous Communication
– Advantages
• Doesn't require synchronization of both
communication sides
• Cheap, timing is not as critical as for synchronous
transmission, therefore hardware can be made
cheaper
• Set-up is very fast, well suited for applications
where messages are generated at irregular
intervals
• Allows more parallelism
– Disadvantages
• Large relative overhead, a high proportion of the
transmitted bits are uniquely for control purposes
and thus carry no useful information
• Not very reliable
Buffering
Sending Receiving
process Message process
Node
boundary
Unbounded Capacity Buffer
Practically impossible
Finite Bound Buffer/ multiple -
message
Used in asynchronous communication.
Receiving
Msg 1 process
Sending
process
Msg 2
Msg 3
Message
Msg n
Untagged representation
– Message data contains only program objects.
– Receiving process should have prior knowledge
on how to decode data as it is not self-
describing.
Process Addressing
Name/ address process in IPC.
Explicit addressing
• Send (process_id , msg)
• Receive (process_id , msg)
Sender Receiver
Send request
Lost
Loss of response msg
Sender Receiver
Request message
Send request
Successful request
execution
Response message
Send response
Lost
Unsuccessful execution of the request
Sender Receiver
Request message
Send request
Unsuccessful request
execution
crash
Restarted
Four message reliable IPC protocol
client server
Request
Acknowledgment
Reply
Blocked state
Acknowledgment
Execution state
Three message reliable IPC protocol
client server
Request
Reply
Blocked state
Acknowledgment
Execution state
Two message reliable IPC protocol
client server
Request
Reply
Blocked state
Execution state
Fault Tolerant Communication
Client Server
Successful request
execution
Timeout Response msg
Lost
debit(amount)
if (balance ≥ amount)
{ balance = balance-amount;
return (“Success”, balance);}
else return (“Failure, balance);
end;
Client Server (balance = 1000)
Send
request
request Process debit routine
Debit(100) balance =1000-100=900
Send lost
request Retransmit request
Process debit routine
balance=900-100=800
Response
(success , 800)
EXACTLY- ONE SEMANTICS
Use a unique identifier for every request that the client makes
and to set up a reply cache in the kernel’s address space on
the server machine to cache replies.
Req-id Reply
Req -1 (success,900)
Client Server (balance=1000)
Send
request-1 Reply cache
Request-1
Retransmit request -1
Send
request-1 Debit (100) Check reply cache for request - 1
Match found
Open Group
– Any process can send message to group as a
whole. Group of replicated servers.
Closed Group
– Only members of a group can send message to
the group. Collection of processors doing
parallel processing.
Group Management
Distributed Approach
– Open group – outsider can send a message to
all group members announcing its presence
– Closed group also have to be open with respect
to joining
Group Addressing
Two-level naming scheme
– High level group name
• ASCII name independent of location of
processes in group
• Used by user applications
– Low level group name
• Multicast address / Broadcast address
• One to one communication (Unicast) to
implement group communication
– Low level name :- List of machine
identifiers of all machines belonging to a
group
– Packets sent = no. of machines in group
Atomic Multicast
– All - or - nothing property
– Required for all - reliable semantics
– Involves repeated retransmissions by sender
– What if sender/ receiver crashes or goes down?
– Include message identifier & field to indicate atomic
multicast
– Receiver also performs atomic multicast of message
Group Communication Primitives
send
send_group
– Simplifies design & implementation of group
communication
– Indicates whether to use name server or group
server
– Can include extra parameter to specify degree
of reliability or atomicity
Many to one Communication
S1 R1 R2 S2
m2
m1 Time
m2 m1
S1 R1 R2 S2
t1 t2
m1
Time
m2 m1
m2 t1 < t2
Consistent Ordering
All messages are delivered to all receiver process
in the same order.
This order may be different from the order in which
messages were sent.
S1 R1 R2 S2
t1 t2
m2
Time
m2
m1
m1 t1 < t2
Centralized Algorithm
– Kernels of sending machines send messages to a single
receiver (sequencer) that assigns a sequence no. to each
message then multicasts it.
Distributed algorithm
– Sender assigns temporary sequence no. larger than
previous sequence nos., & sends to group.
– Each member returns a proposed sequence no. Member
(i) calculates it as
max(Fmax,Pmax) + 1 +i/N
Fmax: Largest seq. no. of any message this member
received till yet
Pmax: Largest proposed seq. no. by this member
S1 R1 R2 R3 S2
m1
Time
m2
m1
m3
m2 m1
m3
Happened before relation satisfies following
conditions:
– If a & b are events in same process & a occurs
before b.
– If a is event of sending a message by one
process & b is event of receipt of same
message by another process.
– If a→b & b →c then a →c
CBCAST Protocol
Vector of Vector of Vector of Vector of
Process A Process B Process C Process D
3251 3251 2251 3241
Process A sends
new msg
4 2 5 1 Msg
Deliver
Delay
A[1]=C[1]+1 Delay
not satisfied A[3]<=D[3]
not satisfied
recv() send()
Process request Transfer message strings with
send/recv or read/write
send() recv()
Server Client
UDP/IP Socket Calls for
Connection
socket() create socket
blocks until
datagram socket()
received
from a client
request specify senders address
sendto()
and send datagram
Process request
reply
sendto() recvfrom()
Server Client