Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Commit

Permalink
new_topo
Browse files Browse the repository at this point in the history
  • Loading branch information
minmit committed Mar 13, 2016
1 parent 4d9d55e commit a61d69d
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 5 deletions.
26 changes: 25 additions & 1 deletion local_mininet/extratopos.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,29 @@ def __init__(self):
self.addLink('h3', 's3')
self.addLink('h4', 's3')

class NSDITopo(Topo):
def __init__(self):
super(NSDITopo, self).__init__()

for i in range(1, 10):
self.addSwitch("s%d" % i)

for i in range(1, 9):
self.addHost("h%d" % i, ip = "10.0.0.%d" % i)

links = [(1, 2), (2, 3), (3, 4), (4, 5),
(1, 7), (7, 8), (8, 9), (9, 5),
(2, 6), (4, 6), (7, 6), (9, 6)]

for i, j in links:
self.addLink("s%d" % i, "s%d" % j)

for i in range(1, 5):
self.addLink("h%d" % i, "s1")

for i in range(5, 9):
self.addLink("h%d" % i, "s5")

topos = { 'triangle': ( lambda: CycleTopo(3,3) ),
'square': (lambda: CycleTopo(4,4)),
'chain': ChainTopo,
Expand All @@ -459,6 +482,7 @@ def __init__(self):
'gateway3_ns': ThreeSwitchGatewayTopoNoSubnets,
'simple_prefix': SimplePrefixTopo,
'stanford' : StanfordTopo,
'demo' : DemoTopo
'demo' : DemoTopo,
'nsdi' : NSDITopo
}

78 changes: 74 additions & 4 deletions pyretic/examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

TEN_IP = '10.0.0.0/24'
EDGE = match(switch = 1, port = 3) | match(switch = 1, port = 4) | \
match(switch = 3, port = 3) | match(switch = 3, port = 4)
match(switch = 1, port = 5) | match(switch = 1, port = 6) | \
match(switch = 5, port = 3) | match(switch = 5, port = 4) | \
match(switch = 5, port = 5) | match(switch = 5, port = 6)

TEN_SUBNET = match(srcip = TEN_IP, dstip = TEN_IP, ethtype=2048)

def forwarding_policy():
def forwarding_policy_small():
return if_(match(dstip = '10.0.0.1'),
if_(match(switch = 1), fwd(3),
if_(match(switch = 2), fwd(1),
Expand All @@ -39,6 +42,68 @@ def forwarding_policy():
drop)))),
drop))))

def forwarding_policy():
last_hop = if_(match(switch = 5),
if_(match(dstip = "10.0.0.5"), fwd(3),
if_(match(dstip = "10.0.0.6"), fwd(4),
if_(match(dstip = "10.0.0.7"), fwd(5),
if_(match(dstip = "10.0.0.8"), fwd(6),
drop)))), drop)

pol = if_(match(dstip = '10.0.0.1'),
if_(match(switch = 1), fwd(3),
if_(match(switch = 2), fwd(1),
if_(match(switch = 3), fwd(1),
if_(match(switch = 4), fwd(1),
if_(match(switch = 5), fwd(1),
drop))))),
if_(match(dstip = '10.0.0.2'),
if_(match(switch = 1), fwd(4),
if_(match(switch = 2), fwd(1),
if_(match(switch = 4), fwd(3),
if_(match(switch = 5), fwd(1),
if_(match(switch = 6), fwd(1),
drop))))),
if_(match(dstip = '10.0.0.3'),
if_(match(switch = 1), fwd(5),
if_(match(switch = 7), fwd(1),
if_(match(switch = 6), fwd(3),
if_(match(switch = 9), fwd(3),
if_(match(switch = 5), fwd(2),
drop))))),
if_(match(dstip = '10.0.0.4'),
if_(match(switch = 1), fwd(6),
if_(match(switch = 7), fwd(1),
if_(match(switch = 8), fwd(1),
if_(match(switch = 9), fwd(1),
if_(match(switch = 5), fwd(2),
drop))))),
if_(match(srcip = '10.0.0.1'),
if_(match(switch = 1), fwd(1),
if_(match(switch = 2), fwd(2),
if_(match(switch = 3), fwd(2),
if_(match(switch = 4), fwd(2),
last_hop)))),
if_(match(srcip = '10.0.0.2'),
if_(match(switch = 1), fwd(1),
if_(match(switch = 2), fwd(3),
if_(match(switch = 4), fwd(2),
if_(match(switch = 6), fwd(2),
last_hop)))),
if_(match(srcip = '10.0.0.3'),
if_(match(switch = 1), fwd(2),
if_(match(switch = 7), fwd(3),
if_(match(switch = 6), fwd(4),
if_(match(switch = 9), fwd(2),
last_hop)))),
if_(match(srcip = '10.0.0.4'),
if_(match(switch = 1), fwd(2),
if_(match(switch = 7), fwd(2),
if_(match(switch = 8), fwd(2),
if_(match(switch = 9), fwd(2),
last_hop)))),
last_hop))))))))
return pol

def count_callback(test_num):
def actual_callback(counts):
Expand All @@ -49,7 +114,8 @@ def actual_callback(counts):
first_hop_stat = {}
second_hop_stat = {}
third_hop_stat = {}
stat_dict_list = [first_hop_stat, second_hop_stat, third_hop_stat]
fourth_hop_stat = {}
stat_dict_list = [first_hop_stat, second_hop_stat, third_hop_stat, fourth_hop_stat]
stat_lock = threading.Lock()
threshold = 0
pull_cnt = 0
Expand All @@ -65,6 +131,9 @@ def print_gb_stats():
print "Third Hop"
print_stat_dict(third_hop_stat)
print "************"
print "Fourth Hop"
print_stat_dict(fourth_hop_stat)
print "************"

def aggr_callback(test_num, id_list):
def actual_callback(agg, res):
Expand All @@ -75,6 +144,7 @@ def actual_callback(agg, res):
with stat_lock:
stat_dict[sw_list] = res
pull_cnt += 1
print pull_cnt
if pull_cnt == threshold:
print_gb_stats()
pull_cnt = 0
Expand Down Expand Up @@ -137,7 +207,7 @@ def up_and_down(q):

def per_switch_hop(pred, cnt):

fvlist = {'switch': range(1,5)}
fvlist = {'switch': range(1,10)}

resq = None

Expand Down

0 comments on commit a61d69d

Please sign in to comment.