1. Damascus University
Faculty of Information Technology Engineering
Department of Computer Systems and Networks
دمشق جامعة
المعلوماتية الهندسة كلية
الحاسوب والشبكات النظم قسم
ةّي
الشبكات ة
إدار عملي
Network Management
Session 7: SDN Applications with FloodLight
اعداد
:
م
.
غاندي
هسام
Ghandi
Hessam
2. Introduction
• The application in SDN belong to control layer.
• We have to build an app above the controller.
• In FloodLight it called: Module.
• Java language is used.
• Remember:
Any packet received on a switch not matching any
flow will trigger a packet_in message sent to the
controller.
8/30/2019 By Eng. Ghandy Hessam 2
3. SDN application development with FloodLight controller
• Main steps to write a module
➢Creating the listener
➢Add Class In Eclipse
➢Setting Up Module Dependencies And Initialization
➢Handling The Packet-In Message
➢Ordering Modules when Processing OpenFlow Messages
➢Register The Module
➢Connect Mininet Software OpenFlow Switches To Floodlight
8/30/2019 By Eng. Ghandy Hessam 3
4. Example: handling Packet_In messages (1)
• Any packet received on a switch not matching any flow will
trigger a packet_in message sent to the controller.
8/30/2019 By Eng. Ghandy Hessam 4
5. Example: handling Packet_In messages (2)
• Handling Packet_In in a prototype module:
8/30/2019 By Eng. Ghandy Hessam 5
6. The receive method
• We will write our code in this method to handle all packet_in
that comes to the controller.
sw: object to the ovs switch that sends the packet_in.
msg: an openflow message.
8/30/2019 By Eng. Ghandy Hessam 6
7. Ethernet frame object
Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
8/30/2019 By Eng. Ghandy Hessam 7
8. Is the ofMessage is Packet_IN?
if (msg.getType( ).equals(OFType.PACKET_IN))
8/30/2019 By Eng. Ghandy Hessam 8
9. Casting objects
• Example: get the packet (Layer 3) from Ethernet object (eth).
• Example: get ICMP object from IPv4.
if (eth.getEtherType().equals(EthType.IPv4)) {
IPv4 packet1 = (IPv4) eth.getPayload();
}
if (eth.getEtherType().equals(EthType.IPv4)) {
IPv4 packet1 = (IPv4) eth.getPayload();
if (packet1.getProtocol().equals(IpProtocol.ICMP)){
ICMP icmp = (ICMP) packet1.getPayload(); }
}
8/30/2019 By Eng. Ghandy Hessam 9
10. Install flow entry on an ovs
• To create a rule (flow entry) and add it to the flow table of a
certain OVS switch, we have to:
1. Create a match object.
2. An object of FlowAdd from flowMod builder.
3. Create a list of actions.
4. Send the flow to an OVS.
8/30/2019 By Eng. Ghandy Hessam 10
11. 1. Match object
Match our_match = sw.getOFFactory().buildMatch()
.setExact(MatchField.IN_PORT, p)
.setExact(MatchField.ETH_SRC, src)
.setExact(MatchField.ETH_DST, dst)
.build();
Note:
p: is object of OFPort
src and dst: are objects of MacAddress
8/30/2019 By Eng. Ghandy Hessam 11
13. 3. List of Actions
List<OFAction> al = new ArrayList<OFAction>();
al.add(sw.getOFFactory().actions().buildOutput()
.setPort(…………….).build());
fmb.setActions(al);
8/30/2019 By Eng. Ghandy Hessam 13
14. 4. Send the flow to an OVS
sw.write(fmb.build());
logger.info("---Flow Add done!---n");
8/30/2019 By Eng. Ghandy Hessam 14
15. Example: Flow installation (Match)
• Flow: a set of packets that have the same value in certain fields.
• All these fields combined compose a Match.
• In Floodlight, each match is an object of
org.projectfloodlight.openflow.protocol.match.Match
• Example: to create a match for flow
8/30/2019 By Eng. Ghandy Hessam 15
16. Example: Flow installation (FlowMod)
• FlowMod: the message regarding flow installation/deletion.
• In Floodlight, each FlowMod message is a object of:
org.projectfloodlight.openflow.protocol.OFFlowMod
• Example:
8/30/2019 By Eng. Ghandy Hessam 16
17. Example: Flow installation (Action)
• Action: A set of operations associated with a match.
• For all packets with the same match, the operations will be applied.
• In Floodlight, each actions is a object of
org.projectfloodlight.openflow.protocol.action.OFAction
• Example: block action (Empty action list)
8/30/2019 By Eng. Ghandy Hessam 17