COMP3221
NTP set up pair-wise between servers
1. Run cristian's algorithm 8 times and records the 8 output pairs 2. The pair with minimum RTT/2 is chosen as most precise offset
What are lightweight processes (LWP)?
1. Runs in context of a process 2. Can be several LWPs per process 3. Once LWP finds runnable thread: locks table in user-mode to update, and switches context to thread in user-mode 4. Does not block upon system calls
How does the Blockchain work?
1. Someone requests a transaction 2. Transaction is broadcasted to a P2P network consisting of computers (nodes) 3. All nodes validate the transaction and the user's status 4. Once validated, the transaction is combined with other transactions to create a new block of data for the ledger 5. New block added to the existing blockchain 6. Transaction complete
The Berkeley Algorithm
1. Time server sends "what is the time" request to all nodes 2. Nodes answer with their local clock value 3. Once server has received values from the nodes, it computes the average and sends it back to all machines telling them to correct it
RPC Steps
1. client calls client stub 2. client stub builds message and calls local OS 3. client's AS sends message to remote AS 4. remote AS gives message to server stub 5. server stub unpacks parameters and calls server 6. server does work and returns result to stub 7. server stub packs message and calls local AS 8. server's AS sends message to client's AS 9. client's AS gives message to client stub 10. stub unpacks result and returns to client
RMI Steps
1. client-side stub creates parcel, sends it to server 2. skeleton unmarshals parameters and invokes desired method on server 3. skeleton marshals return value into parcel and returns 4. stub unmarshals return value and passes it to client
Port number
<1024 are for specific service protocols a client initiating a connection is assigned a free port number (>1024) by its host
What is a Distributed System?
A collection of independent computers that appear to its users as a single coherent system
NFS (Network File System)
A distributed file system that comes with a protocol that describes precisely how a client can access a file stored on a (remote) NFS file server NFS protocol: RPC for file operation on server NFS servers are stateless Three layers 1. Unix file-system interface 2. VFS layer 3. NFS service layer
What is middleware?
A layer over the network services providing general services to applications in a very transparent manner Middleware layer extends over multiple machines and offers each application the same interface. Logically placed between higher-level layer and layer underneath consisting of OSs and basic communication
What helps a distributed system seem transparent?
Access, location, migration, relocation (while in use), replication, concurrency, failure
What does ARP do?
Address Resolution Protocol returns the physical @ given an IP @ in a network
What is the address space (and stack)?
Address space: amount of memory allocated for all possible addresses. A unit of management of a process's virtual memory Stack --> Heap --> Data section --> Text region
What is an Address and Identifier?
Address: name of access point of entity Identifier: uniquely identify an entity
RIP algorithm (Adv and limitations)
Adv: simple, efficient in small networks Limitations: costs based on number of hops is unrealistic. No big deal, just defining link weights. Inefficient in large networks as loops may occur before convergence state is reached
What does the transport layer do?
After receiving a message from application layer, the transport layer breaks it into pieces small enough for transmission, assigns each one a sequence number, then sends them all. Build on top of connection-oriented or connectionless network services.
What is the message structure of the OSI model layers?
As the message goes through lower layers before being sent, each layer adds its header to the message. Upon reception, the message is unmarshalled by the successive layers from bottom to top
What are some Blockchain applications?
Automative (manage fractional ownership of autonomous cars) Financial services (faster, cheaper) Voting (via smartphone resulting in immediate verifiable results) Healthcare (patient's encrypted health information shared with other health places)
How to resolve MAC address on LAN?
Broadcast message to all, destination MAC: FF-FF-... Multicast: sending messages to a specific group
CAN (Content Addressable Network), another DHT
CAN deploys a d-dimensional Cartesian coordinate space, which is completely partitioned among all nodes that participate in the system New node: chooses random coordinate, lookups node responsible, becomes responsible for half of its zone Routing: each node has address of neighbours, route to destination, each node chooses closest neighbour to destination in terms of euclidean distances
What are some characteristics and principles of Message-Oriented Persistent Communication?
Characteristics: don't require sender / receiver to be active during communication, offering intermediate storage capacity for messages, typically target long message transfers Principles: each application maintains local queue and sends messages to other application queues, unaware of the reading of its messages
Atomic clock. Leap seconds
Counting transitions of the cesium 133 atom (second = 9,192,631,770 transitions of the cesium 133 atom) Leap seconds: introduced when necessary to keep in phase with sun, corrected is UTC Difference returned by two clock values is called clock skew
Streaming multimedia: DASH
DASH: Dynamic Adaptive Streaming over HTTP Server: divides video files into multiple chunks, each chunk stored, encoded at different rates, not responsible for selecting next chunk to improve user quality of experience Client: periodically measures server-to-client bandwidth, requests one chunk at a time
What are the three main Java Sockets?
DatagramSocket: connectionless socket MulticastSocket: multicast socket Socket: connection-oriented socket
What are Content Distribution Networks (CDNs)?
Dealing with streaming hundreds of thousands of users simultaneously Option 1: single, large server, however single point of failure, point of network congestion, long paths to distant clients Option 2: store/server multiple copies of vides at multiple geographically distributed sites CDN: stores copies of content at CDN nodes Over the top (OTT) challenges: coping with a congested internet
What is the Blockhain?
Decentralized ledger of all transactions across a peer-to-peer network
What are processes and how does concurrency work?
Defined as a program in execution. OS creates a virtual CPU for each process, while making sure the processes cannot maliciously or inadvertently affect each other's behaviour The concurrency transparency comes at a very high cost: for every process, OS must create a completely independent address spa
Open Systems Interconnection (OSI) model
Designed to allow open systems to communicate. Each layer deals with one specific aspect of the communication 1. Application 2. Presentation 3. Session 4. Transport 5. Network 6. Data link 7. Physical
RPC: Passing parameters
Different architectures have different data representations: hence, need to specify types Difference process have difference address space: solution is to call-by-copy/restore instead of call-by-reference
How do multithreaded servers work (dispatcher/worker model, thread pool)?
Dispatcher/worker model: - one thread, the dispatcher, reads incoming clients requests - the server chooses an idle worker thread and hands it the request Thread pool: creates pool of threads that the server can reuse, no need to initialise many threads, nor to destroy many threads Other alternatives: - single-threaded: one loop iteration must treat request before starting to treat another (requests lost) - finite state machine: uses cache
What is a distributed OS, and network OS?
Distributed OS: single system image, system maintains single copy of resources Network OS: machines provides resources to other machines
What is Connection oriented and connectionless communication?
Establish explicitly a connection with a partner before exchanging data (e.g. TCP) No setup in advance is needed (e.g. UDP, IP). Advantage is being efficient, as long as messages don't get lost or corrupted
What is the peer-to-peer model?
Every machine is both client and server. No centralised control (responsibility is distributed evenly). Forms an overlay network, nodes are processors, links possible communication channels
DHT: fault tolerance, scalability
Fault tolerance: fully distributed, no central point of control Scalability: to a large number n of participants
Dijkstra's algorithm (used in IS-IS (IP) and OSPF protocols)
Finds shortest path from a node i to other nodes computes least cost paths from one node ('source') to all other nodes
What are Flat (unstructured) names? And what is a physical address?
Flat: often not human readable Physical: uniquely identifier to a network interface, commonly referred as MAC address
How to locate an entity?
Forwarding pointers: entity moves, it leaves behind a reference Home-based approaches: home location keeps track of the current location of an entity
What are the various ways of communication depending on the need?
General-purpose communication: Socket High performance parallel communication: MPI Very long message transmission: MOM
What is a Distributed hash table (iterative, recursive lookup)?
Given key, find resource: keys assigned to resources, locating key similar to resolving name Iterative lookup: node requested to look up key returns to requester the address of the next node found Recursive lookup: node requested to look up key forward the lookup request to the next node
Routing algorithm classification (global, decentralized, static, dynamic)
Global: all routers have complete topology, link cost info Decentralized: routers know physically connected neighbours, link costs to neighbours Static: routes change slowly over time Dynamic: routes change more quickly
Multicast: FIFO
Goal: broadcasting messages that got delivered in same order at all nodes Each process maintains counter and priority queue of messages
Causal ordered multicast
Goal: broadcasting messages that got delivered only if all causally preceding messages have already been delivered Each process maintains vector clock and a priority queue of messages
Vector clocks
Goal: to make also the "did-not-happen-before" relation visible Key idea: each process should also maintain an approximation of the clock of other processes
Hard and Symbolic linking
Hard links: allowing multiple absolute path names to refer to the same node in a naming graph Symbolic links: leaf node stores only absolute path name; resolving path name leading to this node returns another path name, that will get resolved
Domain name system
Hostname to IP address translation Host aliasing Domain: subtree Domain name: path name to its root node
Network Time Protocol: Cristian's algorithm
Idea: Letting clients contact a time server, however there are message delays, therefore we try find a good estimation for these delays. 1. A sends message to B with T1 2. B records current time T2 3. B returns response message to A with T2 and current time T3 of its clock 4. A records current time T4 of its local clock RTT = (T2-T1)+(T4-T3) Offset of A relative to B = T4 - T3 - RTT/2
Lamport's logical clocks
If two processes don't interact, there's no point in keeping the time between them as it doesn't matter Each process should keep track of order in which events appear to take place locally
Processes vs threads
Isolated vs non-isolated Inefficient vs efficient A thread is generally faster than a process, but shares its data with other threads
What is thread safety?
It's about protecting data from uncontrolled concurrent access Potential solutions: don't share state variable among threads. Make the state variable immutable. Use synchronisation to access the state variable
Describe the distance vector algorithm
Iterative, asynchronous: each local iteration caused by: local link cost change, DV update message from neighbour Distributed: each node notifies neighbours only when its DV changes
Logical time
Keeping track of the order of events is what matters! "a happens before b", denoted by a --> b, is true if - a and b from same process, so a occurs before b - a and b being received by some process - exists event c such that a --> c and c --> b
MPI (Message-Passing Interface) vs Sockets
MPI: hardware and platform independent, direct use of underlying network, assume no failures, designed for parallel applications tailored to transient communication Sockets: limited set of primitives, provides only send/receive for communication, exploits general purpose (TCP, UDP)
Distance Vector vs Link State (Message complexity, speed of convergence, robustness)
Message complexity - LS: n nodes, e links, O(nE) msgs sent - DV: exchange between neighbours only (convergence varies) Speed of convergence - LS: O(n^2) algorithm requires O(nE) msgs - DV: convergence time varies (may be routing loops) Robustness - LS: node advertise incorrect link cost, each node computes own table - DV: node can advertise incorrect path cost, each node's table used by others
What is a hash function? (and one-way function, weak-collision resistant)
Message digest is the result of hashing some input Given same message produces the same digest. One-way function: infeasible to find input m that corresponds to output h, whereas computing h from m is easy Weak collision resistant: infeasible to find another different input m' such that H(m) = H(m')
Mounting in a Network File System
Mount point: directory node storing the node identifier Mounting point: directory node in foreign name space, usually the root of the name space To mount foreign name space in distributed system requires at least the following: 1. name of access protocol 2. name of server 3. name of mounting point in foreign name space
What is the Thread API Lifecycle?
NEW: instantiated RUNNABLE: executing, ready for running state BLOCKED: waiting for monitor lock in this state WAITING: waiting indefinitely for another thread to perform action SLEEPING: waiting for another thread to perform an action for x time TERMINATED: a thread has exited
Distributed file system caching
Name translations: mapping from paths to inodes Disk blocks: mapping from block address --> disk content Least recently used (LRU) policy: when cache is full, another access occurs, LRU block or path entry overridden
What are some challenges involved in distributed systems?
Network communication, scalability, consistency, fault-tolerance, security
Chord is an example of a DHT (Distributed Hash Table)
Nodes organised in a ring. Has shortcuts to other nodes to speedup delivery of requests. Data item with key k mapped to node with smallest id ~ k. This node is referred to as the successor of key k. Each node has finger table Routing: ask node with closest id, or target
Persistent vs Transient Communication
Persistent: message stored by middleware, no need for either end to store message Transient: message stored only for duration that sending and receiving application are executing
What are the low-level layers (physical, data link, network layer)?
Physical: send bits Data link layer: group bits into frames, assign sequence numbers, add checksum Network layer: routing of datagrams from source to destination
What is Inter-Process Communication (IPC)?
Pipes / Message Queues / Shared memory segments
TCP Overview
Point-to-point connection-oriented, reliable, in-order, byte stream full duplex data flow controlled congestion controlled
Sockets
Process send/receives messages to/from its socket identified by IP address with port number uses the CS model
What is the producer/consumer model?
Producer thread rapidly takes input to not miss any. Tasks wait in a queue for being processed. Consumer thread slowly executes tasks
Pros and Cons of Physical Time
Pros: very powerful - universal representation of occurrence time of all distributed events - all events made comparable Cons: hard to achieve - physical time instruments are difficult to synchronise - in large-scale system, the message delay is typically
MOM (Message-Oriented Middleware)
Provide extensive support for persistent asynchronous communication. Offers intermediate-term storage capacity for messages, without requiring either end to be active during message transmission Sender uses put to enqueue message in a non-blocking way Get primitive returns the longest pending message of the queue or may be tuned to return the highest priority message Poll is the non-blocking variant of the get Callbacks can be used to automatically fetch new messages from the receiver side via notify
RFC (Request for Comments)
Public description of internet communication protocols
OSPF (Open Shortest Path First)
Publicly available Uses link-state algorithm Router floods OSPF link-state advertisements to all other routers in entire AS IS-IS routing protocol: nearly identical to OSPF Multiple same-cost paths allowed (only one allowed in RIP
RMI (Remote Method Invocations)
RMI: same as RPC, except it operates on objects instead of applications RMI allows a thread to invoke a method on remote object
Differences between RMI and RPC
RPC is procedural RMI is object-based RPC parameters are data structures RMI parameters can be primitive data types
International Standards Organization (ISO)
Reference model that clearly identifies various levels involved, gives them standard names, and points out which level should do which job.
RIP (Router Information Protocol)
Relies on Bellman-Ford algorithm Link cost = 1 If node detects link failure, sets infinity as associated cost of such a link and sends its local table to neighbours Eventually (when failure stops) each router gets for each destination the direction leading to minimal cost
How do Layer-based, Object-based, Event-based and Data-centered Architectures work?
Requests go downward and responses go upward Objects communicate through Remote Procedure Calls (RPCs) Communication through events, that optionally carry data Through a shared repository, that contains data
What is Context-Switches?
S1. Process A switches from user to kernel mode S2. Process context-switch S3. Process B switches from kernel mode to user mode Switch form user to kernel mode. Requires changing the memory map in the MMU, as well as flushing the TLB MMU: Memory Management Unit TLB: Translation Lookaside Buffer
What are Edge-Server Systems?
Servers placed at edge of network. They serve content, possibly after applying filtering and transcoding functions
What are the high level layers (session, presentation, application)?
Session: enhanced transport layer: provides dialog control to keep track of which party is currently talking, and provides synchronisation facilities (insert checkpoints into longer transfers) Presentation: concerned with the meaning of bits, defines records containing structured information (name, amounts, etc) and then have the sender notify the receiver that a message contains a certain format Application: HTTP, FTP
Shared vs mutable variables
Shared variable: variable that could be accessed by multiple threads Mutable variable: variable whose value may change
Difference between stateless and stateful servers?
Stateless: doesn't record the state of its client (and can change without informing client) Stateful: maintains persistent info about its client
RPC: Client and server interaction
Stubs are created for client stub and server stub, both ends to provide transparency
What are some error correction and interleaving to cope with message losses?
TCP/IP retransmit drops packets, yet this is too heavy for streaming application Forward error correction: k out of n packets are enough to reconstruct k packets Interleaving circumvents dropped packets to contain multiple consecutive audio and video frames
What does fault-tolerance mean?
The ability for the system to recover from partial failures
What is concurrency?
The ability of different parts or units of a program executed out-of-order or in partial order, without affecting the final outcome Multi-cores on a single machine
What is the three-tiered, two-tiered and single-tiered architecture?
Three-tiered: each layer on separate machine Two-tiered: client, single server config Single-tiered: dumb terminal, mainframe config
Name format (URI, URL)
Uniform Resource Identifiers (URI) uniquely identify a resource (so the resource can be identified by software and new resources can be added) Uniform Resource Locator (URL): used to locate and access a resource
Uniprogramming vs multiprogramming
Uniprogramming: one program execution at a time Multiprogramming: more than one program executing at a time
What is Stream-oriented communication?
Used when timing is crucial. Previous communication modes don't guarantee transmission rate. In stream-oriented communication, the stream should not be interrupted
What is the three-layered application view?
User interface layer: contains feature to control the application from the user Processing layer: typically contains the application Data layer: manages the actual data being sent
User-level threads library vs. kernel-level thread
User-level: cheap to create and destroy threads, cheap context switching, however it does bock Kernel-level: costly context switching, costly to create, destroy and synchronise threads, however it does not block
What is synchronisation?
When threads must coordinate their access to a given state variable
What is RPC (Remote Procedure Call)?
allow programs to call procedures located on other computers, no message passing visible to the programmer
Connection Management
before exchanging data, sender/receiver "handshake": agree to establish connection (each knowing the other willing to establish connection) agree on connection parameters
MPI communication primitives
blocking synchronous send and asynchronous send RPC-like mechanism Pointers passed as parameters takes care of communication
Principles of congestion control
causes lost packets and long delays approach: sender increases transmission rate (window size), probing for usable bandwidth, until loss occurs
HTTP Overview
client: browser requests, receives and displays web objects server: web server sends objects in response to requests
What is parameter marshalling?
packing parameters into a message 1. client stub marshals message before sending it 2. server stub unmarshals message and calls the procedure on the server 3. server stub marshals result to send back 4. client stub unmarshals message and returns to client
TCP seq, numbers, ACKs
seq: byte stream of first byte in segment's data ack: seq # of next byte expected from other side
HTTP is "stateless" What is HTTPS?
server maintains no information about past client requests HTTPS over TLS, e.g. over SSL
Berkely Sockets: Socket Interface
socket: create new communication end point bind: attach local address to socket listen: announce willingness to accept connections accept: block caller until connection request arrives connect send receive close
DNS records:
type=A (contains IP address of the host this node represents) - name is hostname - value is IP address type=NS (name server that implements the represented zone) - name is domain - value is hostname type=CNAME (symbolic link with primary name of represented node) - name is alias name for some real name - value is canonical name type=MX (mail server to handle mail addressed to this node) - value is name of mail server