本文整理汇总了Java中org.openflow.protocol.action.OFActionOutput类的典型用法代码示例。如果您正苦于以下问题:Java OFActionOutput类的具体用法?Java OFActionOutput怎么用?Java OFActionOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFActionOutput类属于org.openflow.protocol.action包,在下文中一共展示了OFActionOutput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIsFlowModAllowedSimple
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testIsFlowModAllowedSimple(){
OFFlowMod flow = new OFFlowMod();
OFMatch match = new OFMatch();
match.setInputPort((short)1);
match.setDataLayerVirtualLan((short)1000);
match.setWildcards(match.getWildcardObj().matchOn(Flag.DL_VLAN));
match.setWildcards(match.getWildcardObj().matchOn(Flag.IN_PORT));
flow.setMatch(match);
List<OFAction> actions = new ArrayList<OFAction>();
OFActionVirtualLanIdentifier setVid = new OFActionVirtualLanIdentifier();
setVid.setVirtualLanIdentifier((short)102);
OFActionOutput output = new OFActionOutput();
output.setPort((short)2);
actions.add(setVid);
actions.add(output);
flow.setActions(actions);
List <OFFlowMod> flows = slicer.allowedFlows(flow);
assertTrue("flows is the right size", flows.size() == 1);
assertEquals("flow was allowed and matches", flow, flows.get(0));
}
示例2: verifyPacketOut
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
protected void verifyPacketOut(OFPacketOut po,
Ethernet eth,
int expectedBufferId,
int expectedInPort,
int expectedOutPort,
Short transportVlan,
ZoneVlanMode inVlanMode,
ZoneVlanMode outVlanMode)
{
assertEquals(curTestId, expectedInPort, po.getInPort());
assertEquals(curTestId, expectedBufferId, po.getBufferId());
if (outVlanMode == ZoneVlanMode.UNTAGGED)
eth.setVlanID(Ethernet.VLAN_UNTAGGED);
else
eth.setVlanID(transportVlan);
assertArrayEquals(curTestId, eth.serialize(), po.getPacketData());
List<OFAction> actions = po.getActions();
assertEquals(curTestId, 1, actions.size());
OFActionOutput expectedAction =
new OFActionOutput((short)expectedOutPort, (short)0xffff);
assertEquals(curTestId, expectedAction, actions.get(0));
}
示例3: receive
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.PACKET_OUT);
po.setBufferId(pi.getBufferId())
.setInPort(pi.getInPort());
// set actions
OFActionOutput action = new OFActionOutput()
.setPort(OFPort.OFPP_FLOOD.getValue());
po.setActions(Collections.singletonList((OFAction)action));
po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
// set data if is is included in the packetin
if (pi.getBufferId() == OFPacketOut.BUFFER_ID_NONE) {
byte[] packetData = pi.getPacketData();
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength() + packetData.length));
po.setPacketData(packetData);
} else {
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength()));
}
try {
sw.write(po, cntx);
} catch (IOException e) {
log.error("Failure writing PacketOut", e);
}
return Command.CONTINUE;
}
示例4: testFloodNoBufferId
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testFloodNoBufferId() throws Exception {
// build our expected flooded packetOut
OFPacketOut po = ((OFPacketOut) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT))
.setActions(Arrays.asList(new OFAction[] {new OFActionOutput().setPort(OFPort.OFPP_FLOOD.getValue())}))
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(this.testPacketSerialized);
po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLengthU()
+ this.testPacketSerialized.length);
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
Capture<FloodlightContext> bc1 = new Capture<FloodlightContext>(CaptureType.ALL);
mockSwitch.write(capture(wc1), capture(bc1));
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assertEquals(po, m);
}
示例5: testFloodBufferId
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testFloodBufferId() throws Exception {
MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
this.packetIn.setBufferId(10);
// build our expected flooded packetOut
OFPacketOut po = ((OFPacketOut) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT))
.setActions(Arrays.asList(new OFAction[] {new OFActionOutput().setPort(OFPort.OFPP_FLOOD.getValue())}))
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
.setBufferId(10)
.setInPort((short) 1);
po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLengthU());
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
Capture<FloodlightContext> bc1 = new Capture<FloodlightContext>(CaptureType.ALL);
mockSwitch.write(capture(wc1), capture(bc1));
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assertEquals(po, m);
}
示例6: testFlood
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testFlood() throws Exception {
// build our expected flooded packetOut
OFPacketOut po = new OFPacketOut()
.setActions(Arrays.asList(new OFAction[] {new OFActionOutput().setPort(OFPort.OFPP_FLOOD.getValue())}))
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
.setBufferId(-1)
.setInPort((short)1)
.setPacketData(this.testPacketSerialized);
po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLengthU()
+ this.testPacketSerialized.length);
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
expect(mockSwitch.getStringId()).andReturn("00:11:22:33:44:55:66:77").anyTimes();
mockSwitch.write(po, null);
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
// Make sure it's the right listener
listener.receive(mockSwitch, this.packetIn, parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
short result = learningSwitch.getFromPortMap(mockSwitch, Ethernet.toLong(Ethernet.toMACAddress("00:44:33:22:11:00")), (short) 42).shortValue();
verify(mockSwitch);
// Verify the MAC table inside the switch
assertEquals(1, result);
}
示例7: receive
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
OFPacketIn pi = (OFPacketIn) msg;
OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory()
.getMessage(OFType.PACKET_OUT);
po.setBufferId(pi.getBufferId())
.setInPort(pi.getInPort());
// set actions
OFActionOutput action = new OFActionOutput()
.setPort((short) OFPort.OFPP_FLOOD.getValue());
po.setActions(Collections.singletonList((OFAction)action));
po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
// set data if is is included in the packetin
if (pi.getBufferId() == 0xffffffff) {
byte[] packetData = pi.getPacketData();
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength() + packetData.length));
po.setPacketData(packetData);
} else {
po.setLength(U16.t(OFPacketOut.MINIMUM_LENGTH
+ po.getActionsLength()));
}
try {
sw.write(po, cntx);
} catch (IOException e) {
log.error("Failure writing PacketOut", e);
}
return Command.CONTINUE;
}
示例8: testFloodNoBufferId
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testFloodNoBufferId() throws Exception {
// build our expected flooded packetOut
OFPacketOut po = ((OFPacketOut) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT))
.setActions(Arrays.asList(new OFAction[] {new OFActionOutput().setPort(OFPort.OFPP_FLOOD.getValue())}))
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
.setBufferId(-1)
.setInPort((short) 1)
.setPacketData(this.testPacketSerialized);
po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLengthU()
+ this.testPacketSerialized.length);
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
Capture<FloodlightContext> bc1 = new Capture<FloodlightContext>(CaptureType.ALL);
mockSwitch.write(capture(wc1), capture(bc1));
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assert(m.equals(po));
}
示例9: testFloodBufferId
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testFloodBufferId() throws Exception {
MockFloodlightProvider mockFloodlightProvider = getMockFloodlightProvider();
this.packetIn.setBufferId(10);
// build our expected flooded packetOut
OFPacketOut po = ((OFPacketOut) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT))
.setActions(Arrays.asList(new OFAction[] {new OFActionOutput().setPort(OFPort.OFPP_FLOOD.getValue())}))
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
.setBufferId(10)
.setInPort((short) 1);
po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLengthU());
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
Capture<FloodlightContext> bc1 = new Capture<FloodlightContext>(CaptureType.ALL);
mockSwitch.write(capture(wc1), capture(bc1));
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
listener.receive(mockSwitch, this.packetIn,
parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
verify(mockSwitch);
assertTrue(wc1.hasCaptured());
OFMessage m = wc1.getValue();
assert(m.equals(po));
}
示例10: testFlood
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testFlood() throws Exception {
// build our expected flooded packetOut
OFPacketOut po = new OFPacketOut()
.setActions(Arrays.asList(new OFAction[] {new OFActionOutput().setPort(OFPort.OFPP_FLOOD.getValue())}))
.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
.setBufferId(-1)
.setInPort((short)1)
.setPacketData(this.testPacketSerialized);
po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLengthU()
+ this.testPacketSerialized.length);
// Mock up our expected behavior
IOFSwitch mockSwitch = createMock(IOFSwitch.class);
expect(mockSwitch.getStringId()).andReturn("00:11:22:33:44:55:66:77").anyTimes();
mockSwitch.write(po, null);
// Start recording the replay on the mocks
replay(mockSwitch);
// Get the listener and trigger the packet in
IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
OFType.PACKET_IN).get(0);
// Make sure it's the right listener
listener.receive(mockSwitch, this.packetIn, parseAndAnnotate(this.packetIn));
// Verify the replay matched our expectations
short result = learningSwitch.getFromPortMap(mockSwitch, Ethernet.toLong(Ethernet.toMACAddress("00:44:33:22:11:00")), (short) 42).shortValue();
verify(mockSwitch);
// Verify the MAC table inside the switch
assertEquals(1, result);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:33,代码来源:LearningSwitchTest.java
示例11: testExpandedFlowStats
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
@Test
public void testExpandedFlowStats(){
cache = new FlowStatCache(fsfw);
OFFlowMod mod = new OFFlowMod();
OFMatch match = new OFMatch();
match.setDataLayerVirtualLan((short)300);
match.setWildcards(match.getWildcardObj().matchOn(Flag.DL_VLAN));
mod.setMatch(match);
List<OFAction> actions = new ArrayList<OFAction>();
OFActionOutput output = new OFActionOutput();
output.setPort((short)65533);
actions.add(output);
mod.setActions(actions);
List<OFFlowMod> mods = slicerExpanded.allowedFlows(mod);
cache.addFlowMod(sw.getId(), slicerExpanded.getSliceName(), mod, mods);
log.error("Sending: " + expandedStats.size() + " flow stats!");
cache.setFlowCache(sw.getId(), expandedStats);
List<OFStatistics> slicedStats = cache.getSlicedFlowStats(sw.getId(), slicerExpanded.getSliceName());
assertNotNull("Sliced Stats with no allowed stats returend ok", slicedStats);
assertEquals("Sliced stats", 6, slicedStats.size());
log.error(slicedStats.get(0).toString());
OFFlowStatisticsReply flowStat = (OFFlowStatisticsReply) slicedStats.get(0);
assertEquals("flowStat byte count is correct", 4L,flowStat.getByteCount());
assertEquals("flowStat packet count is correct", 4L,flowStat.getPacketCount());
}
示例12: init
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
/**
* Adds flow for given switch, outgoing port, and DC switch port. Constructs {@link OFMatch} and instructs switch
* to send all packets from the given interface to dcPort interface
* @param sw
* @param floodlightProvider
* @param cntx
* @param dcPort
* @param inetPort
*/
public static void init(IOFSwitch sw, IFloodlightProviderService floodlightProvider, FloodlightContext cntx, short dcPort, short inetPort) {
logger.debug("init(IOFSwitch,IFloodlightProviderService,FloodlightContext,short OFPacketIn) begin");
//floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
// Create new match
OFMatch match = new OFMatch();
match.setInputPort(inetPort);
match.setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_IN_PORT);
flowMod.setMatch(match);
flowMod.setCommand(OFFlowMod.OFPFC_ADD);
flowMod.setIdleTimeout((short) 0);
flowMod.setHardTimeout((short) 0);
flowMod.setPriority((short) 10);
flowMod.setBufferId(OFPacketOut.BUFFER_ID_NONE);
flowMod.setFlags((short) 1);
List<OFAction> actions = new ArrayList<>();
actions.add(new OFActionOutput().setPort(dcPort));
flowMod.setActions(actions);
flowMod.setLengthU(OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH);
logger.debug("Modyfing to rule {}", flowMod.toString());
try {
sw.write(flowMod, cntx);
sw.flush();
logger.debug(String.format("Added return rule from port %d to port %d (to switch %s)", inetPort, dcPort, sw.getStringId()));
} catch (IOException ex) {
logger.error(String.format("Error while adding return flow rule (in port %d, out port %d) to switch %s", inetPort, dcPort, sw.getStringId()), ex);
}
logger.debug("init(IOFSwitch,IFloodlightProviderService,FloodlightContext,short OFPacketIn) end");
}
示例13: testAllowedPacketOut
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
/**
* tests packetOut event slicing
*/
@Test
public void testAllowedPacketOut(){
OFPacketOut out = new OFPacketOut();
List<OFAction> actions = new ArrayList<OFAction>();
OFActionOutput output = new OFActionOutput();
output.setType(OFActionType.OUTPUT);
output.setPort((short)1);
actions.add(output);
out.setActions(actions);
Ethernet pkt = new Ethernet();
pkt.setVlanID((short)1000);
pkt.setDestinationMACAddress("aa:bb:cc:dd:ee:ff");
pkt.setSourceMACAddress("ff:ee:dd:cc:bb:aa");
pkt.setEtherType((short)35020);
out.setPacketData(pkt.serialize());
List<OFMessage> outPackets = slicer.allowedPacketOut(out);
assertTrue("OutPacket size is correct, expected 1 got " + outPackets.size(), outPackets.size() == 1);
pkt.setVlanID((short)2000);
out.setPacketData(pkt.serialize());
outPackets = slicer.allowedPacketOut(out);
assertTrue("Packet out was denied", outPackets.size() == 0);
}
示例14: revertApplyFm
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
private Tuple<Tuple<OVXFlowMod, List<PlumbingFlowMod>>, Integer> revertApplyFm(
Tuple<Tuple<OVXFlowMod, List<PlumbingFlowMod>>, Integer> fmTuple,
PlumbingFlowMod pmod) {
OVXFlowMod ofm = fmTuple.first.first;
Integer hop = fmTuple.second;
// match
OFMatch newMatch =
PolicyCompositionUtil.
intersectMatchIgnoreInport(pmod.getMatch(),
PolicyCompositionUtil.
actRevertMatch(ofm.getMatch(),
pmod.getActions()));
ofm.setMatch(newMatch);
// action
for (OFAction action : pmod.getActions()) {
if (action instanceof OFActionOutput) {
continue;
}
ofm.getActions().add(action);
ofm.setLengthU(ofm.getLengthU() + action.getLengthU());
}
// priority
ofm.setPriority(
(short) (pmod.getPriority() * vanillaPow(PolicyCompositionUtil.SEQUENTIAL_SHIFT, hop)
+ ofm.getPriority()));
return new Tuple<Tuple<OVXFlowMod, List<PlumbingFlowMod>>, Integer>(fmTuple.first, hop + 1);
}
示例15: actApplyMatchWithInportChange
import org.openflow.protocol.action.OFActionOutput; //导入依赖的package包/类
private OFMatch actApplyMatchWithInportChange(OFMatch match,
List<OFAction> actions) {
OFMatch m = match.clone();
for (OFAction action : actions) {
if (action instanceof OFActionNetworkLayerDestination) {
OFActionNetworkLayerDestination modNwDst =
(OFActionNetworkLayerDestination) action;
m.setWildcards(m.getWildcards() & ~OFMatch.OFPFW_NW_DST_MASK);
m.setNetworkDestination(modNwDst.getNetworkAddress());
} else if (action instanceof OFActionDataLayerSource) {
OFActionDataLayerSource modDataSrc =
(OFActionDataLayerSource) action;
m.setWildcards(m.getWildcards() & ~OFMatch.OFPFW_DL_SRC);
m.setDataLayerSource(modDataSrc.getDataLayerAddress());
} else if (action instanceof OFActionDataLayerDestination) {
OFActionDataLayerDestination modDataDst =
(OFActionDataLayerDestination) action;
m.setWildcards(m.getWildcards() & ~OFMatch.OFPFW_DL_DST);
m.setDataLayerDestination(modDataDst.getDataLayerAddress());
} else if (action instanceof OFActionOutput) {
short outport = ((OFActionOutput) action).getPort();
m.setWildcards(m.getWildcards() & ~OFMatch.OFPFW_IN_PORT);
m.setInputPort(this.nextHopPortMap.get(outport));
}
}
return m;
}