An intrusion detection system (IDS) for WiFi networks that combines federated learning with a Deep Belief Network (DBN). Multiple clients train locally and share model updates with a central server, which aggregates them using Federated Averaging (FedAvg).
- Federated learning: clients train locally; only model updates are shared
- DBN-based model: RBM-stacked pretraining with FNN classifier
- RPC server/client: lightweight Go services to exchange model parameters
- Visualization & metrics: accuracy, precision/recall, F1, ROC, confusion matrix
config/ # YAML configs (placeholders)
datasets/ # Data and processed CSVs
logs/ # Server and client logs
output_images/ # Plots generated during training
scripts/ # Data helpers (placeholders)
src/
clients/
client1/ # Go RPC client + Python runner
client2/, client3/ # Python clients (placeholders)
FEDavg/ # FedAvg aggregator + client config JSON
models/ # DBN/RBM implementations and training scripts
server/ # Go RPC server + helper scripts
trained models/ # Local/global model checkpoints (.pth)
Notable files:
src/server/server.go: RPC server (listens on0.0.0.0:8080) serving and accepting model filessrc/clients/client1/client.go: RPC client to download global model and runDBN_client.py, then upload updatessrc/FEDavg/fedavg.py: FedAvg aggregator working fromclient_configuration.jsonsrc/models/{DBN.py,RBM.py}: model code;DBN_client*.pytraining entry pointssrc/FEDavg/client_configuration.json: source of truth for clients and global model path
- Python 3.10+ (3.12 tested by bytecode present)
- Go 1.20+
- Recommended: Linux environment with virtualenv/conda
Python packages commonly used by the codebase:
torch,torchvision(optional),tqdm,pandas,scikit-learn,matplotlib,seaborn,networkx,torchviz
If requirements.txt is empty, install manually:
python -m venv .venv && source .venv/bin/activate
pip install torch tqdm pandas scikit-learn matplotlib seaborn networkx torchviz- Place your processed CSVs under
datasets/processed/(e.g.,Filtered_dataset.csv,Preprocessed_set*.csv). - Some scripts contain absolute paths. Update them to point to files under
datasets/processed/on your machine. - Example quick check helper:
datasets/processed/preprocess.pyprints unique label values from the last column.
Set these before running server/clients to avoid path issues (note: folder name has a space):
# Run from repository root
export PARAMS_PATH="$PWD/src/trained models/GLOBAL_dbn_rbm_model.pth"
export JSON_PATH="$PWD/src/FEDavg/client_configuration.json"
export UNIQUE_ID="client_001"
export NUMBER_ITR="10000" # number of instances trained last iteration
export NAME="$(hostname)" # client display nameHelper scripts:
src/server/server_setup.shexportsPARAMS_PATHandJSON_PATHto~/.bashrcsrc/clients/client_setup.shshows an example client-side setup and cron scheduling
The server expects to find auth.json and writes into ../FEDavg/ relative to its working directory.
# From repo root
cd src/server
go run server.go
# The server listens on 0.0.0.0:8080 and serves model at $PARAMS_PATHAuthentication list: src/server/auth.json (valid client IDs). Update it to match your clients.
The Go client performs two operations:
dwn: download the global model (via RPC) intoPARAMS_PATHand run../../models/DBN_client.pyupdt: upload the locally updated model inPARAMS_PATHback to the server
# From repo root
cd src/clients/client1
# Set env vars as shown above, ensure dataset paths in Python scripts are valid
# 1) Download global params and trigger Python training
go run client.go -opn dwn
# 2) After training finishes, upload updated params
go run client.go -opn updtRPC address: The client currently dials a placeholder host. Update both occurrences in src/clients/client1/client.go to your server:
rpc.Dial("tcp", "NotAvailable-37552.portmap.host:37552")→ e.g.rpc.Dial("tcp", "<server-ip>:8080")
Aggregation is driven by src/FEDavg/client_configuration.json:
network_summary.last_iteration_summary.global_model_path: path to the global model checkpointclients[]: list of clients withinstances_trained_last_iterationand their model checkpoints
You can trigger FedAvg manually:
# Ensure JSON_PATH is exported to src/FEDavg/client_configuration.json
python src/FEDavg/fedavg.pyNote: The server also invokes FedAvg after receiving a client update.
Several training entry points are provided under src/models/. Make sure to change any absolute dataset paths to your local paths under datasets/processed/.
DBN_client.py,DBN_client_with_visualization.py,DBN_client_two_attacks.pyDBN_server.py(server-side training)
These scripts typically:
- Pretrain a DBN via stacked RBMs (see
RBM.py) - Build an FNN from the DBN layers (
initialize_model) - Train and report metrics, optionally saving a
.pthcheckpoint tosrc/trained models/
- Checkpoints:
src/trained models/*.pth - Metrics/plots:
output_images/*.png - Logs:
logs/server.log,logs/client*.log
- RPC cannot connect: Update the RPC host/port in
src/clients/client1/client.goto your server’s IP and open port8080. - Relative paths fail: Run the server from
src/server/; it expectsauth.jsonin CWD and writes to../FEDavg/. - Spaces in path: The
trained modelsfolder contains a space. Always quotePARAMS_PATHas shown. - FedAvg script error: If
src/FEDavg/fedavg.pycomplains about function arguments, ensure_load_jsonsignature matches how it is called and thatJSON_PATHpoints to an existing JSON. - Hard-coded absolute paths: Some model scripts include absolute paths. Replace them with repo-relative paths.
- Open an issue describing the change
- Create a feature branch and submit a PR
- Please avoid committing large binaries; link to dataset sources instead
MIT License