Chapter 2
Chapter 2
1 11/13/2024
Contents
Characterization of Distributed systems
Issues of Distributed System
Architectures
Networking and Internetworking
Inter-process Communication
2 11/13/2024
Networks vs. Distributed Systems
Networks: A media for interconnecting local and wide area computers
and exchange messages based on protocols. Network entities are visible
and they are explicitly addressed (IP address).
Distributed System: existence of multiple autonomous computers is
transparent
However,
Networks focuses on packets, routing, etc., whereas distributed
systems focus on applications.
Every distributed system relies on services provided by a computer
network.
3 11/13/2024
Why Distributed System?
Functional distribution: computers have different functional
capabilities (i.e., sharing of resources with specific functionalities).
Load distribution / balancing: assign tasks to processors such that the
overall system performance is optimized.
Replication of processing power: independent processors working on
the same task:
Physical separation: systems that rely on the fact that computers are
physically separated
Economics: collections of microprocessors offer a better
price/performance ration than large mainframes.
4 11/13/2024
Examples: Internet
The Internet is a vast interconnected collection of computer networks of
many types.
Its design enabling a program running anywhere to address messages to
programs anywhere else.
Allowing its users to make use of many services as: WWW, E-Mail,
Web hosting, and File transfer.
Its services can be extended by adding new types of service
Small organizations and individual users can access to internet services
through Internet Service Providers (ISPs).
Independent intranets are linked together by high transmission capacity
circuits called backbones.
5 11/13/2024
Examples: Internet
6 11/13/2024
Examples: Intranet
An Intranet is a portion of the internet that is administrated separately and its local
security policies are enforced by a configured boundary.
Composed of several local area networks (LANs) linked by backbone connections to
allow its users to access the provided services.
Connected to the Internet via a router which allows its users to make use of the internet
services elsewhere.
Many organization protect their own services from unauthorized use by filtering
incoming and outgoing messages using a firewall.
email server Desktop
computers
print and other servers
Local area
Web server network
email server
print
File server
other servers
the rest of
the Internet
router/firewall
7 11/13/2024
Examples: Mobile and Ubiquitous Computing
Mobile Computing: This involves using portable computing devices (like
smartphones, tablets, and laptops) to perform tasks while on the move.
It relies on wireless technologies to provide access to resources and services,
enabling users to stay connected and productive regardless of their location.
Ubiquitous Computing: Also known as pervasive computing, this concept
predicts a world where computing is seamlessly integrated into the
environment.
It involves embedding microprocessors in everyday objects, allowing them to
communicate and perform useful tasks without requiring direct human
interaction.
The goal is to create an environment where technology is omnipresent but
unobtrusive, enhancing the user’s experience by making technology more
intuitive and accessible.
8 11/13/2024
Characterization of Distributed systems
Distributed systems are composed of multiple independent computers that work
together as a unified system. Here are some key characteristics:
Resource Sharing: Distributed systems can share hardware, software, and data
across multiple nodes.
Concurrency: Multiple tasks are processed simultaneously, improving
performance and response times.
Scalability: The system can easily scale up by adding more machines to handle
increased load.
Fault Tolerance: The system is designed to continue functioning even if some
components fail.
Transparency: The complexity of the system is hidden from users, making it
appear as a single coherent system.
Decentralization: Control is distributed across the network, reducing the risk
of a single point of failure
9 11/13/2024
Issues of Distributed System
Distributed systems offer many advantages, but they also come with several
challenges. Here are some of the key issues:
Fault Tolerance: Ensuring the system continues to operate despite failures in
some of its components can be complex or rear. This often requires redundancy
and sophisticated error detection and recovery mechanisms.
Scalability: As the system grows, maintaining performance and efficiency can
be difficult. This involves managing increased load and ensuring that the
system can scale horizontally by adding more nodes.
Consistency: Keeping data consistent across all nodes in the system is
challenging, especially in the presence of network partitions or failures.
Techniques like eventual consistency are often used, but they come with trade-
offs.
10 11/13/2024
Issues of Distributed System
Security: Protecting data and resources from unauthorized access is crucial.
Distributed systems are more vulnerable to security breaches due to their
multiple points of entry.
Latency: Communication delays between nodes can affect the performance of
the system. This is particularly problematic in real-time applications where
timely responses are critical.
Complexity: Designing, developing, and maintaining a distributed system is
inherently more complex than a centralized system. This includes handling
issues like synchronization, data distribution, and fault tolerance.
Network Issues: The network can lose, delay, duplicate, or reorder messages,
making reliable communication a significant challenge
11 11/13/2024
Architectures
Distributed systems are complex pieces of software of which the
components are by definition dispersed across multiple machines.
In order to manage their basic complexity, distributed systems should be
properly organized.
Organization of a distributed system is mostly expressed in terms of its
software components.
Different ways to look at organization of distributed systems two
obvious ones:
Software architecture logical organization (of software
components and interconnections)
System architecture physical realization (the instantiation of
software components on real machines)
12 11/13/2024
Architectures
Software architecture
logical organization of distributed systems into software components
A architectural style is formulated in terms of:
Types of components
The way that components are connected to each other
The data exchanged between components
How these elements are jointly configured into a system.
Software component - a modular unit with well-defined, required and
provided interfaces that is replaceable within its environment
Connector - a mechanism that mediates communication, coordination,
or cooperation among component
e.g. a connector can be formed by the facilities for (remote)
procedure calls, message passing, or streaming data.
13 11/13/2024
Architectures
Using components and connectors, we can come to various
configurations, which in turn have been classified into four main
architectural styles:
Layered architectures
Object-based architectures
Data-centered architectures
Event-based architectures
14 11/13/2024
Architectural styles: Layered architectures
Components are organized in a layered fashion where components of a
layer only call components of the layer below, and are only called by the
components of the layer above.
”Mult-level client-server” Each layer acts as a
Server: Service provider to layer ”above”
Client: service consumer of layers(s) ”below:
Connectors are protocols of layer interaction
15 11/13/2024
Architectural styles: Object-based architectures
16 11/13/2024
Architectural styles: Data-centered architectures
Access and update of data stored is the main purpose of the system.
Processes communicate info primarily by reading and modifying data in
some shared repository;
e.g., a shared distributed file system , database
Components:
Data store
Client interact with store
Connectors:
Queries
17 11/13/2024
Architectural styles: Data-centered architectures
18 11/13/2024
Architectural styles: Event-based architectures
19 11/13/2024
Architectural styles: shared data spaces
Event-based architectures can be combined with data-centered
architectures, yielding what is also known as shared data spaces.
processes are decoupled in time
20 11/13/2024
System Architectures
Deciding on software components, their interaction, and their placement
leads to an instance of a software architecture, also called a system
architecture.
System architectures can usually be characterized as examples of one or
more architectural styles
The realization of an architecture may be:
Centralized - most components located on a single machine
Decentralized - most machines have approximately the same
functionality
Hybrid - some combination
21 11/13/2024
Centralized Architectures
22 11/13/2024
Centralized Architectures
Communication between client and server can be:
By a connectionless protocol if the underlying network is fairly reliable;
efficient since there is no much overhead. E.g ,UDP
but assuring reliability is difficult
when messages are lost or corrupted let the client send the request
again; applicable only for idempotent operations
an operation is idempotent (unchanged) if it can be repeated
multiple times without harm; e.g., reading a record in a database
By reliable connection-oriented protocol if the underlying
network is unreliable. E.g, TCP
establishing and terminating connections is expensive
23 11/13/2024
Centralized Architectures: Layered architecture for Client-Server systems
24 11/13/2024
Centralized Architectures: Layered architecture for Client-Server systems
25 11/13/2024
Centralized Architectures: Multi-Tiered Architectures
26 11/13/2024
Centralized Architectures: Multi-Tiered Architectures
27 11/13/2024
Centralized Architectures: Multi-Tiered Architectures
Traditional two-tiered configurations
28 11/13/2024
Centralized Architectures: Multi-Tiered Architectures
29 11/13/2024
Decentralized Architectures: Vertical vs. Horizontal
30 11/13/2024
Decentralized Architectures: Vertical vs. Horizontal
31 11/13/2024
Decentralized Architectures: Peer-to-Peer Systems
32 11/13/2024
Hybrid Architectures
33 11/13/2024
Networking and Internetworking
Communication Subsystem
The hardware and software within a distributed system which provides
the communication facilities is known as the communication subsystem.
Consists of:
Transmission media: providing the physical connectivity, e.g. wire,
cable, fibre and wireless channels;
Hardware devices: providing the linkage, e.g. routers, bridges, hubs,
repeaters, network interfaces and gateways;
Software components: managing the communication, e.g. protocol
stacks, communication handlers and drivers.
34 11/13/2024
Networking and Internetworking
Impact on Distributed Systems
The communication impact on a distributed system will be one of the delay
introduced by the message passing (Message passing is the most fundamental
paradigm for distributed applications.
A process sends a message representing a request. The message is delivered to
a receiver, which processes the request, and sends a message in response).
The delay experienced by each individual message can be broken down into
two factors:
Latency: is the time which is necessary to set up the communication, i.e. it
is the delay incurred from the time the message is sent until it starts to
arrive at the destination.
Transmission delay: determined by the length of the message and the data
transfer rate, the speed of data transfer between two computers in the
network, usually in bits per second.
35 11/13/2024
Networking and Internetworking
36 11/13/2024
Networking and Internetworking: Network Types
Wired Network Types
1. Local Area Networks (LAN)
floor/building-wide
single communication medium
no routing, broadcast
segments connected by switches or hubs
high bandwidth, low latency
Ethernet - 10Mbps, 100Mbps, 1Gbps
Personal area networks (PAN) [ad-hoc networks]: blue tooth, infra-red
for PDAs, cell phones, …
37 11/13/2024
Networking and Internetworking: Network Types
2. Metropolitan Area Networks (MAN)
City-wide, up to 50 km
Digital Subscriber Line (DSL): 0.25 - 8 Mbps, 5.5km from switch
Cable modem: 1.5 Mbps, longer range than DSL
3. Wide Area Networks (WAN)
World-wide
Different organizations
Large distances
routed, latency 0.1 - 0.5 seconds
Commonly 1-10 Mbps (upto 600 Mbps)
38 11/13/2024
Networking and Internetworking: Network Types
Wireless Network Types
1.Wireless local area networks (WLAN)
IEEE 802.11 (WiFi)
10-100 Mbps, 1.5km
802.11 (1997): upto 2 Mbps, 2.4 GHz
802.11a (1999): upto 54 Mbps, 5 GHz, ~75 feet outdoor
802.11b (1999): upto 11 Mbps, 2.4 GHz, ~150 feet [most popular]
802.11g (2003): upto 54 Mbps, 2.4 GHz, ~150 feet [backward
compatible with 802.11b, becoming more popular]
2. Wireless metropolitan area networks (WMAN)
IEEE 802.16 (WiMax)
1.5-20 Mbps, 5-50km
39 11/13/2024
Networking and Internetworking: Network Types
3. Wireless wide area networks (WWAN)
worldwide
GSM (Global System for Mobile communications)
9.6 – 33 kbps
3G (“third generation”): 128-384 kbps to 2Mbps
Internetworks
Several networks linked together to provide common data communication facilities.
Needed for developing open distributed systems that contain very large numbers of
computers.
Interconnected by dedicated switching computers, routers, and general purpose
computers, gateways.
Routers: Responsible for forwarding the internetwork packets arrived on any
connection to the correct outgoing connection and maintain routing tables for that
purpose.
Bridges: Link networks of different types.
40 11/13/2024
Networking and Internetworking: Network Types
41 11/13/2024
Networking and Internetworking: Networking Principles
Packet transmission
A packet is a sequence of binary data with addressing information to identify the source
and destination computers.
A network message with arbitrary length is divided before transmission into packets of
restricted length.
Switching Schemes
A switching system is required to transmit information between two arbitrary nodes in
the network using shared communications link.
Four types of switching are used in computer network:
1. Broadcast:
Requires no switches.
All messages are sent to all connected computers.
Each computer is responsible extracting messages addressed to itself.
Used approach in Ethernet and wireless networks.
42 11/13/2024
Networking and Internetworking: Networking Principles
2. Circuit switching:
Approach taken in the telephone system.
A physical link is established between the sender and the receiver.
3. Packet switching:
Otherwise known as store-and-forward (postal system).
At each switching node (connection point) a computer manages the packets by reading
each one into memory, examining its destination, and choosing an outgoing circuit
appropriately.
4. Frame relay:
Reading in and storing the whole of each packet introduces a performance overhead
which can become significant.
In ATM networks a frame of fixed size is used in place of a packet and only its header
needs to be examined.
The remainder of the frame is simply relayed as a stream of bits.
43 11/13/2024
Networking and Internetworking: Networking Principles
2. Circuit switching:
Approach taken in the telephone system.
A physical link is established between the sender and the receiver.
3. Packet switching:
Otherwise known as store-and-forward (postal system).
At each switching node (connection point) a computer manages the packets by reading
each one into memory, examining its destination, and choosing an outgoing circuit
appropriately.
4. Frame relay:
Reading in and storing the whole of each packet introduces a performance overhead
which can become significant.
In ATM networks a frame of fixed size is used in place of a packet and only its header
needs to be examined.
The remainder of the frame is simply relayed as a stream of bits.
44 11/13/2024
Networking and Internetworking: Protocols
A well-known set of rules and formats used for communication
between processes to perform a given task.
A complete set of protocol layers is referred to as a protocol suite
or protocol stack.
OSI TCP/IP
45 11/13/2024
Networking and Internetworking: Protocols
Each of the Seven Layers of the OSI Model Represents Functions Required for
Communication
Number Name Interpretation
1 Physical Layer how devices are physically connected
2 Data Link Layer how neighboring devices communicate
3 Network Layer how non-neighboring devices communicate
4 Transport Layer how to avoid communication errors
how devices managing ongoing
5 Session Layer
communication
6 Presentation Layer how devices agree on the format of data
7 Application Layer how devices agree on the meaning of data
46 11/13/2024
Networking and Internetworking: Protocols
Internet Protocols
TCP is a reliable connection-oriented protocol used to transport streams of data.
Another transport protocol (User Datagram Protocol UDP) is used to meet
traditional message-based communication.
IP is the underlying network protocol that provide the basic transmission
mechanism for the Internet and other subnets.
IP Addressing
Used scheme for assigning addresses to networks and the computers connected
to them.
IPv4 (1984): 32-bit addresses for 232 (~ 4 billion) addresses, but insufficient
due to:
i) Unforeseen growth of internet.
ii) Inefficient use of address space.
IPv6 (1994): 128-bit addresses for 2128 (~ 3x1038) addressable nodes.
47 11/13/2024
Inter Process Communication(IPC)
IPC refers Communication between two different processes by message passing.
Types of communication
48 11/13/2024
Inter Process Communication(IPC)
Characteristics of IPC
Message passing between a pair of processes supported by two communication
operations: Send and Receive.
A queue is associated with each message destination regarded as a buffer between the
sender and receiver:
When the buffer is empty the receiver must wait.
When the buffer is full the sender must wait, or messages will be lost.
Communication is termed as synchronous or asynchronous depending on the degree of
coordination imposed between sender and receiver:
Synchronous: both send and receive are blocking operations:
Sender blocks until a receive is issued
Receiver blocks until a message arrives.
Asynchronous: send operation is non-blocking
Sender is non-blocking (copy goes to its local buffer)
Receiver blocking (ALWAYS) or non-blocking (out of control flow).
49 11/13/2024
Inter Process Communication(IPC)
Ports and Sockets
Communication between processes is made between ports.
Each computer has 216 possible ports represented by integer numbers:
some ports have specific use but others are available for general use.
Each port corresponds to a single receiving process, but each process may have
more than one port at which it receives.
Any number of senders can send messages to a port.
Sockets are software abstractions of ports used within running processes.
Messages are sent between a pair of sockets.
Sockets need to be bound to a port number and a host IP address in order to be
useable for sending and receiving messages.
Socket binding may be automatic (Java) or done explicitly (BSD UNIX).
Each socket is associated with a particular transport protocol, i.e. UDP (datagrams)
or TCP (streams).
50 11/13/2024
IPC Communication using UDP
UDP is suitable for applications that need low overheads and accepting
occasional omission failures.
A datagram is communicated between processes when one process sends it and
the other receives it.
Datagrams sent from socket to socket without acknowledgement or reliability.
A server binds its socket to a specific server port known to clients but a client
binds its socket to any free port.
Sender socket information is passed with the datagram content so that a reply
can be sent.
The receiver must specify a buffer of a particular size (8 KBytes in most
implementations) to place received message.
51 11/13/2024
IPC Communication using UDP
Datagram communication provides non-blocking sends and blocking receives although
timeouts can be set.
Timeouts can be set on receiver socket to forbid indefinitely waiting in case of crashed
sender or lost message.
Disadvantages of UDP transmission
Datagrams can be dropped because of
Full Buffers
Checksum Failure
Messages can arrive out of order
UDP Applications
Where failures are tolerable
DNS
VOIP
Where overheads are costly
52 11/13/2024
IPC Communication using UDP
Java API for Internet Addresses
The java.net package is intended to provide an application programmer with a
powerful infrastructure for networking:
Java provides three basic socket classes:
DatagramSocket for datagram communication and
Both of ServerSocket and Socket for stream (TCP) communication.
Java includes classes for representing URLs (the URL class) and Internet
addresses (the InetAddress class).
InetAddress aComputer = InetAddress.getByName(“wassif.ccis.ksu.edu.sa");
53 11/13/2024
IPC Communication using UDP
Java API for UDP Datagrams
Java API provides datagram communication by two classes:
DatagramPacket:
Has a constructor to create datagram packets comprising a message, its length, and
destination socket information
Has another constructor to put a received message into that packet.
The message can be retrieved using getData method and the Internet address and
the port are accessed by getAddress and getPort methods.
DatagramSocket:
Supports sockets for sending and receiving UDP datagrams.
Has a constructor with a port number as argument to tie that port, if a particular port is
needed, or without argument to use any free local port.
send and receive methods are used for transmitting datagrams between a pair of sockets.
The method setSoTimeout allows a timeouts to be set and connect method is used for
connecting a socket to a particular remote port and host address.
54 11/13/2024
IPC Communication using TCP
TCP offers the following characteristics:
No restriction about message sizes:
Guarantee message delivery using acknowledgment scheme:
Attempt to match the speeds of reader and writer processes:
Guarantee unduplication and ordering of messages:
Message identifiers enable the receiver to detect and reject duplicates or to
reorder messages not arrived in sender order
A pair of communicating processes establish a connection before they can
communicate over a stream:
The client role involves:
Creating a stream socket bound to any free port.
Making a connect request to a server at its server port.
55 11/13/2024
IPC Communication using TCP
The server role involves:
Creating a listening socket bound to a server port and waiting for clients to
request connections.
Making accept request to reply a client request at its port.
Creating a new stream socket to communicate with this client.
Keeping the listening socket for new connecting requests.
Once the connection is established the processes write to and read from the
stream without needing to use Internet addresses and ports.
Disadvantages
Timeout and retransmission
Connections can break down
No guarantee that connection will not break, so not fully reliable
Applications
Many services such as FTP, HTTP and SMTP uses TCP
56 11/13/2024
IPC Communication using TCP
Java API for TCP Streams
Java API provides stream communication by two classes:
ServerSocket:
Intended for use by a server to create a socket at a server port for listening
connect request from clients.
Has an accept method that is blocked until arriving of any request to create
an instance of stream socket.
Socket:
Used by a pair of processes with a stream connection.
Has a constructor used by the client to create its stream socket and send a
connect request to the specified remote server.
Provides getInputStream and getOutputStream methods for accessing the two
input and output streams associated with a socket.
read and write methods are used for bytes reading from and writing to
58 11/13/2024
IPC Communication using Message-Passing Interface(MPI)
59 11/13/2024
IPC Communication using Message-Passing Interface(MPI)
60 11/13/2024
i o n!
te nt
r a t
y o u
s fo r
a nk
Th
61 11/13/2024