Skip to content
Craig Riecke edited this page Jun 14, 2016 · 1 revision

The best place to learn Frenetic Python programming is the Frenetic Programmers Guide. In addition the Frenetic distribution contains Python example code under /lang/python/frenetic/examples.

In each of the following examples, you can run the sample on Frenetic User VM by running Frenetic in one window:

$ frenetic http-controller --verbosity debug

Mininet in one window, and the application itself in a third window.

drop_all

This application very simply drops all packets - the ultimate firewall!

Mininet Command: sudo mn --topo=single,2 --controller=remote

$ python -m frenetic.examples.drop_all.py

pingall in the Mininet window should yield 100% drops.

learning

This application implements a single L2 switch with an abitrary number of ports. It'll learn MAC addresses and selectively route traffic for those it knows about.

Mininet Command: sudo mn --topo=single,10 --controller=remote

$ python -m frenetic.examples.learning

pingall in the Mininet window should yield 100% successfully sent packets. There will be a lot of Packet Out activity at first, but as MACs are learned the controller traffic should quiet down. Eventually the switch will handle all the traffic itself.

packet_in_out

This application implements a very simple 2 port repeater where all the traffic goes through the controller.

Mininet Command: sudo mn --topo=single,2 --controller=remote

$ python -m frenetic.examples.packet_in_out

pingall in the Mininet window should yield 100% successfully sent packets. There will be a lot of Packet Out activity.

port_count

This application polls for port statistics and prints them every five seconds. It implements a simple switch-based repeater for a single switch and an arbitrary number of ports.

Mininet Command: sudo mn --topo=single,10 --controller=remote

$ python -m frenetic.examples.port_count

pingall in the Mininet window should yield 100% successfully sent packets. Port counts should keep climbing as ping traffic gets forwarded.

repeater

This application implements a simple switch-based repeater for a single switch and an arbitrary number of ports.

Mininet Command: sudo mn --topo=single,10 --controller=remote

$ python -m frenetic.examples.repeater

pingall in the Mininet window should yield 100% successfully sent packets.

discovery

Located in the discovery subdirectory, this multi-object Python application performs a topology discovery on the given network. It finds all internal (switch-to-switch) links and all connected hosts.

Mininet Command: sudo mn --topo=tree,3,3 --controller=remote

$ python -m frenetic.examples.discovery.discovery

Running this app should yield the internal links in the above topology listed on the console log.