learning switch code(Analysis2)
TutorialL2Forwarding()
close()
onPacketReceived
packetOut
programL2Flow
初始化 logger,FLOOD_PORT_NUMBER, macTable(HashMap <String, NodeConnectorId>),function("hub");
registrations(List<Registration>),dataBroker,packetProcessingService
TutorialL2Forwarding()
传参赋值,注册notification监听器
dataBroker packetProcessingService registrations
onPacketReceived()
Get information of Node Reference,Id& NodeConnector Id, providing the NodeConnectorRef by notification.getIngress()
From NodeId,FLOOD_PORT_NUMBER get NodeConnectorId,NodeConnectorRef for flooding
Logic:
0. Ignore LLDP packets
1. If behaving as "hub", perform a PACKET_OUT with FLOOD action
2. Else if behaving as "learning switch",
2.1. Extract MAC addresses
2.2. Update MAC table with source MAC address
2.3. Lookup in MAC table for the target node connector of dst_mac
2.3.1 If found,
2.3.1.1 perform FLOW_MOD for that dst_mac through the target node connector
2.3.1.2 perform PACKET_OUT of this packet to target node connector
2.3.2 If not found, perform a PACKET_OUT with FLOOD action
0.Ignore LLDP packets
PacketParsingUtils.extractEtherType
1. Behave as hub
packetOut() according to node and node connector flooding reference
2.Behave as learning switch
Extract payload, Extract MAC addresses, Update MAC table with source MAC, MAC table for the target node connector with destination MAC, FLOW_MOD || PACKET_OUT || PACKET_OUT with FLOOD action
Construct input for RPC call to packet processing service,using the node and node connector information.
TransmitPacketInput input = new TransmitPacketInputBuilder()
TransmitPacketInput input = new TransmitPacketInputBuilder()
.setPayload(payload)
.setNode(egressNodeRef)
.setEgress(egressNodeConnectorRef)
.build();
packetProcessingService.transmitPacket(input);
programL2Flow()
/* Programming a flow involves:
* 1. Creating a Flow object that has a match and a list of instructions,
* 2. Adding Flow object as an augmentation to the Node object in the inventory.
* 3. FlowProgrammer module of OpenFlowPlugin will pick up this data change and eventually program the switch.
*/
close()
onPacketReceived
packetOut
programL2Flow
初始化 logger,FLOOD_PORT_NUMBER, macTable(HashMap <String, NodeConnectorId>),function("hub");
registrations(List<Registration>),dataBroker,packetProcessingService
TutorialL2Forwarding()
传参赋值,注册notification监听器
dataBroker packetProcessingService registrations
onPacketReceived()
Get information of Node Reference,Id& NodeConnector Id, providing the NodeConnectorRef by notification.getIngress()
From NodeId,FLOOD_PORT_NUMBER get NodeConnectorId,NodeConnectorRef for flooding
Logic:
0. Ignore LLDP packets
1. If behaving as "hub", perform a PACKET_OUT with FLOOD action
2. Else if behaving as "learning switch",
2.1. Extract MAC addresses
2.2. Update MAC table with source MAC address
2.3. Lookup in MAC table for the target node connector of dst_mac
2.3.1 If found,
2.3.1.1 perform FLOW_MOD for that dst_mac through the target node connector
2.3.1.2 perform PACKET_OUT of this packet to target node connector
2.3.2 If not found, perform a PACKET_OUT with FLOOD action
0.Ignore LLDP packets
PacketParsingUtils.extractEtherType
1. Behave as hub
packetOut() according to node and node connector flooding reference
2.Behave as learning switch
Extract payload, Extract MAC addresses, Update MAC table with source MAC, MAC table for the target node connector with destination MAC, FLOW_MOD || PACKET_OUT || PACKET_OUT with FLOOD action
packetOut()
Construct input for RPC call to packet processing service,using the node and node connector information.
TransmitPacketInput input = new TransmitPacketInputBuilder()
TransmitPacketInput input = new TransmitPacketInputBuilder()
.setPayload(payload)
.setNode(egressNodeRef)
.setEgress(egressNodeConnectorRef)
.build();
packetProcessingService.transmitPacket(input);
programL2Flow()
/* Programming a flow involves:
* 1. Creating a Flow object that has a match and a list of instructions,
* 2. Adding Flow object as an augmentation to the Node object in the inventory.
* 3. FlowProgrammer module of OpenFlowPlugin will pick up this data change and eventually program the switch.
*/
评论
发表评论