I am creating a topology with two switches and each switch has 4 hosts(the
code for creating the topology is included). Then I have a script for pox
learning which process each received packet and try to figure out each host
is connected to which one of the switches(the code is included).
When I ping two hosts inside the same switch, the code is working
perfectly, but if I do "n1 ping n6 -c1"
it does not return the correct switches. For example this is the result:(I
can also include the complete code)
host 1
switch 1
[ 1. 0. 0. 0. 0. 0. 0. 0.]
host 1
switch 2
[ 2. 0. 0. 0. 0. 0. 0. 0.]
host 6
switch 2
[ 2. 0. 0. 0. 0. 2. 0. 0.]
host 6
switch 1
[ 2. 0. 0. 0. 0. 1. 0. 0.]
Creating topology:
>
> Class MyTopo(Topo):
> def __init__(self, enable_all = True):
> setLogLevel('info')
> super(MyTopo, self).__init__()
>
> self.switch1 = self.addSwitch('s1')
> self.switch2 = self.addSwitch('s2')
> n = 0
> for h in range(4):
> n += 1
> host = self.addHost('n%s' % (n))
> self.addLink(host, self.switch1)
> for h in range(4):
> n += 1
> host = self.addHost('n%s' % (n))
> self.addLink(host, self.switch2)
> self.addLink(self.switch1, self.switch2)
>
Processing packets:
>
> packet = event.parsed
> ip = packet.find('ipv4')
> if ip is not None:
> parts = (str(ip.srcip)).split(".")
> lp = parts[3]
> log.info("host %s" % lp)
> log.info("switch %s" % event.dpid)
> hosts[int(lp) - 1] = event.dpid
>