0

I use POX controller with mininet. To detect the topology I'm listening to many events and was success to get links and switch information.

Now I would like to know how to get all host information (port in host that connected to the switch and the host ID ect...

I tried host tracker module but I get only Mac and IP address.

engbarakat
  • 39
  • 10

1 Answers1

1

With Host Tracker you can have the info you want. Add the module

import pox.host_tracker

Than add a listener in your init`

core.host_tracker.addListenerByName("HostEvent", self._handle_HostEvent)  # listen to host_tracker

and later on implement the listener method

def _handle_HostEvent(self, event):
        """
        Listen to host_tracker events, fired up every time a host is up or down
        To fire up we must issue a pingall from mininet cli. 
        Args:
            event: HostEvent listening to core.host_tracker
        Returns: nada
        """
        macaddr = event.entry.macaddr.toStr()
        port = event.entry.port
        # your code here

As you see in the comment unlike the switch event listener which is fired up on start as soon as the switch is connected to the controller, to get host info we must have data running in our network. Issue a ping all in your mininet topology to get all the info. Remeber if you have a custom controller code to flood the packets in the start to get all hosts in your topology.

In order to get IDs of the hosts you should start your mininet topology with the --mac arg. This way mac addresses of hosts are like 00:00:00:00:01 last 2 numbers represent the ID of the host.

  • Thanks alot. But how I get the ID or Host name?. Also is port here the switch port or host port? as what I see in host tracker source code that they listen to packet in event which mean this port is in_port which belong to the switch – engbarakat May 11 '17 at 21:37
  • I tracked down pox source code and the port info here comes from packetIn event caught by host_tracker.py which means it comes from a switch. Also I had to do some editing in source code to get the IP address as the event fired before updating the IP address information. – engbarakat May 12 '17 at 17:57
  • I will change my scheme so i will not use the host port as I guess it is not usable in routing etc... – engbarakat May 12 '17 at 18:10