请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OFPacketOut类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openflow.protocol.OFPacketOut的典型用法代码示例。如果您正苦于以下问题:Java OFPacketOut类的具体用法?Java OFPacketOut怎么用?Java OFPacketOut使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OFPacketOut类属于org.openflow.protocol包,在下文中一共展示了OFPacketOut类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testAllowedPacketOutALL

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
/**
 * tests packetOut event slicing
 */
@Test
public void testAllowedPacketOutALL(){
	
	OFPacketOut out = new OFPacketOut();
	List<OFAction> actions = new ArrayList<OFAction>();
	OFActionOutput output = new OFActionOutput();
	output.setType(OFActionType.OUTPUT);
	output.setPort(OFPort.OFPP_ALL.getValue());
	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 5 got " + outPackets.size(), outPackets.size() == 5);
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:25,代码来源:VLANSlicerTest.java


示例2: assertPacketOut

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
protected void assertPacketOut(OFMessage ofm, byte[] packetData,
                               Short[] ports) {
    assertNotNull(ofm);
    assertNotNull(ports);
    assertEquals(true, ofm instanceof OFPacketOut);
    OFPacketOut ofpo = (OFPacketOut) ofm;

    List<OFAction> actions = ofpo.getActions();
    assertEquals(ports.length, actions.size());
    HashSet<Short> packetOutPorts = new HashSet<Short>();
    for (OFAction action: actions) {
        assertEquals(true, action instanceof OFActionOutput);
        OFActionOutput a = (OFActionOutput)action;
        packetOutPorts.add(a.getPort());
    }
    Arrays.sort(ports);
    Short[] packetOutPortsArray =
            packetOutPorts.toArray(new Short[0]);
    Arrays.sort(packetOutPortsArray);
    assertArrayEquals(ports, packetOutPortsArray);
    if (packetData != null) {
        // a mismatch here usually indicates that something
        // went wrong with rewriting.
        assertArrayEquals(packetData, ofpo.getPacketData());
    }
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:27,代码来源:ForwardingTest.java


示例3: addPort

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
/**
 * Add physical port port to discovery process.
 * Send out initial LLDP and label it as slow port.
 *
 * @param port the port
 */
public void addPort(final PhysicalPort port) {
    // Ignore ports that are not on this switch
    if (port.getParentSwitch().equals(this.sw)) {
        synchronized (this) {
            this.log.debug("sending init probe to port {}",
                    port.getPortNumber());
            OFPacketOut pkt;
            try {
                pkt = this.createLLDPPacketOut(port);
                this.sendMsg(pkt, this);
                if (useBDDP) {
                    OFPacketOut bpkt = this.createBDDPPacketOut(port);
                    this.sendMsg(bpkt, this);
                }
            } catch (PortMappingException e) {
                log.warn(e.getMessage());
                return;
            }
            this.slowPorts.add(port.getPortNumber());
            this.slowIterator = this.slowPorts.iterator();
        }
    }
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:30,代码来源:SwitchDiscoveryManager.java


示例4: createPacketOut

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
private OFPacketOut createPacketOut() {
	//["packet", {"outport": 1, "protocol": 2, "header_len": 14, "inport": 2, 
	// "dstip": [49, 48, 46, 48, 46, 48, 46, 49], 
	// "srcmac": [99, 101, 58, 97, 56, 58, 100, 100, 58, 99, 102, 58, 49, 99, 58, 97, 101], "dstmac": [99, 101, 58, 97, 54, 58, 99, 51, 58, 100, 100, 58, 56, 57, 58, 99, 51], 
	// "raw": [206, 166, 195, 221, 137, 195, 206, 168, 221, 207, 28, 174, 8, 6, 0, 1, 8, 0, 6, 4, 0, 2, 206, 168, 221, 207, 28, 174, 10, 0, 0, 2, 206, 166, 195, 221, 137, 195, 10, 0, 0, 1], 
	// "payload_len": 42, "switch": 1, "ethtype": 2054, "srcip": [49, 48, 46, 48, 46, 48, 46, 50] }] + TERM_CHAR

	OFPacketOut packetOut = new OFPacketOut();
	packetOut.setBufferId(10);
	packetOut.setInPort((short)2);
	packetOut.setPacketData(new byte[] {28, 8, 6, 0, 1, 8, 0, 6, 4, 0, 2, 28, 10, 0, 0, 2, 10, 0, 0, 1});
	
	BasicFactory factory = new BasicFactory();
	packetOut.setActionFactory(factory.getActionFactory());
	List<OFAction> actions = new ArrayList<OFAction>();
	OFAction action = new OFActionOutput((short)3);
	actions.add(action);
	packetOut.setActions(actions);
	
	return packetOut;
}
 
开发者ID:fp7-netide,项目名称:Engine,代码行数:22,代码来源:TestOFMessageParsing.java


示例5: convertBCastToUcast

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
private OFPacketIn convertBCastToUcast(Ethernet eth,
                                       OFPacketIn pi,
                                       IDevice dst) {
    byte[] dstMac = Ethernet.toByteArray(dst.getMACAddress());
    eth.setDestinationMACAddress(dstMac);
    byte[] serializedPacket = eth.serialize();

    OFPacketIn fakePi =
            ((OFPacketIn) controllerProvider.getOFMessageFactory()
                .getMessage(OFType.PACKET_IN))
                .setInPort(pi.getInPort())
                .setBufferId(OFPacketOut.BUFFER_ID_NONE)
                .setReason(OFPacketInReason.NO_MATCH);
    fakePi.setPacketData(serializedPacket);
    fakePi.setTotalLength((short) serializedPacket.length);
    fakePi.setLength((short)(OFPacketIn.MINIMUM_LENGTH +
                             serializedPacket.length));

    return fakePi;
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:21,代码来源:DhcpManager.java


示例6: doDropFlow

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
@LogMessageDoc(level="ERROR",
        message="Failure writing drop flow mod",
        explanation="An I/O error occured while trying to write a " +
        		"drop flow mod to a switch",
        recommendation=LogMessageDoc.CHECK_SWITCH)
protected void doDropFlow(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
    // initialize match structure and populate it using the packet
    OFMatch match = new OFMatch();
    match.loadFromPacket(pi.getPacketData(), pi.getInPort());
    if (decision.getWildcards() != null) {
        match.setWildcards(decision.getWildcards());
    }

    // Create flow-mod based on packet-in and src-switch
    OFFlowMod fm =
            (OFFlowMod) floodlightProvider.getOFMessageFactory()
                                          .getMessage(OFType.FLOW_MOD);
    List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to
                                                        // drop
    long cookie = AppCookie.makeCookie(FORWARDING_APP_ID, 0);

    fm.setCookie(cookie)
      .setHardTimeout((short) 0)
      .setIdleTimeout((short) 5)
      .setBufferId(OFPacketOut.BUFFER_ID_NONE)
      .setMatch(match)
      .setActions(actions)
      .setLengthU(OFFlowMod.MINIMUM_LENGTH); // +OFActionOutput.MINIMUM_LENGTH);

    try {
        if (log.isDebugEnabled()) {
            log.debug("write drop flow-mod sw={} match={} flow-mod={}",
                      new Object[] { sw, match, fm });
        }
        messageDamper.write(sw, fm, cntx);
    } catch (IOException e) {
        log.error("Failure writing drop flow mod", e);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:40,代码来源:Forwarding.java


示例7: receive

import org.openflow.protocol.OFPacketOut; //导入依赖的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;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:32,代码来源:Hub.java


示例8: doDropFlow

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
/**
     * Writes a FlowMod to a switch that inserts a drop flow.
     * @param sw The switch to write the FlowMod to.
     * @param pi The corresponding OFPacketIn. Used to create the OFMatch structure.
     * @param cntx The FloodlightContext that gets passed to the switch.
     */
    protected void doDropFlow(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
        if (log.isTraceEnabled()) {
            log.trace("doDropFlow pi={} srcSwitch={}",
                    new Object[] { pi, sw });
        }

        if (sw == null) {
            log.warn("Switch is null, not installing drop flowmod for PacketIn {}", pi);
            return;
        }

        // Create flow-mod based on packet-in and src-switch
        OFFlowMod fm =
            (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
        OFMatch match = new OFMatch();
        match.loadFromPacket(pi.getPacketData(), pi.getInPort());
        List<OFAction> actions = new ArrayList<OFAction>(); // no actions = drop
        long cookie = AppCookie.makeCookie(APP_ID, 0);
        fm.setCookie(cookie)
        .setIdleTimeout(ForwardingBase.FLOWMOD_DEFAULT_IDLE_TIMEOUT)
        .setHardTimeout(ForwardingBase.FLOWMOD_DEFAULT_HARD_TIMEOUT)
        .setBufferId(OFPacketOut.BUFFER_ID_NONE)
        .setMatch(match)
        .setActions(actions)
        .setLengthU(OFFlowMod.MINIMUM_LENGTH);
//        fm.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
        try {
            if (log.isTraceEnabled()) {
                log.trace("write drop flow-mod srcSwitch={} match={} " +
                          "pi={} flow-mod={}",
                          new Object[] {sw, match, pi, fm});
            }
            sw.write(fm, cntx);
        } catch (IOException e) {
            log.error("Failure writing drop flow mod", e);
        }
        return;
    }
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:45,代码来源:VirtualNetworkFilter.java


示例9: initDefaultFlowMod

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
/**
 * Sets defaults for an OFFlowMod
 * @param fm The OFFlowMod to set defaults for
 * @param entryName The name of the entry. Used to compute the cookie.
 */
public static void initDefaultFlowMod(OFFlowMod fm, String entryName) {
    fm.setIdleTimeout((short) 0);   // infinite
    fm.setHardTimeout((short) 0);   // infinite
    fm.setBufferId(OFPacketOut.BUFFER_ID_NONE);
    fm.setCommand((short) 0);
    fm.setFlags((short) 0);
    fm.setOutPort(OFPort.OFPP_NONE.getValue());
    fm.setCookie(computeEntryCookie(fm, 0, entryName));  
    fm.setPriority(Short.MAX_VALUE);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:16,代码来源:StaticFlowEntries.java


示例10: testFloodNoBufferId

import org.openflow.protocol.OFPacketOut; //导入依赖的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);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:36,代码来源:HubTest.java


示例11: testFloodBufferId

import org.openflow.protocol.OFPacketOut; //导入依赖的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);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:36,代码来源:HubTest.java


示例12: testFlood

import org.openflow.protocol.OFPacketOut; //导入依赖的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:JianqingJiang,项目名称:QoS-floodlight,代码行数:33,代码来源:LearningSwitchTest.java


示例13: DhcpDiscoveryRequestOFPacketIn

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(MACAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    return (((OFPacketIn)OFMessageFactory
            .getMessage(OFType.PACKET_IN))
            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
            .setInPort((short) 1)
            .setPacketData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH)
            .setTotalLength((short)serializedPacket.length));
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:16,代码来源:PacketFactory.java


示例14: receive

import org.openflow.protocol.OFPacketOut; //导入依赖的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;
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:32,代码来源:Hub.java


示例15: doDropFlow

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
/**
 * Writes a FlowMod to a switch that inserts a drop flow.
 * @param sw The switch to write the FlowMod to.
 * @param pi The corresponding OFPacketIn. Used to create the OFMatch structure.
 * @param cntx The FloodlightContext that gets passed to the switch.
 */
protected void doDropFlow(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    if (log.isTraceEnabled()) {
        log.trace("doDropFlow pi={} srcSwitch={}",
                new Object[] { pi, sw });
    }

    if (sw == null) {
        log.warn("Switch is null, not installing drop flowmod for PacketIn {}", pi);
        return;
    }

    // Create flow-mod based on packet-in and src-switch
    OFFlowMod fm = 
        (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
    OFMatch match = new OFMatch();
    match.loadFromPacket(pi.getPacketData(), pi.getInPort());
    List<OFAction> actions = new ArrayList<OFAction>(); // no actions = drop
    long cookie = AppCookie.makeCookie(APP_ID, 0);
    fm.setCookie(cookie)
    .setIdleTimeout(ForwardingBase.FLOWMOD_DEFAULT_IDLE_TIMEOUT)
    .setHardTimeout(ForwardingBase.FLOWMOD_DEFAULT_HARD_TIMEOUT)
    .setBufferId(OFPacketOut.BUFFER_ID_NONE)
    .setMatch(match)
    .setActions(actions)
    .setLengthU(OFFlowMod.MINIMUM_LENGTH);
    fm.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
    try {
        if (log.isTraceEnabled()) {
            log.trace("write drop flow-mod srcSwitch={} match={} " + 
                      "pi={} flow-mod={}",
                      new Object[] {sw, match, pi, fm});
        }
        sw.write(fm, cntx);
    } catch (IOException e) {
        log.error("Failure writing drop flow mod", e);
    }
    return;
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:45,代码来源:VirtualNetworkFilter.java


示例16: testFloodNoBufferId

import org.openflow.protocol.OFPacketOut; //导入依赖的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));
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:36,代码来源:HubTest.java


示例17: testFloodBufferId

import org.openflow.protocol.OFPacketOut; //导入依赖的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));
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:36,代码来源:HubTest.java


示例18: testFlood

import org.openflow.protocol.OFPacketOut; //导入依赖的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


示例19: createARPPkt

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
private OFPacketIn createARPPkt(String hostMACStr, String hostIpStr,
                                String vIpStr) {
    int vIP = IPv4.toIPv4Address(vIpStr);
    ARP arprequestVIP = new ARP()
    .setHardwareType(ARP.HW_TYPE_ETHERNET)
    .setProtocolType(ARP.PROTO_TYPE_IP)
    .setHardwareAddressLength((byte) 6)
    .setProtocolAddressLength((byte) 4)
    .setOpCode(ARP.OP_REQUEST)
    .setSenderHardwareAddress(Ethernet.toMACAddress(hostMACStr))
    .setSenderProtocolAddress(IPv4.toIPv4AddressBytes(hostIpStr))
    .setTargetHardwareAddress(Ethernet.toMACAddress("FF:FF:FF:FF:FF:FF"))
    .setTargetProtocolAddress(vIP);

    IPacket arprequestPacketVIP = new Ethernet()
    .setSourceMACAddress(hostMACStr)
    .setDestinationMACAddress("FF:FF:FF:FF:FF:FF")
    .setEtherType(Ethernet.TYPE_ARP)
    .setPayload(arprequestVIP);
    byte[] arpRequestSerializedVIP = arprequestPacketVIP.serialize();

    OFPacketIn packetInARPRequestVIP =
            ((OFPacketIn) (new BasicFactory()).getMessage(OFType.PACKET_IN))
            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
            .setInPort((short) 1)
            .setPacketData(arpRequestSerializedVIP)
            .setReason(OFPacketInReason.NO_MATCH)
            .setTotalLength((short) arpRequestSerializedVIP.length);
    return packetInARPRequestVIP;
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:31,代码来源:VirtualRoutingTest.java


示例20: clonePacketOut

import org.openflow.protocol.OFPacketOut; //导入依赖的package包/类
private OFPacketOut clonePacketOut(OFPacketOut packet){
	OFPacketOut newOut = new OFPacketOut();
	newOut.setActions(packet.getActions());
	newOut.setPacketData(packet.getPacketData().clone());
	newOut.setBufferId(packet.getBufferId());
	newOut.setInPort(packet.getInPort());
	newOut.setLength(packet.getLength());
	newOut.setType(packet.getType());
	newOut.setXid(packet.getXid());
	return newOut;
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:12,代码来源:VLANSlicer.java



注:本文中的org.openflow.protocol.OFPacketOut类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Example类代码示例发布时间:2022-05-21
下一篇:
Java PackageInstaller类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap