Académique Documents
Professionnel Documents
Culture Documents
What is a network?
What types of network are there?
What networking standards are there?
How do you represent information?
What is communication protocol?
What are communication models? (message-
passing, stream communication and RPC)
Distributed Systems 1
Anatomy of a network
A set of interconnected
resources
Hosts that run network
applications software
Clients and servers
Set of peers
The network infrastructure that
interconnects the hosts
The networking hardware
and software
Network node devices
connectors, network
interfaces
Distributed Systems 2
Transmission links
Convey bits, bytes, packets
Physical medium
Copper (or aluminium)
Optical fibre
Glass, plastic
Free-space optical
Laser
Radio
Satellite, microwave link, mobile, wireless LAN,
‘Bluetooth’
Mode
Point-to-point
Shared medium (multicast)
Broadcast
Distributed Systems 3
Representing data: bits and bytes
Bits
Different codes used in different interface standards
Images, multi-media
Require special bit pattern as delimiter
Bytes
Text is usually ASCII or Unicode characters
Text files, documents
Character set includes special control characters
Bits Bytes
node)
Trailer (if present) carries error check
Used for detecting errors in received frame
Distributed Systems 6
Types of network
Main types:
LAN, WAN, MAN, and Internet
LAN (Local Area Network) is mainly private
Ether net, Token ring
Or interconnected
WAN (Wide Area Network) can be private or public
Interconnected
MAN (Metropolitan Area Network) is mainly public
Interconnected by Optical fibre
Global Network is public
The internet
The telephone network
Distributed Systems 7
Interconnecting LANs and WANs
Distributed Systems 8
OSI: The International Standards Model
Distributed Systems 9
OSI: A Seven Layer Protocol
Distributed Systems 10
The OSI and IETF Protocol Suites
Layer 7- Application
application
layers 5/6/7: Layer 6 - Presentation protocols
Application
Layer 5 - Session
Distributed Systems 11
Protocol Data Encapsulation
101011100101
Distributed Systems 12
A Typical Message on the Network
Distributed Systems 13
Protocol Data Flow
Addresses Addresses
Distributed Systems 14
Communication Models
• Message Passing
lowest level of communication, e.g. sockets
unstructured peer-peer IPC
varieties of communication patterns
• Data Stream
continuous media
satisfy real time data services
• Request / Reply semantics
basis of Client-Server
RPC (Remote Procedure Call)
RMI (Remote Method Invocation)
Distributed Systems 15
Message Passing Definitions(1)
Procedures: send, receive, accept, create, connect, locate , re
ply, acknowledge
Multiplicity: point-to-point, broadcast, multicast
Message Content: data or instruction, by value or by reference (addre
ss)
Channels:
- link, port, mailbox
- direction can be uni-diection or bi-direction
- capacity can be unbounded (i.e. asynchronous, no blocking)
or null (implies synchronous) or fixed (implies buffering)
Message Receipt:
explicit receive – receiver can select message
implicit receive – receiver must receive from sender
Distributed Systems 16
Message Passing Definitions(2)
Synchronous/Asynchronous
Synchronous – receiver waits ready for sender message and responds in
real time (e.g. phone call). Both sender and receiver return when transfer i
s complete. No buffer is required.
Asynchronous – sender sends message into buffer, message picked
up later at receivers convenience (e.g. mailbox). Sender process retur
ns whether or not a message is received. Receiver blocks until the me
ssage is available
Blocking/Non-Blocking
Blocking – sender cannot proceed after sending message until receiver pi
cks up message
Non Blocking – sender can continue as soon as message send is done
(e.g. added to buffer)
Sender/Receiver Naming
Static – sender and receiver names (location) fixed
Dynamic – names may change (e.g. ask a static name server
Distributed Systems 17
Message Passing Definitions(3)
Connection Link
Connection Oriented – link is established and held for duration of
service. Guaranteed link but bandwidth may be wasted.
Connectionless – connection not established until message send
occurs e.g. different packets sent by different routes
Transient
message is only stored by system while sender and receiver are ex
ecuting (e.g. MSN messenger)
Persistent
message is stored and delivered by system, even if receiver is not
executing (e.g. email)
Distributed Systems 18
Persistence and Synchronicity in Communication (1)
Distributed Systems 19
Persistence and Synchronicity in Communication (2)
Distributed Systems 20
Persistence and Synchronicity in Communication (3)
Distributed Systems 21
Persistence and Synchronicity in Communication (4)
Distributed Systems 22
Socket Programming
Distributed Systems 23
Socket Families and Types
• AF_UNIX – for communicating between processes on the same
(UNIX) computer.
Distributed Systems 24
Socket primitives for TCP/IP
Primitive Meaning
Distributed Systems 25
TCP/IP Socket Calls for Connection
recv() send()
Process request Transfer message strings with
send/recv or read/write
send() recv()
Server Client
Distributed Systems 26
UDP/IP Socket Calls for Connection
blocks until
datagram socket()
received
from a client
request specify senders address
sendto()
and send datagram
Process request
reply
sendto() recvfrom()
Server Client
Distributed Systems 27
UDP/IP Socket program example(1)
Distributed Systems 28
UDP/IP Socket program example(2)
#include <stdio.h>
#include <sys/types.h> fromlen = sizeof(juliet_addr);
#include <sys/socket.h>
#include <netinet/in.h> recvfrom(juliet, message, sizeof(message), 0,
(struct sockaddr) &romeo_addr, &fromlen);
#define PORT_NUM 2222
char message[20]; printf(“Romeo says: %s\n”, message);
Distributed Systems 29
Stream Oriented Communication
sender receiver
Distributed Systems 30
Data Stream transmission modes
Distributed Systems 31
Specifying QoS
Distributed Systems 32
Token bucket algorithm
Distributed Systems 33
Request / Reply Model
Distributed Systems 34
Local Procedure Call
main(){
char cip[] = “Buubdl!bu!ebxo”; /* cipher*/
int key = 1;/* secret key */ call
int len = decrypt(cip, key); /* LPC */
/* other processing */ LPC
} procedure
int decrypt(char * s, int key){ /* decryption */
int i = 0;
while( *s) { *s -= key; i++; s++;} return
return i;
}
Return address
i -> 0
s -> main.cip
before key -> 1 after
cip ->Buubdl!bu!ebxo cip ->Buubdl!bu!ebxo cip ->Attack at dawn
len -> ? len -> ? len -> 14
key -> 1 key -> 1 key -> 1
Distributed Systems 35
Remote Procedure Call
Binding server
binder
(0)
recv req
program stub (2) register stub procedure
or search
return
LPC Bind req recv req execute
(1) (3) (5) (5)
(1) Recv bind unmarsh
marshal (4)
Send req LPC
client server
Distributed Systems 36
Remote Procedure Call: steps
(0) Remote procedures registration;
(1) Client procedure calls client stub in normal way;
(2) Client stub sends a binding request asking for information;
(3) Binding server searches for binding and reply to client stub;
(4) Client stub packs a message (marshalling) and send to server stub;
(5) Server stub unpacks parameters (unmarshalling), invokes LPC;
(6) Server procedure executes and returns results to server stub;
(7) Server stub packs results (marshalling) and sends to client stub;
(8) Client stub unpacks results and returns to client procedure.
Distributed Systems 38
Example: SUN RPC(2)
Distributed Systems 39
Example: SUN RPC(3)
Distributed Systems 40
Example: SUN RPC(4)
Server stub
RPC
XDR Definition Header file
library
client stub
Client program Client code
Distributed Systems 41
The steps in writing a client and a server in DCE
RPC
no no no maybe
yes no no at-least-once
yes yes no maybe-once
yes yes yes at-most-once
Distributed Systems 43
RMI: Remote Method Invocation
Distributed Systems 44