Skip to content
Snippets Groups Projects

MP0: Event Logging System

This is a distributed logging system that collects events from multiple nodes into a centralized logger. The system tracks event delays and bandwidth usage across nodes.

Table of Contents

Project Structure

cs425-mp0/
├── cmd/
│   ├── logger/
│   │   └── main.go
│   └── node/
│       └── main.go
├── Makefile
├── generator.py
└── plot_metrics.py

Note: The repository also includes scripts (deploy.sh, run_scenarios.sh) for automating and testing across multiple VMs. These are specific to my testing environment and not meant for general use.

Requirements

  • Go 1.21 or later
  • Python 3.x
  • Python packages for plotting: pip install pandas matplotlib numpy

Setup and Running

Building the Code

  1. Clone the repository on VMs (both logger and nodes):
git clone <repository-url> cs425-mp0
cd cs425-mp0
  1. Build the binaries using make:
make build

This will create two executables in the project root:

  • logger: The centralized logging server
  • node: The client program that sends events to the logger

Running the Logger

On the logger VM:

# Using make:
make run-logger

# Or directly:
./logger 1234

The logger will create event_metrics.log in the current directory.

Running Nodes

On each node VM:

# Using make:
make run-node NAME=node1 HOST=logger-hostname PORT=1234 RATE=2.0

# Or directly:
python3 -u generator.py 2.0 | ./node node1 logger-hostname 1234

Replace:

  • node1: Unique name for each node (e.g., node1, node2, etc.)
  • logger-hostname: Hostname or IP of the logger machine
  • 1234: Port number the logger is listening on
  • 2.0: Event generation rate in Hz (use 2.0 for scenario 1, 5.0 for scenario 2)

Stopping Components

To stop the logger or nodes:

# Find the process ID
ps aux | grep logger  # for logger
ps aux | grep node    # for nodes

# Kill the process
kill <pid>

Generating Graphs

On the logger VM after running a scenario:

# Install required Python packages
pip install pandas matplotlib numpy

# For scenario 1 (3 nodes, 2Hz):
python plot_metrics.py event_metrics.log 3 2

# For scenario 2 (8 nodes, 5Hz):
python plot_metrics.py event_metrics.log 8 5

This will generate:

  • bandwidth_[nodes]nodes_[freq]hz.png: Shows bandwidth usage over time
  • delay_[nodes]nodes_[freq]hz.png: Shows delay statistics over time

Test Scenarios

Scenario 1: 3 Nodes at 2Hz

  • 3 nodes running for 100 seconds
  • Each node generates events at 2Hz
  • Logger collects and timestamps events

Scenario 2: 8 Nodes at 5Hz

  • 8 nodes running for 100 seconds
  • Each node generates events at 5Hz
  • Logger collects and timestamps events

Metrics Collected

  • Event transmission delays (min, max, median, 90th percentile)
  • Bandwidth usage per second