kill -9 $_PROCESS_ID#forcefully terminate the process, and any subprocesses or child processes, with the ID using the SIGKILL signal. (sometimes it's not enough, why?)
(tshark -r $_FILE_REF -T fields -e frame.number -c $_MAX_TO| wc -l >$_TMP/pipe1)&#the symbol '&' runs the command in the background, allowing other commands to be run in parallel.
(tshark -r $_FILE_REF -Y "wlan" -T fields -e frame.number -c $_MAX_TO| wc -l >$_TMP/pipe2)&#the symbol '&' runs the command in the background, allowing other commands to be run in parallel.
(tshark -r $_FILE_REF -Y "wlan.ssid == $_SSID_REF" -T fields -e frame.number -c $_MAX_TO| wc -l >$_TMP/pipe3)&#the symbol '&' runs the command in the background, allowing other commands to be run in parallel.
(tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -c $_MAX_TO| tr '[:lower:]''[:upper:]'| sort | uniq | tee >(wc -l > $_TMP/pipe4) >"$_FILE2_TMP")&#the symbol '&' runs the command in the background, allowing other commands to be run in parallel.
(tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -e wlan.fc.type -c $_MAX_TO| tr '[:lower:]''[:upper:]'| tee >(wc -l > $_TMP/pipe4) >"$_FILE2_TMP")&#the symbol '&' runs the command in the background, allowing other commands to be run in parallel.
done < <(paste -d ' '$_TMP/pipe1 $_TMP/pipe2 $_TMP/pipe3 $_TMP/pipe4)#the 'paste' command merges the lines of both named pipes and separates them with a space. the '< <' operator to redirect the merged output as input to the while loop.
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| sort | uniq | tee >(wc -l) >"$_FILE_TMP")#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). sort+uniq remove the duplicates(seems useless but necessary). tee split the data in the pipe.
else
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| sort | uniq | wc -l)#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). sort+uniq remove the duplicates(seems useless but necessary).
fi
else
if[[$_VERBOSE_FLAG=='true']];then
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| tee >(wc -l) >"$_FILE_TMP")#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). tee split the data in the pipe.
else
_SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP| awk '/^.[AE26]:..:..:..:..:../{print $1}'| wc -l)#cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx).
# filter="($scope) && (wlan) $filterSSID" #save the complete filter which wanna use to split the data.
# rm -f $_FILE_TMP $_FILE2_TMP #just as a precaution.
# if [[ $_UNIQ_FLAG == 'true' ]]; then
# verbose_msg "Counting packets with filter '$filter' in $_FILE_REF"
# _SCOPE_ALL_CNTR=$(tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -c $_MAX_TO | tr '[:lower:]' '[:upper:]' | sort | uniq | tee >(wc -l) >"$_FILE2_TMP") #for details see 'man tshark'. tr swap all upper-case. sort+uniq remove the duplicates. tee split the data in the pipe.
# verbose_msg "=> $_SCOPE_ALL_CNTR"
# if [[ $_VERBOSE_FLAG == 'true' ]]; then
# _SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP | awk '/^.[AE26]:..:..:..:..:../{print $1}' | sort | uniq | tee >(wc -l) >"$_FILE_TMP") #cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). sort+uniq remove the duplicates(seems useless but necessary). tee split the data in the pipe.
# else
# _SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP | awk '/^.[AE26]:..:..:..:..:../{print $1}' | sort | uniq | wc -l) #cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). sort+uniq remove the duplicates(seems useless but necessary).
# fi
# else
# verbose_msg "Counting packets with filter '$filter' in $_FILE_REF"
# _SCOPE_ALL_CNTR=$(tshark -r $_FILE_REF -Y "$filter" -T fields -e wlan.ta -e wlan.fc.type -c $_MAX_TO | tr '[:lower:]' '[:upper:]' | tee >(wc -l) >"$_FILE2_TMP") #for details see 'man tshark'. tr swap all upper-case. tee split the data in the pipe.
# verbose_msg "=> $_SCOPE_ALL_CNTR"
# if [[ $_VERBOSE_FLAG == 'true' ]]; then
# _SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP | awk '/^.[AE26]:..:..:..:..:../{print $1}' | tee >(wc -l) >"$_FILE_TMP") #cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx). tee split the data in the pipe.
# else
# _SCOPE_RAND_CNTR=$(cut -c 1-17 $_FILE2_TMP | awk '/^.[AE26]:..:..:..:..:../{print $1}' | wc -l) #cut print selected parts of line. awk is used to consider only MAC specified(x[A E 2 6]:xx:xx:xx:xx:xx).
echo -ne "\033[2J\033[H"#the "\033[2J" sequence clear the terminal screen, the "\033[H" sequence moves the cursor to the top left corner of the screen.
echo"$(cat $lock_print)"#The "$()" syntax is used to execute the command inside the parentheses and return the result as a string (used to handle print cases TO REVIEW)
if head -c4 | od -t x4 -N4 | grep -q -e "a1b2c3d4" -e "d4c3b2a1" -e "0a0d0d0a";then#handled only pcap, pcapng files (not erf ...) using magic number of file.
if ! head -c4 $_FILE_REF| od -t x4 -N4 | grep -q -e "a1b2c3d4" -e "d4c3b2a1" -e "0a0d0d0a";then#handled only pcap, pcapng files (not erf ...) using magic number of file.