Skip to content

Commit

Permalink
Veriflow 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MuLx10 committed Nov 17, 2020
1 parent b50d914 commit 5f1caf6
Show file tree
Hide file tree
Showing 14 changed files with 963 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

from VeriFlow.Network import Network

ROUTE_VIEW = 1;
BIT_BUCKET = 2;


def main():
print("Enter network configuration file name (eg.: file.txt):");
# filename = input("> ");
filename = "Topo1.txt"
network = Network();
network.parseNetworkFromFile(filename);
generatedECs = network.getECsFromTrie();
network.checkWellformedness();
network.log(generatedECs);
while True:
print(" ");
print("Add rule by entering A#switchIP-rulePrefix-nextHopIP (eg.A#127.0.0.1-128.0.0.0/2-127.0.0.2)");
print("Remove rule by entering R#switchIP-rulePrefix-nextHopIP (eg.R#127.0.0.1-128.0.0.0/2-127.0.0.2)");
print("To exit type exit");

affectedEcs = set()
inputline = input('> ')
if (inputline.startswith("A")):
affectedEcs = network.addRuleFromString(inputline[2:]);
network.checkWellformedness(affectedEcs);
elif (inputline.startswith("R")):
affectedEcs = network.deleteRuleFromString(inputline[2:]);
network.checkWellformedness(affectedEcs);
elif ("exit" in inputline):
break;
else:
print("Wrong input format!");
continue;

print("");
network.log(affectedEcs);

if __name__ == '__main__':
main()
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# VeriFlow

## Requirements
- Python 3

## Running


```bash
$ python Main.py
```

## Sample Run

```bash
$ python Main.py
Enter network configuration file name (eg.: file.txt):
> Topo1.txt

Number of ECs: 9
Number of affected ECs: 9
Network is well-formed (No property violations)

Add rule by entering A#switchIP-rulePrefix-nextHopIP (eg.A#127.0.0.1-128.0.0.0/2-127.0.0.2)
Remove rule by entering R#switchIP-rulePrefix-nextHopIP (eg.R#127.0.0.1-128.0.0.0/2-127.0.0.2)
To exit type exit
> A#127.0.0.1-128.0.0.0/2-127.0.0.2

Number of ECs: 9
Number of affected ECs: 2
Network is well-formed (No property violations)

Add rule by entering A#switchIP-rulePrefix-nextHopIP (eg.A#127.0.0.1-128.0.0.0/2-127.0.0.2)
Remove rule by entering R#switchIP-rulePrefix-nextHopIP (eg.R#127.0.0.1-128.0.0.0/2-127.0.0.2)
To exit type exit
> exit
```








54 changes: 54 additions & 0 deletions Topo1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
S#
127.0.0.1:127.0.0.11
127.0.0.2:127.0.0.11,127.0.0.3
127.0.0.3:127.0.0.5,127.0.0.4,127.0.0.2,127.0.0.11,127.0.0.7,127.0.0.6
127.0.0.4:127.0.0.3,127.0.0.7,127.0.0.6,127.0.0.11
127.0.0.5:127.0.0.3
127.0.0.6:127.0.0.3,127.0.0.4
127.0.0.7:127.0.0.3,127.0.0.4,127.0.0.9
127.0.0.8:127.0.0.11
127.0.0.9:127.0.0.7,127.0.0.11
127.0.0.10:127.0.0.11
127.0.0.11:127.0.0.1,127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.8,127.0.0.9,127.0.0.10
H#
127.0.0.101:127.0.0.5
127.0.0.102:127.0.0.1
127.0.0.103:127.0.0.10
127.0.0.104:127.0.0.9
127.0.0.105:127.0.0.8
127.0.0.106:127.0.0.7
127.0.0.107:127.0.0.6
127.0.0.108:127.0.0.4
R#
127.0.0.10-0.0.0.0/2-127.0.0.11
127.0.0.11-0.0.0.0/2-127.0.0.2
127.0.0.2-0.0.0.0/2-127.0.0.3
127.0.0.3-0.0.0.0/2-127.0.0.5
127.0.0.10-96.0.0.0/4-127.0.0.11
127.0.0.11-96.0.0.0/4-127.0.0.3
127.0.0.3-96.0.0.0/4-127.0.0.4
127.0.0.4-128.0.0.0/3-127.0.0.6
127.0.0.9-144.0.0.0/4-127.0.0.11
127.0.0.11-144.0.0.0/4-127.0.0.3
127.0.0.3-144.0.0.0/4-127.0.0.7
127.0.0.4-192.0.0.0/3-127.0.0.7
127.0.0.7-192.0.0.0/3-127.0.0.9
127.0.0.4-64.0.0.0/3-127.0.0.11
127.0.0.11-64.0.0.0/3-127.0.0.8
127.0.0.1-128.0.0.0/3-127.0.0.11
127.0.0.11-128.0.0.0/3-127.0.0.3
127.0.0.3-128.0.0.0/3-127.0.0.6
E!



-0.0.0.0/2- 00*
-96.0.0.0/4- 0110*
-128.0.0.0/3- 100*
-144.0.0.0/4- 1001*
-192.0.0.0/3- 110*
-64.0.0.0/3- 010*




54 changes: 54 additions & 0 deletions Topo2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
S#
127.0.0.1:127.0.0.11
127.0.0.2:127.0.0.11,127.0.0.3
127.0.0.3:127.0.0.5,127.0.0.4,127.0.0.2,127.0.0.11,127.0.0.7,127.0.0.6
127.0.0.4:127.0.0.3,127.0.0.7,127.0.0.6,127.0.0.11
127.0.0.5:127.0.0.3
127.0.0.6:127.0.0.3,127.0.0.4
127.0.0.7:127.0.0.3,127.0.0.4,127.0.0.9
127.0.0.8:127.0.0.11
127.0.0.9:127.0.0.7,127.0.0.11
127.0.0.10:127.0.0.11
127.0.0.11:127.0.0.1,127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.8,127.0.0.9,127.0.0.10
H#
127.0.0.101:127.0.0.5
127.0.0.102:127.0.0.1
127.0.0.103:127.0.0.10
127.0.0.104:127.0.0.9
127.0.0.105:127.0.0.8
127.0.0.106:127.0.0.7
127.0.0.107:127.0.0.6
127.0.0.108:127.0.0.4
R#
127.0.0.10-0.0.0.0/2-127.0.0.11
127.0.0.11-0.0.0.0/2-127.0.0.2
127.0.0.2-0.0.0.0/2-127.0.0.3
127.0.0.3-0.0.0.0/2-127.0.0.11
127.0.0.10-96.0.0.0/4-127.0.0.11
127.0.0.11-96.0.0.0/4-127.0.0.3
127.0.0.3-96.0.0.0/4-127.0.0.4
127.0.0.4-128.0.0.0/3-127.0.0.6
127.0.0.9-144.0.0.0/4-127.0.0.11
127.0.0.11-144.0.0.0/4-127.0.0.3
127.0.0.3-144.0.0.0/4-127.0.0.7
127.0.0.4-192.0.0.0/3-127.0.0.7
127.0.0.7-192.0.0.0/3-127.0.0.9
127.0.0.4-64.0.0.0/3-127.0.0.11
127.0.0.11-64.0.0.0/3-127.0.0.8
127.0.0.1-128.0.0.0/3-127.0.0.11
127.0.0.11-128.0.0.0/3-127.0.0.3
127.0.0.3-128.0.0.0/3-127.0.0.6
E!



-0.0.0.0/2- 00*
-96.0.0.0/4- 0110*
-128.0.0.0/3- 100*
-144.0.0.0/4- 1001*
-192.0.0.0/3- 110*
-64.0.0.0/3- 010*




2 changes: 2 additions & 0 deletions VeriFlow/ErrorType.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LOOP = 0
BLACK_HOLE = 1
18 changes: 18 additions & 0 deletions VeriFlow/ForwardingGraph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ForwardingGraph(object):
"""docstring for ForwardingGraph"""
def __init__(self):
super(ForwardingGraph, self).__init__()
self.forwardingGraph = set()

def addToGraph(self, nextHopId):
self.forwardingGraph.add(nextHopId)

def getForwardingGraph(self):
return self.forwardingGraph

def setForwardingGraph(self, forwardingGraph):
self.forwardingGraph = forwardingGraph

def contains(self, id):
return id in self.forwardingGraph

19 changes: 19 additions & 0 deletions VeriFlow/Host.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Host(object):
"""docstring for Host"""
def __init__(self):
super(Host, self).__init__()
self.id = None
self.switchId = None

def getId(self):
return self.id

def setId(self, id):
self.id = id

def getSwitchId(self):
return self.switchId

def setSwitchId(self, switchId):
self.switchId = switchId

34 changes: 34 additions & 0 deletions VeriFlow/Interval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Interval(object):
"""docstring for Interval"""
def __init__(self, left, right):
super(Interval, self).__init__()
self.left = left
self.right = right

def getRight(self):
return self.right

def setRight(self, right):
self.right = right

def getLeft(self):
return self.left

def setLeft(self, left):
self.left = left


def hashCode(self):
return Objects.hash(left, right)

def equals(self, obj) :
if obj is None:
return False
try:
eq = self.left == obj.left and self.right == obj.right
except Exception as e:
eq = False
return eq

def toString(self):
return "[" + left + "," + right + ")"
Loading

0 comments on commit 5f1caf6

Please sign in to comment.