You are on page 1of 22

05

Practice with Floodlight

Using OpenFlow 1.3


Floodlight
JAVA based open-source controller

Apache license

2
Set-up
Downloads
$ sudo apt-get install build-essential openjdk-7-jdk ant maven python-dev eclipse

$ git clone git://github.com/mininet/mininet


$ mininet/util/install.sh -a

$ git clone git://github.com/floodlight/floodlight.git b v1.2


$ cd floodlight
$ ant eclipse
$ ant;

Running Floodlight in the terminal


$ java jar target/floodlight.jar

3
Web GUI
Start Mininet

sudo mn --topo single,3 --mac --switch ovsk,protocols=OpenFlow13


--controller remote,port=6653

Floodlight Web GUI


http://127.0.0.1:8080/ui/index.html

4
Architecture
Modular architecture

5
Architecture
Modular architecture

The controller architecture consists of a core module, that's responsible for listening to
the openflow sockets and dispatching events,

and a number of secondary modules that can register with the core module to handle
those events

6
Write a Module
Make working Eclipse project for Floodlight
Open eclipse and create a new workspace
File Import General Existing Projects into Workspace. Then click Next
From Select root directory click Browse. Select the parent directory where you
placed floodlight earlier
Check the box for Floodlight. No other Projects should be present and none should
be selected
Click Finish

7
Write a Module
Create the FloodlightLaunch target
Click Run Run Configurations
Right Click Java Application New
For Name use FloodlightLaunch
For Project use Floodlight
For Main use net.floodlightcontroller.core.Main
Click Apply

8
Write a Module
Add Class in Eclipse
Right Click on the src/main/java folder and choose New Class
Enter net.floodlightcontroller.mactracker in the Package box
Enter MACTracker in the Name box
Next to the Interfaces box, choose Add
Add the IOFMessageListener and the IFloodlightModule, click OK
Click Finish in the dialog

9
Write a Module
Skeleton class

10
Write a Module
Skeleton class (cont)
Add these up front

im port net.fl
oodlightcontroller.core.IFloodlightProviderService;
im port java.util.ArrayList;
im port java.util.concurrent.ConcurrentSkipListSet;
im port java.util.Set;
im port net.fl
oodlightcontroller.packet.Ethernet;
im port org.slf4j.Logger;
im port org.slf4j.LoggerFactory;

11
Write a Module
Registering some member variables
protected IFloodlightProviderService fl
oodlightProvider;
protected Set< Long> m acAddresses;
protected static Logger logger;

12
Write a Module
Tell the module loader we depend on it
Modifying the getModuleDependencies() function
@ O verride
public Collection< Class< ? extends IFloodlightService> > getM oduleD ependencies() {

Collection< Class< ? extends IFloodlightService> > l=


new ArrayList< Class< ? extends IFloodlightService> > ();

l.add(IFloodlightProviderService.class);

return l;

13
Write a Module
Init is called early in the controller startup processes
Modifying the init() function
@ O verride
public void init(FloodlightM oduleContext context)
throw s FloodlightM oduleException {

floodlightProvider = context.getServiceIm pl(IFloodlightProviderService.class);


m acAddresses = new ConcurrentSkipListSet< Long> ();
logger = LoggerFactory.getLogger(M ACTracker.class);

14
Write a Module
Handling the Packet-In message
Register for PACKET_IN messages in our startUp method

@Override
public void startUp(FloodlightModuleContext context) {

floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);

15
Write a Module
Put in an ID for our OFMessage listener
Modifying getName()

@Override
public String getName() {

return MACTracker.class.getSimpleName();

16
Write a Module
Define the behavior we want for PACKET_IN messages
Note that we return Command.CONTINUE to allow this message to continue to be
handled by other PACKET_IN handlers as well
@Override
public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg,
FloodlightContext cntx)
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

Long sourceMACHash = eth.getSourceMACAddress().getLong();

if (!macAddresses.contains(sourceMACHash)) {
macAddresses.add(sourceMACHash);
logger.info("MAC Address: {} seen on switch: {}", eth.getSourceMACAddress().toString(),
sw.getId().toString());
}
return Command.CONTINUE;
}
17
Regist the Module
Tell the loader that the module exists
add the fully qualified module name on it's own line in
src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule

net.floodlightcontroller.mactracker.MACTracker

modify the Floodlight module configuration file to append the MACTracker


src/main/resources/floodlightdefault.properties
The key is floodlight.modules and the value is a comma separated list of fully qualified
module names

floodlight.modules = <leave thedefaultlist of modules in place ,\


net.floodlightcontroller.mactracker.MACTracker

18
Regist the Module
Run the controller
right clicking onMain.javaand choose "Run As.../Java Application/FloodlightLaunch"

19
Regist the Module
Run the controller
right clicking onMain.javaand choose "Run As.../Java Application/FloodlightLaunch"

20
More Floodlight tutorials
https://floodlight.atlassian.net/wiki/display/floodlightcontroller/How+to+Add+Services+to+a+Module

21
END
THANK YOU

Using OpenFlow 1.3

You might also like