Here is the help of cicflowmeter
cicflowmeter -h
usage: cicflowmeter [-h] (-i INPUT_INTERFACE | -f INPUT_FILE) [-c]
[-u URL_MODEL]
output
positional arguments:
output output file name (in flow mode) or directory (in
sequence mode)
optional arguments:
-h, --help show this help message and exit
-i INPUT_INTERFACE, --interface INPUT_INTERFACE
capture online data from INPUT_INTERFACE
-f INPUT_FILE, --file INPUT_FILE
capture offline data from INPUT_FILE
-c, --csv, --flow output flows as csv
-u URL_MODEL, --url URL_MODEL
URL endpoint for send to Machine Learning Model. e.g
http://0.0.0.0:80/prediction
I want to use cicflowmeter to capture realtime features that generated by net flow, and test my ML model trained by CICIDS2017 dataset,this URL_MODEL function can greatly simplify my implement of realtime detection,but I try a lot of times, it doesn't work.
Then, I read the code in flow_session.py
to find how it writes generated feature into specified file, and found maybe the URL_MODEL
function were not implemeted, here is the code in line 107:
def garbage_collect(self, latest_time) -> None:
localtime = time.asctime( time.localtime(time.time()) )
print(localtime, latest_time)
# TODO: Garbage Collection / Feature Extraction should have a separate thread
if not self.url_model:
print("Garbage Collection Began. Flows = {}".format(len(self.flows)))
keys = list(self.flows.keys())
for k in keys:
flow = self.flows.get(k)
if (
latest_time is None
or latest_time - flow.latest_timestamp > EXPIRED_UPDATE
or flow.duration > 90
):
data = flow.get_data()
if self.csv_line == 0:
self.csv_writer.writerow(data.keys())
self.csv_writer.writerow(data.values())
# print('-----------------------')
# print(data.keys())
# print('-----------------------')
self.csv_line += 1
del self.flows[k]
I did some print to see where the features are going,and I am now doing some change to the code to implement the function url_model,send the features with json format to specified url.