From a6cca70e50e6dcd3360f5c4f766d8116c611ea52 Mon Sep 17 00:00:00 2001
From: arshiam2 <arshiam2@illinois.edu>
Date: Sun, 7 Oct 2018 23:00:35 -0500
Subject: [PATCH] readme

---
 README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 netbps    | 24 +++++++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100644 README.md
 create mode 100755 netbps

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f6d4d21
--- /dev/null
+++ b/README.md
@@ -0,0 +1,58 @@
+# CS 425 Membership
+
+
+## Prerequisites
+Have node and npm installed on each VM and clone the repo in each one. 
+
+## Cli Tool
+
+The cli tool has a couple commands that allows it to interact with the introducers and machines to tell it to join, leave, or list that machine's membership lists.
+
+To set it up, run the following commands 
+```
+cd cli
+npm install
+npm run build
+npm link
+```
+
+This links the ```mem``` command to your command line, so you can run all the commands below
+
+```mem -h``` Explains all the commands availible
+
+```mem init``` Sets up five nodes (VMs 2 through 6) in a group, with VM 1 as the introducer. 
+
+```mem join <VM_number>```: Adds the specified VM to the group. 
+
+```mem leave <VM_number>```: Voluntarily removal of the specified VM from group. 
+
+```mem list <VM_number>```: Lists the membership list local the specified VM. 
+
+
+## Machine
+
+The machine can be run on VM's 2 through 10. Each machine has a membership lists of nodes its pinging and statuses of whether or not they are alive or dead depending on how long it has been since the last ping. 
+
+To set it up, run the following commands 
+```
+cd machine
+npm install
+npm run start
+```
+
+
+## Introducer
+
+The introducer can be run on VM 1. The introducer has a list of all VMs up, and gets messages when anotehr machine joins and leaves. Based on that, it updates all the nodes membership lists.
+
+To set it up, run the following commands 
+```
+cd introducer
+npm install
+npm run start
+```
+
+
+# Getting logs 
+
+In the introducer and Machine, instead of running ```npm run start``` as the last command, run ```npm run start > log.txt``` which will write all the output to  a file. Otherwise, if it is open, you can the logs printed out to temrinal. 
\ No newline at end of file
diff --git a/netbps b/netbps
new file mode 100755
index 0000000..b5520c8
--- /dev/null
+++ b/netbps
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Time::HiRes;
+
+my $reporting_interval = 10.0; # seconds
+my $bytes_this_interval = 0;
+my $start_time = [Time::HiRes::gettimeofday()];
+
+STDOUT->autoflush(1);
+
+while (<>) {
+  if (/ length (\d+):/) {
+    $bytes_this_interval += $1;
+    my $elapsed_seconds = Time::HiRes::tv_interval($start_time);
+    if ($elapsed_seconds > $reporting_interval) {
+       my $bps = $bytes_this_interval / $elapsed_seconds;
+       printf "%02d:%02d:%02d %10.2f Bps\n", (localtime())[2,1,0],$bps;
+       $start_time = [Time::HiRes::gettimeofday()];
+       $bytes_this_interval = 0;
+    }
+  }
+}
+
-- 
GitLab