Simple_IDS_using_RYU_SDN_controller_and_Machine_Learning
Simple_IDS_using_RYU_SDN_controller_and_Machine_Learning copied to clipboard
File not found: MalPredictFlowStatsfile.txt
Hey there,
When trying to run this code, CollectStats.py runs perfectly however IDS_RyuApp.py returns a file not found error for MalPredictFlowStatsfile.txt.
I notice in the code it tries to open this file but it is never created. Is there a remedy for this?
Thanks in advance
Hi,
I have made a mistake, the filename shouldn't be MalPredictFlowStatsfile. It should PredictFlowStatsFile.txt. If you remove 'Mal' it will work. Thanks for bringing it to my attention.
On a different note, if the procedure is not clear here it is, (may be I should update my readme file.)
- Run collectstats.py on the controller.
- Then create a mininet custom topology. (While collecting normal traffic label the data 0.)
- Run some simple commands. So that you will be able to generate the clean data.
- Stop the controller.
- Change the collectstats.py file. Label the data as 1.
- Start the controller and run collectstats.py file.
- Create topology.
- Run hping flood command to capture malicious data.
- Now stop the controller.
- Run ryuapplication.py on the controller.
- Create a topology.
- Test the model on the new traffic.
Also be careful while calling data_cleaning_port and data_cleaning_flow methods, paths can be confusing.
I appreciate your response, thank you!
For step 5 Change the collectstats.py file. Label the data as 1.
Is that the only thing you have to change in collectstats? Or do you also change the output file names to have "Mal" at the beginning?
Otherwise running it a second time and writing to the same FlowStatsFile results in there being another header added (file.write('dp_id,port_no,rx_bytes,rx_pkts,tx_bytes,tx_pkts') in the constructor.
Like so:
dp_id,port_no,rx_bytes,rx_pkts,tx_bytes,tx_pkts
1,1,824,10,3143,27
1,2,824,10,3143,27
1,1,1622,19,4225,39
1,2,1622,19,4225,39
1,1,2406,27,5149,49
1,2,2476,28,5009,47
1,1,3456,38,6236,60
1,2,3456,38,6236,60
1,1,4478,49,7258,71
1,2,4478,49,7258,71dp_id,port_no,rx_bytes,rx_pkts,tx_bytes,tx_pkts
1,1,516,6,2447,20
1,2,516,6,2447,20
1,1,656,8,3152,27
1,2,656,8,3152,27
Which then causes a parsing error in the IDS app
Hi,
No, you don't have to change the file name to 'mal'. I see the cause of error. Every time we create a new topology and run CollectStats.py, '' dp_id,port_no,rx_bytes,rx_pkts,tx_bytes,tx_pkts '' this header is added to the PortStats.txt file as it is in the constructor of CollectStats.py. I need to modify this code such that I will only write it once.
This will be the case in FlowStatsFile.txt file as well. Thanks. I will modify the code and get back to you.