Skip to content
Addie edited this page Jun 5, 2016 · 3 revisions

Three Python files make up the code for the mini-project.

flow_adder

This Ryu app adds the initial flows to the OpenFlow controller that allow Internet connectivity. It is a heavily modified simple switch, found in Ryu's examples here.

Assuming a router with access to the wider Internet is connected to port 1 of the Zodiac, and another router for clients on the internal network is connected to port 2, the initial flows send all traffic on port 1 to the controller and also port 2, while all traffic on port 2 is sent to port 1. This means that all incoming packets are processed by the controller, and outgoing packets are not processed at all. The packet_in handler thus inspects all incoming packets to port 2. This was done because the Zodiac was simply unable to handle 130 initial flows matching Netflix ranges. The FAQ elaborates on this.

Before any checks are done, a list of IP ranges known to be associated with Netflix (which has an Autonomous System number of 2906) is created. These IP ranges are read from a plaintext file containing IPs scraped from the Hurricane Electric BGP Toolkit - the file can be found in the repo.

A condition in the packet_in handler will inspect the incoming Ethernet frame for an enclosed IP packet. If it exists, the IP is compared against the list of Netflix ranges, and a new flow with a much higher priority than the initial flows, and matches against the current packet's destination MAC address and incoming IP address, is added. The flow sends matching packets directly to port 2 so the controller is not bogged down. The incoming IP address is also added to a set containing IPs that have already been seen so as to not add duplicate flows for the same IP.

If the frame does not meet the condition, it is simply ignored (as it's already been sent to port 2 anyway).

netflix_monitor

This app is the simple monitor Ryu app example with a minor tweak. It outputs flow information and statistics in JSON format every 10 seconds to a file named jsonout.json, which is then parsed by the plot script.

Example output can be found in the repository.

plot

This file was misnamed. It doesn't plot anything.

Displays flow statistics in the terminal. It reads the jsonout.json file output by the netflix_monitor app every 10 seconds and parses it using the JSON module. It then displays the needed information (client MAC address, byte count, packet count and flow duration) in the terminal.

Example output:

Client | Packets | Bytes | Duration (s)

e0:c7:67:65:b2:3b | 61028 | 80585771 | 485
f0:cb:a1:04:3d:46 | 2059 | 2900724 | 64


flow_adder and netflix_monitor are intended to be placed inside the Ryu app directory, so that they can be run like so:

ryu-manager ryu.app.netflix_monitor ryu.app.flow_adder

The plot script should be run in a different terminal.

Clone this wiki locally