In-network detection of network attacks using Random Forests
In-Network detection of attacks using Random Forests
Please cite this paper if you use this code:
Jong-Hyouk Lee and Kamal Singh, "SwitchTree: In-network Computing and Traffic Analyses with Random Forests", Neural Computing and Applications (2020)
We perform in-network analysis of the network data by exploiting the power of programmable data planes.
SwitchTree coded in P4 embeds Random Forest algorithm inside a programmable switch such that the
Random Forest is configurable and re-configurable at runtime. We show how some flow level
stateful features can be estimated, such as the round trip time and bitrate of each flow.
Main references for this work are IISY and pForest.
To run the code
Use or Create a BMV2 VM or machine. For example you may download the VM from here provided by P4 developer day: https://drive.google.com/uc?id=1lYF4NgFkYoRqtskdGTMxy3sXUV0jkMxo&export=download
Check if the examples are compiling and working in tutorials/exercises folder.
Copy the SwitchTree folder to tutorials/exercises/ folder
cd to SwitchTree folder
make
Open a new terminal and cd to tutorials/exercises/switchtree folder. Add rules (trained Decision Trees were translated to SwitchTree P4 rules using a script) to P4 switch by
simple_switch_CLI < commands_1_tree.txt
sudo tcpreplay -i s1-eth1 demo_data/UNSW_1000_packets.pcap
simple_switch_CLI < get_results.txt
To use SwitchTree with 3 trees:
cp switchtree.3trees switchtree.p4
make clean
make
simple_switch_CLI < commands_3_trees.txt
Note you may need to exit and type make again to reinitialize and do a new test with new data.
(TODO: I have put the commands below that I remember. Need to test and verify them.)
cd behavioral-model/
sudo ./configure 'CXXFLAGS=-g -O3' 'CFLAGS=-g -O3' --disable-logging-macros --disable-elogger
sudo make
sudo make install