diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f6d4d2130a82bae6897e811751b2c1059980220e --- /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 0000000000000000000000000000000000000000..b5520c8f23e18427804c34e0042f1e50e49be24f --- /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; + } + } +} +