<div dir="ltr"><div><div><br></div><div>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).<br>
<br></div><div>When I ping two hosts inside the same switch, the code is working perfectly, but if I do "n1 ping n6 -c1"<br></div><div>it does not return the correct switches. For example this is the result:(I can also include the complete code)<br>
<br><br><br><span style="color:rgb(153,0,0)"> host 1<br>switch 1<br> [ 1.  0.  0.  0.  0.  0.  0.  0.]<br><br> host 1<br>switch 2<br> [ 2.  0.  0.  0.  0.  0.  0.  0.]<br><br> host 6<br> switch 2<br> [ 2.  0.  0.  0.  0.  2.  0.  0.]<br>
<br> host 6<br> switch 1<br> [ 2.  0.  0.  0.  0.  1.  0.  0.]<br><br></span><br><br><br> </div><div><br><br><font size="1"><span style="color:rgb(102,102,102)"><br></span></font><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<font size="1"><span style="color:rgb(102,102,102)">Creating topology: <br></span></font></blockquote><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<div><font size="1"><span style="color:rgb(102,102,102)">Class MyTopo(Topo):<br>    def __init__(self,  enable_all = True):<br>        setLogLevel('info')    <br>        super(MyTopo, self).__init__()<br>        <br>
        self.switch1 = self.addSwitch('s1')<br>        self.switch2 = self.addSwitch('s2')<br>        n = 0<br>        for h in range(4):<br>            n += 1<br>            host = self.addHost('n%s' % (n))<br>
            self.addLink(host, self.switch1) <br>        for h in range(4):<br>            n += 1            <br>            host = self.addHost('n%s' % (n))<br>            self.addLink(host, self.switch2)<br>        self.addLink(self.switch1, self.switch2) </span></font><br>
</div></blockquote></div><span class=""></span><span class=""><br><br><br></span></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div><span style="color:rgb(68,68,68)"><span class="">Processing packets:<br>
 <br></span></span></div><span style="color:rgb(68,68,68)"><span class="">packet = event.parsed</span><br><span class="">ip = packet.find('ipv4')</span><br><span class="">if ip is not None:</span><br><span class="">    parts = (str(ip.srcip)).split(".")</span><br>
<span class="">    lp = parts[3]</span><br><span class="">    <a href="http://log.info">log.info</a>("host %s" % lp)</span><br><span class="">    <a href="http://log.info">log.info</a>("switch %s" % event.dpid)</span><br>
<span class="">    hosts[int(lp) - 1] = event.dpid</span></span><br><span class=""></span></blockquote><span class="">    <br><br><br></span></div>