diff options
author | Andreas Lindhé <andreas@lindhe.io> | 2017-10-31 08:33:46 +0100 |
---|---|---|
committer | Andreas Lindhé <andreas@lindhe.io> | 2017-10-31 08:41:40 +0100 |
commit | bc5ecd6da7f068a12b9ee5397178723481c7a3ea (patch) | |
tree | 6ac5bb33df7c3aacde8eb254c4aee1ce1df9dd29 | |
parent | 2d5d5be5702867a7a719312a5a148489c3b68f31 (diff) | |
download | midbro-bc5ecd6da7f068a12b9ee5397178723481c7a3ea.tar.gz midbro-bc5ecd6da7f068a12b9ee5397178723481c7a3ea.tar.bz2 |
Move all files one level down
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | Makefile (renamed from broccoli/Makefile) | 0 | ||||
-rw-r--r-- | broccoli/src/pasad.c | 160 | ||||
-rw-r--r-- | data/U.txt (renamed from broccoli/data/U.txt) | 0 | ||||
-rw-r--r-- | includes/broevent.h (renamed from broccoli/includes/broevent.h) | 0 | ||||
-rw-r--r-- | includes/fifoqueue.h (renamed from broccoli/includes/fifoqueue.h) | 0 | ||||
-rw-r--r-- | includes/midbro.h (renamed from broccoli/includes/midbro.h) | 0 | ||||
-rw-r--r-- | includes/types.h (renamed from broccoli/includes/types.h) | 0 | ||||
-rw-r--r-- | script/README (renamed from broccoli/script/README) | 0 | ||||
-rwxr-xr-x | script/investigate.sh (renamed from broccoli/script/investigate.sh) | 0 | ||||
-rwxr-xr-x | script/livegraph.sh (renamed from broccoli/script/livegraph.sh) | 0 | ||||
-rw-r--r-- | script/measure-packets.sh (renamed from broccoli/script/measure-packets.sh) | 0 | ||||
-rw-r--r-- | script/modbus.bro (renamed from broccoli/script/modbus.bro) | 0 | ||||
-rw-r--r-- | script/pasad-parsed.bro (renamed from broccoli/script/pasad-parsed.bro) | 0 | ||||
-rw-r--r-- | script/pasad-simple.bro (renamed from broccoli/script/pasad-simple.bro) | 0 | ||||
-rw-r--r-- | script/run-midbro.sh (renamed from broccoli/script/run-midbro.sh) | 0 | ||||
-rw-r--r-- | src/broevent.c (renamed from broccoli/src/broevent.c) | 0 | ||||
-rw-r--r-- | src/fifoqueue.c (renamed from broccoli/src/fifoqueue.c) | 0 | ||||
-rw-r--r-- | src/midbro.c (renamed from broccoli/src/midbro.c) | 0 | ||||
-rw-r--r-- | test/midbro_test.c (renamed from broccoli/test/midbro_test.c) | 0 | ||||
-rw-r--r-- | test/tests.c (renamed from broccoli/test/tests.c) | 0 |
21 files changed, 4 insertions, 164 deletions
@@ -1,6 +1,6 @@ -broccoli/bin/ -broccoli/build/ -broccoli/script/.state/ -broccoli/lib/ +bin/ +build/ +.state/ +lib/ *.o *.log diff --git a/broccoli/Makefile b/Makefile index 02d9f66..02d9f66 100644 --- a/broccoli/Makefile +++ b/Makefile diff --git a/broccoli/src/pasad.c b/broccoli/src/pasad.c deleted file mode 100644 index 58dc9ab..0000000 --- a/broccoli/src/pasad.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - - -Course- - DAT300: Data-driven support for cyber-physical systems - - -Project- - Intrusion Detection for Industrial Control Networks - - -Group 8- - Hassan Ghalayini - hassang@student.chalmers.se - Malama Kasanda - malama@student.chalmers.se - Vaios Taxiarchis - vaios@student.chalmers.se - - Modified by Robin Krahl <guskraro@student.gu.se>, Group 3: - - Write sensor readings and distance to text files - - Take the arguments N, L, r from argc - - Formatting - - */ - -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include "midbro.h" - -int main(int argc, char **argv) -{ - clock_t begin; - int l=0; - double t=30; - - if (argc != 4) { - fprintf(stderr, "Usage: %s N L r\n", argv[0]); - fprintf(stderr, " Example values: N = 1000, L = 500, r = 18\n"); - fprintf(stderr, "Wrong argument count. Aborting.\n"); - return 1; - } - - int N = atoi(argv[1]); - int L = atoi(argv[2]); - int r = atoi(argv[3]); - - /* Arrays and variables */ - int sL=86336; - double s[sL]; - double U[L][r]; - double X[L]; - double product_Xt_P_X; - double product_Xt_X; - int i=0,j=0,c=0,d=0,k=0; - double sum=0.0,dist=0.0; - - start_data_capture(); - - /* File Descriptor to read projection matrix from U.txt */ - FILE *file; - char ch='a'; - int flag=0; - file=fopen("U.txt", "r"); - if (!file) { - fprintf(stderr, "Could not open U.txt. Aborting.\n"); - return 1; - } - printf(" >Reading U[%dx%d] matrix from .txt file...",L,r); - /* Read all values to an array */ - for(i=0;i<L;i++) - { - if(flag==1){break;} - for(j=0;j<r;j++) - { - /* Use %lf format specifier, to read doubles with scanf */ - if(!fscanf(file,"%lf",&U[i][j])) - break; - /* Break the inner loop and set flag=true */ - ch = getc(file); - if(ch == EOF) - { - flag=1; - break; - } - /* Break the inner loop when find \n */ - else if(ch - '0'== -38) - break; - } - } - /* Close File Descriptor */ - fclose(file); - printf("Completed!\n"); - - for(i=0;i<N;i++) - { - s[i] = (double)request_value(); - } - - int p=1; - X[0]=0; - - for(i=N-L+1;i<N;i++) - { - X[p] = s[i]; - sum = sum + X[p]*X[p]; - p++; - } - product_Xt_X = sum; - sum = 0; - - FILE *file_sensor = fopen("sensor.dat", "w"); - FILE *file_distance = fopen("distance.dat", "w"); - - begin = clock(); - while(1) - { - int value = request_value(); - s[p] = (double) value; - fprintf(file_sensor, "%d\n", value); - - /* Xt[1xL] * X[Lx1] */ - product_Xt_X = product_Xt_X - X[0]*X[0] + s[p]*s[p]; - - /* Generate new test vector Xtest */ - for(j=0;j<L-1;j++) - { - X[j] = X[j+1]; - } - X[L-1] = s[p]; - - product_Xt_P_X = 0; - /* P_1 = Xt[1xL] * U[Lxr] */ - for (d=0;d<r;d++) - { - for (k=0;k<L;k++) - { - sum = sum + X[k]*U[k][d]; - } - product_Xt_P_X = product_Xt_P_X + sum*sum; - sum = 0; - } - - dist = (product_Xt_X - product_Xt_P_X)/L; - p++; - - printf("%lf\n",dist); - fprintf(file_distance, "%lf\n", dist); - - fflush(file_sensor); - fflush(file_distance); - } - - fclose(file_sensor); - fclose(file_distance); - - printf(" [Program exits]\n"); - /* Stop timer */ - clock_t end = clock(); - - /* Print the time elapsed */ - printf("Time elapsed: %f milliseconds\n", 1000*((double)(end - begin) / CLOCKS_PER_SEC)); - - return 0; -} diff --git a/broccoli/data/U.txt b/data/U.txt index 3f124f0..3f124f0 100644 --- a/broccoli/data/U.txt +++ b/data/U.txt diff --git a/broccoli/includes/broevent.h b/includes/broevent.h index 5e34f5c..5e34f5c 100644 --- a/broccoli/includes/broevent.h +++ b/includes/broevent.h diff --git a/broccoli/includes/fifoqueue.h b/includes/fifoqueue.h index 75b09c4..75b09c4 100644 --- a/broccoli/includes/fifoqueue.h +++ b/includes/fifoqueue.h diff --git a/broccoli/includes/midbro.h b/includes/midbro.h index e7143a3..e7143a3 100644 --- a/broccoli/includes/midbro.h +++ b/includes/midbro.h diff --git a/broccoli/includes/types.h b/includes/types.h index 149415e..149415e 100644 --- a/broccoli/includes/types.h +++ b/includes/types.h diff --git a/broccoli/script/README b/script/README index 15f121e..15f121e 100644 --- a/broccoli/script/README +++ b/script/README diff --git a/broccoli/script/investigate.sh b/script/investigate.sh index 9f67949..9f67949 100755 --- a/broccoli/script/investigate.sh +++ b/script/investigate.sh diff --git a/broccoli/script/livegraph.sh b/script/livegraph.sh index 67111bc..67111bc 100755 --- a/broccoli/script/livegraph.sh +++ b/script/livegraph.sh diff --git a/broccoli/script/measure-packets.sh b/script/measure-packets.sh index b3df4be..b3df4be 100644 --- a/broccoli/script/measure-packets.sh +++ b/script/measure-packets.sh diff --git a/broccoli/script/modbus.bro b/script/modbus.bro index d258de3..d258de3 100644 --- a/broccoli/script/modbus.bro +++ b/script/modbus.bro diff --git a/broccoli/script/pasad-parsed.bro b/script/pasad-parsed.bro index 88b1be1..88b1be1 100644 --- a/broccoli/script/pasad-parsed.bro +++ b/script/pasad-parsed.bro diff --git a/broccoli/script/pasad-simple.bro b/script/pasad-simple.bro index db3b4be..db3b4be 100644 --- a/broccoli/script/pasad-simple.bro +++ b/script/pasad-simple.bro diff --git a/broccoli/script/run-midbro.sh b/script/run-midbro.sh index a9bb008..a9bb008 100644 --- a/broccoli/script/run-midbro.sh +++ b/script/run-midbro.sh diff --git a/broccoli/src/broevent.c b/src/broevent.c index 362ed5e..362ed5e 100644 --- a/broccoli/src/broevent.c +++ b/src/broevent.c diff --git a/broccoli/src/fifoqueue.c b/src/fifoqueue.c index e7ed8f6..e7ed8f6 100644 --- a/broccoli/src/fifoqueue.c +++ b/src/fifoqueue.c diff --git a/broccoli/src/midbro.c b/src/midbro.c index e2f9644..e2f9644 100644 --- a/broccoli/src/midbro.c +++ b/src/midbro.c diff --git a/broccoli/test/midbro_test.c b/test/midbro_test.c index c0f4ba6..c0f4ba6 100644 --- a/broccoli/test/midbro_test.c +++ b/test/midbro_test.c diff --git a/broccoli/test/tests.c b/test/tests.c index 5b91feb..5b91feb 100644 --- a/broccoli/test/tests.c +++ b/test/tests.c |