Communications in Distributed Systems Study Guide
Basics of Communication Systems in Distributed Systems
In uniprocessor operating systems, inter-process communication (IPC) implicitly assumes the existence of shared memory (for example, shared memory solutions for the Producer-Consumer problem).
In distributed systems, there is no shared memory. All inter-process communication relies entirely on message passing across a communication network.
Protocols are predefined sets of rules adhered to by communicating processes to manage message structure, timing, sequence, and error control.
In Wide-Area Distributed Systems, protocols are structured into multiple hierarchical layers.
Major platforms for inter-process communication include:
Open Systems Interconnection (OSI) model
Asynchronous Transfer Mode (ATM)
Remote Procedure Calls (RPC)
Group Communication
Network Connections, Physical Topologies, and Network Types
Network: Two or more devices connected through physical or logical links.
Link: A communications pathway that transfers data from one device to another.
Types of Connections:
Point-to-Point: A dedicated communication channel shared exclusively between two devices or nodes.
Multi-Point: A single communication channel shared simultaneously among multiple devices or nodes (for example, a Bus topology).
Physical Topology: The geometric representation of the layout of links and connecting nodes in a network.
Mesh Topology (Fully Connected):
Every device has a dedicated point-to-point link to every other device.
For connected devices, the total number of dedicated physical links required is given by the combination formula:
Example: For devices, the required number of links is:

Star Topology:
All nodes connect directly to a central networking device (such as a router, switch, or hub).
The central device acts as a server/relay, while attached nodes act as clients.

Bus Topology (Line Topology):
All devices connect to a single primary backbone cable (the bus) via drop lines and cable taps.
All attached nodes receive transmitted signals simultaneously.

Ring Topology:
Devices are connected in a closed circular loop.
Each node connects directly to two adjacent neighbors using repeaters.
Data travels unidirectionally around the ring passing through intermediate nodes until it reaches its destination.

Network Classifications:
Local Area Network (LAN):
Connects devices within a limited physical site (building, office, home).
Scale ranges from single-user home networks to enterprise networks serving thousands of devices.
Built using components like cables, wireless access points, switches, and routers.
Evolution of Isolated LANs:
Past: Shared common coaxial cable with physical taps.
Today: Star-configured topology driven by central link-layer switches.

Wide Area Network (WAN):
Spans large geographical distances to interconnect individual LANs or subnets.
Primary technologies: Packet switching, TCP/IP protocol suite, router overlay networks (network virtualization).
Switched WAN: Utilizes internal switches across backbone networks with multiple connection endpoints.

Point-to-Point WAN: Dedicated point-to-point leased line connecting routers across long distances (for example, connecting a West Coast office LAN to an East Coast office LAN).

Heterogeneous Networks: Complex interconnections involving switched WANs, point-to-point WANs, routers, modems, and local subnets.

The Internet:
internet (lowercase i): Any collection of two or more distinct networks communicating together.
Internet (uppercase I): The global network of millions of interconnected networks.
Structural hierarchy: Customer networks connect to Provider networks, which interface via Peering Points to major high-speed Backbones.

Protocol Layering, TCP/IP Suite, and OSI Model
Principles of Protocol Layering:
Principle 1: Each layer must perform two opposite complementary tasks in each direction (for example, talk/listen, encrypt/decrypt, send/receive).
Principle 2: The protocols and shared objects at corresponding peer layers across communicating nodes must be identical.
Conceptual Protocol Models:
Single-Layer Protocol: Communication occurs directly through a single medium (for example, two people, Maria and Ann, speaking over air at Layer 1: Listen/Talk).

Three-Layer Protocol:
Layer 3: Listen/Talk (Plaintext objects shared logically).
Layer 2: Encrypt/Decrypt (Ciphertext objects shared logically).
Layer 1: Send/Receive Mail (Postal carrier mail objects transferred physically).
Logical connections exist horizontally between peer layers, while actual data moves vertically down through layers at the sender and up at the receiver.


TCP/IP Protocol Suite:
Consists of 5 functional layers:
Layer 5: Application Layer (Identical objects: Messages) — Responsible for process-to-process communication.
Layer 4: Transport Layer (Identical objects: Segments or User Datagrams) — Responsible for end-to-end service delivery between application processes.
Layer 3: Network Layer (Identical objects: Datagrams) — Responsible for host-to-host routing across intermediate routers.
Layer 2: Data Link Layer (Identical objects: Frames) — Responsible for moving datagrams across individual physical links.
Layer 1: Physical Layer (Identical objects: Bits) — Responsible for transmitting individual bits across physical media.




Open Systems Interconnection (OSI) Reference Model:
Established in 1947 by the International Organization for Standardization (ISO); introduced in the late 1970s.
Defines 7 standard layers:
Layer 7: Application
Layer 6: Presentation
Layer 5: Session
Layer 4: Transport
Layer 3: Network
Layer 2: Data Link
Layer 1: Physical

Comparison Between OSI and TCP/IP Models:
Session (Layer 5) and Presentation (Layer 6) layers are explicitly defined in OSI, but are absent as distinct layers in TCP/IP.
The Application Layer in TCP/IP combines the functionality of OSI's Application, Presentation, and Session layers.

Asynchronous Transfer Mode (ATM) Architecture
Overview of ATM:
High-speed, connection-oriented networking technology standardized by ITU-T (International Telecommunication Union - Telecommunication Standardization Sector).
Transfers voice, video, and data concurrently using fixed-size cells over virtual circuits.
Combines the predictable performance of circuit switching with the efficiency of packet switching.
ATM Operational Steps:
Sender establishes a virtual circuit connection to the receiver.
A designated route is calculated across intermediate switches.
Routing information is stored in lookup tables within switches along the path.
Data stream is segmented into fixed cells by hardware.
Routing state is cleared from switches when the connection terminates.
ATM Reference Layer Model:
Maps to OSI Layers 1 and 2:
ATM Physical Layer: Handles physical transmission media.
ATM Layer: Manages cell header generation, multiplexing, and virtual path/channel routing.
ATM Adaptation Layer (AAL): Serves as the interface between upper-layer application requirements and raw ATM cell transfer.

ATM Physical Layer Details:
Operates synchronously by transmitting empty cells when no data is queued.
Frequently deployed over SONET (Synchronous Optical NETwork).
SONET frame structure: Total size ( overhead + payload), yielding a gross data rate of .
Basic channel standard: Optical Carrier 1 (OC-1) at . OC-12 and OC-48 are used for long-haul backbones.
ATM Layer and Cell Header Architecture:
Total cell size: Fixed at ( header + payload).
Header Fields (User-to-Network Interface - UNI):
GFC (Generic Flow Control): — Controls local traffic flow at the user interface.
VPI (Virtual Path Identifier): — Identifies the virtual path bundle.
VCI (Virtual Channel Identifier): — Identifies the specific virtual channel.
Payload Type: — Distinguishes between user data cells and control cells.
CLP (Cell Loss Priority): — Indicates priority; cells with CLP are dropped first during congestion.
CRC / HEC (Header Error Control): — Cyclic redundancy check for error detection and single-bit error correction in the header.
ATM Adaptation Layer (AAL) Traffic Classes:
Constant Bit Rate (CBR): For real-time, uncompressed audio and video streams.
Variable Bit Rate (VBR): For delay-sensitive, compressed stream traffic.
Connection-oriented Data Traffic: For bursty, connection-oriented network protocols.
Connectionless Data Traffic: For standard datagram traffic.
SEAL (Simple and Efficient Adaptation Layer):
Uses 1 bit of the Payload Type field set to on the final cell of a frame.
Appends an trailer in the last cell containing:
Reserved fields: ( each, unused).
Packet Length: .
Checksum: .
ATM Switching:
Connects input lines to output lines through a switching fabric.
Head-of-Line (HOL) Blocking: Occurs when a cell at the front of an input queue is delayed, blocking all subsequent queued cells.
Solution: Implement copy buffering within output queues.

Evaluation of ATM Technology:
Advantages: High speed; unified transmission of voice, video, and data; standardized QoS guarantees (delay, jitter, cell loss ratio, bandwidth); fast hardware switching due to fixed cell size.
Disadvantages: Expensive specialized switches; complex configuration; fixed cell header overhead ( header per payload = overhead); sub-optimal for bursty data; setup latency for virtual circuit establishment; largely superseded by Ethernet, MPLS, and IP networks.
Client-Server Model and IPC Addressing
Inter-Process Communication (IPC):
Absence of shared memory in distributed systems mandates message-passing architectures.
Protocols dictate communication semantics.
Client-Server Architecture:
Based on a simple request/reply pattern.
Highly efficient: No connection setup before transmission and no connection teardown afterward.
Requires only 3 effective protocol layers (Physical/Data Link at Layers 1–2, Request/Reply at Layer 5).
Operating system micro-kernels provide two primary primitives:
send(dest, &mptr)receive(addr, &mptr)where
mptrpoints to the message buffer,destis the destination process ID, andaddris the source address.
Implementation Source Code Examples:
Header Definitions (
header.h):
/* Definitions needed by clients and servers. */
#define TRUE 1
#define MAX_PATH 255 /* maximum length of file name */
#define BUF_SIZE 1024 /* how much data to transfer at once */
#define FILE_SERVER 243/* file server's network address */
/* Definitions of the allowed operations */
#define CREATE 1 /* create a new file */
#define READ 2 /* read data from a file and return it */
#define WRITE 3 /* write data to a file */
#define DELETE 4 /* delete an existing file */
/* Error codes. */
#define OK 0
#define E_BAD_OPCODE -1 /* unknown operation requested */
#define E_BAD_PARAM -2 /* error in a parameter */
#define E_IO -3 /* disk error or other I/O error */
/* Definition of the message format. */
struct message {
long source; /* sender's identity */
long dest; /* receiver's identity */
long opcode; /* requested operation */
long count; /* number of bytes to transfer */
long offset; /* position in file to start I/O */
long result; /* result of the operation */
char name[MAX_PATH]; /* name of file being operated on */
char data[BUF_SIZE]; /* data to be read or written */
};
Server Main Loop:
#include <header.h>
void main(void) {
struct message m1, m2; /* incoming and outgoing messages */
int r; /* result code */
while(TRUE) { /* server runs forever */
receive(FILE_SERVER, &m1); /* block waiting for a message */
switch(m1.opcode) { /* dispatch on type of request */
case CREATE:
r = do_create(&m1, &m2);
break;
case READ:
r = do_read(&m1, &m2);
break;
case WRITE:
r = do_write(&m1, &m2);
break;
case DELETE:
r = do_delete(&m1, &m2);
break;
default:
r = E_BAD_OPCODE;
}
m2.result = r; /* return result to client */
send(m1.source, &m2); /* send reply */
}
}
Client Copy Procedure:
#include <header.h>
int copy(char *src, char *dst) {
struct message m1; /* message buffer */
long position; /* current file position */
long client = 110; /* client's address */
initialize(); /* prepare for execution */
position = 0;
do {
m1.opcode = READ;
m1.offset = position;
m1.count = BUF_SIZE; /* how many bytes to read */
strcpy(&m1.name, src); /* copy name of file to be read to message */
send(FILE_SERVER, &m1); /* send the message to the file server */
receive(client, &m1); /* block waiting for the reply */
/* Write the data just received to the destination file. */
m1.opcode = WRITE;
m1.offset = position;
m1.count = m1.result; /* how many bytes to write */
strcpy(&m1.name, dst); /* copy name of file to be written to buf */
send(FILE_SERVER, &m1); /* send the message to the file server */
receive(client, &m1); /* block waiting for the reply */
position += m1.result; /* m1.result is number of bytes written */
} while(m1.result > 0); /* iterate until done */
return(m1.result >= 0 ? OK : m1.result); /* return OK or error code */
}
Addressing Alternatives in Client-Server Systems:
Alternative 1 (Two-Part Names): Addressed as
machine.process(e.g.,243.4or4@243). Avoids global coordination because each host assigns process numbers locally.Alternative 2 (
machine.local-id): Process registers a local ID with its kernel. Lacks location transparency; if machine243crashes, compiled binaries referencing243fail even if service is migrated to machine365.Alternative 3 (Centralized Allocator): Centralized process address allocator issues globally unique IDs. Fails to scale due to central bottleneck.
Alternative 4 (Sparse Address Space + Broadcast): Processes choose random integers. Senders broadcast a
Locatepacket; the matching node responds with a "here I am" message containing its physical address.Drawback: High network overhead due to broadcasting.

Alternative 5 (Name Server Mapping): High-level ASCII service names are embedded in code. Senders query a Name Server to obtain the current machine address before sending requests.
Drawback: Replicated name servers present consistency challenges.
Message Passing Primitives
Synchronization Semantics:
Blocking (Synchronous) Send: The calling process is suspended until the message has been fully transmitted across the network interface.

Non-blocking (Asynchronous) Send: Control returns to the caller immediately, allowing processing to continue in parallel with network transmission.
Buffer reuse issue: The sender must not modify the buffer while transmission is underway.
Solution 1: Kernel copies the message to an internal kernel buffer immediately.
Drawback: Adds copy overhead from user space to kernel space.

Solution 2: User-level interrupt notifies the sender when the buffer becomes available.
Blocking Receive: The receiver halts until a message arrives in the designated buffer.
Non-blocking Receive: Control returns immediately after telling the kernel where the message buffer is located.
Arrival notification methods:
Polling: The receiver periodically checks buffer status using a test primitive.
Software Interrupt: The kernel asynchronously interrupts the receiver when a message arrives.
Buffering Semantics:
Unbuffered Primitives: Direct transfer without intermediate kernel queues.

Issue: If
send()is invoked beforereceive(), the receiving kernel cannot determine target buffer placement and may drop the packet.Mitigation: Pre-emptive receive design, timeouts, or buffered passing.
Buffered Primitives: Uses a mailbox data structure created by the process to store incoming messages until
receive()is called.
Reliability Semantics:
Unreliable: The system provides no delivery guarantees.
Request-ACK-Reply-ACK: Receiver kernel sends explicit acknowledgments for both request and reply packets.
Request-Reply-ACK: The server's reply acts as an implicit acknowledgment of the request; client kernel acknowledges the reply.
Client-Server Communication Implementation Options Matrix:
Addressing: Machine address | Sparse process addresses | Name Server lookup
Blocking: Blocking primitives | Nonblocking with kernel copy | Nonblocking with interrupt
Buffering: Unbuffered (discard unexpected) | Unbuffered (temporarily keep unexpected) | Mailboxes
Reliability: Unreliable | Request-ACK-Reply-ACK | Request-Reply-ACK
Packetization & Micro-Kernel Control Packet Types:
Large messages are split into multiple numbered packets containing sequence numbers.
Packet control codes:
REQ(Request): Client to Server — Request for service.REP(Reply): Server to Client — Reply containing result.ACK(Acknowledgment): Either direction — Confirms receipt of previous packet.AYA(Are You Alive?): Client to Server — Checks if server has crashed during long processing.IAA(I Am Alive): Server to Client — Confirms server is running.TA(Try Again): Server to Client — Indicates buffer full, retry later.AU(Address Unknown): Server to Client — Target process address does not exist.
Remote Procedure Call (RPC) Concepts and Mechanics
RPC Abstraction:
Allows programs to call procedures on remote hosts as if they were local procedure calls.
Calling and called procedures run in disjoint address spaces on different machines.
RPC Architectural Components:
Client Program, Client Stub, Client Kernel, Network Interface, Server Kernel, Server Stub, Server Program.

10-Step RPC Execution Sequence:
Client procedure calls the client stub in the standard local way.
Client stub builds a message packet and traps to the local kernel.
Client kernel transmits the message across the network to the remote kernel.
Remote server kernel passes the message to the server stub.
Server stub unpacks (unmarshals) parameters and calls the local server procedure.
Server procedure executes the computation and returns results to the server stub.
Server stub packs (marshals) results into a reply message and traps to the kernel.
Remote kernel sends the message back across the network to the client kernel.
Client kernel delivers the reply message to the client stub.
Client stub unpacks the result and returns execution control to the client caller.


Parameter Marshaling and Data Representation:
Marshaling: Converting procedure parameters and identifier numbers into a standard network message format.
Heterogeneity Challenges:
Character encodings differ (for example, EBCDIC on IBM Mainframes vs. ASCII on personal computers).
Integer representation differs (Big-endian vs. Little-endian byte ordering).
Floating-point representations differ across hardware architectures.
Interface Definition Language (IDL) compilers generate client and server stubs automatically to convert between native and standardized data representations transparently.
Dynamic Binding via Binder:
Exporting Interface (Server Registration):
Server registers its availability with a daemon called the Binder.
Sends server name, version number, unique identifier, and server handle (for example, Ethernet address, IP address, or process ID).
Importing Interface (Client Location):
Client stub queries Binder for a matching server name and version.
If found, Binder returns the handle and unique ID to the client stub, enabling direct communication.
RPC Failure Handling and Fault Tolerance
5 Classes of RPC Failures:
Client Unable to Locate Server:
Server may be down or running an incompatible interface version.
Handling mechanisms: Return error code (e.g., ), set
errno, or raise language exceptions.Limitation: Returning is ambiguous if is a valid procedure return value (e.g., ).
Lost Request Messages:
Kernel starts a retransmission timer upon sending.
If timer expires before an ACK/reply arrives, the kernel retransmits the message.
Lost Reply Messages:
Retransmission risks duplicate execution of operations.
Idempotent Operations: Safe to repeat multiple times without altering system state (for example, reading the first of a file).
Non-Idempotent Operations: Causes cumulative side effects if repeated (for example, transferring between bank accounts).
Safeguards: Client kernel assigns incremental sequence numbers; server kernel tracks sequence numbers to reject duplicate executions.
Server Crashes:
Scenarios: Normal completion, Crash after execution (before reply), Crash before execution.

Semantics:
At-least-once semantics: Retransmits repeatedly until server reboots; guarantees execution times.
At-most-once semantics: Reports immediate failure upon crash; guarantees execution times (0 or 1).
No guarantees: Execution occurs anywhere from 0 to many times.
Client Crashes and Orphan Handling:
Orphan: An active remote computation whose calling client process has crashed.
Problems: Wasted CPU cycles, locked files/data, stale replies confusing rebooted clients.
Recovery Strategies:
Extermination: Client stub logs RPC intent to disk before sending. Upon reboot, disk logs are scanned to kill active orphans (expensive disk I/O).
Reincarnation: Time is divided into numbered epochs. Client reboot broadcasts a new epoch number, automatically killing remote computations tied to older epochs.
Gentle Reincarnation: Upon epoch broadcast, nodes verify owner status before terminating computations.
Expiration: Each RPC is allocated time quantum . If uncompleted, it must request extensions; after client crash, servers wait time before rebooting to ensure orphan expiration.
RPC Performance Optimization and Critical Path
Performance Factors:
System performance depends directly on communication speed.
Key optimization areas: Protocol Selection, Acknowledgments, Critical Path length, Memory Copying, Timer Management.
RPC Protocol Selection:
Connection-Oriented (WANs) vs. Connectionless (LANs).
Standard Protocols (IP/UDP) vs. Specialized RPC Protocols:
Standard protocols save development time, but IP overhead (13 header fields, checksum calculations, TCP layering) degrades local performance.
Specialized RPC protocols avoid unnecessary protocol bouncing across local subnets.
Packet/Message Length:
Large payload transfers (e.g., ) split into many small packets (e.g., ) introduce high header overhead.
Constraints: Sun Microsystems limit is ; Ethernet MTU limit is .
Automatic Repeat Request (ARQ) Algorithms:
Stop-and-Wait ARQ:
Sender transmits 1 packet and waits for an ACK before sending the next.
Uses a 1-bit sequence number ( or ) to detect duplicate frames and ACKs.
Inefficiency Analysis Example:
One-way propagation delay , Bandwidth , Packet size .
Transmission time .
Round-Trip Time (RTT) .
Throughput .
Link capacity utilization .
Sliding Window Protocol:
Sender parameters: Sender Window Size (SWS), Last ACK Received (LAR), Last Frame Sent (LFS).
Receiver parameters: Receiver Window Size (RWS), Last Frame Received (LFR), Last Acceptable Frame (LAF).
Window boundary constraint:
Sequence number space requirement:
Go-Back-N ARQ:
Receiver sends cumulative ACKs.
Upon timeout, sender retransmits all unacknowledged packets in the current window.

Selective Repeat / Selective ACK ARQ:
Receiver individually acknowledges all correctly received out-of-order packets and buffers them.
Sender retransmits only missing/unacknowledged packets.

RPC Critical Path Analysis:
Sequence of instructions executed on every RPC call.
14 Steps in Client-to-Server Execution Path:
Call stub procedure
Get message buffer
Marshal parameters into buffer
Fill in message header fields
Compute UDP checksum
Trap to kernel
Queue packet for transmission
Move packet to controller over system bus
Ethernet physical transmission
Receive packet from controller on target machine
Interrupt service routine execution
Compute UDP checksum on receiver
Context switch to user space
Server stub execution
Primary performance bottlenecks: Marshaling parameters, kernel context switches, interrupt processing, timer maintenance.
Memory Copying Optimization:
RPC messages can be copied up to 8 times between user and kernel spaces during execution.
Elimination techniques:
Hardware Scatter-Gather: Network controller performs Direct Memory Access (DMA) transfers directly from user-space stub buffers.
Virtual Memory Page Mapping: Kernel updates page table maps instead of physically copying memory bytes.
Timer Management Systems:
Sorted List Approach: Maintains timeouts in a sorted linked list; requires list updates upon packet transmission and ACK arrival.
Process Table Approach (Kernel Sweep Algorithm): Each process table entry stores a timer value. The kernel periodically sweeps the process table to check active timers against current system time .
Summary Review Questions
Draw the block diagram of the OSI Reference Model and the TCP/IP Protocol Suite, detailing the synchronization and mapping between corresponding layers.
Explain the specific networking functionalities and operational layers of key hardware devices: Hub, Bridge, Unmanaged Switch, Managed Switch, Router, Brouter, and Gateway.