-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
22,935 additions
and
576 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
#$1 - WoR PCAP $2 WR PCAP $3 Slot $4 $Folder | ||
#To find Probe/FDF Ratio in a per second slot | ||
#Probe = Take all probe requests and probe responses in the pcap | ||
#Data = Take only fresh data frames of a particular AC via the BSSID 07:00/07:01 | ||
|
||
|
||
filename=$1 | ||
folder=$2 #Output Folder | ||
|
||
home_dir=`eval echo ~$USER/` | ||
codePath=$home_dir"Scripts/CausalAnalysis/1PReq_NPRes/" | ||
|
||
#tshark -E separator=, -T fields -e frame.time_epoch -e frame.number -e prism.did.frmlen -e prism.did.channel -e prism.did.mactime -e prism.did.rate -e wlan.fc.type_subtype -e wlan_mgt.ssid -e wlan.bssid -e wlan_mgt.ds.current_channel -e wlan_mgt.qbss.scount -e wlan.fc.retry -e wlan.fc.pwrmgt -e wlan.fc.moredata -e wlan.fc.frag -e wlan.duration -e wlan.ra -e wlan.ta -e wlan.sa -e wlan.da -e wlan.seq -e wlan.qos.priority -e wlan.qos.amsdupresent -e wlan.fc.type -e wlan_mgt.fixed.reason_code -e wlan.fc.ds -r $file | ||
#Time, subtype, ssid, bssid, channel, station_count, ra, ta, sa, da, type | ||
#1, 7, 8, 9, 10, 11, 17, 18, 19, 20, 24 | ||
|
||
cat $filename | grep '0x04\|0x05' | awk -v OFS="," -F"," '{print $1, $7, $19, $20, $3}' > /tmp/frames.csv | ||
if [ ! -d $folder ]; then | ||
mkdir $folder | ||
fi | ||
|
||
gcc $codePath/ParsePCAPFor1PReq_NPRes_UniqueBSSIDs.c -o $codePath/ParsePCAPFor1PReq_NPRes_UniqueBSSIDs.o | ||
$codePath/ParsePCAPFor1PReq_NPRes_UniqueBSSIDs.o /tmp/frames.csv > $folder/1PReqNPRes_UniqueBSSIDs.csv | ||
|
||
gcc $codePath/ParsePCAPFor1PReq_NPRes.c -o $codePath/ParsePCAPFor1PReq_NPRes.o | ||
$codePath/ParsePCAPFor1PReq_NPRes.o /tmp/frames.csv > $folder/1PReqNPRes.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
#$1 - WoR PCAP $2 WR PCAP $3 Slot $4 $Folder | ||
#To find Probe/FDF Ratio in a per second slot | ||
#Probe = Take all probe requests and probe responses in the pcap | ||
#Data = Take only fresh data frames of a particular AC via the BSSID 07:00/07:01 | ||
|
||
|
||
filename=$1 | ||
folder=$2 #Output Folder | ||
|
||
home_dir=`eval echo ~$USER/` | ||
codePath=$home_dir"Scripts/CausalAnalysis/1PReq_NPRes/" | ||
|
||
#tshark -E separator=, -T fields -e frame.time_epoch -e frame.number -e prism.did.frmlen -e prism.did.channel -e prism.did.mactime -e prism.did.rate -e wlan.fc.type_subtype -e wlan_mgt.ssid -e wlan.bssid -e wlan_mgt.ds.current_channel -e wlan_mgt.qbss.scount -e wlan.fc.retry -e wlan.fc.pwrmgt -e wlan.fc.moredata -e wlan.fc.frag -e wlan.duration -e wlan.ra -e wlan.ta -e wlan.sa -e wlan.da -e wlan.seq -e wlan.qos.priority -e wlan.qos.amsdupresent -e wlan.fc.type -e wlan_mgt.fixed.reason_code -e wlan.fc.ds -r $file | ||
#Time, subtype, ssid, bssid, channel, station_count, ra, ta, sa, da, type | ||
#1, 7, 8, 9, 10, 11, 17, 18, 19, 20, 24 | ||
|
||
cat $filename | grep '0x04\|0x05' | awk -v OFS="," -F"," '{print $1, $7, $19, $20, $3}' > /tmp/frames.csv | ||
if [ ! -d $folder ]; then | ||
mkdir $folder | ||
fi | ||
|
||
gcc $codePath/ParsePCAPFor1PReq_NPRes_UniqueBSSIDs.c -o $codePath/ParsePCAPFor1PReq_NPRes_UniqueBSSIDs.o | ||
$codePath/ParsePCAPFor1PReq_NPRes.o /tmp/frames.csv > $folder/1PReqNPRes.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
tshark -E separator=, -T fields -e frame.time_epoch -e wlan.fc.type_subtype -e prism.did.channel -e wlan.sa -e wlan.da -e wlan.bssid -e wlan.ta -e wlan.ra -e wlan.duration -e prism.did.rate -e wlan.fc.retry -r WR6.pcap > WR6.csv | ||
2009 | ||
*/ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
#include<string.h> | ||
#define Max_Frames 10000000 | ||
#define SIFS 0.000011 | ||
|
||
struct PCAP_Data | ||
{ | ||
double frame_time_epoch; | ||
char wlan_fc_type_subtype[5]; | ||
int prism_did_channel; | ||
char wlan_sa[18]; | ||
char wlan_da[18]; | ||
char wlan_bssid[18]; | ||
char wlan_ta[18]; | ||
char wlan_ra[18]; | ||
double wlan_duration; | ||
int frame_len; | ||
int prism_did_rate; | ||
int wlan_fc_retry; | ||
int wlan_mgt_ds_current_channel; | ||
char wlan_mgt_ssid[33]; | ||
}PCAP_DATA_VAL[Max_Frames]; | ||
|
||
|
||
unsigned long framesCount=0; | ||
|
||
void LoadPCAPData(char *pcap); | ||
void FindPreqPres(); | ||
|
||
void main( int argc, char *argv[] ) | ||
{ | ||
if ( argc != 2 ) | ||
{ | ||
printf( "usage: %s filename\n", argv[0] ); | ||
} | ||
else | ||
{ | ||
LoadPCAPData(argv[1]); | ||
FindPreqPres(); | ||
} | ||
|
||
} | ||
|
||
//Load Pcap into Structure Array | ||
void LoadPCAPData(char *pcap) | ||
{ | ||
unsigned long frame=-1; | ||
FILE *file = fopen(pcap, "r" ); | ||
if (file == NULL) | ||
{ | ||
printf("\n Unable to read file"); | ||
return; | ||
} | ||
char buffer[4095]; | ||
char *token; | ||
char * end; | ||
double temp; | ||
while(fgets(buffer, 4095, file) != NULL) | ||
{ | ||
frame=frame+1; | ||
token = strtok(buffer, ","); | ||
if (token != NULL) | ||
{ | ||
temp = strtod (token, & end); | ||
if (end == token) | ||
PCAP_DATA_VAL[frame].frame_time_epoch = -1; | ||
else | ||
PCAP_DATA_VAL[frame].frame_time_epoch = temp; | ||
} | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
strcpy(PCAP_DATA_VAL[frame].wlan_fc_type_subtype, token); | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
strcpy(PCAP_DATA_VAL[frame].wlan_sa, token); | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
strcpy(PCAP_DATA_VAL[frame].wlan_da, token); | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
PCAP_DATA_VAL[frame].frame_len= atoi(token); | ||
|
||
|
||
} | ||
framesCount=frame; | ||
fclose(file); | ||
|
||
} | ||
|
||
void FindPreqPres() | ||
{ | ||
int eFrame=0; | ||
int nextFrame; | ||
char *success; | ||
int illegalFrames=0; | ||
int totalFrames=0; | ||
while(eFrame<framesCount) | ||
{ | ||
|
||
if(strcmp(PCAP_DATA_VAL[eFrame].wlan_fc_type_subtype,"0x04") == 0 && | ||
strcmp(PCAP_DATA_VAL[eFrame+1].wlan_fc_type_subtype,"0x05") == 0) | ||
{ | ||
int nFrame = eFrame + 1; | ||
int probeResponse = 0; | ||
|
||
while((nFrame<framesCount)&& | ||
strcmp(PCAP_DATA_VAL[nFrame].wlan_da,PCAP_DATA_VAL[eFrame].wlan_sa) == 0 && | ||
strcmp(PCAP_DATA_VAL[nFrame].wlan_fc_type_subtype,"0x05") == 0) | ||
{ | ||
|
||
probeResponse ++; | ||
nFrame ++; | ||
} | ||
if(probeResponse > 0) | ||
printf("%d\n",probeResponse); | ||
eFrame = nFrame; | ||
} | ||
else | ||
eFrame++; | ||
} | ||
} | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
tshark -E separator=, -T fields -e frame.time_epoch -e wlan.fc.type_subtype -e prism.did.channel -e wlan.sa -e wlan.da -e wlan.bssid -e wlan.ta -e wlan.ra -e wlan.duration -e prism.did.rate -e wlan.fc.retry -r WR6.pcap > WR6.csv | ||
2009 | ||
*/ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
#include<string.h> | ||
#define Max_Frames 10000000 | ||
#define SIFS 0.000011 | ||
|
||
struct PCAP_Data | ||
{ | ||
double frame_time_epoch; | ||
char wlan_fc_type_subtype[5]; | ||
int prism_did_channel; | ||
char wlan_sa[18]; | ||
char wlan_da[18]; | ||
char wlan_bssid[18]; | ||
char wlan_ta[18]; | ||
char wlan_ra[18]; | ||
double wlan_duration; | ||
int frame_len; | ||
int prism_did_rate; | ||
int wlan_fc_retry; | ||
int wlan_mgt_ds_current_channel; | ||
char wlan_mgt_ssid[33]; | ||
}PCAP_DATA_VAL[Max_Frames]; | ||
|
||
|
||
unsigned long framesCount=0; | ||
|
||
void LoadPCAPData(char *pcap); | ||
void FindPreqPres(); | ||
|
||
void main( int argc, char *argv[] ) | ||
{ | ||
if ( argc != 2 ) | ||
{ | ||
printf( "usage: %s filename\n", argv[0] ); | ||
} | ||
else | ||
{ | ||
LoadPCAPData(argv[1]); | ||
FindPreqPres(); | ||
} | ||
|
||
} | ||
|
||
//Load Pcap into Structure Array | ||
void LoadPCAPData(char *pcap) | ||
{ | ||
unsigned long frame=-1; | ||
FILE *file = fopen(pcap, "r" ); | ||
if (file == NULL) | ||
{ | ||
printf("\n Unable to read file"); | ||
return; | ||
} | ||
char buffer[4095]; | ||
char *token; | ||
char * end; | ||
double temp; | ||
while(fgets(buffer, 4095, file) != NULL) | ||
{ | ||
frame=frame+1; | ||
token = strtok(buffer, ","); | ||
if (token != NULL) | ||
{ | ||
temp = strtod (token, & end); | ||
if (end == token) | ||
PCAP_DATA_VAL[frame].frame_time_epoch = -1; | ||
else | ||
PCAP_DATA_VAL[frame].frame_time_epoch = temp; | ||
} | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
strcpy(PCAP_DATA_VAL[frame].wlan_fc_type_subtype, token); | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
strcpy(PCAP_DATA_VAL[frame].wlan_sa, token); | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
strcpy(PCAP_DATA_VAL[frame].wlan_da, token); | ||
|
||
token = strtok(NULL, ","); | ||
if (token != NULL) | ||
PCAP_DATA_VAL[frame].frame_len= atoi(token); | ||
|
||
|
||
} | ||
framesCount=frame; | ||
fclose(file); | ||
|
||
} | ||
|
||
void FindPreqPres() | ||
{ | ||
int eFrame=0; | ||
int nextFrame; | ||
char *success; | ||
int illegalFrames=0; | ||
int totalFrames=0; | ||
while(eFrame<framesCount) | ||
{ | ||
|
||
if(strcmp(PCAP_DATA_VAL[eFrame].wlan_fc_type_subtype,"0x04") == 0 && | ||
strcmp(PCAP_DATA_VAL[eFrame+1].wlan_fc_type_subtype,"0x05") == 0) | ||
{ | ||
int nFrame = eFrame + 1; | ||
int probeResponse = 0; | ||
|
||
char respondingBSSIDs[100][18]; | ||
int lenRespBSSIDs=1; | ||
strcpy(respondingBSSIDs[0], PCAP_DATA_VAL[nFrame].wlan_sa); | ||
while((nFrame<framesCount)&& | ||
strcmp(PCAP_DATA_VAL[nFrame].wlan_da,PCAP_DATA_VAL[eFrame].wlan_sa) == 0 && | ||
strcmp(PCAP_DATA_VAL[nFrame].wlan_fc_type_subtype,"0x05") == 0) | ||
{ | ||
if (probeResponse==0) probeResponse=1; | ||
//Check if the source of this probe response is already added or not. If it is not added then only count its probe response | ||
int count=0,flag=0; | ||
while (count < lenRespBSSIDs && !flag) | ||
{ | ||
if (strcmp(PCAP_DATA_VAL[nFrame].wlan_sa,respondingBSSIDs[count]) == 0)//Match found do not count this probe response | ||
flag=1; | ||
count++; | ||
} | ||
if (!flag) { | ||
probeResponse ++; | ||
//Unique BSSID found, add it to the list | ||
strcpy(respondingBSSIDs[lenRespBSSIDs], PCAP_DATA_VAL[nFrame].wlan_sa); | ||
lenRespBSSIDs++; | ||
} | ||
nFrame ++; | ||
} | ||
if(probeResponse > 0) | ||
printf("%d\n",probeResponse); | ||
eFrame = nFrame; | ||
} | ||
else | ||
eFrame++; | ||
} | ||
} | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python | ||
import numpy as np | ||
import sys | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
data = np.loadtxt(str(sys.argv[1])) | ||
|
||
sorted_data = np.sort(data) | ||
|
||
yvals=np.arange(len(sorted_data))/float(len(sorted_data)) | ||
|
||
s = np.vstack((sorted_data,yvals)).T | ||
np.savetxt('CDF.csv', s, delimiter=",",fmt='%.6f') | ||
#f=plt.plot(sorted_data,yvals) | ||
#plt.xscale('log'); | ||
#plt.show() | ||
#plt.savefig('CDFIFAT.png') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python | ||
import numpy as np | ||
import sys | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
data = np.loadtxt(sys.argv[1]) | ||
|
||
sorted_data = np.sort(data) | ||
|
||
yvals=np.arange(len(sorted_data))/float(len(sorted_data)) | ||
|
||
s = np.vstack((sorted_data,yvals)).T | ||
np.savetxt('CDF.csv', s, delimiter=",",fmt='%.6f') | ||
#f=plt.plot(sorted_data,yvals) | ||
#plt.xscale('log'); | ||
#plt.show() | ||
#plt.savefig('CDFIFAT.png') |
Oops, something went wrong.