faucetsdn / ryu

Ryu component-based software defined networking framework
https://ryu-sdn.org
Apache License 2.0
1.51k stars 1.16k forks source link

Update simple_switch_13.py #148

Open c1x1x00xxPentium opened 3 years ago

c1x1x00xxPentium commented 3 years ago

Dear Community, I made a few changes to make it easier to understand the value of the variable 'mac_to_port' and also provide an example of how to custom OFPFlowMod.

self.logger.info(json.dumps(self.mac_to_port, sort_keys=True, indent=4))

def add_flow(self, datapath, priority, tableID=0, idle=0, hard=0, match, actions, buffer_id=None):
      ofproto = datapath.ofproto
      parser = datapath.ofproto_parser

      if buffer_id:
          mod = parser.OFPFlowMod(datapath=datapath, buffer_id=buffer_id,
                                  priority=priority, match=match,
                                  idle_timeout=idle, hard_timeout=hard,
                                  instructions=inst, table_id=tableID)
      else:
          mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
                                  idle_timeout=idle, hard_timeout=hard,
                                  match=match, instructions=inst
                                  table_id=tableID)
      datapath.send_msg(mod)

Thank you