You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dmitry-Orekhov edited this page Aug 23, 2013
·
23 revisions
OpenFlow Java library API Cookbook
(work in progress)
Launch a controller
The controller infrastructure is started the next way:
importorg.flowforwarding.of.controller.Controller;
/*................*/Controller.launch (SessionHandler.class); // This launches a controller listening tcp port 6633Controller.launch (SessionHandler.class, configuration); // This launches a controller listening given tcp port
Configuration
It's a POJO containing some configuration information as tcp port number etc.
importorg.flowforwarding.of.controller.Configuration/*................*/Configurationconfig1 = newConfiguration(); // tcp port 6633 by defaultConfigurationconfig2 = newConfiguration(6633);
Session handlers
You have to implement your session handler to interact with Controller. Session handlers extend the class OFSessionHandler:
importorg.flowforwarding.of.controller.SwitchState;
importorg.flowforwarding.of.controller.session.OFSessionHandler;
publicclassSimpleHandlerextendsOFSessionHandler {
@Overrideprotectedvoidhandshaked(SwitchStateswState) {
super.handshaked(swState);
/*You have to implement your own logic here*/
}
}