If a packet from Host 1 is forwarded across four switches, how do you know 
which one was the first one where Host 1 is actually attached and not just some 
non-first switch?

There may not be a super easy answer to this question.  POX's host_tracker 
component attempts one possible solution to this issue.  A simple possibility 
is to use openflow.discovery to figure out which ports are "edge" ports and 
which ports connect switches to other switches.  Only "learn" a host position 
at an edge port.

-- Murphy

On Jul 8, 2013, at 2:50 PM, nibble nibble wrote:

> 
> 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
>     
> 
> 

Reply via email to