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


Java PacketContext.send方法代码示例

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


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

示例1: process

import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
@Override
public void process(PacketContext context) {
	if (context.isHandled()) {
		return;
	}
	InboundPacket pkt = context.inPacket();
	Ethernet ethPkt = pkt.parsed();

	if (ethPkt == null) {
		return;
	}

	if (ethPkt.getEtherType() == EtherType.ARP.ethType().toShort()) {
		context.treatmentBuilder().setOutput(PortNumber.FLOOD);
		context.send();
	}
}
 
开发者ID:ShakhMoves,项目名称:ShakhSDVPN,代码行数:18,代码来源:ARPHandler.java

示例2: packetOut

import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
private void packetOut(PacketContext context, PortNumber portNumber) {
    context.treatmentBuilder().setOutput(portNumber);
    context.send();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:SimpleLoadBalancer.java

示例3: actLikeSwitch

import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
/**
 * Ensures packet is of required type. Obtain the PortNumber associated with the inPackets DeviceId.
 * If this port has previously been learned (in initMacTable method) build a flow using the packet's
 * out port, treatment, destination, and other properties.  Send the flow to the learned out port.
 * Otherwise, flood packet to all ports if out port is not learned.
 *
 * @param pc the PacketContext object passed through from activate() method
 */
public void actLikeSwitch(PacketContext pc) {

    /*
     * Ensures the type of packet being processed is only of type IPV4 (not LLDP or BDDP).  If it is not, return
     * and do nothing with the packet. actLikeSwitch can only process IPV4 packets.
     */
    Short type = pc.inPacket().parsed().getEtherType();
    if (type != Ethernet.TYPE_IPV4) {
        return;
    }

    /*
     * Learn the destination, source, and output port of the packet using a ConnectPoint and the
     * associated macTable.  If there is a known port associated with the packet's destination MAC Address,
     * the output port will not be null.
     */
    ConnectPoint cp = pc.inPacket().receivedFrom();
    Map<MacAddress, PortNumber> macTable = macTables.get(cp.deviceId());
    MacAddress srcMac = pc.inPacket().parsed().getSourceMAC();
    MacAddress dstMac = pc.inPacket().parsed().getDestinationMAC();
    macTable.put(srcMac, cp.port());
    PortNumber outPort = macTable.get(dstMac);

    /*
     * If port is known, set pc's out port to the packet's learned output port and construct a
     * FlowRule using a source, destination, treatment and other properties. Send the FlowRule
     * to the designated output port.
     */
    if (outPort != null) {
        pc.treatmentBuilder().setOutput(outPort);
        FlowRule fr = DefaultFlowRule.builder()
                .withSelector(DefaultTrafficSelector.builder().matchEthDst(dstMac).build())
                .withTreatment(DefaultTrafficTreatment.builder().setOutput(outPort).build())
                .forDevice(cp.deviceId()).withPriority(PacketPriority.REACTIVE.priorityValue())
                .makeTemporary(60)
                .fromApp(appId).build();

        flowRuleService.applyFlowRules(fr);
        pc.send();
    } else {
    /*
     * else, the output port has not been learned yet.  Flood the packet to all ports using
     * the actLikeHub method
     */
        actLikeHub(pc);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:56,代码来源:LearningSwitchSolution.java

示例4: packetOut

import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
private void packetOut(PacketContext context, PortNumber portNumber, ReactiveForwardMetrics macMetrics) {
    replyPacket(macMetrics);
    context.treatmentBuilder().setOutput(portNumber);
    context.send();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:6,代码来源:ReactiveForwarding.java

示例5: actLikeHub

import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
/**
 * Example method. Floods packet out of all switch ports.
 *
 * @param pc the PacketContext object passed through from activate method
 */
public void actLikeHub(PacketContext pc) {
    pc.treatmentBuilder().setOutput(PortNumber.FLOOD);
    pc.send();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:10,代码来源:LearningSwitchTutorial.java

示例6: actLikeHub

import org.onosproject.net.packet.PacketContext; //导入方法依赖的package包/类
/**
 * Example method. Floods packet out of all switch ports.
 *
 * @param pc the PacketContext object passed through from activate() method
 */
public void actLikeHub(PacketContext pc) {
    pc.treatmentBuilder().setOutput(PortNumber.FLOOD);
    pc.send();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:10,代码来源:LearningSwitchSolution.java


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