Hi Mahmoud,
Well, on my environment, the patch on my previous mail looks fine.
=== My Mininet topology ===
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.log import setLogLevel
def main():
net = Mininet(controller=RemoteController)
net.addController('c0')
s1 = net.addSwitch('s1')
s2 = net.addSwitch('s2')
s3 = net.addSwitch('s3')
# To simulate host migration, create 2 hosts which have the same addresses
h1 = net.addHost('h1', ip='10.0.0.1', mac='00:00:00:00:00:01')
h2 = net.addHost('h2', ip='10.0.0.2', mac='00:00:00:00:00:02')
h3 = net.addHost('h3', ip='10.0.0.2', mac='00:00:00:00:00:02')
net.addLink(s1, h1)
net.addLink(s2, h2)
net.addLink(s3, h3)
net.addLink(s1, s2)
net.addLink(s2, s3)
net.start()
CLI(net)
net.stop()
if '__main__' == __name__:
setLogLevel('info')
main()
===========================
$ ryu-manager ryu/app/rest_topology.py ryu/app/simple_switch_13.py
...(snip)...
$ sudo python topo_mac_ip_duplicated.py
...(snip)...
mininet>
# Learn the initial position(=h2)
mininet> h2 ping -c 1 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=15.2 ms
--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 15.209/15.209/15.209/0.000 ms
# Confirm the response of the API
# ---> The host is detected on "s2-eth2"(=h2)
$ curl -X GET http://localhost:8080/v1.0/topology/hosts | jq .
[
{
"ipv6": [],
"mac": "00:00:00:00:00:01",
"ipv4": [
"10.0.0.1"
],
"port": {
"port_no": "00000002",
"hw_addr": "6e:89:36:2f:25:66",
"name": "s2-eth2",
"dpid": "0000000000000002"
}
},
{
"ipv6": [],
"mac": "00:00:00:00:00:02",
"ipv4": [
"10.0.0.2"
],
"port": {
"port_no": "00000002",
"hw_addr": "a2:c8:8a:0e:42:0b",
"name": "s1-eth2",
"dpid": "0000000000000001"
}
}
]
# Because simple_switch_13 is not aware of the host migration,
# flushed flow entries before reproducing the migration.
mininet> sh ovs-ofctl del-flows s1
mininet> sh ovs-ofctl del-flows s2
mininet> sh ovs-ofctl add-flow s1 priority=0,actions=CONTROLLER
mininet> sh ovs-ofctl add-flow s2 priority=0,actions=CONTROLLER
mininet> sh ovs-ofctl dump-flows s1
cookie=0x0, duration=11.687s, table=0, n_packets=1, n_bytes=126, priority=0
actions=CONTROLLER:65535
mininet> sh ovs-ofctl dump-flows s2
cookie=0x0, duration=11.256s, table=0, n_packets=2, n_bytes=252, priority=0
actions=CONTROLLER:65535
mininet> sh ovs-ofctl dump-flows s3
cookie=0x0, duration=134.092s, table=0, n_packets=14, n_bytes=1564, priority=0
actions=CONTROLLER:65535
# Reproduce the host migration and learn the second position(=h3)
mininet> h3 ping -c 1 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=23.5 ms
--- 10.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 23.561/23.561/23.561/0.000 ms
# Confirm the response of the API
# ---> The host is detected on "s3-eth2"(=h3)
$ curl -X GET http://localhost:8080/v1.0/topology/hosts | jq .
[
{
"ipv6": [],
"mac": "00:00:00:00:00:01",
"ipv4": [
"10.0.0.1"
],
"port": {
"port_no": "00000002",
"hw_addr": "5a:ca:38:8d:d8:49",
"name": "s3-eth2",
"dpid": "0000000000000003"
}
},
{
"ipv6": [],
"mac": "00:00:00:00:00:02",
"ipv4": [
"10.0.0.2"
],
"port": {
"port_no": "00000002",
"hw_addr": "a2:c8:8a:0e:42:0b",
"name": "s1-eth2",
"dpid": "0000000000000001"
}
}
]
Sorry, I don't know the detail implementation of the topology library, but it
is required that any
communicating paths are establish and valid ARP(or IPv4/IPv6) packets are sent
to the controller.
So you need to implement your application which running with rest_topology.py
to generate Packet-In
with the first packet when the host moved on to another port.
Thanks,
Iwase
On 2017年11月27日 23:32, Mahmoud Elzoghbi wrote:
Hi Iwase thank you for your help
i just added your code in event.py and switches.py to test your code,i created custom topology in
mininet with two hosts and one switch which it change host H1 position from port 1 to port 7, i ran
simple_switch.py and rest_topology.py in my controller(RYU),and i called api
(http//localhost:8080/v1.0/topology/hosts) before movement of host,API observes network without any
problem but when i change H1 position from port 1 to port 7 and call API again it observes the old
position of host.
what should i do to solve this problem??
thnx
mahmoud
On Mon, Nov 27, 2017 at 8:38 AM, Iwase Yusuke <iwase.yusu...@gmail.com
<mailto:iwase.yusu...@gmail.com>> wrote:
Hi Mahmoud,
To solve this issue, we need to fix this bug.
For the quick patch, the following corrects this behavior?
$ git diff
diff --git a/ryu/topology/event.py b/ryu/topology/event.py
index e7b682c..5b776dc 100644
--- a/ryu/topology/event.py
+++ b/ryu/topology/event.py
@@ -170,4 +170,10 @@ class EventHostAdd(EventHostBase):
def __init__(self, host):
super(EventHostAdd, self).__init__(host)
+
+class EventHostDelete(EventHostBase):
+ def __init__(self, host):
+ super(EventHostDelete, self).__init__(host)
+
+
handler.register_service('ryu.topology.switches')
diff --git a/ryu/topology/switches.py b/ryu/topology/switches.py
index 7264075..5b0415b 100644
--- a/ryu/topology/switches.py
+++ b/ryu/topology/switches.py
@@ -868,6 +868,14 @@ class Switches(app_manager.RyuApp):
self.hosts.add(host)
ev = event.EventHostAdd(host)
self.send_event_to_observers(ev)
+ elif self.hosts[host_mac].port != port:
+ # Case of the host is moved to another port
+ ev = event.EventHostDelete(self.hosts[host_mac])
+ self.send_event_to_observers(ev)
+ # Register the moved host with the new location
+ self.hosts[host_mac] = host
+ ev = event.EventHostAdd(host)
+ self.send_event_to_observers(ev)
# arp packet, update ip address
if eth.ethertype == ether_types.ETH_TYPE_ARP:
Please note that the above does not handle the host deletion at the
topology app side, the host
might be duplicated in the REST response...
(Sorry, I couldn't reproduce the host migration on my environment, I
haven't test it enough)
Thanks,
Iwase
On 2017年11月24日 17:40, Mahmoud Elzoghbi wrote:
when i call (http//localhost:8080/v1.0/topology/hosts) API it discovers
hosts's macs and
which port these hosts connected,but when host move from port to
another,it discover the old
position of host
what should i do to solve this problem??
thnx
mahmoud
On Fri, Nov 24, 2017 at 9:16 AM, Iwase Yusuke <iwase.yusu...@gmail.com
<mailto:iwase.yusu...@gmail.com> <mailto:iwase.yusu...@gmail.com
<mailto:iwase.yusu...@gmail.com>>> wrote:
Hi Mahmoud,
When Ryu detects the new host connection, it only checks if the
host is known not not
at here.
https://github.com/osrg/ryu/blob/ed2c6eca2227c9efb3c7e51cdd6db6bf578ec609/ryu/topology/switches.py#L867-L870
<https://github.com/osrg/ryu/blob/ed2c6eca2227c9efb3c7e51cdd6db6bf578ec609/ryu/topology/switches.py#L867-L870>
<https://github.com/osrg/ryu/blob/ed2c6eca2227c9efb3c7e51cdd6db6bf578ec609/ryu/topology/switches.py#L867-L870
<https://github.com/osrg/ryu/blob/ed2c6eca2227c9efb3c7e51cdd6db6bf578ec609/ryu/topology/switches.py#L867-L870>>
So, as your situation, when the host moves from a port to another,
even if Ryu detects
it, the
new connection to that host seems to be ignored...
It seems that we need to store which port connecting to the host
(not just known or not).
Thanks,
Iwase
On 2017年11月24日 00:36, Mahmoud Elzoghbi wrote:
Hello to everyone,
I used Rest_topology.py to discover hosts in my topology, but
when any host moves
from Port
1 to port 5 for example Rest_topology.py discover this host in
port 1 also , it doesn't
sense the movement of host
What is the problem?
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net <mailto:Ryu-devel@lists.sourceforge.net>
<mailto:Ryu-devel@lists.sourceforge.net
<mailto:Ryu-devel@lists.sourceforge.net>>
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<https://lists.sourceforge.net/lists/listinfo/ryu-devel>
<https://lists.sourceforge.net/lists/listinfo/ryu-devel
<https://lists.sourceforge.net/lists/listinfo/ryu-devel>>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net <mailto:Ryu-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/ryu-devel
<https://lists.sourceforge.net/lists/listinfo/ryu-devel>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel