DS Chapter4
DS Chapter4
Interprocess Communication
4.1 Introduction
1
2. Message Destination
➢ Message are sent to (Internet address, local port) pairs.
➢ A local port is a message destination within a computer, specified as an integer.
➢ A port has exactly one receiver but can have many senders.
➢ Any process that knows the number of a port can send a message to it.
➢ Servers generally publicize their port numbers for use by clients.
3. Reliability
➢ Reliable communication in terms of validity and integrity.
➢ As far as the validity property is concerned, a point-to-point message service can
be described as reliable if messages are guaranteed to be delivered despite a
‘reasonable’ number of packets being dropped or lost.
4. Ordering
➢ Some applications require that messages be delivered in sender order – that is, the
order in which they were transmitted by the sender.
➢ The delivery of messages out of sender order is regarded as a failure by such
applications.
4.2.2 Sockets
Socket
Socket provides an endpoint for communication between processes. For a process to receive
messages, its socket must be bound to a local port and one of the Internet addresses of the
computer on which it runs.
➢ Processes may use the same socket for sending and receiving messages.
➢ Each computer has a large number (216) of possible port numbers for use by local
processes for receiving messages.
➢ Any process may make use of multiple ports to receive messages.
2
➢ message size: up to 216, usually restrict to 8K
➢ blocking: non-blocking send, blocking receive
➢ timeouts: timeout on blocking receive
➢ receive from any: doesn't specify sender origin (possible to specify a
particular host for send and receive)
• use of UDP
➢ DNS, VoIP
➢ less overhead: no state information, extra messages, latency due to start up
Some issues:
➢ matching of data items: two processes need to agree on format and order
(protocol)
➢ blocking: non-blocking send, blocking receive (send might be blocked due to
flow control)
➢ concurrency: one receiver, multiple senders, one thread for each connection
The information stored in running programs is represented as data structures – for example, by
sets of interconnected objects – whereas the information in messages consists of sequences of
bytes. Irrespective of the form of communication used, the data structures must be flattened
(converted to a sequence of bytes) before transmission and rebuilt on arrival. The individual
primitive data items transmitted in messages can be data values of many different types, and
not all computers store primitive values such as integers in the same order.
One of the following methods can be used to enable any two computers to exchange binary
data values:
➢ The values are converted to an agreed external format before transmission and
converted to the local form on receipt; if the two computers are known to be the same
type, the conversion to external format can be omitted.
➢ The values are transmitted in the sender’s format, together with an indication of the
format used, and the recipient converts the values if necessary.
3
External data representation
An agreed standard for the representation of data structures and primitive values is
called an external data representation.
4
4.3.2 Java object serialization
• serialization and de-serialization are automatic in arguments and return values of
Remote Method Interface (RMI)
• flattened to be transmitted or stored on the disk
➢ write class information, types and names of instance variables
➢ new classes, recursively write class information, types, names...
➢ each class has a handle, for subsequent references
➢ values are in Universal Transfer Format (UTF)
5
• References are serialized as handles.
➢ It must ensure that each object is written once only
➢ second or subsequent occurrence of the object is written as a handle
• The use of reflection
➢ to enquire about about the properties (name, types, methods) of a class
6
XML namespace
• Name clashes within an application
• Namespaces: a set of names for a collection of element types and attributes
➢ xmlns: xml namespace
➢ pers: name of the name space (used as a prefix)
• http://www.cdk4.net/person : location of schema
XML schema
• Defines elements and attributes
• Similar to type definition
• xsd: namespace for xml schema definition
• A multicast group is specified by a class D addresses, first four bits are 1110 in IPv4.
• IP multicast is available only via UDP.
• Join a group via socket binding to the multicast address.
• Messages arriving on a host deliver them to all local sockets in the group.
• Multicast routers: route messages to out-going links that have members
• Multicast address allocation
➢ permanent
➢ temporary:
o no central registry by IP (one addr might have different groups)
o use (time to live) TTL to limit the distance propagation of hops
8
o tools like sd (session directory) can help manage multicast addresses and find
new ones
***********************************