Floodlight Start-Up process analysis

Source: Internet
Author: User


1. In main, first load the module, start the rest service, and then build an instance that implements the Ifloodlightproviderservice interface (that is, the controller) and execute it; 2. Next enter the controller's run () method, at which time all the environment initialization work is complete. Build a TCP server based on Netty, the most important is the setup of Pipelining factory openflowpipelinefactory, Inside is controller high, dirty processing handler (Detailed details see = = =).

When the channel is established, the messagereceived () method is called after receiving a message from the SW and distributed to the processofmessage for detailed processing according to the different types of msg;  Assuming that the message requires a response to the SW, or that other listeners are interested, call handlemessage for additional processing, and the code is posted. protected void Handlemessage (Iofswitch SW, Ofmessage m, Floodlightcontext Bcontext) {
Ethernet eth = null;
Switch (M.gettype ()) {
Case packet_in:
Ofpacketin pi = (ofpacketin) m;
Always true by default
if (Controller.always_decode_eth) {
ETH = new Ethernet (); Parse the PACKET_IN message into the ETH, so the following bcstore can be stored directly
eth.deserialize (pi.getpacketdata (), 0, Pi.getpacketdata (). length);
Counterstore.updatepacketincounters (SW, M, ETH);
}
//Fall through to the default case ...

Default

List<iofmessagelistener> listeners = null;
if (Messagelisteners.containskey (M.gettype ())) {
Listeners = Messagelisteners.get (M.gettype ()). Getorderedlisteners ();
}

floodlightcontext BC = NULL;
if (listeners! = null) {
Check If floodlight context is passed from the calling
function, if so use that floodlight context, otherwise
Allocate one
if (Bcontext = = null) {
BC = Flcontext_alloc ();
} else {
BC = Bcontext;
}
if (ETH! = null) {
IFloodlightProviderService.bcStore.put (Bc,ifloodlightproviderservice.context_pi_payload, ETH);                        //cache to HashMap. So when we join our own module to listen to Packetin messages. can be removed from it. Do your own business processing.
}

Command cmd;
for (Iofmessagelistener listener:listeners) {
if (listener instanceof Iofswitchfilter) {
if (! ( (iofswitchfilter) listener). isinterested (SW)) {
Continue
}
}
Traverse all listener that are of interest to packetin. To run their receive method separately;
cmd = listener.receive (SW, M, BC);

if (Command.STOP.equals (cmd)) {
Break
}     }    }

if ((Bcontext = = null) && (BC = null)) flcontext_free (BC);
}    }
3. Process the update message of SW at any time in the loop.




Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

Floodlight Start-Up process analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.