Ejemplo n.º 1
0
 def connect_to_switches(self):
     for p4rtswitch, data in self.topo.get_p4switches().items():
         device_id = self.topo.get_p4switch_id(p4rtswitch)
         grpc_port = self.topo.get_grpc_port(p4rtswitch)
         p4rt_path = data['p4rt_path']
         json_path = data['json_path']
         self.controllers[p4rtswitch] = SimpleSwitchP4RuntimeAPI(
             device_id, grpc_port, p4rt_path=p4rt_path, json_path=json_path)
Ejemplo n.º 2
0
 def connect_to_switches(self):
     """
     Connects to all the switches in the topology and saves them
     in self.controllers.
     """
     for p4rtswitch, data in self.topo.get_p4switches().items():
         device_id = self.topo.get_p4switch_id(p4rtswitch)
         grpc_port = self.topo.get_grpc_port(p4rtswitch)
         p4rt_path = data['p4rt_path']
         json_path = data['json_path']
         self.controllers[p4rtswitch] = SimpleSwitchP4RuntimeAPI(
             device_id, grpc_port, p4rt_path=p4rt_path, json_path=json_path)
Ejemplo n.º 3
0
 def __init__(self, sw_name):
     self.topo = load_topo('topology.json')
     self.sw_name = sw_name
     self.cpu_port = self.topo.get_cpu_port_index(self.sw_name)
     device_id = self.topo.get_p4switch_id(sw_name)
     grpc_port = self.topo.get_grpc_port(sw_name)
     sw_data = self.topo.get_p4rtswitches()[sw_name]
     self.controller = SimpleSwitchP4RuntimeAPI(
         device_id,
         grpc_port,
         p4rt_path=sw_data['p4rt_path'],
         json_path=sw_data['json_path'])
     self.init()
Ejemplo n.º 4
0
from p4utils.utils.helper import load_topo
from p4utils.utils.sswitch_p4runtime_API import SimpleSwitchP4RuntimeAPI

topo = load_topo('topology.json')
controllers = {}

for switch, data in topo.get_p4rtswitches().items():
    controllers[switch] = SimpleSwitchP4RuntimeAPI(data['device_id'],
                                                   data['grpc_port'],
                                                   p4rt_path=data['p4rt_path'],
                                                   json_path=data['json_path'])

controller = controllers['s1']

controller.table_add('dmac', 'forward', ['00:00:0a:00:00:01'], ['1'])
controller.table_add('dmac', 'forward', ['00:00:0a:00:00:02'], ['2'])
controller.table_add('dmac', 'forward', ['00:00:0a:00:00:03'], ['3'])
controller.table_add('dmac', 'forward', ['00:00:0a:00:00:04'], ['4'])