0% found this document useful (0 votes)
20 views26 pages

Inter Process Communication-1

Uploaded by

Rishabh Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views26 pages

Inter Process Communication-1

Uploaded by

Rishabh Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Inter processes

Communication
• Interprocess Communication is a process of exchanging the data
between two or more independent process in a distributed environment
is called as Interprocess communication.
• Interprocess communication on the internet provides both Datagram and
stream communication.
• Examples Of Interprocess Communication:
1.N number of applications can communicate with the X server through
network protocols.
2.Servers like Apache spawn child processes to handle requests.
3.Pipes are a form of IPC
• It has two functions:
1.Synchronization:
Exchange of data is done synchronously which means it has a single
clock pulse.
2.Message Passing:
When processes wish to exchange information. Message passing takes
several forms such as: pipes, FIFO, Shared Memory, and Message
Queues.
• Characteristics Of Inter-process Communication:
There are mainly five characteristics of inter-process communication in a
distributed environment/system.
1.Synchronous System Calls:
In the synchronous system calls both sender and receiver use blocking system
calls to transmit the data which means the sender will wait until the
acknowledgment is received from the receiver and receiver waits until the
message arrives.
2.Asynchronous System Calls:
In the asynchronous system calls, both sender and receiver use non-blocking
system calls to transmit the data which means the sender doesn’t wait from
the receiver acknowledgment.
1.Message Destination:
A local port is a message destination within a computer, specified as
an integer. Aport has exactly one receiver but many senders. Processes
may use multiple ports from which to receive messages. Any process
that knows the number of a port can send the message to it.
2.Reliability:
It is defined as validity and integrity.
3.Integrity:
Messages must arrive without corruption and duplication to the
destination.
1.Validity:
Point to point message services are defined as reliable, If the messages
are guaranteed to be delivered without being lost is called validity.
2.Ordering:
It is the process of delivering messages to the receiver in a particular
order. Some applications require messages to be delivered in the
sender order i.e the order in which they were transmitted by the
sender.
The API for the Internet protocols
Characteristics of inter process
communication:
• Message passing between a pair of processes can be supported by
two message communication operations, send and receive, defined in
terms of destinations and messages.
• To communicate, one process sends a message (a sequence of bytes)
to a destination and another process at the destination receives the
message.
• This activity involves the communication of data from the sending
process to the receiving process and may involve the synchronization
of the two processes
Synchronous and asynchronous
communication
• A queue is associated with each message destination.
• Sending processes cause messages to be added to remote queues and
receiving processes remove messages from local queues.
• Communication between the sending and receiving processes may be
either synchronous or asynchronous.
• In the synchronous form of communication, the sending and receiving
processes synchronize at each message.
• In this case, both send and receive are blocking operations. Whenever a
send is issued the sending process (or thread) is blocked until the
corresponding receive is issued. Whenever a receive is issued by a process
(or thread), it blocks until a message arrives.
• In the asynchronous form of communication, the use of the send
operation is nonblocking in that the sending process is allowed to
proceed as soon as the message has been copied to a local buffer, and
the transmission of the message proceeds in parallel with the sending
process.
• The receive operation can have blocking and non-blocking variants.
• In the non-blocking variant, the receiving process proceeds with its
program after issuing a receive operation, which provides a buffer to be
filled in the background, but it must separately receive notification that
its buffer has been filled, by polling or interrupt.
• Message destinations
• A local port is a message destination within a computer, specified as an
integer.
• A port has an exactly one receiver but can have many senders.
Reliability
• A reliable communication is defined in terms of validity and integrity.
• A point-to-point message service is described as reliable if messages
are guaranteed to be delivered despite a reasonable number of
packets being dropped or lost.
• For integrity, messages must arrive uncorrupted and without
duplication.
Sockets
• Both forms of communication (UDP and TCP) use the socket
abstraction, which provides an endpoint for communication between
processes.
• Sockets originate from BSD UNIX but are also present in most other
versions of UNIX, including Linux as well as Windows and the
Macintosh OS.
• Interprocess communication consists of transmitting a message
between a socket in one process and a socket in another process, as
illustrated in Figure
• For a process to receive messages, its socket must be bound to a local
port and one of the Internet addresses of the computer on which it
runs.
• Messages sent to a particular Internet address and port number can
be received only by a process whose socket is associated with that
Internet address and port number.
• Processes may use the same socket for sending and receiving
messages.
• Each computer has a large number (216) of possible port numbers for
use by local processes for receiving messages.
• Any process may make use of multiple ports to receive messages, but
a process cannot share ports with other processes on the same
computer.
• Each socket is associated with a particular protocol – either UDP or
TCP
• UDP datagram communication
• Interaction b/w UDP client and
server
• Datagram sent by UDP is transmitted from a sending process to a
receiving process without acknowledgement or retries.
• If a failure occurs, the message may not arrive.
• A datagram is transmitted between processes when one process
sends it and another receives it.
• To send or receive messages a process must first create a socket
bound to an Internet address of the local host and a local port.
• A server will bind its socket to a server port – one that it makes
known to clients so that they can send messages to it.
• A client binds its socket to any free local port.
• The receive method returns the Internet address and port of the
sender, in addition to the message, allowing the recipient to send a
reply.
• Message size: The receiving process needs to specify an array of bytes
of a particular size in which to receive a message.
• If the message is too big for the array ,it is truncated on arrival.
• The underlying IP protocol allows packet lengths of upto216 bytes,
which includes the headers as well as the message.
• Blocking:
• Sockets normally provide non-blocking sends and blocking receives
for datagram communication.
• The send operation returns when it has handed the message to the
underlying UDP and IP protocols ,which are responsible for
transmitting it to its destination
• On arrival ,the message is placed in a queue for the socket that is
bound to the destination port.
• The method receive blocks until a datagram is received, unless a
timeout has been set on the socket.
• If the process that invokes the receive method has other work to do
while waiting for the message ,it should arrange to use a separate
thread
• Timeouts:
• But in some programs, it is not appropriate that a process that has
invoked a receive operation should wait indefinitely in situations
where the sending process may have crashed or the expected
message may have been lost.
• To allow for such requirements, timeouts can be set on sockets.
• Choosing an appropriate timeout interval is difficult, but it should be
fairly large in comparison with the time required to transmit a
message.
• Receive from any: The receive method does not specify an origin for
messages.
• Instead ,an invocation of receive gets a message addressed to its
socket from any origin.
• The receive method returns the Internet address and local port of the
sender, allowing the recipient to check where the message came
from.
• Failure model for UDP datagrams: Reliable communication in terms of
two properties: integrity and validity. The integrity property requires
that messages should not be corrupted or duplicated.
• The use of a checksum ensures that there is a negligible probability
that any message received is corrupted
UDP datagrams suffer from the following failures:
• Omission failures: Messages may be dropped occasionally, either
because of a checksum error or because no buffer space is available
at the source or destination. To simplify the discussion, we regard
send-omission and receive-omission failures as omission failures in
the communication channel.
• Ordering: Messages can sometimes be delivered out of sender order.
Applications using UDP datagrams are left to provide their own checks
to achieve the quality of reliable communication they require. A
reliable delivery service may be constructed from one that suffers
from omission failures by the use of acknowledgements.
• Use of UDP
• For some applications, it is acceptable to use a service that is liable to
occasional omission failures. For example, the Domain Name System,
which looks up DNS names in the Internet, is implemented over UDP.
Voice over IP (VOIP) also runs over UDP. UDP datagrams are
sometimes an attractive choice because they do not suffer from the
overheads associated with guaranteed message delivery. There are
three main sources of overhead:
• The need to store state information at the source and destination;
• The transmission of extra messages;
• Latency for the sender.
TCP stream communication
• The API to the TCP protocol, which originates from BSD 4.x UNIX, provides
the abstraction of a stream of bytes to which data may be written and from
which data may be read.
• The following characteristics of the network are hidden by the stream
abstraction
• Message sizes:
• The application can choose how much data it writes to a stream or reads
from it. It may deal in very small or very large sets of data.
• The underlying implementation of a TCP stream decides how much data to
collect before transmitting it as one or more IP packets.
• On arrival, the data is handed to the application as requested.
• Applications can, if necessary, force data to be sent immediately.
Lost messages:
• The TCP protocol uses an acknowledgement scheme.
• As an example of a simple scheme (which is not used in TCP), the sending
end keeps a record of each IP packet sent and the receiving end
acknowledges all the arrivals.
• If the sender does not receive an acknowledgement within a timeout, it
retransmits the message. The more sophisticated sliding window scheme
[Comer 2006] cuts down on the number of acknowledgement messages
required
• Flow control:
• The TCP protocol attempts to match the speeds of the processes that read
from and write to a stream. If the writer is too fast for the reader, then it
is blocked until the reader has consumed sufficient data
• Message duplication and ordering:
• Message identifiers are associated with each IP packet, which enables
the recipient to detect and reject duplicates, or to reorder messages
that do not arrive in sender order.
• Message destinations:
• A pair of communicating processes establish a connection before they
can communicate over a stream.
• Once a connection is established, the processes simply read from and
write to the stream without needing to use Internet addresses and
ports.
• Establishing a connection involves a connect request from client to
server followed by an accept request from server to client before any
communication can take place.
Failure model
• To satisfy the integrity property of reliable communication, TCP streams use
checksums to detect and reject corrupt packets and sequence numbers to detect and
reject duplicate packets.
• For the sake of the validity property, TCP streams use timeouts and retransmissions to
deal with lost packets.
• Therefore, messages are guaranteed to be delivered even when some of the
underlying packets are lost.
• But if the packet loss over a connection passes some limit or the network connecting a
pair of communicating processes is severed or becomes severely congested, the TCP
software responsible for sending messages will receive no acknowledgements and
after a time will declare the connection to be broken. Thus TCP does not provide
reliable communication, because it does not guarantee to deliver messages in the face
of all possible difficulties.
• Use of TCP
• Many frequently used services run over TCP connections, with
reserved port numbers. These include the following:
• HTTP: The Hypertext Transfer Protocol is used for communication
between web browsers and web servers;
• FTP: The File Transfer Protocol allows directories on a remote
computer to be browsed and files to be transferred from one
computer to another over a connection. Telnet: Telnet provides
access by means of a terminal session to a remote computer. SMTP:
The Simple Mail Transfer Protocol is used to send mail between
computers.
JavaAPIforTCPstreams•TheJavainterfacetoTCPstreamsisprovidedinthe
classesServerSocketandSocket:

You might also like