当前位置: 首页>>代码示例>>Java>>正文


Java OFPacketOut.setLengthU方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: testFloodNoBufferId

import org.openflow.protocol.OFPacketOut; //导入方法依赖的package包/类
@Test
public void testFloodNoBufferId() throws Exception {
    // build our expected flooded packetOut
    OFPacketOut po = ((OFPacketOut) mockControllerProvider.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<ListenerContext> bc1 = new Capture<ListenerContext>(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 = mockControllerProvider.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:opendaylight,项目名称:archived-net-virt-platform,代码行数:36,代码来源:HubTest.java

示例8: testFloodBufferId

import org.openflow.protocol.OFPacketOut; //导入方法依赖的package包/类
@Test
public void testFloodBufferId() throws Exception {
    MockControllerProvider mockControllerProvider = getMockControllerProvider();
    this.packetIn.setBufferId(10);

    // build our expected flooded packetOut
    OFPacketOut po = ((OFPacketOut) mockControllerProvider.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<ListenerContext> bc1 = new Capture<ListenerContext>(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 = mockControllerProvider.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:opendaylight,项目名称:archived-net-virt-platform,代码行数:36,代码来源:HubTest.java

示例9: 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 = mockControllerProvider.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:opendaylight,项目名称:archived-net-virt-platform,代码行数:33,代码来源:LearningSwitchTest.java

示例10: sendDiscoveryMessage

import org.openflow.protocol.OFPacketOut; //导入方法依赖的package包/类
/**
 * Send link discovery message out of a given switch port. The discovery
 * message may be a standard LLDP or a modified LLDP, where the dst mac
 * address is set to :ff. TODO: The modified LLDP will updated in the future
 * and may use a different eth-type.
 *
 * @param sw
 * @param port
 * @param isStandard
 *            indicates standard or modified LLDP
 * @param isReverse
 *            indicates whether the LLDP was sent as a response
 */
@LogMessageDoc(level = "ERROR",
               message = "Failure sending LLDP out port {port} on switch {switch}",
               explanation = "An I/O error occured while sending LLDP message "
                             + "to the switch.",
               recommendation = LogMessageDoc.CHECK_SWITCH)
protected void sendDiscoveryMessage(long sw, short port,
                                    boolean isStandard, boolean isReverse) {

    // Takes care of all checks including null pointer checks.
    if (!isOutgoingDiscoveryAllowed(sw, port, isStandard, isReverse))
        return;

    IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);
    OFPhysicalPort ofpPort = iofSwitch.getPort(port).toOFPhysicalPort();

    if (log.isTraceEnabled()) {
        log.trace("Sending LLDP packet out of swich: {}, port: {}",
                  HexString.toHexString(sw), port);
    }
    OFPacketOut po = generateLLDPMessage(sw, port, isStandard, isReverse);

    // Add actions
    List<OFAction> actions = getDiscoveryActions(iofSwitch, ofpPort);
    po.setActions(actions);
    short  actionLength = 0;
    Iterator <OFAction> actionIter = actions.iterator();
    while (actionIter.hasNext()) {
        actionLength += actionIter.next().getLength();
    }
    po.setActionsLength(actionLength);

    // po already has the minimum length + data length set
    // simply add the actions length to this.
    po.setLengthU(po.getLengthU() + po.getActionsLength());

    // send
    try {
        iofSwitch.write(po, null);
        iofSwitch.flush();
    } catch (IOException e) {
        log.error("Failure sending LLDP out port {} on switch {}",
                  new Object[] { port, iofSwitch.getStringId() }, e);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:58,代码来源:LinkDiscoveryManager.java

示例11: sendHostProbe

import org.openflow.protocol.OFPacketOut; //导入方法依赖的package包/类
protected boolean sendHostProbe(InetAddress ip, MACAddress mac, long dpid, short port){
	byte[] data;
	
	//Currently, we use ICMPing to probe the host
	// data = generateARPPing(ip);
	data = generateICMPPing(ip, mac);
	
	IOFSwitch sw = floodlightProvider.getSwitch(dpid);
	
       if (sw == null) {
           return false;
       }
       ImmutablePort ofpPort = sw.getPort(port);

       if (ofpPort == null) {
           if (logger.isTraceEnabled()) {
               logger.trace("Null physical port. sw={}, port={}", sw, port);
           }
           return false;
       }

       OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT);
       po.setBufferId(OFPacketOut.BUFFER_ID_NONE);
       po.setInPort(OFPort.OFPP_NONE);

       // set actions
       List<OFAction> actions = new ArrayList<OFAction>();
       actions.add(new OFActionOutput(port, (short) 0));
       po.setActions(actions);
       po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);

       // set data
       po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLength() + data.length);
       po.setPacketData(data);

       // send
       try {
           sw.write(po, null);
           sw.flush();
       } catch (IOException e) {
           logger.error("Failure sending host probe out port {} on switch {}",
                     new Object[]{ port, sw.getStringId() }, e);
           return false;
       }
       return true;
       
}
 
开发者ID:xuraylei,项目名称:floodlight_with_topoguard,代码行数:48,代码来源:TopoloyUpdateChecker.java

示例12: sendDiscoveryMessage

import org.openflow.protocol.OFPacketOut; //导入方法依赖的package包/类
/**
 * Send link discovery message out of a given switch port. The discovery
 * message may be a standard LLDP or a modified LLDP, where the dst mac
 * address is set to :ff. TODO: The modified LLDP will updated in the future
 * and may use a different eth-type.
 *
 * @param sw
 * @param port
 * @param isStandard
 *            indicates standard or modified LLDP
 * @param isReverse
 *            indicates whether the LLDP was sent as a response
 */
@LogMessageDoc(level = "ERROR",
               message = "Failure sending LLDP out port {port} on switch {switch}",
               explanation = "An I/O error occured while sending LLDP message "
                             + "to the switch.",
               recommendation = LogMessageDoc.CHECK_SWITCH)
protected void sendDiscoveryMessage(long sw, short port,
                                    boolean isStandard, boolean isReverse) {

    // Takes care of all checks including null pointer checks.
    if (!isOutgoingDiscoveryAllowed(sw, port, isStandard, isReverse))
        return;

    IOFSwitch iofSwitch = controllerProvider.getSwitches().get(sw);
    OFPhysicalPort ofpPort = iofSwitch.getPort(port);

    if (log.isTraceEnabled()) {
        log.trace("Sending LLDP packet out of swich: {}, port: {}",
                  HexString.toHexString(sw), port);
    }
    OFPacketOut po = generateLLDPMessage(sw, port, isStandard, isReverse);

    // Add actions
    List<OFAction> actions = getDiscoveryActions(iofSwitch, ofpPort);
    po.setActions(actions);
    short  actionLength = 0;
    Iterator <OFAction> actionIter = actions.iterator();
    while (actionIter.hasNext()) {
        actionLength += actionIter.next().getLength();
    }
    po.setActionsLength(actionLength);

    // po already has the minimum length + data length set
    // simply add the actions length to this.
    po.setLengthU(po.getLengthU() + po.getActionsLength());

    // send
    try {
        iofSwitch.write(po, null);
        iofSwitch.flush();
    } catch (IOException e) {
        log.error("Failure sending LLDP out port {} on switch {}",
                  new Object[] { port, iofSwitch.getStringId() }, e);
    }
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:58,代码来源:LinkDiscoveryManager.java

示例13: verifyTunnelLiveness

import org.openflow.protocol.OFPacketOut; //导入方法依赖的package包/类
private void verifyTunnelLiveness(long srcDPID, long dstDPID) {

        if (tunnelManager == null) {
            log.warn("Cannot veirfy tunnel without tunnel manager.");
            return;
        }

        // If the tunnel end-points are not active, there's no point in
        // verifying liveness.
        if (!tunnelManager.isTunnelActiveByDpid(srcDPID)) {
            if (log.isTraceEnabled()) {
                log.trace("Switch {} is not in tunnel active state," +
                        " cannot verify tunnel liveness.", srcDPID);
            }
            return;
        }
        if (!tunnelManager.isTunnelActiveByDpid(dstDPID)) {
            if (log.isTraceEnabled()) {
                log.trace("Switch {} is not in tunnel active state," +
                        " cannot verify tunnel liveness.", dstDPID);
            }
            return;
        }

        // At this point, both endpoints are tunnel active.
        Short srcPort = tunnelManager.getTunnelPortNumber(srcDPID);
        Integer dstIpAddr = tunnelManager.getTunnelIPAddr(dstDPID);

        IOFSwitch iofSwitch = controllerProvider.getSwitches().get(srcDPID);
        if (iofSwitch == null) {
            if (log.isTraceEnabled()) {
                log.trace("Cannot send tunnel LLDP as switch object does " +
                        "not exist for DPID {}", srcDPID);
            }
            return;
        }

        // Generate and send an LLDP to the tunnel port of srcDPID
        OFPacketOut po = linkDiscovery.generateLLDPMessage(srcDPID,
                                                           srcPort.shortValue(),
                                                           true, false);

        List<OFAction> actions = new ArrayList<OFAction>();
        short actionsLength = 0;

        // Set the tunnel destination action
        OFActionTunnelDstIP tunnelDstAction =
                new OFActionTunnelDstIP(dstIpAddr.intValue());
        actions.add(tunnelDstAction);
        actionsLength += tunnelDstAction.getLengthU();

        // Set the output port action
        OFActionOutput outputAction = new OFActionOutput();
        outputAction.setPort(srcPort.shortValue());
        actions.add(outputAction);
        actionsLength += outputAction.getLengthU();

        po.setActions(actions);
        po.setActionsLength(actionsLength);
        po.setLengthU(po.getLengthU() + actionsLength);

        try {
            iofSwitch.write(po, null);
            iofSwitch.flush();
            // once the LLDP is written, add the tunnel event to the
            // checkTunnelLivenessQueue
            OrderedNodePair onp = new OrderedNodePair(srcDPID, dstDPID);
            this.tunnelVerificationQueue.add(onp);
        } catch (IOException e) {
            log.error("Failure sending LLDP out port {} on switch {}",
                      new Object[] { srcPort, iofSwitch.getStringId() }, e);
        }
    }
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:74,代码来源:BetterTopologyManager.java


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