Professional Documents
Culture Documents
What is a network?
Anatomy of a network
Distributed Systems
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
such as routers and
switches
Links: cables,
connectors, network
interfaces
2
Transmission links
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
01100001011000111 01110101
Bytes
00000010 10000000 10100001
Distributed Systems
header
Data or payload
Distributed Systems
trailer
5
Packet:
header
Data or payload
Distributed Systems
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
Distributed Systems
switch
router
To the
Internet
To offsite
LANs
Layer 7- Application
Layer 6 - Presentation
Layer 5 - Session
Layer 4 - Transport
Layer 3 - Network
Layer 2 - Link:
Layer 1 - Physical
application
protocols
networking
protocols
Distributed Systems
10
OSI model
Layer 7- Application
layers 5/6/7:
Application
Layer 6 - Presentation
application
protocols
Layer 5 - Session
TCP, UDP
IP
Layer 4 - Transport
Layer 3 - Network
Layer 2 - Link:
Logical
MAC
networking
protocols
Layer 1 - Physical
Distributed Systems
11
Application
Layer
Application data
Transport
Layer
T hdr
App data
Network
Layer
N hdr
Transport
Link Layer
L hdr
Network
CRC
Physical Layer
101011100101
Distributed Systems
12
Distributed Systems
13
Addresses
Addresses
Web
client
DNS
client
URL
Web server
Source port
Destination port
TCP
UDP
TCP
UDP
Transport protocol
Transport protocol
IP
IP
Encapsulation
Encapsulation
Physical network
Physical network
Source IP
Source NIC
Distributed Systems
Destination IP
Destination NIC
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
Distributed Systems
15
Message Receipt:
Distributed Systems
16
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
is complete. No buffer is required.
picks 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
Distributed Systems
18
19
20
Distributed Systems
21
22
Socket Programming
A socket is a communication endpoint between processes
A socket forms the API that allows processes to communicate
point-to-point over the internet, within a LAN or within a single
computer
Each internet host implements the TCP/IP family of protocols
A socket is identified by a socket address consisting of an IP
(version 4) address and port number e.g. 129.86.5.20:80
IP addresses are stored as unsigned 32 bit integer, and frequently
represented in dotted decimal notation.
/* Internet address structure */
struct in_addr {unsigned int s_addr;};
Port numbers are unsigned 16 bit integers (range 0-65535). Port
numbers 0-1024 are well known and reserved, e.g. 21 ftp, 23 telnet,
25 email, 80 http...
Distributed Systems
23
24
Primitive
Meaning
Socket
Bind
Listen
Accept
Connect
Send
Receive
Close
Distributed Systems
25
create socket
bind()
listen()
accept()
socket()
Blocks until
connection
from client
recv()
connect()
send()
Process request
send()
recv()
close()
close()
Server
Client
Distributed Systems
26
create socket
bind()
recvfrom()
blocks until
datagram
received
from a client
socket()
request
sendto()
Process request
sendto()
reply
recvfrom()
close()
Server
Close socket
Client
Distributed Systems
27
juliet_addr.sin_family = AF_INET;
juliet_addr.sin_addr.s_addr =
inet_addr(xxx.xxx.xxx.xxx);
juliet_addr.sin_port = PORT_NUM;
fromlen = sizeof(juliet_addr);
close(romeo);
}
Distributed Systems
28
fromlen = sizeof(juliet_addr);
recvfrom(juliet, message, sizeof(message), 0,
(struct sockaddr) &romeo_addr, &fromlen);
int juliet,fromlen;
struct sockaddr_in romeo_addr, juliet_addr;
close(juliet);
}
Distributed Systems
29
sender
receiver
30
31
Specifying QoS
Characteristics of the Input
Service Required
(bytes/sec)
32
33
34
/* cipher*/
/* LPC */
call
LPC
/* decryption */
return
stack
stack
Return address
i -> 0
s -> main.cip
key -> 1
before
cip ->Buubdl!bu!ebxo
len -> ?
key -> 1
procedure
cip ->Buubdl!bu!ebxo
len -> ?
key -> 1
Distributed Systems
after
cip ->Attack at dawn
len -> 14
key -> 1
35
stub
recv req
register
or search
return
(2)
Bind req
(1)
Recv bind
marshal
Send req
(3)
(8)
unmarsh
stub
recv req
(5)
unmarsh
(4)
Recv
result
(8)
(0)
(7)
procedure
execute
(5)
LPC
marshal
(6)
send
result
(6)
return
return
client
server
Distributed Systems
36
37
/* return type */
typedef struct {
int key;
char cipher[MAX];
} Args;
/* parameter type */
program CAESAR {
/* CAESAR program */
version VERSION {
Data DECRYPT(Args) = 1; /* decryption procedure */
Data ENCRYPT(Args) = 2; /* encryption procedure*/
} = 5;
} = 8888;
Distributed Systems
38
Client stub
Server main program and server stub
XDR parameter marshalling/unmarshalling functions
Program header file, caesar.h, which includes constants,
user defined types, remote procedure prototypes.
39
#include <rpc/rpc.h>
#include caesar.h
#include <rpc/rpc.h>
#include ceasar.h
main(){
CLIENT *cp;
char *serverName = Caesar_server;
Args arg;
Data * plaintext;
/* create client pointer */
cp = clnt_create(serverName, CRESAR, VERSION, udp);
if (cp == NULL) exit(1);
arg.key = 1;
/* set RPC parameters */
arg.cipher = Buubdl!bu!ebxo;
plaintext = decrypt_2(&arg, cp); /* issue RPC */
/* other processing */
clnt_destroy(cp);
Distributed Systems
40
Server code
Server stub
XDR Definition
Header file
RPC
library
client stub
Client program
Client code
Distributed Systems
41
42
RPC Semantics
Re-sending RPC
Replica filtering
Re-sending results
RPC semantics
no
no
no
maybe
yes
no
no
at-least-once
yes
yes
no
maybe-once
yes
yes
yes
at-most-once
Distributed Systems
43
Distributed Systems
44