1

Currently, I'm writing an application on top of Ryu, the Open-source OpenFlow Controller.

To create an OF-Config connection (or OVSDB connection), I think I have to get the IP address of each switch connected to the Ryu controller. However, I cannot find the API that converts the Datapath object or datapath id to the IP address of the switch.

So, if there is such an API, I want to know about it. If not, I'm looking forward to receiving some comments about the way to make the connections without the IP addresses.

Byungjoon Lee
  • 913
  • 6
  • 18

3 Answers3

1

Byungjoon are you using mininet?

If you are, all the switches are instantiated with the localhost ip address (This is mininet's default behavior). The controller distinguishes between switches using the tcp port.

As far as I know, you only need to know the dpid of the switch in order to send OF messages. This is what the sample l2-learning switch is doing: https://github.com/osrg/ryu/blob/master/ryu/app/simple_switch_13.py

I am also try to communicate with the switches using Ryu controller. I am using the above sample as my basic code and adding on top of it. It is not done yet (so you might see some bugs) but it's good starting point. Here is the link: https://github.com/Ehsan70/RyuApps/blob/master/l2.py

Ehsan Ab
  • 679
  • 5
  • 16
1
@set_ev_cls(event.EventSwitchEnter)
def switch_features_handler(self, ev):
    address = ev.switch.dp.address
    dpid = ev.switch.dp.id

"address" is a tuple of (ip_address, port) and "dpid" is the datapath id.

Myth
  • 26
  • 2
1

for latest version of ryu, you should use following code.

@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def _switch_features_handler(self, ev):
    print(ev.msg.datapath.address)
qin
  • 1,627
  • 15
  • 22