Commit 3772f8bb authored by Carlos A. Iglesias's avatar Carlos A. Iglesias
Browse files

Creado un directorio securegrid-demo para dejarlo list y actualizado README

parent 7a1eebdb
......@@ -8,10 +8,35 @@ Deep Learning based Attack Detection System for Smart Grids
pip uninstall numpy
pip install --upgrade numpy==1.16.1
# Mosaik
For running the demo number of packages are needed:
sudo apt-get install git python3-numpy python3-scipy python3-h5py
In addition, there is a bug in arrow in mosaik demo, so you should install the version arrow 0.14:
pip install arrow==0.14
Execute
python securegrid-demo.py
After finishing, you will have the simulation data in the file demo.hdf5
You can visualize this file with any hdf5 viewer.
In our case, we are using ViTables (http://vitables.org/Download/).
If you desire to install it, follow the installation instructions.
The suggested process is:
apt install libhdf5-dev
pip install pyqt5
pip install vitables
Then execute 'vitables' in a terminal.
If you wish to visualize the scenario, you can install maverig: https://bitbucket.org/mosaik/maverig/src/master/. Basically
pip install maverig
## Usage
In order to detect attacks, the power consumption values of the houses are analyzed. For that reason, first, the needed DataFrames to feed the neural network (autoencoder) have to be created.
For this purpose, the notebook dataframe_creation is used. This notebook generates .pkl files that contain the DataFrames with the necessary data. In addition, these DataFrames contain the following features:
| Feature | Description |
......@@ -29,6 +54,10 @@ For this purpose, the notebook dataframe_creation is used. This notebook generat
| Q3 | Third quartile of the window values |
| IQR | Interquartile range of the window values |
For executing the dataframe, it is needed to install the package h5py
pip install h5py
Once the DataFrames are created, they are used to feed the autoencoder. Therefore, the conv1d_autoencoder.py file has to be configured.
The normal_data_path variable has to contain the path to the .pkl file that contains data without attacks, that is to say, a normal behaviour of the houses. In addition, the attack_data_path variable has to contain the path to the .pkl file that contains the data that is wanted to be analyzed in order to detect attacks.
......
This module allows users to generate synthetic data from a smart grid that suffers False Data Injection Attacks. For this purpose, a smart grid is simulated using Mosaik, which can be installed following the instructions of this link https://mosaik.readthedocs.io/en/latest/installation.html.
Basically, it requres two steps:
1) Installing mosaik: pip install mosaik
2) Installing mosaik-demo.
1) Installing mosaik:
$ pip install mosaik
2) Installing packages and requirements for the demo
$ sudo apt-get install git python3-numpy python3-scipy python3-h5py
$ cd securegrid-demo
pip install -r requirements.txt
Mosaik only allows users to simulate a scenario that contains normal smart grid behavior, so this module has been implemented in order to simulate attacks. The attack that can be simulated modifies the power consumption values of the houses to a specific percentage of the original value.
The directory securegrid-demo contains the demo. It has been done extending mosaik-demo (git clone https://git@bitbucket.org/mosaik/mosaik-demo.git ~/Code/mosaik-demo) with the files `securegrid-demo.py`, `householdsim.py`, `attack.py` and `model_house.py`.
After installing Mosaik, the original `demo.py` file in the `mosaik-demo` folder has to be replaced by the one in this folder. The `attack.py`, `householdsim.py` and `model_house.py` files have also to be copied to the `mosaik-demo` folder.
Mosaik only allows users to simulate a scenario that contains normal smart grid behavior, so this module has been implemented in order to simulate attacks. The attack that can be simulated modifies the power consumption values of the houses to a specific percentage of the original value.
In order to define how many houses of the simulation suffer an attack, the variable `nAttacks` of the `demo.py` file can be modified.
......@@ -15,6 +19,17 @@ Furthermore, to define the moment in which the attack starts, the variable `atta
Finally, the following command starts the simulation.
$ python demo.py
$ python securegrid-demo.py
Once the simulation ends, the results are stored in the `demo.hdf5` file.
During the simulation, the grid can be inspected by accessing to `http://localhost:8000`.
For inspecting hdf5 file, an hdf5 viewer should be used. In linux, ViTables can be used, which is available at http://vitables.org/Download/.
It can be installed as follows.
$ apt install libhdf5-dev
$ python -m pip install pyqt5
$ python -m pip install vitables
The files that will be used for attack detection are Series/HouseholdSim-0.House_{N}/P_out which contain the power of House N. It has 44.640 values, since the
simulator generates data every minute for a month (60 minutes * 24 hours * 31 days).
File mode changed from 100755 to 100644
mosaik-demo @ 5f3f4d8c
Subproject commit 5f3f4d8c34ec614e3486e889b482be6e1a5977a4
securegrid-demo @ 5f3f4d8c
Subproject commit 5f3f4d8c34ec614e3486e889b482be6e1a5977a4
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment