0% found this document useful (0 votes)
23 views29 pages

Interprocess Communicatio N

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
23 views29 pages

Interprocess Communicatio N

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 29

InterProcess

Communicatio
n
OUTLINE

⚫Introduction
⚫APIs for Internet Protocols

⚫ Concerned with the characteristics of protocols for


communication between processes in a distributed
system – that is, interprocess communication.
IPC - Introduction
• Interprocess Communication, commonly referred to as IPC, is a
fundamental concept in distributed computing systems

• IPC refers to the exchange of data or messages between


multiple processes running concurrently within a system.

• These processes might be running on different devices, but


they need to communicate and coordinate with one another
for the entire system to function effectively.
IPC - Introduction
• IPC techniques are divided into methods for message passing, synchronization,
shared memory, and remote procedure calls (RPC).
• The operating systems provide facilities/resources for inter-process
communications (IPC), such as message queues, semaphores, and shared
memory.

Message passing
takes several forms
such as: pipes,
FIFO, Shared
Memory, and
Message Queues.
IPC - Introduction
• The method of IPC used may vary based on the bandwidth
and latency of communication between the threads, data
type
• Distributed computing systems make use of these
facilities/resources to provide application programming
interface (API) which allows IPC to be programmed at a
higher level of abstraction. (e.g., send and receive)
Main IPC Methods
Method Provided by (Operating systems or other environments)

File Most operating systems.

Most operating systems; some systems, such as Windows, only


Signal implement signals in the C run-time library and do not actually
provide support for their use as an IPC technique.

Socket Most operating systems


Message queue Most operating systems
Pipe All POSIX systems, Windows
Named pipe All POSIX systems, Windows
Semaphore All POSIX systems, Windows
Shared memory All POSIX systems, Windows
Message passing
Used in MPI paradigm, Java RMI, CORBA, MSMQ and others.
(shared nothing)

All POSIX systems, Windows. This technique may carry race condition
memory-mapped file
risk if a temporary file is used.
Introduction
Shared Memory
In a Non-Distributed
System:
Two approaches to
communication:
⚫ Shared memory
◦ Information placed in a
common memory area Message Passing
⚫ Message passing
◦ Generally makes use of
IPC mechanisms made
available by the
underlying OS
◦ Ex : Pipes, Sockets
Introduction
Communication In a Distributed System
⚫ Message Passing
⚫ Only mechanism available for the passing of messages is
network communication
◦ Message passing involves the sending process creating
and enqueuing a message to be delivered to the
receiving process.
◦ The receiving process then dequeues and handles the
message accordingly.
⚫ Send() and receive() operations

To communicate, one process sends a


message (a sequence of bytes) to a
destination and another process at the
destination receives the message.
Issues
Communication In a Distributed System
⚫ Message Passing
⚫ Send() and receive() operations
◦ Synchronization
●refers to how multiple processes ensure they are
working together towards a common goal.
◦ Introduces latencies
◦ Introduces higher chances of failure
●Failure handling -involve multiple interconnected
components – should not cause cascading failures
throughout the entire system.
◦ Heterogeneity introduces possible incompatibilities
Issues/Challenges
Characteristics of IPC
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.
Characteristics of IPC

🞆 Message Passing Primitives: Send, Receive


🞆 Message = <Destination, Content>

🞆 Destination = <Network address, Port>


⚫ Port = destination within a host that identifies a
receiving process, specified as an integer
⚫ Processes are uniquely identified by their port number
⚫ Hosts are uniquely identified
⚫ Any process that knows the number of a port can send
a message to it.
⚫ Servers generally publicize their port numbers for use
by clients
Standard Ports
Port Numbers A service or port number is used to
distinguish between services on a
FTP Data 20 machine. It is an entry or exit point
FTP Control 21 After IP passes incoming data to the
SSH 22 transport protocol, the transport
protocol passes the data to the correct
Telnet 23 application process. (It requires a port
SMTP 25 number to be assigned to each message
Domain Name Server 42 while sending)
Application processes (also called
Whois 43
network services) are identified by port
HTTP 80 numbers, which are 16-bit values.
POP3 110 Sending Process : Source port number,
RPC(Sun RPC) 111 Receiving Process : Destination port
number
BGP 179 Port No : Contained in the first header
word of each
TCP segment and UDP packet
Standard Ports
These ports are merely reference numbers used to define a service
There is a group called the IANA (Internet Assigned Numbers Authority) that controls
the assigning of ports for specific services.
There are some ports that are assigned, some reserved and many unassigned which
may be utilized by application programs. Port numbers are straight unsigned integer
values which range up to a value of 65535.
Port Range Groups
0 to 1023 - Well known port numbers. Only special companies like Apple QuickTime,
MSN, SQL Services, Gopher Services and other prominent services have these port
numbers.
1024 to 49151 - Registered ports; meaning they can be registered to specific
protocols by software corporations.
49152 to 65536 - Dynamic or private ports; meaning that they can be used for
applications.
Communication Modes

There are two main types of message passing in distributed


systems, namely synchronous and asynchronous

Synchronous (blocking) communication


Asynchronous (non-blocking ) communication
Communication Modes
Synchronous (blocking) 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.
⚫ The sending and receiving processes synchronize at every message.
⚫ The sender of a message blocks until the message has been received by the
intended recipient.
⚫ Stronger version - sender often blocks until the receiver has processed the
message and the sender has received a reply.
⚫ Client-Server generally uses synchronous communication
Communication Modes
Asynchronous
⚫Use of the send operation is nonblocking - 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.
⚫Non-blocking communication appears to be more efficient, but
it involves extra complexity in the receiving process associated
with the need to acquire the incoming message out of its flow of
control.
Communication Modes
Communication Modes
Multidatagram Messages
Upper bound on the size of data that can be transmitted at a
time – known as maximum transfer unit (MTU) of a network

Single Datagram Message : Message < MTU – sent in a single


packet (called datagram)
Multi Datagram Message : Message > MTU – split into
fragments – each fragment is sent in a packet with some
control information
Sockets
⚫ A socket is one of the most fundamental technologies of
computer networking. Sockets allow applications to
communicate using standard mechanisms built into
network hardware and operating systems.
⚫ Socket technology actually has been employed for roughly
two decades.
⚫ Many of today's most popular software packages --
including Web browsers, instant messaging applications
and peer to peer file sharing systems -- rely on sockets.
Sockets
⚫ Socket (Addressable point)—The complete designation of a
TCP/IP node consisting of a IP address and port number
⚫ Each communication circuit into and out of the TCP layer is
uniquely identified by a combination of two numbers, which
together are called a socket.
⚫ The socket is composed of the IP address of the machine
and the port number used by the TCP software.
⚫ Both the sending and receiving machines have sockets.
⚫ Because the IP address is unique across the internetwork,
and the port numbers are unique to the individual machine,
the socket numbers are also unique across the entire
internetwork – enabling a process to talk to another process
across the network, based entirely on the socket number
⚫ Each computer has 216 possible port numbers
Sockets Each socket is associated with a
particular protocol – either UDP
or TCP
⚫ Characteristics
◦ Endpoint for inter-process communication
◦ Message transmission between sockets
◦ A socket is associated with either UDP or TCP
◦ Sockets are bound to ports
◦ One process can use many ports
◦ Processes don’t share sockets
IPC consists of transmitting a

Sockets and Ports message between a socket in


one process and a socket in
another process.

any port agreed port


socket
socket
message
client server
other ports
Internet address = 138.37.94.248 Internet address = 138.37.88.249

One popular abstraction for transport layer


connectivity: sockets
Developed at Berkeley
Socket = Internet address + port number
Only one receiver but many senders per port
Transport-layer protocols over
IP
⚫ IP sends packets between machine
◦ No mechanism for identifying sending or receiving application
⚫ Transport layer uses a port number to identify the application
⚫ TCP – Transmission Control Protocol
◦ connection-oriented service
◦ Send acknowledgement for each received packet
◦ Checksum to validate data
◦ Data may be transmitted simultaneously in both directions
Transport-layer protocols over
IP
⚫ UDP – User Datagram Protocol
◦ Datagram service (connectionless)
◦ Data may be lost
◦ Data may arrive out of sequence
◦ Checksum for data but no retransmission
◦ Bad packets dropped
Berkeley Sockets
The Berkeley sockets application programming interface (API) comprises a
library for developing applications in the C programming language that
perform inter-process communication

This interface implementation is implicit for TCP/IP, and it is therefore one


of the fundamental technologies underlying the Internet

Since Berkeley sockets were largely the first socket implementation and
most programmers are familiar with them, a large number of systems use
Berkeley sockets as their primary network API
Sockets
A non-exhaustive list includes:
•FreeBSD, NetBSD, OpenBSD
•Linux based systems
•Microsoft Windows sockets "Winsock"
•Java Sockets follow the same model, with java.net.Socket
•Python sockets
•Perl sockets
•Most other networked operating systems
Berkeley Sockets API Functions
• socket() creates a new socket of a certain socket type, identified by an integer
number, and allocates system resources to it.
• bind() is typically used on the server side, and associates a socket with a socket
address structure, i.e. a specified local port number and IP address.
• listen() is used on the server side, and causes a bound TCP socket to enter
listening state.
• connect() is used on the client side, and assigns a free local port number to a
socket. In case of a TCP socket, it causes an attempt to establish a new TCP
connection.
• accept() is used on the server side. It accepts a received incoming attempt to
create a new TCP connection from the remote client, and creates a new socket
associated with the socket address pair of this connection.
• send() and recv(), or write() and read(), or sendto() and recvfrom(), are used for
sending and receiving data to/from a remote socket.
Berkeley Sockets API Functions
• close() causes the system to release resources allocated to a socket. In case of
TCP, the connection is terminated.
• gethostbyname() and gethostbyaddr() are used to resolve host names and
addresses.
• select() is used to prune a provided list of sockets for those that are ready to
read, ready to write, or that have errors.
• poll() is used to check on the state of a socket in a set of sockets. The set can
be tested to see if any socket can be written to, read from or if an error
occurred.
• getsockopt() is used to retrieve the current value of a particular socket option
for the specified socket.
• setsockopt() is used to set a particular socket option for the specified socket.

You might also like