Coder Social home page Coder Social logo

mosaico-anr / p4-classifier Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.54 MB

P4 program in charge of computing flow features. It then decides whether it is CG traffic or not.

License: GNU General Public License v3.0

Shell 17.99% Makefile 17.69% P4 0.74% C 57.86% Python 0.35% Awk 0.02% M4 2.42% Perl 0.13% Roff 2.79%
bmv2 classification cloud-gaming p4

p4-classifier's Introduction

P4 Flow Classifier


Licence

  • ๐Ÿข This work is part of the MOSAICO PROJECT
  • ๐Ÿ‡ซ๐Ÿ‡ท Copyright (c) 2022 Centre National de la Recherche Scientifique. All Rights Reserved.
  • โœ’๏ธ Author: GRAFF Philippe
  • ๐Ÿ”— The DT classifier has been trained thanks to pcap traces available on this website link.
  • ๐Ÿ“‚ The Utils folder is used by our program
    • ๐Ÿ‘‰ Approx: division approximation
    • ๐Ÿ‘‰ LoadRulesDT: export trained DT in CSV
    • ๐Ÿ‘‰ Visualize: visualize features & classification results

Software Used / Installation

  • โš ๏ธ Needed libraries:
    • You need Docker to make it work
    • Python libraries: scikit-learn - graphviz - joblib
  • ๐Ÿ“‚ The includes folder contains third party Software

Objective

  • P4 program recognizing CG traffic
  • 33ms windows
  • Features computation when window is over
  • Features stored inside the packet closing the window (metadata)
  • If predicts CG ๐Ÿ‘‰ bit CG to 1
  • In visualize, we read the P4 logfile
    • Displays the features (12) on graphs
    • Prompts the CG percentage (ratio Reports CG/Reports)

P4 Controller

* Generates the topology

  • mininet
  • 1 switch
  • 3 hosts Topology
  • Rules to forward the trafic

* Install lookup tables (division)

  • Approximates a division
  • With 3 reverse powers of 2
  • 1/Y ~ 1/2a + 1/2b + 1/2c
  • X/Y ~ X>>a + X>>b + X>>c
  • For Y in [1;4095] (2**12-1)
  • Will be used for mean and std calculation
  • โ€ผ๏ธ We always have 3 reverse power of 2 (๐Ÿ‘‰ +1/2255 if not necessary)
  • โ€ผ๏ธ The same table is present twice (impossible to look twice)

* Install Feature Rules

  • Loads CSV file FTR_Ruls.csv
  • In LoadRulesDT
  • More details: ๐Ÿ‘‰ in this folder
  • Represents a feature with an Index
  • Function of the thresholds of that feature in the DT
  • | Feati | 0 | 37 | 42 | 58 | 63 | |-|-|-|-|-|-|
  • If Feati = 41
    • 37<41<42
    • Then index = 2

* Install Action Rules

  • Loads CSV file ACT_Ruls.csv
  • In LoadRulesDT
  • More details: ๐Ÿ‘‰ in this folder
  • One rule per leaf
  • Given the feature's indexes (Cf II.c)), find the adequate leaf
  • Give the label associated with that leaf

P4 Program

* Instructions

  • Limitation to UDP traffic (hdr.udp.isValid : ยฌUDP => ยฌCG )
  • Get to know the traffic direction (function of the IPv4 prefix)
  • Compute the Hash: an index ind of the conversation in the registers
  • If end of window or collision:
    • Retrieve Data UP & Down
    • Do the divisions
    • Classify
    • Initialize
  • If window is not over:
    • Update values

* Registers

Associate a conversation (IP1 <-> IP2) to its data.

  • 16 registers
    • 2 global registers
    • 7 registers downlink
    • 7 registers uplink
  • Global Registers (2):
  • Links ind to the conversation key (IP1+IP2)
  • Start of current temporal window
  • Directional registers (7x2):
    • Number of elements (in current window)
    • Sum of packet sizes
    • Last mean of packet sizes
    • Sum of squared deviance (size-LastMean)2
    • Last timestamp (:point_right: compute IAT)
    • Last mean of IATs
    • Sum of squared deviance (iat-LastMean)2

* Metadata

  • 3 values linked to global registers
    • Index ind
    • Collision (2 conversations have same ind)
    • End of window
  • 7 values read in the directional registers (UP or DOWN)
  • 12 features computed (end of the window)
  • 12 indexes of the features (end of the window)
  • Is CG (end of the window)

How it works

  1. Go to the folder /Utils/Approx
  • Call make
  • Execute a.out and type 4095
  • It will generate out.csv.
  • out.csv is used by the main program.
  • ๐Ÿ‘ There is a Readme if necessary
  1. Go to the folder /Utils/LoadRulesDT
  • Type python3 dum2cond.py
  • It will generate ACT_Ruls.csv and FTR_Ruls.csv
  • ACT_Ruls.csv and FTR_Ruls.csv are used by the main program.
  • ๐Ÿ‘ There is a Readme if necessary
  1. Go to the folder P4-Classifier/
  • Call sudo make
  • โš ๏ธ You need root privileges
  • It compiles everything
  1. Instantiate a host
  • Open a new terminal in P4-classifier/
  • Call sudo make h1
  • Type ./Host.sh INTERF PATH_TO_PCAP from a host
  • ๐Ÿ’ก need to store a pcap file in Data/
  • Type x.y.z when asked tcpreplay version (Software Used / Installation)
  • It will generate trafic
  1. Go to the folder Utils/Visualize
  • Execute FtsFromLog.sh
  • You will be asked a conversation number
  • Look at out.csv ๐Ÿ‘‰ last column = identifier
  • Type the most frequent identifier
  • You will be prompted % of CG recognition
  • There will be some graph in Utils/Visualize/Out/

Made with โค๏ธ by GRAFF Philippe

p4-classifier's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.