DC (U1)
DC (U1)
DC (U1)
UNIT I
Unit I Introduction: Characteristics, Examples, Applications, Challenges –System models:- Architectural
models and Fundamental models – Network principles and Internet protocols – Inter-process communication:
API, Marshalling ,Multicast communication, Client-server communication, Group communication.
• It enables the users, wherever they are, to make use of services such as World Wide Web, e-mail and file transfer.
IV YEAR VIIISEM Distributed Computing
• The services of internet can be extended by addition of server and new type of services.
• The above figure shows a collection of intranets. Intranets are subnetwork operated by companies and other
organizations.
• ISPs (Internet Service Providers) are companies that provide Connections to individual users and small organizations.
• The intranets are linked together by back bones.
• A back bone is a network link with a high transmission Capacity. It employs satellite connections, fiber optical cables
and other high band width cables.
• Multimedia services are available in the internet. This service enable the users to access audio and video data.
• As a second example, consider a work flow information system that supports the automatic processing of
orders.
• Typically, such a system is used by people from several departments, at different locations.
• For example, people from the sales department may be spread across a large region or an entire country.
Orders areplaced bymeans of laptop computers that are connected to the system through the telephone networks.
Incoming orders are automatically forwarded to the planning department.
The system will automatically forward orders to an appropriate and available person.
• As a final example, consider the world wide web. The web offers a simple, consistent, and uniform model of distributed
documents.
• To see a document, a user need merely activate a reference, and the document appears on the screen. Publishing a
document is also simple: you only have to give it a unique name in the form of uniform.
• Resource Locator that refers to a local file containing the document's content.
1.3. CHALLENGES
The key challenges faced by the designers of Distributed system are
Heterogeneity.
Openness.
Security.
Scalability.
Failure handling.
Concurrency.
The need for transparency.
1.3.1 Heterogeneity
• They must be constructed from a variety of different networks, operating systems, computer hardware and
programming languages.
• The internet Communication protocols mask the difference in networks, and middleware can deal with other
differences.
• The term Middleware applies to a software layer that provides a programming abstraction as well as masking the
heterogeneity of the underlying networks, hardware, operating systems and programming languages.
Example: Common Object Request Broker Architecture (CORBA).
1.3.2 Openness
• The openness of a computer system is the characteristic that determines whether the system can be extended and re-
implemented in various ways.
• The openness of distributed systems is determined primarily by the degree to which new resource sharing services can
be added and be made available for use by a variety of client programs.
IV YEAR VIIISEM Distributed Computing
• The first step to provide openness is to publish the interfaces of the components, but the integration of components
written by different programmers is a real challenge.
• Open systems are characterized by the fact that their key interfaces are published.
• Open distributed systems are based the provision of a uniform communication mechanism and published interfaces for
access to shared resources.
• Open systems can be constructed from heterogeneous hardware and software.
1.3.3 Security
Security for information resources has three components:
(i) Confidentiality
Protection against disclosure to unauthorized individuals.
(ii) Integrity
Protection against alteration or corruption.
(iii) Availability
Protection against interference with the means to access the resources.
• The challenge is to send sensitive information in a message over a network in a secure manner.
• But security is not just a matter of concealing the contents of messages, it also involves knowing for sure the identity of
the user.
• The second challenge is to identify a remote user.
• Both of these challenges can be met by the use of encryption techniques.
• Encryption can be used to provide adequate protection of shared resource and to keep sensitive information secret when
it is transmitted in messages over a network.
• Denial of service attacks are still a problem.
1.3.4 Scalability
• A distributed system is scalable if the cost of adding a user is a constant amount in terms of the resources that must be
added.
• In other words, a system is described as scalable if it will remain effective when there is significant increase in the
number of resources and the number of users.
• The design of scalable distributed system present the following challenges: Controlling the cost of physical
resources.
• As the demand for a resource grows, it should be possible to extend the system, at reasonable cost, to meet it.
Controlling the performance loss:
• Consider the management of a set of data whose size is proportional to the number of users or resources in
them.
• In this case, Algorithms that use hierarchic structures scale better than linear structures.
• But, even with hierarchic structures, an increase in size will result in some loss in performance.
Size
• When a system needs to scale, we must consider scaling with respect to size.
• If more users or resources need be supported, we are confronted the limitations of centralized services, data and
algorithms.
• For example, many services are centralized in the sense that they are implemented by means of only a single server
running on specific machine in the distributed system.
• The problem now is that the server become a bottleneck as the number of users grows.
• Even if we have virtually unlimited processing and storage capacity, communication with that server will prohibit
further growth.
IV YEAR VIIISEM Distributed Computing
Preventing software resources running out
• As an Example, the supply of available internet addresses is running out.
• There is no correct solution to this problem. It is difficult to predict the demand that will be put on a system years
ahead.
Avoiding performance bottle necks
• Algorithms should be decentralized to avoid having performance bottlenecks.
• Because, in a large distributed system, enormous number of messages have to be routed over many lines.
• The optimal way to do this is collect complete information about the load on all machines and lines, and then run a
graph theory algorithm to compute all the optional.
• The trouble is that collecting and transporting all the Input and output information would again be a bad idea
because these messages world overload part of the network.
1.3.5 Failure handling
• Failures fall into two obvious categories: hardware and software.
• If failure occurs, program may produce incorrect results on they may stop before they have completed and
intended computation.
• Failures in a distributed system are partial, i.e., some components fail while others continue to function.
Therefore, the handling of failures is particularly difficult.
• The techniques dealing with failures are listed below.
Detecting failures - Some failures can be detected. E.g. checksums can be used to detect corrupted data in a message
or a file
Masking failures - Some failures that have been detected can be hidden or made less severe. E.g. messages can be
retransmitted when they fail to arrive.
Tolerating failures - It is not possible to detect and hide all the failures that might occur in large network. Their
clients can be designed to tolerate failures, which generally involve the users tolerating them as well. Services can be
made to tolerate failures by the use of redundant components.
• Recovery from failures - Recovery involves the design of software so that the state of permanent data can be recovered
or rolled back after a server has crashed.
1.3.6 Concurrency
• Both services and applications provide resources that can be shared by clients in a distributed system.
• There is therefore a possibility that several clients will attempt to access a shared resource at the same time.
• The process that manages a shared resource could take one client request at a time. But that approach limits
throughput.
• Therefore, services and applications generally allow multiple client requests to be processed concurrently.
• For an object to be safe in concurrent environment, its operations must be synchronized in such a way that it s data
remains consistent.
• This can be achieved by standard techniques such as semaphores.
1.3.7 Transparency
• It is defined as the concealment from the user and the application programmer of the separation of components in a
distributed system.
• Hence, the system is perceived as a whole rather than as a collection of independent components.
• The main aim of the transparency is to make certain aspects of distribution invisible to the application programmers.
Access transparency enables local and remote resources to be accessed using identical operations.
Location transparency enables resources to be accessed without knowledge of their location.
IV YEAR VIIISEM Distributed Computing
Concurrency transparency enables several processes to operate concurrently using shared resources. The resources wil
not interfere among themselves.
Replication transparency enables multiple instances of resources to be used to increase reliability and performance
without knowledge of the replicas by users or application programmers.
Failure transparency enables the concealment of faults. It allows users and application programs to complete their tasks
even though they have the failure of hardware or software components.
Mobility transparency allows the movement of resources and clients within a system. The movement will not affect
the operation of users or programs.
Performance transparency allows the system to be reconfigured to improve performance as loads vary.
Scaling transparency allows the system and applications to expand in scale.However
it will not change to the system structure or the application algorithms.
• There are two important transparencies available. They are access and location transparency; their presence or absence
most strongly affects the utilization of distributed resources. They are referred together as network transparency.
1.4 ARCHITECTURAL MODELS
• An architectural model of a distributed system is concerned with placement of its parts and the relationships between
them.
• An architectural model defines the way in which the components of systems interact with one another and the way in
which they are mapped onto an underlying network of computers.
• The overall goal is to ensure that the structure will meet present and likely future demands on it.
• Major concerns are to make the system reliable, manageable, adaptable and cost effective.
• An architectural model first simplifies and abstracts the functions of the individual components of a
distributed system and then it considers :
oThe placement of the components across a network of computers, seeking to definite useful patterns
for the distribution of data and workload.
• This classification identifies the responsibilities of each and hence helps us to assess their workloads and to
determine the impact of failures in each of them.
1.4.1 Software layers
• The term 'software architecture'refers to the structuring of software as layers or modules in a single computer and in
terms of services offered and requested between processes located in the same or different computers.
• This process and service-oriented view can be expressed in terms of service layers.
Network Computers
The OS and application software for desktop computers typically require much of the active code and data to be
located on a local disk.
• But the management of application files and the maintenance of a local software base require considerable technical
effort of a nature that most users are not qualified to provide.
• The network computer is a response to this problem.
• It downloads its operating system and any application software needed by the user from a remote file server.
• Applications are run locally but the files are managed by a remote file server.
Since all the application data and code is stored by a file server, the users may migrate from one network computer to
another.
1.5 FUNDAMENTAL MODELS
• Fundamental models are concerned with a more formal description of the properties that are common in all of
the architectural models.
• All communication between processes is achieved by means of messages.
• Message communication over a computer network can be affected by delays. It may suffer from a variety of failures.
• It is vulnerable to security attacks. These issues are addressed by three models.
• The interaction modeldeals with performance and with the difficulty of setting time limits in a distributed system.
• The failure modelattempts to give a precise specification of the faults that can be exhibited by processes and
communication channels.
• The security modeldiscusses the possible threats to processes and communication channels. It introduces the concept
of a secure channel, which is secure against these threats.
1.5.1 Interaction model
• Interacting processes perform all activities in a distributed system.
• Each process has its own state, consisting of the set of data that it can access and update, including the variables in its
program.
• The state belonging to each process is completely private, i.e., it cannot be accessed or updated by any other process.
• Two significant factors affecting interacting processes in a distributed system are:
• Communication performance is often a limiting characteristic.
• It is impossible to maintain a single global notion of time.
Performance of communication Channels
Communication over a computer network has the following performance characteristics relating to latency, bandwidth
and jitter.
IV YEAR VIIISEM Distributed Computing
• Delay between the start of a message is transmission from one process and the beginning of its receipt by another is
referred to as latency, the latency includes:
o The delay in accessing the network.
o The time taken by the OS communication services which may vary according to the load
on the OS.
• Bandwidthis the total amount of information that can be transmitted in a given time. When a large number of
communication channels are using the same network, they have to share the available bandwidth.
• Jitter is the variation in the time taken to deliver a series of messages. Jitter is relevant to multimedia data. E.g., if
consecutive samples of audio data are played with different time intervals then the sound will be badly distorted.
Computer clocks and timing events
• Each computer in a distributed system has its own internal clock, which can be used by local processes to
obtain the value of the current time.
• Therefore, two processes running on different computers can associate timestamps with their events.
• However, even if two processes read their clocks at the same time, their local clocks may supply different time values.
• This is because computer clocks drift from perfect time and their drift rates differ from one another.
• The term clock drift raterefers to the relative amount that a computer clock differs from a perfect reference clock.
• Even if the clocks on all computers are set to the same time initially, their clock would eventually vary quite
significantly unless corrections are applied.
Two variants of the interaction model
In a distributed system it is hard to set time limits for process execution, message delivery or clock drift.
Two opposing extreme positions provide a pair of simple models, the first has a strong assumption of time and the
second makes no assumption about time.
(i) Synchronous distributed systems
It is defined as one in which the following bounds are specified:
The time to execute each step of a process has known lower and upper bounds.
Each message transmitted over a channel is received within a known bounded time.
Each process has a local clock whose drift rate from real time has a known bound.
• It is possible to suggest likely upper and lower bounds for process execution time message delivery and clock drift
rates in a distributed system.
• But it is difficult to arrive at realistic values and to provide guarantees of the chosen values.
• Unless the values are guaranteed, any design based on the chosen values will not be reliable.
(ii) Asynchronous distributed system
• An asynchronous distributed system is one in which there are no bounds on process execution speeds,
message transmission delays and clock drift rates.
• This exactly models the Internet, in which there is no intrinsic bound on server or network load.
• For example, to transfer a file using ftp. Actual distributed systems are very often asynchronous because of the need for
processes to share the processors and for communication channels to share the network.
1.5.2 The failure model
The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of
failures.
There are three types of failures andare explained below:
Omission failures: The faults classified as omission failures refer to cases when a process or communication
channel fails to perform actions that it is supposed to do.
There are two types of omission failures. They are:
IV YEAR VIIISEM Distributed Computing
Process omission failures:
• The chief omission failure of a process is to crash.
• The design of services that can survive in the presence of faults can be simplified if it can be assumed that the
services on which it depends crash cleanly, i.e. the processes either function correctly or else stop.
• Other processes may be able to detect such a crash by the fact that the process repeatedly fails to respond to
invocation messages.
• However this method of crash detection relies on the use of timeouts.
• A process crash is called fail-stop if other processes can detect certainly that the process has crashed.
Communication omission failures
• As an example, consider the two communication primitives namely send and receive. A process P performs a
send by inserting the message m in its outgoing message buffer.
• The communication channel transports m to q ' s incoming message buffer.
• Process q performs a receive by taking m from its incoming message buffer and then delivers it.
• The outgoing and incoming message buffers are typically provided by the operating system.
• The communication channel produces an omission failure if it does not transport a message from p's outgoing
message buffer to q's incoming message buffer. This is known as 'dropping messages'and is generally caused by
lack of buffer space.
The loss of message between the sending process and the outgoing message buffer is called sending omission
failure.
• The loss of message between the incoming message buffer and the receiving process is called receive-omission
failureand the loss of messages in between is called channel omission failure
Arbitrary failures
• The term arbitrary or Byzantine failure is used to describe the worst possible failure semantics, in which any
type of error may occur.
• An arbitrary failure of a process is one in which it arbitrarily omits intended processing steps or takes unintended
processing steps.
• Communication channels can suffer from arbitrary failures, e.g. Message contents may be corrupted or non-
existent messages may be delivered or real messages may be delivered more than once.
Timing failures
• Timing failures are applicable in synchronous distributed system where time limits are set for all operations.
IV YEAR VIIISEM Distributed Computing
Class of failure Affects Description
Clock Process Local clock exceeds the bounds
• Timing is particularly relevent to multimedia computers with video and audio channels. Video information may
require a large amount of data to be transferred.
To deliver such information without timing failures will make demands on the operating system as well as
communication system.
Masking failure
• Each component in a distributed system is generally constructed from a collection of other components.
• It is possible to construct reliable services from components that exhibit failures.
For example, multiple servers that hold replicas of data can continue to provide a service when one of
them crashes.
• A Knowledge of the failure characteristics can enable a new service to be designed to mask the failure of the
components on which it depends.
• A service masks a failure, either by hiding it altogether or by converting it into a more acceptable type
of failure
1.5.3 Security Model
• The security of a distributed system can be achieved by securing the processes and the channels used for their
interactions and by protecting the objects that they encapsulate against unauthorized access.
Protecting objects
• Protection is described in terms of objects.
• Objects are intended to be used in different ways by different users. For example, some objects may hold a user's
private data and other objects may hold shared data such as Web pages.
• To support this, access rights specify who is allowed to perform the operations (read/write) of an object.
• The server is responsible for verifying the identity of the client behind each invocation and checking their
access rights on the requested object.
• The clients in turn can check the authenticity of the server.
Mobile code
• Mobile code raise new and interesting security problems for any process that receives and executes
program code from elsewhere, such as the e-mail attachments, such code may easily play a Trojan
horse role.
Drawbacks of security techniques
• The use of security techniques such as encryption and access control incurs substantial
processing overhead and management costs.
1.6 INTER PROCESS COMMUNICATION
1.6.1 Introduction
• Inter process communication is concerned with the communication between processes in a distributed
system, both in its own right and as support for communication between distributed objects.
• The Java API for inter process communication in the internet provides both datagram and stream
communication.
• The Application Program Interface (API) to UDP provides a message passing abstraction - the simplest form
of interprocess communication.
• This enables a sending process to transmit a single message to a receiving process. The independent packets
containing these messages are called datagrams.
• In the Java and UNIX APIs, the sender specifies the destination using a socket - an indirect reference to a
particular port used by the destination process at a destination computer.
• The API to TCP provides the abstraction of a two-way stream between pairs of processes. The information
communicated consists of a stream of data items with no message boundaries.
• Request-reply protocols are designed to support client server communication in either Remote Procedure
Call(RPC) or Remote Method Invocation(RMI).
• Group multicast protocols are designed to support group communication. Group multicast is a form of
communication in which one process in a group of processes transmits the message to all members of the
group.
1.6.2 The API for the Internet Protocol 1.1
Characteristics of Interprocess Communication
• Message passing between a pair of processes can be supported by two message communication operations
send and receive.
• In order for one process to communicate with another, one process sends a message to destination and another
process at the destination receives the message.
• This activity involves communication of data from the sending process to the receiving process and may
involve synchronization of the two processes.
• 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 sending and receiving processes may be either synchronous or
asynchronous.
• In synchronous form of communication, the sending and receiving process synchronize, query message.
• In this case, both send and receive are blocking operations.
• Whenever a send issued the sending process is blocked until the corresponding receive is issued.
IV YEAR VIIISEM Distributed Computing
• Whenever receive is issued, the process blocks until a message arrives.
• In asynchronous form of communication, the use of send operation is non-blocking.
• The sending process is allowed to proceed as soon as the message have been copied to a buffer and the
transmission of the message proceeds in parallel with the sending process.
• Receive operation can have blocking and non-blocking variants.
• Messages are sent to(Internet address,localport)pairs. A local port is a message information within a
computer, specified as an integer.
• A port has exactly one receiver but can have many senders.
• Processes may use multiple ports from which to receive messages.
• Servers generally publicize their port numbers for use by clients.
Socket
• Both forms of communication( UDP and TCP) use the socket abstraction which provides end point for
communication between processes
• Inter-process communication consists of transmitting a message between a socket m one process and a socket
in another process.
• For process to receive messages,its socket must be bound to a local port and the Internet address of the
computer on which it runs.
• Processes may use the same socket for sending and 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.
• To send or receive messages, a process must first create a socket bound to an Internet address of the localhost
and 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.
Message Size
• The receiving process need to specify an array of bytes of a particular size.
• Any application requiring messages larger than the maximum must fragment them into chunks of that size.
Blocking
• Sockets normally provide non-blocking sends and blocking receives for datagram communication.
Timeouts
IV YEAR VIIISEM Distributed Computing
• The receive that blocks for ever is suitable for use by a server that is waiting to receive requests from its
clients.
• But in some program,it is no appropriate that a process that has used a receive operation should wait
indefinitely in situations where the potential sending process has crashed or the expected message has been
lost.
Use of UDP
• The Domain Name Service(DNS) which looks up DNS names in the Internet, is implemented over UDP.
• UDP datagrams are sometimes an attractive choice because they do not suffer from overheads associated with
guaranteed message delivery.
DatagramPacket
• This class provides a constructor that makes an instance out of an array of bytes comprising a message,the
length of the message and the Internet address and local port number of the destination socket.
• This class provides another constructor for receiving a message.
• Its arguments specify an array of byte to receive the message and its length.
Datagram Socket
• This class supports sockets for sending and receiving UDP datagrams.
• It provide a constructor that takes a port number as argument,for use by a processes that need to use particular
port.
• It also provides a non-argument constructor that allows the system to choose a free local port.
• The class Datagram Socket provides the following methods:
• send and receive: These methods are for transmitting datagrams between a pair of sockets.
SetSoTimeout:
This method allows a time out to be set.With a timeout set,the receive method will block for the time specified
and the throws an InterruptedIOException.
connect
This method is used for connecting it to a particular remote port and Internet address.
Program:UDPclient
import java.net.*;
import java.io.*;
IV YEAR VIIISEM Distributed Computing
public class UDPclient{
public static void main(String args[){
try{
InetAddress aHost=InetAddress.getByName(args[1]);
aSocket.receive(reply);
Message Destination
• A pair of communicating processes establishes a connection before they can communicate over a stream.
• Once a communication is established,the process simply read from and writes to the stream without the use
of internet,address and ports.
• The API for stream communication assumes that when a pair of processes are establishing a connection,one
of them plays the client role and the other plays the server role,but thereafter they would be peers.
• The client role involves creating a stream socket bound to any port and then making a connect request asking
for a connection to a server at its server port.
• The server role involves creating a listening socket bound to a serverport and waiting for clients to request
connections.The listening socket maintains a queue of incoming connection requests.
• When the server accepts a connection,a new stream socket is created for the server to communicate with a
client,meanwhile retaining its socket at the port for listening to other clients. Some outstanding issues
related to stream communication are
Blocking
• When a process attempts to read data from an input channel,it will get data iron,the queue or it will block until
data becomes available.
• The process that writer data to stream may be blocked by the TCP flow control mechanism if the socket at the
other end is queuing as much data as the protocol allows.
IV YEAR VIIISEM Distributed Computing
Threads
• When a server accepts a connection,it generally creates a new thread to communicate with the
new client.
Failure Model
• To satisfy the integrity property, TCP use checksums to detect and reject corrupt packets and
sequence numbers to detect and reject duplicate packets.
• In order to satisfy the validity property, timeouts and retransmissions are used by TCP.
Uses of TCP
• Many frequently used services run over TCP connection with reserved port numbers.
• Those include HTTP, FTP, Telnet and SMTP.
Server Socket
• This class is intended for use by a server to create a socket at a server port for listening for connect requests
from clients.
• Its accept method gets a connect request from the queue,or the queue is empty ,it blocks until one arrives.
Socket
• The client uses this constructor to create socket specifying the DNS hostname and port of a server.
• The Socket class provides methods getInputStream and getOutputStream for accessing the two streams
associated with a Socket.
import java.net.*;
import java.io.*;
public class TCPClient
{
public static void manin( String args[ ])
{
try {
int serverport =7896;
Socket c=new Socket(args[1],serverport);
DataInputStream in =new DataInputStream(c.getInputStream());
DataOutputStream out =new
DataOutputStream(c.getOutputStrea()); out.writeUTF(args[0]);
String data=in.readUTF();
System.out.println(“Received:”+data);
}
Catch(UnknownHostException e)
{
System.out.printlnfsock:”+e.getMessage());
}
Catch(EOFException e)
{
System.out.println(“EOF:”+e.getMessage());
}
Catch(IOException e)
{
System.out.println(“IO:” +e.getMessage());
}
finally{if(c!=null) try{c.close();}catch(IOException
e);
• In the client program,the argument of the main method supply a message and the DNS name of the
server.
• The client creates a socket bound to the hostname and server port 7896.
• It makes DataInputStream and DataOutputStream then writes the message to its output stream and waitsto
read a reply from its input stream.UTF is an encoding that representing in a particular format.
• The server program opens a server socket on its serverport(7896) and listens for connect sets.
• When one arrives,it makes a new thread in whinch to communicate with the client.
Server program
IV YEAR VIIISEM Distributed Computing
import java.net.*;
import java.io.*; public
class TCPServer{
public static void main(String args[ ])
{ try{ int
serverport=7896;
ServerSocket lissoc=new ServerSocket(serverport);
While(true)
{
Socket s =lissoc.accept();
DataInputStream out=new DataOutputStream(s.getOutputStream());
String line=in.read(JTF());
out.writeUTF(line);
}
catch(EOFException e) {
System.out.println(“EOF:”+e.getMessage());
}
catch(IOException e) {
System.out.println(“IO:”+e.getMessage();}
finally{try{lissoc.close();}
catch(IOException e){ }
• Primitive types are written in portable format using methods of ObjectOutputStream class.
• Strings and characters are written by its method called writeUTF(Universal Transfer Format)
Syntax
public byte[ ]doOperation(RemoteObjectref o,int methodid,byte[ ] arguments)
• The doOperation method sends a request message to the server whose Internet address j port arespecified in
the remote object reference given as argument.
• After sending the request message,doOperation invokes receive to get a reply message,from which itextracts
results and returns it to the caller.
• GetRequest is used by a server process to acquire service requests.
When the server has invoked the method in the specified object it then uses sendReply to send the
replymessage to client.
• When the reply message is received by the client,the doOperation is unblocked the execution of theclient
program continues.
Syntax
public byte[ ] getRequest();
public void sendReply(byte[ ] reply,InetAddress clientHost,int clientPort);
The action taken when a timeout occurs depends upon the delivery guarantees to be offered.
• The protocol is designed to recognize successive messages with the same request identifier and to filterout
duplicates.if the server has already sent the reply when it receives a duplicate request it will need toexecute
the operation again to obtain the result.
• Some servers can execute their operations more than once and obtain the same results each time.
• An idempotent operation is one that can be performed repeatedly with the same effect as if performedexactly
once.
• For servers that require retransmission of replies without re-execution of operations,a history may beused.
• The term „history‟ refers to a structure that contains a record of reply messages that have beentransmuted.
• An entry,in a history contains a request identifier,and an identifier of the client to which it was sent.
• Its purpose is to allow the server and transmit reply messages when client processes request it.
• A problem associated with the history is its memory.
RPC Exchange Protocols
The following three protocols are used for implementing various types of RPC three protocols producediffering
behaviors in the presence of communication failures.
The request(R protocol)
It may be used when there is no value to be returned from the procedure and the client requires noconfirmation that
the procedure has been executed.
The request-reply(RR) protocol .
It is useful for most client-server exchanges.Special acknowledgement messages are notrequired,because a server‟s
reply message is regarded as an acknowledgement.
The request reply-acknowledgement(RRA)
Protocol it is based on exchange of 3 messages: request,reply and acknowledgement.the
acknowledgement contains the requested which will enable the server to discard entries from its history.
Message Contents
• The Request Message specifies the name of a method,the URL of a resource,the protocol version,someheaders
and an optional message body.
• A Reply message specifies the protocol version,a status code and „reason‟,some headers and an optionalmessage
body.
try{
InetAddress
group=InetAddress.getByName(args[1]);MulticastSocket
s=new MulticastSocket(6789);s.joinGroup(group);byte [
] m= args[0].getBytes();
DatagramPacket message =new
DatagramPacket(m,m.length,group,6789);
s.send(message);byte [ ]
buffer=new byte[1000];
for ( int i=0;i<n;i++)
{
No.of members in a group Datagrampacket messagesln=new
DatagramPacket(buffer,buffer.length);
s.leaveGroup(group);
}
Catch(socket exception e) {
System.out.println(“Socket:”+e.getMessage());
}catch(IOException e) {
System.out.println(“IO:”+e.getMessage());}finally{if(s!=null
)s.closef);}
Fig1.16 illustrates the packets used for datagrams.Client Address and Server Address are socketaddresses.
s=socket(AF_INET,SOCK_DGRAM,0) s=socket(AF_INET,SOCK_DGRAM,0)
bind(s,clientAddress) bind(s.ServerAddress)
Both processes use the bind call to bind their sockets to socket addresses.
• The sending process binds its socket address referring to any available local port number.
• The receiving process binds its socket to a socket address that contains its server port and must be
madeknown to the sender.
• The sending process uses sendto call with arguments specifying the socket through the message is to
besent,the message itself and the socket address of the destination.
• The sendto call hands the message to the underlying UDP ans IP protocols and returns the actual numberof
bytes sent.
• As datagram service is requested the messagae is transmitted to its destination without anacknowledgement.
• If the message is too long to be sent,there is an error return.
• The reveiving process uses the recvfrom call with arguments specifying the local socket on which toreceive a
message and memory locations in which to store the message and the socket address of thesending socket.
• The recvfrom call collects the first message in the queue at the socket,or if the queue is empty it will
waituntil a message arrives.
• Communication occurs only when a sendto in one process addresses its message to the socket used by
arecvfrom in another process.
• In client-server communication there is no need for servers to have prior knowledge of client‟s
socketaddresses,because the recvfrom operation supplies the sender‟s address with each message it delivers.
• The properties of datagram communication in UNIX are the same as those described in Section 1.6
Stream Communication
• In order to use the stream protocol, two processes must first establish a connection between their pair
ofsockets.
• The arrangement is a asymmetric because one of the sockets will be listening for a request for connectionand
the other will be asking for a connection.
• Once a pair of socket has been connected,they may be used for transmitting data in both or eitherdirection.
That is they behave like streams in that any available data is read immediately m the same order as it
waswritten and there is no indication of the boundary of the empty,the sender blocks if it is full.
• Fig1.17 illustrates stream communication in which the details of the arguments are simplified,it does notshow
the server closing the socket on which it listens.
• Normally a server would first listen and accept a connection and then fork a new process to communicatewith
the client.
IV YEAR VIIISEM Distributed Computing
• Mean while,it will continue to listen in the original process.
• The properties of stream communication in UNIX are the same as those described in section 1.6
• Server or listening process first uses the socket operation to create a stream socket and the bind operationto
bind its socket to the server‟s socket address.
• The second argument to the socket system call is given as STOCK_STREAM to indicate that
streamcommunication is required.
• If the third argument is left as zero,the TCP/IP protocol will be selected automatically.
• It uses the listen operation to listen on its socket for client requests for connections.
• The second argument to the listen system call specifies the maximum number of requests forcommunication
that can be queued at this socket.
• The server uses accept system call to accept a connection requested by a client and obtain a new socketfor
communication with that client.
• The original socket may still be used further for connection with other clients.
• The client process uses the socket operation to create a stream socket and then uses the connect systemcall to
request a connection via the socket address of the listening process.
• As the connect call automatically binds a socket name to the caller‟s socket prior binding is unnecessary.