7
Marco Aiello Master a.y. 2017/18 Smart Cities and Internet of Things DS background A distributed system is a collection of autonomous hosts that are connected through a computer network. Each host executes computations and operates a distribution middleware, which enables the components to coordinate their activities via message-passing in such a way that users perceive the system as a single, integrated computing facility. 2 DS Definition A smart city is a distributed system 2 DS Definition A smart city is a distributed system “A distributed system is one in which the failure of a machine you have never heard of can cause your own machine to become unusable” Leslie Lamport Two generals problem Two Generals need to coordinate an attack against an enemy. If they attack individually, they will loose, if they attack together they will win. But the enemy lies in the middle and can intercept the coordination messages and avoid delivery Can the generals defeat the enemy?

connected through a computer network. Each host executes

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: connected through a computer network. Each host executes

Marco Aiello

Master

a.y. 2017/18

Smart Cities and Internet of Things DS background

• A distributed system is a collection of autonomous hosts that are connected through a computer network. Each host executes computations and operates a distribution middleware, which enables the components to coordinate their activities via message-passing in such a way that users perceive the system as a single, integrated computing facility.

!2

DS DefinitionA smart city is a distributed system

!2

DS DefinitionA smart city is a distributed system

“A distributed system is one in which the failure of a machine you have never heard of can cause your own machine to become unusable”

Leslie Lamport

Two generals problem

• Two Generals need to coordinate an attack against an enemy. If they attack individually, they will loose, if they attack together they will win.

• But the enemy lies in the middle and can intercept the coordination messages and avoid delivery

• Can the generals defeat the enemy?

Page 2: connected through a computer network. Each host executes

Two generals problem

• Two Generals need to coordinate an attack against an enemy. If they attack individually, they will loose, if they attack together they will win.

• But the enemy lies in the middle and can intercept the coordination messages and avoid delivery

• Can the generals defeat the enemy?

Two generals

• Theorem: there is no non-trivial protocol that guarantees that the generals will always attack simultaneously

• Proof: Ab absurdum, suppose there is one such protocol that does the job in the minimum number of steps n>0.

Consider the last message sent, the n-th. The state of the sender cannot depend on its receipt, the state of the receiver cannot depend on its arrival, so they both do not need the n-th message. So we would have a protocol with n-1 messages. But that contradict the hypothesis

• Fact: A solution requires reliable message delivery.

!5 !6

The Byzantine case

• Byzantine army is attacking a city and they can use reliable messengers. They

need to decide whether to attack or not (agreement). If they are unanimous in

the attack decision, then they should attack (validity). But some of the generals

could be Byzantine traitors and send malicious, conflicting messages or even

form a coalition.

• Theorem In a systems with three processes and one Byzantine process, there

is no algorithm that solves the consensus problem.

• Theorem (lower bound on number of faulty processes) In a system with n

processes and f Byzantine processes, there is no algorithm that solves the

consensus problem if n ≤ 3 f.

39

Page 3: connected through a computer network. Each host executes

• Middleware: software layer which abstracts from network hardware, computing hardware, operating systems, programming languages and different implementations providing a uniform computational model

• Socket: the abstraction of a connection from the process’ perspective

!7

definitionsMiddleware and sockets

• Middleware: software layer which abstracts from network hardware, computing hardware, operating systems, programming languages and different implementations providing a uniform computational model

• Socket: the abstraction of a connection from the process’ perspective

!7

definitionsMiddleware and sockets

message

agreed portany port socketsocket

Internet address = 138.37.88.249Internet address = 138.37.94.248

other portsclient server

• Marshalling: the process of encoding a set of data items into a coherent form for the purpose of transmission

• Unmarshalling: the corresponding decoding process

• CORBA uses an external data representation approach

• Java uses a marshalling technique called serialization

!8

Definitions and examplesData transport

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5.3 Remote and local method invocations

invocation invocationremote

invocationremote

locallocal

localinvocation

invocationA B

C

D

E

F

Page 4: connected through a computer network. Each host executes

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

Figure 5.4 A remote object and its remote interface

interfaceremote

m1m2m3

m4m5m6

Data

implementation

remoteobject

{ of methods

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

The architecture of remote method invocation

object A object BskeletonRequestproxy for B

Reply

CommunicationRemote Remote referenceCommunication module modulereference module module

for B’s class& dispatcher

remoteclient server

Figure 5.6

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

The architecture of remote method invocation

object A object BskeletonRequest

proxy for B

Reply

CommunicationRemote Remote referenceCommunication module modulereference module module

for B’s class& dispatcher

remoteclient server

Figure 5.6

carries out Request-reply protocol

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

The architecture of remote method invocation

object A object BskeletonRequest

proxy for B

Reply

CommunicationRemote Remote referenceCommunication module modulereference module module

for B’s class& dispatcher

remoteclient server

Figure 5.6

translates between local and remote object references and creates remote object references. Uses remote object table

Page 5: connected through a computer network. Each host executes

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

The architecture of remote method invocation

object A object BskeletonRequestproxy for B

Reply

CommunicationRemote Remote referenceCommunication module modulereference module module

for B’s class& dispatcher

remoteclient server

Figure 5.6

RMI software - between application level objects and communication and remote reference modules

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

The architecture of remote method invocation

object A object BskeletonRequestproxy for B

Reply

CommunicationRemote Remote referenceCommunication module modulereference module module

for B’s class& dispatcher

remoteclient server

Figure 5.6

RMI software - between application level objects and communication and remote reference modules

Proxy - makes RMI transparent to client. Class implements remote interface. Marshals requests and unmarshals results. Forwards request.

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3 © Addison-Wesley Publishers 2000

The architecture of remote method invocation

object A object BskeletonRequest

proxy for B

Reply

CommunicationRemote Remote referenceCommunication module modulereference module module

for B’s class& dispatcher

remoteclient server

Figure 5.6

RMI software - between application level objects and communication and remote reference modules

Dispatcher - gets request from communication module and invokes method in skeleton (using methodID in message). Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 3

© Addison-Wesley Publishers 2000

The architecture of remote method invocation

object A object BskeletonRequest

proxy for B

Reply

CommunicationRemote Remote referenceCommunication module modulereference module module

for B’s class& dispatcher

remoteclient server

Figure 5.6

RMI software - between application level objects and communication and remote reference modules

Skeleton - implements methods in remote interface. Unmarshals requests and marshals results. Invokes method in remote object.

Page 6: connected through a computer network. Each host executes

• Unicast: a one to one communication with a uniquely identified sender and receiver

• Broadcast: a one to all communication (all components of a system)

• Multicast: a one to many communication (identified as groups)

!12

DefinitionsUnicast and Broadcast

• Unicast: a one to one communication with a uniquely identified sender and receiver

• Broadcast: a one to all communication (all components of a system)

• Multicast: a one to many communication (identified as groups)

!12

DefinitionsUnicast and Broadcast

At the Internet Protocol (IP) level

• FIFO ordering:

• If a correct process issues multicast(g, m) and then multicast(g,m’ ), then every correct process that delivers m’ will deliver m before m’ .

• Causal ordering:

• If multicast(g, m) → multicast(g,m’ ), where → is the happened-before relation between messages in group g, then any correct process that delivers m’ will deliver m before m’ .

• Total ordering: • If a correct process delivers message m before it delivers m’, then any other correct process that delivers m’ will deliver m before m’.

!13

OrderingMulticast

!14

Ordering examplesMulticast

Page 7: connected through a computer network. Each host executes

!14

Ordering examplesMulticast

F3

F1

F2

T2T1

P1 P2 P3

Time

C3

C1

C2

!15

MulticastBulletin example

Bulletin board: os.interesting

Item From Subject

23 A.Hanlon Mach

24 G.Joseph Microkernels

25 A.Hanlon Re: Microkernels

26 T.L’Heureux RPC performance

27 M.Walker Re: Mach

endFigure 11.13

�15

!15

MulticastBulletin example

Bulletin board: os.interesting

Item From Subject

23 A.Hanlon Mach

24 G.Joseph Microkernels

25 A.Hanlon Re: Microkernels

26 T.L’Heureux RPC performance

27 M.Walker Re: Mach

endFigure 11.13

total (makes the numbers the same at all sites)

FIFO (gives sender order

causal (makes replies come after original message)

�15