Compare commits

..

No commits in common. "3e87203535dfdafb93c20966b5f49981f0aaff22" and "c6926c8baaabe8f992893813db501fa80ddf3210" have entirely different histories.

4 changed files with 3 additions and 71 deletions

View File

@ -1,47 +0,0 @@
/* 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 */

View File

@ -1,3 +0,0 @@
/* pavan changes */
void attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_OF_FREQUENCY);
/* pavan changes */

View File

@ -60,10 +60,9 @@ SOURCES = \
ipdcGui.c ipdcGui.h \
attack_detection.c attack_detection.h \
data_vis.c data_vis.h \
utility_tools.c utility_tools.h \
Attack_detect.c Attack_detect.h
utility_tools.c utility_tools.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 Attack_detect.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
CLEAN_OBJECTS = recreate.o connections.o new_pmu_or_pdc.o parser.o dallocate.o align_sort.o ipdcGui.o ~iPDC.xml

View File

@ -54,7 +54,6 @@
#include <stdlib.h>
#include <pthread.h>
#include <stdint.h>
#include <time.h>
#include "parser.h"
#include "global.h"
#include "dallocate.h"
@ -62,7 +61,6 @@
#include "connections.h"
#include "recreate.h"
#include "utility_tools.h"
#include "Attack_detect.h"
/* ---------------------------------------------------------------------------- */
/* FUNCTION cfgparser(): */
@ -72,15 +70,6 @@
/* 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;
@ -1280,13 +1269,8 @@ int dataparser(unsigned char data[]) {
//No match for configuration frame
printf("Configuration is not fresent for received data frame!\n");
}
/*pavan changes*/
attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
/*pavan changes*/
printf("freq = %d\n",to_intconvertor(df->dpmu[0]->freq));
// 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);
@ -1302,7 +1286,6 @@ 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;