Ryu controller code

Most of us network engineers take routing for granted after a while. After all, it is easy to just assign the default gateway for devices, turn on the routing protocol on routers, advertise IP blocks, and call it a day. However, as we have seen in the switch configuration, OpenFlow gives you very granular control over network operations. With this control, you have to tell the devices what to do with your code: very little is handled on your behalf. So let's take a step back and think about the network operations in our two-router topology when h1 is trying to ping h2, such as when issuing the command h1 ping -c 2 h2:

  • The h1 host with IP address 192.168.1.10/24 knows that the destination 192.168.2.10 is not on its own subnet. Therefore, it will need to send the packet to its default gateway, 192.168.1.1.
  • The h1 host initially does not know how to reach 192.168.1.1 on the same subnet, so it will send out an ARP request for 192.168.1.1.
  • After receiving the ARP response, h1 will encapsulate the ICMP packet with IPv4 source 192.168.1.10, IPv4 destination 192.168.2.10, source mac 00:00:00:00:00:01, and the destination mac from the ARP response.
  • If router 1 does not have a flow for the receiving packet, assuming we have installed a flow miss entry for the controller, the packet will be sent to the controller for further action.
  • The controller will instruct router 1 to send the packet out to the correct port, in this case port 2, and optionally install a flow entry for future flow table match.
  • The steps are repeated until the packet reaches h2, and then the process is reversed, that is, h2 will ARP for its default gateway, then send out the packet, and so on.

The code is provided for you in Chapter11_3.py. As with the rest of the code in the book, the code is written to demonstrate concepts and features, so some implementation might not make sense in real-world production. This is especially true when it comes to OpenFlow and Ryu because of the freedom it offers you. First, let's take a look at the static flow installs from the controller.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.126.211