├── analysis ├── mitigation_graph1.png ├── validation.py ├── mitigation_graph.py ├── accuration_controllermitigation.py ├── detection_controllermitigation.py ├── demographic.py └── result.csv ├── mycmd.py ├── addh3s2.sh ├── dataresearch ├── command.txt ├── threetier9h1h5_link100packets.csv ├── threetest.csv ├── spineleaf9h1h12_links100packets.csv └── threetier9newhost_5s.csv ├── bryanwebsite ├── requirements.txt ├── manage.py ├── getsw.txt ├── .gitignore └── webcommand.txt ├── addh13s5.sh ├── svmML.py ├── README.md ├── spineleaf9h1h12.csv ├── spineleaf7.py ├── rest_topology.py ├── threetier9h1h12.csv ├── threetier7.py ├── simple_switch_13.py ├── spineleafdatacentertopo.py ├── simple_switch_stp_13.py ├── threetier9.py ├── spineleaf9.py ├── mininet2.py ├── mininet1.py ├── flowsetup.sh ├── result.csv ├── controllerfinal.py ├── flowsetupsl.sh ├── controllertest.py ├── controllerwithstp.py └── minine2.mn /analysis/mitigation_graph1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bryanoliverh/SDNSecurity_DDOSMitigationDecisionTree_PortBlocking/HEAD/analysis/mitigation_graph1.png -------------------------------------------------------------------------------- /mycmd.py: -------------------------------------------------------------------------------- 1 | def mycmd( self, line ): 2 | "mycmd is an example command to extend the Mininet CLI" 3 | net = self.mn 4 | output( 'mycmd invoked for', net, 'with line', line, '\n' ) 5 | CLI.do_mycmd = mycmd -------------------------------------------------------------------------------- /addh3s2.sh: -------------------------------------------------------------------------------- 1 | 2 | #source addh3s2.sh 3 | py net.addHost('h3s1') 4 | py net.addLink(s1, net.get('h3s1')) 5 | py s1.attach('s1-eth8') 6 | py net.get('h3s1').cmd('ifconfig h3s1-eth0 10.0.0.4') 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dataresearch/command.txt: -------------------------------------------------------------------------------- 1 | link s1 s7 down 2 | 3 | source addh13s5.sh 4 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=12,actions=output:1,2,3 5 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=1,actions=output:12 6 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=2,actions=output:12 -------------------------------------------------------------------------------- /bryanwebsite/requirements.txt: -------------------------------------------------------------------------------- 1 | astroid==1.6.3 2 | autopep8==1.3.5 3 | backports.functools-lru-cache==1.5 4 | certifi==2018.4.16 5 | chardet==3.0.4 6 | configparser==3.5.0 7 | Django==1.11.29 8 | enum34==1.1.6 9 | futures>=3.1.1 10 | idna==2.6 11 | isort==4.3.4 12 | lazy-object-proxy==1.3.1 13 | mccabe==0.6.1 14 | pycodestyle==2.4.0 15 | pylint==1.8.4 16 | pytz==2018.4 17 | requests==2.20.0 18 | singledispatch==3.4.0.3 19 | six==1.11.0 20 | urllib3==1.24.2 21 | wrapt==1.10.11 22 | -------------------------------------------------------------------------------- /addh13s5.sh: -------------------------------------------------------------------------------- 1 | 2 | 3 | py net.addHost('h13s5') 4 | py net.addLink(s5, net.get('h13s5')) 5 | py s5.attach('s5-eth12') 6 | py net.get('h13s5').cmd('ifconfig h13s5-eth0 10.2.0.4') 7 | s5 ovs-ofctl1.3 add-flow "s5" in_port=12,actions:output=1 8 | s5 ovs-ofctl add-flow "s5" in_port=12,actions:output=2 9 | s5 ovs-ofctl add-flow "s5" in_port=12,actions:output=3 10 | s5 ovs-ofctl add-flow "s5" in_port=12,actions:output=4 11 | s5 ovs-ofctl add-flow "s5" in_port=12,actions:output=5 12 | s5 ovs-ofctl add-flow "s5" in_port=12,actions:output=6 13 | s5 ovs-ofctl add-flow "s5" in_port=12,actions:output=7 14 | s5 ovs-ofctl add-flow "s5" in_port=12,actions:output=8 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dataresearch/threetier9h1h5_link100packets.csv: -------------------------------------------------------------------------------- 1 | 20211031021107,1635671467,10.1.0.2,0.474 2 | 20211031021108,1635671468,10.1.0.2,0.179 3 | 20211031021109,1635671469,10.1.0.2,0.128 4 | 20211031021110,1635671470,10.1.0.2,0.128 5 | 20211031021111,1635671471,10.1.0.2,0.164 6 | 20211031021112,1635671472,10.1.0.2,0.139 7 | 20211031021113,1635671473,10.1.0.2,0.114 8 | 20211031021114,1635671474,10.1.0.2,0.131 9 | 20211031021115,1635671475,10.1.0.2,0.130 10 | 20211031021116,1635671476,10.1.0.2,0.132 11 | 20211031021117,1635671477,10.1.0.2,0.130 12 | 20211031021118,1635671478,10.1.0.2,0.127 13 | 20211031021119,1635671479,10.1.0.2,0.137 14 | 20211031021120,1635671480,10.1.0.2,0.131 15 | 20211031021121,1635671481,10.1.0.2,0.202 16 | -------------------------------------------------------------------------------- /bryanwebsite/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "websrc.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /svmML.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | import sys 3 | import numpy 4 | import os 5 | from sklearn import svm 6 | from collections import deque 7 | from sklearn import tree 8 | 9 | 10 | 11 | class SVM: 12 | 13 | def __init__(self): 14 | """ 15 | train the model from generated training data in generate-data folder 16 | """ 17 | data = numpy.loadtxt(open('result.csv', 'rb'), delimiter=',', dtype='str') 18 | #Support_Vector_Machine 19 | #self.svm = svm.SVC() 20 | # Decision tree 21 | self.svm = tree.DecisionTreeClassifier() 22 | self.svm.fit(data[:, 0:3], data[:, 3]) 23 | 24 | 25 | def classify(self, data): 26 | fparams = numpy.zeros((1, 3)) 27 | fparams[:,0] = data[0] 28 | fparams[:,1] = data[1] 29 | fparams[:,2] = data[2] 30 | prediction = self.svm.predict(fparams) 31 | print("Read Data :", data , "Result of Prediction: ", prediction) 32 | return prediction 33 | -------------------------------------------------------------------------------- /analysis/validation.py: -------------------------------------------------------------------------------- 1 | #Accuracy reference: https://github.com/kshitijved/Support_Vector_Machine 2 | 3 | from sklearn import svm, datasets 4 | import matplotlib.pyplot as plt 5 | import numpy as np 6 | from sklearn.metrics import accuracy_score 7 | from sklearn.model_selection import train_test_split 8 | 9 | 10 | data = np.loadtxt(open('result.csv', 'rb'), delimiter=',') 11 | 12 | X = data[:, 0:3] 13 | y = data[:, 3] 14 | x_train, x_test, y_train, y_test = train_test_split(X, y, random_state = 0, test_size = 0.25)#clf = svm.SVC() 15 | 16 | clf = svm.SVC() 17 | #clf = tree.DecisionTreeClassifier() 18 | clf.fit(x_train, y_train) 19 | classifier_predictions = clf.predict(x_test) 20 | print("Detection Rate Process") 21 | length = len(y_test) 22 | DD = 0 23 | DN = 0 24 | FD = 0 25 | TN = 0 26 | for i in range(0,length): 27 | #print("Actual",y_test[i], "prediction", classifier_predictions[i]) 28 | if y_test[i] == 1.0: 29 | if classifier_predictions[i] == 1.0: 30 | DD = DD + 1 31 | else: 32 | DN = DN + 1 33 | if y_test[i] == 0.0: 34 | if classifier_predictions[i] == 1.0: 35 | FD = FD + 1 36 | else: 37 | TN = TN + 1 38 | DR = DD / (DD + DN) 39 | print("Average Detection Rate :", DR) 40 | FAR = FD / (FD + TN) 41 | print("Average False Posivie", FAR) 42 | -------------------------------------------------------------------------------- /analysis/mitigation_graph.py: -------------------------------------------------------------------------------- 1 | #http://rasbt.github.io/mlxtend/user_guide/plotting/plot_decision_regions/ 2 | from __future__ import division 3 | import numpy 4 | import os 5 | from sklearn import svm 6 | from collections import deque 7 | import matplotlib.pyplot as plt 8 | from mlxtend.plotting import plot_decision_regions 9 | import numpy as np 10 | 11 | data = np.loadtxt(open('result.csv', 'rb'), delimiter=',') 12 | 13 | #sfe,ssip,rfip 14 | sfe = 0 15 | ssip = 1 16 | rfip = 2 17 | 18 | 19 | 20 | 21 | 22 | #Graph1 sfe & ssip 23 | X = data[:, [sfe,ssip]] 24 | y = data[:, 3] 25 | clf = svm.SVC() 26 | clf.fit(X, y) 27 | # Plot Decision Region using mlxtend's awesome plotting function 28 | fig = plt.figure(figsize=(10,8)) 29 | fig = plot_decision_regions(X=X, 30 | y=y.astype(int), 31 | clf=clf, 32 | legend=2) 33 | plt.title('Demografi Akurasi dan Proses Mitigasi Serangan', size=16) 34 | plt.xlabel('SFE') 35 | plt.ylabel('SSIP') 36 | plt.savefig("mitigation_graph1.png") 37 | 38 | 39 | 40 | 41 | #Graph1 sfe & rfip 42 | X = data[:, [sfe,rfip]] 43 | y = data[:, 3] 44 | clf = svm.SVC() 45 | clf.fit(X, y) 46 | # Plot Decision Region using mlxtend's awesome plotting function 47 | fig = plt.figure(figsize=(10,8)) 48 | fig = plot_decision_regions(X=X, 49 | y=y.astype(int), 50 | clf=clf, 51 | legend=2) 52 | plt.title('Demografi Akurasi dan Proses Mitigasi Serangan', size=16) 53 | plt.xlabel('sfe') 54 | plt.ylabel('rfip') 55 | plt.savefig("mitigation_graph2.png") 56 | -------------------------------------------------------------------------------- /bryanwebsite/getsw.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | {% extends "base.html" %} 4 | {% block content %} 5 |

Network Status

6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | '' 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
ManifacturerHardware DescriptionSwitch DescriptionSwitch Serial NumberDP DescriptionDPID
{{ rules1.mfr_desc }}{{ rules1.hw_desc }}{{ rules1.sw_desc }}{{ rules1.serial_num }}{{ rules1.dp_desc }}
38 | {% endblock %} 39 | 40 | 42 | 43 | 48 | 49 | 52 | -------------------------------------------------------------------------------- /analysis/accuration_controllermitigation.py: -------------------------------------------------------------------------------- 1 | #Accuracy reference: https://github.com/kshitijved/Support_Vector_Machine 2 | 3 | from sklearn import svm, datasets 4 | import matplotlib.pyplot as plt 5 | import numpy as np 6 | from sklearn.metrics import accuracy_score 7 | from sklearn.model_selection import train_test_split 8 | from sklearn import tree 9 | 10 | 11 | from sklearn.model_selection import cross_val_score 12 | 13 | #step1: Load the data in numpy array 14 | data = np.loadtxt(open('res2.csv', 'rb'), delimiter=',') 15 | X = data[:, 0:3] 16 | y = data[:, 3] 17 | 18 | #step2: Split the data to training & test data. Test-size is 0.25(25%) of data 19 | x_train, x_test, y_train, y_test = train_test_split(X, y, random_state = 0, test_size = 0.25) 20 | 21 | 22 | #step3: select the machine learning algorithm 23 | 24 | #svm 25 | #clf = svm.SVC() 26 | clf = svm.SVC(kernel="linear",C=0.025) 27 | #clf = tree.DecisionTreeClassifier() 28 | 29 | #step4: Train the ML Algo with training data 30 | clf.fit(x_train, y_train) 31 | 32 | 33 | #step5: Pass the test data for classify or predict 34 | classifier_predictions = clf.predict(x_test) 35 | print("Score of Accuration from Controller on Detecting Attack from Host 1 ") 36 | 37 | #step6. Calculate the accuracy from the the prediction result. 38 | print("Accuracy Score of Controller Detection and Mitigation ", accuracy_score(y_test, classifier_predictions)*100) 39 | 40 | 41 | #step7. calculate cross validation score 42 | scores = cross_val_score(clf, x_train, y_train, cv=5) 43 | print("Re-Validate Accuration Score #1",scores.mean()) 44 | 45 | 46 | scores2 = cross_val_score(clf, x_train, y_train, cv=5) 47 | print("Re-Validate Accuration Score #2",scores2.mean()) 48 | -------------------------------------------------------------------------------- /bryanwebsite/.gitignore: -------------------------------------------------------------------------------- 1 | # VS-Vode 2 | .vscode 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | env/ 15 | build/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | 60 | # Flask stuff: 61 | instance/ 62 | .webassets-cache 63 | 64 | # Scrapy stuff: 65 | .scrapy 66 | 67 | # Sphinx documentation 68 | docs/_build/ 69 | 70 | # PyBuilder 71 | target/ 72 | 73 | # Jupyter Notebook 74 | .ipynb_checkpoints 75 | 76 | # pyenv 77 | .python-version 78 | 79 | # celery beat schedule file 80 | celerybeat-schedule 81 | 82 | # SageMath parsed files 83 | *.sage.py 84 | 85 | # dotenv 86 | .env 87 | 88 | # virtualenv 89 | .venv 90 | venv/ 91 | ENV/ 92 | venv*/ 93 | 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | -------------------------------------------------------------------------------- /analysis/detection_controllermitigation.py: -------------------------------------------------------------------------------- 1 | #Accuracy reference: https://github.com/kshitijved/Support_Vector_Machine 2 | 3 | from sklearn import svm, datasets 4 | import matplotlib.pyplot as plt 5 | import numpy as np 6 | from sklearn.metrics import accuracy_score 7 | from sklearn.model_selection import train_test_split 8 | 9 | 10 | 11 | #step1: Load the data in numpy array 12 | data = np.loadtxt(open('result.csv', 'rb'), delimiter=',') 13 | 14 | 15 | #step2: Split the data to training & test data. Test-size is 0.25(25%) of data 16 | X = data[:, 0:3] 17 | y = data[:, 3] 18 | x_train, x_test, y_train, y_test = train_test_split(X, y, random_state = 0, test_size = 0.25)#clf = svm.SVC() 19 | 20 | 21 | #step3: select the machine learning algorithm 22 | 23 | #svm 24 | clf = svm.SVC() 25 | #Decision Tree 26 | #clf = tree.DecisionTreeClassifier() 27 | 28 | #step4: Train the ML Algo with training data 29 | clf.fit(x_train, y_train) 30 | 31 | 32 | 33 | #step5: Pass the test data for classify or predict 34 | classifier_predictions = clf.predict(x_test) 35 | 36 | 37 | #step6. Calculate the Detection Ratio 38 | print("Proses Perhitungan Rata-Rata Deteksi") 39 | length = len(y_test) 40 | DD = 0 41 | DN = 0 42 | FD = 0 43 | TN = 0 44 | for i in range(0,length): 45 | #print("Actual",y_test[i], "prediction", classifier_predictions[i]) 46 | #Calculating DR 47 | if y_test[i] == 1.0: 48 | if classifier_predictions[i] == 1.0: 49 | DD = DD + 1 50 | else: 51 | DN = DN + 1 52 | #calculating FAR 53 | if y_test[i] == 0.0: 54 | if classifier_predictions[i] == 1.0: 55 | FD = FD + 1 56 | else: 57 | TN = TN + 1 58 | #print("DD", DD , "DN", DN) 59 | DR = DD / (DD + DN) 60 | print("Nilai Rata-rata Deteksi :", DR) 61 | 62 | 63 | #print("FD", FD , "TN", TN) 64 | FAR = FD / (FD + TN) 65 | print("Nilai Rata-rata False Positive :", FAR) 66 | -------------------------------------------------------------------------------- /dataresearch/threetest.csv: -------------------------------------------------------------------------------- 1 | PING 10.1.0.2 (10.1.0.2) 56(84) bytes of data. 2 | 64 bytes from 10.1.0.2: icmp_seq=1 ttl=64 time=40.2 ms 3 | 64 bytes from 10.1.0.2: icmp_seq=2 ttl=64 time=0.941 ms 4 | 64 bytes from 10.1.0.2: icmp_seq=3 ttl=64 time=0.125 ms 5 | 64 bytes from 10.1.0.2: icmp_seq=4 ttl=64 time=0.127 ms 6 | 64 bytes from 10.1.0.2: icmp_seq=5 ttl=64 time=0.308 ms 7 | 64 bytes from 10.1.0.2: icmp_seq=6 ttl=64 time=0.110 ms 8 | 64 bytes from 10.1.0.2: icmp_seq=7 ttl=64 time=0.169 ms 9 | 64 bytes from 10.1.0.2: icmp_seq=8 ttl=64 time=0.134 ms 10 | 64 bytes from 10.1.0.2: icmp_seq=9 ttl=64 time=0.130 ms 11 | 64 bytes from 10.1.0.2: icmp_seq=10 ttl=64 time=0.108 ms 12 | 64 bytes from 10.1.0.2: icmp_seq=11 ttl=64 time=0.174 ms 13 | 64 bytes from 10.1.0.2: icmp_seq=12 ttl=64 time=0.127 ms 14 | 64 bytes from 10.1.0.2: icmp_seq=13 ttl=64 time=0.152 ms 15 | 64 bytes from 10.1.0.2: icmp_seq=14 ttl=64 time=0.220 ms 16 | 64 bytes from 10.1.0.2: icmp_seq=15 ttl=64 time=0.173 ms 17 | 64 bytes from 10.1.0.2: icmp_seq=16 ttl=64 time=0.128 ms 18 | 64 bytes from 10.1.0.2: icmp_seq=17 ttl=64 time=0.163 ms 19 | 64 bytes from 10.1.0.2: icmp_seq=18 ttl=64 time=0.155 ms 20 | 64 bytes from 10.1.0.2: icmp_seq=19 ttl=64 time=0.131 ms 21 | 64 bytes from 10.1.0.2: icmp_seq=20 ttl=64 time=0.169 ms 22 | 64 bytes from 10.1.0.2: icmp_seq=21 ttl=64 time=0.113 ms 23 | 64 bytes from 10.1.0.2: icmp_seq=22 ttl=64 time=0.071 ms 24 | 64 bytes from 10.1.0.2: icmp_seq=23 ttl=64 time=0.277 ms 25 | 64 bytes from 10.1.0.2: icmp_seq=24 ttl=64 time=0.132 ms 26 | 64 bytes from 10.1.0.2: icmp_seq=25 ttl=64 time=0.083 ms 27 | 64 bytes from 10.1.0.2: icmp_seq=26 ttl=64 time=0.148 ms 28 | 64 bytes from 10.1.0.2: icmp_seq=27 ttl=64 time=0.127 ms 29 | 64 bytes from 10.1.0.2: icmp_seq=28 ttl=64 time=0.255 ms 30 | 64 bytes from 10.1.0.2: icmp_seq=29 ttl=64 time=0.281 ms 31 | 64 bytes from 10.1.0.2: icmp_seq=30 ttl=64 time=0.148 ms 32 | 64 bytes from 10.1.0.2: icmp_seq=31 ttl=64 time=0.122 ms 33 | 64 bytes from 10.1.0.2: icmp_seq=32 ttl=64 time=0.344 ms 34 | 35 | --- 10.1.0.2 ping statistics --- 36 | 32 packets transmitted, 32 received, 0% packet loss, time 31003ms 37 | rtt min/avg/max/mdev = 0.071/1.441/40.289/6.978 ms 38 | -------------------------------------------------------------------------------- /analysis/demographic.py: -------------------------------------------------------------------------------- 1 | #Accuracy Score 2 | #http://rasbt.github.io/mlxtend/user_guide/plotting/plot_decision_regions/ 3 | from __future__ import division 4 | import numpy 5 | import os 6 | from sklearn import svm 7 | from collections import deque 8 | import matplotlib.pyplot as plt 9 | from mlxtend.plotting import plot_decision_regions 10 | import numpy as np 11 | from google.colab import drive 12 | drive.mount('/content/drive') 13 | data = np.loadtxt(open('/content/drive/MyDrive/Colab Notebooks/resultthreetier.csv', 'rb'), delimiter=',') 14 | 15 | sfe = 0 16 | ssip = 1 17 | rfip = 2 18 | 19 | 20 | X = data[:, [sfe,ssip]] 21 | print('Standard Deviation for Speed of Flow Entry:', np.std(data[:, [sfe]])) 22 | print('Standard Deviation for Speed of Source IP:', np.std(data[:, [ssip]])) 23 | print('Standard Deviation of Ratio in Flow Entry Pair:', np.std(data[:, [rfip]])) 24 | y = data[:, 3] 25 | clf = svm.SVC() 26 | clf.fit(X, y) 27 | 28 | fig = plt.figure(figsize=(10,8)) 29 | fig = plot_decision_regions(X=X, 30 | y=y.astype(int), 31 | clf=clf, 32 | legend=2, colors='cyan,red') 33 | 34 | plt.xlabel('Speed of Flow Entry', fontweight='bold') 35 | plt.ylabel('Speed of Source IP', fontweight='bold') 36 | L=plt.legend() 37 | L.get_texts()[0].set_text('Normal Traffic') 38 | L.get_texts()[1].set_text('Attack Traffic') 39 | ax = plt.axes() 40 | ax = plt.axes() 41 | ax.patch.set_alpha(0.3) 42 | # ax.set_facecolor("cyan") 43 | ax.set_facecolor("limegreen") 44 | # L.facecolor ='snow' 45 | # L.edgecolor ='snow' 46 | 47 | # plt.rcParams.update({'axes.facecolor':'green'}) 48 | 49 | # ax.set_facecolor(color='green') 50 | plt.savefig("mitigation_graph1.png") 51 | 52 | 53 | 54 | 55 | #Graph1 sfe & rfip 56 | X = data[:, [sfe,rfip]] 57 | y = data[:, 3] 58 | clf = svm.SVC() 59 | clf.fit(X, y) 60 | fig = plt.figure(figsize=(10,8)) 61 | fig = plot_decision_regions(X=X, 62 | y=y.astype(int), 63 | clf=clf, 64 | legend=2, colors='cyan,red') 65 | # plt.title('Demografi Akurasi dan Proses Mitigasi Serangan pada Arsitektur Three Tier', size=16, fontweight='bold') 66 | plt.xlabel('Speed of Flow Entry', fontweight='bold') 67 | plt.ylabel('Ratio in Flow Entry Pair', fontweight='bold') 68 | plt.savefig("mitigation_graph2.png") 69 | L=plt.legend() 70 | L.get_texts()[0].set_text('Normal Traffic') 71 | L.get_texts()[1].set_text('Attack Traffic') 72 | ax = plt.axes() 73 | ax.patch.set_alpha(0.3) 74 | ax.set_facecolor("limegreen") 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SDN Security - DDOS Mitigation System based on Ryu Controller Framework with Port Blocking Mechanism using Decision Tree Algorithm 2 | 3 | **This is a thesis project that creates a DDoS Mitigation System inside the Ryu SDN Controller. The specification is as follows:** 4 | 1. The controller is using the Machine Learning Classification Decision Tree Model. 5 | 2. Please use the [controllerfinal.py](https://github.com/bryanoliverh/SDNSecurity_DDOSMitigationDecisionTree_PortBlocking/blob/master/controllerfinal.py) for the full capabilities. 6 | 3. The machine learning model is being used to train the controller to determine whether a network packet is considered a DDoS attack or not. 7 | 4. The controller then will be able to detect the packet using the detection mechanism and mitigate the attack by doing a port blocking the attacker port. 8 | 5. The controller has been tested on multiple data center topologies (Three Tier, Leaf-Spine, etc) with the multiple number of nodes selection with most of the switches being used being OpenFlow Switch 1.3. 9 | 6. There is an application layer that was made to keep the monitoring of the eaeachf the node inside https://github.com/bryanoliverh/SDNSecurity_RyuControllerApplicationLayer. 10 | 7. The application layer functions to manually enable/disable ports, create whitelist/blacklist firewall rules, check the packet forwarding, block specific ports from the network devices, check the condition via the monitoring graphs, and so on. 11 | 12 | **Simulation** 13 | 14 | - Normal Traffic detection: https://youtu.be/l3U2RKbh_E4 15 | 16 | - Attack Traffic detection: https://youtu.be/wmVMV7yVDJU 17 | 18 | **Topology Example:** 19 | 20 | 21 | **Three Tier Data Center:** 22 | 23 | 24 | 25 | image 26 | 27 | 28 | 29 | 30 | **Spine Leaf Data Center:** 31 | 32 | 33 | 34 | **Introduction to Ryu and Mininet** 35 | 36 | Please read through these two docs for the introduction to Mininet and Ryu controllers: 37 | 38 | - https://ryu.readthedocs.io/en/latest/getting_started.html 39 | - http://mininet.org/walkthrough/ 40 | 41 | Ryu also has an API that can be hit from the application firewall that we run. In this case, I am using Django for the website framework. Some of the API functions are very beneficial for network monitoring and configurations. It allows the management of traffic, enabling or disabling a switch, and many more. Please choose the corresponding mininet and Ryu versions that you prefer. You can check this doc for the API functionalities: https://ryu.readthedocs.io/en/latest/app/ofctl_rest.html 42 | -------------------------------------------------------------------------------- /spineleaf9h1h12.csv: -------------------------------------------------------------------------------- 1 | 20211003072437,1633271077,10.2.1.3,7.65 2 | 20211003072438,1633271078,10.2.1.3,17.4 3 | 20211003072439,1633271079,10.2.1.3,18.3 4 | 20211003072440,1633271080,10.2.1.3,20.2 5 | 20211003072441,1633271081,10.2.1.3,17.9 6 | 20211003072442,1633271082,10.2.1.3,17.5 7 | 20211003072443,1633271083,10.2.1.3,16.8 8 | 20211003072444,1633271084,10.2.1.3,24.1 9 | 20211003072445,1633271085,10.2.1.3,19.8 10 | 20211003072446,1633271086,10.2.1.3,16.5 11 | 20211003072447,1633271087,10.2.1.3,10.7 12 | 20211003072448,1633271088,10.2.1.3,9.96 13 | 20211003072449,1633271089,10.2.1.3,22.0 14 | 20211003072450,1633271090,10.2.1.3,22.3 15 | 20211003072451,1633271091,10.2.1.3,20.3 16 | 20211003072452,1633271092,10.2.1.3,21.4 17 | 20211003072453,1633271093,10.2.1.3,19.5 18 | 20211003072454,1633271094,10.2.1.3,17.8 19 | 20211003072455,1633271095,10.2.1.3,15.2 20 | 20211003072456,1633271096,10.2.1.3,22.3 21 | 20211003072457,1633271097,10.2.1.3,13.8 22 | 20211003072458,1633271098,10.2.1.3,24.4 23 | 20211003072459,1633271099,10.2.1.3,31.1 24 | 20211003072500,1633271100,10.2.1.3,16.2 25 | 20211003072501,1633271101,10.2.1.3,22.4 26 | 20211003072502,1633271102,10.2.1.3,17.2 27 | 20211003072503,1633271103,10.2.1.3,16.8 28 | 20211003072504,1633271104,10.2.1.3,16.2 29 | 20211003072505,1633271105,10.2.1.3,17.1 30 | 20211003072506,1633271106,10.2.1.3,20.6 31 | 20211003072507,1633271107,10.2.1.3,18.1 32 | 20211003072508,1633271108,10.2.1.3,16.3 33 | 20211003072509,1633271109,10.2.1.3,18.0 34 | 20211003072510,1633271110,10.2.1.3,16.0 35 | 20211003072511,1633271111,10.2.1.3,16.7 36 | 20211003072512,1633271112,10.2.1.3,18.2 37 | 20211003072513,1633271113,10.2.1.3,16.5 38 | 20211003072514,1633271114,10.2.1.3,15.5 39 | 20211003072515,1633271115,10.2.1.3,15.8 40 | 20211003072516,1633271116,10.2.1.3,16.5 41 | 20211003072517,1633271117,10.2.1.3,18.0 42 | 20211003072518,1633271118,10.2.1.3,22.1 43 | 20211003072519,1633271119,10.2.1.3,17.8 44 | 20211003072520,1633271120,10.2.1.3,17.7 45 | 20211003072521,1633271121,10.2.1.3,21.1 46 | 20211003072522,1633271122,10.2.1.3,17.2 47 | 20211003072523,1633271123,10.2.1.3,15.8 48 | 20211003072524,1633271124,10.2.1.3,15.4 49 | 20211003072525,1633271125,10.2.1.3,16.3 50 | 20211003072526,1633271126,10.2.1.3,18.3 51 | 20211003072527,1633271127,10.2.1.3,25.5 52 | 20211003072528,1633271128,10.2.1.3,16.2 53 | 20211003072529,1633271129,10.2.1.3,17.0 54 | 20211003072530,1633271130,10.2.1.3,15.6 55 | 20211003072531,1633271131,10.2.1.3,16.0 56 | 20211003072532,1633271132,10.2.1.3,18.3 57 | 20211003072533,1633271133,10.2.1.3,16.4 58 | 20211003072534,1633271134,10.2.1.3,16.6 59 | 20211003072535,1633271135,10.2.1.3,16.7 60 | 20211003072536,1633271136,10.2.1.3,14.8 61 | 20211003072537,1633271137,10.2.1.3,18.6 62 | 20211003072538,1633271138,10.2.1.3,17.6 63 | 20211003072539,1633271139,10.2.1.3,15.8 64 | 20211003072540,1633271140,10.2.1.3,15.5 65 | 20211003072541,1633271141,10.2.1.3,16.8 66 | 20211003072542,1633271142,10.2.1.3,16.8 67 | 20211003072543,1633271143,10.2.1.3,22.3 68 | 20211003072544,1633271144,10.2.1.3,18.3 69 | 20211003072545,1633271145,10.2.1.3,16.6 70 | 20211003072546,1633271146,10.2.1.3,16.4 71 | 20211003072547,1633271147,10.2.1.3,17.4 72 | 20211003072548,1633271148,10.2.1.3,16.4 73 | 20211003072549,1633271149,10.2.1.3,17.2 74 | 20211003072550,1633271150,10.2.1.3,18.8 75 | 20211003072551,1633271151,10.2.1.3,8.72 76 | 20211003072552,1633271152,10.2.1.3,11.1 77 | 20211003072553,1633271153,10.2.1.3,15.5 78 | 20211003072554,1633271154,10.2.1.3,19.0 79 | 20211003072555,1633271155,10.2.1.3,16.6 80 | 20211003072556,1633271156,10.2.1.3,14.9 81 | 20211003072557,1633271157,10.2.1.3,16.0 82 | 20211003072558,1633271158,10.2.1.3,16.0 83 | 20211003072559,1633271159,10.2.1.3,7.15 84 | 20211003072600,1633271160,10.2.1.3,15.9 85 | 20211003072601,1633271161,10.2.1.3,15.2 86 | 20211003072602,1633271162,10.2.1.3,16.9 87 | 20211003072603,1633271163,10.2.1.3,17.6 88 | 20211003072604,1633271164,10.2.1.3,15.5 89 | 20211003072605,1633271165,10.2.1.3,16.2 90 | 20211003072606,1633271166,10.2.1.3,16.5 91 | 20211003072607,1633271167,10.2.1.3,17.7 92 | 20211003072608,1633271168,10.2.1.3,19.5 93 | 20211003072609,1633271169,10.2.1.3,17.7 94 | 20211003072610,1633271170,10.2.1.3,21.7 95 | 20211003072611,1633271171,10.2.1.3,18.6 96 | 20211003072612,1633271172,10.2.1.3,17.9 97 | 20211003072613,1633271173,10.2.1.3,21.0 98 | 20211003072614,1633271174,10.2.1.3,16.1 99 | 20211003072615,1633271175,10.2.1.3,17.4 100 | 20211003072616,1633271176,10.2.1.3,26.8 101 | -------------------------------------------------------------------------------- /spineleaf7.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from mininet.net import Mininet 4 | from mininet.node import Controller, RemoteController, OVSController 5 | from mininet.node import CPULimitedHost, Host, Node 6 | from mininet.node import OVSKernelSwitch, UserSwitch 7 | from mininet.node import IVSSwitch 8 | from mininet.cli import CLI 9 | from mininet.log import setLogLevel, info 10 | from mininet.link import TCLink, Intf 11 | from subprocess import call 12 | 13 | def myNetwork(): 14 | 15 | net = Mininet( topo=None, 16 | build=False, 17 | ipBase='10.0.0.0/8') 18 | 19 | info( '*** Adding controller\n' ) 20 | c0=net.addController(name='c0', 21 | controller=Controller, 22 | ip='192.168.1.107', 23 | protocol='tcp', 24 | port=6633) 25 | 26 | info( '*** Add switches\n') 27 | s1 = net.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13') 28 | s2 = net.addSwitch('s2', cls=OVSKernelSwitch, protocols='OpenFlow13') 29 | s3 = net.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13') 30 | s4 = net.addSwitch('s4', cls=OVSKernelSwitch, protocols='OpenFlow13') 31 | s5 = net.addSwitch('s5', cls=OVSKernelSwitch, protocols='OpenFlow13') 32 | s6 = net.addSwitch('s6', cls=OVSKernelSwitch, protocols='OpenFlow13') 33 | s7 = net.addSwitch('s7', cls=OVSKernelSwitch, protocols='OpenFlow13') 34 | # s1 = net.addSwitch('s1') 35 | # s2 = net.addSwitch('s2') 36 | # s3 = net.addSwitch('s3') 37 | # s4 = net.addSwitch('s4') 38 | # s5 = net.addSwitch('s5') 39 | # s6 = net.addSwitch('s6') 40 | # s7 = net.addSwitch('s7') 41 | h1 = net.addHost('h1', cls=Host, ip='10.0.0.2', defaultRoute=None) 42 | h2 = net.addHost('h2', cls=Host, ip='10.0.0.3', defaultRoute=None) 43 | h3 = net.addHost('h3', cls=Host, ip='10.0.1.2', defaultRoute=None) 44 | h4 = net.addHost('h4', cls=Host, ip='10.0.1.3', defaultRoute=None) 45 | h5 = net.addHost('h5', cls=Host, ip='10.1.0.2', defaultRoute=None) 46 | h6 = net.addHost('h6', cls=Host, ip='10.1.0.3', defaultRoute=None) 47 | h7 = net.addHost('h7', cls=Host, ip='10.1.1.2', defaultRoute=None) 48 | h8 = net.addHost('h8', cls=Host, ip='10.1.1.3', defaultRoute=None) 49 | info( '*** Add links\n') 50 | net.addLink(h1, s1 ,cls = TCLink,bw=40) 51 | net.addLink(h2, s1 ,cls = TCLink,bw=40) 52 | net.addLink(h3, s2 ,cls = TCLink,bw=40) 53 | net.addLink(h4, s2 ,cls = TCLink,bw=40) 54 | net.addLink(h5, s3 ,cls = TCLink,bw=40) 55 | net.addLink(h6, s3 ,cls = TCLink,bw=40) 56 | net.addLink(h7, s4 ,cls = TCLink,bw=40) 57 | net.addLink(h8, s4 ,cls = TCLink,bw=40) 58 | 59 | # net.addLink(h16, s4, cls=TCLink, bw=5) 60 | #net.addLink(s4, s1, cls=TCLink, bw=5) 61 | #add links s1--All Switches 62 | net.addLink(s6, s3 ,cls = TCLink,bw=80) 63 | net.addLink(s6, s4 ,cls = TCLink,bw=80) 64 | net.addLink(s6, s1 ,cls = TCLink,bw=80) 65 | net.addLink(s6, s2 ,cls = TCLink,bw=80) 66 | 67 | #addlinks s2--All Switches 68 | net.addLink(s5, s1 ,cls = TCLink,bw=80) 69 | net.addLink(s5, s2 ,cls = TCLink,bw=80) 70 | net.addLink(s5, s3 ,cls = TCLink,bw=80) 71 | net.addLink(s5, s4 ,cls = TCLink,bw=80) 72 | 73 | #addlinks s7--All Switches 74 | net.addLink(s7, s1 ,cls = TCLink,bw=80) 75 | net.addLink(s7, s2, cls = TCLink,bw=80) 76 | net.addLink(s7, s3 ,cls = TCLink,bw=80) 77 | net.addLink(s7, s4, cls = TCLink,bw=80) 78 | 79 | info( '*** Starting network\n') 80 | net.build() 81 | info( '*** Starting controllers\n') 82 | for controller in net.controllers: 83 | controller.start() 84 | 85 | info( '*** Starting switches\n') 86 | 87 | net.get('s2').start([c0]) 88 | net.get('s3').start([c0]) 89 | net.get('s5').start([c0]) 90 | net.get('s6').start([c0]) 91 | net.get('s1').start([c0]) 92 | net.get('s7').start([c0]) 93 | net.get('s4').start([c0]) 94 | 95 | info( '*** Post configure switches and hosts\n') 96 | s1.cmd('ifconfig s1 10.0.0.1') 97 | s2.cmd('ifconfig s2 10.0.1.1') 98 | s3.cmd('ifconfig s3 10.1.0.1') 99 | s4.cmd('ifconfig s4 10.1.1.1') 100 | s5.cmd('ifconfig s5 10.2.0.1') 101 | s6.cmd('ifconfig s6 10.2.1.1') 102 | s7.cmd('ifconfig s7 10.3.0.1') 103 | 104 | CLI(net) 105 | net.stop() 106 | 107 | if __name__ == '__main__': 108 | setLogLevel( 'info' ) 109 | myNetwork() -------------------------------------------------------------------------------- /rest_topology.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 Nippon Telegraph and Telephone Corporation. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | # implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | import json 17 | 18 | from ryu.app.wsgi import ControllerBase 19 | from ryu.app.wsgi import Response 20 | from ryu.app.wsgi import route 21 | from ryu.app.wsgi import WSGIApplication 22 | from ryu.base import app_manager 23 | from ryu.lib import dpid as dpid_lib 24 | from ryu.topology.api import get_switch, get_link, get_host 25 | 26 | # REST API for switch configuration 27 | # 28 | # get all the switches 29 | # GET /v1.0/topology/switches 30 | # 31 | # get the switch 32 | # GET /v1.0/topology/switches/ 33 | # 34 | # get all the links 35 | # GET /v1.0/topology/links 36 | # 37 | # get the links of a switch 38 | # GET /v1.0/topology/links/ 39 | # 40 | # get all the hosts 41 | # GET /v1.0/topology/hosts 42 | # 43 | # get the hosts of a switch 44 | # GET /v1.0/topology/hosts/ 45 | # 46 | # where 47 | # : datapath id in 16 hex 48 | 49 | 50 | class TopologyAPI(app_manager.RyuApp): 51 | _CONTEXTS = { 52 | 'wsgi': WSGIApplication 53 | } 54 | 55 | def __init__(self, *args, **kwargs): 56 | super(TopologyAPI, self).__init__(*args, **kwargs) 57 | 58 | wsgi = kwargs['wsgi'] 59 | wsgi.register(TopologyController, {'topology_api_app': self}) 60 | 61 | 62 | class TopologyController(ControllerBase): 63 | def __init__(self, req, link, data, **config): 64 | super(TopologyController, self).__init__(req, link, data, **config) 65 | self.topology_api_app = data['topology_api_app'] 66 | 67 | @route('topology', '/v1.0/topology/switches', 68 | methods=['GET']) 69 | def list_switches(self, req, **kwargs): 70 | return self._switches(req, **kwargs) 71 | 72 | @route('topology', '/v1.0/topology/switches/{dpid}', 73 | methods=['GET'], requirements={'dpid': dpid_lib.DPID_PATTERN}) 74 | def get_switch(self, req, **kwargs): 75 | return self._switches(req, **kwargs) 76 | 77 | @route('topology', '/v1.0/topology/links', 78 | methods=['GET']) 79 | def list_links(self, req, **kwargs): 80 | return self._links(req, **kwargs) 81 | 82 | @route('topology', '/v1.0/topology/links/{dpid}', 83 | methods=['GET'], requirements={'dpid': dpid_lib.DPID_PATTERN}) 84 | def get_links(self, req, **kwargs): 85 | return self._links(req, **kwargs) 86 | 87 | @route('topology', '/v1.0/topology/hosts', 88 | methods=['GET']) 89 | def list_hosts(self, req, **kwargs): 90 | return self._hosts(req, **kwargs) 91 | 92 | @route('topology', '/v1.0/topology/hosts/{dpid}', 93 | methods=['GET'], requirements={'dpid': dpid_lib.DPID_PATTERN}) 94 | def get_hosts(self, req, **kwargs): 95 | return self._hosts(req, **kwargs) 96 | 97 | def _switches(self, req, **kwargs): 98 | dpid = None 99 | if 'dpid' in kwargs: 100 | dpid = dpid_lib.str_to_dpid(kwargs['dpid']) 101 | switches = get_switch(self.topology_api_app, dpid) 102 | body = json.dumps([switch.to_dict() for switch in switches]) 103 | return Response(content_type='application/json', body=body) 104 | 105 | def _links(self, req, **kwargs): 106 | dpid = None 107 | if 'dpid' in kwargs: 108 | dpid = dpid_lib.str_to_dpid(kwargs['dpid']) 109 | links = get_link(self.topology_api_app, dpid) 110 | body = json.dumps([link.to_dict() for link in links]) 111 | return Response(content_type='application/json', body=body) 112 | 113 | def _hosts(self, req, **kwargs): 114 | dpid = None 115 | if 'dpid' in kwargs: 116 | dpid = dpid_lib.str_to_dpid(kwargs['dpid']) 117 | hosts = get_host(self.topology_api_app, dpid) 118 | body = json.dumps([host.to_dict() for host in hosts]) 119 | return Response(content_type='application/json', body=body) 120 | -------------------------------------------------------------------------------- /bryanwebsite/webcommand.txt: -------------------------------------------------------------------------------- 1 | cd D:\UI\skripsi 2 | D: 3 | 4 | env\Scripts\activate 5 | cd bryanwebsite 6 | python .\manage.py runserver 7 | 8 | python .\manage.py makemigrations 9 | python .\manage.py migrate 10 | python .\manage.py runserver 11 | 12 | ssh -X mininet@192.168.1.112 13 | ssh -X ryu@192.168.1.103 14 | ssh -X wifi@192.168.168.6 15 | 16 | 17 | 18 | sudo mn --controller=remote,ip=192.168.1.108 --topo=linear,4 --switch ovsk,protocols=OpenFlow13 19 | 20 | cd bryanfinal 21 | sudo python threetier9.py 22 | 23 | cd app 24 | ryu-manager simple_switch_13.py rest_firewall.py ofctl_rest.py 25 | 26 | ryu-manager controller.py rest_firewall.py ofctl_rest.py 27 | 28 | in folder applayer ryu 29 | ryu-manager simple_switch_13.py rest_firewall.py 30 | hping3 -S --flood -V -p 80 170.155.9.185 --rand-source 31 | 32 | source flowsetupsl.sh 33 | source stpsetup.sh 34 | 35 | ovs-ofctl -O OpenFlow13 dump-flows s1 36 | 37 | python -m venv env 38 | 39 | 40 | Address already in use: 41 | ps -fA | grep python 42 | kill 43 | 44 | 45 | scp -r mininet@192.168.1.116:/home/mininet/bryanfinal/threetier9h1h12_5000packets.csv dataresearch/ 46 | 47 | scp -r mininet@192.168.1.116:/home/mininet/bryanfinal/threetest.csv dataresearch/ 48 | unsupported version: 49 | sudo ovs-vsctl set bridge s1 protocols=OpenFlow13 50 | sudo ovs-vsctl set bridge s2 protocols=OpenFlow13 51 | sudo ovs-vsctl set bridge s3 protocols=OpenFlow13 52 | sudo ovs-vsctl set bridge s4 protocols=OpenFlow13 53 | 54 | s1 = net.addSwitch('s3', cls=OVSSwitch, mac='00:00:00:00:00:06', protocols='OpenFlow13') 55 | # ============================= 56 | # REST API 57 | # ============================= 58 | # 59 | # Note: specify switch and vlan group, as follows. 60 | # {switch-id} : 'all' or switchID 61 | # {vlan-id} : 'all' or vlanID 62 | # 63 | # 64 | 65 | # about Firewall status 66 | # 67 | # get status of all firewall switches 68 | # GET /firewall/module/status 69 | # 70 | # set enable the firewall switches 71 | # PUT /firewall/module/enable/{switch-id} 72 | # 73 | # set disable the firewall switches 74 | # PUT /firewall/module/disable/{switch-id} 75 | # 76 | 77 | # about Firewall logs 78 | # 79 | # get log status of all firewall switches 80 | # GET /firewall/log/status 81 | # 82 | # set log enable the firewall switches 83 | # PUT /firewall/log/enable/{switch-id} 84 | # 85 | # set log disable the firewall switches 86 | # PUT /firewall/log/disable/{switch-id} 87 | # 88 | 89 | # about Firewall rules 90 | # 91 | # get rules of the firewall switches 92 | # * for no vlan 93 | # GET /firewall/rules/{switch-id} 94 | # 95 | # * for specific vlan group 96 | # GET /firewall/rules/{switch-id}/{vlan-id} 97 | # 98 | # 99 | # set a rule to the firewall switches 100 | # * for no vlan 101 | # POST /firewall/rules/{switch-id} 102 | # 103 | # * for specific vlan group 104 | # POST /firewall/rules/{switch-id}/{vlan-id} 105 | # 106 | # request body format: 107 | # {"":"", "":"",...} 108 | # 109 | # : 110 | # "priority": "0 to 65533" 111 | # "in_port" : "" 112 | # "dl_src" : "" 113 | # "dl_dst" : "" 114 | # "dl_type" : "" 115 | # "nw_src" : "" 116 | # "nw_dst" : "" 117 | # "ipv6_src": "" 118 | # "ipv6_dst": "" 119 | # "nw_proto": "" 120 | # "tp_src" : "" 121 | # "tp_dst" : "" 122 | # "actions" : "" 123 | # 124 | # Note: specifying nw_src/nw_dst 125 | # without specifying dl-type as "ARP" or "IPv4" 126 | # will automatically set dl-type as "IPv4". 127 | # 128 | # Note: specifying ipv6_src/ipv6_dst 129 | # without specifying dl-type as "IPv6" 130 | # will automatically set dl-type as "IPv6". 131 | # 132 | # Note: When "priority" has not been set up, 133 | # "0" is set to "priority". 134 | # 135 | # Note: When "actions" has not been set up, 136 | # "ALLOW" is set to "actions". 137 | # 138 | # 139 | # delete a rule of the firewall switches from ruleID 140 | # * for no vlan 141 | # DELETE /firewall/rules/{switch-id} 142 | # 143 | # * for specific vlan group 144 | # DELETE /firewall/rules/{switch-id}/{vlan-id} 145 | # 146 | # request body format: 147 | # {"":""} 148 | # 149 | # : 150 | # "rule_id" : "" or "all" 151 | # -------------------------------------------------------------------------------- /threetier9h1h12.csv: -------------------------------------------------------------------------------- 1 | 20211003074433,1633272273,10.2.1.3,0.600 2 | 20211003074434,1633272274,10.2.1.3,0.148 3 | 20211003074435,1633272275,10.2.1.3,0.217 4 | 20211003074436,1633272276,10.2.1.3,0.148 5 | 20211003074437,1633272277,10.2.1.3,0.158 6 | 20211003074438,1633272278,10.2.1.3,0.154 7 | 20211003074439,1633272279,10.2.1.3,0.188 8 | 20211003074440,1633272280,10.2.1.3,0.216 9 | 20211003074441,1633272281,10.2.1.3,0.195 10 | 20211003074442,1633272282,10.2.1.3,0.194 11 | 20211003074443,1633272283,10.2.1.3,0.156 12 | 20211003074444,1633272284,10.2.1.3,0.149 13 | 20211003074445,1633272285,10.2.1.3,0.152 14 | 20211003074446,1633272286,10.2.1.3,0.181 15 | 20211003074447,1633272287,10.2.1.3,0.155 16 | 20211003074448,1633272288,10.2.1.3,0.192 17 | 20211003074449,1633272289,10.2.1.3,0.155 18 | 20211003074450,1633272290,10.2.1.3,0.198 19 | 20211003074451,1633272291,10.2.1.3,0.162 20 | 20211003074452,1633272292,10.2.1.3,0.160 21 | 20211003074453,1633272293,10.2.1.3,0.214 22 | 20211003074454,1633272294,10.2.1.3,0.192 23 | 20211003074455,1633272295,10.2.1.3,0.157 24 | 20211003074456,1633272296,10.2.1.3,0.154 25 | 20211003074457,1633272297,10.2.1.3,0.151 26 | 20211003074458,1633272298,10.2.1.3,0.160 27 | 20211003074459,1633272299,10.2.1.3,0.185 28 | 20211003074500,1633272300,10.2.1.3,0.206 29 | 20211003074501,1633272301,10.2.1.3,0.159 30 | 20211003074502,1633272302,10.2.1.3,0.159 31 | 20211003074503,1633272303,10.2.1.3,0.157 32 | 20211003074504,1633272304,10.2.1.3,0.198 33 | 20211003074505,1633272305,10.2.1.3,0.159 34 | 20211003074506,1633272306,10.2.1.3,0.165 35 | 20211003074507,1633272307,10.2.1.3,0.165 36 | 20211003074508,1633272308,10.2.1.3,0.161 37 | 20211003074509,1633272309,10.2.1.3,0.208 38 | 20211003074510,1633272310,10.2.1.3,0.158 39 | 20211003074511,1633272311,10.2.1.3,0.162 40 | 20211003074512,1633272312,10.2.1.3,0.153 41 | 20211003074513,1633272313,10.2.1.3,0.157 42 | 20211003074514,1633272314,10.2.1.3,0.156 43 | 20211003074515,1633272315,10.2.1.3,0.399 44 | 20211003074516,1633272316,10.2.1.3,0.155 45 | 20211003074517,1633272317,10.2.1.3,0.155 46 | 20211003074518,1633272318,10.2.1.3,0.153 47 | 20211003074519,1633272319,10.2.1.3,0.161 48 | 20211003074520,1633272320,10.2.1.3,0.155 49 | 20211003074521,1633272321,10.2.1.3,0.160 50 | 20211003074522,1633272322,10.2.1.3,0.158 51 | 20211003074523,1633272323,10.2.1.3,0.193 52 | 20211003074524,1633272324,10.2.1.3,0.181 53 | 20211003074525,1633272325,10.2.1.3,0.153 54 | 20211003074526,1633272326,10.2.1.3,0.159 55 | 20211003074527,1633272327,10.2.1.3,0.156 56 | 20211003074528,1633272328,10.2.1.3,0.161 57 | 20211003074529,1633272329,10.2.1.3,0.160 58 | 20211003074530,1633272330,10.2.1.3,0.159 59 | 20211003074531,1633272331,10.2.1.3,0.231 60 | 20211003074532,1633272332,10.2.1.3,0.159 61 | 20211003074533,1633272333,10.2.1.3,0.160 62 | 20211003074534,1633272334,10.2.1.3,0.157 63 | 20211003074535,1633272335,10.2.1.3,0.159 64 | 20211003074536,1633272336,10.2.1.3,0.160 65 | 20211003074537,1633272337,10.2.1.3,0.158 66 | 20211003074538,1633272338,10.2.1.3,0.154 67 | 20211003074539,1633272339,10.2.1.3,0.162 68 | 20211003074540,1633272340,10.2.1.3,0.201 69 | 20211003074541,1633272341,10.2.1.3,0.223 70 | 20211003074542,1633272342,10.2.1.3,0.161 71 | 20211003074543,1633272343,10.2.1.3,0.160 72 | 20211003074544,1633272344,10.2.1.3,0.191 73 | 20211003074545,1633272345,10.2.1.3,0.156 74 | 20211003074546,1633272346,10.2.1.3,0.156 75 | 20211003074547,1633272347,10.2.1.3,0.178 76 | 20211003074548,1633272348,10.2.1.3,0.236 77 | 20211003074549,1633272349,10.2.1.3,0.152 78 | 20211003074550,1633272350,10.2.1.3,0.155 79 | 20211003074551,1633272351,10.2.1.3,0.236 80 | 20211003074552,1633272352,10.2.1.3,0.188 81 | 20211003074553,1633272353,10.2.1.3,0.157 82 | 20211003074554,1633272354,10.2.1.3,0.159 83 | 20211003074555,1633272355,10.2.1.3,0.192 84 | 20211003074556,1633272356,10.2.1.3,0.219 85 | 20211003074557,1633272357,10.2.1.3,0.184 86 | 20211003074558,1633272358,10.2.1.3,0.158 87 | 20211003074559,1633272359,10.2.1.3,0.218 88 | 20211003074600,1633272360,10.2.1.3,0.205 89 | 20211003074601,1633272361,10.2.1.3,0.157 90 | 20211003074602,1633272362,10.2.1.3,0.159 91 | 20211003074603,1633272363,10.2.1.3,0.158 92 | 20211003074604,1633272364,10.2.1.3,0.158 93 | 20211003074605,1633272365,10.2.1.3,0.158 94 | 20211003074606,1633272366,10.2.1.3,0.155 95 | 20211003074607,1633272367,10.2.1.3,0.164 96 | 20211003074608,1633272368,10.2.1.3,0.160 97 | 20211003074609,1633272369,10.2.1.3,0.165 98 | 20211003074610,1633272370,10.2.1.3,0.191 99 | 20211003074611,1633272371,10.2.1.3,0.153 100 | 20211003074612,1633272372,10.2.1.3,0.190 101 | -------------------------------------------------------------------------------- /dataresearch/spineleaf9h1h12_links100packets.csv: -------------------------------------------------------------------------------- 1 | 20211101092633,1635783993,10.0.0.3,0.036 2 | 20211101092634,1635783994,10.0.0.3,0.100 3 | 20211101092635,1635783995,10.0.0.3,0.099 4 | 20211101092636,1635783996,10.0.0.3,0.096 5 | 20211101092637,1635783997,10.0.0.3,0.106 6 | 20211101092638,1635783998,10.0.0.3,0.099 7 | 20211101092639,1635783999,10.0.0.3,0.091 8 | 20211101092640,1635784000,10.0.0.3,0.099 9 | 20211101092641,1635784001,10.0.0.3,0.102 10 | 20211101092642,1635784002,10.0.0.3,0.099 11 | 20211101092643,1635784003,10.0.0.3,0.135 12 | 20211101092644,1635784004,10.0.0.3,0.101 13 | 20211101092645,1635784005,10.0.0.3,0.099 14 | 20211101092646,1635784006,10.0.0.3,0.085 15 | 20211101092647,1635784007,10.0.0.3,0.171 16 | 20211101092648,1635784008,10.0.0.3,0.099 17 | 20211101092649,1635784009,10.0.0.3,0.099 18 | 20211101092650,1635784010,10.0.0.3,0.102 19 | 20211101092651,1635784011,10.0.0.3,0.099 20 | 20211101092652,1635784012,10.0.0.3,0.077 21 | 20211101092653,1635784013,10.0.0.3,0.099 22 | 20211101092654,1635784014,10.0.0.3,0.099 23 | 20211101092655,1635784015,10.0.0.3,0.102 24 | 20211101092656,1635784016,10.0.0.3,0.101 25 | 20211101092657,1635784017,10.0.0.3,0.135 26 | 20211101092658,1635784018,10.0.0.3,0.104 27 | 20211101092659,1635784019,10.0.0.3,0.104 28 | 20211101092700,1635784020,10.0.0.3,0.105 29 | 20211101092701,1635784021,10.0.0.3,0.098 30 | 20211101092702,1635784022,10.0.0.3,0.100 31 | 20211101092703,1635784023,10.0.0.3,0.131 32 | 20211101092704,1635784024,10.0.0.3,0.099 33 | 20211101092705,1635784025,10.0.0.3,0.103 34 | 20211101092706,1635784026,10.0.0.3,0.099 35 | 20211101092707,1635784027,10.0.0.3,0.105 36 | 20211101092708,1635784028,10.0.0.3,0.104 37 | 20211101092709,1635784029,10.0.0.3,0.115 38 | 20211101092710,1635784030,10.0.0.3,0.100 39 | 20211101092711,1635784031,10.0.0.3,0.107 40 | 20211101092712,1635784032,10.0.0.3,0.102 41 | 20211101092713,1635784033,10.0.0.3,0.104 42 | 20211101092714,1635784034,10.0.0.3,0.101 43 | 20211101092715,1635784035,10.0.0.3,0.132 44 | 20211101092716,1635784036,10.0.0.3,0.101 45 | 20211101092717,1635784037,10.0.0.3,0.109 46 | 20211101092718,1635784038,10.0.0.3,0.099 47 | 20211101092719,1635784039,10.0.0.3,0.101 48 | 20211101092720,1635784040,10.0.0.3,0.105 49 | 20211101092721,1635784041,10.0.0.3,0.103 50 | 20211101092722,1635784042,10.0.0.3,0.100 51 | 20211101092723,1635784043,10.0.0.3,0.101 52 | 20211101092724,1635784044,10.0.0.3,0.100 53 | 20211101092725,1635784045,10.0.0.3,0.104 54 | 20211101092726,1635784046,10.0.0.3,0.105 55 | 20211101092727,1635784047,10.0.0.3,0.093 56 | 20211101092728,1635784048,10.0.0.3,0.132 57 | 20211101092729,1635784049,10.0.0.3,0.103 58 | 20211101092730,1635784050,10.0.0.3,0.103 59 | 20211101092731,1635784051,10.0.0.3,0.099 60 | 20211101092732,1635784052,10.0.0.3,0.103 61 | 20211101092733,1635784053,10.0.0.3,0.101 62 | 20211101092734,1635784054,10.0.0.3,0.100 63 | 20211101092735,1635784055,10.0.0.3,0.099 64 | 20211101092736,1635784056,10.0.0.3,0.118 65 | 20211101092737,1635784057,10.0.0.3,0.102 66 | 20211101092738,1635784058,10.0.0.3,0.103 67 | 20211101092739,1635784059,10.0.0.3,0.107 68 | 20211101092740,1635784060,10.0.0.3,0.106 69 | 20211101092741,1635784061,10.0.0.3,0.098 70 | 20211101092742,1635784062,10.0.0.3,0.099 71 | 20211101092743,1635784063,10.0.0.3,0.101 72 | 20211101092744,1635784064,10.0.0.3,0.101 73 | 20211101092745,1635784065,10.0.0.3,0.100 74 | 20211101092746,1635784066,10.0.0.3,0.112 75 | 20211101092747,1635784067,10.0.0.3,0.104 76 | 20211101092748,1635784068,10.0.0.3,0.108 77 | 20211101092749,1635784069,10.0.0.3,0.101 78 | 20211101092750,1635784070,10.0.0.3,0.108 79 | 20211101092751,1635784071,10.0.0.3,0.107 80 | 20211101092752,1635784072,10.0.0.3,0.104 81 | 20211101092753,1635784073,10.0.0.3,0.099 82 | 20211101092754,1635784074,10.0.0.3,0.103 83 | 20211101092755,1635784075,10.0.0.3,0.103 84 | 20211101092756,1635784076,10.0.0.3,0.108 85 | 20211101092757,1635784077,10.0.0.3,0.092 86 | 20211101092758,1635784078,10.0.0.3,0.061 87 | 20211101092759,1635784079,10.0.0.3,0.102 88 | 20211101092800,1635784080,10.0.0.3,0.101 89 | 20211101092801,1635784081,10.0.0.3,0.161 90 | 20211101092802,1635784082,10.0.0.3,0.103 91 | 20211101092803,1635784083,10.0.0.3,0.100 92 | 20211101092804,1635784084,10.0.0.3,0.100 93 | 20211101092805,1635784085,10.0.0.3,0.107 94 | 20211101092806,1635784086,10.0.0.3,0.102 95 | 20211101092807,1635784087,10.0.0.3,0.100 96 | 20211101092808,1635784088,10.0.0.3,0.102 97 | 20211101092809,1635784089,10.0.0.3,0.100 98 | 20211101092810,1635784090,10.0.0.3,0.105 99 | 20211101092811,1635784091,10.0.0.3,0.102 100 | 20211101092812,1635784092,10.0.0.3,0.113 101 | -------------------------------------------------------------------------------- /threetier7.py: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/python 3 | from mininet.topo import Topo 4 | from mininet.net import Mininet, Host 5 | from mininet.node import OVSKernelSwitch, UserSwitch 6 | from mininet.log import setLogLevel 7 | from mininet.cli import CLI 8 | from mininet.node import OVSSwitch, Controller, RemoteController 9 | from mininet.link import TCLink 10 | from time import sleep 11 | import random 12 | 13 | ''' 14 | s7 15 | s5 s6 16 | s1 s2 s3 s4 17 | h1 h2 h3 h4 h5 h6 h7 h8 18 | 19 | ''' 20 | 21 | TEST_TIME = 30 #seconds 22 | TEST_TYPE = "manual" 23 | #normal, attack, manual 24 | 25 | class datacentertopo(Topo): 26 | "Single switch connected to 10 hosts." 27 | def build(self): 28 | s1 = self.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13') 29 | s2 = self.addSwitch('s2', cls=OVSKernelSwitch, protocols='OpenFlow13') 30 | s3 = self.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13') 31 | s4 = self.addSwitch('s4', cls=OVSKernelSwitch, protocols='OpenFlow13') 32 | s5 = self.addSwitch('s5', cls=OVSKernelSwitch, protocols='OpenFlow13') 33 | s6 = self.addSwitch('s6', cls=OVSKernelSwitch, protocols='OpenFlow13') 34 | s7 = self.addSwitch('s7', cls=OVSKernelSwitch, protocols='OpenFlow13') 35 | # s1 = self.addSwitch('s1') 36 | # s2 = self.addSwitch('s2') 37 | # s3 = self.addSwitch('s3') 38 | # s4 = self.addSwitch('s4') 39 | # s5 = self.addSwitch('s5') 40 | # s6 = self.addSwitch('s6') 41 | # s7 = self.addSwitch('s7') 42 | h1 = self.addHost('h1', cls=Host, ip='10.0.0.2', defaultRoute="via 10.0.0.2") 43 | h2 = self.addHost('h2', cls=Host, ip='10.0.0.3', defaultRoute="via 10.0.0.2") 44 | h3 = self.addHost('h3', cls=Host, ip='10.0.1.2', defaultRoute="via 10.0.1.2") 45 | h4 = self.addHost('h4', cls=Host, ip='10.0.1.3', defaultRoute="via 10.0.1.2") 46 | h5 = self.addHost('h5', cls=Host, ip='10.1.0.2', defaultRoute="via 10.1.0.2") 47 | h6 = self.addHost('h6', cls=Host, ip='10.1.0.3', defaultRoute="via 10.1.0.2") 48 | h7 = self.addHost('h7', cls=Host, ip='10.1.1.2', defaultRoute="via 10.1.1.2") 49 | h8 = self.addHost('h8', cls=Host, ip='10.1.1.3', defaultRoute="via 10.1.1.2") 50 | self.addLink(h1, s1 ,cls = TCLink,bw=40) 51 | self.addLink(h2, s1 ,cls = TCLink,bw=40) 52 | self.addLink(h3, s2 ,cls = TCLink,bw=40) 53 | self.addLink(h4, s2 ,cls = TCLink,bw=40) 54 | self.addLink(h5, s3 ,cls = TCLink,bw=40) 55 | self.addLink(h6, s3 ,cls = TCLink,bw=40) 56 | self.addLink(h7, s4 ,cls = TCLink,bw=40) 57 | self.addLink(h8, s4 ,cls = TCLink,bw=40) 58 | 59 | # self.addLink(h16, s4, cls=TCLink, bw=5) 60 | #self.addLink(s4, s1, cls=TCLink, bw=5) 61 | #add links s1--All Switches 62 | self.addLink(s6, s3 ,cls = TCLink,bw=80) 63 | self.addLink(s6, s4 ,cls = TCLink,bw=80) 64 | 65 | #addlinks s2--All Switches 66 | self.addLink(s5, s1 ,cls = TCLink,bw=80) 67 | self.addLink(s5, s2 ,cls = TCLink,bw=80) 68 | 69 | #addlinks s7--All Switches 70 | self.addLink(s7, s5 ,cls = TCLink,bw=120) 71 | self.addLink(s7, s6, cls = TCLink,bw=120) 72 | 73 | if __name__ == '__main__': 74 | setLogLevel('info') 75 | topo = datacentertopo() 76 | c1 = RemoteController('c1', ip='192.168.1.107') 77 | # c1 = RemoteController('c1', ip='127.0.0.1') 78 | net = Mininet(topo=topo, controller=c1) 79 | net.start() 80 | 81 | if TEST_TYPE == "normal": 82 | print "Generating NORMAL Traffic......." 83 | h1 = net.get('h1') 84 | cmd1 = "bash normal.sh &" 85 | h1.cmd(cmd1) 86 | 87 | h2 = net.get('h2') 88 | cmd1 = "bash normal.sh &" 89 | h2.cmd(cmd1) 90 | 91 | h3 = net.get('h3') 92 | cmd1 = "bash normal.sh &" 93 | h3.cmd(cmd1) 94 | 95 | h4 = net.get('h4') 96 | cmd1 = "bash normal.sh &" 97 | h4.cmd(cmd1) 98 | 99 | h5 = net.get('h5') 100 | cmd1 = "bash normal.sh &" 101 | h5.cmd(cmd1) 102 | 103 | h6 = net.get('h6') 104 | cmd1 = "bash normal.sh &" 105 | h6.cmd(cmd1) 106 | 107 | h7 = net.get('h7') 108 | cmd1 = "bash normal.sh &" 109 | h7.cmd(cmd1) 110 | 111 | h8 = net.get('h8') 112 | cmd1 = "bash normal.sh &" 113 | h8.cmd(cmd1) 114 | 115 | 116 | sleep(TEST_TIME) 117 | net.stop() 118 | elif TEST_TYPE == "attack": 119 | print "Generating ATTACK Traffic......." 120 | h1 = net.get('h1') 121 | cmd1 = "bash attack.sh &" 122 | h1.cmd(cmd1) 123 | 124 | sleep(TEST_TIME) 125 | net.stop() 126 | 127 | 128 | elif TEST_TYPE == "manual": 129 | CLI(net) 130 | net.stop() 131 | 132 | 133 | # CLI.do_mycmd = addh3s1 134 | # if Mininet == "py net.addHost('h3s1')": 135 | # "py net.addLink(s1, net.get('h3s1'))" 136 | # "py s1.attach('s1-eth8')" 137 | -------------------------------------------------------------------------------- /simple_switch_13.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011 Nippon Telegraph and Telephone Corporation. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | # implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | from ryu.base import app_manager 17 | from ryu.controller import ofp_event 18 | from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER 19 | from ryu.controller.handler import set_ev_cls 20 | from ryu.ofproto import ofproto_v1_3 21 | from ryu.lib.packet import packet 22 | from ryu.lib.packet import ethernet 23 | from ryu.lib.packet import ether_types 24 | 25 | 26 | class SimpleSwitch13(app_manager.RyuApp): 27 | OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION] 28 | 29 | def __init__(self, *args, **kwargs): 30 | super(SimpleSwitch13, self).__init__(*args, **kwargs) 31 | self.mac_to_port = {} 32 | 33 | @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) 34 | def switch_features_handler(self, ev): 35 | datapath = ev.msg.datapath 36 | ofproto = datapath.ofproto 37 | parser = datapath.ofproto_parser 38 | 39 | # install table-miss flow entry 40 | # 41 | # We specify NO BUFFER to max_len of the output action due to 42 | # OVS bug. At this moment, if we specify a lesser number, e.g., 43 | # 128, OVS will send Packet-In with invalid buffer_id and 44 | # truncated packet data. In that case, we cannot output packets 45 | # correctly. The bug has been fixed in OVS v2.1.0. 46 | match = parser.OFPMatch() 47 | actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, 48 | ofproto.OFPCML_NO_BUFFER)] 49 | self.add_flow(datapath, 0, match, actions) 50 | 51 | def add_flow(self, datapath, priority, match, actions, buffer_id=None): 52 | ofproto = datapath.ofproto 53 | parser = datapath.ofproto_parser 54 | 55 | inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, 56 | actions)] 57 | if buffer_id: 58 | mod = parser.OFPFlowMod(datapath=datapath, buffer_id=buffer_id, 59 | priority=priority, match=match, 60 | instructions=inst) 61 | else: 62 | mod = parser.OFPFlowMod(datapath=datapath, priority=priority, 63 | match=match, instructions=inst) 64 | datapath.send_msg(mod) 65 | 66 | @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) 67 | def _packet_in_handler(self, ev): 68 | # If you hit this you might want to increase 69 | # the "miss_send_length" of your switch 70 | if ev.msg.msg_len < ev.msg.total_len: 71 | self.logger.debug("packet truncated: only %s of %s bytes", 72 | ev.msg.msg_len, ev.msg.total_len) 73 | msg = ev.msg 74 | datapath = msg.datapath 75 | ofproto = datapath.ofproto 76 | parser = datapath.ofproto_parser 77 | in_port = msg.match['in_port'] 78 | 79 | pkt = packet.Packet(msg.data) 80 | eth = pkt.get_protocols(ethernet.ethernet)[0] 81 | 82 | if eth.ethertype == ether_types.ETH_TYPE_LLDP: 83 | # ignore lldp packet 84 | return 85 | dst = eth.dst 86 | src = eth.src 87 | 88 | dpid = format(datapath.id, "d").zfill(16) 89 | self.mac_to_port.setdefault(dpid, {}) 90 | 91 | self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port) 92 | 93 | # learn a mac address to avoid FLOOD next time. 94 | self.mac_to_port[dpid][src] = in_port 95 | 96 | if dst in self.mac_to_port[dpid]: 97 | out_port = self.mac_to_port[dpid][dst] 98 | else: 99 | out_port = ofproto.OFPP_FLOOD 100 | 101 | actions = [parser.OFPActionOutput(out_port)] 102 | 103 | # install a flow to avoid packet_in next time 104 | if out_port != ofproto.OFPP_FLOOD: 105 | match = parser.OFPMatch(in_port=in_port, eth_dst=dst, eth_src=src) 106 | # verify if we have a valid buffer_id, if yes avoid to send both 107 | # flow_mod & packet_out 108 | if msg.buffer_id != ofproto.OFP_NO_BUFFER: 109 | self.add_flow(datapath, 1, match, actions, msg.buffer_id) 110 | return 111 | else: 112 | self.add_flow(datapath, 1, match, actions) 113 | data = None 114 | if msg.buffer_id == ofproto.OFP_NO_BUFFER: 115 | data = msg.data 116 | 117 | out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id, 118 | in_port=in_port, actions=actions, data=data) 119 | datapath.send_msg(out) -------------------------------------------------------------------------------- /spineleafdatacentertopo.py: -------------------------------------------------------------------------------- 1 | from mininet.net import Mininet 2 | from mininet.node import Controller,OVSKernelSwitch,RemoteController 3 | from mininet.cli import CLI 4 | from mininet.log import setLogLevel, info 5 | from mininet.link import Link, Intf, TCLink 6 | from mininet.topo import Topo 7 | from mininet.util import irange,dumpNodeConnections 8 | import logging 9 | import os 10 | 11 | 12 | logger = logging.getLogger( __name__ ) 13 | 14 | class LinearTopo(Topo): 15 | logger.info("Class HugeTopo") 16 | CoreSwitchList = [] 17 | AggSwitchList = [] 18 | EdgeSwitchList = [] 19 | HostList = [] 20 | KNumber = 0 21 | 22 | 23 | def __init__(self, k, **opts): 24 | super(LinearTopo, self).__init__(**opts) 25 | self.k = k 26 | self.iCoreLayerSwitch = (k/2)**2 27 | self.iAggLayerSwitch = (k**2)/2 28 | self.iEdgeLayerSwitch = (k**2)/2 29 | self.iHost = (k**3)/4 30 | lastSwitch = None 31 | 32 | def createTopo(self): 33 | 34 | logger.info("Start create Core Layer Swich") 35 | self.createCoreLayerSwitch(self.iCoreLayerSwitch) 36 | logger.debug("Start create Agg Layer Swich ") 37 | self.createAggLayerSwitch(self.iAggLayerSwitch) 38 | logger.debug("Start create Edge Layer Swich ") 39 | self.createEdgeLayerSwitch(self.iEdgeLayerSwitch) 40 | logger.debug("Start create Host") 41 | self.createHost(self.iHost) 42 | 43 | 44 | def createCoreLayerSwitch(self,NUMBER): 45 | logger.info("Create Core Layer") 46 | k1=NUMBER 47 | Coreid=[] 48 | for i in irange(1,k1/2): 49 | k2=1 50 | while k2<((k1/2)+1): 51 | print '000000000'+'%s'%k1+'0'+'%s'%i+'0'+'%s'%k2 52 | Coreid.append('000000000'+'%s'%k1+'0'+'%s'%i+'0'+'%s'%k2) 53 | k2=k2+1 54 | for i in irange(1,NUMBER): 55 | self.CoreSwitchList.append(self.addSwitch('CS%s' % i,dpid=Coreid[i-1],listenport=6633,protcols=["OpenFlow13"],Controller=RemoteController)) 56 | print self.CoreSwitchList[0] 57 | 58 | 59 | def createAggLayerSwitch(self,NUMBER): 60 | logger.info("Create Agg Layer") 61 | k1=NUMBER/2 62 | Aggid=[] 63 | for i1 in range(0,k1): 64 | k2=((k1/2)+1) 65 | while k2<(k1+1): 66 | print '00000000000'+'%s'%i1+'0'+'%s'%k2+'01' 67 | Aggid.append('00000000000'+'%s'%i1+'0'+'%s'%k2+'01') 68 | k2=k2+1 69 | for i in irange(1,NUMBER): 70 | self.AggSwitchList.append(self.addSwitch('AS%s' % (i),dpid=Aggid[i-1],listenport=6633,protcols=["OpenFlow13"],controller=RemoteController)) 71 | print ('AS%s',i) 72 | print Aggid 73 | 74 | def createEdgeLayerSwitch(self,NUMBER): 75 | logger.info("Create Edge Layer") 76 | k1=NUMBER/2 77 | Eggid=[] 78 | for i1 in range(0,k1): 79 | k2=1 80 | while k2<((k1/2)+1): 81 | print '00000000000'+'%s'%i1+'0'+'%s'%k2+'01' 82 | Eggid.append('00000000000'+'%s'%i1+'0'+'%s'%k2+'01') 83 | k2=k2+1 84 | for i in irange(1,NUMBER): 85 | self.EdgeSwitchList.append(self.addSwitch('ES%s' % (i),dpid=Eggid[i-1],listenport=6633,protcols=["OpenFlow13"],controller=RemoteController)) 86 | print ('ES%s',i) 87 | print Eggid 88 | 89 | def createHost(self,NUMBER): 90 | logger.info("Create Hosts") 91 | Host=[] 92 | k1=NUMBER/4 93 | for i in range(0,k1): 94 | k3=0 95 | while k3<(k1/2): 96 | k2=0 97 | while(k2<(k1/2)): 98 | print i,k2 99 | Host.append('10.'+'%s'%i+'.'+'%s.'%k3+'%s'%((k1/2)+k2)) 100 | k2=k2+1 101 | k3=k3+1 102 | 103 | for i in irange(1,NUMBER): 104 | self.HostList.append(self.addHost('Host%s'%i)) 105 | 106 | print Host 107 | 108 | def createLink(self): 109 | logger.info("Start creating Links") 110 | logger.info("Creating Core to Agg Layer links") 111 | k = self.k 112 | #for i in range(0,(2*(k/2)),(k/2)): 113 | # for j in range(0,(k/2)): 114 | 115 | k1=0 116 | m=0 117 | k3=0 118 | while k1<(k/2): 119 | k4=(0) 120 | for i in range(k1,((k/2)*k),(k/2)): 121 | k2=0 122 | while k2<(k/2): 123 | print k2+m,i,k4+1,(k/2)-1-k2+1 124 | self.addLink(self.CoreSwitchList[k2+m],self.AggSwitchList[i],k4+1,(k/2)-1-k2+1) 125 | k2=k2+1 126 | k4=k4+1 127 | k3=k3+(k/2) 128 | m=k2 129 | k1=k1+1 130 | for i in range(0,((k/2)*k),(k/2)): 131 | m1=((k/2)-1) 132 | for j in range(0,(k/2)): 133 | k1=0 134 | while(k1<(k/2)): 135 | print ((k/2)+k1+1),m1+1 136 | self.addLink(self.AggSwitchList[j+i],self.EdgeSwitchList[k1+i],((k/2)+k1+1),m1+1) 137 | k1=k1+1 138 | m1=m1-1 139 | 140 | m=0 141 | for i in range(0,((k/2)*k)): 142 | k1=0 143 | while k1<(k/2): 144 | self.addLink(self.EdgeSwitchList[i],self.HostList[m],port1=(((k/2)+k1)+1),port2=1) 145 | print self.EdgeSwitchList[i],self.HostList[m] 146 | k1=k1+1 147 | m=m+1 148 | 149 | def simpleTest(): 150 | topo = LinearTopo(k=4) 151 | topo.createTopo() 152 | topo.createLink() 153 | #use=LinearTopo.DPIDS(4) 154 | net = Mininet(topo, link=TCLink,controller=None,autoSetMacs=True,autoStaticArp=True) 155 | ryu_ctrl=RemoteController(name='c1',ip='192.168.1.107',port=6633,protocols="OpenFlow13") 156 | net.addController(ryu_ctrl) 157 | print "addcontroller" 158 | #net.get('ES1').start([ryu_ctrl]) 159 | net.start() 160 | net.staticArp() 161 | #net.cli() 162 | dumpNodeConnections(net.hosts) 163 | CLI(net) 164 | net.stop() 165 | 166 | 167 | if __name__ == '__main__': 168 | setLogLevel('info') 169 | simpleTest() -------------------------------------------------------------------------------- /simple_switch_stp_13.py: -------------------------------------------------------------------------------- 1 | from ryu.base import app_manager 2 | from ryu.controller import ofp_event 3 | from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER 4 | from ryu.controller.handler import set_ev_cls 5 | from ryu.ofproto import ofproto_v1_3 6 | from ryu.lib import dpid as dpid_lib 7 | from ryu.lib import stplib 8 | from ryu.lib.packet import packet 9 | from ryu.lib.packet import ethernet 10 | 11 | 12 | class SimpleSwitch13(app_manager.RyuApp): 13 | OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION] 14 | _CONTEXTS = {'stplib': stplib.Stp} 15 | 16 | def __init__(self, *args, **kwargs): 17 | super(SimpleSwitch13, self).__init__(*args, **kwargs) 18 | self.mac_to_port = {} 19 | self.stp = kwargs['stplib'] 20 | 21 | # Sample of stplib config. 22 | # please refer to stplib.Stp.set_config() for details. 23 | config = {dpid_lib.str_to_dpid('0000000000000001'): 24 | {'bridge': {'priority': 0x8000}}, 25 | dpid_lib.str_to_dpid('0000000000000002'): 26 | {'bridge': {'priority': 0x9000}}, 27 | dpid_lib.str_to_dpid('0000000000000003'): 28 | {'bridge': {'priority': 0xa000}}} 29 | self.stp.set_config(config) 30 | 31 | @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) 32 | def switch_features_handler(self, ev): 33 | datapath = ev.msg.datapath 34 | ofproto = datapath.ofproto 35 | parser = datapath.ofproto_parser 36 | 37 | # install table-miss flow entry 38 | # 39 | # We specify NO BUFFER to max_len of the output action due to 40 | # OVS bug. At this moment, if we specify a lesser number, e.g., 41 | # 128, OVS will send Packet-In with invalid buffer_id and 42 | # truncated packet data. In that case, we cannot output packets 43 | # correctly. 44 | match = parser.OFPMatch() 45 | actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, 46 | ofproto.OFPCML_NO_BUFFER)] 47 | self.add_flow(datapath, 0, match, actions) 48 | 49 | def add_flow(self, datapath, priority, match, actions): 50 | ofproto = datapath.ofproto 51 | parser = datapath.ofproto_parser 52 | 53 | inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, 54 | actions)] 55 | 56 | mod = parser.OFPFlowMod(datapath=datapath, priority=priority, 57 | match=match, instructions=inst) 58 | datapath.send_msg(mod) 59 | 60 | def delete_flow(self, datapath): 61 | ofproto = datapath.ofproto 62 | parser = datapath.ofproto_parser 63 | 64 | for dst in self.mac_to_port[datapath.id].keys(): 65 | match = parser.OFPMatch(eth_dst=dst) 66 | mod = parser.OFPFlowMod( 67 | datapath, command=ofproto.OFPFC_DELETE, 68 | out_port=ofproto.OFPP_ANY, out_group=ofproto.OFPG_ANY, 69 | priority=1, match=match) 70 | datapath.send_msg(mod) 71 | 72 | @set_ev_cls(stplib.EventPacketIn, MAIN_DISPATCHER) 73 | def _packet_in_handler(self, ev): 74 | msg = ev.msg 75 | datapath = msg.datapath 76 | ofproto = datapath.ofproto 77 | parser = datapath.ofproto_parser 78 | in_port = msg.match['in_port'] 79 | 80 | pkt = packet.Packet(msg.data) 81 | eth = pkt.get_protocols(ethernet.ethernet)[0] 82 | 83 | dst = eth.dst 84 | src = eth.src 85 | 86 | dpid = datapath.id 87 | self.mac_to_port.setdefault(dpid, {}) 88 | 89 | self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port) 90 | 91 | # learn a mac address to avoid FLOOD next time. 92 | self.mac_to_port[dpid][src] = in_port 93 | 94 | if dst in self.mac_to_port[dpid]: 95 | out_port = self.mac_to_port[dpid][dst] 96 | else: 97 | out_port = ofproto.OFPP_FLOOD 98 | 99 | actions = [parser.OFPActionOutput(out_port)] 100 | 101 | # install a flow to avoid packet_in next time 102 | if out_port != ofproto.OFPP_FLOOD: 103 | match = parser.OFPMatch(in_port=in_port, eth_dst=dst) 104 | self.add_flow(datapath, 1, match, actions) 105 | 106 | data = None 107 | if msg.buffer_id == ofproto.OFP_NO_BUFFER: 108 | data = msg.data 109 | 110 | out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id, 111 | in_port=in_port, actions=actions, data=data) 112 | datapath.send_msg(out) 113 | 114 | @set_ev_cls(stplib.EventTopologyChange, MAIN_DISPATCHER) 115 | def _topology_change_handler(self, ev): 116 | dp = ev.dp 117 | dpid_str = dpid_lib.dpid_to_str(dp.id) 118 | msg = 'Receive topology change event. Flush MAC table.' 119 | self.logger.debug("[dpid=%s] %s", dpid_str, msg) 120 | 121 | if dp.id in self.mac_to_port: 122 | self.delete_flow(dp) 123 | del self.mac_to_port[dp.id] 124 | 125 | @set_ev_cls(stplib.EventPortStateChange, MAIN_DISPATCHER) 126 | def _port_state_change_handler(self, ev): 127 | dpid_str = dpid_lib.dpid_to_str(ev.dp.id) 128 | of_state = {stplib.PORT_STATE_DISABLE: 'DISABLE', 129 | stplib.PORT_STATE_BLOCK: 'BLOCK', 130 | stplib.PORT_STATE_LISTEN: 'LISTEN', 131 | stplib.PORT_STATE_LEARN: 'LEARN', 132 | stplib.PORT_STATE_FORWARD: 'FORWARD'} 133 | self.logger.debug("[dpid=%s][port=%d] state=%s", 134 | dpid_str, ev.port_no, of_state[ev.port_state]) -------------------------------------------------------------------------------- /threetier9.py: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/python 3 | from mininet.topo import Topo 4 | from mininet.net import Mininet, Host 5 | from mininet.node import OVSKernelSwitch, UserSwitch 6 | from mininet.log import setLogLevel 7 | from mininet.cli import CLI 8 | from mininet.node import OVSSwitch, Controller, RemoteController 9 | from mininet.link import TCLink 10 | from time import sleep 11 | import random 12 | 13 | ''' 14 | s9 15 | s7 s8 16 | s1 s2 s3 s4 s5 s6 17 | h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 18 | 19 | ''' 20 | 21 | TEST_TIME = 30 #seconds 22 | TEST_TYPE = "manual" 23 | #normal, attack, manual 24 | 25 | class datacentertopo(Topo): 26 | "Single switch connected to 10 hosts." 27 | def build(self): 28 | s1 = self.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13') 29 | s2 = self.addSwitch('s2', cls=OVSKernelSwitch, protocols='OpenFlow13') 30 | s3 = self.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13') 31 | s4 = self.addSwitch('s4', cls=OVSKernelSwitch, protocols='OpenFlow13') 32 | s5 = self.addSwitch('s5', cls=OVSKernelSwitch, protocols='OpenFlow13') 33 | s6 = self.addSwitch('s6', cls=OVSKernelSwitch, protocols='OpenFlow13') 34 | s7 = self.addSwitch('s7', cls=OVSKernelSwitch, protocols='OpenFlow13') 35 | s8 = self.addSwitch('s8', cls=OVSKernelSwitch, protocols='OpenFlow13') 36 | s9 = self.addSwitch('s9', cls=OVSKernelSwitch, protocols='OpenFlow13') 37 | # s1 = self.addSwitch('s1') 38 | # s2 = self.addSwitch('s2') 39 | # s3 = self.addSwitch('s3') 40 | # s4 = self.addSwitch('s4') 41 | # s5 = self.addSwitch('s5') 42 | # s6 = self.addSwitch('s6') 43 | # s7 = self.addSwitch('s7') 44 | h1 = self.addHost('h1', cls=Host, ip='10.0.0.2', defaultRoute="via 10.0.0.2") 45 | h2 = self.addHost('h2', cls=Host, ip='10.0.0.3', defaultRoute="via 10.0.0.2") 46 | h3 = self.addHost('h3', cls=Host, ip='10.0.1.2', defaultRoute="via 10.0.1.2") 47 | h4 = self.addHost('h4', cls=Host, ip='10.0.1.3', defaultRoute="via 10.0.1.2") 48 | h5 = self.addHost('h5', cls=Host, ip='10.1.0.2', defaultRoute="via 10.1.0.2") 49 | h6 = self.addHost('h6', cls=Host, ip='10.1.0.3', defaultRoute="via 10.1.0.2") 50 | h7 = self.addHost('h7', cls=Host, ip='10.1.1.2', defaultRoute="via 10.1.1.2") 51 | h8 = self.addHost('h8', cls=Host, ip='10.1.1.3', defaultRoute="via 10.1.1.2") 52 | h9 = self.addHost('h9', cls=Host, ip='10.2.0.2', defaultRoute="via 10.2.0.2") 53 | h10 = self.addHost('h10', cls=Host, ip='10.2.0.3', defaultRoute="via 10.2.0.2") 54 | h11 = self.addHost('h11', cls=Host, ip='10.2.1.2', defaultRoute="via 10.2.1.2") 55 | h12 = self.addHost('h12', cls=Host, ip='10.2.1.3', defaultRoute="via 10.2.1.2") 56 | self.addLink(h1, s1 ,cls = TCLink,bw=40) 57 | self.addLink(h2, s1 ,cls = TCLink,bw=40) 58 | self.addLink(h3, s2 ,cls = TCLink,bw=40) 59 | self.addLink(h4, s2 ,cls = TCLink,bw=40) 60 | self.addLink(h5, s3 ,cls = TCLink,bw=40) 61 | self.addLink(h6, s3 ,cls = TCLink,bw=40) 62 | self.addLink(h7, s4 ,cls = TCLink,bw=40) 63 | self.addLink(h8, s4 ,cls = TCLink,bw=40) 64 | self.addLink(h9, s5 ,cls = TCLink,bw=40) 65 | self.addLink(h10, s5 ,cls = TCLink,bw=40) 66 | self.addLink(h11, s6 ,cls = TCLink,bw=40) 67 | self.addLink(h12, s6 ,cls = TCLink,bw=40) 68 | 69 | # self.addLink(h16, s4, cls=TCLink, bw=5) 70 | #self.addLink(s4, s1, cls=TCLink, bw=5) 71 | #add links s1--All Switches 72 | self.addLink(s8, s4 ,cls = TCLink,bw=80) 73 | self.addLink(s8, s5 ,cls = TCLink,bw=80) 74 | self.addLink(s8, s6 ,cls = TCLink,bw=80) 75 | 76 | #addlinks s2--All Switches 77 | self.addLink(s7, s1 ,cls = TCLink,bw=80) 78 | self.addLink(s7, s2 ,cls = TCLink,bw=80) 79 | self.addLink(s7, s3 ,cls = TCLink,bw=80) 80 | 81 | #addlinks s7--All Switches 82 | self.addLink(s9, s7 ,cls = TCLink,bw=120) 83 | self.addLink(s9, s8, cls = TCLink,bw=120) 84 | 85 | if __name__ == '__main__': 86 | setLogLevel('info') 87 | topo = datacentertopo() 88 | c1 = RemoteController('c1', ip='192.168.1.107') 89 | # c1 = RemoteController('c1', ip='127.0.0.1') 90 | net = Mininet(topo=topo, controller=c1) 91 | net.start() 92 | 93 | if TEST_TYPE == "normal": 94 | print "Generating NORMAL Traffic......." 95 | h1 = net.get('h1') 96 | cmd1 = "bash normal.sh &" 97 | h1.cmd(cmd1) 98 | 99 | h2 = net.get('h2') 100 | cmd1 = "bash normal.sh &" 101 | h2.cmd(cmd1) 102 | 103 | h3 = net.get('h3') 104 | cmd1 = "bash normal.sh &" 105 | h3.cmd(cmd1) 106 | 107 | h4 = net.get('h4') 108 | cmd1 = "bash normal.sh &" 109 | h4.cmd(cmd1) 110 | 111 | h5 = net.get('h5') 112 | cmd1 = "bash normal.sh &" 113 | h5.cmd(cmd1) 114 | 115 | h6 = net.get('h6') 116 | cmd1 = "bash normal.sh &" 117 | h6.cmd(cmd1) 118 | 119 | h7 = net.get('h7') 120 | cmd1 = "bash normal.sh &" 121 | h7.cmd(cmd1) 122 | 123 | h8 = net.get('h8') 124 | cmd1 = "bash normal.sh &" 125 | h8.cmd(cmd1) 126 | 127 | 128 | sleep(TEST_TIME) 129 | net.stop() 130 | elif TEST_TYPE == "attack": 131 | print "Generating ATTACK Traffic......." 132 | h1 = net.get('h1') 133 | cmd1 = "bash attack.sh &" 134 | h1.cmd(cmd1) 135 | 136 | sleep(TEST_TIME) 137 | net.stop() 138 | 139 | 140 | elif TEST_TYPE == "manual": 141 | CLI(net) 142 | net.stop() 143 | 144 | 145 | # CLI.do_mycmd = addh3s1 146 | # if Mininet == "py net.addHost('h3s1')": 147 | # "py net.addLink(s1, net.get('h3s1'))" 148 | # "py s1.attach('s1-eth8')" 149 | -------------------------------------------------------------------------------- /spineleaf9.py: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/python 3 | from mininet.topo import Topo 4 | from mininet.net import Mininet, Host 5 | from mininet.node import OVSKernelSwitch, UserSwitch 6 | from mininet.log import setLogLevel 7 | from mininet.cli import CLI 8 | from mininet.node import OVSSwitch, Controller, RemoteController 9 | from mininet.link import TCLink 10 | from time import sleep 11 | import random 12 | 13 | ''' 14 | s9 15 | s7 s8 16 | s1 s2 s3 s4 s5 s6 17 | h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 18 | 19 | ''' 20 | 21 | TEST_TIME = 30 #seconds 22 | TEST_TYPE = "manual" 23 | #normal, attack, manual 24 | 25 | class datacentertopo(Topo): 26 | "Single switch connected to 10 hosts." 27 | 28 | def build(net): 29 | 30 | s1 = net.addSwitch('s1', cls=OVSKernelSwitch, protocols='OpenFlow13') 31 | s2 = net.addSwitch('s2', cls=OVSKernelSwitch, protocols='OpenFlow13') 32 | s3 = net.addSwitch('s3', cls=OVSKernelSwitch, protocols='OpenFlow13') 33 | s4 = net.addSwitch('s4', cls=OVSKernelSwitch, protocols='OpenFlow13') 34 | s5 = net.addSwitch('s5', cls=OVSKernelSwitch, protocols='OpenFlow13') 35 | s6 = net.addSwitch('s6', cls=OVSKernelSwitch, protocols='OpenFlow13') 36 | s7 = net.addSwitch('s7', cls=OVSKernelSwitch, protocols='OpenFlow13') 37 | s8 = net.addSwitch('s8', cls=OVSKernelSwitch, protocols='OpenFlow13') 38 | s9 = net.addSwitch('s9', cls=OVSKernelSwitch, protocols='OpenFlow13') 39 | # s1 = net.addSwitch('s1') 40 | # s2 = net.addSwitch('s2') 41 | # s3 = net.addSwitch('s3') 42 | # s4 = net.addSwitch('s4') 43 | # s5 = net.addSwitch('s5') 44 | # s6 = net.addSwitch('s6') 45 | # s7 = net.addSwitch('s7') 46 | h1 = net.addHost('h1', cls=Host, ip='10.0.0.2', defaultRoute=None) 47 | h2 = net.addHost('h2', cls=Host, ip='10.0.0.3', defaultRoute=None) 48 | h3 = net.addHost('h3', cls=Host, ip='10.0.1.2', defaultRoute=None) 49 | h4 = net.addHost('h4', cls=Host, ip='10.0.1.3', defaultRoute=None) 50 | h5 = net.addHost('h5', cls=Host, ip='10.1.0.2', defaultRoute=None) 51 | h6 = net.addHost('h6', cls=Host, ip='10.1.0.3', defaultRoute=None) 52 | h7 = net.addHost('h7', cls=Host, ip='10.1.1.2', defaultRoute=None) 53 | h8 = net.addHost('h8', cls=Host, ip='10.1.1.3', defaultRoute=None) 54 | h9 = net.addHost('h9', cls=Host, ip='10.2.0.2', defaultRoute="via 10.2.0.2") 55 | h10 = net.addHost('h10', cls=Host, ip='10.2.0.3', defaultRoute="via 10.2.0.2") 56 | h11 = net.addHost('h11', cls=Host, ip='10.2.1.2', defaultRoute="via 10.2.1.2") 57 | h12 = net.addHost('h12', cls=Host, ip='10.2.1.3', defaultRoute="via 10.2.1.2") 58 | 59 | net.addLink(h1, s1 ,cls = TCLink,bw=40) 60 | net.addLink(h2, s1 ,cls = TCLink,bw=40) 61 | net.addLink(h3, s2 ,cls = TCLink,bw=40) 62 | net.addLink(h4, s2 ,cls = TCLink,bw=40) 63 | net.addLink(h5, s3 ,cls = TCLink,bw=40) 64 | net.addLink(h6, s3 ,cls = TCLink,bw=40) 65 | net.addLink(h7, s4 ,cls = TCLink,bw=40) 66 | net.addLink(h8, s4 ,cls = TCLink,bw=40) 67 | net.addLink(h9, s5 ,cls = TCLink,bw=40) 68 | net.addLink(h10, s5 ,cls = TCLink,bw=40) 69 | net.addLink(h11, s6 ,cls = TCLink,bw=40) 70 | net.addLink(h12, s6 ,cls = TCLink,bw=40) 71 | 72 | # net.addLink(h16, s4, cls=TCLink, bw=5) 73 | #net.addLink(s4, s1, cls=TCLink, bw=5) 74 | #add links s1--All Switches 75 | net.addLink(s7, s3 ,cls = TCLink,bw=80) 76 | net.addLink(s7, s4 ,cls = TCLink,bw=80) 77 | net.addLink(s7, s1 ,cls = TCLink,bw=80) 78 | net.addLink(s7, s2 ,cls = TCLink,bw=80) 79 | net.addLink(s7, s5 ,cls = TCLink,bw=80) 80 | net.addLink(s7, s6 ,cls = TCLink,bw=80) 81 | 82 | #addlinks s2--All Switches 83 | net.addLink(s8, s1 ,cls = TCLink,bw=80) 84 | net.addLink(s8, s2 ,cls = TCLink,bw=80) 85 | net.addLink(s8, s3 ,cls = TCLink,bw=80) 86 | net.addLink(s8, s4 ,cls = TCLink,bw=80) 87 | net.addLink(s8, s5 ,cls = TCLink,bw=80) 88 | net.addLink(s8, s6 ,cls = TCLink,bw=80) 89 | 90 | #addlinks s7--All Switches 91 | net.addLink(s9, s1 ,cls = TCLink,bw=80) 92 | net.addLink(s9, s2, cls = TCLink,bw=80) 93 | net.addLink(s9, s3 ,cls = TCLink,bw=80) 94 | net.addLink(s9, s4, cls = TCLink,bw=80) 95 | net.addLink(s9, s5 ,cls = TCLink,bw=80) 96 | net.addLink(s9, s6 ,cls = TCLink,bw=80) 97 | if __name__ == '__main__': 98 | setLogLevel('info') 99 | topo = datacentertopo() 100 | c1 = RemoteController('c1', ip='192.168.1.107') 101 | # c1 = RemoteController('c1', ip='127.0.0.1') 102 | net = Mininet(topo=topo, controller=c1) 103 | net.start() 104 | 105 | if TEST_TYPE == "normal": 106 | print "Generating NORMAL Traffic......." 107 | h1 = net.get('h1') 108 | cmd1 = "bash normal.sh &" 109 | h1.cmd(cmd1) 110 | 111 | h2 = net.get('h2') 112 | cmd1 = "bash normal.sh &" 113 | h2.cmd(cmd1) 114 | 115 | h3 = net.get('h3') 116 | cmd1 = "bash normal.sh &" 117 | h3.cmd(cmd1) 118 | 119 | h4 = net.get('h4') 120 | cmd1 = "bash normal.sh &" 121 | h4.cmd(cmd1) 122 | 123 | h5 = net.get('h5') 124 | cmd1 = "bash normal.sh &" 125 | h5.cmd(cmd1) 126 | 127 | h6 = net.get('h6') 128 | cmd1 = "bash normal.sh &" 129 | h6.cmd(cmd1) 130 | 131 | h7 = net.get('h7') 132 | cmd1 = "bash normal.sh &" 133 | h7.cmd(cmd1) 134 | 135 | h8 = net.get('h8') 136 | cmd1 = "bash normal.sh &" 137 | h8.cmd(cmd1) 138 | 139 | 140 | sleep(TEST_TIME) 141 | net.stop() 142 | elif TEST_TYPE == "attack": 143 | print "Generating ATTACK Traffic......." 144 | h1 = net.get('h1') 145 | cmd1 = "bash attack.sh &" 146 | h1.cmd(cmd1) 147 | 148 | sleep(TEST_TIME) 149 | net.stop() 150 | 151 | 152 | elif TEST_TYPE == "manual": 153 | CLI(net) 154 | net.stop() 155 | 156 | 157 | # CLI.do_mycmd = addh3s1 158 | # if Mininet == "py net.addHost('h3s1')": 159 | # "py net.addLink(s1, net.get('h3s1'))" 160 | # "py s1.attach('s1-eth8')" 161 | -------------------------------------------------------------------------------- /mininet2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from mininet.net import Mininet 4 | from mininet.node import Controller, RemoteController, OVSController 5 | from mininet.node import CPULimitedHost, Host, Node 6 | from mininet.node import OVSKernelSwitch, UserSwitch 7 | from mininet.node import IVSSwitch 8 | from mininet.cli import CLI 9 | from mininet.log import setLogLevel, info 10 | from mininet.link import TCLink, Intf 11 | from subprocess import call 12 | 13 | def myNetwork(): 14 | 15 | net = Mininet( topo=None, 16 | build=False, 17 | ipBase='10.0.0.0/8') 18 | 19 | info( '*** Adding controller\n' ) 20 | c0=net.addController(name='c0', 21 | controller=Controller, 22 | protocol='tcp', 23 | port=6633) 24 | 25 | info( '*** Add switches\n') 26 | s15 = net.addSwitch('s15', cls=OVSKernelSwitch) 27 | s20 = net.addSwitch('s20', cls=OVSKernelSwitch) 28 | s2 = net.addSwitch('s2', cls=OVSKernelSwitch) 29 | s3 = net.addSwitch('s3', cls=OVSKernelSwitch) 30 | s5 = net.addSwitch('s5', cls=OVSKernelSwitch) 31 | s17 = net.addSwitch('s17', cls=OVSKernelSwitch) 32 | s6 = net.addSwitch('s6', cls=OVSKernelSwitch) 33 | s13 = net.addSwitch('s13', cls=OVSKernelSwitch) 34 | s11 = net.addSwitch('s11', cls=OVSKernelSwitch) 35 | s18 = net.addSwitch('s18', cls=OVSKernelSwitch) 36 | s8 = net.addSwitch('s8', cls=OVSKernelSwitch) 37 | s19 = net.addSwitch('s19', cls=OVSKernelSwitch) 38 | s1 = net.addSwitch('s1', cls=OVSKernelSwitch) 39 | s7 = net.addSwitch('s7', cls=OVSKernelSwitch) 40 | s12 = net.addSwitch('s12', cls=OVSKernelSwitch) 41 | s10 = net.addSwitch('s10', cls=OVSKernelSwitch) 42 | s16 = net.addSwitch('s16', cls=OVSKernelSwitch) 43 | s9 = net.addSwitch('s9', cls=OVSKernelSwitch) 44 | s14 = net.addSwitch('s14', cls=OVSKernelSwitch) 45 | s4 = net.addSwitch('s4', cls=OVSKernelSwitch) 46 | 47 | info( '*** Add hosts\n') 48 | h7 = net.addHost('h7', cls=Host, ip='10.1.1.2', defaultRoute=None) 49 | h8 = net.addHost('h8', cls=Host, ip='10.1.1.3', defaultRoute=None) 50 | h9 = net.addHost('h9', cls=Host, ip='10.2.0.2', defaultRoute=None) 51 | h10 = net.addHost('h10', cls=Host, ip='10.2.0.3', defaultRoute=None) 52 | h11 = net.addHost('h11', cls=Host, ip='10.2.1.2', defaultRoute=None) 53 | h6 = net.addHost('h6', cls=Host, ip='10.1.0.3', defaultRoute=None) 54 | h15 = net.addHost('h15', cls=Host, ip='10.3.1.2', defaultRoute=None) 55 | h12 = net.addHost('h12', cls=Host, ip='10.2.1.3', defaultRoute=None) 56 | h14 = net.addHost('h14', cls=Host, ip='10.3.0.3', defaultRoute=None) 57 | h13 = net.addHost('h13', cls=Host, ip='10.3.0.2', defaultRoute=None) 58 | h2 = net.addHost('h2', cls=Host, ip='10.0.0.3', defaultRoute=None) 59 | h16 = net.addHost('h16', cls=Host, ip='10.3.1.3', defaultRoute=None) 60 | h1 = net.addHost('h1', cls=Host, ip='10.0.0.2', defaultRoute=None) 61 | h3 = net.addHost('h3', cls=Host, ip='10.0.1.2', defaultRoute=None) 62 | h4 = net.addHost('h4', cls=Host, ip='10.0.1.3', defaultRoute=None) 63 | h5 = net.addHost('h5', cls=Host, ip='10.1.0.2', defaultRoute=None) 64 | 65 | info( '*** Add links\n') 66 | net.addLink(s1, h1) 67 | net.addLink(s1, h2) 68 | net.addLink(s2, h3) 69 | net.addLink(s2, h4) 70 | net.addLink(s3, h5) 71 | net.addLink(s3, h6) 72 | net.addLink(s4, h7) 73 | net.addLink(s4, h8) 74 | net.addLink(s5, h9) 75 | net.addLink(s5, h10) 76 | net.addLink(s6, h11) 77 | net.addLink(s6, h12) 78 | net.addLink(s7, h13) 79 | net.addLink(s7, h14) 80 | net.addLink(s8, h15) 81 | net.addLink(s8, h16) 82 | net.addLink(s9, s1) 83 | net.addLink(s9, s2) 84 | net.addLink(s1, s10) 85 | net.addLink(s10, s2) 86 | net.addLink(s11, s3) 87 | net.addLink(s3, s12) 88 | net.addLink(s11, s4) 89 | net.addLink(s12, s4) 90 | net.addLink(s13, s5) 91 | net.addLink(s14, s5) 92 | net.addLink(s13, s6) 93 | net.addLink(s14, s6) 94 | net.addLink(s15, s7) 95 | net.addLink(s15, s8) 96 | net.addLink(s16, s7) 97 | net.addLink(s16, s8) 98 | net.addLink(s17, s9) 99 | net.addLink(s9, s18) 100 | net.addLink(s11, s17) 101 | net.addLink(s11, s18) 102 | net.addLink(s13, s17) 103 | net.addLink(s15, s17) 104 | net.addLink(s10, s19) 105 | net.addLink(s10, s20) 106 | net.addLink(s12, s19) 107 | net.addLink(s12, s20) 108 | net.addLink(s14, s19) 109 | net.addLink(s14, s20) 110 | net.addLink(s15, s18) 111 | net.addLink(s16, s19) 112 | net.addLink(s16, s20) 113 | net.addLink(s18, s13) 114 | 115 | info( '*** Starting network\n') 116 | net.build() 117 | info( '*** Starting controllers\n') 118 | for controller in net.controllers: 119 | controller.start() 120 | 121 | info( '*** Starting switches\n') 122 | net.get('s15').start([c0]) 123 | net.get('s20').start([c0]) 124 | net.get('s2').start([c0]) 125 | net.get('s3').start([c0]) 126 | net.get('s5').start([c0]) 127 | net.get('s17').start([c0]) 128 | net.get('s6').start([c0]) 129 | net.get('s13').start([c0]) 130 | net.get('s11').start([c0]) 131 | net.get('s18').start([c0]) 132 | net.get('s8').start([c0]) 133 | net.get('s19').start([c0]) 134 | net.get('s1').start([c0]) 135 | net.get('s7').start([c0]) 136 | net.get('s12').start([c0]) 137 | net.get('s10').start([c0]) 138 | net.get('s16').start([c0]) 139 | net.get('s9').start([c0]) 140 | net.get('s14').start([c0]) 141 | net.get('s4').start([c0]) 142 | 143 | info( '*** Post configure switches and hosts\n') 144 | s15.cmd('ifconfig s15 10.3.2.1') 145 | s20.cmd('ifconfig s20 10.4.2.2') 146 | s2.cmd('ifconfig s2 10.0.1.1') 147 | s3.cmd('ifconfig s3 10.1.0.1') 148 | s5.cmd('ifconfig s5 10.2.0.1') 149 | s17.cmd('ifconfig s17 10.4.1.1') 150 | s6.cmd('ifconfig s6 10.2.1.1') 151 | s13.cmd('ifconfig s13 10.2.2.1') 152 | s11.cmd('ifconfig s11 10.1.2.1') 153 | s18.cmd('ifconfig s18 10.4.1.2') 154 | s8.cmd('ifconfig s8 10.3.1.1') 155 | s19.cmd('ifconfig s19 10.4.2.1') 156 | s1.cmd('ifconfig s1 10.0.0.1') 157 | s7.cmd('ifconfig s7 10.3.0.1') 158 | s12.cmd('ifconfig s12 10.1.3.1') 159 | s10.cmd('ifconfig s10 10.0.3.1') 160 | s16.cmd('ifconfig s16 10.3.3.1') 161 | s9.cmd('ifconfig s9 10.0.2.1') 162 | s14.cmd('ifconfig s14 10.2.3.1') 163 | s4.cmd('ifconfig s4 10.1.1.1') 164 | 165 | CLI(net) 166 | net.stop() 167 | 168 | if __name__ == '__main__': 169 | setLogLevel( 'info' ) 170 | myNetwork() -------------------------------------------------------------------------------- /mininet1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from mininet.net import Mininet 3 | from mininet.node import Controller, RemoteController, OVSController 4 | from mininet.node import CPULimitedHost, Host, Node 5 | from mininet.node import OVSKernelSwitch, UserSwitch 6 | from mininet.node import IVSSwitch 7 | from mininet.cli import CLI 8 | from mininet.log import setLogLevel, info 9 | from mininet.link import TCLink, Intf 10 | from subprocess import call 11 | 12 | #fattree 13 | def myNetwork(): 14 | 15 | net = Mininet( topo=None, 16 | build=False, 17 | ipBase='10.0.0.0/8') 18 | 19 | info( '*** Adding controller\n' ) 20 | 21 | c0=net.addController('c0', 22 | controller=RemoteController, 23 | ip="192.168.1.102", 24 | port=6653) 25 | 26 | info( '*** Add switches\n') 27 | s15 = net.addSwitch('s15', cls=OVSKernelSwitch) 28 | s2 = net.addSwitch('s2', cls=OVSKernelSwitch) 29 | s17 = net.addSwitch('s17', cls=OVSKernelSwitch) 30 | s5 = net.addSwitch('s5', cls=OVSKernelSwitch) 31 | s18 = net.addSwitch('s18', cls=OVSKernelSwitch) 32 | s6 = net.addSwitch('s6', cls=OVSKernelSwitch) 33 | s7 = net.addSwitch('s7', cls=OVSKernelSwitch) 34 | s14 = net.addSwitch('s14', cls=OVSKernelSwitch) 35 | s20 = net.addSwitch('s20', cls=OVSKernelSwitch) 36 | s9 = net.addSwitch('s9', cls=OVSKernelSwitch) 37 | s8 = net.addSwitch('s8', cls=OVSKernelSwitch) 38 | s10 = net.addSwitch('s10', cls=OVSKernelSwitch) 39 | s4 = net.addSwitch('s4', cls=OVSKernelSwitch) 40 | s12 = net.addSwitch('s12', cls=OVSKernelSwitch) 41 | s13 = net.addSwitch('s13', cls=OVSKernelSwitch) 42 | s19 = net.addSwitch('s19', cls=OVSKernelSwitch) 43 | s16 = net.addSwitch('s16', cls=OVSKernelSwitch) 44 | s1 = net.addSwitch('s1', cls=OVSKernelSwitch) 45 | s3 = net.addSwitch('s3', cls=OVSKernelSwitch) 46 | s11 = net.addSwitch('s11', cls=OVSKernelSwitch) 47 | 48 | info( '*** Add hosts\n') 49 | h6 = net.addHost('h6', cls=Host, ip='10.1.0.3', defaultRoute=None) 50 | h7 = net.addHost('h7', cls=Host, ip='10.1.1.2', defaultRoute=None) 51 | h8 = net.addHost('h8', cls=Host, ip='10.1.1.3', defaultRoute=None) 52 | h9 = net.addHost('h9', cls=Host, ip='10.2.0.2', defaultRoute=None) 53 | h10 = net.addHost('h10', cls=Host, ip='10.2.0.3', defaultRoute=None) 54 | h11 = net.addHost('h11', cls=Host, ip='10.2.1.2', defaultRoute=None) 55 | h15 = net.addHost('h15', cls=Host, ip='10.3.1.2', defaultRoute=None) 56 | h12 = net.addHost('h12', cls=Host, ip='10.2.1.3', defaultRoute=None) 57 | h14 = net.addHost('h14', cls=Host, ip='10.3.0.3', defaultRoute=None) 58 | h13 = net.addHost('h13', cls=Host, ip='10.3.0.2', defaultRoute=None) 59 | h2 = net.addHost('h2', cls=Host, ip='10.0.0.3', defaultRoute=None) 60 | h16 = net.addHost('h16', cls=Host, ip='10.3.1.3', defaultRoute=None) 61 | h1 = net.addHost('h1', cls=Host, ip='10.0.0.2', defaultRoute=None) 62 | h3 = net.addHost('h3', cls=Host, ip='10.0.1.2', defaultRoute=None) 63 | h4 = net.addHost('h4', cls=Host, ip='10.0.1.3', defaultRoute=None) 64 | h5 = net.addHost('h5', cls=Host, ip='10.1.0.2', defaultRoute=None) 65 | 66 | info( '*** Add links\n') 67 | net.addLink(s1, h1) 68 | net.addLink(s1, h2) 69 | net.addLink(s2, h3) 70 | net.addLink(s2, h4) 71 | net.addLink(s3, h5) 72 | net.addLink(s3, h6) 73 | net.addLink(s4, h7) 74 | net.addLink(s4, h8) 75 | net.addLink(s5, h9) 76 | net.addLink(s5, h10) 77 | net.addLink(s6, h11) 78 | net.addLink(s6, h12) 79 | net.addLink(s7, h13) 80 | net.addLink(s7, h14) 81 | net.addLink(s8, h15) 82 | net.addLink(s8, h16) 83 | net.addLink(s9, s1) 84 | net.addLink(s9, s2) 85 | net.addLink(s1, s10) 86 | net.addLink(s10, s2) 87 | net.addLink(s11, s3) 88 | net.addLink(s3, s12) 89 | net.addLink(s11, s4) 90 | net.addLink(s12, s4) 91 | net.addLink(s13, s5) 92 | net.addLink(s14, s5) 93 | net.addLink(s13, s6) 94 | net.addLink(s14, s6) 95 | net.addLink(s15, s7) 96 | net.addLink(s15, s8) 97 | net.addLink(s16, s7) 98 | net.addLink(s16, s8) 99 | net.addLink(s17, s9) 100 | net.addLink(s9, s18) 101 | net.addLink(s11, s17) 102 | net.addLink(s11, s18) 103 | net.addLink(s13, s17) 104 | net.addLink(s15, s17) 105 | net.addLink(s10, s19) 106 | net.addLink(s10, s20) 107 | net.addLink(s12, s19) 108 | net.addLink(s12, s20) 109 | net.addLink(s14, s19) 110 | net.addLink(s14, s20) 111 | net.addLink(s15, s18) 112 | net.addLink(s16, s19) 113 | net.addLink(s16, s20) 114 | net.addLink(s18, s13) 115 | 116 | info( '*** Starting network\n') 117 | net.build() 118 | info( '*** Starting controllers\n') 119 | for controller in net.controllers: 120 | controller.start() 121 | 122 | info( '*** Starting switches\n') 123 | net.get('s15').start([c0]) 124 | net.get('s2').start([c0]) 125 | net.get('s17').start([c0]) 126 | net.get('s5').start([c0]) 127 | net.get('s18').start([c0]) 128 | net.get('s6').start([c0]) 129 | net.get('s7').start([c0]) 130 | net.get('s14').start([c0]) 131 | net.get('s20').start([c0]) 132 | net.get('s9').start([c0]) 133 | net.get('s8').start([c0]) 134 | net.get('s10').start([c0]) 135 | net.get('s4').start([c0]) 136 | net.get('s12').start([c0]) 137 | net.get('s13').start([c0]) 138 | net.get('s19').start([c0]) 139 | net.get('s16').start([c0]) 140 | net.get('s1').start([c0]) 141 | net.get('s3').start([c0]) 142 | net.get('s11').start([c0]) 143 | 144 | info( '*** Post configure switches and hosts\n') 145 | s15.cmd('ifconfig s15 10.3.2.1') 146 | s2.cmd('ifconfig s2 10.0.1.1') 147 | s17.cmd('ifconfig s17 10.4.1.1') 148 | s5.cmd('ifconfig s5 10.2.0.1') 149 | s18.cmd('ifconfig s18 10.4.1.2') 150 | s6.cmd('ifconfig s6 10.2.1.1') 151 | s7.cmd('ifconfig s7 10.3.0.1') 152 | s14.cmd('ifconfig s14 10.2.3.1') 153 | s20.cmd('ifconfig s20 10.4.2.2') 154 | s9.cmd('ifconfig s9 10.0.2.1') 155 | s8.cmd('ifconfig s8 10.3.1.1') 156 | s10.cmd('ifconfig s10 10.0.3.1') 157 | s4.cmd('ifconfig s4 10.1.1.1') 158 | s12.cmd('ifconfig s12 10.1.3.1') 159 | s13.cmd('ifconfig s13 10.2.2.1') 160 | s19.cmd('ifconfig s19 10.4.2.1') 161 | s16.cmd('ifconfig s16 10.3.3.1') 162 | s1.cmd('ifconfig s1 10.0.0.1') 163 | s3.cmd('ifconfig s3 10.1.0.1') 164 | s11.cmd('ifconfig s11 10.1.2.1') 165 | 166 | info('*** Enable spanning tree\n') 167 | 168 | #net.pingAll() 169 | 170 | CLI(net) 171 | net.stop() 172 | 173 | if __name__ == '__main__': 174 | setLogLevel( 'info' ) 175 | myNetwork() -------------------------------------------------------------------------------- /flowsetup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo ovs-ofctl add-flow s17 arp,in_port=1,actions=output:2 4 | sudo ovs-ofctl add-flow s17 arp,in_port=2,actions=output:1 5 | sudo ovs-ofctl add-flow s18 arp,in_port=3,actions=output:4 6 | sudo ovs-ofctl add-flow s18 arp,in_port=4,actions=output:3 7 | sudo ovs-ofctl add-flow s19 arp,in_port=1,actions=output:3 8 | sudo ovs-ofctl add-flow s19 arp,in_port=3,actions=output:1 9 | sudo ovs-ofctl add-flow s20 arp,in_port=2,actions=output:4 10 | sudo ovs-ofctl add-flow s20 arp,in_port=4,actions=output:2 11 | 12 | sudo ovs-ofctl add-flow s1 arp,in_port=1,actions=output:2,3,4 13 | sudo ovs-ofctl add-flow s1 arp,in_port=2,actions=output:1,3,4 14 | sudo ovs-ofctl add-flow s1 arp,in_port=3,actions=output:1,2,4 15 | sudo ovs-ofctl add-flow s1 arp,in_port=4,actions=output:1,2,3 16 | 17 | sudo ovs-ofctl add-flow s2 arp,in_port=1,actions=output:2,4 18 | sudo ovs-ofctl add-flow s2 arp,in_port=2,actions=output:1,4 19 | sudo ovs-ofctl add-flow s2 arp,in_port=4,actions=output:1,2 20 | 21 | sudo ovs-ofctl add-flow s3 arp,in_port=1,actions=output:2,3 22 | sudo ovs-ofctl add-flow s3 arp,in_port=2,actions=output:1,3 23 | sudo ovs-ofctl add-flow s3 arp,in_port=3,actions=output:1,2 24 | 25 | sudo ovs-ofctl add-flow s4 arp,in_port=1,actions=output:2,3,4 26 | sudo ovs-ofctl add-flow s4 arp,in_port=2,actions=output:1,3,4 27 | sudo ovs-ofctl add-flow s4 arp,in_port=3,actions=output:1,2,4 28 | sudo ovs-ofctl add-flow s4 arp,in_port=4,actions=output:1,2,3 29 | 30 | sudo ovs-ofctl add-flow s5 arp,in_port=1,actions=output:2,3,4 31 | sudo ovs-ofctl add-flow s5 arp,in_port=2,actions=output:1,3,4 32 | sudo ovs-ofctl add-flow s5 arp,in_port=3,actions=output:1,2,4 33 | sudo ovs-ofctl add-flow s5 arp,in_port=4,actions=output:1,2,3 34 | 35 | sudo ovs-ofctl add-flow s6 arp,in_port=1,actions=output:2,4 36 | sudo ovs-ofctl add-flow s6 arp,in_port=2,actions=output:1,4 37 | sudo ovs-ofctl add-flow s6 arp,in_port=4,actions=output:1,2 38 | 39 | sudo ovs-ofctl add-flow s7 arp,in_port=1,actions=output:2,3 40 | sudo ovs-ofctl add-flow s7 arp,in_port=2,actions=output:1,3 41 | sudo ovs-ofctl add-flow s7 arp,in_port=3,actions=output:1,2 42 | 43 | sudo ovs-ofctl add-flow s8 arp,in_port=1,actions=output:2,4 44 | sudo ovs-ofctl add-flow s8 arp,in_port=2,actions=output:1,4 45 | sudo ovs-ofctl add-flow s8 arp,in_port=4,actions=output:1,2 46 | 47 | sudo ovs-ofctl add-flow s9 arp,in_port=1,actions=output:3 48 | sudo ovs-ofctl add-flow s9 arp,in_port=3,actions=output:1 49 | 50 | sudo ovs-ofctl add-flow s10 arp,in_port=1,actions=output:2,3 51 | sudo ovs-ofctl add-flow s10 arp,in_port=2,actions=output:1,3 52 | sudo ovs-ofctl add-flow s10 arp,in_port=3,actions=output:1,2 53 | 54 | sudo ovs-ofctl add-flow s11 arp,in_port=1,actions=output:2,3 55 | sudo ovs-ofctl add-flow s11 arp,in_port=2,actions=output:1,3 56 | sudo ovs-ofctl add-flow s11 arp,in_port=3,actions=output:1,2 57 | 58 | sudo ovs-ofctl add-flow s12 arp,in_port=2,actions=output:4 59 | sudo ovs-ofctl add-flow s12 arp,in_port=4,actions=output:2 60 | 61 | sudo ovs-ofctl add-flow s13 arp,in_port=1,actions=output:4 62 | sudo ovs-ofctl add-flow s13 arp,in_port=4,actions=output:1 63 | 64 | sudo ovs-ofctl add-flow s14 arp,in_port=1,actions=output:2,3 65 | sudo ovs-ofctl add-flow s14 arp,in_port=2,actions=output:1,3 66 | sudo ovs-ofctl add-flow s14 arp,in_port=3,actions=output:1,2 67 | 68 | sudo ovs-ofctl add-flow s15 arp,in_port=1,actions=output:4 69 | sudo ovs-ofctl add-flow s15 arp,in_port=4,actions=output:1 70 | 71 | sudo ovs-ofctl add-flow s16 arp,in_port=2,actions=output:4 72 | sudo ovs-ofctl add-flow s16 arp,in_port=4,actions=output:2 73 | 74 | sudo ovs-ofctl add-flow s1 ip,nw_dst=10.0.0.2/32,actions=output:1 75 | sudo ovs-ofctl add-flow s1 ip,nw_dst=10.0.0.3/32,actions=output:2 76 | sudo ovs-ofctl add-flow s1 ip,nw_src=10.0.0.2/32,actions=output:3 77 | sudo ovs-ofctl add-flow s1 ip,nw_src=10.0.0.3/32,actions=output:4 78 | 79 | sudo ovs-ofctl add-flow s2 ip,nw_dst=10.0.1.2/32,actions=output:1 80 | sudo ovs-ofctl add-flow s2 ip,nw_dst=10.0.1.3/32,actions=output:2 81 | sudo ovs-ofctl add-flow s2 ip,nw_src=10.0.1.2/32,actions=output:4 82 | sudo ovs-ofctl add-flow s2 ip,nw_src=10.0.1.3/32,actions=output:3 83 | 84 | sudo ovs-ofctl add-flow s3 ip,nw_dst=10.1.0.2/32,actions=output:1 85 | sudo ovs-ofctl add-flow s3 ip,nw_dst=10.1.0.3/32,actions=output:2 86 | sudo ovs-ofctl add-flow s3 ip,nw_src=10.1.0.2/32,actions=output:3 87 | sudo ovs-ofctl add-flow s3 ip,nw_src=10.1.0.3/32,actions=output:4 88 | 89 | sudo ovs-ofctl add-flow s4 ip,nw_dst=10.1.1.2/32,actions=output:1 90 | sudo ovs-ofctl add-flow s4 ip,nw_dst=10.1.1.3/32,actions=output:2 91 | sudo ovs-ofctl add-flow s4 ip,nw_src=10.1.1.2/32,actions=output:4 92 | sudo ovs-ofctl add-flow s4 ip,nw_src=10.1.1.3/32,actions=output:3 93 | 94 | sudo ovs-ofctl add-flow s5 ip,nw_dst=10.2.0.2/32,actions=output:1 95 | sudo ovs-ofctl add-flow s5 ip,nw_dst=10.2.0.3/32,actions=output:2 96 | sudo ovs-ofctl add-flow s5 ip,nw_src=10.2.0.2/32,actions=output:3 97 | sudo ovs-ofctl add-flow s5 ip,nw_src=10.2.0.3/32,actions=output:4 98 | 99 | sudo ovs-ofctl add-flow s6 ip,nw_dst=10.2.1.2/32,actions=output:1 100 | sudo ovs-ofctl add-flow s6 ip,nw_dst=10.2.1.3/32,actions=output:2 101 | sudo ovs-ofctl add-flow s6 ip,nw_src=10.2.1.2/32,actions=output:4 102 | sudo ovs-ofctl add-flow s6 ip,nw_src=10.2.1.3/32,actions=output:3 103 | 104 | sudo ovs-ofctl add-flow s7 ip,nw_dst=10.3.0.2/32,actions=output:1 105 | sudo ovs-ofctl add-flow s7 ip,nw_dst=10.3.0.3/32,actions=output:2 106 | sudo ovs-ofctl add-flow s7 ip,nw_src=10.3.0.2/32,actions=output:3 107 | sudo ovs-ofctl add-flow s7 ip,nw_src=10.3.0.3/32,actions=output:4 108 | 109 | sudo ovs-ofctl add-flow s8 ip,nw_dst=10.3.1.2/32,actions=output:1 110 | sudo ovs-ofctl add-flow s8 ip,nw_dst=10.3.1.3/32,actions=output:2 111 | sudo ovs-ofctl add-flow s8 ip,nw_src=10.3.1.2/32,actions=output:4 112 | sudo ovs-ofctl add-flow s8 ip,nw_src=10.3.1.3/32,actions=output:3 113 | 114 | sudo ovs-ofctl add-flow s9 priority=900,ip,nw_dst=10.0.0.0/24,actions=output:1 115 | sudo ovs-ofctl add-flow s9 priority=900,ip,nw_dst=10.0.1.0/24,actions=output:2 116 | sudo ovs-ofctl add-flow s9 priority=800,ip,nw_src=10.0.0.0/24,actions=output:3 117 | sudo ovs-ofctl add-flow s9 priority=800,ip,nw_src=10.0.1.0/24,actions=output:4 118 | 119 | sudo ovs-ofctl add-flow s10 priority=900,ip,nw_dst=10.0.0.0/24,actions=output:1 120 | sudo ovs-ofctl add-flow s10 priority=900,ip,nw_dst=10.0.1.0/24,actions=output:2 121 | sudo ovs-ofctl add-flow s10 priority=800,ip,nw_src=10.0.0.0/24,actions=output:4 122 | sudo ovs-ofctl add-flow s10 priority=800,ip,nw_src=10.0.1.0/24,actions=output:3 123 | 124 | sudo ovs-ofctl add-flow s11 priority=900,ip,nw_dst=10.1.0.0/24,actions=output:1 125 | sudo ovs-ofctl add-flow s11 priority=900,ip,nw_dst=10.1.1.0/24,actions=output:2 126 | sudo ovs-ofctl add-flow s11 priority=800,ip,nw_src=10.1.0.0/24,actions=output:3 127 | sudo ovs-ofctl add-flow s11 priority=800,ip,nw_src=10.1.1.0/24,actions=output:4 128 | 129 | sudo ovs-ofctl add-flow s12 priority=900,ip,nw_dst=10.1.0.0/24,actions=output:1 130 | sudo ovs-ofctl add-flow s12 priority=900,ip,nw_dst=10.1.1.0/24,actions=output:2 131 | sudo ovs-ofctl add-flow s12 priority=800,ip,nw_src=10.1.0.0/24,actions=output:4 132 | sudo ovs-ofctl add-flow s12 priority=800,ip,nw_src=10.1.1.0/24,actions=output:3 133 | 134 | sudo ovs-ofctl add-flow s13 priority=900,ip,nw_dst=10.2.0.0/24,actions=output:1 135 | sudo ovs-ofctl add-flow s13 priority=900,ip,nw_dst=10.2.1.0/24,actions=output:2 136 | sudo ovs-ofctl add-flow s13 priority=800,ip,nw_src=10.2.0.0/24,actions=output:3 137 | sudo ovs-ofctl add-flow s13 priority=800,ip,nw_src=10.2.1.0/24,actions=output:4 138 | 139 | sudo ovs-ofctl add-flow s14 priority=900,ip,nw_dst=10.2.0.0/24,actions=output:1 140 | sudo ovs-ofctl add-flow s14 priority=900,ip,nw_dst=10.2.1.0/24,actions=output:2 141 | sudo ovs-ofctl add-flow s14 priority=800,ip,nw_src=10.2.0.0/24,actions=output:4 142 | sudo ovs-ofctl add-flow s14 priority=800,ip,nw_src=10.2.1.0/24,actions=output:3 143 | 144 | sudo ovs-ofctl add-flow s15 priority=900,ip,nw_dst=10.3.0.0/24,actions=output:1 145 | sudo ovs-ofctl add-flow s15 priority=900,ip,nw_dst=10.3.1.0/24,actions=output:2 146 | sudo ovs-ofctl add-flow s15 priority=800,ip,nw_src=10.3.0.0/24,actions=output:3 147 | sudo ovs-ofctl add-flow s15 priority=800,ip,nw_src=10.3.1.0/24,actions=output:4 148 | 149 | sudo ovs-ofctl add-flow s16 priority=900,ip,nw_dst=10.3.0.0/24,actions=output:1 150 | sudo ovs-ofctl add-flow s16 priority=900,ip,nw_dst=10.3.1.0/24,actions=output:2 151 | sudo ovs-ofctl add-flow s16 priority=800,ip,nw_src=10.3.0.0/24,actions=output:4 152 | sudo ovs-ofctl add-flow s16 priority=800,ip,nw_src=10.3.1.0/24,actions=output:3 153 | 154 | sudo ovs-ofctl add-flow s17 ip,nw_dst=10.0.0.0/16,actions=output:1 155 | sudo ovs-ofctl add-flow s17 ip,nw_dst=10.1.0.0/16,actions=output:2 156 | sudo ovs-ofctl add-flow s17 ip,nw_dst=10.2.0.0/16,actions=output:3 157 | sudo ovs-ofctl add-flow s17 ip,nw_dst=10.3.0.0/16,actions=output:4 158 | 159 | sudo ovs-ofctl add-flow s18 ip,nw_dst=10.0.0.0/16,actions=output:1 160 | sudo ovs-ofctl add-flow s18 ip,nw_dst=10.1.0.0/16,actions=output:2 161 | sudo ovs-ofctl add-flow s18 ip,nw_dst=10.2.0.0/16,actions=output:3 162 | sudo ovs-ofctl add-flow s18 ip,nw_dst=10.3.0.0/16,actions=output:4 163 | 164 | sudo ovs-ofctl add-flow s19 ip,nw_dst=10.0.0.0/16,actions=output:1 165 | sudo ovs-ofctl add-flow s19 ip,nw_dst=10.1.0.0/16,actions=output:2 166 | sudo ovs-ofctl add-flow s19 ip,nw_dst=10.2.0.0/16,actions=output:3 167 | sudo ovs-ofctl add-flow s19 ip,nw_dst=10.3.0.0/16,actions=output:4 168 | 169 | sudo ovs-ofctl add-flow s20 ip,nw_dst=10.0.0.0/16,actions=output:1 170 | sudo ovs-ofctl add-flow s20 ip,nw_dst=10.1.0.0/16,actions=output:2 171 | sudo ovs-ofctl add-flow s20 ip,nw_dst=10.2.0.0/16,actions=output:3 172 | sudo ovs-ofctl add-flow s20 ip,nw_dst=10.3.0.0/16,actions=output:4 -------------------------------------------------------------------------------- /analysis/result.csv: -------------------------------------------------------------------------------- 1 | 1,0,1.0,0 2 | 10,8,1.0,0 3 | 0,0,1.0,0 4 | 6,3,1.0,0 5 | 0,0,1.0,0 6 | 0,0,1.0,0 7 | 4,1,1.0,0 8 | 8,2,1.0,0 9 | 0,0,1.0,0 10 | 6,0,1.0,0 11 | 4,1,1.0,0 12 | 0,0,1.0,0 13 | 6,0,1.0,0 14 | 2,0,1.0,0 15 | 2,0,1.0,0 16 | 2,0,1.0,0 17 | 2,0,1.0,0 18 | 4,0,1.0,0 19 | 0,0,1.0,0 20 | 6,0,1.0,0 21 | 0,0,1.0,0 22 | 2,0,1.0,0 23 | 2,0,1.0,0 24 | 6,0,1.0,0 25 | 0,0,1.0,0 26 | 8,0,1.0,0 27 | 0,0,1.0,0 28 | 0,0,1.0,0 29 | 4,0,1.0,0 30 | 6,0,1.0,0 31 | 2,0,1.0,0 32 | 4,0,1.0,0 33 | 2,0,1.0,0 34 | 4,0,1.0,0 35 | 2,0,1.0,0 36 | 0,0,1.0,0 37 | 2,0,1.0,0 38 | 2,0,1.0,0 39 | 0,0,1.0,0 40 | 6,0,1.0,0 41 | 0,0,1.0,0 42 | 0,0,1.0,0 43 | 0,0,1.0,0 44 | 2,0,1.0,0 45 | 2,0,1.0,0 46 | 2,0,1.0,0 47 | 0,0,1.0,0 48 | 0,0,1.0,0 49 | 8,2,1.0,0 50 | 2,0,1.0,0 51 | 4,0,1.0,0 52 | 0,0,1.0,0 53 | 0,0,1.0,0 54 | 0,0,1.0,0 55 | 0,0,1.0,0 56 | 2,1,1.0,0 57 | 6,1,1.0,0 58 | 4,1,1.0,0 59 | 4,0,1.0,0 60 | 0,0,1.0,0 61 | 2,0,1.0,0 62 | 2,0,1.0,0 63 | 2,0,1.0,0 64 | 4,0,1.0,0 65 | 0,0,1.0,0 66 | 2,0,1.0,0 67 | 0,0,1.0,0 68 | 2,0,1.0,0 69 | 4,0,1.0,0 70 | 4,0,1.0,0 71 | 4,0,1.0,0 72 | 4,0,1.0,0 73 | 4,0,1.0,0 74 | 4,0,1.0,0 75 | 2,0,1.0,0 76 | 6,0,1.0,0 77 | 2,0,1.0,0 78 | 2,0,1.0,0 79 | 6,0,1.0,0 80 | 0,0,1.0,0 81 | 4,0,1.0,0 82 | 6,0,1.0,0 83 | 2,0,1.0,0 84 | 2,0,1.0,0 85 | 2,0,1.0,0 86 | 4,0,1.0,0 87 | 4,0,1.0,0 88 | 0,0,1.0,0 89 | 6,0,1.0,0 90 | 0,0,1.0,0 91 | 6,0,1.0,0 92 | 2,0,1.0,0 93 | 6,0,1.0,0 94 | 0,0,1.0,0 95 | 0,0,1.0,0 96 | 0,0,1.0,0 97 | 0,0,1.0,0 98 | 6,0,1.0,0 99 | 4,0,1.0,0 100 | 2,0,1.0,0 101 | 0,0,1.0,0 102 | 0,0,1.0,0 103 | 1,0,0.9961977186311787,0 104 | 1,0,1.0,0 105 | 0,0,1.0,0 106 | 0,0,1.0,0 107 | 2,0,1.0,0 108 | 0,0,1.0,0 109 | 0,0,1.0,0 110 | 0,0,1.0,0 111 | 2,0,1.0,0 112 | 0,0,1.0,0 113 | 0,0,1.0,0 114 | 0,0,1.0,0 115 | 0,0,1.0,0 116 | 2,0,1.0,0 117 | 0,0,1.0,0 118 | 0,0,1.0,0 119 | 0,0,1.0,0 120 | 0,0,1.0,0 121 | 0,0,1.0,0 122 | 0,0,1.0,0 123 | 0,0,1.0,0 124 | 0,0,1.0,0 125 | 0,0,1.0,0 126 | 0,0,1.0,0 127 | 0,0,1.0,0 128 | 0,0,1.0,0 129 | 0,0,1.0,0 130 | 0,0,1.0,0 131 | 0,0,1.0,0 132 | 0,0,1.0,0 133 | 0,0,1.0,0 134 | 0,0,1.0,0 135 | 0,0,1.0,0 136 | 0,0,1.0,0 137 | 0,0,1.0,0 138 | 0,0,1.0,0 139 | 0,0,1.0,0 140 | 0,0,1.0,0 141 | 0,0,1.0,0 142 | 0,0,1.0,0 143 | 0,0,1.0,0 144 | 0,0,1.0,0 145 | 0,0,1.0,0 146 | 0,0,1.0,0 147 | 0,0,1.0,0 148 | 0,0,1.0,0 149 | 0,0,1.0,0 150 | 0,0,1.0,0 151 | 0,0,1.0,0 152 | 0,0,1.0,0 153 | 0,0,1.0,0 154 | 0,0,1.0,0 155 | 0,0,1.0,0 156 | 0,0,1.0,0 157 | 0,0,1.0,0 158 | 0,0,1.0,0 159 | 0,0,1.0,0 160 | 0,0,1.0,0 161 | 0,0,1.0,0 162 | 0,0,1.0,0 163 | 0,0,1.0,0 164 | 0,0,1.0,0 165 | 0,0,1.0,0 166 | 0,0,1.0,0 167 | 0,0,1.0,0 168 | 0,0,1.0,0 169 | 0,0,1.0,0 170 | 0,0,1.0,0 171 | 0,0,1.0,0 172 | 0,0,1.0,0 173 | 0,0,1.0,0 174 | 0,0,1.0,0 175 | 0,0,1.0,0 176 | 0,0,1.0,0 177 | 0,0,1.0,0 178 | 0,0,1.0,0 179 | 0,0,1.0,0 180 | 0,0,1.0,0 181 | 0,0,1.0,0 182 | 0,0,1.0,0 183 | 0,0,1.0,0 184 | 0,0,1.0,0 185 | 0,0,1.0,0 186 | 0,0,1.0,0 187 | 0,0,1.0,0 188 | 0,0,1.0,0 189 | 0,0,1.0,0 190 | 0,0,1.0,0 191 | 0,0,1.0,0 192 | 0,0,1.0,0 193 | 0,0,1.0,0 194 | 0,0,1.0,0 195 | 0,0,1.0,0 196 | 43,42,0.0,1 197 | 65,65,0.0,1 198 | 64,64,0.0,1 199 | 65,65,0.0,1 200 | 64,64,0.0,1 201 | 64,64,0.0,1 202 | 65,65,0.0,1 203 | 64,64,0.0,1 204 | 65,65,0.0,1 205 | 64,64,0.0,1 206 | 65,65,0.0,1 207 | 64,64,0.0,1 208 | 65,65,0.0,1 209 | 26,26,0.0,1 210 | 56,56,0.0,1 211 | 55,55,0.0,1 212 | 56,56,0.0,1 213 | 56,56,0.0,1 214 | 55,55,0.0,1 215 | 56,56,0.0,1 216 | 55,55,0.0,1 217 | 56,56,0.0,1 218 | 56,56,0.0,1 219 | 55,55,0.0,1 220 | 56,56,0.0,1 221 | 55,55,0.0,1 222 | 56,56,0.0,1 223 | 55,55,0.0,1 224 | 56,56,0.0,1 225 | 56,56,0.0,1 226 | 56,56,0.0,1 227 | 35,35,0.0,1 228 | 41,41,0.0,1 229 | 48,48,0.0,1 230 | 49,49,0.0,1 231 | 49,49,0.0,1 232 | 49,49,0.0,1 233 | 49,49,0.0,1 234 | 48,48,0.0,1 235 | 49,49,0.0,1 236 | 49,49,0.0,1 237 | 49,49,0.0,1 238 | 49,49,0.0,1 239 | 49,49,0.0,1 240 | 48,48,0.0,1 241 | 49,49,0.0,1 242 | 49,49,0.0,1 243 | 49,49,0.0,1 244 | 49,49,0.0,1 245 | 49,49,0.0,1 246 | 49,49,0.0,1 247 | 49,49,0.0,1 248 | 31,31,0.0,1 249 | 37,37,0.0,1 250 | 43,43,0.0,1 251 | 44,44,0.0,1 252 | 43,43,0.0,1 253 | 44,44,0.0,1 254 | 43,43,0.0,1 255 | 44,44,0.0,1 256 | 44,44,0.0,1 257 | 43,43,0.0,1 258 | 44,44,0.0,1 259 | 43,43,0.0,1 260 | 28,28,0.0,1 261 | 33,33,0.0,1 262 | 40,40,0.0,1 263 | 39,39,0.0,1 264 | 39,39,0.0,1 265 | 39,39,0.0,1 266 | 40,40,0.0,1 267 | 39,39,0.0,1 268 | 39,39,0.0,1 269 | 39,39,0.0,1 270 | 40,40,0.0,1 271 | 39,39,0.0,1 272 | 39,39,0.0,1 273 | 35,35,0.0,1 274 | 24,24,0.0,1 275 | 40,40,0.0,1 276 | 39,39,0.0,1 277 | 39,39,0.0,1 278 | 40,40,0.0,1 279 | 39,39,0.0,1 280 | 39,39,0.0,1 281 | 39,39,0.0,1 282 | 40,40,0.0,1 283 | 39,39,0.0,1 284 | 39,39,0.0,1 285 | 40,40,0.0,1 286 | 39,39,0.0,1 287 | 72,72,0.0004554771122751082,1 288 | 185,185,0.00043706293706293706,1 289 | 185,185,0.0004200798151648813,1 290 | 185,185,0.0004043671653861706,1 291 | 163,163,0.00039146604032100216,1 292 | 176,176,0.0003784295175023652,1 293 | 80,80,0.0003727865796831314,1 294 | 121,121,0.0003645643456069996,1 295 | 83,83,0.0003591309032142216,1 296 | 64,64,0.0003550505947097461,1 297 | 130,130,0.00034704147145583897,1 298 | 140,140,0.000338810774182619,1 299 | 148,148,0.0003305238803503553,1 300 | 155,155,0.0003222687721559781,1 301 | 119,119,0.00031620553359683795,1 302 | 106,106,0.00031099362463069506,1 303 | 129,129,0.0003048780487804878,1 304 | 154,154,0.0002978850163836759,1 305 | 147,147,0.0002915026963999417,1 306 | 149,149,0.0002853067047075606,1 307 | 137,137,0.0002798376941374003,1 308 | 148,148,0.00027416038382453733,1 309 | 84,84,0.0002710394362379726,1 310 | 126,126,0.0002664890073284477,1 311 | 122,122,0.0002622263012980202,1 312 | 140,140,0.00025749967812540236,1 313 | 142,142,0.00025287646984448094,1 314 | 136,136,0.0002486016159105034,1 315 | 131,131,0.0002446183953033268,1 316 | 87,87,0.00024204284158296018,1 317 | 51,51,0.00024055809477988935,1 318 | 34,34,0.00023957834211787255,1 319 | 74,74,0.00023747328425552126,1 320 | 122,122,0.00023408239700374532,1 321 | 122,122,0.00023078698361412417,1 322 | 121,121,0.00022760896779333106,1 323 | 141,141,0.00022401433691756272,1 324 | 133,133,0.0002207261891623441,1 325 | 135,135,0.00021748586341887777,1 326 | 92,92,0.0002153316106804479,1 327 | 37,37,0.00021447721179624664,1 328 | 87,87,0.00021249468763280918,1 329 | 34,34,0.00021172983273343214,1 330 | 55,55,0.00021050415745710977,1 331 | 75,75,0.00020885547201336674,1 332 | 56,56,0.00020764119601328904,1 333 | 83,83,0.0002058672156459084,1 334 | 120,120,0.00020335536349771224,1 335 | 126,126,0.00020078305391024997,1 336 | 125,125,0.000198294665873488,1 337 | 127,127,0.00019582884558895524,1 338 | 112,112,0.0001937046004842615,1 339 | 80,80,0.00019221528111484863,1 340 | 23,23,0.00019179133103183735,1 341 | 98,98,0.00019000570017100514,1 342 | 14,14,0.00018975332068311195,1 343 | 120,120,0.0001876172607879925,1 344 | 117,117,0.0001855804027094739,1 345 | 49,49,0.00018474043968224645,1 346 | 76,76,0.000183452577508714,1 347 | 49,49,0.00018263172313030774,1 348 | 47,47,0.0001818512456810329,1 349 | 31,31,0.00018134010336385892,1 350 | 78,78,0.00018006662465112092,1 351 | 31,31,0.0001795654516071108,1 352 | 66,66,0.0001785076758300607,1 353 | 47,47,0.00017776197671318106,1 354 | 41,41,0.00017711654268508679,1 355 | 54,54,0.00017627357659086903,1 356 | 61,61,0.00017533093714385903,1 357 | 32,32,0.00017484045808200017,1 358 | 15,15,0.00017461148943600488,1 359 | 21,21,0.00017429193899782134,1 360 | 2,2,0.00017426156661148382,1 361 | 13,13,0.00017406440382941688,1 362 | 14,14,0.00017385257301808066,1 363 | 13,13,0.00017365633411478684,1 364 | 11,11,0.00017349063150589867,1 365 | 21,21,0.00017317516668109793,1 366 | 13,13,0.0001729804532087874,1 367 | 3,2,1.0,0 368 | 4,3,1.0,0 369 | 0,0,1.0,0 370 | 4,3,1.0,0 371 | 2,0,1.0,0 372 | 4,2,1.0,0 373 | 6,1,1.0,0 374 | 4,0,1.0,0 375 | 4,0,1.0,0 376 | 2,0,1.0,0 377 | 4,1,1.0,0 378 | 0,0,1.0,0 379 | 0,0,1.0,0 380 | 4,0,1.0,0 381 | 2,0,1.0,0 382 | 2,0,1.0,0 383 | 2,0,1.0,0 384 | 4,0,1.0,0 385 | 0,0,1.0,0 386 | 4,0,1.0,0 387 | 4,0,1.0,0 388 | 2,0,1.0,0 389 | 4,0,1.0,0 390 | 2,0,1.0,0 391 | 2,0,1.0,0 392 | 0,0,1.0,0 393 | 2,0,1.0,0 394 | 0,0,1.0,0 395 | 2,0,1.0,0 396 | 4,0,1.0,0 397 | 2,0,1.0,0 398 | 0,0,1.0,0 399 | 2,0,1.0,0 400 | 4,0,1.0,0 401 | 4,0,1.0,0 402 | 2,0,1.0,0 403 | 2,1,1.0,0 404 | 0,0,1.0,0 405 | 0,0,1.0,0 406 | 0,0,1.0,0 407 | 0,0,1.0,0 408 | 2,1,1.0,0 409 | 0,0,1.0,0 410 | 2,0,1.0,0 411 | 2,1,1.0,0 412 | 4,0,1.0,0 413 | 2,0,1.0,0 414 | 0,0,1.0,0 415 | 4,0,1.0,0 416 | 2,0,1.0,0 417 | 2,0,1.0,0 418 | 2,1,1.0,0 419 | 2,1,1.0,0 420 | 4,0,1.0,0 421 | 2,0,1.0,0 422 | 0,0,1.0,0 423 | 2,0,1.0,0 424 | 2,0,1.0,0 425 | 0,0,1.0,0 426 | 2,0,1.0,0 427 | 2,1,1.0,0 428 | 6,0,1.0,0 429 | 2,0,1.0,0 430 | 2,0,1.0,0 431 | 2,0,1.0,0 432 | 6,1,1.0,0 433 | 0,0,1.0,0 434 | 2,1,1.0,0 435 | 2,0,1.0,0 436 | 0,0,1.0,0 437 | 2,0,1.0,0 438 | 8,0,1.0,0 439 | 4,0,1.0,0 440 | 2,0,1.0,0 441 | 4,0,1.0,0 442 | 2,0,1.0,0 443 | 2,0,1.0,0 444 | 8,0,1.0,0 445 | 0,0,1.0,0 446 | 2,0,1.0,0 447 | 0,0,1.0,0 448 | 10,0,1.0,0 449 | 4,0,1.0,0 450 | 4,0,1.0,0 451 | 4,0,1.0,0 452 | 2,0,1.0,0 453 | 2,0,1.0,0 454 | 2,0,1.0,0 455 | 4,0,1.0,0 456 | 0,0,1.0,0 457 | 2,0,1.0,0 458 | 8,0,1.0,0 459 | 4,0,1.0,0 460 | 2,0,1.0,0 461 | 2,0,1.0,0 462 | 4,0,1.0,0 463 | 4,0,1.0,0 464 | 0,0,1.0,0 465 | 2,0,1.0,0 466 | 0,0,1.0,0 467 | 4,0,1.0,0 468 | 2,0,1.0,0 469 | 0,0,1.0,0 470 | 2,0,1.0,0 471 | 2,0,1.0,0 472 | 0,0,1.0,0 473 | 2,0,1.0,0 474 | 0,0,1.0,0 475 | 0,0,1.0,0 476 | 2,0,1.0,0 477 | 0,0,1.0,0 478 | 2,0,1.0,0 479 | 0,0,1.0,0 480 | 2,0,1.0,0 481 | 2,0,1.0,0 482 | 0,0,1.0,0 483 | 2,0,1.0,0 484 | 0,0,1.0,0 485 | 0,0,1.0,0 486 | 2,0,1.0,0 487 | 0,0,1.0,0 488 | 0,0,1.0,0 489 | 0,0,1.0,0 490 | 0,0,1.0,0 491 | 0,0,1.0,0 492 | 0,0,1.0,0 493 | 0,0,1.0,0 494 | 0,0,1.0,0 495 | 0,0,1.0,0 496 | 0,0,1.0,0 497 | 0,0,1.0,0 498 | 0,0,1.0,0 499 | 0,0,1.0,0 500 | 0,0,1.0,0 501 | 0,0,1.0,0 502 | 0,0,1.0,0 503 | 0,0,1.0,0 504 | 0,0,1.0,0 505 | 0,0,1.0,0 506 | 0,0,1.0,0 507 | 0,0,1.0,0 508 | 0,0,1.0,0 509 | 0,0,1.0,0 510 | 0,0,1.0,0 511 | 0,0,1.0,0 512 | 0,0,1.0,0 513 | 0,0,1.0,0 514 | 0,0,1.0,0 515 | 0,0,1.0,0 516 | 0,0,1.0,0 517 | 0,0,1.0,0 518 | 0,0,1.0,0 519 | 0,0,1.0,0 520 | 0,0,1.0,0 521 | 0,0,1.0,0 522 | 0,0,1.0,0 523 | 0,0,1.0,0 524 | 0,0,1.0,0 525 | 0,0,1.0,0 526 | 0,0,1.0,0 527 | 0,0,1.0,0 528 | 0,0,1.0,0 529 | 0,0,1.0,0 530 | 0,0,1.0,0 531 | 0,0,1.0,0 532 | 0,0,1.0,0 533 | 0,0,1.0,0 534 | 0,0,1.0,0 535 | 0,0,1.0,0 536 | 0,0,1.0,0 537 | 0,0,1.0,0 538 | 0,0,1.0,0 539 | 0,0,1.0,0 540 | 0,0,1.0,0 541 | 0,0,1.0,0 542 | 0,0,1.0,0 543 | 0,0,1.0,0 544 | 0,0,1.0,0 545 | -------------------------------------------------------------------------------- /result.csv: -------------------------------------------------------------------------------- 1 | 1,0,1.0,0 2 | 10,8,1.0,0 3 | 0,0,1.0,0 4 | 6,3,1.0,0 5 | 0,0,1.0,0 6 | 0,0,1.0,0 7 | 4,1,1.0,0 8 | 8,2,1.0,0 9 | 0,0,1.0,0 10 | 6,0,1.0,0 11 | 4,1,1.0,0 12 | 0,0,1.0,0 13 | 6,0,1.0,0 14 | 2,0,1.0,0 15 | 2,0,1.0,0 16 | 2,0,1.0,0 17 | 2,0,1.0,0 18 | 4,0,1.0,0 19 | 0,0,1.0,0 20 | 6,0,1.0,0 21 | 0,0,1.0,0 22 | 2,0,1.0,0 23 | 2,0,1.0,0 24 | 6,0,1.0,0 25 | 0,0,1.0,0 26 | 8,0,1.0,0 27 | 0,0,1.0,0 28 | 0,0,1.0,0 29 | 4,0,1.0,0 30 | 6,0,1.0,0 31 | 2,0,1.0,0 32 | 4,0,1.0,0 33 | 2,0,1.0,0 34 | 4,0,1.0,0 35 | 2,0,1.0,0 36 | 0,0,1.0,0 37 | 2,0,1.0,0 38 | 2,0,1.0,0 39 | 0,0,1.0,0 40 | 6,0,1.0,0 41 | 0,0,1.0,0 42 | 0,0,1.0,0 43 | 0,0,1.0,0 44 | 2,0,1.0,0 45 | 2,0,1.0,0 46 | 2,0,1.0,0 47 | 0,0,1.0,0 48 | 0,0,1.0,0 49 | 8,2,1.0,0 50 | 2,0,1.0,0 51 | 4,0,1.0,0 52 | 0,0,1.0,0 53 | 0,0,1.0,0 54 | 0,0,1.0,0 55 | 0,0,1.0,0 56 | 2,1,1.0,0 57 | 6,1,1.0,0 58 | 4,1,1.0,0 59 | 4,0,1.0,0 60 | 0,0,1.0,0 61 | 2,0,1.0,0 62 | 2,0,1.0,0 63 | 2,0,1.0,0 64 | 4,0,1.0,0 65 | 0,0,1.0,0 66 | 2,0,1.0,0 67 | 0,0,1.0,0 68 | 2,0,1.0,0 69 | 4,0,1.0,0 70 | 4,0,1.0,0 71 | 4,0,1.0,0 72 | 4,0,1.0,0 73 | 4,0,1.0,0 74 | 4,0,1.0,0 75 | 2,0,1.0,0 76 | 6,0,1.0,0 77 | 2,0,1.0,0 78 | 2,0,1.0,0 79 | 6,0,1.0,0 80 | 0,0,1.0,0 81 | 4,0,1.0,0 82 | 6,0,1.0,0 83 | 2,0,1.0,0 84 | 2,0,1.0,0 85 | 2,0,1.0,0 86 | 4,0,1.0,0 87 | 4,0,1.0,0 88 | 0,0,1.0,0 89 | 6,0,1.0,0 90 | 0,0,1.0,0 91 | 6,0,1.0,0 92 | 2,0,1.0,0 93 | 6,0,1.0,0 94 | 0,0,1.0,0 95 | 0,0,1.0,0 96 | 0,0,1.0,0 97 | 0,0,1.0,0 98 | 6,0,1.0,0 99 | 4,0,1.0,0 100 | 2,0,1.0,0 101 | 0,0,1.0,0 102 | 0,0,1.0,0 103 | 1,0,0.9961977186311787,0 104 | 1,0,1.0,0 105 | 0,0,1.0,0 106 | 0,0,1.0,0 107 | 2,0,1.0,0 108 | 0,0,1.0,0 109 | 0,0,1.0,0 110 | 0,0,1.0,0 111 | 2,0,1.0,0 112 | 0,0,1.0,0 113 | 0,0,1.0,0 114 | 0,0,1.0,0 115 | 0,0,1.0,0 116 | 2,0,1.0,0 117 | 0,0,1.0,0 118 | 0,0,1.0,0 119 | 0,0,1.0,0 120 | 0,0,1.0,0 121 | 0,0,1.0,0 122 | 0,0,1.0,0 123 | 0,0,1.0,0 124 | 0,0,1.0,0 125 | 0,0,1.0,0 126 | 0,0,1.0,0 127 | 0,0,1.0,0 128 | 0,0,1.0,0 129 | 0,0,1.0,0 130 | 0,0,1.0,0 131 | 0,0,1.0,0 132 | 0,0,1.0,0 133 | 0,0,1.0,0 134 | 0,0,1.0,0 135 | 0,0,1.0,0 136 | 0,0,1.0,0 137 | 0,0,1.0,0 138 | 0,0,1.0,0 139 | 0,0,1.0,0 140 | 0,0,1.0,0 141 | 0,0,1.0,0 142 | 0,0,1.0,0 143 | 0,0,1.0,0 144 | 0,0,1.0,0 145 | 0,0,1.0,0 146 | 0,0,1.0,0 147 | 0,0,1.0,0 148 | 0,0,1.0,0 149 | 0,0,1.0,0 150 | 0,0,1.0,0 151 | 0,0,1.0,0 152 | 0,0,1.0,0 153 | 0,0,1.0,0 154 | 0,0,1.0,0 155 | 0,0,1.0,0 156 | 0,0,1.0,0 157 | 0,0,1.0,0 158 | 0,0,1.0,0 159 | 0,0,1.0,0 160 | 0,0,1.0,0 161 | 0,0,1.0,0 162 | 0,0,1.0,0 163 | 0,0,1.0,0 164 | 0,0,1.0,0 165 | 0,0,1.0,0 166 | 0,0,1.0,0 167 | 0,0,1.0,0 168 | 0,0,1.0,0 169 | 0,0,1.0,0 170 | 0,0,1.0,0 171 | 0,0,1.0,0 172 | 0,0,1.0,0 173 | 0,0,1.0,0 174 | 0,0,1.0,0 175 | 0,0,1.0,0 176 | 0,0,1.0,0 177 | 0,0,1.0,0 178 | 0,0,1.0,0 179 | 0,0,1.0,0 180 | 0,0,1.0,0 181 | 0,0,1.0,0 182 | 0,0,1.0,0 183 | 0,0,1.0,0 184 | 0,0,1.0,0 185 | 0,0,1.0,0 186 | 0,0,1.0,0 187 | 0,0,1.0,0 188 | 0,0,1.0,0 189 | 0,0,1.0,0 190 | 0,0,1.0,0 191 | 0,0,1.0,0 192 | 0,0,1.0,0 193 | 0,0,1.0,0 194 | 0,0,1.0,0 195 | 0,0,1.0,0 196 | 43,42,0.0,1 197 | 65,65,0.0,1 198 | 64,64,0.0,1 199 | 65,65,0.0,1 200 | 64,64,0.0,1 201 | 64,64,0.0,1 202 | 65,65,0.0,1 203 | 64,64,0.0,1 204 | 65,65,0.0,1 205 | 64,64,0.0,1 206 | 65,65,0.0,1 207 | 64,64,0.0,1 208 | 65,65,0.0,1 209 | 26,26,0.0,1 210 | 56,56,0.0,1 211 | 55,55,0.0,1 212 | 56,56,0.0,1 213 | 56,56,0.0,1 214 | 55,55,0.0,1 215 | 56,56,0.0,1 216 | 55,55,0.0,1 217 | 56,56,0.0,1 218 | 56,56,0.0,1 219 | 55,55,0.0,1 220 | 56,56,0.0,1 221 | 55,55,0.0,1 222 | 56,56,0.0,1 223 | 55,55,0.0,1 224 | 56,56,0.0,1 225 | 56,56,0.0,1 226 | 56,56,0.0,1 227 | 35,35,0.0,1 228 | 41,41,0.0,1 229 | 48,48,0.0,1 230 | 49,49,0.0,1 231 | 49,49,0.0,1 232 | 49,49,0.0,1 233 | 49,49,0.0,1 234 | 48,48,0.0,1 235 | 49,49,0.0,1 236 | 49,49,0.0,1 237 | 49,49,0.0,1 238 | 49,49,0.0,1 239 | 49,49,0.0,1 240 | 48,48,0.0,1 241 | 49,49,0.0,1 242 | 49,49,0.0,1 243 | 49,49,0.0,1 244 | 49,49,0.0,1 245 | 49,49,0.0,1 246 | 49,49,0.0,1 247 | 49,49,0.0,1 248 | 31,31,0.0,1 249 | 37,37,0.0,1 250 | 43,43,0.0,1 251 | 44,44,0.0,1 252 | 43,43,0.0,1 253 | 44,44,0.0,1 254 | 43,43,0.0,1 255 | 44,44,0.0,1 256 | 44,44,0.0,1 257 | 43,43,0.0,1 258 | 44,44,0.0,1 259 | 43,43,0.0,1 260 | 28,28,0.0,1 261 | 33,33,0.0,1 262 | 40,40,0.0,1 263 | 39,39,0.0,1 264 | 39,39,0.0,1 265 | 39,39,0.0,1 266 | 40,40,0.0,1 267 | 39,39,0.0,1 268 | 39,39,0.0,1 269 | 39,39,0.0,1 270 | 40,40,0.0,1 271 | 39,39,0.0,1 272 | 39,39,0.0,1 273 | 35,35,0.0,1 274 | 24,24,0.0,1 275 | 40,40,0.0,1 276 | 39,39,0.0,1 277 | 39,39,0.0,1 278 | 40,40,0.0,1 279 | 39,39,0.0,1 280 | 39,39,0.0,1 281 | 39,39,0.0,1 282 | 40,40,0.0,1 283 | 39,39,0.0,1 284 | 39,39,0.0,1 285 | 40,40,0.0,1 286 | 39,39,0.0,1 287 | 72,72,0.0004554771122751082,1 288 | 185,185,0.00043706293706293706,1 289 | 185,185,0.0004200798151648813,1 290 | 185,185,0.0004043671653861706,1 291 | 163,163,0.00039146604032100216,1 292 | 176,176,0.0003784295175023652,1 293 | 80,80,0.0003727865796831314,1 294 | 121,121,0.0003645643456069996,1 295 | 83,83,0.0003591309032142216,1 296 | 64,64,0.0003550505947097461,1 297 | 130,130,0.00034704147145583897,1 298 | 140,140,0.000338810774182619,1 299 | 148,148,0.0003305238803503553,1 300 | 155,155,0.0003222687721559781,1 301 | 119,119,0.00031620553359683795,1 302 | 106,106,0.00031099362463069506,1 303 | 129,129,0.0003048780487804878,1 304 | 154,154,0.0002978850163836759,1 305 | 147,147,0.0002915026963999417,1 306 | 149,149,0.0002853067047075606,1 307 | 137,137,0.0002798376941374003,1 308 | 148,148,0.00027416038382453733,1 309 | 84,84,0.0002710394362379726,1 310 | 126,126,0.0002664890073284477,1 311 | 122,122,0.0002622263012980202,1 312 | 140,140,0.00025749967812540236,1 313 | 142,142,0.00025287646984448094,1 314 | 136,136,0.0002486016159105034,1 315 | 131,131,0.0002446183953033268,1 316 | 87,87,0.00024204284158296018,1 317 | 51,51,0.00024055809477988935,1 318 | 34,34,0.00023957834211787255,1 319 | 74,74,0.00023747328425552126,1 320 | 122,122,0.00023408239700374532,1 321 | 122,122,0.00023078698361412417,1 322 | 121,121,0.00022760896779333106,1 323 | 141,141,0.00022401433691756272,1 324 | 133,133,0.0002207261891623441,1 325 | 135,135,0.00021748586341887777,1 326 | 92,92,0.0002153316106804479,1 327 | 37,37,0.00021447721179624664,1 328 | 87,87,0.00021249468763280918,1 329 | 34,34,0.00021172983273343214,1 330 | 55,55,0.00021050415745710977,1 331 | 75,75,0.00020885547201336674,1 332 | 56,56,0.00020764119601328904,1 333 | 83,83,0.0002058672156459084,1 334 | 120,120,0.00020335536349771224,1 335 | 126,126,0.00020078305391024997,1 336 | 125,125,0.000198294665873488,1 337 | 127,127,0.00019582884558895524,1 338 | 112,112,0.0001937046004842615,1 339 | 80,80,0.00019221528111484863,1 340 | 23,23,0.00019179133103183735,1 341 | 98,98,0.00019000570017100514,1 342 | 14,14,0.00018975332068311195,1 343 | 120,120,0.0001876172607879925,1 344 | 117,117,0.0001855804027094739,1 345 | 49,49,0.00018474043968224645,1 346 | 76,76,0.000183452577508714,1 347 | 49,49,0.00018263172313030774,1 348 | 47,47,0.0001818512456810329,1 349 | 31,31,0.00018134010336385892,1 350 | 78,78,0.00018006662465112092,1 351 | 31,31,0.0001795654516071108,1 352 | 66,66,0.0001785076758300607,1 353 | 47,47,0.00017776197671318106,1 354 | 41,41,0.00017711654268508679,1 355 | 54,54,0.00017627357659086903,1 356 | 61,61,0.00017533093714385903,1 357 | 32,32,0.00017484045808200017,1 358 | 15,15,0.00017461148943600488,1 359 | 21,21,0.00017429193899782134,1 360 | 2,2,0.00017426156661148382,1 361 | 13,13,0.00017406440382941688,1 362 | 14,14,0.00017385257301808066,1 363 | 13,13,0.00017365633411478684,1 364 | 11,11,0.00017349063150589867,1 365 | 21,21,0.00017317516668109793,1 366 | 13,13,0.0001729804532087874,1 367 | 3,2,1.0,0 368 | 4,3,1.0,0 369 | 0,0,1.0,0 370 | 4,3,1.0,0 371 | 2,0,1.0,0 372 | 4,2,1.0,0 373 | 6,1,1.0,0 374 | 4,0,1.0,0 375 | 4,0,1.0,0 376 | 2,0,1.0,0 377 | 4,1,1.0,0 378 | 0,0,1.0,0 379 | 0,0,1.0,0 380 | 4,0,1.0,0 381 | 2,0,1.0,0 382 | 2,0,1.0,0 383 | 2,0,1.0,0 384 | 4,0,1.0,0 385 | 0,0,1.0,0 386 | 4,0,1.0,0 387 | 4,0,1.0,0 388 | 2,0,1.0,0 389 | 4,0,1.0,0 390 | 2,0,1.0,0 391 | 2,0,1.0,0 392 | 0,0,1.0,0 393 | 2,0,1.0,0 394 | 0,0,1.0,0 395 | 2,0,1.0,0 396 | 4,0,1.0,0 397 | 2,0,1.0,0 398 | 0,0,1.0,0 399 | 2,0,1.0,0 400 | 4,0,1.0,0 401 | 4,0,1.0,0 402 | 2,0,1.0,0 403 | 2,1,1.0,0 404 | 0,0,1.0,0 405 | 0,0,1.0,0 406 | 0,0,1.0,0 407 | 0,0,1.0,0 408 | 2,1,1.0,0 409 | 0,0,1.0,0 410 | 2,0,1.0,0 411 | 2,1,1.0,0 412 | 4,0,1.0,0 413 | 2,0,1.0,0 414 | 0,0,1.0,0 415 | 4,0,1.0,0 416 | 2,0,1.0,0 417 | 2,0,1.0,0 418 | 2,1,1.0,0 419 | 2,1,1.0,0 420 | 4,0,1.0,0 421 | 2,0,1.0,0 422 | 0,0,1.0,0 423 | 2,0,1.0,0 424 | 2,0,1.0,0 425 | 0,0,1.0,0 426 | 2,0,1.0,0 427 | 2,1,1.0,0 428 | 6,0,1.0,0 429 | 2,0,1.0,0 430 | 2,0,1.0,0 431 | 2,0,1.0,0 432 | 6,1,1.0,0 433 | 0,0,1.0,0 434 | 2,1,1.0,0 435 | 2,0,1.0,0 436 | 0,0,1.0,0 437 | 2,0,1.0,0 438 | 8,0,1.0,0 439 | 4,0,1.0,0 440 | 2,0,1.0,0 441 | 4,0,1.0,0 442 | 2,0,1.0,0 443 | 2,0,1.0,0 444 | 8,0,1.0,0 445 | 0,0,1.0,0 446 | 2,0,1.0,0 447 | 0,0,1.0,0 448 | 10,0,1.0,0 449 | 4,0,1.0,0 450 | 4,0,1.0,0 451 | 4,0,1.0,0 452 | 2,0,1.0,0 453 | 2,0,1.0,0 454 | 2,0,1.0,0 455 | 4,0,1.0,0 456 | 0,0,1.0,0 457 | 2,0,1.0,0 458 | 8,0,1.0,0 459 | 4,0,1.0,0 460 | 2,0,1.0,0 461 | 2,0,1.0,0 462 | 4,0,1.0,0 463 | 4,0,1.0,0 464 | 0,0,1.0,0 465 | 2,0,1.0,0 466 | 0,0,1.0,0 467 | 4,0,1.0,0 468 | 2,0,1.0,0 469 | 0,0,1.0,0 470 | 2,0,1.0,0 471 | 2,0,1.0,0 472 | 0,0,1.0,0 473 | 2,0,1.0,0 474 | 0,0,1.0,0 475 | 0,0,1.0,0 476 | 2,0,1.0,0 477 | 0,0,1.0,0 478 | 2,0,1.0,0 479 | 0,0,1.0,0 480 | 2,0,1.0,0 481 | 2,0,1.0,0 482 | 0,0,1.0,0 483 | 2,0,1.0,0 484 | 0,0,1.0,0 485 | 0,0,1.0,0 486 | 2,0,1.0,0 487 | 0,0,1.0,0 488 | 0,0,1.0,0 489 | 0,0,1.0,0 490 | 0,0,1.0,0 491 | 0,0,1.0,0 492 | 0,0,1.0,0 493 | 0,0,1.0,0 494 | 0,0,1.0,0 495 | 0,0,1.0,0 496 | 0,0,1.0,0 497 | 0,0,1.0,0 498 | 0,0,1.0,0 499 | 0,0,1.0,0 500 | 0,0,1.0,0 501 | 0,0,1.0,0 502 | 0,0,1.0,0 503 | 0,0,1.0,0 504 | 0,0,1.0,0 505 | 0,0,1.0,0 506 | 0,0,1.0,0 507 | 0,0,1.0,0 508 | 0,0,1.0,0 509 | 0,0,1.0,0 510 | 0,0,1.0,0 511 | 0,0,1.0,0 512 | 0,0,1.0,0 513 | 0,0,1.0,0 514 | 0,0,1.0,0 515 | 0,0,1.0,0 516 | 0,0,1.0,0 517 | 0,0,1.0,0 518 | 0,0,1.0,0 519 | 0,0,1.0,0 520 | 0,0,1.0,0 521 | 0,0,1.0,0 522 | 0,0,1.0,0 523 | 0,0,1.0,0 524 | 0,0,1.0,0 525 | 0,0,1.0,0 526 | 0,0,1.0,0 527 | 0,0,1.0,0 528 | 0,0,1.0,0 529 | 0,0,1.0,0 530 | 0,0,1.0,0 531 | 0,0,1.0,0 532 | 0,0,1.0,0 533 | 0,0,1.0,0 534 | 0,0,1.0,0 535 | 0,0,1.0,0 536 | 0,0,1.0,0 537 | 0,0,1.0,0 538 | 0,0,1.0,0 539 | 0,0,1.0,0 540 | 0,0,1.0,0 541 | 0,0,1.0,0 542 | 0,0,1.0,0 543 | 0,0,1.0,0 544 | 0,0,1.0,0 545 | 3,2,1.0,0 546 | 0,0,1.0,0 547 | 0,0,1.0,0 548 | 0,0,1.0,0 549 | 0,0,1.0,0 550 | 0,0,1.0,0 551 | 0,0,1.0,0 552 | 0,0,1.0,0 553 | 0,0,1.0,0 554 | 0,0,1.0,0 555 | 0,0,1.0,0 556 | 0,0,1.0,0 557 | 0,0,1.0,0 558 | 0,0,1.0,0 559 | 0,0,1.0,0 560 | 0,0,1.0,0 561 | 0,0,1.0,0 562 | 0,0,1.0,0 563 | 0,0,1.0,0 564 | 0,0,1.0,0 565 | -------------------------------------------------------------------------------- /controllerfinal.py: -------------------------------------------------------------------------------- 1 | from ryu.base import app_manager 2 | from ryu.controller import ofp_event 3 | from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER 4 | from ryu.controller.handler import set_ev_cls 5 | from ryu.ofproto import ofproto_v1_3 6 | from ryu.lib.packet import packet 7 | from ryu.lib.packet import ethernet 8 | from ryu.lib.packet import ether_types 9 | 10 | from ryu.lib.packet import in_proto 11 | from ryu.lib.packet import ipv4 12 | from ryu.lib.packet import icmp 13 | from ryu.lib.packet import tcp 14 | from ryu.lib.packet import udp 15 | from ryu.lib.packet import arp 16 | 17 | from ryu.lib import hub 18 | import csv 19 | import time 20 | import math 21 | import statistics 22 | 23 | from svm import SVM 24 | 25 | detect = 1 26 | mitigate = 1 27 | collectorType = 0 28 | timeIntrv = 2 29 | globalFlows = [] 30 | pastSSIPLenght = 0 31 | prevFlowCount = 0 32 | 33 | flowSerialNo = 0 34 | iterate = 0 35 | 36 | #Bryan Oliver - Network Security Detector and Mitigator Controller 37 | 38 | 39 | def getFlowNumb(): 40 | global flowSerialNo 41 | flowSerialNo = flowSerialNo + 1 42 | return flowSerialNo 43 | 44 | 45 | def initCsv_Port(dpid): 46 | fname = "switch_" + str(dpid) + "_data.csv" 47 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 48 | header = ["time", "sfe","ssip","rfip","type"] 49 | writ.writerow(header) 50 | 51 | 52 | def initCsv_FlowCount(dpid): 53 | fname = "switch_" + str(dpid) + "_flowcount.csv" 54 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 55 | header = ["time", "flowcount"] 56 | writ.writerow(header) 57 | 58 | 59 | 60 | def update_flowcountcsv(dpid, row): 61 | fname = "switch_" + str(dpid) + "_flowcount.csv" 62 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 63 | writ.writerow(row) 64 | 65 | 66 | def updateCsv_Port(dpid, row): 67 | fname = "sw_" + str(dpid) + "_data.csv" 68 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 69 | row.append(str(collectorType)) 70 | writ.writerow(row) 71 | 72 | 73 | def updateCsv_resData(row): 74 | fname = "resData.csv" 75 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 76 | row.append(str(collectorType)) 77 | writ.writerow(row) 78 | 79 | 80 | 81 | 82 | 83 | class SimpleSwitch13(app_manager.RyuApp): 84 | OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION] 85 | 86 | def __init__(self, *args, **kwargs): 87 | super(SimpleSwitch13, self).__init__(*args, **kwargs) 88 | self.macToPort = {} 89 | self.flow_thread = hub.spawn(self.flowMonitor) 90 | self.datapaths = {} 91 | self.mitigation = 0 92 | self.svmobj = None 93 | self.arpIpToPort = {} 94 | 95 | if detect == 1: 96 | self.svmobj = SVM() 97 | 98 | def flowMonitor(self): 99 | hub.sleep(5) 100 | while True: 101 | for dp in self.datapaths.values(): 102 | self.reqFlowMetric(dp) 103 | hub.sleep(timeIntrv) 104 | 105 | @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) 106 | def switchFeaturesHandler(self, ev): 107 | datapath = ev.msg.datapath 108 | ofproto = datapath.ofproto 109 | parser = datapath.ofproto_parser 110 | self.datapaths[datapath.id] = datapath 111 | flowSerialNo = getFlowNumb() 112 | 113 | match = parser.OFPMatch() 114 | actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, 115 | ofproto.OFPCML_NO_BUFFER)] 116 | self.addFlows(datapath, 0, match, actions, flowSerialNo) 117 | 118 | initCsv_Port(datapath.id) 119 | initCsv_FlowCount(datapath.id) 120 | 121 | def reqFlowMetric(self, datapath): 122 | ofp = datapath.ofproto 123 | ofp_parser = datapath.ofproto_parser 124 | req = ofp_parser.OFPFlowStatsRequest(datapath) 125 | datapath.send_msg(req) 126 | 127 | 128 | def speedFlowEntry(self, flows): 129 | global prevFlowCount 130 | curr_flowCount = 0 131 | for flow in flows: 132 | curr_flowCount += 1 133 | 134 | #print "speed of flow entries ", flowCount 135 | sfe = curr_flowCount - prevFlowCount 136 | prevFlowCount = curr_flowCount 137 | return sfe 138 | 139 | 140 | def speedofSourceIP(self, flows): 141 | global pastSSIPLenght 142 | ssip = [] 143 | #print "length of flow table " ,len(flows) 144 | for flow in flows: 145 | m = {} 146 | for i in flow.match.items(): 147 | key = list(i)[0] # match key 148 | val = list(i)[1] # match value 149 | if key == "ipv4_src": 150 | 151 | if val not in ssip: 152 | ssip.append(val) 153 | cur_ssip_len = len(ssip) 154 | ssip_result = cur_ssip_len - pastSSIPLenght 155 | pastSSIPLenght = cur_ssip_len 156 | return ssip_result 157 | 158 | 159 | def _ratio_of_flowpair(self, flows): 160 | flowCount = 0 161 | for flow in flows: 162 | flowCount += 1 163 | flowCount -= 1 164 | 165 | collaborative_flows = {} 166 | for flow in flows: 167 | m = {} 168 | srcip = dstip = None 169 | for i in flow.match.items(): 170 | key = list(i)[0] # match key 171 | val = list(i)[1] # match value 172 | if key == "ipv4_src": 173 | srcip = val 174 | #print key,val 175 | if key == "ipv4_dst": 176 | dstip = val 177 | if srcip and dstip: 178 | fwdflowhash = srcip + "_" + dstip 179 | revflowhash = dstip + "_" + srcip 180 | #check flowhash is already exist 181 | if not fwdflowhash in collaborative_flows: 182 | #check you have reverse flowhash exists? 183 | if not revflowhash in collaborative_flows: 184 | collaborative_flows[fwdflowhash] = {} 185 | else: 186 | collaborative_flows[revflowhash][fwdflowhash] = 1 187 | #identify number of collaborative flows 188 | onesideflow = iflow = 0 189 | for key in collaborative_flows: 190 | if collaborative_flows[key] == {}: 191 | onesideflow += 1 192 | else: 193 | iflow +=2 194 | #print "collaborative_flows", collaborative_flows 195 | #print "oneside flow", onesideflow 196 | #print "collaborative flow ", iflow 197 | if flowCount != 0 : 198 | rfip = float(iflow) / flowCount 199 | #print "rfip ", rfip 200 | return rfip 201 | return 1.0 202 | 203 | @set_ev_cls([ofp_event.EventOFPFlowStatsReply], MAIN_DISPATCHER) 204 | def flowstatsReplyHandler(self, ev): 205 | global globalFlows, iterate 206 | t_flows = ev.msg.body 207 | flags = ev.msg.flags 208 | dpid = ev.msg.datapath.id 209 | globalFlows.extend(t_flows) 210 | 211 | if flags == 0: 212 | sfe = self.speedFlowEntry(globalFlows) 213 | ssip = self.speedofSourceIP(globalFlows) 214 | rfip = self._ratio_of_flowpair(globalFlows) 215 | 216 | if detect == 1: 217 | result = self.svmobj.classify([sfe,ssip,rfip]) 218 | #print "Attack result ", result 219 | if '1' in result: 220 | print("Status : Attack Traffic Detected") 221 | self.mitigation = 1 222 | if mitigate == 1 : 223 | print("Status : Starting Mitigation") 224 | 225 | if '0' in result: 226 | print("Status : Normal Traffic") 227 | 228 | else: 229 | t = time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()) 230 | row = [t, str(sfe), str(ssip), str(rfip)] 231 | self.logger.info(row) 232 | 233 | updateCsv_Port(dpid, row) 234 | updateCsv_resData([str(sfe), str(ssip), str(rfip)]) 235 | globalFlows = [] 236 | 237 | 238 | t = time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()) 239 | update_flowcountcsv(dpid, [t, str(prevFlowCount)]) 240 | 241 | def addFlows(self, datapath, priority, match, actions,serial_no, buffer_id=None, idletime=0, hardtime=0): 242 | ofproto = datapath.ofproto 243 | parser = datapath.ofproto_parser 244 | 245 | inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, 246 | actions)] 247 | if buffer_id: 248 | mod = parser.OFPFlowMod(datapath=datapath, cookie=serial_no, buffer_id=buffer_id, 249 | idle_timeout=idletime, hard_timeout=hardtime, 250 | priority=priority, match=match, 251 | instructions=inst) 252 | else: 253 | mod = parser.OFPFlowMod(datapath=datapath, cookie=serial_no, priority=priority, 254 | idle_timeout=idletime, hard_timeout=hardtime, 255 | match=match, instructions=inst) 256 | datapath.send_msg(mod) 257 | 258 | 259 | def blockPort(self, datapath, portnumber): 260 | ofproto = datapath.ofproto 261 | parser = datapath.ofproto_parser 262 | match = parser.OFPMatch(in_port=portnumber) 263 | actions = [] 264 | flowSerialNo = getFlowNumb() 265 | self.addFlows(datapath, 100, match, actions, flowSerialNo, hardtime=120) 266 | 267 | @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) 268 | def packetinHandler(self, ev): 269 | if ev.msg.msg_len < ev.msg.total_len: 270 | self.logger.debug("packet truncated: only %s of %s bytes", 271 | ev.msg.msg_len, ev.msg.total_len) 272 | msg = ev.msg 273 | datapath = msg.datapath 274 | ofproto = datapath.ofproto 275 | parser = datapath.ofproto_parser 276 | in_port = msg.match['in_port'] 277 | 278 | pkt = packet.Packet(msg.data) 279 | eth = pkt.get_protocols(ethernet.ethernet)[0] 280 | 281 | if eth.ethertype == ether_types.ETH_TYPE_LLDP: 282 | 283 | return 284 | dst = eth.dst 285 | src = eth.src 286 | dpid = datapath.id 287 | self.macToPort.setdefault(dpid, {}) 288 | self.arpIpToPort.setdefault(dpid, {}) 289 | self.arpIpToPort[dpid].setdefault(in_port, []) 290 | self.logger.info("packet in Switch : %s SrcMAC : %s DstMAC : %s Switch Port : %s", dpid, src, dst, in_port) 291 | 292 | 293 | self.macToPort[dpid][src] = in_port 294 | 295 | if dst in self.macToPort[dpid]: 296 | out_port = self.macToPort[dpid][dst] 297 | else: 298 | out_port = ofproto.OFPP_FLOOD 299 | 300 | actions = [parser.OFPActionOutput(out_port)] 301 | if eth.ethertype == ether_types.ETH_TYPE_ARP: 302 | self.logger.info("Received ARP Packet from Switch: %s SrcMac : %s DstMac: %s ", dpid, src, dst) 303 | a = pkt.get_protocol(arp.arp) 304 | #print "arp packet ", a 305 | if a.opcode == arp.ARP_REQUEST or a.opcode == arp.ARP_REPLY: 306 | if not a.src_ip in self.arpIpToPort[dpid][in_port]: 307 | self.arpIpToPort[dpid][in_port].append(a.src_ip) 308 | #print "arpIpToPort " ,self.arpIpToPort 309 | if out_port != ofproto.OFPP_FLOOD: 310 | if eth.ethertype == ether_types.ETH_TYPE_IP: 311 | ip = pkt.get_protocol(ipv4.ipv4) 312 | srcip = ip.src 313 | dstip = ip.dst 314 | protocol = ip.proto 315 | print("Source :", ip) 316 | 317 | if self.mitigation and mitigate: 318 | if not (srcip in self.arpIpToPort[dpid][in_port]): 319 | self.logger.info("Attack Detected from Switch: %s SwitchPort %s ", dpid, in_port) 320 | print("Port Blocking on Port: ", in_port) 321 | self.blockPort(datapath, in_port) 322 | print("Attacker Source :", ip) 323 | return 324 | match = parser.OFPMatch(eth_type=ether_types.ETH_TYPE_IP, ipv4_src=srcip, ipv4_dst=dstip) 325 | 326 | flowSerialNo = getFlowNumb() 327 | if msg.buffer_id != ofproto.OFP_NO_BUFFER: 328 | self.addFlows(datapath, 1, match, actions, flowSerialNo, buffer_id=msg.buffer_id) 329 | return 330 | else: 331 | self.addFlows(datapath, 1, match, actions, flowSerialNo) 332 | data = None 333 | if msg.buffer_id == ofproto.OFP_NO_BUFFER: 334 | data = msg.data 335 | 336 | out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id, 337 | in_port=in_port, actions=actions, data=data) 338 | datapath.send_msg(out) 339 | -------------------------------------------------------------------------------- /flowsetupsl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # sudo ovs-ofctl add-flow s17 arp,in_port=1,actions=output:2 4 | # sudo ovs-ofctl add-flow s17 arp,in_port=2,actions=output:1 5 | # sudo ovs-ofctl add-flow s18 arp,in_port=3,actions=output:4 6 | # sudo ovs-ofctl add-flow s18 arp,in_port=4,actions=output:3 7 | # sudo ovs-ofctl add-flow s19 arp,in_port=1,actions=output:3 8 | # sudo ovs-ofctl add-flow s19 arp,in_port=3,actions=output:1 9 | # sudo ovs-ofctl add-flow s20 arp,in_port=2,actions=output:4 10 | # sudo ovs-ofctl add-flow s20 arp,in_port=4,actions=output:2 11 | sudo ovs-ofctl -O OpenFlow13 add-flow s1 arp,in_port=1,actions=output:2,3,4,5 12 | sudo ovs-ofctl -O OpenFlow13 add-flow s1 arp,in_port=2,actions=output:1,3,4,5 13 | sudo ovs-ofctl -O OpenFlow13 add-flow s1 arp,in_port=3,actions=output:1,2,4,5 14 | sudo ovs-ofctl -O OpenFlow13 add-flow s1 arp,in_port=4,actions=output:1,2,3,5 15 | sudo ovs-ofctl -O OpenFlow13 add-flow s1 arp,in_port=5,actions=output:1,2,3,4 16 | 17 | sudo ovs-ofctl -O OpenFlow13 add-flow s2 arp,in_port=1,actions=output:2,3,4,5 18 | sudo ovs-ofctl -O OpenFlow13 add-flow s2 arp,in_port=2,actions=output:1,3,4,5 19 | sudo ovs-ofctl -O OpenFlow13 add-flow s2 arp,in_port=3,actions=output:1,2,4,5 20 | sudo ovs-ofctl -O OpenFlow13 add-flow s2 arp,in_port=4,actions=output:1,2,3,5 21 | sudo ovs-ofctl -O OpenFlow13 add-flow s2 arp,in_port=5,actions=output:1,2,3,4 22 | 23 | sudo ovs-ofctl -O OpenFlow13 add-flow s3 arp,in_port=1,actions=output:2,3,4,5 24 | sudo ovs-ofctl -O OpenFlow13 add-flow s3 arp,in_port=2,actions=output:1,3,4,5 25 | sudo ovs-ofctl -O OpenFlow13 add-flow s3 arp,in_port=3,actions=output:1,2,4,5 26 | sudo ovs-ofctl -O OpenFlow13 add-flow s3 arp,in_port=4,actions=output:1,2,3,5 27 | sudo ovs-ofctl -O OpenFlow13 add-flow s3 arp,in_port=5,actions=output:1,2,3,4 28 | 29 | sudo ovs-ofctl -O OpenFlow13 add-flow s4 arp,in_port=1,actions=output:2,3,4,5 30 | sudo ovs-ofctl -O OpenFlow13 add-flow s4 arp,in_port=2,actions=output:1,3,4,5 31 | sudo ovs-ofctl -O OpenFlow13 add-flow s4 arp,in_port=3,actions=output:1,2,4,5 32 | sudo ovs-ofctl -O OpenFlow13 add-flow s4 arp,in_port=4,actions=output:1,2,3,5 33 | sudo ovs-ofctl -O OpenFlow13 add-flow s4 arp,in_port=5,actions=output:1,2,3,4 34 | 35 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=1,actions=output:2,3,4,5 36 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=2,actions=output:1,3,4,5 37 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=3,actions=output:1,2,4,5 38 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=4,actions=output:1,2,3,5 39 | sudo ovs-ofctl -O OpenFlow13 add-flow s5 arp,in_port=5,actions=output:1,2,3,4 40 | 41 | sudo ovs-ofctl -O OpenFlow13 add-flow s6 arp,in_port=1,actions=output:2,3,4,5 42 | sudo ovs-ofctl -O OpenFlow13 add-flow s6 arp,in_port=2,actions=output:1,3,4,5 43 | sudo ovs-ofctl -O OpenFlow13 add-flow s6 arp,in_port=3,actions=output:1,2,4,5 44 | sudo ovs-ofctl -O OpenFlow13 add-flow s6 arp,in_port=4,actions=output:1,2,3,5 45 | sudo ovs-ofctl -O OpenFlow13 add-flow s6 arp,in_port=5,actions=output:1,2,3,4 46 | 47 | sudo ovs-ofctl -O OpenFlow13 add-flow s7 arp,in_port=1,actions=output:2,3,4,5,6 48 | sudo ovs-ofctl -O OpenFlow13 add-flow s7 arp,in_port=2,actions=output:1,3,4,5,6 49 | sudo ovs-ofctl -O OpenFlow13 add-flow s7 arp,in_port=3,actions=output:1,2,4,5,6 50 | sudo ovs-ofctl -O OpenFlow13 add-flow s7 arp,in_port=4,actions=output:1,2,3,5,6 51 | sudo ovs-ofctl -O OpenFlow13 add-flow s7 arp,in_port=5,actions=output:1,2,3,4,6 52 | sudo ovs-ofctl -O OpenFlow13 add-flow s7 arp,in_port=6,actions=output:1,2,3,4,5 53 | 54 | 55 | sudo ovs-ofctl -O OpenFlow13 add-flow s8 arp,in_port=1,actions=output:2,3,4,5,6 56 | sudo ovs-ofctl -O OpenFlow13 add-flow s8 arp,in_port=2,actions=output:1,3,4,5,6 57 | sudo ovs-ofctl -O OpenFlow13 add-flow s8 arp,in_port=3,actions=output:1,2,4,5,6 58 | sudo ovs-ofctl -O OpenFlow13 add-flow s8 arp,in_port=4,actions=output:1,2,3,5,6 59 | sudo ovs-ofctl -O OpenFlow13 add-flow s8 arp,in_port=5,actions=output:1,2,3,4,6 60 | sudo ovs-ofctl -O OpenFlow13 add-flow s8 arp,in_port=6,actions=output:1,2,3,4,5 61 | 62 | 63 | sudo ovs-ofctl -O OpenFlow13 add-flow s9 arp,in_port=1,actions=output:2,3,4,5,6 64 | sudo ovs-ofctl -O OpenFlow13 add-flow s9 arp,in_port=2,actions=output:1,3,4,5,6 65 | sudo ovs-ofctl -O OpenFlow13 add-flow s9 arp,in_port=3,actions=output:1,2,4,5,6 66 | sudo ovs-ofctl -O OpenFlow13 add-flow s9 arp,in_port=4,actions=output:1,2,3,5,6 67 | sudo ovs-ofctl -O OpenFlow13 add-flow s9 arp,in_port=5,actions=output:1,2,3,4,6 68 | sudo ovs-ofctl -O OpenFlow13 add-flow s9 arp,in_port=6,actions=output:1,2,3,4,5 69 | 70 | 71 | #diatas dimasukin di mininet buat bisa stp 72 | 73 | 74 | 75 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.0.0.2/32,actions=output:1 76 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.0.0.3/32,actions=output:2 77 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.0.1.2/32,actions=output:1 78 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.0.1.3/32,actions=output:2 79 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.1.0.2/32,actions=output:1 80 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.1.0.3/32,actions=output:2 81 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.1.1.2/32,actions=output:1 82 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_dst=10.1.1.3/32,actions=output:2 83 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.0.0.2/32,actions=output:3 84 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.0.0.3/32,actions=output:4 85 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.0.1.2/32,actions=output:3 86 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.0.1.3/32,actions=output:4 87 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.1.0.2/32,actions=output:3 88 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.1.0.3/32,actions=output:4 89 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.1.1.3/32,actions=output:4 90 | # sudo ovs-ofctl -O OpenFlow13 add-flow s1 ip,nw_src=10.1.1.2/32,actions=output:3 91 | 92 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.0.0.2/32,actions=output:1 93 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.0.0.3/32,actions=output:2 94 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.0.1.2/32,actions=output:1 95 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.0.1.3/32,actions=output:2 96 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.1.0.2/32,actions=output:1 97 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.1.0.3/32,actions=output:2 98 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.1.1.2/32,actions=output:1 99 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_dst=10.1.1.3/32,actions=output:2 100 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.0.0.2/32,actions=output:3 101 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.0.0.3/32,actions=output:4 102 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.0.1.2/32,actions=output:3 103 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.0.1.3/32,actions=output:4 104 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.1.0.2/32,actions=output:3 105 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.1.0.3/32,actions=output:4 106 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.1.1.3/32,actions=output:4 107 | # sudo ovs-ofctl -O OpenFlow13 add-flow s2 ip,nw_src=10.1.1.2/32,actions=output:3 108 | 109 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.0.0.2/32,actions=output:1 110 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.0.0.3/32,actions=output:2 111 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.0.1.2/32,actions=output:1 112 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.0.1.3/32,actions=output:2 113 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.1.0.2/32,actions=output:1 114 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.1.0.3/32,actions=output:2 115 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.1.1.2/32,actions=output:1 116 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_dst=10.1.1.3/32,actions=output:2 117 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.0.0.2/32,actions=output:3 118 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.0.0.3/32,actions=output:4 119 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.0.1.2/32,actions=output:3 120 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.0.1.3/32,actions=output:4 121 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.1.0.2/32,actions=output:3 122 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.1.0.3/32,actions=output:4 123 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.1.1.3/32,actions=output:4 124 | # sudo ovs-ofctl -O OpenFlow13 add-flow s3 ip,nw_src=10.1.1.2/32,actions=output:3 125 | 126 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.0.0.2/32,actions=output:1 127 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.0.0.3/32,actions=output:2 128 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.0.1.2/32,actions=output:1 129 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.0.1.3/32,actions=output:2 130 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.1.0.2/32,actions=output:1 131 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.1.0.3/32,actions=output:2 132 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.1.1.2/32,actions=output:1 133 | # sudo ovs-ofctl add-flow s4 ip,nw_dst=10.1.1.3/32,actions=output:2 134 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.0.0.2/32,actions=output:3 135 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.0.0.3/32,actions=output:4 136 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.0.1.2/32,actions=output:3 137 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.0.1.3/32,actions=output:4 138 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.1.0.2/32,actions=output:3 139 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.1.0.3/32,actions=output:4 140 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.1.1.3/32,actions=output:4 141 | # sudo ovs-ofctl add-flow s4 ip,nw_src=10.1.1.2/32,actions=output:3 142 | 143 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.0.0.2/32,actions=output:1 144 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.0.0.3/32,actions=output:2 145 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.0.1.2/32,actions=output:1 146 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.0.1.3/32,actions=output:2 147 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.1.0.2/32,actions=output:1 148 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.1.0.3/32,actions=output:2 149 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.1.1.2/32,actions=output:1 150 | # sudo ovs-ofctl add-flow s5 ip,nw_dst=10.1.1.3/32,actions=output:2 151 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.0.0.2/32,actions=output:3 152 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.0.0.3/32,actions=output:4 153 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.0.1.2/32,actions=output:3 154 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.0.1.3/32,actions=output:4 155 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.1.0.2/32,actions=output:3 156 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.1.0.3/32,actions=output:4 157 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.1.1.3/32,actions=output:4 158 | # sudo ovs-ofctl add-flow s5 ip,nw_src=10.1.1.2/32,actions=output:3 159 | 160 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.0.0.2/32,actions=output:1 161 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.0.0.3/32,actions=output:2 162 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.0.1.2/32,actions=output:1 163 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.0.1.3/32,actions=output:2 164 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.1.0.2/32,actions=output:1 165 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.1.0.3/32,actions=output:2 166 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.1.1.2/32,actions=output:1 167 | # sudo ovs-ofctl add-flow s6 ip,nw_dst=10.1.1.3/32,actions=output:2 168 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.0.0.2/32,actions=output:3 169 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.0.0.3/32,actions=output:4 170 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.0.1.2/32,actions=output:3 171 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.0.1.3/32,actions=output:4 172 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.1.0.2/32,actions=output:3 173 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.1.0.3/32,actions=output:4 174 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.1.1.3/32,actions=output:4 175 | # sudo ovs-ofctl add-flow s6 ip,nw_src=10.1.1.2/32,actions=output:3 176 | 177 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.0.0.2/32,actions=output:1 178 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.0.0.3/32,actions=output:2 179 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.0.1.2/32,actions=output:1 180 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.0.1.3/32,actions=output:2 181 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.1.0.2/32,actions=output:1 182 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.1.0.3/32,actions=output:2 183 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.1.1.2/32,actions=output:1 184 | # sudo ovs-ofctl add-flow s7 ip,nw_dst=10.1.1.3/32,actions=output:2 185 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.0.0.2/32,actions=output:3 186 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.0.0.3/32,actions=output:4 187 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.0.1.2/32,actions=output:3 188 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.0.1.3/32,actions=output:4 189 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.1.0.2/32,actions=output:3 190 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.1.0.3/32,actions=output:4 191 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.1.1.3/32,actions=output:4 192 | # sudo ovs-ofctl add-flow s7 ip,nw_src=10.1.1.2/32,actions=output:3 193 | -------------------------------------------------------------------------------- /controllertest.py: -------------------------------------------------------------------------------- 1 | from ryu.base import app_manager 2 | from ryu.controller import ofp_event 3 | from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER 4 | from ryu.controller.handler import set_ev_cls 5 | from ryu.ofproto import ofproto_v1_3 6 | from ryu.lib.packet import packet 7 | from ryu.lib.packet import ethernet 8 | from ryu.lib.packet import ether_types 9 | 10 | from ryu.lib.packet import in_proto 11 | from ryu.lib.packet import ipv4 12 | from ryu.lib.packet import icmp 13 | from ryu.lib.packet import tcp 14 | from ryu.lib.packet import udp 15 | from ryu.lib.packet import arp 16 | 17 | from ryu.lib import hub 18 | import csv 19 | import time 20 | import math 21 | import statistics 22 | 23 | from svm import SVM 24 | 25 | APP_TYPE = 1 26 | #0 datacollection, 1 ddos detection 27 | 28 | PREVENTION = 1 29 | # ddos prevention 30 | 31 | #TEST_TYPE is applicable only for data collection 32 | #0 normal traffic, 1 attack traffic 33 | TEST_TYPE = 0 34 | 35 | #data collection time interval in seconds 36 | INTERVAL = 2 37 | #-------------------------------------------------------# 38 | 39 | 40 | 41 | gflows = [] 42 | 43 | 44 | old_ssip_len = 0 45 | prev_flow_count = 0 46 | 47 | FLOW_SERIAL_NO = 0 48 | iteration = 0 49 | 50 | 51 | 52 | 53 | def get_flow_number(): 54 | global FLOW_SERIAL_NO 55 | FLOW_SERIAL_NO = FLOW_SERIAL_NO + 1 56 | return FLOW_SERIAL_NO 57 | 58 | 59 | def init_portcsv(dpid): 60 | fname = "switch_" + str(dpid) + "_data.csv" 61 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 62 | header = ["time", "sfe","ssip","rfip","type"] 63 | writ.writerow(header) 64 | 65 | 66 | def init_flowcountcsv(dpid): 67 | fname = "switch_" + str(dpid) + "_flowcount.csv" 68 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 69 | header = ["time", "flowcount"] 70 | writ.writerow(header) 71 | 72 | 73 | 74 | def update_flowcountcsv(dpid, row): 75 | fname = "switch_" + str(dpid) + "_flowcount.csv" 76 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 77 | writ.writerow(row) 78 | 79 | 80 | def update_portcsv(dpid, row): 81 | fname = "switch_" + str(dpid) + "_data.csv" 82 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 83 | row.append(str(TEST_TYPE)) 84 | writ.writerow(row) 85 | 86 | 87 | def update_resultcsv(row): 88 | fname = "result.csv" 89 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 90 | row.append(str(TEST_TYPE)) 91 | writ.writerow(row) 92 | 93 | 94 | 95 | 96 | 97 | class SimpleSwitch13(app_manager.RyuApp): 98 | OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION] 99 | 100 | def __init__(self, *args, **kwargs): 101 | super(SimpleSwitch13, self).__init__(*args, **kwargs) 102 | self.mac_to_port = {} 103 | self.flow_thread = hub.spawn(self._flow_monitor) 104 | self.datapaths = {} 105 | self.mitigation = 0 106 | self.svmobj = None 107 | self.arp_ip_to_port = {} 108 | 109 | if APP_TYPE == 1: 110 | self.svmobj = SVM() 111 | 112 | def _flow_monitor(self): 113 | #inital delay 114 | hub.sleep(5) 115 | while True: 116 | #self.logger.info("Starts Flow monitoring") 117 | for dp in self.datapaths.values(): 118 | self.request_flow_metrics(dp) 119 | hub.sleep(INTERVAL) 120 | 121 | @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) 122 | def switch_features_handler(self, ev): 123 | datapath = ev.msg.datapath 124 | ofproto = datapath.ofproto 125 | parser = datapath.ofproto_parser 126 | self.datapaths[datapath.id] = datapath 127 | #init_portcsv(datapath.id) 128 | 129 | 130 | flow_serial_no = get_flow_number() 131 | 132 | match = parser.OFPMatch() 133 | actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, 134 | ofproto.OFPCML_NO_BUFFER)] 135 | self.add_flow(datapath, 0, match, actions, flow_serial_no) 136 | 137 | init_portcsv(datapath.id) 138 | init_flowcountcsv(datapath.id) 139 | 140 | def request_flow_metrics(self, datapath): 141 | ofp = datapath.ofproto 142 | ofp_parser = datapath.ofproto_parser 143 | req = ofp_parser.OFPFlowStatsRequest(datapath) 144 | datapath.send_msg(req) 145 | 146 | 147 | def _speed_of_flow_entries(self, flows): 148 | global prev_flow_count 149 | curr_flow_count = 0 150 | #collect the packet_count from all the flows 151 | for flow in flows: 152 | curr_flow_count += 1 153 | 154 | #print "speed of flow entries ", flow_count 155 | sfe = curr_flow_count - prev_flow_count 156 | prev_flow_count = curr_flow_count 157 | return sfe 158 | 159 | 160 | def _speed_of_source_ip(self, flows): 161 | global old_ssip_len 162 | ssip = [] 163 | #print "length of flow table " ,len(flows) 164 | for flow in flows: 165 | m = {} 166 | for i in flow.match.items(): 167 | key = list(i)[0] # match key 168 | val = list(i)[1] # match value 169 | if key == "ipv4_src": 170 | #print key,val 171 | if val not in ssip: 172 | ssip.append(val) 173 | #print "source_ips ", ssip 174 | cur_ssip_len = len(ssip) 175 | ssip_result = cur_ssip_len - old_ssip_len 176 | old_ssip_len = cur_ssip_len 177 | #print "ssip ", ssip 178 | return ssip_result 179 | 180 | 181 | def _ratio_of_flowpair(self, flows): 182 | #find total number of flows 183 | # find collaborative flows (ideal case - all - 1 ) 184 | flow_count = 0 185 | for flow in flows: 186 | flow_count += 1 187 | #print "total number of flows ", flow_count 188 | #excluding the table miss entry from flow count 189 | flow_count -= 1 190 | 191 | collaborative_flows = {} 192 | for flow in flows: 193 | m = {} 194 | srcip = dstip = None 195 | for i in flow.match.items(): 196 | key = list(i)[0] # match key 197 | val = list(i)[1] # match value 198 | if key == "ipv4_src": 199 | srcip = val 200 | #print key,val 201 | if key == "ipv4_dst": 202 | dstip = val 203 | if srcip and dstip: 204 | fwdflowhash = srcip + "_" + dstip 205 | revflowhash = dstip + "_" + srcip 206 | #check flowhash is already exist 207 | if not fwdflowhash in collaborative_flows: 208 | #check you have reverse flowhash exists? 209 | if not revflowhash in collaborative_flows: 210 | collaborative_flows[fwdflowhash] = {} 211 | else: 212 | collaborative_flows[revflowhash][fwdflowhash] = 1 213 | #identify number of collaborative flows 214 | onesideflow = iflow = 0 215 | for key in collaborative_flows: 216 | if collaborative_flows[key] == {}: 217 | onesideflow += 1 218 | else: 219 | iflow +=2 220 | #print "collaborative_flows", collaborative_flows 221 | #print "oneside flow", onesideflow 222 | #print "collaborative flow ", iflow 223 | if flow_count != 0 : 224 | rfip = float(iflow) / flow_count 225 | #print "rfip ", rfip 226 | return rfip 227 | return 1.0 228 | 229 | @set_ev_cls([ofp_event.EventOFPFlowStatsReply], MAIN_DISPATCHER) 230 | def flow_stats_reply_handler(self, ev): 231 | global gflows, iteration 232 | t_flows = ev.msg.body 233 | flags = ev.msg.flags 234 | dpid = ev.msg.datapath.id 235 | gflows.extend(t_flows) 236 | 237 | if flags == 0: 238 | sfe = self._speed_of_flow_entries(gflows) 239 | ssip = self._speed_of_source_ip(gflows) 240 | rfip = self._ratio_of_flowpair(gflows) 241 | 242 | if APP_TYPE == 1: 243 | result = self.svmobj.classify([sfe,ssip,rfip]) 244 | #print "Attack result ", result 245 | if '1' in result: 246 | print("Attack Traffic detected") 247 | self.mitigation = 1 248 | if PREVENTION == 1 : 249 | print("Mitigation Started") 250 | 251 | if '0' in result: 252 | print("It's Normal Traffic") 253 | 254 | else: 255 | t = time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()) 256 | row = [t, str(sfe), str(ssip), str(rfip)] 257 | self.logger.info(row) 258 | 259 | update_portcsv(dpid, row) 260 | update_resultcsv([str(sfe), str(ssip), str(rfip)]) 261 | gflows = [] 262 | 263 | 264 | #update the flowcount csv file 265 | t = time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()) 266 | update_flowcountcsv(dpid, [t, str(prev_flow_count)]) 267 | 268 | def add_flow(self, datapath, priority, match, actions,serial_no, buffer_id=None, idletime=0, hardtime=0): 269 | ofproto = datapath.ofproto 270 | parser = datapath.ofproto_parser 271 | 272 | inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, 273 | actions)] 274 | if buffer_id: 275 | mod = parser.OFPFlowMod(datapath=datapath, cookie=serial_no, buffer_id=buffer_id, 276 | idle_timeout=idletime, hard_timeout=hardtime, 277 | priority=priority, match=match, 278 | instructions=inst) 279 | else: 280 | mod = parser.OFPFlowMod(datapath=datapath, cookie=serial_no, priority=priority, 281 | idle_timeout=idletime, hard_timeout=hardtime, 282 | match=match, instructions=inst) 283 | datapath.send_msg(mod) 284 | 285 | 286 | def block_port(self, datapath, portnumber): 287 | ofproto = datapath.ofproto 288 | parser = datapath.ofproto_parser 289 | match = parser.OFPMatch(in_port=portnumber) 290 | actions = [] 291 | flow_serial_no = get_flow_number() 292 | self.add_flow(datapath, 100, match, actions, flow_serial_no, hardtime=120) 293 | 294 | @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) 295 | def _packet_in_handler(self, ev): 296 | # If you hit this you might want to increase 297 | # the "miss_send_length" of your switch 298 | if ev.msg.msg_len < ev.msg.total_len: 299 | self.logger.debug("packet truncated: only %s of %s bytes", 300 | ev.msg.msg_len, ev.msg.total_len) 301 | msg = ev.msg 302 | datapath = msg.datapath 303 | ofproto = datapath.ofproto 304 | parser = datapath.ofproto_parser 305 | in_port = msg.match['in_port'] 306 | 307 | pkt = packet.Packet(msg.data) 308 | eth = pkt.get_protocols(ethernet.ethernet)[0] 309 | 310 | if eth.ethertype == ether_types.ETH_TYPE_LLDP: 311 | 312 | return 313 | dst = eth.dst 314 | src = eth.src 315 | 316 | dpid = datapath.id 317 | self.mac_to_port.setdefault(dpid, {}) 318 | self.arp_ip_to_port.setdefault(dpid, {}) 319 | self.arp_ip_to_port[dpid].setdefault(in_port, []) 320 | #self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port) 321 | 322 | self.mac_to_port[dpid][src] = in_port 323 | 324 | if dst in self.mac_to_port[dpid]: 325 | out_port = self.mac_to_port[dpid][dst] 326 | else: 327 | out_port = ofproto.OFPP_FLOOD 328 | 329 | actions = [parser.OFPActionOutput(out_port)] 330 | 331 | #if ARP Request packet , log the IP and MAC Address from that port 332 | if eth.ethertype == ether_types.ETH_TYPE_ARP: 333 | #self.logger.info("Received ARP Packet %s %s %s ", dpid, src, dst) 334 | a = pkt.get_protocol(arp.arp) 335 | #print "arp packet ", a 336 | if a.opcode == arp.ARP_REQUEST or a.opcode == arp.ARP_REPLY: 337 | if not a.src_ip in self.arp_ip_to_port[dpid][in_port]: 338 | self.arp_ip_to_port[dpid][in_port].append(a.src_ip) 339 | #print "arp_ip_to_port " ,self.arp_ip_to_port 340 | 341 | 342 | # install a flow to avoid packet_in next time 343 | if out_port != ofproto.OFPP_FLOOD: 344 | 345 | # check IP Protocol and create a match for IP 346 | if eth.ethertype == ether_types.ETH_TYPE_IP: 347 | ip = pkt.get_protocol(ipv4.ipv4) 348 | srcip = ip.src 349 | dstip = ip.dst 350 | protocol = ip.proto 351 | 352 | 353 | if self.mitigation and PREVENTION: 354 | if not (srcip in self.arp_ip_to_port[dpid][in_port]): 355 | print("attack detected from port ", in_port) 356 | print("Block the port ", in_port) 357 | self.block_port(datapath, in_port) 358 | #print ip 359 | return 360 | 361 | match = parser.OFPMatch(eth_type=ether_types.ETH_TYPE_IP, ipv4_src=srcip, ipv4_dst=dstip) 362 | 363 | # verify if we have a valid buffer_id, if yes avoid to send both 364 | # flow_mod & packet_out 365 | flow_serial_no = get_flow_number() 366 | if msg.buffer_id != ofproto.OFP_NO_BUFFER: 367 | self.add_flow(datapath, 1, match, actions, flow_serial_no, buffer_id=msg.buffer_id) 368 | return 369 | else: 370 | self.add_flow(datapath, 1, match, actions, flow_serial_no) 371 | data = None 372 | if msg.buffer_id == ofproto.OFP_NO_BUFFER: 373 | data = msg.data 374 | 375 | out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id, 376 | in_port=in_port, actions=actions, data=data) 377 | datapath.send_msg(out) 378 | -------------------------------------------------------------------------------- /controllerwithstp.py: -------------------------------------------------------------------------------- 1 | from ryu.base import app_manager 2 | from ryu.controller import ofp_event 3 | from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER 4 | from ryu.controller.handler import set_ev_cls 5 | from ryu.ofproto import ofproto_v1_3 6 | from ryu.lib.packet import packet 7 | from ryu.lib.packet import ethernet 8 | from ryu.lib.packet import ether_types 9 | from ryu.lib import dpid as dpid_lib 10 | from ryu.lib import stplib 11 | from ryu.lib.packet import in_proto 12 | from ryu.lib.packet import ipv4 13 | from ryu.lib.packet import icmp 14 | from ryu.lib.packet import tcp 15 | from ryu.lib.packet import udp 16 | from ryu.lib.packet import arp 17 | 18 | from ryu.lib import hub 19 | import csv 20 | import time 21 | import math 22 | import statistics 23 | 24 | from svm import SVM 25 | 26 | APP_TYPE = 1 27 | #0 datacollection, 1 ddos detection 28 | 29 | PREVENTION = 1 30 | # ddos prevention 31 | 32 | #TEST_TYPE is applicable only for data collection 33 | #0 normal traffic, 1 attack traffic 34 | TEST_TYPE = 0 35 | 36 | #data collection time interval in seconds 37 | INTERVAL = 2 38 | #-------------------------------------------------------# 39 | 40 | 41 | 42 | gflows = [] 43 | 44 | 45 | old_ssip_len = 0 46 | prev_flow_count = 0 47 | 48 | FLOW_SERIAL_NO = 0 49 | iteration = 0 50 | 51 | 52 | 53 | 54 | def get_flow_number(): 55 | global FLOW_SERIAL_NO 56 | FLOW_SERIAL_NO = FLOW_SERIAL_NO + 1 57 | return FLOW_SERIAL_NO 58 | 59 | 60 | def init_portcsv(dpid): 61 | fname = "switch_" + str(dpid) + "_data.csv" 62 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 63 | header = ["time", "sfe","ssip","rfip","type"] 64 | writ.writerow(header) 65 | 66 | 67 | def init_flowcountcsv(dpid): 68 | fname = "switch_" + str(dpid) + "_flowcount.csv" 69 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 70 | header = ["time", "flowcount"] 71 | writ.writerow(header) 72 | 73 | 74 | 75 | def update_flowcountcsv(dpid, row): 76 | fname = "switch_" + str(dpid) + "_flowcount.csv" 77 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 78 | writ.writerow(row) 79 | 80 | 81 | def update_portcsv(dpid, row): 82 | fname = "switch_" + str(dpid) + "_data.csv" 83 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 84 | row.append(str(TEST_TYPE)) 85 | writ.writerow(row) 86 | 87 | 88 | def update_resultcsv(row): 89 | fname = "result.csv" 90 | writ = csv.writer(open(fname, 'a', buffering=1), delimiter=',') 91 | row.append(str(TEST_TYPE)) 92 | writ.writerow(row) 93 | 94 | 95 | 96 | 97 | 98 | class SimpleSwitch13(app_manager.RyuApp): 99 | OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION] 100 | _CONTEXTS = {'stplib': stplib.Stp} 101 | 102 | 103 | def __init__(self, *args, **kwargs): 104 | super(SimpleSwitch13, self).__init__(*args, **kwargs) 105 | self.mac_to_port = {} 106 | self.flow_thread = hub.spawn(self._flow_monitor) 107 | self.datapaths = {} 108 | self.mitigation = 0 109 | self.svmobj = None 110 | self.arp_ip_to_port = {} 111 | self.stp = kwargs['stplib'] 112 | config = {dpid_lib.str_to_dpid('0000000000000001'): 113 | {'bridge': {'priority': 0x8000}}, 114 | dpid_lib.str_to_dpid('0000000000000002'): 115 | {'bridge': {'priority': 0x9000}}, 116 | dpid_lib.str_to_dpid('0000000000000003'): 117 | {'bridge': {'priority': 0xa000}}} 118 | self.stp.set_config(config) 119 | 120 | if APP_TYPE == 1: 121 | self.svmobj = SVM() 122 | 123 | def _flow_monitor(self): 124 | #inital delay 125 | hub.sleep(5) 126 | while True: 127 | #self.logger.info("Starts Flow monitoring") 128 | for dp in self.datapaths.values(): 129 | self.request_flow_metrics(dp) 130 | hub.sleep(INTERVAL) 131 | 132 | @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER) 133 | def switch_features_handler(self, ev): 134 | datapath = ev.msg.datapath 135 | ofproto = datapath.ofproto 136 | parser = datapath.ofproto_parser 137 | self.datapaths[datapath.id] = datapath 138 | #init_portcsv(datapath.id) 139 | 140 | 141 | flow_serial_no = get_flow_number() 142 | 143 | match = parser.OFPMatch() 144 | actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, 145 | ofproto.OFPCML_NO_BUFFER)] 146 | self.add_flow(datapath, 0, match, actions, flow_serial_no) 147 | 148 | init_portcsv(datapath.id) 149 | init_flowcountcsv(datapath.id) 150 | 151 | def request_flow_metrics(self, datapath): 152 | ofp = datapath.ofproto 153 | ofp_parser = datapath.ofproto_parser 154 | req = ofp_parser.OFPFlowStatsRequest(datapath) 155 | datapath.send_msg(req) 156 | 157 | 158 | def _speed_of_flow_entries(self, flows): 159 | global prev_flow_count 160 | curr_flow_count = 0 161 | #collect the packet_count from all the flows 162 | for flow in flows: 163 | curr_flow_count += 1 164 | 165 | #print "speed of flow entries ", flow_count 166 | sfe = curr_flow_count - prev_flow_count 167 | prev_flow_count = curr_flow_count 168 | return sfe 169 | 170 | def delete_flow(self, datapath): 171 | ofproto = datapath.ofproto 172 | parser = datapath.ofproto_parser 173 | 174 | for dst in self.mac_to_port[datapath.id].keys(): 175 | match = parser.OFPMatch(eth_dst=dst) 176 | mod = parser.OFPFlowMod( 177 | datapath, command=ofproto.OFPFC_DELETE, 178 | out_port=ofproto.OFPP_ANY, out_group=ofproto.OFPG_ANY, 179 | priority=1, match=match) 180 | datapath.send_msg(mod) 181 | def _speed_of_source_ip(self, flows): 182 | global old_ssip_len 183 | ssip = [] 184 | #print "length of flow table " ,len(flows) 185 | for flow in flows: 186 | m = {} 187 | for i in flow.match.items(): 188 | key = list(i)[0] # match key 189 | val = list(i)[1] # match value 190 | if key == "ipv4_src": 191 | #print key,val 192 | if val not in ssip: 193 | ssip.append(val) 194 | #print "source_ips ", ssip 195 | cur_ssip_len = len(ssip) 196 | ssip_result = cur_ssip_len - old_ssip_len 197 | old_ssip_len = cur_ssip_len 198 | #print "ssip ", ssip 199 | return ssip_result 200 | 201 | 202 | def _ratio_of_flowpair(self, flows): 203 | #find total number of flows 204 | # find collaborative flows (ideal case - all - 1 ) 205 | flow_count = 0 206 | for flow in flows: 207 | flow_count += 1 208 | #print "total number of flows ", flow_count 209 | #excluding the table miss entry from flow count 210 | flow_count -= 1 211 | 212 | collaborative_flows = {} 213 | for flow in flows: 214 | m = {} 215 | srcip = dstip = None 216 | for i in flow.match.items(): 217 | key = list(i)[0] # match key 218 | val = list(i)[1] # match value 219 | if key == "ipv4_src": 220 | srcip = val 221 | #print key,val 222 | if key == "ipv4_dst": 223 | dstip = val 224 | if srcip and dstip: 225 | fwdflowhash = srcip + "_" + dstip 226 | revflowhash = dstip + "_" + srcip 227 | #check flowhash is already exist 228 | if not fwdflowhash in collaborative_flows: 229 | #check you have reverse flowhash exists? 230 | if not revflowhash in collaborative_flows: 231 | collaborative_flows[fwdflowhash] = {} 232 | else: 233 | collaborative_flows[revflowhash][fwdflowhash] = 1 234 | #identify number of collaborative flows 235 | onesideflow = iflow = 0 236 | for key in collaborative_flows: 237 | if collaborative_flows[key] == {}: 238 | onesideflow += 1 239 | else: 240 | iflow +=2 241 | #print "collaborative_flows", collaborative_flows 242 | #print "oneside flow", onesideflow 243 | #print "collaborative flow ", iflow 244 | if flow_count != 0 : 245 | rfip = float(iflow) / flow_count 246 | #print "rfip ", rfip 247 | return rfip 248 | return 1.0 249 | 250 | @set_ev_cls([ofp_event.EventOFPFlowStatsReply], MAIN_DISPATCHER) 251 | def flow_stats_reply_handler(self, ev): 252 | global gflows, iteration 253 | t_flows = ev.msg.body 254 | flags = ev.msg.flags 255 | dpid = ev.msg.datapath.id 256 | gflows.extend(t_flows) 257 | 258 | if flags == 0: 259 | sfe = self._speed_of_flow_entries(gflows) 260 | ssip = self._speed_of_source_ip(gflows) 261 | rfip = self._ratio_of_flowpair(gflows) 262 | 263 | if APP_TYPE == 1: 264 | result = self.svmobj.classify([sfe,ssip,rfip]) 265 | #print "Attack result ", result 266 | if '1' in result: 267 | print("Attack Traffic detected") 268 | self.mitigation = 1 269 | if PREVENTION == 1 : 270 | print("Mitigation Started") 271 | 272 | if '0' in result: 273 | print("It's Normal Traffic") 274 | 275 | else: 276 | t = time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()) 277 | row = [t, str(sfe), str(ssip), str(rfip)] 278 | self.logger.info(row) 279 | 280 | update_portcsv(dpid, row) 281 | update_resultcsv([str(sfe), str(ssip), str(rfip)]) 282 | gflows = [] 283 | 284 | 285 | #update the flowcount csv file 286 | t = time.strftime("%m/%d/%Y, %H:%M:%S", time.localtime()) 287 | update_flowcountcsv(dpid, [t, str(prev_flow_count)]) 288 | 289 | def add_flow(self, datapath, priority, match, actions,serial_no, buffer_id=None, idletime=0, hardtime=0): 290 | ofproto = datapath.ofproto 291 | parser = datapath.ofproto_parser 292 | 293 | inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, 294 | actions)] 295 | if buffer_id: 296 | mod = parser.OFPFlowMod(datapath=datapath, cookie=serial_no, buffer_id=buffer_id, 297 | idle_timeout=idletime, hard_timeout=hardtime, 298 | priority=priority, match=match, 299 | instructions=inst) 300 | else: 301 | mod = parser.OFPFlowMod(datapath=datapath, cookie=serial_no, priority=priority, 302 | idle_timeout=idletime, hard_timeout=hardtime, 303 | match=match, instructions=inst) 304 | datapath.send_msg(mod) 305 | 306 | 307 | def block_port(self, datapath, portnumber): 308 | ofproto = datapath.ofproto 309 | parser = datapath.ofproto_parser 310 | match = parser.OFPMatch(in_port=portnumber) 311 | actions = [] 312 | flow_serial_no = get_flow_number() 313 | self.add_flow(datapath, 100, match, actions, flow_serial_no, hardtime=120) 314 | 315 | @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER) 316 | def _packet_in_handler(self, ev): 317 | # If you hit this you might want to increase 318 | # the "miss_send_length" of your switch 319 | if ev.msg.msg_len < ev.msg.total_len: 320 | self.logger.debug("packet truncated: only %s of %s bytes", 321 | ev.msg.msg_len, ev.msg.total_len) 322 | msg = ev.msg 323 | datapath = msg.datapath 324 | ofproto = datapath.ofproto 325 | parser = datapath.ofproto_parser 326 | in_port = msg.match['in_port'] 327 | 328 | pkt = packet.Packet(msg.data) 329 | eth = pkt.get_protocols(ethernet.ethernet)[0] 330 | 331 | if eth.ethertype == ether_types.ETH_TYPE_LLDP: 332 | 333 | return 334 | dst = eth.dst 335 | src = eth.src 336 | 337 | dpid = datapath.id 338 | self.mac_to_port.setdefault(dpid, {}) 339 | self.arp_ip_to_port.setdefault(dpid, {}) 340 | self.arp_ip_to_port[dpid].setdefault(in_port, []) 341 | #self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port) 342 | 343 | self.mac_to_port[dpid][src] = in_port 344 | 345 | if dst in self.mac_to_port[dpid]: 346 | out_port = self.mac_to_port[dpid][dst] 347 | else: 348 | out_port = ofproto.OFPP_FLOOD 349 | 350 | actions = [parser.OFPActionOutput(out_port)] 351 | 352 | #if ARP Request packet , log the IP and MAC Address from that port 353 | if eth.ethertype == ether_types.ETH_TYPE_ARP: 354 | #self.logger.info("Received ARP Packet %s %s %s ", dpid, src, dst) 355 | a = pkt.get_protocol(arp.arp) 356 | #print "arp packet ", a 357 | if a.opcode == arp.ARP_REQUEST or a.opcode == arp.ARP_REPLY: 358 | if not a.src_ip in self.arp_ip_to_port[dpid][in_port]: 359 | self.arp_ip_to_port[dpid][in_port].append(a.src_ip) 360 | #print "arp_ip_to_port " ,self.arp_ip_to_port 361 | 362 | 363 | # install a flow to avoid packet_in next time 364 | if out_port != ofproto.OFPP_FLOOD: 365 | 366 | # check IP Protocol and create a match for IP 367 | if eth.ethertype == ether_types.ETH_TYPE_IP: 368 | ip = pkt.get_protocol(ipv4.ipv4) 369 | srcip = ip.src 370 | dstip = ip.dst 371 | protocol = ip.proto 372 | 373 | 374 | if self.mitigation and PREVENTION: 375 | if not (srcip in self.arp_ip_to_port[dpid][in_port]): 376 | print("attack detected from port ", in_port) 377 | print("Block the port ", in_port) 378 | self.block_port(datapath, in_port) 379 | #print ip 380 | return 381 | 382 | match = parser.OFPMatch(eth_type=ether_types.ETH_TYPE_IP, ipv4_src=srcip, ipv4_dst=dstip) 383 | 384 | # verify if we have a valid buffer_id, if yes avoid to send both 385 | # flow_mod & packet_out 386 | flow_serial_no = get_flow_number() 387 | if msg.buffer_id != ofproto.OFP_NO_BUFFER: 388 | self.add_flow(datapath, 1, match, actions, flow_serial_no, buffer_id=msg.buffer_id) 389 | return 390 | else: 391 | self.add_flow(datapath, 1, match, actions, flow_serial_no) 392 | data = None 393 | if msg.buffer_id == ofproto.OFP_NO_BUFFER: 394 | data = msg.data 395 | 396 | out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id, 397 | in_port=in_port, actions=actions, data=data) 398 | datapath.send_msg(out) 399 | @set_ev_cls(stplib.EventTopologyChange, MAIN_DISPATCHER) 400 | def _topology_change_handler(self, ev): 401 | dp = ev.dp 402 | dpid_str = dpid_lib.dpid_to_str(dp.id) 403 | msg = 'Receive topology change event. Flush MAC table.' 404 | #self.logger.debug("[dpid=%s] %s", dpid_str, msg) 405 | 406 | if dp.id in self.mac_to_port: 407 | self.delete_flow(dp) 408 | del self.mac_to_port[dp.id] 409 | @set_ev_cls(stplib.EventPortStateChange, MAIN_DISPATCHER) 410 | def _port_state_change_handler(self, ev): 411 | dpid_str = dpid_lib.dpid_to_str(ev.dp.id) 412 | of_state = {stplib.PORT_STATE_DISABLE: 'DISABLE', 413 | stplib.PORT_STATE_BLOCK: 'BLOCK', 414 | stplib.PORT_STATE_LISTEN: 'LISTEN', 415 | stplib.PORT_STATE_LEARN: 'LEARN', 416 | stplib.PORT_STATE_FORWARD: 'FORWARD'} 417 | #self.logger.debug("[dpid=%s][port=%d] state=%s", 418 | # dpid_str, ev.port_no, of_state[ev.port_state]) -------------------------------------------------------------------------------- /minine2.mn: -------------------------------------------------------------------------------- 1 | { 2 | "application": { 3 | "dpctl": "", 4 | "ipBase": "10.0.0.0/8", 5 | "netflow": { 6 | "nflowAddId": "0", 7 | "nflowTarget": "", 8 | "nflowTimeout": "600" 9 | }, 10 | "openFlowVersions": { 11 | "ovsOf10": "1", 12 | "ovsOf11": "0", 13 | "ovsOf12": "0", 14 | "ovsOf13": "0" 15 | }, 16 | "sflow": { 17 | "sflowHeader": "128", 18 | "sflowPolling": "30", 19 | "sflowSampling": "400", 20 | "sflowTarget": "" 21 | }, 22 | "startCLI": "0", 23 | "switchType": "ovs", 24 | "terminalType": "xterm" 25 | }, 26 | "controllers": [], 27 | "hosts": [ 28 | { 29 | "number": "3", 30 | "opts": { 31 | "hostname": "h3", 32 | "ip": "10.0.1.2", 33 | "nodeNum": 3, 34 | "sched": "host" 35 | }, 36 | "x": "192.0", 37 | "y": "543.0" 38 | }, 39 | { 40 | "number": "4", 41 | "opts": { 42 | "hostname": "h4", 43 | "ip": "10.0.1.3", 44 | "nodeNum": 4, 45 | "sched": "host" 46 | }, 47 | "x": "266.0", 48 | "y": "544.0" 49 | }, 50 | { 51 | "number": "5", 52 | "opts": { 53 | "hostname": "h5", 54 | "ip": "10.1.0.2", 55 | "nodeNum": 5, 56 | "sched": "host" 57 | }, 58 | "x": "363.0", 59 | "y": "536.0" 60 | }, 61 | { 62 | "number": "6", 63 | "opts": { 64 | "hostname": "h6", 65 | "ip": "10.1.0.3", 66 | "nodeNum": 6, 67 | "sched": "host" 68 | }, 69 | "x": "425.0", 70 | "y": "535.0" 71 | }, 72 | { 73 | "number": "7", 74 | "opts": { 75 | "hostname": "h7", 76 | "ip": "10.1.1.2", 77 | "nodeNum": 7, 78 | "sched": "host" 79 | }, 80 | "x": "496.0", 81 | "y": "533.0" 82 | }, 83 | { 84 | "number": "8", 85 | "opts": { 86 | "hostname": "h8", 87 | "ip": "10.1.1.3", 88 | "nodeNum": 8, 89 | "sched": "host" 90 | }, 91 | "x": "566.0", 92 | "y": "533.0" 93 | }, 94 | { 95 | "number": "9", 96 | "opts": { 97 | "hostname": "h9", 98 | "ip": "10.2.0.2", 99 | "nodeNum": 9, 100 | "sched": "host" 101 | }, 102 | "x": "649.0", 103 | "y": "528.0" 104 | }, 105 | { 106 | "number": "10", 107 | "opts": { 108 | "hostname": "h10", 109 | "ip": "10.2.0.3", 110 | "nodeNum": 10, 111 | "sched": "host" 112 | }, 113 | "x": "719.0", 114 | "y": "527.0" 115 | }, 116 | { 117 | "number": "11", 118 | "opts": { 119 | "hostname": "h11", 120 | "ip": "10.2.1.2", 121 | "nodeNum": 11, 122 | "sched": "host" 123 | }, 124 | "x": "798.0", 125 | "y": "525.0" 126 | }, 127 | { 128 | "number": "15", 129 | "opts": { 130 | "hostname": "h15", 131 | "ip": "10.3.1.2", 132 | "nodeNum": 15, 133 | "sched": "host" 134 | }, 135 | "x": "1087.0", 136 | "y": "517.0" 137 | }, 138 | { 139 | "number": "12", 140 | "opts": { 141 | "hostname": "h12", 142 | "ip": "10.2.1.3", 143 | "nodeNum": 12, 144 | "sched": "host" 145 | }, 146 | "x": "873.0", 147 | "y": "524.0" 148 | }, 149 | { 150 | "number": "14", 151 | "opts": { 152 | "hostname": "h14", 153 | "ip": "10.3.0.3", 154 | "nodeNum": 14, 155 | "sched": "host" 156 | }, 157 | "x": "1012.0", 158 | "y": "515.0" 159 | }, 160 | { 161 | "number": "13", 162 | "opts": { 163 | "hostname": "h13", 164 | "ip": "10.3.0.2", 165 | "nodeNum": 13, 166 | "sched": "host" 167 | }, 168 | "x": "944.0", 169 | "y": "526.0" 170 | }, 171 | { 172 | "number": "2", 173 | "opts": { 174 | "hostname": "h2", 175 | "ip": "10.0.0.3", 176 | "nodeNum": 2, 177 | "sched": "host" 178 | }, 179 | "x": "121.0", 180 | "y": "542.0" 181 | }, 182 | { 183 | "number": "16", 184 | "opts": { 185 | "hostname": "h16", 186 | "ip": "10.3.1.3", 187 | "nodeNum": 16, 188 | "sched": "host" 189 | }, 190 | "x": "1174.0", 191 | "y": "517.0" 192 | }, 193 | { 194 | "number": "1", 195 | "opts": { 196 | "hostname": "h1", 197 | "ip": "10.0.0.2", 198 | "nodeNum": 1, 199 | "sched": "host" 200 | }, 201 | "x": "44.0", 202 | "y": "544.0" 203 | } 204 | ], 205 | "links": [ 206 | { 207 | "dest": "h1", 208 | "opts": {}, 209 | "src": "s1" 210 | }, 211 | { 212 | "dest": "h2", 213 | "opts": {}, 214 | "src": "s1" 215 | }, 216 | { 217 | "dest": "h3", 218 | "opts": {}, 219 | "src": "s2" 220 | }, 221 | { 222 | "dest": "h4", 223 | "opts": {}, 224 | "src": "s2" 225 | }, 226 | { 227 | "dest": "h5", 228 | "opts": {}, 229 | "src": "s3" 230 | }, 231 | { 232 | "dest": "h6", 233 | "opts": {}, 234 | "src": "s3" 235 | }, 236 | { 237 | "dest": "h7", 238 | "opts": {}, 239 | "src": "s4" 240 | }, 241 | { 242 | "dest": "h8", 243 | "opts": {}, 244 | "src": "s4" 245 | }, 246 | { 247 | "dest": "h9", 248 | "opts": {}, 249 | "src": "s5" 250 | }, 251 | { 252 | "dest": "h10", 253 | "opts": {}, 254 | "src": "s5" 255 | }, 256 | { 257 | "dest": "h11", 258 | "opts": {}, 259 | "src": "s6" 260 | }, 261 | { 262 | "dest": "h12", 263 | "opts": {}, 264 | "src": "s6" 265 | }, 266 | { 267 | "dest": "h13", 268 | "opts": {}, 269 | "src": "s7" 270 | }, 271 | { 272 | "dest": "h14", 273 | "opts": {}, 274 | "src": "s7" 275 | }, 276 | { 277 | "dest": "h15", 278 | "opts": {}, 279 | "src": "s8" 280 | }, 281 | { 282 | "dest": "h16", 283 | "opts": {}, 284 | "src": "s8" 285 | }, 286 | { 287 | "dest": "s1", 288 | "opts": {}, 289 | "src": "s9" 290 | }, 291 | { 292 | "dest": "s2", 293 | "opts": {}, 294 | "src": "s9" 295 | }, 296 | { 297 | "dest": "s10", 298 | "opts": {}, 299 | "src": "s1" 300 | }, 301 | { 302 | "dest": "s2", 303 | "opts": {}, 304 | "src": "s10" 305 | }, 306 | { 307 | "dest": "s3", 308 | "opts": {}, 309 | "src": "s11" 310 | }, 311 | { 312 | "dest": "s12", 313 | "opts": {}, 314 | "src": "s3" 315 | }, 316 | { 317 | "dest": "s4", 318 | "opts": {}, 319 | "src": "s11" 320 | }, 321 | { 322 | "dest": "s4", 323 | "opts": {}, 324 | "src": "s12" 325 | }, 326 | { 327 | "dest": "s5", 328 | "opts": {}, 329 | "src": "s13" 330 | }, 331 | { 332 | "dest": "s5", 333 | "opts": {}, 334 | "src": "s14" 335 | }, 336 | { 337 | "dest": "s6", 338 | "opts": {}, 339 | "src": "s13" 340 | }, 341 | { 342 | "dest": "s6", 343 | "opts": {}, 344 | "src": "s14" 345 | }, 346 | { 347 | "dest": "s7", 348 | "opts": {}, 349 | "src": "s15" 350 | }, 351 | { 352 | "dest": "s8", 353 | "opts": {}, 354 | "src": "s15" 355 | }, 356 | { 357 | "dest": "s7", 358 | "opts": {}, 359 | "src": "s16" 360 | }, 361 | { 362 | "dest": "s8", 363 | "opts": {}, 364 | "src": "s16" 365 | }, 366 | { 367 | "dest": "s9", 368 | "opts": {}, 369 | "src": "s17" 370 | }, 371 | { 372 | "dest": "s18", 373 | "opts": {}, 374 | "src": "s9" 375 | }, 376 | { 377 | "dest": "s17", 378 | "opts": {}, 379 | "src": "s11" 380 | }, 381 | { 382 | "dest": "s18", 383 | "opts": {}, 384 | "src": "s11" 385 | }, 386 | { 387 | "dest": "s17", 388 | "opts": {}, 389 | "src": "s13" 390 | }, 391 | { 392 | "dest": "s17", 393 | "opts": {}, 394 | "src": "s15" 395 | }, 396 | { 397 | "dest": "s19", 398 | "opts": {}, 399 | "src": "s10" 400 | }, 401 | { 402 | "dest": "s20", 403 | "opts": {}, 404 | "src": "s10" 405 | }, 406 | { 407 | "dest": "s19", 408 | "opts": {}, 409 | "src": "s12" 410 | }, 411 | { 412 | "dest": "s20", 413 | "opts": {}, 414 | "src": "s12" 415 | }, 416 | { 417 | "dest": "s19", 418 | "opts": {}, 419 | "src": "s14" 420 | }, 421 | { 422 | "dest": "s20", 423 | "opts": {}, 424 | "src": "s14" 425 | }, 426 | { 427 | "dest": "s18", 428 | "opts": {}, 429 | "src": "s15" 430 | }, 431 | { 432 | "dest": "s19", 433 | "opts": {}, 434 | "src": "s16" 435 | }, 436 | { 437 | "dest": "s20", 438 | "opts": {}, 439 | "src": "s16" 440 | }, 441 | { 442 | "dest": "s13", 443 | "opts": {}, 444 | "src": "s18" 445 | } 446 | ], 447 | "switches": [ 448 | { 449 | "number": "16", 450 | "opts": { 451 | "controllers": [], 452 | "hostname": "s16", 453 | "netflow": "0", 454 | "nodeNum": 16, 455 | "sflow": "0", 456 | "switchIP": "10.3.3.1", 457 | "switchType": "default" 458 | }, 459 | "x": "1126.0", 460 | "y": "265.0" 461 | }, 462 | { 463 | "number": "3", 464 | "opts": { 465 | "controllers": [], 466 | "hostname": "s3", 467 | "netflow": "0", 468 | "nodeNum": 3, 469 | "sflow": "0", 470 | "switchIP": "10.1.0.1", 471 | "switchType": "default" 472 | }, 473 | "x": "366.0", 474 | "y": "392.0" 475 | }, 476 | { 477 | "number": "2", 478 | "opts": { 479 | "controllers": [], 480 | "hostname": "s2", 481 | "netflow": "0", 482 | "nodeNum": 2, 483 | "sflow": "0", 484 | "switchIP": "10.0.1.1", 485 | "switchType": "default" 486 | }, 487 | "x": "223.0", 488 | "y": "403.0" 489 | }, 490 | { 491 | "number": "20", 492 | "opts": { 493 | "controllers": [], 494 | "hostname": "s20", 495 | "netflow": "0", 496 | "nodeNum": 20, 497 | "sflow": "0", 498 | "switchIP": "10.4.2.2", 499 | "switchType": "default" 500 | }, 501 | "x": "996.0", 502 | "y": "72.0" 503 | }, 504 | { 505 | "number": "17", 506 | "opts": { 507 | "controllers": [], 508 | "hostname": "s17", 509 | "netflow": "0", 510 | "nodeNum": 17, 511 | "sflow": "0", 512 | "switchIP": "10.4.1.1", 513 | "switchType": "default" 514 | }, 515 | "x": "115.0", 516 | "y": "112.0" 517 | }, 518 | { 519 | "number": "5", 520 | "opts": { 521 | "controllers": [], 522 | "hostname": "s5", 523 | "netflow": "0", 524 | "nodeNum": 5, 525 | "sflow": "0", 526 | "switchIP": "10.2.0.1", 527 | "switchType": "default" 528 | }, 529 | "x": "667.0", 530 | "y": "403.0" 531 | }, 532 | { 533 | "number": "18", 534 | "opts": { 535 | "controllers": [], 536 | "hostname": "s18", 537 | "netflow": "0", 538 | "nodeNum": 18, 539 | "sflow": "0", 540 | "switchIP": "10.4.1.2", 541 | "switchType": "default" 542 | }, 543 | "x": "392.0", 544 | "y": "90.0" 545 | }, 546 | { 547 | "number": "6", 548 | "opts": { 549 | "controllers": [], 550 | "hostname": "s6", 551 | "netflow": "0", 552 | "nodeNum": 6, 553 | "sflow": "0", 554 | "switchIP": "10.2.1.1", 555 | "switchType": "default" 556 | }, 557 | "x": "829.0", 558 | "y": "400.0" 559 | }, 560 | { 561 | "number": "7", 562 | "opts": { 563 | "controllers": [], 564 | "hostname": "s7", 565 | "netflow": "0", 566 | "nodeNum": 7, 567 | "sflow": "0", 568 | "switchIP": "10.3.0.1", 569 | "switchType": "default" 570 | }, 571 | "x": "965.0", 572 | "y": "401.0" 573 | }, 574 | { 575 | "number": "9", 576 | "opts": { 577 | "controllers": [], 578 | "hostname": "s9", 579 | "netflow": "0", 580 | "nodeNum": 9, 581 | "sflow": "0", 582 | "switchIP": "10.0.2.1", 583 | "switchType": "default" 584 | }, 585 | "x": "92.0", 586 | "y": "276.0" 587 | }, 588 | { 589 | "number": "8", 590 | "opts": { 591 | "controllers": [], 592 | "hostname": "s8", 593 | "netflow": "0", 594 | "nodeNum": 8, 595 | "sflow": "0", 596 | "switchIP": "10.3.1.1", 597 | "switchType": "default" 598 | }, 599 | "x": "1133.0", 600 | "y": "383.0" 601 | }, 602 | { 603 | "number": "10", 604 | "opts": { 605 | "controllers": [], 606 | "hostname": "s10", 607 | "netflow": "0", 608 | "nodeNum": 10, 609 | "sflow": "0", 610 | "switchIP": "10.0.3.1", 611 | "switchType": "default" 612 | }, 613 | "x": "205.0", 614 | "y": "278.0" 615 | }, 616 | { 617 | "number": "4", 618 | "opts": { 619 | "controllers": [], 620 | "hostname": "s4", 621 | "netflow": "0", 622 | "nodeNum": 4, 623 | "sflow": "0", 624 | "switchIP": "10.1.1.1", 625 | "switchType": "default" 626 | }, 627 | "x": "516.0", 628 | "y": "389.0" 629 | }, 630 | { 631 | "number": "12", 632 | "opts": { 633 | "controllers": [], 634 | "hostname": "s12", 635 | "netflow": "0", 636 | "nodeNum": 12, 637 | "sflow": "0", 638 | "switchIP": "10.1.3.1", 639 | "switchType": "default" 640 | }, 641 | "x": "489.0", 642 | "y": "292.0" 643 | }, 644 | { 645 | "number": "13", 646 | "opts": { 647 | "controllers": [], 648 | "hostname": "s13", 649 | "netflow": "0", 650 | "nodeNum": 13, 651 | "sflow": "0", 652 | "switchIP": "10.2.2.1", 653 | "switchType": "default" 654 | }, 655 | "x": "691.0", 656 | "y": "281.0" 657 | }, 658 | { 659 | "number": "19", 660 | "opts": { 661 | "controllers": [], 662 | "hostname": "s19", 663 | "netflow": "0", 664 | "nodeNum": 19, 665 | "sflow": "0", 666 | "switchIP": "10.4.2.1", 667 | "switchType": "default" 668 | }, 669 | "x": "720.0", 670 | "y": "109.0" 671 | }, 672 | { 673 | "number": "1", 674 | "opts": { 675 | "controllers": [], 676 | "hostname": "s1", 677 | "netflow": "0", 678 | "nodeNum": 1, 679 | "sflow": "0", 680 | "switchIP": "10.0.0.1", 681 | "switchType": "default" 682 | }, 683 | "x": "66.0", 684 | "y": "410.0" 685 | }, 686 | { 687 | "number": "14", 688 | "opts": { 689 | "controllers": [], 690 | "hostname": "s14", 691 | "netflow": "0", 692 | "nodeNum": 14, 693 | "sflow": "0", 694 | "switchIP": "10.2.3.1", 695 | "switchType": "default" 696 | }, 697 | "x": "816.0", 698 | "y": "273.0" 699 | }, 700 | { 701 | "number": "11", 702 | "opts": { 703 | "controllers": [], 704 | "hostname": "s11", 705 | "netflow": "0", 706 | "nodeNum": 11, 707 | "sflow": "0", 708 | "switchIP": "10.1.2.1", 709 | "switchType": "default" 710 | }, 711 | "x": "382.0", 712 | "y": "302.0" 713 | }, 714 | { 715 | "number": "15", 716 | "opts": { 717 | "controllers": [], 718 | "hostname": "s15", 719 | "netflow": "0", 720 | "nodeNum": 15, 721 | "sflow": "0", 722 | "switchIP": "10.3.2.1", 723 | "switchType": "default" 724 | }, 725 | "x": "959.0", 726 | "y": "269.0" 727 | } 728 | ], 729 | "version": "2" 730 | } -------------------------------------------------------------------------------- /dataresearch/threetier9newhost_5s.csv: -------------------------------------------------------------------------------- 1 | 20211105013016,1636101016,10.2.1.3,0.713 2 | 20211105013017,1636101017,10.2.1.3,0.132 3 | 20211105013018,1636101018,10.2.1.3,0.146 4 | 20211105013019,1636101019,10.2.1.3,0.231 5 | 20211105013020,1636101020,10.2.1.3,0.153 6 | 20211105013021,1636101021,10.2.1.3,0.144 7 | 20211105013022,1636101022,10.2.1.3,0.169 8 | 20211105013023,1636101023,10.2.1.3,0.233 9 | 20211105013024,1636101024,10.2.1.3,0.151 10 | 20211105013025,1636101025,10.2.1.3,0.185 11 | 20211105013026,1636101026,10.2.1.3,0.186 12 | 20211105013027,1636101027,10.2.1.3,0.148 13 | 20211105013028,1636101028,10.2.1.3,0.196 14 | 20211105013029,1636101029,10.2.1.3,0.184 15 | 20211105013030,1636101030,10.2.1.3,0.187 16 | 20211105013031,1636101031,10.2.1.3,0.147 17 | 20211105013032,1636101032,10.2.1.3,0.123 18 | 20211105013033,1636101033,10.2.1.3,0.151 19 | 20211105013034,1636101034,10.2.1.3,0.131 20 | 20211105013035,1636101035,10.2.1.3,0.151 21 | 20211105013036,1636101036,10.2.1.3,0.159 22 | 20211105013037,1636101037,10.2.1.3,0.132 23 | 20211105013038,1636101038,10.2.1.3,0.146 24 | 20211105013039,1636101039,10.2.1.3,0.143 25 | 20211105013040,1636101040,10.2.1.3,0.159 26 | 20211105013041,1636101041,10.2.1.3,0.144 27 | 20211105013042,1636101042,10.2.1.3,0.130 28 | 20211105013043,1636101043,10.2.1.3,0.130 29 | 20211105013044,1636101044,10.2.1.3,0.145 30 | 20211105013045,1636101045,10.2.1.3,0.133 31 | 20211105013046,1636101046,10.2.1.3,0.145 32 | 20211105013047,1636101047,10.2.1.3,0.163 33 | 20211105013048,1636101048,10.2.1.3,0.146 34 | 20211105013049,1636101049,10.2.1.3,0.145 35 | 20211105013050,1636101050,10.2.1.3,0.148 36 | 20211105013051,1636101051,10.2.1.3,0.143 37 | 20211105013052,1636101052,10.2.1.3,0.155 38 | 20211105013053,1636101053,10.2.1.3,0.153 39 | 20211105013054,1636101054,10.2.1.3,0.158 40 | 20211105013055,1636101055,10.2.1.3,0.141 41 | 20211105013056,1636101056,10.2.1.3,0.150 42 | 20211105013057,1636101057,10.2.1.3,0.147 43 | 20211105013058,1636101058,10.2.1.3,0.145 44 | 20211105013059,1636101059,10.2.1.3,0.163 45 | 20211105013100,1636101060,10.2.1.3,0.118 46 | 20211105013101,1636101061,10.2.1.3,0.164 47 | 20211105013102,1636101062,10.2.1.3,0.134 48 | 20211105013103,1636101063,10.2.1.3,0.146 49 | 20211105013104,1636101064,10.2.1.3,0.147 50 | 20211105013105,1636101065,10.2.1.3,0.345 51 | 20211105013106,1636101066,10.2.1.3,0.148 52 | 20211105013107,1636101067,10.2.1.3,0.129 53 | 20211105013108,1636101068,10.2.1.3,0.150 54 | 20211105013109,1636101069,10.2.1.3,0.185 55 | 20211105013110,1636101070,10.2.1.3,0.129 56 | 20211105013111,1636101071,10.2.1.3,0.147 57 | 20211105013112,1636101072,10.2.1.3,0.147 58 | 20211105013113,1636101073,10.2.1.3,0.136 59 | 20211105013114,1636101074,10.2.1.3,0.179 60 | 20211105013115,1636101075,10.2.1.3,0.200 61 | 20211105013116,1636101076,10.2.1.3,0.167 62 | 20211105013117,1636101077,10.2.1.3,0.175 63 | 20211105013118,1636101078,10.2.1.3,0.101 64 | 20211105013119,1636101079,10.2.1.3,0.107 65 | 20211105013120,1636101080,10.2.1.3,0.134 66 | 20211105013121,1636101081,10.2.1.3,0.148 67 | 20211105013122,1636101082,10.2.1.3,0.132 68 | 20211105013123,1636101083,10.2.1.3,0.146 69 | 20211105013124,1636101084,10.2.1.3,0.146 70 | 20211105013125,1636101085,10.2.1.3,0.149 71 | 20211105013126,1636101086,10.2.1.3,0.145 72 | 20211105013127,1636101087,10.2.1.3,0.133 73 | 20211105013128,1636101088,10.2.1.3,0.150 74 | 20211105013129,1636101089,10.2.1.3,0.191 75 | 20211105013130,1636101090,10.2.1.3,0.147 76 | 20211105013131,1636101091,10.2.1.3,0.149 77 | 20211105013132,1636101092,10.2.1.3,0.132 78 | 20211105013133,1636101093,10.2.1.3,0.148 79 | 20211105013134,1636101094,10.2.1.3,0.159 80 | 20211105013135,1636101095,10.2.1.3,0.151 81 | 20211105013136,1636101096,10.2.1.3,0.175 82 | 20211105013137,1636101097,10.2.1.3,0.157 83 | 20211105013138,1636101098,10.2.1.3,0.284 84 | 20211105013139,1636101099,10.2.1.3,0.148 85 | 20211105013140,1636101100,10.2.1.3,0.150 86 | 20211105013141,1636101101,10.2.1.3,0.149 87 | 20211105013142,1636101102,10.2.1.3,0.131 88 | 20211105013143,1636101103,10.2.1.3,0.132 89 | 20211105013144,1636101104,10.2.1.3,0.147 90 | 20211105013145,1636101105,10.2.1.3,0.153 91 | 20211105013146,1636101106,10.2.1.3,0.127 92 | 20211105013147,1636101107,10.2.1.3,0.197 93 | 20211105013148,1636101108,10.2.1.3,0.132 94 | 20211105013149,1636101109,10.2.1.3,0.148 95 | 20211105013150,1636101110,10.2.1.3,0.160 96 | 20211105013151,1636101111,10.2.1.3,0.148 97 | 20211105013152,1636101112,10.2.1.3,0.134 98 | 20211105013153,1636101113,10.2.1.3,0.168 99 | 20211105013154,1636101114,10.2.1.3,0.095 100 | 20211105013155,1636101115,10.2.1.3,0.144 101 | 20211105013156,1636101116,10.2.1.3,0.157 102 | 20211105013157,1636101117,10.2.1.3,0.149 103 | 20211105013158,1636101118,10.2.1.3,0.135 104 | 20211105013159,1636101119,10.2.1.3,0.153 105 | 20211105013200,1636101120,10.2.1.3,0.182 106 | 20211105013201,1636101121,10.2.1.3,0.147 107 | 20211105013202,1636101122,10.2.1.3,0.132 108 | 20211105013203,1636101123,10.2.1.3,0.145 109 | 20211105013204,1636101124,10.2.1.3,0.153 110 | 20211105013205,1636101125,10.2.1.3,0.128 111 | 20211105013206,1636101126,10.2.1.3,0.150 112 | 20211105013207,1636101127,10.2.1.3,0.132 113 | 20211105013208,1636101128,10.2.1.3,0.179 114 | 20211105013209,1636101129,10.2.1.3,0.146 115 | 20211105013210,1636101130,10.2.1.3,0.177 116 | 20211105013211,1636101131,10.2.1.3,0.239 117 | 20211105013212,1636101132,10.2.1.3,0.166 118 | 20211105013213,1636101133,10.2.1.3,0.137 119 | 20211105013214,1636101134,10.2.1.3,0.152 120 | 20211105013215,1636101135,10.2.1.3,0.173 121 | 20211105013216,1636101136,10.2.1.3,0.173 122 | 20211105013217,1636101137,10.2.1.3,0.205 123 | 20211105013218,1636101138,10.2.1.3,0.144 124 | 20211105013219,1636101139,10.2.1.3,0.151 125 | 20211105013220,1636101140,10.2.1.3,0.148 126 | 20211105013221,1636101141,10.2.1.3,0.234 127 | 20211105013222,1636101142,10.2.1.3,0.120 128 | 20211105013223,1636101143,10.2.1.3,0.157 129 | 20211105013224,1636101144,10.2.1.3,0.153 130 | 20211105013225,1636101145,10.2.1.3,0.149 131 | 20211105013226,1636101146,10.2.1.3,0.132 132 | 20211105013227,1636101147,10.2.1.3,0.109 133 | 20211105013228,1636101148,10.2.1.3,0.150 134 | 20211105013229,1636101149,10.2.1.3,0.133 135 | 20211105013230,1636101150,10.2.1.3,0.135 136 | 20211105013231,1636101151,10.2.1.3,0.151 137 | 20211105013232,1636101152,10.2.1.3,0.110 138 | 20211105013233,1636101153,10.2.1.3,0.142 139 | 20211105013234,1636101154,10.2.1.3,0.130 140 | 20211105013235,1636101155,10.2.1.3,0.128 141 | 20211105013236,1636101156,10.2.1.3,0.125 142 | 20211105013237,1636101157,10.2.1.3,0.115 143 | 20211105013238,1636101158,10.2.1.3,0.132 144 | 20211105013239,1636101159,10.2.1.3,0.129 145 | 20211105013240,1636101160,10.2.1.3,0.135 146 | 20211105013241,1636101161,10.2.1.3,0.130 147 | 20211105013242,1636101162,10.2.1.3,0.116 148 | 20211105013243,1636101163,10.2.1.3,0.161 149 | 20211105013244,1636101164,10.2.1.3,0.130 150 | 20211105013245,1636101165,10.2.1.3,0.134 151 | 20211105013246,1636101166,10.2.1.3,0.133 152 | 20211105013247,1636101167,10.2.1.3,0.131 153 | 20211105013248,1636101168,10.2.1.3,0.132 154 | 20211105013249,1636101169,10.2.1.3,0.151 155 | 20211105013250,1636101170,10.2.1.3,0.150 156 | 20211105013251,1636101171,10.2.1.3,0.149 157 | 20211105013252,1636101172,10.2.1.3,0.109 158 | 20211105013253,1636101173,10.2.1.3,0.135 159 | 20211105013254,1636101174,10.2.1.3,0.130 160 | 20211105013255,1636101175,10.2.1.3,0.130 161 | 20211105013256,1636101176,10.2.1.3,0.197 162 | 20211105013257,1636101177,10.2.1.3,0.116 163 | 20211105013258,1636101178,10.2.1.3,0.166 164 | 20211105013259,1636101179,10.2.1.3,0.132 165 | 20211105013300,1636101180,10.2.1.3,0.186 166 | 20211105013301,1636101181,10.2.1.3,0.179 167 | 20211105013302,1636101182,10.2.1.3,0.178 168 | 20211105013303,1636101183,10.2.1.3,0.134 169 | 20211105013304,1636101184,10.2.1.3,0.135 170 | 20211105013305,1636101185,10.2.1.3,0.133 171 | 20211105013306,1636101186,10.2.1.3,0.129 172 | 20211105013307,1636101187,10.2.1.3,0.111 173 | 20211105013308,1636101188,10.2.1.3,0.135 174 | 20211105013309,1636101189,10.2.1.3,0.147 175 | 20211105013310,1636101190,10.2.1.3,0.148 176 | 20211105013311,1636101191,10.2.1.3,0.147 177 | 20211105013312,1636101192,10.2.1.3,0.143 178 | 20211105013313,1636101193,10.2.1.3,0.152 179 | 20211105013314,1636101194,10.2.1.3,0.146 180 | 20211105013315,1636101195,10.2.1.3,0.140 181 | 20211105013316,1636101196,10.2.1.3,0.203 182 | 20211105013317,1636101197,10.2.1.3,0.196 183 | 20211105013318,1636101198,10.2.1.3,0.139 184 | 20211105013319,1636101199,10.2.1.3,0.125 185 | 20211105013320,1636101200,10.2.1.3,0.152 186 | 20211105013321,1636101201,10.2.1.3,0.147 187 | 20211105013322,1636101202,10.2.1.3,0.135 188 | 20211105013323,1636101203,10.2.1.3,0.132 189 | 20211105013324,1636101204,10.2.1.3,0.150 190 | 20211105013325,1636101205,10.2.1.3,0.148 191 | 20211105013326,1636101206,10.2.1.3,0.209 192 | 20211105013327,1636101207,10.2.1.3,0.129 193 | 20211105013328,1636101208,10.2.1.3,0.141 194 | 20211105013329,1636101209,10.2.1.3,0.160 195 | 20211105013330,1636101210,10.2.1.3,0.217 196 | 20211105013331,1636101211,10.2.1.3,0.148 197 | 20211105013332,1636101212,10.2.1.3,0.131 198 | 20211105013333,1636101213,10.2.1.3,0.160 199 | 20211105013334,1636101214,10.2.1.3,0.185 200 | 20211105013335,1636101215,10.2.1.3,0.130 201 | 20211105013336,1636101216,10.2.1.3,0.196 202 | 20211105013337,1636101217,10.2.1.3,0.131 203 | 20211105013338,1636101218,10.2.1.3,0.155 204 | 20211105013339,1636101219,10.2.1.3,0.148 205 | 20211105013340,1636101220,10.2.1.3,0.175 206 | 20211105013341,1636101221,10.2.1.3,0.150 207 | 20211105013342,1636101222,10.2.1.3,0.150 208 | 20211105013343,1636101223,10.2.1.3,0.149 209 | 20211105013344,1636101224,10.2.1.3,0.142 210 | 20211105013345,1636101225,10.2.1.3,0.151 211 | 20211105013346,1636101226,10.2.1.3,0.149 212 | 20211105013347,1636101227,10.2.1.3,0.146 213 | 20211105013348,1636101228,10.2.1.3,0.146 214 | 20211105013349,1636101229,10.2.1.3,0.147 215 | 20211105013350,1636101230,10.2.1.3,0.128 216 | 20211105013351,1636101231,10.2.1.3,0.175 217 | 20211105013352,1636101232,10.2.1.3,0.183 218 | 20211105013353,1636101233,10.2.1.3,0.149 219 | 20211105013354,1636101234,10.2.1.3,0.145 220 | 20211105013355,1636101235,10.2.1.3,0.157 221 | 20211105013356,1636101236,10.2.1.3,0.146 222 | 20211105013357,1636101237,10.2.1.3,0.147 223 | 20211105013358,1636101238,10.2.1.3,0.163 224 | 20211105013359,1636101239,10.2.1.3,0.148 225 | 20211105013400,1636101240,10.2.1.3,0.191 226 | 20211105013401,1636101241,10.2.1.3,0.198 227 | 20211105013402,1636101242,10.2.1.3,0.150 228 | 20211105013403,1636101243,10.2.1.3,0.129 229 | 20211105013404,1636101244,10.2.1.3,0.150 230 | 20211105013405,1636101245,10.2.1.3,0.132 231 | 20211105013406,1636101246,10.2.1.3,0.145 232 | 20211105013407,1636101247,10.2.1.3,0.146 233 | 20211105013408,1636101248,10.2.1.3,0.151 234 | 20211105013409,1636101249,10.2.1.3,0.154 235 | 20211105013410,1636101250,10.2.1.3,0.261 236 | 20211105013411,1636101251,10.2.1.3,0.159 237 | 20211105013412,1636101252,10.2.1.3,0.169 238 | 20211105013413,1636101253,10.2.1.3,0.198 239 | 20211105013414,1636101254,10.2.1.3,0.149 240 | 20211105013415,1636101255,10.2.1.3,0.152 241 | 20211105013416,1636101256,10.2.1.3,0.194 242 | 20211105013417,1636101257,10.2.1.3,0.145 243 | 20211105013418,1636101258,10.2.1.3,0.145 244 | 20211105013419,1636101259,10.2.1.3,0.164 245 | 20211105013420,1636101260,10.2.1.3,0.186 246 | 20211105013421,1636101261,10.2.1.3,0.154 247 | 20211105013422,1636101262,10.2.1.3,0.150 248 | 20211105013423,1636101263,10.2.1.3,0.146 249 | 20211105013424,1636101264,10.2.1.3,0.148 250 | 20211105013425,1636101265,10.2.1.3,0.151 251 | 20211105013426,1636101266,10.2.1.3,0.157 252 | 20211105013427,1636101267,10.2.1.3,0.150 253 | 20211105013428,1636101268,10.2.1.3,0.147 254 | 20211105013429,1636101269,10.2.1.3,0.148 255 | 20211105013430,1636101270,10.2.1.3,0.138 256 | 20211105013431,1636101271,10.2.1.3,0.147 257 | 20211105013432,1636101272,10.2.1.3,0.148 258 | 20211105013433,1636101273,10.2.1.3,0.148 259 | 20211105013434,1636101274,10.2.1.3,0.149 260 | 20211105013435,1636101275,10.2.1.3,0.131 261 | 20211105013436,1636101276,10.2.1.3,0.146 262 | 20211105013437,1636101277,10.2.1.3,0.135 263 | 20211105013438,1636101278,10.2.1.3,0.130 264 | 20211105013439,1636101279,10.2.1.3,0.210 265 | 20211105013440,1636101280,10.2.1.3,0.156 266 | 20211105013441,1636101281,10.2.1.3,0.173 267 | 20211105013442,1636101282,10.2.1.3,0.135 268 | 20211105013443,1636101283,10.2.1.3,0.150 269 | 20211105013444,1636101284,10.2.1.3,0.133 270 | 20211105013445,1636101285,10.2.1.3,0.151 271 | 20211105013446,1636101286,10.2.1.3,0.134 272 | 20211105013447,1636101287,10.2.1.3,0.133 273 | 20211105013448,1636101288,10.2.1.3,0.148 274 | 20211105013449,1636101289,10.2.1.3,0.150 275 | 20211105013450,1636101290,10.2.1.3,0.152 276 | 20211105013451,1636101291,10.2.1.3,0.154 277 | 20211105013452,1636101292,10.2.1.3,0.153 278 | 20211105013453,1636101293,10.2.1.3,0.132 279 | 20211105013454,1636101294,10.2.1.3,0.151 280 | 20211105013455,1636101295,10.2.1.3,0.150 281 | 20211105013456,1636101296,10.2.1.3,0.150 282 | 20211105013457,1636101297,10.2.1.3,0.130 283 | 20211105013458,1636101298,10.2.1.3,0.134 284 | 20211105013459,1636101299,10.2.1.3,0.167 285 | 20211105013500,1636101300,10.2.1.3,0.130 286 | 20211105013501,1636101301,10.2.1.3,0.127 287 | 20211105013502,1636101302,10.2.1.3,0.144 288 | 20211105013503,1636101303,10.2.1.3,0.146 289 | 20211105013504,1636101304,10.2.1.3,0.148 290 | 20211105013505,1636101305,10.2.1.3,0.149 291 | 20211105013506,1636101306,10.2.1.3,0.149 292 | 20211105013507,1636101307,10.2.1.3,0.150 293 | 20211105013508,1636101308,10.2.1.3,0.146 294 | 20211105013509,1636101309,10.2.1.3,0.154 295 | 20211105013510,1636101310,10.2.1.3,0.145 296 | 20211105013511,1636101311,10.2.1.3,0.150 297 | 20211105013512,1636101312,10.2.1.3,0.148 298 | 20211105013513,1636101313,10.2.1.3,0.152 299 | 20211105013514,1636101314,10.2.1.3,0.132 300 | 20211105013515,1636101315,10.2.1.3,0.135 301 | 20211105013516,1636101316,10.2.1.3,0.130 302 | 20211105013517,1636101317,10.2.1.3,0.128 303 | 20211105013518,1636101318,10.2.1.3,0.155 304 | 20211105013519,1636101319,10.2.1.3,0.139 305 | 20211105013520,1636101320,10.2.1.3,0.155 306 | 20211105013521,1636101321,10.2.1.3,0.133 307 | 20211105013522,1636101322,10.2.1.3,0.129 308 | 20211105013523,1636101323,10.2.1.3,0.128 309 | 20211105013524,1636101324,10.2.1.3,0.149 310 | 20211105013525,1636101325,10.2.1.3,0.130 311 | 20211105013526,1636101326,10.2.1.3,0.152 312 | 20211105013527,1636101327,10.2.1.3,0.267 313 | 20211105013528,1636101328,10.2.1.3,0.143 314 | 20211105013529,1636101329,10.2.1.3,0.227 315 | 20211105013530,1636101330,10.2.1.3,0.150 316 | 20211105013531,1636101331,10.2.1.3,0.152 317 | 20211105013532,1636101332,10.2.1.3,0.307 318 | 20211105013533,1636101333,10.2.1.3,0.152 319 | 20211105013534,1636101334,10.2.1.3,0.150 320 | 20211105013535,1636101335,10.2.1.3,0.149 321 | 20211105013536,1636101336,10.2.1.3,0.175 322 | 20211105013537,1636101337,10.2.1.3,0.132 323 | 20211105013538,1636101338,10.2.1.3,0.154 324 | 20211105013539,1636101339,10.2.1.3,0.166 325 | 20211105013540,1636101340,10.2.1.3,0.173 326 | 20211105013541,1636101341,10.2.1.3,0.157 327 | 20211105013542,1636101342,10.2.1.3,0.132 328 | 20211105013543,1636101343,10.2.1.3,0.146 329 | 20211105013544,1636101344,10.2.1.3,0.149 330 | 20211105013545,1636101345,10.2.1.3,0.144 331 | 20211105013546,1636101346,10.2.1.3,0.131 332 | 20211105013547,1636101347,10.2.1.3,0.165 333 | 20211105013548,1636101348,10.2.1.3,0.148 334 | 20211105013549,1636101349,10.2.1.3,0.149 335 | 20211105013550,1636101350,10.2.1.3,0.147 336 | 20211105013551,1636101351,10.2.1.3,0.175 337 | 20211105013552,1636101352,10.2.1.3,0.151 338 | 20211105013553,1636101353,10.2.1.3,0.149 339 | 20211105013554,1636101354,10.2.1.3,0.184 340 | 20211105013555,1636101355,10.2.1.3,0.148 341 | 20211105013556,1636101356,10.2.1.3,0.153 342 | 20211105013557,1636101357,10.2.1.3,0.129 343 | 20211105013558,1636101358,10.2.1.3,0.146 344 | 20211105013559,1636101359,10.2.1.3,0.179 345 | 20211105013600,1636101360,10.2.1.3,0.150 346 | 20211105013601,1636101361,10.2.1.3,0.168 347 | 20211105013602,1636101362,10.2.1.3,0.147 348 | 20211105013603,1636101363,10.2.1.3,0.137 349 | 20211105013604,1636101364,10.2.1.3,0.147 350 | 20211105013605,1636101365,10.2.1.3,0.150 351 | 20211105013606,1636101366,10.2.1.3,0.152 352 | 20211105013607,1636101367,10.2.1.3,0.131 353 | 20211105013608,1636101368,10.2.1.3,0.182 354 | 20211105013609,1636101369,10.2.1.3,0.148 355 | 20211105013610,1636101370,10.2.1.3,0.134 356 | 20211105013611,1636101371,10.2.1.3,0.152 357 | 20211105013612,1636101372,10.2.1.3,0.151 358 | 20211105013613,1636101373,10.2.1.3,0.147 359 | 20211105013614,1636101374,10.2.1.3,0.148 360 | 20211105013615,1636101375,10.2.1.3,0.130 361 | 20211105013616,1636101376,10.2.1.3,0.150 362 | 20211105013617,1636101377,10.2.1.3,0.128 363 | 20211105013618,1636101378,10.2.1.3,0.109 364 | 20211105013619,1636101379,10.2.1.3,0.129 365 | 20211105013620,1636101380,10.2.1.3,0.160 366 | 20211105013621,1636101381,10.2.1.3,0.164 367 | 20211105013622,1636101382,10.2.1.3,0.173 368 | 20211105013623,1636101383,10.2.1.3,0.127 369 | 20211105013624,1636101384,10.2.1.3,0.151 370 | 20211105013625,1636101385,10.2.1.3,0.151 371 | 20211105013626,1636101386,10.2.1.3,0.131 372 | 20211105013627,1636101387,10.2.1.3,0.152 373 | 20211105013628,1636101388,10.2.1.3,0.149 374 | 20211105013629,1636101389,10.2.1.3,0.138 375 | 20211105013630,1636101390,10.2.1.3,0.153 376 | 20211105013631,1636101391,10.2.1.3,0.132 377 | 20211105013632,1636101392,10.2.1.3,0.134 378 | 20211105013633,1636101393,10.2.1.3,0.135 379 | 20211105013634,1636101394,10.2.1.3,0.163 380 | 20211105013635,1636101395,10.2.1.3,0.145 381 | 20211105013636,1636101396,10.2.1.3,0.183 382 | 20211105013637,1636101397,10.2.1.3,0.129 383 | 20211105013638,1636101398,10.2.1.3,0.130 384 | 20211105013639,1636101399,10.2.1.3,0.139 385 | 20211105013640,1636101400,10.2.1.3,0.155 386 | 20211105013641,1636101401,10.2.1.3,0.151 387 | 20211105013642,1636101402,10.2.1.3,0.137 388 | 20211105013643,1636101403,10.2.1.3,0.145 389 | 20211105013644,1636101404,10.2.1.3,0.146 390 | 20211105013645,1636101405,10.2.1.3,0.145 391 | 20211105013646,1636101406,10.2.1.3,0.149 392 | 20211105013647,1636101407,10.2.1.3,0.131 393 | 20211105013648,1636101408,10.2.1.3,0.147 394 | 20211105013649,1636101409,10.2.1.3,0.154 395 | 20211105013650,1636101410,10.2.1.3,0.148 396 | 20211105013651,1636101411,10.2.1.3,0.133 397 | 20211105013652,1636101412,10.2.1.3,0.152 398 | 20211105013653,1636101413,10.2.1.3,0.133 399 | 20211105013654,1636101414,10.2.1.3,0.149 400 | 20211105013655,1636101415,10.2.1.3,0.133 401 | 20211105013656,1636101416,10.2.1.3,0.146 402 | 20211105013657,1636101417,10.2.1.3,0.129 403 | 20211105013658,1636101418,10.2.1.3,0.130 404 | 20211105013659,1636101419,10.2.1.3,0.133 405 | 20211105013700,1636101420,10.2.1.3,0.133 406 | 20211105013701,1636101421,10.2.1.3,0.147 407 | 20211105013702,1636101422,10.2.1.3,0.152 408 | 20211105013703,1636101423,10.2.1.3,0.197 409 | 20211105013704,1636101424,10.2.1.3,0.147 410 | 20211105013705,1636101425,10.2.1.3,0.145 411 | 20211105013706,1636101426,10.2.1.3,0.151 412 | 20211105013707,1636101427,10.2.1.3,0.130 413 | 20211105013708,1636101428,10.2.1.3,0.106 414 | 20211105013709,1636101429,10.2.1.3,0.130 415 | 20211105013710,1636101430,10.2.1.3,0.128 416 | 20211105013711,1636101431,10.2.1.3,0.151 417 | 20211105013712,1636101432,10.2.1.3,0.136 418 | 20211105013713,1636101433,10.2.1.3,0.151 419 | 20211105013714,1636101434,10.2.1.3,0.152 420 | 20211105013715,1636101435,10.2.1.3,0.150 421 | 20211105013716,1636101436,10.2.1.3,0.147 422 | 20211105013717,1636101437,10.2.1.3,0.129 423 | 20211105013718,1636101438,10.2.1.3,0.137 424 | 20211105013719,1636101439,10.2.1.3,0.136 425 | 20211105013720,1636101440,10.2.1.3,0.167 426 | 20211105013721,1636101441,10.2.1.3,0.139 427 | 20211105013722,1636101442,10.2.1.3,0.154 428 | 20211105013723,1636101443,10.2.1.3,0.132 429 | 20211105013724,1636101444,10.2.1.3,0.158 430 | 20211105013725,1636101445,10.2.1.3,0.093 431 | 20211105013726,1636101446,10.2.1.3,0.111 432 | 20211105013727,1636101447,10.2.1.3,0.241 433 | 20211105013728,1636101448,10.2.1.3,0.153 434 | 20211105013729,1636101449,10.2.1.3,0.149 435 | 20211105013730,1636101450,10.2.1.3,0.148 436 | 20211105013731,1636101451,10.2.1.3,0.148 437 | 20211105013732,1636101452,10.2.1.3,0.148 438 | 20211105013733,1636101453,10.2.1.3,0.150 439 | 20211105013734,1636101454,10.2.1.3,0.150 440 | 20211105013735,1636101455,10.2.1.3,0.148 441 | 20211105013736,1636101456,10.2.1.3,0.152 442 | 20211105013737,1636101457,10.2.1.3,0.132 443 | 20211105013738,1636101458,10.2.1.3,0.152 444 | 20211105013739,1636101459,10.2.1.3,0.185 445 | 20211105013740,1636101460,10.2.1.3,0.146 446 | 20211105013741,1636101461,10.2.1.3,0.148 447 | 20211105013742,1636101462,10.2.1.3,0.152 448 | 20211105013743,1636101463,10.2.1.3,0.163 449 | 20211105013744,1636101464,10.2.1.3,0.154 450 | 20211105013745,1636101465,10.2.1.3,0.152 451 | 20211105013746,1636101466,10.2.1.3,0.195 452 | 20211105013747,1636101467,10.2.1.3,0.144 453 | 20211105013748,1636101468,10.2.1.3,0.151 454 | 20211105013749,1636101469,10.2.1.3,0.147 455 | 20211105013750,1636101470,10.2.1.3,0.147 456 | 20211105013751,1636101471,10.2.1.3,0.147 457 | 20211105013752,1636101472,10.2.1.3,0.146 458 | 20211105013753,1636101473,10.2.1.3,0.146 459 | 20211105013754,1636101474,10.2.1.3,0.143 460 | 20211105013755,1636101475,10.2.1.3,0.129 461 | 20211105013756,1636101476,10.2.1.3,0.258 462 | 20211105013757,1636101477,10.2.1.3,0.146 463 | 20211105013758,1636101478,10.2.1.3,0.185 464 | 20211105013759,1636101479,10.2.1.3,0.157 465 | 20211105013800,1636101480,10.2.1.3,0.243 466 | 20211105013801,1636101481,10.2.1.3,0.151 467 | 20211105013802,1636101482,10.2.1.3,0.155 468 | 20211105013803,1636101483,10.2.1.3,0.160 469 | 20211105013804,1636101484,10.2.1.3,0.265 470 | 20211105013805,1636101485,10.2.1.3,0.129 471 | 20211105013806,1636101486,10.2.1.3,0.127 472 | 20211105013807,1636101487,10.2.1.3,0.146 473 | 20211105013808,1636101488,10.2.1.3,0.192 474 | 20211105013809,1636101489,10.2.1.3,0.153 475 | 20211105013810,1636101490,10.2.1.3,0.158 476 | 20211105013811,1636101491,10.2.1.3,0.149 477 | 20211105013812,1636101492,10.2.1.3,0.064 478 | 20211105013813,1636101493,10.2.1.3,0.145 479 | 20211105013814,1636101494,10.2.1.3,0.154 480 | 20211105013815,1636101495,10.2.1.3,0.146 481 | 20211105013816,1636101496,10.2.1.3,0.150 482 | 20211105013817,1636101497,10.2.1.3,0.144 483 | 20211105013818,1636101498,10.2.1.3,0.152 484 | 20211105013819,1636101499,10.2.1.3,0.147 485 | 20211105013820,1636101500,10.2.1.3,0.150 486 | 20211105013821,1636101501,10.2.1.3,0.148 487 | 488 | --------------------------------------------------------------------------------