1919import os
2020import sys
2121import argparse
22+ import time
23+
2224import pyshark as ps
2325import importlib
2426from datetime import datetime
@@ -45,9 +47,11 @@ def __init__(self,
4547 _live_filter = None ,
4648 _live_remote_cap_host = None ,
4749 _live_remote_cap_interface = None ,
48- _debug_on = False
50+ _debug_on = False ,
51+ _pcap_name = None
4952 ):
5053 # super().__init__(lfclient_host=host, lfclient_port=port, debug_=_debug_on)
54+ self .pcap_name = _pcap_name
5155 self .host = host ,
5256 self .port = port
5357 self .debug = _debug_on
@@ -179,9 +183,9 @@ def check_beamformee_association_request(self, pcap_file):
179183 break
180184 print (packet_count )
181185 if packet_count >= 1 :
182- return { "Association Request - MU Beamformee Capable" : value }
186+ return f "Association Request - MU Beamformee Capable: { value } "
183187 else :
184- return { "Association Request - MU Beamformee Capable" : value }
188+ return f "Association Request - MU Beamformee Capable: { value } "
185189 except ValueError :
186190 raise "pcap file is required"
187191
@@ -205,9 +209,9 @@ def check_beamformer_association_response(self, pcap_file):
205209 if packet_count == 1 :
206210 break
207211 if packet_count >= 1 :
208- return { "Association Response -MU Beamformer Capable" : value }
212+ return f "Association Response - MU Beamformer Capable : { value } "
209213 else :
210- return { "Association Response -MU Beamformer Capable" : value }
214+ return f "Association Response - MU Beamformer Capable: { value } "
211215 except ValueError :
212216 raise "pcap file is required"
213217
@@ -230,9 +234,9 @@ def check_beamformer_beacon_frame(self, pcap_file):
230234 if packet_count == 1 :
231235 break
232236 if packet_count >= 1 :
233- return { "Beacon Frame - MU Beamformer Capable" : value }
237+ return f "Beacon Frame - MU Beamformer Capable: { value } "
234238 else :
235- return { "Beacon Frame - MU Beamformer Capable" : value }
239+ return f "Beacon Frame - MU Beamformer Capable: { value } "
236240 except ValueError :
237241 raise "pcap file is required."
238242
@@ -251,16 +255,16 @@ def check_beamformer_report_poll(self, pcap_file):
251255 if packet_count == 1 :
252256 break
253257 if packet_count >= 1 :
254- return { "Beamforming Report Poll " : value }
258+ return f "Beamforming Report Poll : { value } "
255259 else :
256- return { "Beamforming Report Poll " : value }
260+ return f "Beamforming Report Poll : { value } "
257261 except ValueError :
258262 raise "pcap file is required."
259263
260- def check_he_capability (self , pcap_file ):
264+ def check_he_capability_beacon_frame (self , pcap_file ):
261265 try :
262266 if pcap_file is not None :
263- cap = self .read_pcap (pcap_file = pcap_file , apply_filter = 'radiotap.he.data_1.ppdu_format' )
267+ cap = self .read_pcap (pcap_file = pcap_file , apply_filter = 'radiotap.he.data_1.ppdu_format && wlan.fc.type_subtype == 8 ' )
264268 packet_count = 0
265269 for pkt in cap :
266270 packet_count += 1
@@ -271,10 +275,10 @@ def check_he_capability(self, pcap_file):
271275 except ValueError :
272276 raise "pcap file is required."
273277
274- def check_probe_request (self , pcap_file ):
278+ def check_he_capability_probe_request (self , pcap_file ):
275279 try :
276280 if pcap_file is not None :
277- cap = self .read_pcap (pcap_file = pcap_file , apply_filter = 'wlan.fc.type_subtype == 4' )
281+ cap = self .read_pcap (pcap_file = pcap_file , apply_filter = 'radiotap.he.data_1.ppdu_format && wlan.fc.type_subtype == 4' )
278282 packet_count = 0
279283 for pkt in cap :
280284 packet_count += 1
@@ -285,10 +289,10 @@ def check_probe_request(self, pcap_file):
285289 except ValueError :
286290 raise "pcap file is required."
287291
288- def check_probe_response (self , pcap_file ):
292+ def check_he_capability_probe_response (self , pcap_file ):
289293 try :
290294 if pcap_file is not None :
291- cap = self .read_pcap (pcap_file = pcap_file , apply_filter = 'wlan.fc.type_subtype == 5' )
295+ cap = self .read_pcap (pcap_file = pcap_file , apply_filter = 'radiotap.he.data_1.ppdu_format && wlan.fc.type_subtype == 5' )
292296 packet_count = 0
293297 for pkt in cap :
294298 packet_count += 1
@@ -300,16 +304,28 @@ def check_probe_response(self, pcap_file):
300304 raise "pcap file is required."
301305
302306 def sniff_packets (self , interface_name = "wiphy1" , test_name = "mu-mimo" , channel = - 1 , sniff_duration = 180 ):
303- pcap_name = test_name + str (datetime .now ().strftime ("%Y-%m-%d-%H-%M" )).replace (':' , '-' ) + ".pcap"
307+ if test_name is not None :
308+ self .pcap_name = test_name + ".pcap"
309+ else :
310+ self .pcap_name = "capture" + str (datetime .now ().strftime ("%Y-%m-%d-%H-%M" )).replace (':' , '-' ) + ".pcap"
311+ print ('----------pcap name----------: ' , self .pcap_name )
304312 self .wifi_monitor .create (resource_ = 1 , channel = channel , mode = "AUTO" , radio_ = interface_name , name_ = "moni0" )
305- self .wifi_monitor .start_sniff (capname = pcap_name , duration_sec = sniff_duration )
313+ self .wifi_monitor .start_sniff (capname = self .pcap_name , duration_sec = sniff_duration )
314+ for i in range (int (sniff_duration )):
315+ time .sleep (1 )
306316 self .wifi_monitor .cleanup ()
307- return pcap_name
317+ return self . pcap_name
308318
309- def move_pcap (self , current_path , updated_path ):
310- lf_report .pull_reports (hostname = self .host , port = 22 , username = "lanforge" , password = "lanforge" ,
311- report_location = current_path ,
312- report_dir = updated_path )
319+ def move_pcap (self , current_path = "/home/lanforge/" , pcap_name = None ):
320+ if current_path is None :
321+ current_path = "/home/lanforge/"
322+ if pcap_name is None :
323+ pcap_name = self .pcap_name
324+ if pcap_name is not None :
325+ print ('...............Moving pcap to directory............' , current_path + pcap_name )
326+ lf_report .pull_reports (hostname = self .host , port = self .port , username = "lanforge" , password = "lanforge" , report_location = current_path + pcap_name , report_dir = "." )
327+ else :
328+ raise ValueError ("pcap_name is Required!" )
313329
314330
315331def main ():
0 commit comments