Module Descriptions and Javadoc
仔细阅读下面的话,在阅读源码时注意标红接口和依赖函数
Floodlight adopts a modular architecture to implement its controller features and some applications. Module Loading System describes the Java IFloodlightModule interface that realizes this framework.(模块化设计)
Floodlight modules that wish to expose features to other Floodlight modules or to the REST API must first implement an IFloodlightService. This page serves as a reference for all existing Floodlight services that you can leverage from within a Floodlight module. In order to use any of these services, you must first specify the service as a dependency in your module's getModuleDependencies() function. (IFloodlightService:接口 getModuleDependencies()依赖函数)
FloodlightProvider (Dev)
源码位置:net.floodlightcontroller.core.FloodlightProvider.
ISyncService IOFSwitchService
DeviceManagerImpl
net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl
设备管理器通过PacketIn请求了解设备。它从PacketIn获取信息,并根据实体分类器的设置方式对设备进行分类。默认情况下,实体分类器使用MAC地址和VLAN来标识设备。这两个属性将定义什么是唯一的设备。设备管理器还将学习其他属性,如IP地址。一个重要的信息是设备附件点。如果在交换机上接收到PacketIn,则将为该设备创建一个附件点。
curl -s http://localhost:8080/wm/device/(Getting all devices)
curl -s http://localhost:8080/wm/device/?ipv4=1.1.1.1 (Getting a device with the IP of 1.1.1.1)
LinkDiscoveryManager (Dev)
net.floodlightcontroller.linkdiscovery.internal.LinkDiscoveryManager
The link discovery services uses both LLDPs and broadcast packets (aka BDDPs) to detect links. The LLDP destination MAC is 01:80:c2:00:00:0e and the BDDP destination MAC is ff:ff:ff:ff:ff:ff (broadcast address). The ether type for LLDPs and BDDPs is 0x88cc and 0x8999. There are two assumptions made in order for the topology to be learned properly.
Any switch (including OpenFlow switches) will consume a link-local packet (LLDP).
Honors layer 2 broadcasts.
Links can either be "direct" or "broadcast". A direct link will be established if an LLDP is sent out one port and the same LLDP is received on another port. This implies that the ports are directly connected. A broadcast link is created if a BDDP is sent out a port and received on another. This implies that there is another layer 2 switch not under the control of the controller between these two ports.
curl -s http://localhost:8080/wm/topology/links/json (Getting all devices)
TopologyService (Dev)
net.floodlightcontroller.topology.TopologyManager
The Topology Service computes topologies based on link information it learns from the ILinkDiscoveryService. An important concept that the TopologyService keeps is the idea of an OpenFlow 'island'. An island is defined as a group of strongly connected OpenFlow switches under the same instance of Floodlight. Islands can be interconnected using non-OpenFlow switches on the same layer 2 domain. Let's take this example:
[OF switch 1] -- [OF switch 2] -- [traditional L2 switch] -- [OF switch 3]
Two islands would be formed by the topology service. Island 1 would contain switches 1 and 2 while island 2 would contain just switch 3.
All the information about the current topology is stored in an immutable data structure called the topology instance. If there is any change in the topology, a new instance is created and the topology changed notification message is called. If other modules want to listen for changes in topology they can implement the ITopologyListener interface.
curl -s http://localhost:8080/wm/topology/switchclusters/json
RestApiServer (Dev)
允许模块通过HTTP公开REST API
net.floodlightcontroller.restserver.RestApiServer
The Rest API server uses the Restlets library. More documentation on Restlet is available here. Other modules that have the REST server as a dependency expose APIs through adding a class that implements RestletRoutable. Each RestletRoutable contains a Router that attaches Restlet resources (the most common being ServerResource). Users will attach their own classes that extend a Restlet resource in order to handle requests for specific URLs. Inside the resource annotations such as @Get, @Put, etc are to select which method will be used for HTTP requests. Serialization is done via the Jackson library that is included in the Restlet library. Jackson can serialize objects in two ways. One is that it will automatically use available getters on objects serialize those fields. Otherwise custom serializers can be created and annotated on the top of the class.