This project implements a distributed gossip protocol for signature distribution in a hierarchical network using the NS-3 network simulation framework. The simulation is parallelized using MPI (Message Passing Interface) to distribute computations across multiple processes, allowing for efficient simulation of large-scale networks.
The system is organized as a hierarchical network with three levels:
- Peers: Basic entities that create and gossip signatures.
- Subnet Aggregators: Collect signatures from peers within their subnet and forward them to the global aggregator.
- Global Aggregator: Receives aggregations from all subnet aggregators.
Instead of peers sending signatures directly to subnet aggregators, signatures are gossiped between peers with a fan-out factor of 6. Each peer:
- Generates its own signature
- Forwards new signatures to 6 randomly selected peers in the same subnet
- Only forwards each unique signature once
Subnet aggregators monitor the signatures spreading through the network and collect them until reaching a threshold (2/3 + 1 of all peers in the subnet).
The simulation leverages MPI to distribute the computational workload:
- Each MPI process handles a subset of subnets
- Only rank 0 (master process) hosts the global aggregator
- Workers communicate with the master through MPI messages
- Each process simulates only its assigned subnets, reducing memory usage and improving performance
- C++23 compiler
- CMake 3.25 or higher
- MPI implementation (OpenMPI recommended)
The project includes a script to download, build, and install NS-3.44 locally within the project:
# Make the setup script executable (if not already)
chmod +x setup_ns3.sh
# Run the setup script
./setup_ns3.shThis script will:
- Create an
externaldirectory - Download NS-3.44 source code
- Extract and build NS-3 with optimized settings
- Install NS-3 within the project folder
The process may take 20-30 minutes depending on your system.
mkdir -p cmake-build-debug
cd cmake-build-debug
cmake ..
makeTo run the simulation with MPI:
mpirun -np <num_processes> ./main [options]Replace <num_processes> with the number of MPI processes you want to use.
You can configure the simulation using the following command-line options:
| Parameter | Description | Default |
|---|---|---|
--nSubnets=<value> |
Number of subnets in the simulation | 5 |
--nPeersPerSubnet=<value> |
Number of peers in each subnet | 512 |
--nRounds=<value> |
Number of rounds of aggregation to run sequentially | 5 |
# Run with 4 MPI processes using default settings
mpirun -np 4 ./main
# Run with 8 MPI processes, 5 subnets, 512 peers per subnet
mpirun -np 8 ./main --nSubnets=5 --nPeersPerSubnet=512
# Run with 16 MPI processes, 16 subnets, 1024 peers per subnet, 3 rounds
mpirun -np 16 ./main --nSubnets=16 --nPeersPerSubnet=1024 --nRounds=3The main configuration parameters are in main.cpp:
nSubnets: Total number of subnets in the simulationnPeersPerSubnet: Number of peers in each subnetm_fanOut: Number of peers that each peer gossips to (default: 6)m_threshold: Threshold for subnet aggregators (default: 2/3 * nPeers + 1)
The simulation outputs several performance metrics:
- Total virtual time: Time taken in the simulated environment
- Total real execution time: Actual wall-clock time
- Ratio (virtual/real): Efficiency of simulation
- Total number of peers: Size of the simulated network
All logs include timestamps in milliseconds and identify the source:
- Peer messages show the peer ID
- Subnet Aggregator (SA) messages show the subnet ID
- Global Aggregator messages show when subnet aggregations are received