Compare commits
3 Commits
c6926c8baa
...
3e87203535
Author | SHA1 | Date |
---|---|---|
pavanvpatil | 3e87203535 | |
pavanvpatil | 50dc610c43 | |
pavanvpatil | 1edf6729e2 |
|
@ -0,0 +1,47 @@
|
|||
/* pavan changes */
|
||||
#include<time.h>
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include "parser.h"
|
||||
|
||||
void attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_OF_FREQUENCY)
|
||||
{
|
||||
*COUNT = *COUNT+1;
|
||||
printf("count: %f\n",*COUNT);
|
||||
float CURR_FREQ=to_intconvertor(df->dpmu[0]->freq);
|
||||
*SUM_OF_FREQUENCY+=CURR_FREQ;
|
||||
float FREQ_AVG=*SUM_OF_FREQUENCY/(*COUNT*1.0f);
|
||||
float DETECT_PERCENT=(abs(FREQ_AVG-CURR_FREQ)/(FREQ_AVG*1.0f))*100;
|
||||
|
||||
printf("Detect_percent: %f\n",DETECT_PERCENT);
|
||||
printf("frequency average: %f\n",FREQ_AVG);
|
||||
|
||||
float THRESHOLD=25;
|
||||
if(DETECT_PERCENT>THRESHOLD)
|
||||
printf("ATTACK DETECTED\n");
|
||||
else
|
||||
printf("NO PROBLEM\n");
|
||||
|
||||
if(*COUNT==1)
|
||||
{
|
||||
time(START);
|
||||
printf("entered\n");
|
||||
}
|
||||
|
||||
|
||||
time_t END;
|
||||
time(&END);
|
||||
|
||||
double time_used = difftime(END,*START);
|
||||
printf("time used %lf\n",time_used);
|
||||
|
||||
|
||||
if(time_used > 60)
|
||||
{
|
||||
time(START);
|
||||
*SUM_OF_FREQUENCY=CURR_FREQ;
|
||||
*COUNT=1;
|
||||
}
|
||||
}
|
||||
|
||||
/* pavan changes */
|
|
@ -0,0 +1,3 @@
|
|||
/* pavan changes */
|
||||
void attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_OF_FREQUENCY);
|
||||
/* pavan changes */
|
|
@ -60,9 +60,10 @@ SOURCES = \
|
|||
ipdcGui.c ipdcGui.h \
|
||||
attack_detection.c attack_detection.h \
|
||||
data_vis.c data_vis.h \
|
||||
utility_tools.c utility_tools.h
|
||||
utility_tools.c utility_tools.h \
|
||||
Attack_detect.c Attack_detect.h
|
||||
|
||||
OBJECTS = ipdc.c recreate.o connections.o new_pmu_or_pdc.o parser.o dallocate.o align_sort.o ipdcGui.o attack_detection.o data_vis.o utility_tools.o
|
||||
OBJECTS = ipdc.c recreate.o connections.o new_pmu_or_pdc.o parser.o dallocate.o align_sort.o ipdcGui.o attack_detection.o data_vis.o utility_tools.o Attack_detect.o
|
||||
|
||||
CLEAN_OBJECTS = recreate.o connections.o new_pmu_or_pdc.o parser.o dallocate.o align_sort.o ipdcGui.o ~iPDC.xml
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include "parser.h"
|
||||
#include "global.h"
|
||||
#include "dallocate.h"
|
||||
|
@ -61,6 +62,7 @@
|
|||
#include "connections.h"
|
||||
#include "recreate.h"
|
||||
#include "utility_tools.h"
|
||||
#include "Attack_detect.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* FUNCTION cfgparser(): */
|
||||
|
@ -70,6 +72,15 @@
|
|||
/* also in the file `cfg.bin` by calling */
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/* pavan changes */
|
||||
/* variables declared of attack_detect function */
|
||||
float SUM_OF_FREQUENCY=0;
|
||||
float COUNT=0;
|
||||
time_t START;
|
||||
/* pavan changes */
|
||||
|
||||
|
||||
void cfgparser(unsigned char st[]){
|
||||
|
||||
unsigned char *s;
|
||||
|
@ -1269,8 +1280,13 @@ int dataparser(unsigned char data[]) {
|
|||
//No match for configuration frame
|
||||
printf("Configuration is not fresent for received data frame!\n");
|
||||
}
|
||||
printf("freq = %d\n",to_intconvertor(df->dpmu[0]->freq));
|
||||
|
||||
/*pavan changes*/
|
||||
attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
|
||||
/*pavan changes*/
|
||||
|
||||
// temp code
|
||||
/* karthik changes*/
|
||||
int freq = to_intconvertor(df->dpmu[0]->freq);
|
||||
if(util_map != NULL){
|
||||
g_red_image = gdk_pixbuf_new_from_file_at_size ("red.png", 24,24,NULL);
|
||||
|
@ -1286,6 +1302,7 @@ int dataparser(unsigned char data[]) {
|
|||
gtk_widget_show_all(GTK_WIDGET(util_map));
|
||||
|
||||
}
|
||||
/* karthik changes */
|
||||
|
||||
if((config_change == 14) ||(config_change == 10))
|
||||
return config_change;
|
||||
|
|
Loading…
Reference in New Issue