Top Banner
Heterogeneity Applies to all of the following: – networks Internet protocols mask the differences between networks computer hardware e.g. data types such as integers can be represented differently operating systems e.g. the API to IP differs from one OS to another programming languages data structures (arrays, records) can be represented differently implementations by different developers they need agreed standards so as to be able to interwork Middleware provides a programming abstraction and masks the heterogeneity of networks etc.
72

Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Mar 26, 2015

Download

Documents

Megan McLain
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Heterogeneity

• Applies to all of the following:– networks

• Internet protocols mask the differences between networks

– computer hardware• e.g. data types such as integers can be represented differently

– operating systems• e.g. the API to IP differs from one OS to another

– programming languages• data structures (arrays, records) can be represented differently

– implementations by different developers• they need agreed standards so as to be able to interwork

• Middleware provides a programming abstraction and masks the heterogeneity of networks etc.

Page 2: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Middleware layers

Applications

Middlewarelayers Request reply protocol

External data representation

Operating System

RMI, RPC and events

Programming model

Interprocess communication

Page 3: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Chapter 5: Middleware programming models

• Procedure call model via remote procedure call (RPC)– E.g. Sun RPC

• Object-based model via remote method invocation (RMI)– E.g. Java RMI or CORBA

• Event-based model via remote event notification– E.g. Jini distributed event specification

Page 4: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Introduction

• The API for the Internet protocols

• External data representation and marshalling

• Client-Server communication

• Group communication

• Case study: interprocess communication in UNIX

• Summary

Chapter 4: Interprocess Communication

Page 5: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Introduction

• The API for the Internet protocols

• External data representation and marshalling

• Client-Server communication

• Group communication

• Case study: interprocess communication in UNIX

• Summary

Chapter 4: Interprocess Communication

Page 6: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Synchronous and asynchronous– a queue associated with message destination, Sending process add message

to remote queue, Receiving process remove message from local queue– Synchronous: send and receive are blocking operations– asynchronous: send is unblocking, receive could be blocking or unblocking

(receive notification by polling or interrupt)

• Message destination– Internet address + local port– service name: help by name service at run time– location independent identifiers, e.g. in Mach

• Reliability– validity: messages are guaranteed to be delivered despite a reasonable

number of packets being dropped or lost– Integrity: messages arrive uncorrupted and without duplication

• Ordering – the messages be delivered in sender order

The characteristics of interprocess communication

Page 7: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Endpoint for communication between processes• Both forms of communication (UDP and TCP ) use the socket

abstraction• Originate from BSD Unix, be present in most versions of UNIX• be bound to a local port (216 possible port number) and one of the

Internet address• a process cannot share ports with other processes on the same

computer

Socket

message

agreed portany port socketsocket

Internet address = 138.37.88.249Internet address = 138.37.94.248

other ports

client server

Page 8: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• UDP datagrams are sent without acknowledgement or retries• Issues relating to datagram communication

– Message size: not bigger than 64k in size, otherwise truncated on arrival– blocking: non-blocking sends (message could be discarded at destination if

there is not a socket bound to the port ) and blocking receives (could be timeout)

– Timeout: receiver set on socket– Receive from any: not specify an origin for messages

• Failure model– omission failure: message be dropped due to checksum error or no buffer s

pace at sender side or receiver side– ordering: message be delivered out of sender order– application maintains the reliability of UDP communication channel by itse

lf

UDP datagram communication

Page 9: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• DatagramPacket

• DatagramSocket– send and receive : transmit datagram between a pair of socket

s

– setSoTimeout : receive method will block for the time specified and then throw an InterruptedIOexception

– connect: connect to a particular remote port and Internet address

• Examples– be acceptable to services that are liable to occasional omissio

n failures, e.g. DNS

Java API for UDP datagrams (skip)

Page 10: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

UDP client sends a message to the server and gets a reply (skip)

import java.net.*;import java.io.*;public class UDPClient{ public static void main(String args[]){

// args give message contents and server hostnameDatagramSocket aSocket = null; try {

aSocket = new DatagramSocket(); byte [] m = args[0].getBytes();InetAddress aHost = InetAddress.getByName(args[1]);int serverPort = 6789; DatagramPacket request = new DatagramPacket(m, args[0].length(), aHost,

serverPort);aSocket.send(request); byte[] buffer = new byte[1000];DatagramPacket reply = new DatagramPacket(buffer, buffer.length);aSocket.receive(reply);System.out.println("Reply: " + new String(reply.getData()));

}catch (SocketException e){System.out.println("Socket: " + e.getMessage()); }catch (IOException e){System.out.println("IO: " + e.getMessage());}}finally {if(aSocket != null) aSocket.close();}

} }

Page 11: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

UDP server repeatedly receives a request and sends it back to the client (skip)

import java.net.*;import java.io.*;public class UDPServer{

public static void main(String args[]){ DatagramSocket aSocket = null; try{ aSocket = new DatagramSocket(6789);

byte[] buffer = new byte[1000]; while(true){ DatagramPacket request = new DatagramPacket(buffer, buffer.length); aSocket.receive(request); 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();}

}}

Page 12: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• The API to the TCP– provide the abstraction of a stream of bytes to which data may be written

and from which data may be read

• Hidden network characteristics– message sizes– lost messages– flow control– message duplication and ordering– message destinations

• issues related to stream communication– Matching of data items: agree to the contents of the transmitted data– Blocking: send blocked until the data is written in the receiver’s buffer,

receive blocked until the data in the local buffer becomes available– Threads: server create a new thread when it accept a connection

TCP stream communication

Page 13: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• failure model– integrity and validity have been achieved by checksum,

sequence number, timeout and retransmission in TCP protocol

– connection could be broken due to unknown failures• Can’t distinguish between network failure and the destination process

failure • Can’t tell whether its recent messages have been received or not

TCP stream communication … continued

Page 14: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• ServerSocket– accept: listen for connect requests from clients

• Socket– constructor

• not only create a socket associated with a local port, but also connect it to the specified remote computer and port number

– getInputStream

– getOutputStream

• Examples

Java API for TCP Streams (skip)

Page 15: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

TCP client makes connection to server, sends request and receives reply

import java.net.*;import java.io.*;public class TCPClient {

public static void main (String args[]) {// arguments supply message and hostname of destinationSocket s = null; try{ int serverPort = 7896; s = new Socket(args[1], serverPort);

DataInputStream in = new DataInputStream( s.getInputStream());DataOutputStream out =

new DataOutputStream( s.getOutputStream());out.writeUTF(args[0]); // UTF is a string encoding see Sn 4.3String data = in.readUTF(); System.out.println("Received: "+ data) ;

}catch (UnknownHostException e){System.out.println("Sock:"+e.getMessage());

}catch (EOFException e){System.out.println("EOF:"+e.getMessage()); }catch (IOException e){System.out.println("IO:"+e.getMessage());}

}finally {if(s!=null) try {s.close();}catch (IOException e){System.out.println("close:"+e.getMessage());}} }}

Page 16: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

TCP server makes a connection for each client and then echoes the client’s request

import java.net.*;import java.io.*;public class TCPServer { public static void main (String args[]) {

try{int serverPort = 7896; ServerSocket listenSocket = new ServerSocket(serverPort);while(true) {

Socket clientSocket = listenSocket.accept();Connection c = new Connection(clientSocket);

}} catch(IOException e) {System.out.println("Listen :"+e.getMessage());}

}}

// this figure continues on the next slide

Page 17: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

TCP Server … continued

class Connection extends Thread {DataInputStream in;DataOutputStream out;Socket clientSocket;public Connection (Socket aClientSocket) { try {

clientSocket = aClientSocket;in = new DataInputStream( clientSocket.getInputStream());out =new DataOutputStream( clientSocket.getOutputStream());this.start();

} catch(IOException e) {System.out.println("Connection:"+e.getMessage());}}public void run(){ try { // an echo server

String data = in.readUTF(); out.writeUTF(data);

} catch(EOFException e) {System.out.println("EOF:"+e.getMessage()); } catch(IOException e) {System.out.println("IO:"+e.getMessage());} } finally{ try {clientSocket.close();}catch (IOException e){/*close failed*/}}}

}

Page 18: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Introduction

• The API for the Internet protocols

• External data representation and marshalling

• Client-Server communication

• Group communication

• Case study: interprocess communication in UNIX

• Summary

Chapter 3: Interprocess Communication

Page 19: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Why does the communication data need external data representation and marshalling?– Different data format on different computers, e.g., big-endian/little-endian i

nteger order, ASCII (Unix) / Unicode character coding• How to enable any two computers to exchange data values?

– The values be converted to an agreed external format before transmission and converted to the local form on receipt

– The values are transmitted in the sender’s format, together with an indication of the format used, and the receipt converts the value if necessary

• External data representation– An agreed standard for the representation of data structures and primitive v

alues• Marshalling (unmarshalling)

– The process of taking a collection of data items and assembling them into a form suitable for transmission in a message

– Usage: for data transmission or storing in files• Two alternative approaches

– CORBA’s common data representation / Java’s object serialization

External data representation and marshalling introduction

Page 20: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Represent all of the data types that can be used as arguments and return values in remote invocations in CORBA

• 15 primitive types– Short (16bit), long(32bit), unsigned short, unsigned long, float, char, …

• Constructed types– Types that composed by several primitive types

• A message example

• The type of a data item is not given with the data representation in message– It is assumed that the sender and recipient have common knowledge of the

order and types of the data items in a message.

– For RMI and RPC, each method invocation passes arguments of particular types, and the result is a value of a particular type.

CORBA’s Common Data Representation (CDR)

Page 21: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

CORBA CDR for constructed types

Type Representation

sequence length (unsigned long) followed by elements in order

string length (unsigned long) followed by characters in order (can also

can have wide characters)

array array elements in order (no length specified because it is fixed)

struct in the order of declaration of the components

enumerated unsigned long (the values are specified by the order declared)

union type tag followed by the selected member

Page 22: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

CORBA CDR message

The flattened form represents a Person struct with value: {‘Smith’, ‘London’, 1934}

0–34–78–1112–1516–1920-2324–27

5"Smit""h___"

6"Lond""on__"

1934

index in sequence of bytes 4 bytes

notes on representation

length of string

‘ Smith’

length of string‘ London’

unsigned long

Struct Person { string name; string place; long year;};

Page 23: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Serialization (deserialization)– The activity of flattening an object or a connected set of objects into a s

erial form that is suitable for storing on the disk or transmitting in a message

– Include information about the class of each object and a version number– Handles: references to other objects are serialized as handles

• Each object is written once only

– Example (n1)– Make use of Java serialization

• ObjectOutputStream.writeObject, ObjectInputStream.readObject

• The use of reflection– Reflection : The ability to enquire about the properties of a class, and als

o enables classes to be created from their properties.– Reflection makes it possible to do serialization (deserialization) in a co

mpletely generic manner

Java object serialization

Page 24: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Indication of Java serialized form

The true serialized form contains additional type markers; h0 and h1 are handles

Serialized valuesPerson

31934

8-byte version number

int year

5 Smith

java.lang.Stringname:

6 London

h0

java.lang.Stringplace:h1

Explanation

class name, version number

number, type and name of instance variables

values of instance variables

Public class Person implements Serializable {private String name;private String place;private int year;public Person (String aName, String aPlace, int aYear){

name = aName;place = aPlace;year = aYear;

}// followed by methods for accessing the instance variables

}

Person p = new Person(“Smith”, “London”, 1934);

Page 25: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• An identifier for a remote object that is valid throughout a distributed system

• Representation of a remote reference

• a remote object reference must be unique in the distributed system and over time. It should not be reused after the object is deleted. Why not?

• the first two fields locate the object unless migration or re-activation in a new process can happen

• the fourth field identifies the object within the process• its interface tells the receiver what methods it has (e.g. class Method)• a remote object reference is created by a remote reference module when a

reference is passed as argument or result to another process– it will be stored in the corresponding proxy– it will be passed in request messages to identify the remote object whose

method is to be invoked

Remote object reference

Internet address port number time object number interface of remote object

32 bits 32 bits 32 bits 32 bits

Page 26: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Introduction

• The API for the Internet protocols

• External data representation and marshalling

• Client-Server communication

• Group communication

• Case study: interprocess communication in UNIX

• Summary

Chapter 4: Interprocess Communication

Page 27: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

The request – reply protocol

• The request-reply protocol • Overheads associated with the TCP protocol

– Acknowledgements are redundant since requests are followed by replies

– Establishing a connection involves two extra pairs of messages in addition to the pair required for a request and a reply

– Flow control is redundant for the majority of invocations, which pass only small arguments and results

• Request-reply message structure– requestID: prevent duplicated request and delayed reply

• Message identifiers– A requestID– An identifier for the sender process, e.g. its port and Internet a

ddress

Page 28: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Request-reply communication

Request

ServerClient

doOperation

(wait)

(continuation)

Replymessage

getRequest

execute

method

messageselect object

sendReply

public byte[] doOperation (RemoteObjectRef o, int methodId, byte[] arguments)sends a request message to the remote object and returns the reply. The arguments specify the remote object, the method to be invoked and the arguments of that method.

public byte[] getRequest ();acquires a client request via the server port.

public void sendReply (byte[] reply, InetAddress clientHost, int clientPort); sends the reply message reply to the client at its Internet address and port.

Page 29: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Request-reply message structure

messageType

requestId

objectReference

methodId

arguments

int (0=Request, 1= Reply)

int

RemoteObjectRef

int or Method

array of bytes

Page 30: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

The request – reply protocol … continued

• Failure model – Timeout

• doOperation return exception when repeatedly issued requests are all timeout

– Duplicate request messages: filter out duplicates by requestID• if the server has not yet sent the reply, transmit the reply after finishing oper

ation execution• If the server has already sent the reply, execute the operation again to obtain

the result. Note idempotent operation, e.g., add an element to a set, and a contrary example, append an item to a sequence

• History: server contains a record of reply messages that have been transmitted to avoid re-execution of operations

• Implement the request-reply protocol on TCP– Costly, but no need for the request-reply protocol to deal with retr

ansmission and filtering– Successive requests and replies can use the same stream to reduce

connection overhead

Page 31: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

HTTP: an example of a request – reply protocol

• Over TCP• Each client-server interaction consists of the following steps

– The client requests and the server accepts a connection at the default server port or at a port specified in the URL

– The client sends a request message to the server– The server sends a reply message to the client– The connection is closed

• Persistent connection– Connections that remain open over a series of request-reply exchanges between

client and server• Marshalling

– Request and replies are marshalled into messages as ASCII text string– Resources are represented as byte sequences and may be compressed

• HTTP Methods– GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE

• HTTP Request and reply messages

Page 32: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

HTTP request / reply messages

GET http://www.dcs.qmw.ac.uk/index.html HTTP/ 1.1

URL or pathnamemethod HTTP version headers message body

HTTP/1.1 200 OK resource data

HTTP version status code reason headers message body

Page 33: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Introduction

• The API for the Internet protocols

• External data representation and marshalling

• Client-Server communication

• Group communication

• Case study: interprocess communication in UNIX

• Summary

Chapter 4: Interprocess Communication

Page 34: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

The usage of Multicast

• Fault tolerance based on replicated services– Client request are multicast to all the members of the group, each of which p

erforms an identical operation

• Finding the discovery servers in spontaneous networking– Multicast message can be used by servers and clients to locate available disc

overy services to register their interfaces or to look up the interfaces of other services

• Better performance through replicated data– Data are replicated to increase the performance of a service, e.g., Web Cache.

Each time the data changes, the new value is multicast to the processes managing the replicas

• Propagation of event notification– Multicast to a group may be used to notify processes when something happe

ns, e.g., the Jini system uses multicast to inform interested clients when new lookup services advertise their existence

Page 35: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

IP Multicast – an implementation of group communication

• A multicast group is specified by a class D Internet address– Built on top of IP– Available only via UDP

• The membership of a group is dynamic– It is possible to send datagram to a multicast group without being a

member• IPv4

– Multicast routers• use the broadcast capability of the local network• MTTL - specify the number of routers a multicast message is allowed to pass

– Multicast address allocation• Permanent group – 224.0.0.1 to 224.0.0.255• Temporary group – the other addresses, set TTL to a small value

• Failure model: due to UDP, so it is a unreliable multicast• Java API to IP multicast

Page 36: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Multicast peer joins a group and sends and receives datagramsimport java.net.*;import java.io.*;public class MulticastPeer{

public static void main(String args[]){ // args give message contents & destination multicast group (e.g. "228.5.6.7")

MulticastSocket s =null; try {

InetAddress group = InetAddress.getByName(args[1]); s = new MulticastSocket(6789); s.joinGroup(group);

byte [] m = args[0].getBytes(); DatagramPacket messageOut =

new DatagramPacket(m, m.length, group, 6789); s.send(messageOut);

// this figure continued on the next slide

Page 37: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Multicast peers example… continued

// get messages from others in group byte[] buffer = new byte[1000];

for(int i=0; i< 3; i++) { DatagramPacket messageIn =

new DatagramPacket(buffer, buffer.length); s.receive(messageIn); System.out.println("Received:" + new String(messageIn.getData())); }

s.leaveGroup(group); }catch (SocketException e){System.out.println("Socket: " + e.getMessage());

}catch (IOException e){System.out.println("IO: " + e.getMessage());}}finally {if(s != null) s.close();}

} }

Page 38: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Reliability and ordering of multicast

• Failures– Omission failures (at chapter 2)– Ordering issue

• Some examples of the effects of reliability and ordering– Fault tolerance based on replicated services

• if one of them misses a request, it will become inconsistent with the others

– Finding the discovery servers in spontaneous networking• an occasional lost request is not an issue when locating a discovery

server

• Reliable multicast or unreliable multicast? – According to application’s requirement

Page 39: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Introduction

• The API for the Internet protocols

• External data representation and marshalling

• Client-Server communication

• Group communication

• Case study: interprocess communication in UNIX

• Summary

Chapter 4: Interprocess Communication

Page 40: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

UNIX socket

• Datagram communication– Datagram Socket– Bind– Sendto– recvfrom

• Stream communication– stream socket , bind– Accept– Connect– Write and read

Page 41: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Sockets used for datagrams

ServerAddress and ClientAddress are socket addresses

Sending a message Receiving a message

bind(s, ClientAddress)

sendto(s, "message", ServerAddress)

bind(s, ServerAddress)

amount = recvfrom(s, buffer, from)

s = socket(AF_INET, SOCK_DGRAM, 0)s = socket(AF_INET, SOCK_DGRAM, 0)

Page 42: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Sockets used for streams

Requesting a connection Listening and accepting a connection

bind(s, ServerAddress);listen(s,5);

sNew = accept(s, ClientAddress);

n = read(sNew, buffer, amount)

s = socket(AF_INET, SOCK_STREAM,0)

connect(s, ServerAddress)

write(s, "message", length)

s = socket(AF_INET, SOCK_STREAM,0)

ServerAddress and ClientAddress are socket addresses

Page 43: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Introduction

• The API for the Internet protocols

• External data representation and marshalling

• Client-Server communication

• Group communication

• Case study: interprocess communication in UNIX

• Summary

Chapter 4: Interprocess Communication

Page 44: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

• Two alternative building blocks– Datagram Socket: based on UDP, efficient but suffer from

failures

– Stream Socket: based on TCP, reliable but expensive

• Marshalling– CORBA’s CDR and Java serialization

• Request-Reply protocol– Base on UDP or TCP

• Multicast– IP multicast is a simple multicast protocol

Summary

Page 45: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

TUTORIAL QUESTIONS

Page 46: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.1

• Is it conceivably useful for a port to have several receivers?

page 128

Page 47: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.2

• A server creates a port which it uses to receive requests from clients. Discuss the design issues concerning the relationship between the name of this port and the names used by clients.

page 128

Page 48: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.3

• The programs in Figure 4.3 and Figure 4.4 are available at cdk3.net/ipc. Use them to make a test kit to determine the conditions in which datagrams are sometimes dropped. Hint: the client program should be able to vary the number of messages sent and their size; the server should detect when a message from a particular client is missed.

page 130

Page 49: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.4

• Use the program in Figure 4.3 to make a client program that repeatedly reads a line of input from the user, sends it to the server in a UDP datagram message, then receives a message from the server. The client sets a timeout on its socket so that it can inform the user when the server does not reply. Test this client program with the server in Figure 4.4.

page 130

Page 50: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.5

• The programs in Figure 4.5 and Figure 4.6 are available at cdk3.net/ipc. Modify them so that the client repeatedly takes a line of user’s input and writes it to the stream and the server reads repeatedly from the stream, printing out the result of each read. Make a comparison between sending data in UDP datagram messages and over a stream.

page 134

Page 51: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.6

• Use the programs developed in Exercise 4.5 to test the effect on the sender when the receiver crashes and vice-versa.

page 134

Page 52: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.7

• Sun XDR marshals data by converting it into a standard big-endian form before transmission. Discuss the advantages and disadvantages of this method when compared with CORBA’s CDR.

page 140

Page 53: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.8

• Sun XDR aligns each primitive value on a four byte boundary, whereas CORBA CDR aligns a primitive value of size n on an n-byte boundary. Discuss the trade-offs in choosing the sizes occupied by primitive values.

page 140

Page 54: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.9

• Why is there no explicit data-typing in CORBA CDR?

page 140

Page 55: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.10• Write an algorithm in pseudocode to describe the

serialization procedure described in Section 4.3.2. The algorithm should show when handles are defined or substituted for classes and instances. Describe the serialized form that your algorithm would produce when serializing an instance of the following class Couple.

class Couple implements Serializable{private Person one;private Person two;public Couple(Person a, Person b) {

one = a;two = b;

}

} page 142

Page 56: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.11

• Write an algorithm in pseudocode to describe deserialization of the serialized form produced by the algorithm defined in Exercise 4.10. Hint: use reflection to create a class from its name, to create a constructor from its parameter types and to create a new instance of an object from the constructor and the argument values.

page 142

Page 57: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.12

• Define a class whose instances represent remote object references. It should contain information similar to that shown in Figure 4.10 and should provide access methods needed by the request-reply protocol. Explain how each of the access methods will be used by that protocol. Give a justification for the type chosen for the instance variable containing information about the interface of the remote object.

page 144

Page 58: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.13

• Define a class whose instances represent request and reply messages as illustrated in Figure 4.13. The class should provide a pair of constructors, one for request messages and the other for reply messages, showing how the request identifier is assigned. It should also provide a method to marshal itself into an array of bytes and to unmarshal an array of bytes into an instance.

page 144

Page 59: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.14

• Program each of the three operations of the request-reply protocol in Figure 4.12, using UDP communication, but without adding any fault-tolerance measures. You should use the classes you defined in Exercise 4.12 and Exercise 4.13.

page 146

Page 60: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.15

• Give an outline of the server implementation showing how the operations getRequest and sendReply are used by a server that creates a new thread to execute each client request. Indicate how the server will copy the requestId from the request message into the reply message and how it will obtain the client IP address and port.

page 146

Page 61: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.16

• Define a new version of the doOperation method that sets a timeout on waiting for the reply message. After a timeout, it retransmits the request message n times. If there is still no reply, it informs the caller.

page 148

Page 62: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.17

• Describe a scenario in which a client could receive a reply from an earlier call.

page 146

Page 63: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.18

• Describe the ways in which the request-reply protocol masks the heterogeneity of operating systems and of computer networks. page 146

Page 64: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.19

• Discuss whether the following operations are idempotent:

• Pressing a lift (elevator) request button;

• Writing data to a file;

• Appending data to a file.

Is it a necessary condition for idempotence that the operation should not be associated with any state?

page 148

Page 65: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.20

• Explain the design choices that are relevant to minimizing the amount of reply data held at a server. Compare the storage requirements when the RR and RRA protocols are used.

page 148

Page 66: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.21

• Assume the RRA protocol is in use. How long should servers retain unacknowledged reply data? Should servers repeatedly send the reply in an attempt to receive an acknowledgement?

page 148

Page 67: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.22

• Why might the number of messages exchanged in a protocol be more significant to performance than the total amount of data sent? Design a variant of the RRA protocol in which the acknowledgement is piggy-backed on, that is, transmitted in the same message as, the next request where appropriate, and otherwise sent as a separate message. (Hint: use an extra timer in the client.)

page 148

Page 68: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.23

• IP multicast provides a service that suffers from omission failures. Make a test kit, possibly based on the program in Figure 4.17, to discover the conditions under which a multicast message is sometimes dropped by one of the members of the multicast group. The test kit should be designed to allow for multiple sending processes.

page 154

Page 69: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.24

• Outline the design of a scheme that uses message retransmissions with IP multicast to overcome the problem of dropped messages. Your scheme should take the following points into account:

i) there may be multiple senders;

ii)generally only a small proportion of messages are dropped;

iii) unlike the request-reply protocol, recipients may not necessarily send a message within any particular time limit.

Assume that messages that are not dropped arrive in sender ordering.

page 157

Page 70: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.25

• Your solution to Exercise 4.24 should have overcome the problem of dropped messages in IP multicast. In what sense does your solution differ from the definition of reliable multicast?

page 157

Page 71: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.26

• Devise a scenario in which multicasts sent by different clients are delivered in different orders at two group members. Assume that some form of message retransmissions are in use, but that messages that are not dropped arrive in sender ordering. Suggest how recipients might remedy this situation.

page 157

Page 72: Heterogeneity Applies to all of the following: –networks Internet protocols mask the differences between networks –computer hardware e.g. data types such.

Exercise 4.27

• Define the semantics for and design a protocol for a group form of request-reply interaction, for example using IP multicast.

pages 146, 154