Professional Documents
Culture Documents
CS407 M3 Distributed Computing Ktustudents - in
CS407 M3 Distributed Computing Ktustudents - in
Module 3 - Overview
Communication Paradigms:
Inter Process Communication:
DISTRIBUTED IPC Characteristics
COMPUTING Multicast Communication
Network Virtualization
MODULE 3 Case study: Skype
COMMUNICATION PARADIGMS: Indirect Communication:
IPC, REMOTE INVOCATION AND INDIRECT Group communication
COMMUNICATION PARADIGMS Remote Invocation:
Remote Procedure call
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 1 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 2
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 5 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 6
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 7 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 8
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 9 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 10
Reliability Ordering
A reliable communication ensures validity and integrity: Sender order delivery:
Some applications require that messages must be
Validity: A point to point message service is considered
delivered in the order in which they were transmitted by
to be reliable if messages are guaranteed to be
the sender.
delivered despite a ‘reasonable’ no of packets being
The delivery of messages out of sender order is
dropped or lost.
regarded as a failure by such applications.
Considered unreliable if messages are not guaranteed
to be delivered when even a single packet is dropped
or lost.
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 13 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 14
Sockets Sockets…
Both UDP and TCP uses the socket abstraction. A socket pair (local IP address, local port, foreign IP address,
A socket provides an endpoint for communication between foreign port) uniquely identifies a communication.
processes. Messages sent to a socket can be received only by a process
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 17 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 18
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 19 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 20
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 21 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 22
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 23 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 24
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 25 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 26
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 27 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 28
Java API for UDP Datagrams… Java UDP API… Datagram Packet
The Java API provides datagram communication by This class provides a constructor that makes an instance out
means of two classes: of an array of bytes comprising a message, the length of the
DatagramPacket - used to implement a connectionless
message and the IP and local port no of the destination
socket.
packet delivery service.
DatagramSocket - specifies the sending or receiving
Instances of this may be transmitted between processes
point for a packet delivery service.
when send and receive happens.
Also provides another constructor for message reception,
Methods of DatagramPacket: whose arguments specify an array of bytes in which to
getData() - Returns the data buffer. receive the message and the length of the array.
getPort() - Returns the port number on the remote host. A received message is put in the DatagramPacket together
getAddress() - Returns the IP address.
with its length and the IP address and port of the sending
socket. (using the methods mentioned before)
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 29 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 30
Java UDP API… Datagram Socket Java UDP API… Datagram Socket…
Support sockets for sending and receiving UDP receive - Receives a datagram packet from this socket.
datagrams. Argument is an empty datagram packet in which to put the
Provides a constructor that takes port no as argument. message, its length and origin
Also provides a no argument constructor that allows the setSoTimeout - Enable/disable the specified timeout, in
system to choose a free local port. milliseconds.
Throws SocketException if the port is already in use or a The receive method will block for this time and then throw
reserved port (below 1024) an InterruptedIO Exception
Provides the following methods: connect - Connects the socket to a remote address for
this socket.
send - Sends a datagram packet from this socket.
Then the socket can send and receive messages only from
» Arguments include an instance of the datagram packet
that address
and its destination
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 31 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 32
UDP Communication Example: UDP Client - sends a message to the server and gets a reply
import java.net.*;
Client sends a message to server at a port 6789 and then import java.io.*;
wait for the reply. public class UDPClient{
public static void main(String args[]){
Arguments of main() supply a message and DNS // args give message contents and server hostname
DatagramSocket aSocket = null;
hostname of the server. try {
aSocket = new DatagramSocket();
Message is converted into an array of bytes. byte [] m = args[0].getBytes();
InetAddress aHost = InetAddress.getByName(args[1]);
DNS hostname is converted into an Internet address. int serverPort = 6789;
DatagramPacket request =
new DatagramPacket(m, args[0].length(), aHost, serverPort);
aSocket.send(request);
Server creates a socket bound to its server port (6789). byte[] buffer = new byte[1000];
DatagramPacket reply = new DatagramPacket(buffer, buffer.length);
Then repeatedly waits to receive a request message from aSocket.receive(reply);
a client to which it replies by sending back the same System.out.println("Reply: " + new String(reply.getData()));
}catch (SocketException e){System.out.println("Socket: " + e.getMessage());
message. }catch (IOException e){System.out.println("IO: " + e.getMessage());}
}finally {if(aSocket != null) aSocket.close();}
KTUStudents.in
}
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 33 } Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 34
UDP Server repeatedly receives a request and sends it back to the client
import java.net.*;
import java.io.*;
public class UDPServer{
public static void main(String args[]){
TCP STREAM
DatagramSocket aSocket = null;
try{
COMMUNICATION
aSocket = new DatagramSocket(6789);
byte[] buffer = new byte[1000];
while(true){
DatagramPacket request =
new DatagramPacket(buffer, buffer.length);
aSocket.receive(request);
Illustrate the communication process using TCP.
DatagramPacket reply = new DatagramPacket(request.getData(),
request.getLength(), request.getAddress(), request.getPort());
aSocket.send(reply);
}
}catch (SocketException e){System.out.println("Socket: " + e.getMessage());
}catch (IOException e) {System.out.println("IO: " + e.getMessage());}
}finally {if(aSocket != null) aSocket.close();}
}
}
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 35 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 36
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 37 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 38
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 41 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 42
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 45 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 46
Java API for TCP Streams Java API for TCP Streams…
The Java API provides TCP streams by two classes:
ServerSocket – Intended for use by a server to create a
socket at the server port for listening to connect
requests from clients.
ServerSocket ss = new ServerSocket(serverPort);
Its accept method gets a connect request from the
queue or, if the queue is empty, blocks until one
arrives.
The result of executing accept is an instance of Socket
KTUStudents.in
DataOutputStream to read and write data.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 49 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 50
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 53 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 54
UDP vs TCP
Datagram Socket: uses Stream Socket:
datagrams that may take communication using a
any route to destination. stream of bytes.
Efficient but suffer from Reliable, but complex. MULTICAST COMMUNICATION
failures – unreliable. Use seq. no., ack,
No ack, no retransmission, retransmission etc for
no seq. no. – out of order reliability. A form of inter process communication in which
delivery. Uses three way handshake one process in a group of processes transmits the
Faster, as there is no conn. to establish connection - same message to all members of the group.
establishment slower.
No flow control and error Flow and error control
checking. using sliding window and
checksums etc.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 55 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 56
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 57 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 58
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 61 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 62
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 65 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 66
KTUStudents.in
network.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 69 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 70
Multicast peer joins a group and sends and Multicast peer joins a group and sends and receives
receives datagrams datagrams…
In the example, the arguments to the main method specify a
message to be multicast and the multicast address of a group
(for example, "228.5.6.7").
After joining that multicast group, the process makes an instance
of DatagramPacket containing the message and sends it through
its multicast socket to the multicast group address at port 6789.
Sending message to group After that, it attempts to receive three multicast messages from its
peers via its socket, which also belongs to the group on the same
port.
Receiving message When several instances of this program are run simultaneously on
from group different computers, all of them join the same group, and each of
them should receive its own message and the messages from
those that joined after it.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 71 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 72
Ordering issue – The packets could arrive in a different order. Discovering services in spontaneous networking
» some group members receive datagrams from a single sender in a A process can discover services by multicasting requests at periodic
different order from other group members. intervals, and the available services will listen for those multicasts and
respond.
» messages sent by two different processes will not necessarily arrive
in the same order at all the members of the group. An occasional lost request is not an issue when discovering services.
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 73 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 74
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 75 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 76
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 77 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 78
applications, like peer-to-peer file sharing, Skype, etc., particular distributed application.
which coexist in the Internet. Eg. One VN might support multimedia streaming, as in BBC
iPlayer, BoxeeTV [boxee.tv] or Hulu [hulu.com], and
It is impractical to alter the Internet Protocols to suit
coexist with another that supports a multiplayer online game,
each of the many applications running over them. both running over the same underlying network.
In addition, the IP transport service is implemented An application-specific virtual network can be built above
over a large number of network technologies. an existing network and optimized for that particular
These two factors led to the network virtualization. application, without changing the characteristics of the
underlying network.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 79 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 80
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 81 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 82
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 83 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 84
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 85 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 86
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 87 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 88
Skype
Skype is a peer-to-peer application offering Voice over
IP (VoIP).
It includes calling, instant messaging, video
CASE STUDY: SKYPE conferencing, file sharing and interfaces to the
standard telephony services through SkypeIn and
SkypeOut.
SkypeOut: the ability to call landline or mobile phones from
Skype; but this term has been dropped later.
Skype Peer-to-Peer Internet Telephony Protocol Skype Number (until 2010 named SkypeIn) allows a Skype user
An example of Overlay Network to receive calls to their Skype client (on whatever device) dialed
from mobiles or landlines to a Skype-provided phone number.
Much of the service is free, but Skype Credit or a subscription is
required to call a landline or a mobile phone number.
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 89 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 90
Skype…
Skype company was created by Niklas Zennström and the
Dane Janus Friis in 2003., acquired by Microsoft in 2011.
Ahti Heinla, Priit Kasesalu and Jaan Tallinn developed the
software, it was same as of Kaaza, a peer-to-peer music
file-sharing application.
Skype is widely deployed, with millions of users.
Registered users of Skype are identified by a unique
Skype Name and may be listed in the Skype directory.
Skype supports conference calls, video chats and screen
sharing between 25 people at a time for free.
In December 2017, Microsoft added ‘Skype Interviews’,
a shared code editing system for those wishing to run job
interviews for programming roles.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 91 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 92
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 93 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 94
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 97 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 98
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 101 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 102
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 105 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 106
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 109 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 110
separately and serially. Ethernet) to deliver the message to both destinations at once,
instead of sending it twice.
This saves bandwidth and time.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 111 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 112
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 113 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 114
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 117 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 118
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 121 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 122
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 125 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 126
Implementation Issues …
In general, the need to maintain group membership has a
significant impact on the utility of group-based approaches.
Group communication is most effective in small-scale and
static systems and does not operate as well in larger-scale REMOTE PROCEDURE CALL
or volatile environments.
Illustrate the Remote Procedure Call mechanism
This can be traced to the need for a form of synchrony
Illustrate Sun RPC
assumption.
A more probabilistic approach to group membership
designed to operate in more large-scale and dynamic
environments is using an underlying gossip protocol.
Researchers have also developed group membership
protocols specifically for ad hoc networks and mobile
environments.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 127 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 128
Introduction RPC
Remote Procedure Call (RPC) is a remote invocation Allows client programs to call procedures transparently
paradigm. in server programs, running in separate processes and
This concept was first introduced by Birrell and Nelson generally in different computers other than the client.
[1984] and paved the way for many of the developments in The underlying RPC system hides important aspects of
distributed systems programming used today. distribution, including
RPC helps achieving a high level of distribution the encoding and decoding of parameters and
transparency in a simple manner, results,
by extending the abstraction of a procedure call to the passing of messages and
distributed environments,
the preserving of the required semantics for the
allowing a calling process to call a procedure in a remote
procedure call.
node as if it is local.
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 129 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 130
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 131 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 132
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 133 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 134
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 135 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 136
Person structure: the interface PersonList specifies the methods remote interface defines
available for RMI in a remote object that implements that
interface PersonList { methods for RMI
interface. The method addPerson specifies its argument as in, readonly attribute string listname;
an input argument, and the method getPerson that retrieves void addPerson (in Person p) ;
an instance of Person by name specifies its second argument void getPerson (in string name, out Person p);
as out, an output argument. long number();
}; parameters are in, out or inout
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 137 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 138
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 141 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 142
more than once. Middleware can also offer additional levels of transparency
Sun RPC provides at-least-once call semantics. to RPC.
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 145 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 146
Transparency… Transparency…
RPC calls are more vulnerable to failure than local ones, since Remote calls require a different style of parameter passing.
they involve a network, another computer and another process. RPC does not offer call by reference.
Sometimes, no result will be received, it is impossible to distinguish
between network failure and remote server process failure. Some others claim that the difference between local and remote
This requires that clients making remote calls are able to recover operations should be expressed at the service interface, to allow
from such situations. participants to react in a consistent way to possible partial
failures.
The latency is several orders of magnitude greater than that of Some arguments are that the syntax of a remote call should be
a local one, so minimize remote interactions. different from that of a local call: in the case of Argus, the
A caller should be able to abort a remote call that is taking too language was extended to make remote operations explicit to
long in such a way that it has no effect on the server. the programmer.
To allow this, the server would need to be able to restore things The choice as to whether RPC should be transparent is also
to how they were before the procedure was called. available to the designers of IDLs.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 147 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 148
KTUStudents.in
languages
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 149 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 150
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 153 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 154
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 157 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 158
Sun RPC Case Study… Sun XDR Sun RPC Case Study… Sun XDR
RPC uses an interface definition language called XDR. A procedure definition specifies a procedure signature and
Has an interface compiler called rpcgen, for C lang. a procedure number (a procedure identifier in request)
Sun XDR is used to define a service interface for Sun RPC Only a single input parameter is allowed.
by specifying a set of procedure definitions together with multiple parameters must be used as components of a single
supporting type definitions. structure.
The notation is rather primitive than CORBA IDL or Java.
The output parameters of a procedure are returned via a
single result.
No Interface name: Instead, uses a program number and
The procedure signature consists of the result type,
version number, passed with request message, so that the
client and server can check that they are using the same version. procedure name and the type of the input parameter.
The program nos can be obtained from a central authority to
The type of both the result and the input parameter may
allow every program to have its own unique number. specify either a single value or a structure containing several
values.
The version no is intended to be changed when a procedure
signature changes.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 159 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 160
KTUStudents.in
};
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 161 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 162
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 163 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 164
Sun RPC Case Study… Binding… Sun RPC Case Study… Authentication
A client cannot use a direct IP multicast message to RPC request and reply messages has fields for
multicast a request to all the instances of a service that authentication between client and server.
are using different port numbers. The request contains the credentials of the client.
The solution is that clients make multicast RPC by Eg. the uid and gid of the user.
multicasting them to all the port mappers, specifying Access control mechanisms can be made available to
the program and version number. the server procedures via a second argument.
Each port mapper forwards all such calls to the The server is enforces access control by deciding
appropriate local service program, if there is one. whether to execute each procedure call according to
the authentication information.
Eg., if the server is an NFS file server, it can check whether
the user has sufficient rights to do a file operation.
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 165 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 166
KTUStudents.in
Has exactly once semantics.
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 169 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 170
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 171 Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 172
KTUStudents.in
Dept. of CSE, Toc H Institute of Science and Technology, Arakkunnam 173