Outline

Communication Protocols

Layered Protocols

A message as it appears on the network may contain headers/trailers that encapsulate the message as it traverse through the different layers in the OSI model. We can look at the OSI model in detail.

Physical Layer

  • Goal: Raw bits over some communication channel
  • Sample Issues:
    • How to encode a 0 or 1
    • What voltage should be uesd?
    • How long does a bit need to be signaled?
    • What kind of cable should be used?
  • Example:
    • Modems

Network Layer

  • Goal: Route packets from the source to destination
  • Sample Issues:
    • How to route packets that have to travel several hops?
    • Congestion control algorithm: traffic shaping, flow specifications, and bandwith reservation
    • Accounting - charge for use of the network
    • Fragment or combine packets depending on rules of link layer
  • Examples:
    • IP

Transport Layer

  • Goal: Accurately transport session data in order
  • Sample Issues:
    • How to order messages and detect duplicates
    • Error detection (corrupt packets) and retransmission
    • Connectionless or connection-oriented
  • Examples:
    • TCP/UDP

Session and Presentation Layer

  • Goal: Common services shared by several apps
  • Sample Issues:
    • Allows users on different machines to establish sesions between them
    • Encodes data in a standard agreed upon way

Application Layer

  • Goal: Common types of exchanges standardized
  • Examples: FTP, SMTP, HTTP

Middleware Protocols

Middleware:

Remote Procedure Call (RPC)

In distributed systems, the callee can be on a one system, and the caller on another.

Goal: Make RPC look like a local procedure call

Conventional Procedure Call

Parameters are pushed onto the stack, then the return address, and then the local variables are pushed onto the stack.

Observations

Parameters in C:

  • call by reference OR call by value
  • Value parameters include like numbers, characters, etc.
  • Reference parameters include pointers, or addresses in our address space.
  • Many options are language dependent

Remote procedure calls can simulate this through:

  • Stubs – procies
  • Marshalling

Stubs

  • Suppose a client makes a procedure call (just like a local procedure call), but to a client stub
  • Server is written as a standard procedure
  • The stubs take care of packaging arguments, and sending messages
  • The packaging is called marshalling
  • Stub compilers can automatically generate stubs from specs in an IDL (interface definition language)

Steps of a Remote Procedure Call

  1. Client procedure calls client stub normally
  2. Stub builds message, calls local OS
  3. Client’s OS sends message to remote OS
  4. Remote OS gives message to server stub
  5. Server stub unpacks parameters, calls server
  6. Server does work, returns result to the stub
  7. Server stub packs it into a message, calls local OS
  8. Server OS sends message to client OS
  9. Client OS gives message to client stub
  10. Client Stub unpacks result, and returns to client

Marshalling: Value Parameters

Problem: Different machines can have different data formats..

  • Consider endianness

Marshalling: Reference Parameters

Problem: How do we pass pointers?

  • If it points to a well defined data structure, ?
  • What about data structures containing pointers?

Implementation Issues

Summary

Case Study: Sun RPC

Binder: Port Mapper

1. Server start-up:

  • Creates port
  • Server stub calls svc_register to register program # and version # with local port mapper
  • Port mapper stores the prog #, version #, and port

2. Client start-up:

  • Calls clnt_create to locate server port
  • Upon return, client can start to call procedures at the server

Sun RPC Programming

The RPC library is a collection of tools for automating the creation of RPC clients and servers

  • RPC clients are processes that call remote procedures
  • RPC servers are processes that include procedures which are called by clients

RPC Library

  • XDR Routines – Data is translated into standardized XDR format
  • RPC run time library
    • call rpc service, e.g. high-level client lib call_rpc(..)
    • register with portmapper, e.g. high-level server lib registerrpc(..)
    • dispatch incoming request to correct procedure, e.g. high-level server lib svc_run(..)
  • Program generator: RPCGEN

Example: RPC Programming

  1. Write RPC protocol specification file foo.x
  2. Write server procedure fooservices.c
  3. Write client procedure foomain.c

Example: RPCGEN

  • A tool for automating the creation of RPC client and servers.
    • The program rpcgen does most of the work for you.
    • The input to rpcgen is a protocol definition in the form of a list of remote procedures and parameter types.

Using SunRPC

  1. rpcgen -c foo.x
  • foo_clnt.c (client stubs)
  • foo_svc.c (server main)
  • foo_xdr.c (xdr filters)
  • foo.h (shared header file)
  1. gcc -o fooclient foomain.c foo_clnt.c foo_xdr.c -lnsl
  • foomain.c is the client main() (and possibly other functions) that call rpc services via the client stub functions in foo_clnt.c
  • The client stubs use the xdr functions.
  1. gcc -o fooserver fooservices.c foo_svc.c foo_xdr.c -lrpcsvc -lnsl
  • fooservices.c contains the definitions of the actual remote procedures
  1. Copy the server fooserver to the remote machine and run it in the background
  2. Now you can call the remote procedure on a local machine

Lightweight RPCs

Other RPC Models

Remote Method Invocation (RMI)

Proxies and Skeletons

Static vs Dynamic RMI

Static invocation

Dynamic invocation

Parameter Passing

Persistence and Synchronicity combinations

  • Persistent: Receiver does not need to be running, message is persistent

  • Transient: Receiver needs to be running, otherwise message is discarded

  • Async: Sender continues immediately after it submits its message

  • Sync: Sender waits on a message to be stored in a local buffer at the receiving host, or actually delivered to the receiver.

  • Delivery-based: Waits for an ACK from receiver

  • Response-based: Waits for receiver to process request

RPC & RMI belong to transient synchronous communication.

Message-oriented Transient Communication

Many distributed systems are built on top of simple message-oriented model

Message-Passing Interface (MPI)

  • Sockets are designed for network communication (TCP/IP)
    • Simple send/receive primitives
    • Use general-purpose protocol stacks like TCP/IP

Sockets are not a suitable abstraction for other protocols in clusters or massively parallel systems

MPI

  • Hardware independent
  • Designed for parallel applications on clusters
  • Transient (sync/async) communication
  • Key idea: Communication between groups of processes
    • An endpoint can be represented as: (groupID, processID)
    • Tons of primitives to facilitate this

Message-oriented Persistent Communication

These provide intermediate storage for messages, when a sender/receiver is inactive

The only guarantee to the sender is that their message will be delivered to the receiver queue (does not guarantee actual processing of the message).

A data stream is a sequence of data units:

For continuous streams: