Reference Guide

Table Of Contents
}
}
private void handleEchoReply(OfmEchoReply msg, DataPathId dpid) {
...
}
private void handlePortStatus(OfmPortStatus msg, DataPathId dpid) {
...
}
}
Statistics
The ControllerService API has a number of methods for retrieving various “statistics” about the
controller, or about datapaths in the network.
getStats()returns statistics on byte and packet counts, from the controller’s perspective.
getPortStats(...)—queries the specified datapath for statistics on its ports.
getFlowStats(...)—queries the specified datapath for statistics on installed flows.
getGroupDescription(...)queries the specified datapath for its group descriptions.
getGroupStats(...)queries the specified datapath for statistics on its groups.
getGroupFeatures(...)queries the specified datapath for the group features it supports.
getMeterConfig(...)queries the specified datapath for its meter configurations.
getMeterStats(...)queries the specified datapath for statistics on its meters.
getMeterFeatures(...)queries the specified datapath for the meter features it supports.
getExperimenter(...)queries the specified datapath for meter configuration or statistics for
OpenFlow 1.0 datapaths.
As an example, a method to print all the flows on a given datapath could be written as follows:
Flows Example:
private void printFlowStats(DataPathId dpid) {
List<MBodyFlowStats> stats = cs.getFlowStats(dpid, TableId.ALL);
// Note: the above is a blocking call, which will wait for the
// controller to send the request to the datapath and retrieve the
// response, before returning.
print("All flows installed on datapath {} ...", dpid);
for (MBodyFlowStats fs: stats)
printFlow(fs);
}
private void printFlow(MBodyFlowStats fs) {
print("Table ID : {}", fs.getTableId());
print("Duration : {} secs", fs.getDurationSec());
print("Idle Timeout : {} secs", fs.getIdleTimeout());
print("Hard Timeout : {} secs", fs.getHardTimeout());
37