Blackboard

Sample Code for Project 3

This function could can be used to return true (1) with a probability of p / 100, and return false (zero) with a probability of (1 - p / 100).
int select_this (int p) {
  /* generate a new random integer in the range 0...4294967295 */
  unsigned int r = random ();
  /* the floating point equivalent of the maximum possible integer */
  float maxint = 4294967295.0;
  /* a floating point random number integer in the range 0...1 */
  float fr = ((float) r) / maxint;
  /* return true with probability p / 100.  Since fr is evenly
     distributed in the range 0..1, the likelyhood that it is less
     than p is proportional to p/100. */
  return (fr < (((float) p) / 100.0));
}
The following pseudo-code shows how to decide whether to send the packet, drop it, or send it in duplicate. The packet and p are assumed to be parameters to a function send, which is called whenever we want to send a packet (be it a data segment, and ack, or a packet carrying a new window).
... send ( ... packet, int p) {
  if (select_this (p)) {  /* random selection */
    /* do nothing, i.e. discard packet */
  } else if (select_this (p)) {  /* a new random selection */
    send the packet, and
    send the packet again
  } else {
    send the packet
  }
}
Although this is C code, it should be easy to recode in whatever language you have chosen.

NFS server

NFS operations are idempotent: they can be repeated without changing what they do (e.g., writing a block of data has the same effect no matter how many times it is done, as long as the data is the same).

A server implementing idempotent operations can be a stateless server.


A server calling a CGI program to generate content dynamically


Procedure call sequence, and remote procedure call


Remote Procedure Call

The client replaces the call to f with a call to f_stub:
....
x = f_stub (3, "a");
....
The stub for f has code along these lines:
int f_stub (int a, char * c) {
  char b [BUFSIZE];

  represent_int (a, b, 0);
  n = 4 + represent_string (c, b, 4);
  s = socket (...
  connect (s, ...
  send (s, b, n);
  recv (s, b, BUFSIZE);
  return decode_int (b);
}

Hierarchical structure of the MIB tree