Hello RGBD,
The following listing shows an example of how to create a flowmod message:
Flowmod Message Example:
public class SampleFlowModMessageCreation {
private static final ProtocolVersion PV = ProtocolVersion.V_1_3;
private static final long COOKIE = 0x00002468;
private static final TableId TABLE_ID = TableId.valueOf(200);
private static final int FLOW_IDLE_TIMEOUT = 300;
private static final int FLOW_HARD_TIMEOUT = 600;
private static final int FLOW_PRIORITY = 50;
private static final BufferId BUFFER_ID = BufferId.NO_BUFFER;
private static final Set<FlowModFlag> FLAGS = EnumSet.of(FlowModFlag.SEND_FLOW_REM, FlowModFlag.CHECK_OVERLAP, FlowModFlag.NO_BYTE_COUNTS);
private static final MacAddress MAC =MacAddress.valueOf("00001e:000000");
private static final MacAddress MAC_MASK =MacAddress.valueOf("ffffff:000000");
private static final PortNumber SMTP_PORT = PortNumber.valueOf(25);
private static final MacAddress MAC_DEST = MacAddress.BROADCAST;
private static final IpAddress IP_DEST = IpAddress.LOOPBACK_IPv4;
private OfmFlowMod sampleFlowModCreation() {
// Create a 1.3 FlowMod ADD message...
OfmMutableFlowMod fm = (OfmMutableFlowMod) MessageFactory.create(PV, MessageType.FLOW_MOD, FlowModCommand.ADD);
// NOTE: outPort = ANY and outGroup = ANY by default so we don’t have
// to explicitly set them.
fm.cookie(COOKIE).tableId(TABLE_ID).priority(FLOW_PRIORITY).idleTimeout(FLOW_IDLE_TIMEOUT).hardTimeout(FLOW_HARD_TIMEOUT).bufferId(BUFFER_ID).flowModFlags(FLAGS).match(createMatch());
for (Instruction ins: createInstructions())
fm.addInstruction(ins);
return (OfmFlowMod) fm.toImmutable();
}
private Match
createMatch() {
// NOTE static imports of:
//
com.hp.of.lib.match.FieldFactory.createBasicField;
//
com.hp.of.lib.match.OxmBasicFieldType.*;
MutableMatch mm = MatchFactory.createMatch(PV).addField(createBasicField(PV, ETH_SRC, MAC, MAC_MASK)).addField(createBasicField(PV, ETH_TYPE, EthernetType.IPv4)).addField(createBasicField(PV, IP_PROTO, IpProtocol.TCP)).addField(createBasicField(PV, TCP_DST, SMTP_PORT));
return (Match) mm.toImmutable();
}
private static final long INS_META_MASK = 0xffff0000;
private static final long INS_META_DATA = 0x33ab0000;
private List<Instruction> createInstructions() {
// NOTE static imports of:
// com.hp.of.lib.instr.ActionFactory.createAction;
// com.hp.of.lib.instr.ActionFactory.createActionSetField;
// com.hp.of.lib.instr.InstructionFactory.createInstruction;
//
com.hp.of.lib.instr.InstructionFactory.createMutableInstruction;
List<Instruction> result = new ArrayList<Instruction>();
result.add(createInstruction(PV, InstructionType.WRITE_METADATA,INS_META_DATA, INS_META_MASK));
InstrMutableAction apply = createMutableInstruction(PV,InstructionType.APPLY_ACTIONS);
apply.addAction(createAction(PV, ActionType.DEC_NW_TTL)).addAction(createActionSetField(PV, ETH_DST, MAC_DEST)).addAction(createActionSetField(PV, IPV4_DST, IP_DEST));
result.add((Instruction) apply.toImmutable());
return result;
}
}
This is an example for FlowMOD message in the SDN Programming guide. [page 27-29]
Please follow the example and let us know if you still face the issue.
Thanks,
HP SDN Team