| 156 | |
| 157 | ---- |
| 158 | == Some notes on architecture and implementation. == |
| 159 | In general, !FlowVisor is well-documented (see refs link at top of page). This section describes some more in-depth implementation details of !FlowVisor (currently 0.8.3). |
| 160 | |
| 161 | === Event handling === |
| 162 | Event handling is done by registering handlers with a loop construct (`FVEventLoop`). Handlers are implementations of the `FVEventHandler` interface. Handlers include core !FlowVisor components such as `OFSwitchAcceptor`, `FVClassifier`, and `FVSlicer`. The overview of the relationship between these components can be found [https://openflow.stanford.edu/display/DOCS/IO+Overview here]. |
| 163 | |
| 164 | Events are `FVEvent`-derived classes, with `FVEvent` being the base unit for passing events between event handlers. They come in several categories, including: |
| 165 | * `FVIOEvent` - a new incoming !OpenFlow message |
| 166 | * `OFKeepAlive` - an !OpenFlow ECHO_REQUEST |
| 167 | * `TearDownEvent` - shutdown of !FlowVisor components |
| 168 | * `FVRequestTimeoutEvent` - a timer has expired |
| 169 | Some things with 'event' in their names, such as `UnhandledEvent`, may represent an exception. |
| 170 | |
| 171 | === Startup === |
| 172 | '''In `Flowvisor.java`:''' |
| 173 | 1. Instantiate event loop |
| 174 | 1. If the topology controller is needed, initialize |
| 175 | 1. Initialize the OFSwitchAcceptor |
| 176 | 1. Initialize the API server |
| 177 | |
| 178 | '''In `OFSwitchAcceptor`:''' |
| 179 | 1. Initialize socket select to listen for incoming connections |
| 180 | 1. If incoming connection is an FVIOEvent, spawn an instance of `FVClassifier` |
| 181 | |
| 182 | '''In `FVClassifier`:''' |
| 183 | 1. Send controller side of !OpenFlow handshake (Hello, features request) |
| 184 | * The initial process also pushes a flow mod that causes switches to drop all, until further flow information can be acquired. |
| 185 | 2.For each event: |
| 186 | 1. Classify the type of event |
| 187 | 1. check if message is from a new or previously known switch (check ''switchInfo'', a structure that holds an `OFFeatureReply` for the switch this classifier is associated with) |
| 188 | * if known switch, call ''classifyFromSwitch'', the appropriate handler for the message (defined by the message itself as part of the `Classifiable` interface) |
| 189 | * if not (and message is a FEATURES_REPLY), fetch a copy of the flow map, and from it, a list of slices associated with the switch's DPID (the list is stored in a classifier's ''newSlices'' list) |
| 190 | * for each slice in ''newSlices'', spawn a `FVSlicer` if slice does not already have a slice (e.g. an entry in ''slicerMap'', a map of slice names to active `FVSlicer` instances) |
| 191 | * update ''slicerMap'' with contents of ''newSlices'' |
| 192 | |