Commit a510de82 authored by Ricardo Fonseca's avatar Ricardo Fonseca

Made host connections explicit in network manager

parent 67d202a5
......@@ -42,6 +42,11 @@ def pre_start_config( mr, extra_args, local_varanus_home ):
topo.add_ring_local_vir_host( 'Cntrl_Center', 1, '192.168.10.103/24', 1, 'Core5' )
topo.add_ring_local_vir_host( 'Attacker', 1, '192.168.10.104/24', 1, 'A1', hidden=True )
topo.add_host_connection( 'SCADA_Client', 'Cntrl_Center' )
topo.add_host_connection( 'RTU', 'Cntrl_Center' )
topo.add_host_connection( 'Cntrl_Center', 'SCADA_Client' )
topo.add_host_connection( 'Cntrl_Center', 'RTU' )
# Collectors
topo.add_ring_local_vir_collector( 'c1', 1, 1 )
......
import argparse
from collections import OrderedDict
import json
import os
import subprocess
......@@ -61,6 +62,8 @@ class VaranusTopo( object ):
self.hosts = {} # NodeConfig mapped by name
self.collectors = {} # NodeConfig mapped by name
self.host_connections = OrderedDict() # list of host names orderly mapped by host name
# ================ CONTROLLERS ================
......@@ -190,6 +193,16 @@ class VaranusTopo( object ):
self.__add_host_link( h_name, h_port_cfg, sw_name, sw_port_cfg )
def add_host_connection( self, src_h_name, dest_h_name ):
src_h_name = as_oneof( src_h_name, self.hosts.keys(), valname='src_h_name', containername='host names' )
dest_h_name = as_oneof( dest_h_name, self.hosts.keys(), valname='dest_h_name', containername='host names' )
if src_h_name != dest_h_name:
src_conns = self.host_connections.setdefault( src_h_name, [] )
if dest_h_name not in src_conns:
src_conns.append( dest_h_name )
# ================ COLLECTORS ================
def add_local_collector( self, c_name, cid, **params ):
......@@ -475,7 +488,7 @@ class VaranusTopo( object ):
f.write( 'net.varanus.sdncontroller.flowdiscovery.FlowDiscoveryModule.staticFlowedConnections=' )
if multiline: f.write( '\n' )
VaranusTopo.__dump_json( f, self.__get_host_connections(), multiline=multiline )
VaranusTopo.__dump_json( f, self.__get_all_flowed_connections(), multiline=multiline )
f.write( '\n' )
f.write( 'net.varanus.sdncontroller.alias.AliasModule.switchAliases=' )
......@@ -506,11 +519,11 @@ class VaranusTopo( object ):
return dict( ( '{:#x}'.format( s.dpid ), name ) for name, s in self.switches.iteritems() )
def __get_host_connections( self ):
def __get_all_flowed_connections( self ):
conns = []
for h1 in self.hosts.itervalues():
for h1_name, h1 in self.hosts.iteritems():
for h1p in VaranusTopo.__get_peered_ports( h1 ):
for h2 in filter( lambda h : h is not h1 , self.hosts.itervalues() ):
for h2 in self.__get_connected_hosts( h1_name ):
for h2p in VaranusTopo.__get_peered_ports( h2 ):
p1 = h1p.get_peer()
p2 = h2p.get_peer()
......@@ -525,6 +538,10 @@ class VaranusTopo( object ):
return dict( ( str( c.cid ), VaranusTopo.__get_ifaces_mapping( c ) ) for c in self.collectors.itervalues() )
def __get_connected_hosts( self, h_name ):
return ( self.hosts[name] for name in self.host_connections.get( h_name, () ) )
@staticmethod
def __get_ifaces_mapping( node ):
return dict( ( '{:#x}'.format( p.get_peer().node.dpid ), p.name ) for p in VaranusTopo.__get_peered_ports( node ) )
......@@ -532,7 +549,7 @@ class VaranusTopo( object ):
@staticmethod
def __get_peered_ports( node ):
return filter( lambda p : p.has_peer(), node.get_ports() )
return ( p for p in node.get_ports() if p.has_peer() )
@staticmethod
......
net.varanus.sdncontroller.monitoring.MonitoringModule.collectorhandler_samplingOFPort=32768
net.varanus.sdncontroller.flowdiscovery.FlowDiscoveryModule.staticFlowedConnections=["0x100000003[5] >> 0x100000008[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.101, ipv4_dst = 192.168.10.102]","0x100000003[5] >> 0x10000000b[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.101, ipv4_dst = 192.168.10.103]","0x100000003[5] >> 0x100000002[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.101, ipv4_dst = 192.168.10.104]","0x100000008[5] >> 0x100000003[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.102, ipv4_dst = 192.168.10.101]","0x100000008[5] >> 0x10000000b[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.102, ipv4_dst = 192.168.10.103]","0x100000008[5] >> 0x100000002[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.102, ipv4_dst = 192.168.10.104]","0x10000000b[5] >> 0x100000003[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.103, ipv4_dst = 192.168.10.101]","0x10000000b[5] >> 0x100000008[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.103, ipv4_dst = 192.168.10.102]","0x10000000b[5] >> 0x100000002[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.103, ipv4_dst = 192.168.10.104]","0x100000002[5] >> 0x100000003[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.104, ipv4_dst = 192.168.10.101]","0x100000002[5] >> 0x100000008[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.104, ipv4_dst = 192.168.10.102]","0x100000002[5] >> 0x10000000b[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.104, ipv4_dst = 192.168.10.103]"]
net.varanus.sdncontroller.flowdiscovery.FlowDiscoveryModule.staticFlowedConnections=["0x100000003[5] >> 0x10000000b[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.101, ipv4_dst = 192.168.10.103]","0x100000008[5] >> 0x10000000b[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.102, ipv4_dst = 192.168.10.103]","0x10000000b[5] >> 0x100000003[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.103, ipv4_dst = 192.168.10.101]","0x10000000b[5] >> 0x100000008[5] | v14[eth_type = 0x0800, ipv4_src = 192.168.10.103, ipv4_dst = 192.168.10.102]"]
net.varanus.sdncontroller.alias.AliasModule.switchAliases={"0x100000001" : "Core1","0x100000002" : "A1","0x100000003" : "A2","0x100000004" : "A3","0x100000005" : "Core2","0x100000006" : "Core3","0x100000007" : "B1","0x100000008" : "B2","0x100000009" : "B3","0x10000000a" : "Core4","0x10000000b" : "Core5"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment