2

I have created a topology in mininet. I want to get the dpid or name of a switch from the host it's connected to using xterm or mininet's python API. I looked it up on google but couldn't find anything.

Thanks in advance.

1 Answers1

1

from the Mininet CLI, you can do:

py net.getNodeByName("s1").dpid

Example:

root@raspberrypi:~# mn
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 1 switches
s1 ...
*** Starting CLI:
mininet> py net.getNodeByName("s1").dpid
0000000000000001
mininet>

from the python API as explained in the official documentation

print(switch_node.dpid)

Or you can directly see in your host machine or using xterm with:

bash -c 'ovs-ofctl show s1|grep dpid'
Giuseppe
  • 658
  • 1
  • 6
  • 14
  • Provided no information is there any way the xterm can fetch the switchID. Maybe something like filtering out cmd("links") result and then finding the appropriate switch to which the current host is connected. – Hanzala Jamash Jun 01 '20 at 07:37
  • from xterm you should be able to see the switches using: ovs-vsctl list-br to have the switch list, than you can use ovs-ofctl show SWITCH_NAME to check the dpid – Giuseppe Jun 01 '20 at 15:27