Commit a11d4d21 authored by Mohammad Imran Syed's avatar Mohammad Imran Syed
Browse files

fixed per user traces part

parent b423c786
......@@ -269,7 +269,7 @@ class PyPal:
def MergeTraces(self):
if self.C:
directory = 'ConcatenatedTraces'
directory = 'ConcatenatedTrace'
if not os.path.exists(directory):
os.makedirs(directory)
os.chmod(directory, 0o777)
......@@ -291,15 +291,31 @@ class PyPal:
f.close()
# extracting per user traces
unique_MAC = self.TRACE1['Source_MAC_address'].unique()
direct_UserTraces = directory + '/PerUserTraces'
if not os.path.exists(direct_UserTraces):
os.makedirs(direct_UserTraces)
os.chmod(direct_UserTraces, 0o777)
direct_UserTraces_TRACE1 = direct_UserTraces + '/Trace1'
if not os.path.exists(direct_UserTraces_TRACE1):
os.makedirs(direct_UserTraces_TRACE1)
os.chmod(direct_UserTraces_TRACE1, 0o777)
direct_UserTraces_TRACE2 = direct_UserTraces + '/Trace2'
if not os.path.exists(direct_UserTraces_TRACE2):
os.makedirs(direct_UserTraces_TRACE2)
os.chmod(direct_UserTraces_TRACE2, 0o777)
unique_MAC = self.TRACE1['Source_MAC_address'].unique()
for i in range(len(unique_MAC)):
per_user_trace = self.TRACE1[self.TRACE1.Source_MAC_address == unique_MAC[i]]
f = open(direct_UserTraces+'/User_' + str (i+1) + '.txt','w')
f = open(direct_UserTraces_TRACE1+'/User_' + str (i+1) + '.txt','w')
per_user_trace.to_csv(f, index=False, header=True, sep='\t')
unique_MAC = self.TRACE2['Source_MAC_address'].unique()
for i in range(len(unique_MAC)):
per_user_trace = self.TRACE2[self.TRACE2.Source_MAC_address == unique_MAC[i]]
f = open(direct_UserTraces_TRACE2+'/User_' + str (i+1) + '.txt','w')
per_user_trace.to_csv(f, index=False, header=True, sep='\t')
print('-----------------------------------------------------------------------------------------')
......@@ -309,7 +325,7 @@ class PyPal:
print('-----------------------------------------------------------------------------------------')
return
directory = 'MergedTraces'
directory = 'MergedTrace'
if not os.path.exists(directory):
os.makedirs(directory)
os.chmod(directory, 0o777)
......@@ -318,7 +334,7 @@ class PyPal:
# checksum, fragment number, and fixed timestamp for the ease of detecting
# duplicate frames
# this key ensures that unique packets are not otherwise considered duplicate
# for example sequence numbers are repeated, capturing device migth drop
# for example sequence numbers are repeated, capturing device might drop
# the framecheck sequence values, and so on
unique_key=list()
......@@ -401,15 +417,31 @@ class PyPal:
f.close()
# extracting per user traces
unique_MAC = self.TRACE1['Source_MAC_address'].unique()
direct_UserTraces = directory + '/PerUserTraces'
if not os.path.exists(direct_UserTraces):
os.makedirs(direct_UserTraces)
os.chmod(direct_UserTraces, 0o777)
direct_UserTraces_TRACE1 = direct_UserTraces + '/Trace1'
if not os.path.exists(direct_UserTraces_TRACE1):
os.makedirs(direct_UserTraces_TRACE1)
os.chmod(direct_UserTraces_TRACE1, 0o777)
direct_UserTraces_TRACE2 = direct_UserTraces + '/Trace2'
if not os.path.exists(direct_UserTraces_TRACE2):
os.makedirs(direct_UserTraces_TRACE2)
os.chmod(direct_UserTraces_TRACE2, 0o777)
unique_MAC = self.TRACE1['Source_MAC_address'].unique()
for i in range(len(unique_MAC)):
per_user_trace = self.TRACE1[self.TRACE1.Source_MAC_address == unique_MAC[i]]
f = open(direct_UserTraces+'/User_' + str (i+1) + '.txt','w')
f = open(direct_UserTraces_TRACE1+'/User_' + str (i+1) + '.txt','w')
per_user_trace.to_csv(f, index=False, header=True, sep='\t')
unique_MAC = self.TRACE2['Source_MAC_address'].unique()
for i in range(len(unique_MAC)):
per_user_trace = self.TRACE2[self.TRACE2.Source_MAC_address == unique_MAC[i]]
f = open(direct_UserTraces_TRACE2+'/User_' + str (i+1) + '.txt','w')
per_user_trace.to_csv(f, index=False, header=True, sep='\t')
print('----------------------------------------------------------------------------------------------')
......
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