Question
How can we get the port’s information in Floodlight?
Solution
The Floodlight use a
ImmutablePort
class to represent a switch port and aIOFSwitch
class has a Portmanager which will manager all ImmutablePort.The content of ImmutablePort is the same as what it described in Openflow specification 1.0.
1
2
3
4
5
6
7
8
9
10
11
12public class ImmutablePort {
private final short portNumber;
private final byte[] hardwareAddress;
private final String name;
private final EnumSet<OFPortConfig> config;
private final boolean portStateLinkDown;
private final OFPortState stpState;
private final EnumSet<OFPortFeatures> currentFeatures;
private final EnumSet<OFPortFeatures> advertisedFeatures;
private final EnumSet<OFPortFeatures> supportedFeatures;
private final EnumSet<OFPortFeatures> peerFeatures;
....The Portmanger provide some API to allow other object to fetch the ImmutablePort.
1 | public ImmutablePort getPort(String name) { |
- Since the Portmanager is a private member of IOFSwitch, you can’t directly use it. You must use the API provied by IOFSwitch to interact with Portmanager.
1 |
|
Example
Assume the type of sw is IOFSwitch.1
2
3
4
5
6Collection<ImmutablePort> swPorts = sw.getPorts();
Iterator<ImmutablePort> it = swPorts.iterator();
while(it.hasNext()){
ImmutablePort port = it.next();
//do something
}